Page 1 of 1

GUI not displaying

Posted: 2014-09-09, 05:56
by SoulRider
I have linked up the TAB key to display a scoreboard. I have a simple plain screen I am trying to display, but when I press tab, the GUI is not displayed.

As a test, I altered the assert(loadfile....) to an invalid path, and when I tested it in the engine, when I pressed the TAB key, the assert failed.

This tells me ScoreBoard_main file is being called, and is loading the _init.cgui file correctly on pressing tab as it is not erroring.

Can you see what I have missed? I have attached the _init from CaWE and my own _main. The gui is based on the console window.

Re: GUI not displaying

Posted: 2014-09-09, 23:44
by Carsten
Hi SoulRider,

I'll have another look at this tomorrow morning, but at a first glance, it looks as if the ScoreBoard_*.cgui files are fine, so it's probably related to the way how you integrated this GUI into the C++ part of the engine. (Do you happen to have a diff (patch) of the related changes? That would be the easiest for me to see what's going on, i.e. follow what changes you made.)

Also without patch, I've not yet looked into the relevant C++ portions of the code, but will do so tomorrow, and then post anything I've come up with. :cheesy:

Re: GUI not displaying

Posted: 2014-09-10, 05:28
by SoulRider
I don't have a diff patch, as I am working on my laptop and don't have a Git client. Good news is I start a new job soon, so I'll be able to get sorted and back online on my main PC again :D

I'll be on the laptop for a couple of weeks, then I may be offline again while I get sorted out for a month.

Re: GUI not displaying

Posted: 2014-09-10, 09:48
by Carsten
Ok. (A Git client would be very useful though, especially if you work with the C++ code.)

As mentioned earlier, something is probably missing in the C++ code.
For comparison and reference, consider how the chat input GUI is handled, in Ca3DE/Client/ClientStateInGame.cpp:

Code: Select all

        case CaKeyboardEventT::CK_T:          // talk to other clients
        case CaKeyboardEventT::CK_Y:
        {
            IntrusivePtrT<cf::GuiSys::GuiImplT> ChatInputGui =
                cf::GuiSys::GuiMan->Find(std::string("Games/") + Client.m_GameInfo.GetName() + "/GUIs/ChatInput_main.cgui", true);

            // Could be NULL on file not found, parse error, etc.
            if (ChatInputGui!=NULL)
            {
                ChatInputGui->Activate();
                cf::GuiSys::GuiMan->BringToFront(ChatInputGui);
            }
            break;
        }
Have you something like this for the ScoreBoard as well? If so, when you press TAB, does the method ever see the related key event for the CaKeyboardEventT::CK_TAB key?

You could insert something like

Code: Select all

        Console->Print("Key CK_xyz was pressed.\n");
e.g. once in the CK_T branch (to cross-check with the chat input GUI) and once in your CK_TAB branch (to check with your ScoreBoard).

Without knowing anything else about the changes you've made, this is probably the most effective way to debug this problem.

Re: GUI not displaying

Posted: 2014-09-11, 01:40
by SoulRider
I have got the scoreboard displaying when pressing tab now, however, it doesn't clear when releasing the tab key. I tried adding the code below into the scoreboard gui.

Code: Select all

local gui = ...

assert(loadfile("Games/Duel/GUIs/ScoreBoard_init.cgui"))(gui)

local Background = gui:GetRootWindow()
local ScoreBoardFrame = Background.ScoreBoardFrame

function Background:OnKeyReleased(key)
    if (key==WXK_TAB) then
        gui:close();
        return true;
    else
        return false;
    end
end

Re: GUI not displaying

Posted: 2014-09-12, 17:13
by Carsten
I guess the constant WXK_TAB is nil in Lua.

It's not elegant, but something like

Code: Select all

local CK_TAB = 15
if key == CK_TAB then ...
should work.

See file Console_main.cgui for more examples for key handling.

Re: GUI not displaying

Posted: 2014-09-12, 19:13
by SoulRider
I tried using the code as you do in Console_main.cgui by doing:

Code: Select all

local gui = ...

assert(loadfile("Games/Duel/GUIs/ScoreBoard_init.cgui"))(gui)

local Background = gui:GetRootWindow()
local ScoreBoardFrame = Background.ScoreBoardFrame

function Background:OnKeyReleased(key)
    if (key==15) then       -- Key number 15 is the TAB key,
        gui:close();
        return true;
    else
        return false;
    end
end
and I tried:

Code: Select all

local gui = ...

assert(loadfile("Games/Duel/GUIs/ScoreBoard_init.cgui"))(gui)

local Background = gui:GetRootWindow()
local ScoreBoardFrame = Background.ScoreBoardFrame

function ScoreBoardFrame:OnKeyReleased(key)
    if (key==15) then       -- Key number 15 is the TAB key,
        gui:close();
        return true;
    else
        return false;
    end
end
Either way, the GUI doesn't close when I release the TAB key. Is OnKeyReleased (key) a genuine function? I just guessed at the name because of your naming structure, but I can't find any examples of you using it in the script files to confirm.

Re: GUI not displaying

Posted: 2014-09-13, 10:34
by Carsten
SoulRider wrote:Is OnKeyReleased (key) a genuine function? I just guessed at the name because of your naming structure, but I can't find any examples of you using it in the script files to confirm.
You're right, it is not: The proper name is OnKeyRelease(), that is, without the "d".

Btw., I just realize that while the Event Handler documentation is not perfect, at least the WindowT callbacks are documented.