Объявления
Поздравляем
VDV_forever


Друзья, если не получается зарегистрироваться, напишите на почту vdv_forever@bk.ru.
Я оторву свою задницу от всех дел и обязательно Вас активирую! :smile10:
Добро пожаловать на геройский форум! :smile25:

Как создать плагин для HD мода

Герои Меча и Магии III: Возрождение Эрафии, Герои Меча и Магии III Дыхание Смерти, Герои Меча и Магии III Клинок Армагеддона, Герои Меча и Магии III Хроники Героев
offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: Как создать плагин для HD мода

Сообщение as239 » 14 июл 2019, 15:01

Цитата:
I'm not sure I understand... do you mean that the flag value still toggles if it is disabled?

No, flag is disabled, but shows incorrect state.
Host having flag is on, without this code:
Код: Выделить всё
//FlagCheckBox->Disable();

Other player seeing also flag is on (Sending net data works fine), but he can toggle flag.

If this code is on:
Код: Выделить всё
FlagCheckBox->Disable();

Host having flag is on, but other player seeing flag is off, despite the value of the flag is true (GamePlayChangesOn=true).
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: Как создать плагин для HD мода

Сообщение RoseKavalier » 14 июл 2019, 15:52

Are you redrawing the button after disabling it / changing its state?
It's a bit hard to guess without code / full info. You can always email / PM if you don't want it public.
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: Как создать плагин для HD мода

Сообщение as239 » 14 июл 2019, 17:44

The only reason I could want to hide my code its sense of shame. But I am quite shameless.
Код: Выделить всё
     int CheckBoxX = ItemHWRules->GetX() + 145;
     H3DlgCustomButton *FlagCheckBox = dlg->CreateCustomButton(CheckBoxX, ItemHWRules->GetY(), CheckBoxID, "ChkBlue.def", MyButtonProc, GamePlayChangesOn, !GamePlayChangesOn);
     if ( ItemHWRules->IsEnabled()) {
        sprintf(h3_TextBuffer, "Gameplay changes (FreshMod %s)", VerInfo);
     }
     else {
        FlagCheckBox->Disable();
        sprintf(h3_TextBuffer, "{Gameplay changes (FreshMod %s)}", VerInfo);
     }
     dlg->CreateText(CheckBoxX+42, ItemHWRules->GetY() + 6, 200, 15, h3_TextBuffer, MEDIUM_TEXT, TEXT_REGULAR, 0, 0);
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: Как создать плагин для HD мода

Сообщение RoseKavalier » 14 июл 2019, 18:03

I'm not seeing any change to GamePlayChanges flag when you are disabling it.

Anyhow, if you disable the button, MyButtonProc will no longer process left-clicks which means you can't re-enable it.
You could simply add a check in MyButtonProc like this:
Код: Выделить всё
if (msg->IsLeftClick())
   {
      auto hw =  msg->GetDlg()->GetH3DlgItem(1001);
      if (hw && hw->IsEnabled())
      {  ... process left-click here }
   }
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: Как создать плагин для HD мода

Сообщение as239 » 14 июл 2019, 18:14

Цитата:
I'm not seeing any change to GamePlayChanges flag when you are disabling it.

Yes and exactly this is strange.

Цитата:
You could simply add a check in MyButtonProc like this:

I did it before but having upleasant visual effect - on second flag becames on, and then off.
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: Как создать плагин для HD мода

Сообщение as239 » 14 июл 2019, 18:31

How to intercept pressing this button, I know it ID:
 
Изображение

I want it works as usual, but with my 2 addisional calls.
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: Как создать плагин для HD мода

Сообщение RoseKavalier » 14 июл 2019, 18:54

as239 писал(а):

Цитата:
I'm not seeing any change to GamePlayChanges flag when you are disabling it.

Yes and exactly this is strange.


You created the button as showing ON by default (see last 2 fields). You should flip everything around if you want it off when HW rulez are disabled.

