Thanks. But I noticed, however, that this seems almost like it'd be the kind of problem that's been done before, especially since something similar would crop up in GUI-app programming for a program for any regular GUI-based system: put up a window, and you have to select options in it to continue with some process. The windows may be "modal" or not -- e.g. they block usage of other windows or not when open.
In MS Windows (I'm programming this under Linux, actually, but I'll use MS Windows as an example since it's a GUI system with which I'm familiar), a program using the windowing functionality of the OS has what is called a "message loop", which gets "messages" from the system (which can indicate anything, including keypresses or mouse clicks), and passes them on to the window. This is sort of analogous to the main loop in the program under discussion here, which has it's own internal windowing system and the loop gets input and then passes it on to the window manager and that "makes the windows go".
Now, in MS Windows, when a modeless window ("non-modal") is created, one uses the main message loop. This would then run into the same problems as are involved here, namely, how to resume a command after it has put up a modeless window. Such a call does not block and return, say, what button was clicked, since its processing is handled by the main message loop. So one has the same problem of having to split the command logic across the window. However, I've always (though I never did an extremely huge, sophisticated program on MS Windows) used, and it seems a lot of programs use,
modal windows when the currently-running command needs input from a new window (as opposed to, say, a paint program where you often set options for a tool on a toolbar instead -- I'm not sure that idea could be adepted here or not). So I myself never had to tackle this problem. As mentioned, a modal window blocks usage of the program's main window (and other windows). You have to fill it out to proceed. When a modal window is invoked, a
new message loop is started for that window, and this provides a blocking effect, and when the window closes, the new message loop stops and the command's code is able to resume as normal.
In the case of this program, such a thing would be equivalent to starting up a subsidiary input/logic/render loop in the command's code, e.g. by calling a routine that runs such a loop, for example. However, isn't the idea here to keep everything to one main loop? Otherwise, aren't you then mixing too much with other stuff? If I could find some Windows programs that use a modeless window in the manner indicated, whose source code is available, perhaps maybe that would indicate a solution to the problem. Or, just ask on a Windows programming forum
But then again, MS Windows may not be the best design there is out there -- in which case, perhaps looking at other GUI systems might be useful? As this kind of problem has surely come up before, I'd think.
What do you think?
I have another question, though: In the program as I have it now, the main game object deals with the window manager and the panes making up the game's "GUI" (actually, right now it's just a text mode program, so not really "graphical"
) directly, that is, it actually has separate window-manager and pane objects it works with. Would it make more sense to hide those in some kind of container or something? What do you do in this regard? What kind of methods does your container, if any, have? Also, there is a phase of the game that comes before the main loop, namely the main menu, which requires different panes. And in addition to the 3 main panes of the game (messages, world, and stats), we could have additional panes that appear during the game (like the inventory menu, or "chatting with NPCs" menus). It seems then that if we are using a container, then we either have to expose some panes to the game, thereby seeming to defeat the purpose of the container, or we have to let the container become bloated with methods to handle all the different panes, which then doesn't seem "tidy". What do you think?