interface.u and Skill Cancel Event in H5

CubAfull

Свой человек
Участник
Сообщения
20
Розыгрыши
0
Репутация
31
Реакции
58
Баллы
575
Hi guys. I have an interface created by me to which I added the casting bar, and I want to hide it when I press the ESC key (skill cancel/target cancel).
In interface.xdat > shortcuts > GamingStateShotcut > Shortcutitems we have the "TargetCancel" command (bind to ESC) and in interface.u > Shortcut.uc class I expanded the function "HandleShortcutCommand" with:
C++:
case "TargetCancel":
                ExecuteEvent(EV_TargetCancel);
                break;

For the record, I defined this event in UICommonAPI.uc

C++:
const EV_TargetCancel = 10008;

Now, in my custom class for the casting bar I creted the functions:
C++:
class PlayerSkillGauge extends UICommonAPI;

function OnRegisterEvent()
{
    RegisterEvent(EV_TargetCancel);
}

function OnEvent(int EventID, string a_Param)
{
    switch (EventID)
    {
        case EV_TargetCancel:
            HandleSkillCancel();
            break;
    }
}

function HandleSkillCancel()
{
    // do the work...
}

The problem is I can't make this to work. I made some test in the Shortcut.uc class but the "TargetCancel" command never fires. Can anybody help me? Thank you!
 
also, anyone knows how to use/enable this Debug("..."); function?
 

CubAfull

У вас по коду все правильно!
Возможно вы неправильно настроили свойства в xdat?

Да и еще я это добавил в Shortcut.uc в Function HandleShortcutKeyEvent( string a_Param )
C++:
case "TargetCancel":

                ExecuteEvent(EV_TargetCancel);

                break;

И так тоже сработала используя функцию, что вы использовали "HandleShortcutCommand"
 

Вложения

  • 2332.JPG
    2332.JPG
    82,8 КБ · Просмотры: 40
  • 2323.JPG
    2323.JPG
    75,5 КБ · Просмотры: 31