Catching button press - add another Hihook on Dialog close process from the needle. Call the default function first and then check if click id was OK or CANCEL. (something like P_WindowMgr->ClickedOK())
Код: Выделить всё
HDDlg* __stdcall _HH_DestroyDlg(HiHook *h, HDDlg *This, char a2)
{
    BOOL isCorrectDialog =  ... // perform necessary checks from before

    HDDlg* r = THISCALL_2(HDDlg*, h->GetDefaultFunc(), This, a2);


    if (isCorrectDialog  && P_WindowManager->ClickedOK()) // if this doesn't work compare against ClickedItemID()
    { //...code... }
    return r;
}

_PI->WriteHiHook((h3func)&vt->destroyDlg, FUNCPTR_, THISCALL_, _HH_CloseDialog); // only hook close dialog from HW mod
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: Как создать плагин для HD мода

Сообщение as239 » 15 июл 2019, 14:10

Цитата:
You created the button as showing ON by default (see last 2 fields). You should flip everything around if you want it off when HW rulez are disabled.

Sorry, didn't get it. I iust want - if "HW rules" is disabled, my flag "GamePlayChangesOn" also is disabled, and always having state from host (it works fine without disabling).
In general, did it:
Код: Выделить всё
int __fastcall MyButtonProc(H3MsgCustom *msg)
{
   if (msg->IsLeftClick())
   {
      H3DlgCustomButton *b = (H3DlgCustomButton*)msg->GetDlg()->GetH3DlgItem(CheckBoxID);
     auto ItemHWRules = (H3DlgCustomButton*)msg->GetDlg()->GetH3DlgItem(1001);
     if (!ItemHWRules->IsEnabled()){
          b->Disable();
          return 1;
     }

      if (b) {
      b->ToggleFlag(GamePlayChangesOn);
      SendFlag();
     }
   }
   else if (msg->IsRightClick())
   {
      sprintf(h3_TextBuffer, "Flag state is %d", GamePlayChangesOn);
      F_MessageBoxRMB();
   }

   return 1;
}

It works with once unpleasant visual effect.

Cannot get ItemHWRules at _HH_CloseDialog:
Код: Выделить всё
HDDlg* __stdcall _HH_CloseDialog(HiHook *h, HDDlg *dlg, char a2)
{
   auto ItemHWRules = dlg->GetH3DlgItem(1001);
   if (ItemHWRules) {
      sprintf(h3_TextBuffer, "IsEnabled %d", ItemHWRules->IsEnabled());
      F_MessageBoxRMB();
   }
   HDDlg* r = THISCALL_2(HDDlg*, h->GetDefaultFunc(), dlg, a2);

   return r;
}

It returns null:
Код: Выделить всё
auto ItemHWRules = dlg->GetH3DlgItem(1001);


And "P_WindowManager" is missing.
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: Как создать плагин для HD мода

Сообщение RoseKavalier » 15 июл 2019, 16:23

Oops it's P_WindowMgr, writing from memory.

Are you certain it returns null or simply the textbox is not showing?
F_MessageBoxRMB requires Right Mouse Button; try F_MessageBox() instead.
Also add the lobby condition, HW has other dialogs in the game which you don't want to check.

If it doesn't work, try with a global flag to make sure we are hooking the correct function :smile14:

I don't understand the visual effect anomaly, but you can try to refresh the button on every left click. If that solves it, we can narrow it down to left-clicks on the button itself.
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

Re: Как создать плагин для HD мода

Сообщение as239 » 15 июл 2019, 16:54

Цитата:
Are you certain it returns null or simply the textbox is not showing?

Not shure about null, but textbox never shows in any dialogs. And without condition, its crash:
Код: Выделить всё
ItemHWRules->IsEnabled()

Цитата:
Also add the lobby condition, HW has other dialogs in the game which you don't want to check.

Yes i know, i am just simplified code.
Цитата:
If it doesn't work,

Yes, it defently doesn't work.
Цитата:
we are hooking the correct function

Hook looks correct, i tested it with message on start game and close dialog.
Цитата:
try with a global flag

What's this?
Цитата:
I don't understand the visual effect anomaly

F.e. flag is off, u clicking on it, on half a second it becomes on, and then automatically returns to off. Further everything is fine, because disabling now is works.

Code in the attachment.
Вложения
Dlg.zip
(3.95 КБ) Скачиваний: 174
Вернуться к началу

Пред.След.

Вернуться в Общий раздел

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 8