Current time: 25.11.2024, 10:25 Hello There, Guest! (LoginRegister)
Language: english | russian  

Post Reply 
Threaded Mode | Linear Mode
Исследование героев
» туториал(ы)
Author Message
RoseKavalier Offline

Posts: 118
Post: #706

Очень приятно, спасибо еще раз за помощь)

EDIT:
Modified to use with short_tip_text. Works great, thanks x2
Code:
int __stdcall show_text_hint(_Dlg_* this_, _EventMsg_* msg)
{
    int r = this_->DefProc(msg);
    char* text;
    text = "";
    if (msg->type == MT_MOUSEOVER) {
        _DlgItem_* it = this_->FindItem(msg->x_abs, msg->y_abs);        
        if (it) {
            if (it->short_tip_text != NULL)
                text = it->short_tip_text;
        }
        statbar->SetText(text);
        statbar->Draw();
        statbar->RedrawScreen();
    }        
    return r;
}
(This post was last modified: 03.09.2017 23:43 by RoseKavalier.)
03.09.2017 18:39
Find all posts by this user Quote this message in a reply
RoseKavalier Offline

Posts: 118
Post: #707

I read conversation at DF2 (don't have account there...) and your solution below.
Я читал разговор на DF2 (нет аккаунта там...) и ваше решение ниже.
Graphic mode

It seems bug is related to different graphic mode,
32-bit GDI ok
True not ok
Image: tFuHLND.png

By any chance, could there be updated versions of dialog files?
Случайно, может быть обновленных версий диалоговые файлы?

If not, is there a way to make Set_DlgStdBackground() more... dynamic and less "one-size fits all". Seems to increment in +64
Если нет, есть ли способ, чтобы сделать Set_DlgStdBackground() в более... динамичным и менее "одну гребенку". Кажется, прирост в +64

Спасибо за ваше время)

Code:
width = 272;
dlg->AddItemByZOrder(_DlgStdBackground_::Create(0, 0, d_w, d_h, 0, 0, o_GameMgr->GetMeID()), 0);
Image: vzITrz1.png

Code:
width = 250
Set_DlgStdBackground (dlg);
Image: KR3sUij.png

Code:
width = 260
Set_DlgStdBackground (dlg);
Image: EMrhDFS.png
07.09.2017 04:06
Find all posts by this user Quote this message in a reply
igrik Offline

Posts: 2819
Post: #708

(07.09.2017 04:06)RoseKavalier Wrote:  By any chance, could there be updated versions of dialog files?
Случайно, может быть обновленных версий диалоговые файлы?

If not, is there a way to make Set_DlgStdBackground() more... dynamic and less "one-size fits all". Seems to increment in +64
Если нет, есть ли способ, чтобы сделать Set_DlgStdBackground() в более... динамичным и менее "одну гребенку". Кажется, прирост в +64
Обновленных версий нет.

Да, там проиходит увеличение дилогового окна на +64.
Если хотите сделать более динамичным, то вам необходимо исследовать функцию 0x48FA80 и перед показом диалога изменять все "64" на нужное увеличение размера, а потом возвращать этот параметр (=64).
Я бы сделал так.


game bug fixes extended.dll || My Plugins || My GitHub
07.09.2017 13:41
Visit this user's website Find all posts by this user Quote this message in a reply
RoseKavalier Offline

Posts: 118
Post: #709

Отличный ответ, спасибо!

EDIT: good news ---
you can place any custom *.pcx, *.def, *.bmp inside your plugin folder and it can be used directly.
вы можете разместить любой заказ, *.pcx, *.def, *.bmp ..., внутри папки плагинов и его можно использовать напрямую.

Image: mdDrR8w.png

EDIT2: after some thinking... started making a function for dynamic background.
Lacks color but maybe that can be fixed...
после некоторых размышлений, я начал делать функцию для динамического фона.

