- Код: Выделить всё
HDDlg* __stdcall _HH_CloseDialog(HiHook *h, HDDlg *This, H3Msg *msg)
{
if (P_NewGameDlg)
{
auto hw = This->GetH3DlgItem(1001);
if (hw)
{
auto but = This->ItemAtPosition(msg);
if (but && but->GetID() == 1) // cancel button is id #2
{
sprintf(h3_TextBuffer, "At close time, state was %d", hw->CastDef()->GetFrame());
F_MessageBox();
}
}
}
return THISCALL_2(HDDlg*, h->GetDefaultFunc(), This, msg);
}
void GetHWproc()
{
...
_PI->WriteHiHook((h3func)&vt->closeDlg, FUNCPTR_, THISCALL_, _HH_CloseDialog); // only hook run dialog from HW mod
}
Also the text doesn't show up if you don't use the HDmod fonts, make its height greater or reduce font size.
To get rid of toggling state - semi-press state is not used and do NOT use disable.
- Код: Выделить всё
int __stdcall _HH_RunDialog(HiHook *h, HDDlg *dlg, int a2)
{
auto ItemHWRules = dlg->GetH3DlgItem(1001);
if (P_NewGameDlg && ItemHWRules) // if we're in lobby
{
HWRulesOn = ItemHWRules->CastDef()->GetFrame();
int CheckBoxX = ItemHWRules->GetX() + 145;
if (!HWRulesOn)
GamePlayChangesOn = FALSE;
H3DlgCustomButton *FlagCheckBox = dlg->CreateCustomButton(CheckBoxX, ItemHWRules->GetY(), CheckBoxID, "ChkBlue.def", MyButtonProc, GamePlayChangesOn, GamePlayChangesOn);
if (ItemHWRules->IsEnabled()) {
sprintf(h3_TextBuffer, "{Gameplay changes (FreshMod %s)}", VerInfo);
IsHost = true;
}
else {
sprintf(h3_TextBuffer, "{Gameplay changes (FreshMod %s)}", VerInfo);
IsHost = false;
}
dlg->CreateText(CheckBoxX + 41, ItemHWRules->GetY() + 6, 200, 25, h3_TextBuffer, MEDIUM_TEXT, TEXT_REGULAR, 0, 0);
}
return THISCALL_2(int, h->GetDefaultFunc(), dlg, a2); // run dialog
}
int __fastcall MyButtonProc(H3MsgCustom *msg)
{
if (msg->IsLeftClick())
{
H3DlgCustomButton *b = (H3DlgCustomButton*)msg->GetDlg()->GetH3DlgItem(CheckBoxID);
auto ItemHWRules = (H3DlgCustomButton*)msg->GetDlg()->GetH3DlgItem(1001);
if (!ItemHWRules->CastDef()->GetFrame()) {
return 1;
}
else
{
if (b) {
b->ToggleFlag(GamePlayChangesOn);
SendFlag();
}
}
}
else if (msg->IsRightClick())
{
sprintf(h3_TextBuffer, "Flag state is %d", GamePlayChangesOn);
F_MessageBoxRMB();
}
return 1;
}