Jump to content

#1191 'esc' key mapped to toggleMenu()


Recommended Posts

Hello, I'm looking to help out with development in my spare time and I was looking to take care of a few small bugs to learn the code base, starting with this one. PM me if you want to learn about me.

So, with regards to this, I just wanted to ask the primary developers their thoughts on how they want this implemented. In the ticket, it says to make the escape key pause the game or toggle the menu, a few questions.

1) Which do we want it to do? Pause (like the pause key) or open the Menu?

1b) If we want it to open the Menu, do we want to pause the game as well?

1c) What should happen if it is a network game?

So, a few other questions, mostly regarding the location of logic in the code base,

1) Where is the code that handles the menu? Is it an overlay?

2) With network games, is there a particular file I should look at to see if an online game is in progress?

Link to comment
Share on other sites

I'll let the programmers answer the programming related questions, but I'll give my opinion on the "what should it do" questions :)

I'd say for non-network game Esc should bring up the menu and pause the game, for network games just bring up the menu (unless perhaps it's the host, but it's probably not worth complicating things like that).

Now for some arguments: I do think we should keep F10 as just bringing up the menu, but it's definitely a good thing to have Esc available as well since it's common in many games. In my opinion Esc is a bit more "brutal" =) so it's not a bad thing to have it pause the game as well, especially if we still keep F10 for the non-pausing menu if you just want to bring up an in-game settings menu to change the settings that can be changed while the game is running or something, so you have that choice. A multiplayer game should probably never be possible to pause (unless you mean a "hard pause" where you save the game, shut it down and then restart later), I guess it might be nice to have the ability in some cases, but it's probably just as well to leave that for the general pause key in that case. In either case pausing a multiplayer game should only be possible for the host if possible, imho.

Link to comment
Share on other sites

Hello, I'm looking to help out with development in my spare time
Welcome. Thanks for your interest in the game.
1) Which do we want it to do? Pause (like the pause key) or open the Menu?

1b) If we want it to open the Menu, do we want to pause the game as well?

1c) What should happen if it is a network game?

When in single player, Esc should open the menu and pause the game. If the menu is already open, it should close the menu and resume the game.

In network games, it should not pause at all, just toggle the menu.

Also, ESC maps to closing dialogs like the chat window. This shouldn't be broken. So only open and pause when no dialog is open already.

I'll leave a more experience developer to answer the other questions.

Link to comment
Share on other sites

Welcome to the forums.

All the code needed for this task should be in gui/session/. The files you are looking for are session.js (contains g_IsNetworked to check for a network game), session.xml for the gui placement and function calling and menu.js for the menu code.

And if you have finished this task we have a list of starter task (those can get you accustomed to our codebase).

Link to comment
Share on other sites

Working off all of that, is there a state machine being used so we know where we are whenever, as opposed to just querying an "isnetworked" variable?

For the menu, I guess my question would be better worded as, where is the mouse click handled/hotkey (if not in Hotkey.cpp) for overlays? When I was playing around in there, I never picked up on mouse clicks. Digging around I see the input.js file which brings me to my next question. How is/where are the interop files for going between the GUI js stuff and the backend C/C++? I mean, I'm not completely clueless about this stuff with the one game I have under my belt, but right now I just have no idea where things are.

Link to comment
Share on other sites

Well I guess querying the g_IsNetworked variable is your best bet as the gui is separeted from the simulation. The interaction with the simulation is mostly done through simulation/components/GuiInterface.js (and performCommands in helpers/Commands.js).

The mouse click is handled in session.xml

<action on="Press">doSomething();</action>

You probably won't need to touch the C++ side of the code base for this ticket at all.

Link to comment
Share on other sites

Well I guess querying the g_IsNetworked variable is your best bet as the gui is separeted from the simulation. The interaction with the simulation is mostly done through simulation/components/GuiInterface.js (and performCommands in helpers/Commands.js).

The mouse click is handled in session.xml

<action on="Press">doSomething();</action>

You probably won't need to touch the C++ side of the code base for this ticket at all.

I found the file you're talking about and that's making sense but I can't seem to figure out where the hotkeys are defined. For example, in session.xml

<object hotkey="chat">

<action on="Press">toggleChatWindow();</action>

</object>

the string "chat" is used but in all of the included files (below) I couldn't find a reference to it. Where are these located?

<script file="gui/common/functions_civinfo.js"/>

<script file="gui/common/functions_utility.js" />

...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...