It works will all graphic modes as far as I could tell.
Code:
int create_standard_background(_Dlg_* dlg, int status_bar)
{
    //dlg->AddItem(_DlgStaticPcx8_::Create(0, 0, min(dlg->width,256), min(dlg->height,256), 0, "DiBoxBck.pcx"));
    
    int current_x, remaining_x, current_y, remaining_y, horizontal_row;

    current_x = 0;
    remaining_x = dlg->width;
    current_y = 0;
    remaining_y = dlg->height;
    horizontal_row = 0;

    if (remaining_x < 64 || remaining_y < 64)
        return 0;

    while (TRUE) {        
        while (TRUE) { // do horizontal pass first
            if (remaining_x > 0) {
                dlg->AddItem(_DlgStaticPcx8_::Create(current_x, horizontal_row * 256, min(remaining_x, 256), min(remaining_y, 256), 0, "DiBoxBck.pcx"));
                current_x = current_x + 256;
                remaining_x = remaining_x - 256;
            }
            else break;
        }        
        current_x = 0;        // reset x position to 0        
        remaining_x = dlg->width; // reset length of horizontal line
        remaining_y = remaining_y - 256; // update remaining y since we're done with horizontal pass
        horizontal_row = horizontal_row + 1;    // we might be working on a new row soon if condition below is met        
        if (remaining_y <= 0)
            break;        // no more rows to add
    }

    int top_left = 0;
    int top_right = 1;
    int bottom_left = 2;
    int bottom_right = 3;
    int left_middle = 4;
    int right_middle = 5;
    int top_middle = 6;
    int bottom_middle = 7;

    if (status_bar) {
        bottom_left = 8;
        bottom_right = 9;
        bottom_middle = 10;
    }

    // add horizontal borders    
    current_x = 0;
    remaining_x = dlg->width;
    while (remaining_x >= 64) {
        dlg->AddItem(_DlgStaticDef_::Create(current_x, 0, 0, "dialgbox.def", top_middle, 0, 0));
        dlg->AddItem(_DlgStaticDef_::Create(current_x, dlg->height - 64, 0, "dialgbox.def", bottom_middle, 0, 0));
        current_x += 64;
        remaining_x -= 64;
    }
    // add vertical borders
    current_y = 0;
    remaining_y = dlg->height;
    while (remaining_y >= 64) {
        dlg->AddItem(_DlgStaticDef_::Create(0, current_y, 0, "dialgbox.def", left_middle, 0, 0));
        dlg->AddItem(_DlgStaticDef_::Create(dlg->width - 64, current_y, 0, "dialgbox.def", right_middle, 0, 0));
        current_y += 64;
        remaining_y -= 64;
    }

    // add four corners
    dlg->AddItem(_DlgStaticDef_::Create(0, 0, 0, "dialgbox.def", top_left, 0, 0));
    dlg->AddItem(_DlgStaticDef_::Create(0, dlg->height - 64, 0, "dialgbox.def", bottom_left, 0, 0));
    dlg->AddItem(_DlgStaticDef_::Create(dlg->width - 64, 0, 0, "dialgbox.def", top_right, 0, 0));    
    dlg->AddItem(_DlgStaticDef_::Create(dlg->width - 64, dlg->height - 64, 0, "dialgbox.def", bottom_right, 0, 0));
}
Image: HWByect.png
(This post was last modified: 08.09.2017 10:24 by RoseKavalier.)
08.09.2017 04:00
Find all posts by this user Quote this message in a reply
igrik Offline

Posts: 2819
Post: #710

(08.09.2017 04:00)RoseKavalier Wrote:  EDIT2: after some thinking... started making a function for dynamic background.
Lacks color but maybe that can be fixed...
после некоторых размышлений, я начал делать функцию для динамического фона.

It works will all graphic modes as far as I could tell.
Wow nice!!
Add a repainted dialogue to the player's color. Like this
Code:
// add color this player
CALL_5 (int, __thiscall, 0x5FF400, dlg, 512, 13, 0, o_GameMgr->GetMeID());

// add four corners
dlg->AddItem(_DlgStaticDef_::Create(0, 0, 0, "dialgbox.def", top_left, 0, 0));
dlg->AddItem(_DlgStaticDef_::Create(0, dlg->height - 64, 0, "dialgbox.def", bottom_left, 0, 0));
dlg->AddItem(_DlgStaticDef_::Create(dlg->width - 64, 0, 0, "dialgbox.def", top_right, 0, 0));    
dlg->AddItem(_DlgStaticDef_::Create(dlg->width - 64, dlg->height - 64, 0, "dialgbox.def", bottom_right, 0, 0));
}
Image: Q5zoYrS.jpg