Hi BIT_hack, thank you for your test! I don't know why it doesn't work :( I have the same configuration as you (second picture) in the interface.xdat

I added this function to UICommonAPI.uc and lets see if I can output some information:

C++:
function DebugMessage(string message)
{
    local ChatWindowHandle NormalChat;
    local Color color;

    NormalChat = ChatWindowHandle( GetHandle("ChatWnd.NormalChat") );

    color.R = 255;
    color.G = 0;
    color.B = 0;
    color.A = 255;

    NormalChat.AddStringToChatWindow(message, color );
}
 
Hi BIT_hack, thank you for your test! I don't know why it doesn't work :( I have the same configuration as you (second picture) in the interface.xdat

I added this function to UICommonAPI.uc and lets see if I can output some information:

C++:
function DebugMessage(string message)
{
    local ChatWindowHandle NormalChat;
    local Color color;

    NormalChat = ChatWindowHandle( GetHandle("ChatWnd.NormalChat") );

    color.R = 255;
    color.G = 0;
    color.B = 0;
    color.A = 255;

    NormalChat.AddStringToChatWindow(message, color );
}
Если вам нужно просто закрыть свое окно, используйте просто этот код в своем скрипте.
C++:
function OnKeyDown(WindowHandle a_WindowHandle, EInputKey nKey)
    {
   if (nKey == IK_Escape )
      {
    AddSystemMessageString("HideWindow: System Message Chat"); //string Вывод системных сообщений в чат
    HideWindow("MY_WindowName"); 
        }
      }
 
Well, I don't know why, but I can't output any info with AddSystemMessageString("...") or the function I posted. When I create this interface 2 years ago I remember using this functions for debug :( I'm here pulling my hair out!!

I have some progress here :)

I can get debug messages with AddSystemMessageString("...") if the windows in use is focussed. For example, I added this function to MenuWnd.uc, and I can see the message in the chat when I press the ESC key ("Escape Pressed!"), but only if I click in the menu (get the window focus), if I lost the focus by clicking in other place when I press the ESC key nothing happens.

What can I do to keep this OnKeyDown function working all the time?

C++:
function OnKeyDown(WindowHandle a_WindowHandle, EInputKey nKey)
{
    if ( nKey == IK_Escape )
    {
        AddSystemMessageString("Escape Pressed!")
    }
}
 
Последнее редактирование модератором:
I have some progress here :)

I can get debug messages with AddSystemMessageString("...") if the windows in use is focussed. For example, I added this function to MenuWnd.uc, and I can see the message in the chat when I press the ESC key ("Escape Pressed!"), but only if I click in the menu (get the window focus), if I lost the focus by clicking in other place when I press the ESC key nothing happens.

What can I do to keep this OnKeyDown function working all the time?

C++:
function OnKeyDown(WindowHandle a_WindowHandle, EInputKey nKey)
{
    if ( nKey == IK_Escape )
    {
        AddSystemMessageString("Escape Pressed!")
    }
}
Я тестировал на Grand Crusade.
Проверил на HF действительно не работает команды через xdat и как у вас обработчик клавиш срабатывает только в фокусе(
 
Thank you again BIT_hack for taking the time to test.
Then, this is a H5 client limitation? Any dev with a H5 client can confirm this? Rolo please?
 

//summon Monokini2, расскажи про ту функцию с павна, где инфа о кастере, я уже название даже забьіл, так и не добрался до єтого каст бара. ))
 
Well, I don't know why, but I can't output any info with AddSystemMessageString("...") or the function I posted. When I create this interface 2 years ago I remember using this functions for debug :( I'm here pulling my hair out!!

I have some progress here :)

I can get debug messages with AddSystemMessageString("...") if the windows in use is focussed. For example, I added this function to MenuWnd.uc, and I can see the message in the chat when I press the ESC key ("Escape Pressed!"), but only if I click in the menu (get the window focus), if I lost the focus by clicking in other place when I press the ESC key nothing happens.

What can I do to keep this OnKeyDown function working all the time?

C++:
function OnKeyDown(WindowHandle a_WindowHandle, EInputKey nKey)
{
    if ( nKey == IK_Escape )
    {
        AddSystemMessageString("Escape Pressed!")
    }
}

Я совсем забыл - вам надо добавьте этот код в UICommonAPI.uc для глобального перехвата клавиш!
C++:
 //!Обработчик нажатий клавиш
function OnKeyDown( WindowHandle a_WindowHandle, EInputKey Key ){

    AddSystemMessageString("Key"@class'InputAPI'.static.GetKeyString(Key)); //Нажата клавиша

 if(class'InputAPI'.static.IsAltPressed() && Key == IK_S ) {//!Если зажата клавиша альт+S откроем окно BoardWnd
    ShowWindow("BoardWnd");//Открыть окно BoardWnd
    }
    }
 
Я совсем забыл - вам надо добавьте этот код в UICommonAPI.uc для глобального перехвата клавиш!
C++:
 //!Обработчик нажатий клавиш
function OnKeyDown( WindowHandle a_WindowHandle, EInputKey Key ){

    AddSystemMessageString("Key"@class'InputAPI'.static.GetKeyString(Key)); //Нажата клавиша

 if(class'InputAPI'.static.IsAltPressed() && Key == IK_S ) {//!Если зажата клавиша альт+S откроем окно BoardWnd
    ShowWindow("BoardWnd");//Открыть окно BoardWnd
    }
    }
Как бы не так) если кликнуть в землю, чтобы персонаж побежал, все-равно не будет реагировать после этого действия, т.к. не будет ниодного окна в фокусе :)
 
Как бы не так) если кликнуть в землю, чтобы персонаж побежал, все-равно не будет реагировать после этого действия, т.к. не будет ниодного окна в фокусе :)
Вроде как если окно не в фокусе все равно не закроется?
Думаю в его случае надо выбрать нужное окно чтобы закрыть его и сработал - IK_Escape.

Как бы не так) если кликнуть в землю, чтобы персонаж побежал, все-равно не будет реагировать после этого действия, т.к. не будет ниодного окна в фокусе :)
Прочитал еще раз ответ автора ему наверно так не подойдет так как после потери фокуса, обработчик клавиш сработает только на второй раз(
 
Назад
Сверху Снизу