Serialize popup window size and location

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Serialize popup window size and location

#1 Post by vincele »

I would like to tackle that subject:

- serialize popup window's size & location at game quit
- restore them at game start / load time

Where should I start ?
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Serialize popup window size and location

#2 Post by Geoff the Medio »

Set up a bunch of options in the OptionsDB, in the source file where the relevant windows are created. When re-creating them at startup, select their positions by querying the OptionsDB. Also set up some signalling so that when the windows are moved (or perhaps when pinned?), their positions are written to the OptionsDB.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Serialize popup window size and location

#3 Post by Dilvish »

Serializing would fit as part of saving the info in the saved game file, so that individual games could have different persistent locations for those windows.

As Geoff just suggested, I think we'd be better off instead saving the info to the options file. That wouldn't mean that it would have to have a control widget in the options window, it's simply a place to store the info so that it is consistent across games. Perhaps take a look at the main window resolution handling (skipping the control widget).
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Serialize popup window size and location

#4 Post by Geoff the Medio »

Also, for window positions, there needs to be some checks in place so windows don't get put off the screen where the user can't access them due to changes in main window size. At the least, a "reset to default window positions" button needs to be avaiable somewhere always-accessible.

Post Reply