#1261 closed defect (fixed)
[PATCH] Control groups are removed after load game
Reported by: | Евгений | Owned by: | Mitchell K |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 10 |
Component: | UI & Simulation | Keywords: | patch, groups, load, loading |
Cc: | mk12360@… | Patch: |
Description
If I create (you known crtl+1,2,3...) several (or only one) control groups of units and save game, then load this save file all the control groups are removed.
And why the game can be loaded only came out to the main menu? It is not convenient.
Attachments (2)
Change History (12)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Cc: | added |
---|---|
Priority: | Release Blocker → Should Have |
I wouldn't call this a release blocker...
I might try fixing this soon.
comment:3 by , 12 years ago
Summary: | Control groups is removed after load game → Control groups are removed after load game |
---|
comment:4 by , 12 years ago
If you haven't seen it already, see gui/session/session.js
getSavedGameData
(with a TODO for saving control groups) - that needs to convert the relevant GUI state into a serializable data structure, which source/ps/SavedGame.cpp
reads into guiMetadata
, and then I can't remember if/where the data is able to be restored into the GUI.
(This won't work for e.g. saving multiplayer games, though - no client knows the other client's control groups, so they can't save that state. I don't know if that matters.)
comment:5 by , 12 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
Ok thanks, I'll look into it today.
comment:6 by , 12 years ago
Keywords: | patch review added |
---|---|
Summary: | Control groups are removed after load game → [PATCH] Control groups are removed after load game |
I think I've come up with a good solution. I tried to implement it so that it will be easy to preserve other GUI data should we want so desire.
My edit to gui/session/selection.js is simply making a couple functions a bit more intuitive. They were looping to build a list of values, than looping through keys with an additional counter to parallel loop with the values. I makes more sense to simply iterate keys and access values through keys.
In gui/session/session.js, I added a restoreSavedGameData(data) function to complement the pre-existing getSavedGameData(). It receives the exact same object as a parameter that getSavedGameData() returns, such that restoreSavedGameData(getSavedGameData()) should have no observable effect.
playerAssignments gets saved in getSavedGameData() but does not get restored in restoreSavedGameData(data) because it is required to start a new game as well, thus init(initData, hotloadData) handles it, and both gamesetup/gamesetup.js and savedgames/load.js pass "playerAssignments" inside initData. In init, I check if there is any saved data and if so send the whole thing to restoreSavedGameData, though there is currently only control groups inside it.
In loadGame() of savedgames/load.js, I simply add a new property to pass on, "savedData". It looks like this:
... "playerAssignments": metadata.gui.playerAssignments, "savedData" : metadata.gui ...
so it contains a duplicate of playerAssignments. Before, I had:
"savedData" : { "groups" : metadata.gui.groups }
but then I realized it would be awkward deconstructing every property except playerAssignments for that (if more GUI state is saved), so it makes more sense to pass the whole thing—and it also makes sense that restoreSavedGameData should have access to playerAssignments as well anyway.
I also implemented this for quicksaving and quickloading (Shift-F5 and Shift-F8). I just added a new string to save the JSON saved game data to upon quicksave, which is then parsed and sent to restoreSavedGameData upon quickload.
That was probably more in depth than it needed to be, but I just wanted to explain my decisions. I hope this patch is useful :-).
by , 12 years ago
Attachment: | Save-Load-Preserve-ControlGroups(1261).patch added |
---|
implements session gui (quick)saving/loading for control groups
comment:7 by , 12 years ago
This looks good to me.
While you are tidying up selection.js you you also make it match this part of our javascript coding conventions?
To convert a string to a number, use the "+" prefix operator (not e.g. parseInt/parseFloat):
by , 12 years ago
Attachment: | Save-Load-Preserve-ControlGroups(1261)-v2.patch added |
---|
comment:10 by , 8 years ago
Keywords: | review removed |
---|
Oh, I forgot to specify the version of the game and my computer (suddenly need):
Game version: Alpha 9 Ides of March. My PC: Windows 7 Ultimate, 64-bit (Service Pack 1), AMD Phenom(tm) 9850 Quad-Core Processor 2.49 GHz, GeForce GTX 260 (driver version 295.73), (two monitors 1920x1200, 1440x900), 4 Gb RAM.