game bug fixes extended.dll || My Plugins || My GitHub
(This post was last modified: 08.09.2017 11:31 by igrik.)
08.09.2017 11:16
Visit this user's website Find all posts by this user Quote this message in a reply
RoseKavalier Offline

Posts: 118
Post: #711

(08.09.2017 11:16)igrik Wrote:  Wow nice!!
Add a repainted dialogue to the player's color. Like this
Code:
// add color this player
CALL_5 (int, __thiscall, 0x5FF400, dlg, 512, 13, 0, o_GameMgr->GetMeID());
Image: Q5zoYrS.jpg

!!!!!

Я не знаю, почему и как это работает, но это **** невероятно! Огромное спасибо)

109

Ed: same logic, blue background.
же логику, синий фон.

Code:
int create_blue_background(_Dlg_* dlg)
{
    int current_x, remaining_x, current_y, remaining_y, horizontal_row;

    current_x = 0;
    remaining_x = dlg->width;
    current_y = 0;
    remaining_y = dlg->height;
    horizontal_row = 0;

    if (remaining_x < 42 || remaining_y < 42)
        return 0;

    while (TRUE) {
        while (TRUE) { // do horizontal pass first
            if (remaining_x > 0) {
                dlg->AddItem(_DlgStaticPcx8_::Create(current_x, horizontal_row * 256, min(remaining_x, 256), min(remaining_y, 256), 0, "DlgBluBk.bmp"));
                current_x += 256;
                remaining_x -= 256;
            }
            else break;
        }
        current_x = 0;        // reset x position to 0        
        remaining_x = dlg->width; // reset length of horizontal line
        remaining_y = remaining_y - 256; // update remaining y since we're done with horizontal pass
        horizontal_row = horizontal_row + 1;    // we might be working on a new row soon if condition below is met        
        if (remaining_y <= 0)
            break;        // no more rows to add
    }

    int top_left = 0;
    int top_right = 1;
    int bottom_left = 2;
    int bottom_right = 3;
    int left_middle = 4;
    int right_middle = 5;
    int top_middle = 6;
    int bottom_middle = 7;

    // add horizontal borders    
    current_x = 0;
    remaining_x = dlg->width;
    while (remaining_x >= 42) {
        dlg->AddItem(_DlgStaticDef_::Create(current_x, 0, 0, "DlgBluBo.def", top_middle, 0, 0));
        dlg->AddItem(_DlgStaticDef_::Create(current_x, dlg->height - 42, 0, "DlgBluBo.def", bottom_middle, 0, 0));
        current_x += 42;
        remaining_x -= 42;
    }
    // add vertical borders
    current_y = 0;
    remaining_y = dlg->height;
    while (remaining_y >= 42) {
        dlg->AddItem(_DlgStaticDef_::Create(0, current_y, 0, "DlgBluBo.def", left_middle, 0, 0));
        dlg->AddItem(_DlgStaticDef_::Create(dlg->width - 42, current_y, 0, "DlgBluBo.def", right_middle, 0, 0));
        current_y += 42;
        remaining_y -= 42;
    }

    // add four corners
    dlg->AddItem(_DlgStaticDef_::Create(0, 0, 0, "DlgBluBo.def", top_left, 0, 0));
    dlg->AddItem(_DlgStaticDef_::Create(0, dlg->height - 42, 0, "DlgBluBo.def", bottom_left, 0, 0));
    dlg->AddItem(_DlgStaticDef_::Create(dlg->width - 42, 0, 0, "DlgBluBo.def", top_right, 0, 0));
    dlg->AddItem(_DlgStaticDef_::Create(dlg->width - 42, dlg->height - 42, 0, "DlgBluBo.def", bottom_right, 0, 0));
}
(This post was last modified: 08.09.2017 17:45 by RoseKavalier.)
08.09.2017 17:36
Find all posts by this user Quote this message in a reply
RoseKavalier Offline

