GUI not displaying
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.
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.44KiB)Downloaded 669 times
-
- ScoreBoard_main.cgui
- (174Bytes)Downloaded 651 times
Re: GUI not displaying
Hi SoulRider,
I'll have another look at this tomorrow morning, but at a first glance, it looks as if the
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.
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.
Best regards,
Carsten
Carsten
Re: GUI not displaying
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
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.
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
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
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
You could insert something like
e.g. once in the
Without knowing anything else about the changes you've made, this is probably the most effective way to debug this problem.
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;
}
CaKeyboardEventT::CK_TAB
key?You could insert something like
Code: Select all
Console->Print("Key CK_xyz was pressed.\n");
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
Carsten
Re: GUI not displaying
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
I guess the constant
It's not elegant, but something like
should work.
See file
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 ...
See file
Console_main.cgui
for more examples for key handling.Best regards,
Carsten
Carsten
Re: GUI not displaying
I tried using the code as you do in Console_main.cgui by doing:
and I tried:
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.
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
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
Re: GUI not displaying
You're right, it is not: The proper name isSoulRider 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.
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
Carsten
Who is online
Users browsing this forum: No registered users and 8 guests