GUI not displaying

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
Post Reply
SoulRider
Posts: 95
Joined: 2014-04-06, 00:16

GUI not displaying

Post by SoulRider » 2014-09-09, 05:56

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.
Attachments
ScoreBoard_init.cgui
(2.44 KiB) Downloaded 121 times
ScoreBoard_main.cgui
(174 Bytes) Downloaded 108 times
User avatar
Carsten
Site Admin
Posts: 2160
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: GUI not displaying

Post by Carsten » 2014-09-09, 23:44

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:
Best regards,
Carsten
SoulRider
Posts: 95
Joined: 2014-04-06, 00:16

Re: GUI not displaying

Post by SoulRider » 2014-09-10, 05:28

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.
User avatar
Carsten
Site Admin
Posts: 2160
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: GUI not displaying

Post by Carsten » 2014-09-10, 09:48

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.
Best regards,
Carsten
SoulRider
Posts: 95
Joined: 2014-04-06, 00:16

Re: GUI not displaying

Post by SoulRider » 2014-09-11, 01:40

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
User avatar
Carsten
Site Admin
Posts: 2160
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: GUI not displaying

Post by Carsten » 2014-09-12, 17:13

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.
Best regards,
Carsten
SoulRider
Posts: 95
Joined: 2014-04-06, 00:16

Re: GUI not displaying

Post by SoulRider » 2014-09-12, 19:13

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.
User avatar
Carsten
Site Admin
Posts: 2160
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: GUI not displaying

Post by Carsten » 2014-09-13, 10:34

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.
Best regards,
Carsten
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest