← Back to team overview

widelands-dev team mailing list archive

Re: Architecture question concerning ui_basic/ui_fsmenu

 

I will go with the template design and separate enums for now. Since
doing away with return codes altogether is a big project, I'd rather
have this clean right now.

It would be great to have you back, Matthias! Is there a way you can
break down the changes into smaller branches, now that you have an idea
of what is needed? To start implementing the prerequisites that you have
identified first, maybe?



Sgrìobh Matthias Horne na leanas 06/08/2015 aig 10:03:
> Hi,
> 
> I just wanted to share some thoughts regarding the event handling and
> main loop I had about two or even three years ago, but since then never
> found the time and motivation to realize them. The problem is, the
> architectural change is very fundamental.
> 
> Right now the main loop is in UI::Panel, but should actually be in
> WlApplication. Another problem is that the button clicks in the main
> menu are handled through return types. I suggest a design where a new
> GUI class takes control of the GUI and is independent from the Widelands
> simulation (just displays results from simmulation). So in the main loop
> the simulation is run first (which now is the think function in
> UI::Panel) and then the GUI is drawn. The GUI class is also responsible
> for keeping a stack of FullscreenMenus to implement the "Back" buttons
> easily. To switch from the main menu to another menu, the new menu is
> simply put on top of the stack, when it is removed the element "below"
> becomes active again. This design also makes loading a game from within
> another game and a "next campaign" button quite easy: Clear the GUI
> stack and initialize a new game. No need to code that information in
> return types, since the single main loop will always run in
> WLApplication and there are no longer nested main loops like today.
> 
> I hope I could explain my idea clearly. Of course there are some
> problems that stopped me from implementing it:
> - The loading screen: I did not find an easy way to make it compatible
> with my new design and keeping it responsive/not freezing. My idea was
> to split the loading process into small tasks using lambda functions and
> run them in between draw calls. However I had a hard time understanding
> the loading process.
> - The modal story dialogs: They stop the game on a very basic level, by
> running their own main loop. I think it is enough to just set the game
> speed to 0.
> - Simulation and presentation are very tightly coupled. The suggested
> design facilitates and requires a stricter separation.
> 
> These are the problems I still remember. I had a branch that managed to
> successfully start the tutorial with this new design, but it was really
> messy to do all the necessary changes and it is such a central part of
> the game that I was to afraid to continue. And of course my studies
> required more attention and I just followed Widelands passively. Maybe
> now is the time to come back.
> 
> Best, Matthias
> 
> 
> On 05.08.2015 17:12, Fòram na Gàidhlig wrote:
>> I am working on a new branch to handle keypresses. This let me to do
>> some refactoring on the return codes, to give them all names rather than
> 
>> using plain numbers.
>>
>> At the moment, I have 2 different types of named codes:
>>
>> 1. Two const int values in UI::Panel as generic codes (dying_code,
>> ok_code) [1]
>>
>> 2. An enum class in FullscreenMenuBase with Widelands-specific codes
>> (kTutorial, kSinglePlayer etc.) [2]
>>
>> I think we should have one global enum class with all the return codes
>> in it, and use it as the argument/return type for Panel::run() and
>> Panel::end_modal(). This way, we could get rid of all plain numbers and
>> hodgepodge scattered enums permanently via type safety.
>>
>> However, we want to keep ui_basic from being Widelands-specific. So,
>> where is the best way to put them?
>>
>>
>>
>> [1]
>> https://bazaar.launchpad.net/~widelands-dev/widelands/bug-1480937/view/head:/src/ui_basic/panel.h#L91
>>
>> [2]
>> https://bazaar.launchpad.net/~widelands-dev/widelands/bug-1480937/view/head:/src/ui_fsmenu/base.h#L43
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~widelands-dev
>> Post to     : widelands-dev@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~widelands-dev
>> More help   : https://help.launchpad.net/ListHelp
>>
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~widelands-dev
> Post to     : widelands-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~widelands-dev
> More help   : https://help.launchpad.net/ListHelp
> 
> 
> -----
> E-Mail ist virenfrei.
> Von AVG überprüft - www.avg.de
> Version: 2015.0.6125 / Virendatenbank: 4392/10383 - Ausgabedatum: 06.08.2015 
> 
> 
> 

-- 
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.22 (MingW32)

mQINBFNbSyEBEADh+uhohycnZgPPnyMs5pZQG6pKyLzFZoIKbVjY31ZoPZ2SdltB
elrwn6kFZkQiDx4K6nkZFHsPh8RMvWoFWg1rGiWkdsZessLFawraC8YEZDwtlaU5
SFXbE4+QnMfbPhe9tmC8Nbhec3dfV9zcXAhxc+zkIUsKFhSkpJ2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