Wake of Gods Forum | Форум Во Имя Богов

Full Version: Плагины. Обсуждение
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
Костыль в способе чтения и вывода текста в IF:Q?
Да. Я не разобрался, как правильно выводить сообщения на экран, у функции 0x4F6C00 слишком много параметров.
Пиши обёртку:
Code:
TMesType =
  (
    MES_MES         = 1,
    MES_QUESTION    = 2,
    MES_RMB_HINT    = 4,
    MES_CHOOSE      = 7,
    MES_MAY_CHOOSE  = 10
  );

function Msg
(
  const Mes:          string;
        MesType:      TMesType  = MES_MES;
        Pic1Type:     integer   = NO_PIC_TYPE;
        Pic1SubType:  integer   = 0;
        Pic2Type:     integer   = NO_PIC_TYPE;
        Pic2SubType:  integer   = 0;
        Pic3Type:     integer   = NO_PIC_TYPE;
        Pic3SubType:  integer   = 0
): integer;

var
  MesStr:     pchar;
  MesTypeInt: integer;
  Res:        integer;

begin
  MesStr     := pchar(Mes);
  MesTypeInt := ORD(MesType);

  asm
    MOV ECX, MesStr
    PUSH Pic3SubType
    PUSH Pic3Type
    PUSH -1
    PUSH -1
    PUSH Pic2SubType
    PUSH Pic2Type
    PUSH Pic1SubType
    PUSH Pic1Type
    PUSH -1
    PUSH -1
    MOV EAX, $4F6C00
    MOV EDX, MesTypeInt
    CALL EAX
    MOV EAX, [WND_MANAGER]
    MOV EAX, [EAX + $38]
    MOV Res, EAX
  end; // .asm

  result := MSG_RES_OK;

  if MesType = MES_QUESTION then begin
    if Res = 30726 then begin
      result := MSG_RES_CANCEL;
    end // .if
  end else if MesType in [MES_CHOOSE, MES_MAY_CHOOSE] then begin
    case Res of
      30729: result := MSG_RES_LEFTPIC;
      30730: result := MSG_RES_RIGHTPIC;
    else
      result := MSG_RES_CANCEL;
    end; // .SWITCH Res
  end; // .elseif
end; // .function Msg

procedure ShowMessage (const Mes: string);
begin
  Msg(Mes);
end;

function Ask (const Question: string): boolean;
begin
  result := Msg(Question, MES_QUESTION) = MSG_RES_OK;
end;
Berserker, большое Вам спасибо!
Вы этот код прямо сейчас написали? Честно говоря, мне даже неудобно как-то - я ожидал простого совета или максимум - примера использования откуда-то ещё...
(15.03.2021 23:12)Raistlin Wrote: [ -> ]Честно говоря, мне даже неудобно как-то - я ожидал простого совета или максимум - примера использования откуда-то ещё...

Вызывай эту воговскую функцию и не парься (в с этим MoP ещё сильнее упрощено):

Code:
int Message(const char *zmes,int n,int showtime)
/*
    1-сообщение
    2-запрос
    4-инфа по правой мышке
    7-просьба выбрать
10-можно и выбрать и отказаться
*/
{
    STARTNA(__LINE__, 0)
    if (MainWindow == 0)
    {
        MessageBox(0, zmes, "Heroes of Might and Magic III", 0);
        RETURN(0);
    }

    __asm{
        mov  ecx,zmes
        push 0         // SType 3 : 0
        push -1        // Type 3  : -1
        push showtime  //0
        push -1        // Par ???
        push 0         // SType 2
        push -1        // Type 2
        push 0         // SType 1
        push -1        // Type 1
        push -1        // y
        push -1        // x
        mov eax,0x4f6C00
        mov edx,n
        call eax
    }
    __asm{
        mov eax,0x6992D0
        mov ecx,[eax]
        mov eax,[ecx+0x38]
        mov IDummy,eax    
    }  
    RETURN(IDummy);
}
Raistlin, Good job! 132 You are our hero of plugin mods! I wonder, what is the new thing that you will come up with? 96-copySpiteful
V_Maiko, thank you for your support! 96-copy The new thing that I will come up with is pretty interesting, but for now it is a secret 144
XEPOMAHT, спасибо за код, я попробую. 132
After having used the H3.RMGDescription plugin for a long time, I have always wondered, why is a plugin not implemented to allow introducing seeds like in Minecraft? So players can generate their own maps in a more fun way Rolleyes
Raistlin, при использовании patcher_x86.hpp и заголовочника HoMM3.h вообще не нужно писать ASM код, и всё становится куда проще:

Универсальная обёртка с использованием условий по умолчанию:
Code:
_bool_ f_MsgBox(char* text, int style = 1, int x = -1, int y = -1, int pic1Type = -1, int pic1Subtype = 0, int pic2Type = -1, int pic2Subtype = 0, int unk = -1, int showTime = 0, int pic3Type = -1, int pic3Subtype = 0)
{
  CALL_12(void, __fastcall, 0x4F6C00, text, style, x, y, pic1Type, pic1Subtype, pic2Type, pic2Subtype, unk, showTime, pic3Type, pic3Subtype);
  return (o_WndMgr->result_dlg_item_id);
}

Примеры вызовов:
Code:
f_MsgBox(message); // просто сообщение с текстом
if(f_MsgBox(message, 4) {...}) // вопрос с текстом, в условии
f_MsgBox(message, 1, -1, -1, pic1Type, pic1Subtype); // показ сообщения с одной картинкой (id картинок см.IF:Q)
f_MsgBox(message, 7, -1, -1, pic1Type, pic1Subtype, pic2Type, pic2Subtype); // сообщение с выбором из 2х картинок

daemon_n, просто проснулся раньше обычного. ХЗ, старею походу...
Raistlin, а я вот не понял, зачем этот плагин, когда есть скрипт отображения экрана героя без схлопывания в эра спкриптс, написанный через un:c. Позволяет и командира проверить, и статус оруженосца, и артефакты в рюкзаке - вообще любую информацию.

igrik, ещё нет шести утра – надеюсь, всё нормально 105
Raistlin, а можешь сделать именно фиксы отдельно? Сделай, пожалуйста. Не хочется возиться с добавлением новых объектов, а вот фиксы полезные.

Как именно он работают они, кстати?
Hello! Looking for help from igrik with WoG Native Dialog. I understand these problems have been reported, but I just hope they can be fixed in the near future. Rolleyes

1. Keypad support. Currently, the keypad has no use with input dialogues from WoG Native Dialog.
2. Disappearing WoG Option dialogue. As I understand after HD 5.2 RC11 the WoG dialogue support of OpenGL gets worse, as a result, the WoG Option dialogue disappear immediately (Details). Switching to non-OpenGL mode could resolve the issue, but it's not ideal - I simply can't play H3 without the great performance in OpenGL.
1. Seems like it's HD mod feature. Tried without it?
2. Disappearing only occurs with zvslib.dll dialogs from WoG 3.58. Not wog native dialogs bug, but HD mod implementation changing.
Am I wrong?
Berserker, sorry for failing to explain. Right, the second one is not a WND issue. But it can only be fixed by re-writing the zvslib dialogue with WND, so I put my hope in igrik Sorry

The first one is not an HD feature. Tried without HD, the issue persisted.
But igrik has rewritten WoG Options dialog. With WND no disappearing should occur. We need igrik's reply.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
Reference URL's