Posts: 118
Post: #712

Small modification for create_standard_background(...) to prevent border appearance in status bar... actually would be slightly more efficient starting from (dlg->height - 64) and working back but this works fine)
Небольшая модификация для create_standard_background(...) для предотвращения появления границы в строке состояния...

Code:
    // add vertical borders
    current_y = 0;
    remaining_y = dlg->height;
    while (remaining_y >= 64) {
        if (remaining_y - 64 <= 37)
            current_y = dlg->height - 64 - 37; // hide a bit for status bar
        dlg->AddItem(_DlgStaticDef_::Create(0, current_y, 0, "dialgbox.def", left_middle, 0, 0));
        dlg->AddItem(_DlgStaticDef_::Create(dlg->width - 64, current_y, 0, "dialgbox.def", right_middle, 0, 0));
        current_y += 64;
        remaining_y -= 64;
    }

~~~~~

Are there structures available for Quest Guards / Seer Huts? Only thing I could find is QU receiver from ERA but no structure... I could probably map these myself but if someone has and is willing to share, would be quite helpful!
Имеющиеся конструкции для охранников квеста / хижины Провидца? Единственное, что я мог найти, это QU приемник от эпохи, но не структура... Я мог бы сопоставить его сам, но если кто-то имеет и готов поделиться, это было бы очень полезно!

e.g.
struct + 0x3C = deadline / крайний срок
(This post was last modified: 18.09.2017 05:38 by RoseKavalier.)
18.09.2017 05:05
Find all posts by this user Quote this message in a reply
gamecreator Offline

Posts: 7107
Post: #713

(18.09.2017 05:05)RoseKavalier Wrote:  Are there structures available for Quest Guards / Seer Huts? Only thing I could find is QU receiver from ERA but no structure... I could probably map these myself but if someone has and is willing to share, would be quite helpful!
Link updated. It has the sources you need.


When all gods have burnt to ashes in eternity of sorrow,
Demons gonna tear your soul because there is no tomorrow.
18.09.2017 20:55
Find all posts by this user Quote this message in a reply
RoseKavalier Offline

Posts: 118
Post: #714

Wonderful, much appreciated. What a great community!
19.09.2017 05:14
Find all posts by this user Quote this message in a reply
RoseKavalier Offline

Posts: 118
Post: #715

Hello... another question I can't seem to solve.
Привет ... другой вопрос, который я не могу решить.

Code:
dlg->AddItem(_DlgTextEdit_::Create(50, 360, 400, 60, 13, "1234", "medfont.fnt", 1, 1, "DlgBluBk.PCX", 5, 4, 0, 0));

// _DlgTextEdit_* Create(int x, int y, int width, int height, int max_len, char* text, char* font_name, _dword_ text_color, _dword_ text_align, char* bkground_pcx8_name, int id, _bool_ has_border, int border_width, int border_height)

Is there an easy way to restrict which characters can be input in _DlgTextEdit_?
e.g. digits only
Есть ли простой способ ограничить, какие символы могут быть введены в _DlgTextEdit_?
например только цифры
Image: zFCZDEQ.png
26.09.2017 09:02
Find all posts by this user Quote this message in a reply
Valery Offline

Posts: 2196
Post: #716

Is there some restriction from HD for that? Because I can't anymore input any digits in that box and I can't find any tweak about in HD.

@Edit: I found, HD requires ctrl hold to change digits.
(This post was last modified: 26.09.2017 11:12 by Valery.)
26.09.2017 11:08
Find all posts by this user Quote this message in a reply
igrik Offline

Posts: 2819
Post: #717

(26.09.2017 09:02)RoseKavalier Wrote:  Hello... another question I can't seem to solve.
Is there an easy way to restrict which characters can be input in _DlgTextEdit_?
I do not know how to do it yet. But I'll figure it out.


game bug fixes extended.dll || My Plugins || My GitHub
26.09.2017 18:08
Visit this user's website Find all posts by this user Quote this message in a reply
RoseKavalier Offline

Posts: 118
Post: #718

