#include "stdafx.h"
#include "..\..\include\homm3.h"
#include "..\..\include\HoMM3_Dlg.cpp"
Patcher* _P;
PatcherInstance* _PI;
#define o_Dlg_ExpaMon 0x845880
_DlgStaticTextPcx8ed_* statbar = NULL; // текст подсказки
int __stdcall New_Dlg_ExpaMon_Proc(_Dlg_* this_, _EventMsg_* msg)
{
int r = this_->DefProc(msg);
return r;
}
// создание окна экспы монстров для ERA (0x845880) // основная функция
void New_Dlg_ExpaMon(_int_ Mon, _int_ Num, _int_ Expo, _ptr_ CRExpo, _int_ Changing)
{
int dop_str = *(int*)(o_Dlg_ExpaMon +52);
int art_num = *(int*)(o_Dlg_ExpaMon +88);
int is_art = 0;
if (CRExpo && CALL_1(_int_, __thiscall, 0x7279C0, CRExpo)){
is_art = 1;
if (art_num < 1)
art_num = 1;
}
if (is_art)
dop_str -= 1;
if (dop_str >= 8){
dop_str = 8;
is_art = 0;
}
int x = 800;
int y = 252 +16*(dop_str-is_art) +53*Round(dop_str/2);
_Dlg_* dlg = _CustomDlg_::Create(-1, -1, x, y, DF_SCREENSHOT | DF_SHADOW, New_Dlg_ExpaMon_Proc);
create_standard_background(dlg, 1);
sprintf(o_TextBuffer, "%d, %d, %d", dop_str, art_num, is_art);
dlg->AddItem(_DlgStaticText_::Create(16, 16, 200, 20, o_TextBuffer, "smalfont.fnt", 1, 111, ALIGN_H_LEFT | ALIGN_V_TOP, 0));
// Добавляем кнопку OK (id = 30722)
dlg->AddItem(_DlgStaticPcx8_::Create(dlg->width -31 -52, dlg->height - 31 -40, 0, "Box64x30.pcx"));
dlg->AddItem(_DlgButton_::Create(dlg->width -30 -52, dlg->height -30 -40, 64, 30, 30722, "iOkay.def", 0, 1, 1, 28, 2));
// Добавляем кнопку просмотра улучшенного (id = 1)
dlg->AddItem(_DlgStaticPcx8_::Create(dlg->width -31 -122, dlg->height - 31 -40, 0, "Box64x30.pcx"));
dlg->AddItem(_DlgButton_::Create(dlg->width -30 -122, dlg->height -30 -40, 64, 30, 1, "DlgUpExp.def", 0, 1, 1, 0, 2));
b_MouseMan_SetCursor(0,0);
// заголовок диалога (id = 3)
sprintf(o_TextBuffer, "%s", *(int*)o_Dlg_ExpaMon);
dlg->AddItem(_DlgStaticText_::Create(0, 15, dlg->width, 30, o_TextBuffer, "bigfont.fnt", 7, 3, ALIGN_H_CENTER | ALIGN_V_TOP, 0));
// нижнее описание монстра красным (id = 4)
sprintf(o_TextBuffer, "%s", *(int*)(o_Dlg_ExpaMon +4));
dlg->AddItem(_DlgStaticText_::Create(18, dlg->height - 82, dlg->width -164, 44, o_TextBuffer, "bigfont.fnt", 27, 4, ALIGN_H_LEFT | ALIGN_V_BOTTOM, 0));
// картинка и рамка монстра (id = 5, 6)
dlg->AddItem(_DlgStaticDef_::Create(18, 35, 5, "twcrport.def", Mon +2, 0, 0x12));
dlg->AddItem(_DlgStaticDef_::Create(18, 35, 6, "twcrport.def", 1, 0, 0x12));
// название артефакта и рамка для него (id = 7,8)
dlg->AddItem(_DlgStaticText_::Create(18, 100, 60, 15, "Артефакт", "medfont.fnt", 1, 7, ALIGN_H_LEFT | ALIGN_V_TOP, 0));
dlg->AddItem(_DlgStaticPcx8_::Create(23, 117, 8, "artbckg.pcx"));
// артефакт и цифры его кол-ва (id = 9)
if (art_num > 0){
dlg->AddItem(_DlgStaticDef_::Create(25, 119, 9, "Artifact.def", 156, 0, 0x12)); // рамка монстра (id = 9)
sprintf(o_TextBuffer, "%d", art_num);
dlg->AddItem(_DlgStaticText_::Create(47, 142, 20, 20, o_TextBuffer, "tiny.fnt", 1, 9, ALIGN_H_RIGHT | ALIGN_V_BOTTOM, 0));
}
// верхние названия
for (int i = 0; i <= 10; i++){
dlg->AddItem(_DlgStaticText_::Create(168 +56*i, 34, 58, 15,
CALL_3 (char*, __cdecl, 0x77710B, 1+i, 1, 0x847D88),
"smalfont.fnt", 7, 10, ALIGN_H_LEFT | ALIGN_V_TOP, 0));
}
// элементы заполнения колонок id = 11...(26)
int y0 = 50; int yy = 16;
for (int i = 0; i < (8+dop_str); i++){
sprintf(o_TextBuffer, "%s", *(int*)(*(int*)(o_Dlg_ExpaMon +36)+4*i));
dlg->AddItem(_DlgStaticText_::Create(80, y0 + yy*i, 80, 15, o_TextBuffer, "smalfont.fnt", 7, 11+i, ALIGN_H_LEFT | ALIGN_V_TOP, 0));
}
int x0 = 168; int xx = 56;
char text[16];
for (char i = 0; i < (8+dop_str); i++){
sprintf(o_TextBuffer, "%s", *(int*)(*(int*)(o_Dlg_ExpaMon +44)+4*i));
for (char j = 0; j < 11; j++){
for (char k = 0; k < 8; k++){
if (*(char*)(*(int*)(*(int*)(o_Dlg_ExpaMon +44)+4*i) +j*8 +k) != ' ')
text[k] = *(char*)(*(int*)(*(int*)(o_Dlg_ExpaMon +44)+4*i) +j*8 +k);
else {
for (char s = k; s < 16; s++){
text[s] = ' ';
}
k = 7;
}
}
dlg->AddItem(_DlgStaticText_::Create(x0 + xx*j, y0 + yy*i, 54, 15, text, "smalfont.fnt", 1, 30+i, ALIGN_H_LEFT | ALIGN_V_TOP, 0));
}
}
// нижние картинки с дефами (id 50 ... )
int xd = 18; int xxd = 366;
int yd = 50 +8 +16*8 +16*dop_str;
int yyd = 53;
if (dop_str > 0 || art_num > 0){
for (int i = 0; i < (dop_str + is_art); i++){
dlg->AddItem(_DlgStaticDef_::Create(xd, yd, 50+i*2, "Expa_Mon.def", *(int*)(*(int*)(o_Dlg_ExpaMon +20)+4*i), 0, 0x12));
sprintf(o_TextBuffer, "%s", *(int*)(*(int*)(o_Dlg_ExpaMon +16)+4*i));
dlg->AddItem(_DlgStaticText_::Create(xd+54, yd, 350, 50, o_TextBuffer, "smalfont.fnt", 7, 51+i*2, ALIGN_H_LEFT | ALIGN_V_CENTER, 0));
if (xd == 18)
xd = 400;
else xd = 18;
if ( (i+10)%2 == 1 )
yd += 53;
}
}
dlg->Run();
dlg->Destroy(TRUE);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_int_ __stdcall New_Dlg_ExpaMon_H(HiHook* hook, _int_ Mon, _int_ Num, _int_ Expo, _ptr_ CRExpo, _int_ Changing)
{
CALL_5(void, __cdecl, hook->GetDefaultFunc(), Mon, Num, Expo, CRExpo, Changing);
// sprintf(o_TextBuffer, "%d, %d, %d, %d, %d", Mon, Num, Expo, CRExpo, Changing);
// b_MsgBox(o_TextBuffer, 1);
New_Dlg_ExpaMon(Mon, Num, Expo, CRExpo, Changing);
return 1;
}
int Y_ChangeBmp_To_DefFrame()
{
_PI->WriteDword(0x792048, 0); // E_ART.bmp
int sdv = 7;
_PI->WriteDword((0x71F86F +sdv), 1); // E_SHOOTN.bmp
_PI->WriteDword((0x71F89F +sdv), 2); // N_SHOOTN.bmp
_PI->WriteDword((0x71F94C +sdv), 3); // E_CASTER.bmp
_PI->WriteDword((0x71F97C +sdv), 4); // N_CASTER.bmp
_PI->WriteDword((0x71FA2D +sdv), 5); // E_FEAR.bmp
_PI->WriteDword((0x71FA5E +sdv), 6); // N_FEAR.bmp
_PI->WriteDword((0x71FB0B +sdv), 7); // E_RETAIL1.bmp
_PI->WriteDword((0x71FB3B +sdv), 8); // N_RETAIL1.bmp
_PI->WriteDword((0x71FBE8 +sdv), 9); // E_DEFBON.bmp
_PI->WriteDword((0x71FC18 +sdv), 10); // N_DEFBON.bmp
_PI->WriteDword((0x71FCC5 +sdv), 11); // E_DWARF.bmp
_PI->WriteDword((0x71FCF5 +sdv), 12); // N_DWARF.bmp
_PI->WriteDword((0x71FDA8 +sdv), 13); // E_GOLEM.bmp
_PI->WriteDword((0x71FDD8 +sdv), 14); // N_GOLEM.bmp
_PI->WriteDword((0x71FE89 +sdv), 15); // E_DIST.bmp
_PI->WriteDword((0x71FEBA +sdv), 16); // N_DIST.bmp
_PI->WriteDword((0x71FF6B +sdv), 17); // E_OBST.bmp
_PI->WriteDword((0x71FF9C +sdv), 18); // N_OBST.bmp
_PI->WriteDword((0x72007B +sdv), 19); // E_FLY.bmp
_PI->WriteDword((0x7200AC +sdv), 20); // N_FLY.bmp
_PI->WriteDword((0x720156 +sdv), 21); // E_SHOOT.bmp
_PI->WriteDword((0x720187 +sdv), 22); // N_SHOOT.bmp
_PI->WriteDword((0x720231 +sdv), 23); // E_BREATH.bmp
_PI->WriteDword((0x720262 +sdv), 24); // N_BREATH.bmp
_PI->WriteDword((0x72030C +sdv), 25); // E_ALIVE.bmp
_PI->WriteDword((0x72033D +sdv), 26); // N_ALIVE.bmp
_PI->WriteDword((0x7203E7 +sdv), 27); // E_KING1.bmp
_PI->WriteDword((0x720418 +sdv), 28); // N_KING1.bmp
_PI->WriteDword((0x7204C2 +sdv), 29); // E_KING2.bmp
_PI->WriteDword((0x7204F3 +sdv), 30); // N_KING2.bmp
_PI->WriteDword((0x72059D +sdv), 31); // E_KING3.bmp
_PI->WriteDword((0x7205CE +sdv), 32); // N_KING3.bmp
_PI->WriteDword((0x720678 +sdv), 33); // E_MIND.bmp
_PI->WriteDword((0x7206A9 +sdv), 34); // N_MIND.bmp
_PI->WriteDword((0x720753 +sdv), 35); // E_MELEE.bmp
_PI->WriteDword((0x720784 +sdv), 36); // N_MELEE.bmp
_PI->WriteDword((0x72082E +sdv), 37); // E_FIRE.bmp
_PI->WriteDword((0x72085F +sdv), 38); // N_FIRE.bmp
_PI->WriteDword((0x720909 +sdv), 39); // E_DOUBLE.bmp
_PI->WriteDword((0x72093A +sdv), 40); // N_DOUBLE.bmp
_PI->WriteDword((0x7209E4 +sdv), 41); // E_RETAIL.bmp
_PI->WriteDword((0x720A15 +sdv), 42); // N_RETAIL.bmp
_PI->WriteDword((0x720ABF +sdv), 43); // E_MORAL.bmp
_PI->WriteDword((0x720AF0 +sdv), 44); // N_MORAL.bmp
_PI->WriteDword((0x720B9A +sdv), 45); // E_UNDEAD.bmp
_PI->WriteDword((0x720BCB +sdv), 46); // N_UNDEAD.bmp
_PI->WriteDword((0x720C75 +sdv), 47); // E_ROUND.bmp
_PI->WriteDword((0x720CA6 +sdv), 48); // N_ROUND.bmp
_PI->WriteDword((0x720D50 +sdv), 49); // E_DRAGON.bmp
_PI->WriteDword((0x720D81 +sdv), 50); // N_DRAGON.bmp
_PI->WriteDword((0x720E34 +sdv), 51); // E_HARPY.bmp
_PI->WriteDword((0x720E65 +sdv), 52); // N_HARPY.bmp
_PI->WriteDword((0x720F18 +sdv), 53); // E_CHAMP.bmp
_PI->WriteDword((0x720F49 +sdv), 54); // N_CHAMP.bmp
_PI->WriteDword((0x720FFC +sdv), 55); // E_MINOT.bmp
_PI->WriteDword((0x72102D +sdv), 56); // N_MINOT.bmp
_PI->WriteDword((0x7210E0 +sdv), 57); // E_SHOOTA.bmp
_PI->WriteDword((0x721111 +sdv), 58); // N_SHOOTA.bmp
_PI->WriteDword((0x7211C4 +sdv), 59); // E_FEARL.bmp
_PI->WriteDword((0x7211F5 +sdv), 60); // N_FEARL.bmp
_PI->WriteDword((0x7212A8 +sdv), 61); // E_REBIRTH.bmp
_PI->WriteDword((0x7212D9 +sdv), 62); // N_REBIRTH.bmp
_PI->WriteDword((0x72138C +sdv), 63); // E_UNIC.bmp
_PI->WriteDword((0x7213BD +sdv), 64); // N_UNIC.bmp
_PI->WriteDword((0x721484 +sdv), 65); // E_BLOCK.bmp
_PI->WriteDword((0x7214B4 +sdv), 66); // N_BLOCK.bmp
_PI->WriteDword((0x72155E +sdv), 67); // E_MANA.bmp
_PI->WriteDword((0x72158E +sdv), 68); // N_MANA.bmp
_PI->WriteDword((0x721638 +sdv), 69); // E_DBLOW.bmp
_PI->WriteDword((0x721668 +sdv), 70); // N_DBLOW.bmp
_PI->WriteDword((0x721A01 +sdv), 71); // E_HATE.bmp
_PI->WriteDword((0x721A31 +sdv), 72); // N_HATE.bmp
_PI->WriteDword((0x721C59 +sdv), 73); // E_TROLL.bmp
_PI->WriteDword((0x721C89 +sdv), 74); // N_TROLL.bmp
_PI->WriteDword((0x721E4C +sdv), 75); // E_CAST.bmp
_PI->WriteDword((0x721E7C +sdv), 76); // N_CAST.bmp
_PI->WriteDword((0x722037 +sdv), 77); // E_CAST1.bmp
_PI->WriteDword((0x722067 +sdv), 78); // N_CAST1.bmp
_PI->WriteDword((0x72224B +sdv), 77); // E_CAST1.bmp
_PI->WriteDword((0x72227B +sdv), 78); // N_CAST1.bmp
_PI->WriteDword((0x722436 +sdv), 79); // E_CAST2.bmp
_PI->WriteDword((0x722466 +sdv), 80); // N_CAST2.bmp
_PI->WriteDword((0x722643 +sdv), 79); // E_CAST2.bmp
_PI->WriteDword((0x722673 +sdv), 80); // N_CAST2.bmp
_PI->WriteDword((0x722A86 +sdv), 81); // E_BLESS.bmp
_PI->WriteDword((0x722AB6 +sdv), 82); // N_BLESS.bmp
_PI->WriteDword((0x72303C +sdv), 83); // E_RDEF.bmp
_PI->WriteDword((0x72306C +sdv), 84); // N_RDEF.bmp
_PI->WriteDword((0x72311F +sdv), 85); // E_DEATH.bmp
_PI->WriteDword((0x72314F +sdv), 86); // N_DEATH.bmp
_PI->WriteDword((0x72341C +sdv), 87); // E_BLOCK1.bmp
_PI->WriteDword((0x72344C +sdv), 88); // N_BLOCK1.bmp
_PI->WriteDword((0x7234F6 +sdv), 89); // E_BLOCK2.bmp
_PI->WriteDword((0x723526 +sdv), 90); // N_BLOCK2.bmp
_PI->WriteDword((0x723754 +sdv), 91); // E_SGTYPE.bmp
_PI->WriteDword((0x723784 +sdv), 92); // N_SGTYPE.bmp
_PI->WriteDword((0x7237D5 +sdv), 93); // E_SGNUM.bmp
_PI->WriteDword((0x723805 +sdv), 94); // N_SGNUM.bmp
_PI->WriteDword((0x7239C8 +sdv), 95); // E_SUMMON.bmp
_PI->WriteDword((0x7239F8 +sdv), 96); // N_SUMMON.bmp
_PI->WriteDword((0x723BBB +sdv), 97); // E_SUMMON1.bmp
_PI->WriteDword((0x723BEB +sdv), 98); // N_SUMMON1.bmp
_PI->WriteDword((0x723DAD +sdv), 99); // E_SUMMON2.bmp
_PI->WriteDword((0x723DDD +sdv), 100); // N_SUMMON2.bmp
int adress = 0x792848;
for (int i = 0; i < 58; i++){
_PI->WriteDword(adress, 101+i);
adress += 4;
}
return 1;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
static _bool_ plugin_On = 0;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
if (!plugin_On)
{
plugin_On = 1;
// Создаём объекты patcher_x86.
_P = GetPatcher();
_PI = _P->CreateInstance("New_Dlg_ExpaMon");
Y_ChangeBmp_To_DefFrame(); // замена путей к bmp в exe на кадры дефа
_PI->WriteHiHook(0x71EF2B, SPLICE_, EXTENDED_, /* THISCALL_*/ CDECL_, New_Dlg_ExpaMon_H);
// затираем вызовы функции ZvsLib1.dll
_PI->WriteCodePatch(0x724BC3, "%n", 10);
_PI->WriteCodePatch(0x72496E, "%n", 10);
}
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}