@Valery
You don't need to press Control, just click in the area and you can type numbers. This is not a HD feature, it is available with regular HoMM3 - or at the very least it worked on my 4.0 copy without HDmod.

@igrik
Thanks)
I looked at function that does for creatures but I got lost.
0x5BB000 (process command)
0x5FF3A0 (load correct text to 0x697428)

Alternatively, I thought of reading text from edit and removing unwanted characters - then load back text without unwanted characters to edit.

Спасибо)
Я смотрел на функцию, которая делает для существ, но я потерялся.
0x5BB000 (команда процесса)
0x5FF3A0 (загрузить правильный текст в 0x697428)

В качестве альтернативы, я думал о чтении текста из редактирования и удалении нежелательных символов, а затем загружать текст без ненужных символов для редактирования.
Code:
proc:
    (print to buffer) ((_DlgTextEdit_*)dlg->GetItem(edit_id))->text;
    (remove non-digits from buffer);
    ((_DlgTextEdit_*)dlg->GetItem(edit_id))->text = buffer;

I have not had time to try and code it and test so no idea if it could/would work.
27.09.2017 08:35
Find all posts by this user Quote this message in a reply
Valery Offline

Posts: 2196
Post: #719

Nope, typing directly digits has no effect, need to hold control key in HD mod. Without HD is ok.
27.09.2017 15:50
Find all posts by this user Quote this message in a reply
RoseKavalier Offline

Posts: 118
Post: #720

(27.09.2017 15:50)Valery Wrote:  Nope, typing directly digits has no effect, need to hold control key in HD mod. Without HD is ok.
I tried on 4.208, few 5.0s and control key is not needed?
Anyhow, not really important.

@igrik
I tried my idea from previous post... it kind of works. It's not perfect but in the end only digits remain. 105
Я попробовал то, что написал в предыдущем посте... Это работает. Это не идеально, но в конце концов только цифры.

Code:
int __stdcall edit_text_proc(_Dlg_* dlg, _EventMsg_* msg)
{
    int r = dlg->DefProc(msg);

    if (msg->type == MT_KEYDOWN || msg->type == MT_KEYUP || msg->type == MT_MOUSEBUTTON) {            // not absolutely necessary, less cpu intensive
        _DlgTextEdit_ *edit = (_DlgTextEdit_*)(dlg->GetItem(55));    // id of _DlgTextEdit_
        char edit_text[25];                                            // _DlgTextEdit_ max_len
        sprintf(edit_text, edit->text);                                // copy _DlgTextEdit_ text
        keep_digits(edit_text);                                        // keep only '0123456789' in string (with !is_digit())
        if (edit_text[0] == 0) {                                    // strlen == 0
            edit_text[0] = '0';                                        // put '0' as default
            edit_text[1] = 0;                                        // terminate string
        }
        sprintf(edit->text, edit_text);                                // replace _DlgTextEdit_ text
        dlg->Redraw();                                                // redraw
    }
    return r;
}

EDIT:
Got it working nice and fine 109

Add this also when creating. Noticed it was happening with creature dialog.
Code:
_DlgTextEdit_* edit= (_DlgTextEdit_*)(dlg->GetItem(#EDIT_ID#));
edit->redraw_actions = FALSE;

In proc, have keep_digits(edit_text) return 1 / 0 depending whether a non-digit was found e.g.
Code:
int keep_digits(char* input)
{
    char* dest = input;
    char* src = input;
    int non_digit = 0;

    while (*src)
    {
        if (!isdigit(*src)) {
            non_digit = 1;
            src++;
            continue;
        }
        *dest++ = *src++;
    }
    *dest = '\0';
    return non_digit;
}

If true, decrease position of cursor "caret".
Code:
if (keep_digits(edit_text))    
    edit->caret_pos--;

Only "slight" bug is CTRL-V "paste"... cursor "caret" vanishes with non-digits.
...don't care too much about that one.
(This post was last modified: 06.10.2017 07:48 by RoseKavalier.)
29.09.2017 22:28
Find all posts by this user Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Forum Jump:

Powered by MyBB Copyright © 2002-2024 MyBB Group