diff --git a/binaries/data/mods/public/gui/savedgames/load.js b/binaries/data/mods/public/gui/savedgames/load.js
index de1150c..9e38cb6 100644
a
|
b
|
function generateLabel(metadata)
|
14 | 14 | |
15 | 15 | var date = t.getFullYear()+"-"+twoDigits(1+t.getMonth())+"-"+twoDigits(t.getDate()); |
16 | 16 | var time = twoDigits(t.getHours())+":"+twoDigits(t.getMinutes())+":"+twoDigits(t.getSeconds()); |
17 | | return "["+date+" "+time+"] "+metadata.initAttributes.map; |
| 17 | return "["+date+" "+time+"] "+metadata.initAttributes.map+(metadata.savename?" ("+metadata.savename+")":""); |
18 | 18 | } |
19 | 19 | |
20 | 20 | function init() |
diff --git a/binaries/data/mods/public/gui/session/menu.js b/binaries/data/mods/public/gui/session/menu.js
index ae3b5b6..5f7e9e8 100644
a
|
b
|
const RESUME = "Resume";
|
9 | 9 | const MARGIN = 4; |
10 | 10 | |
11 | 11 | // Includes the main menu button |
12 | | const NUM_BUTTONS = 8; |
| 12 | const NUM_BUTTONS = 9; |
13 | 13 | |
14 | 14 | // Regular menu buttons |
15 | 15 | const BUTTON_HEIGHT = 32; |
… |
… |
function exitMenuButton()
|
148 | 148 | messageBox(400, 200, "Are you sure you want to quit?", "Confirmation", 0, btCaptions, btCode); |
149 | 149 | } |
150 | 150 | |
| 151 | function openSaveAs() |
| 152 | { |
| 153 | closeMenu(); |
| 154 | closeOpenDialogs(); |
| 155 | pauseGame(); |
| 156 | |
| 157 | getGUIObjectByName("saveAsPanel").focus(); |
| 158 | getGUIObjectByName("saveAsPanel").hidden = false; |
| 159 | |
| 160 | } |
| 161 | |
| 162 | function closeSaveAs() |
| 163 | { |
| 164 | getGUIObjectByName("saveAsPanel").hidden = true; |
| 165 | |
| 166 | resumeGame(); |
| 167 | } |
| 168 | |
| 169 | |
151 | 170 | function openDeleteDialog(selection) |
152 | 171 | { |
153 | 172 | closeMenu(); |
diff --git a/binaries/data/mods/public/gui/session/session.xml b/binaries/data/mods/public/gui/session/session.xml
index 38d2e5b..583470d 100644
a
|
b
|
|
427 | 427 | </object> |
428 | 428 | |
429 | 429 | <!-- ================================ ================================ --> |
| 430 | <!-- Save As Window --> |
| 431 | <!-- ================================ ================================ --> |
| 432 | <object name="saveAsPanel" |
| 433 | style="StoneDialog" |
| 434 | type="image" |
| 435 | size="50%-180 50%-64 50%+180 50%+64" |
| 436 | hidden="true" |
| 437 | z="200" |
| 438 | > |
| 439 | <object type="text" style="TitleText" size="50%-96 -16 50%+96 16">Save Game As</object> |
| 440 | <object size="25%-64 35%-12 25%+64 35%+12" type="text" style="LeftLabelText"> |
| 441 | Save As: |
| 442 | </object> |
| 443 | <object name="savegameName" size="25% 35%-12 95%-8 35%+12" type="input" style="StoneInput" max_length="80"> |
| 444 | savegame |
| 445 | </object> |
| 446 | |
| 447 | <!-- Cancel button --> |
| 448 | <object type="button" |
| 449 | style="StoneButton" |
| 450 | size="75%-64 100%-52 75%+64 100%-24" |
| 451 | tooltip_style="sessionToolTip" |
| 452 | > |
| 453 | Cancel |
| 454 | <action on="Press">closeSaveAs();</action> |
| 455 | </object> |
| 456 | <!-- Save button --> |
| 457 | <object type="button" |
| 458 | style="StoneButton" |
| 459 | size="25%-64 100%-52 25%+64 100%-24" |
| 460 | tooltip_style="sessionToolTip" |
| 461 | > |
| 462 | Save |
| 463 | <action on="Press">closeSaveAs();Engine.SaveGameAs(getGUIObjectByName("savegameName").caption);</action> |
| 464 | </object> |
| 465 | </object> |
| 466 | |
| 467 | <!-- ================================ ================================ --> |
430 | 468 | <!-- Settings Window --> |
431 | 469 | <!-- ================================ ================================ --> |
432 | 470 | <object name="settingsDialogPanel" |
… |
… |
|
707 | 745 | </action> |
708 | 746 | </object> |
709 | 747 | |
| 748 | <!-- Save game as button --> |
| 749 | <object type="button" |
| 750 | name="saveGameAsButton" |
| 751 | style="StoneButtonFancy" |
| 752 | size="0 64 100% 92" |
| 753 | tooltip_style="sessionToolTip" |
| 754 | > |
| 755 | Save As |
| 756 | <action on="Press"> |
| 757 | |
| 758 | openSaveAs(); |
| 759 | </action> |
| 760 | </object> |
| 761 | |
710 | 762 | <!-- Chat button --> |
711 | 763 | <object type="button" |
712 | 764 | name="chatButton" |
713 | 765 | style="StoneButtonFancy" |
714 | | size="0 64 100% 92" |
| 766 | size="0 96 100% 124" |
715 | 767 | tooltip_style="sessionToolTip" |
716 | 768 | > |
717 | 769 | Chat |
… |
… |
|
722 | 774 | <object type="button" |
723 | 775 | name="menuResignButton" |
724 | 776 | style="StoneButtonFancy" |
725 | | size="0 96 100% 124" |
| 777 | size="0 128 100% 156" |
726 | 778 | tooltip_style="sessionToolTip" |
727 | 779 | > |
728 | 780 | Resign |
… |
… |
|
733 | 785 | <object type="button" |
734 | 786 | name="menuExitButton" |
735 | 787 | style="StoneButtonFancy" |
736 | | size="0 128 100% 156" |
| 788 | size="0 160 100% 188" |
737 | 789 | tooltip_style="sessionToolTip" |
738 | 790 | > |
739 | 791 | Exit |
… |
… |
|
744 | 796 | <object type="button" |
745 | 797 | name="pauseButton" |
746 | 798 | style="StoneButtonFancy" |
747 | | size="0 160 100% 188" |
| 799 | size="0 192 100% 220" |
748 | 800 | tooltip_style="sessionToolTip" |
749 | 801 | > |
750 | 802 | <object name="pauseButtonText" type="text" style="CenteredButtonText" ghost="true">Pause</object> |
… |
… |
|
755 | 807 | <object type="button" |
756 | 808 | name="manualButton" |
757 | 809 | style="StoneButtonFancy" |
758 | | size="0 192 100% 220" |
| 810 | size="0 224 100% 252" |
759 | 811 | tooltip_style="sessionToolTip" |
760 | 812 | > |
761 | 813 | Manual |
diff --git a/source/gui/scripting/ScriptFunctions.cpp b/source/gui/scripting/ScriptFunctions.cpp
index dd530cb..b8febdc 100644
a
|
b
|
void SaveGame(void* cbdata)
|
266 | 266 | LOGERROR(L"Failed to save game"); |
267 | 267 | } |
268 | 268 | |
| 269 | void SaveGameAs(void* cbdata, std::wstring prefix) |
| 270 | { |
| 271 | CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata); |
| 272 | |
| 273 | if (SavedGames::Save(prefix, *g_Game->GetSimulation2(), guiManager, g_Game->GetPlayerID()) < 0) |
| 274 | LOGERROR(L"Failed to save game as"); |
| 275 | } |
| 276 | |
269 | 277 | void SetNetworkGameAttributes(void* cbdata, CScriptVal attribs) |
270 | 278 | { |
271 | 279 | CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata); |
… |
… |
void GuiScriptingInit(ScriptInterface& scriptInterface)
|
670 | 678 | scriptInterface.RegisterFunction<std::vector<CScriptValRooted>, &GetSavedGames>("GetSavedGames"); |
671 | 679 | scriptInterface.RegisterFunction<bool, std::wstring, &DeleteSavedGame>("DeleteSavedGame"); |
672 | 680 | scriptInterface.RegisterFunction<void, &SaveGame>("SaveGame"); |
| 681 | scriptInterface.RegisterFunction<void, std::wstring, &SaveGameAs>("SaveGameAs"); |
673 | 682 | scriptInterface.RegisterFunction<void, &QuickSave>("QuickSave"); |
674 | 683 | scriptInterface.RegisterFunction<void, &QuickLoad>("QuickLoad"); |
675 | 684 | |
diff --git a/source/ps/SavedGame.cpp b/source/ps/SavedGame.cpp
index 20bb944..837fafa 100644
a
|
b
|
|
1 | | /* Copyright (C) 2012 Wildfire Games. |
| 1 | /* Copyright (C) 2013 Wildfire Games. |
2 | 2 | * This file is part of 0 A.D. |
3 | 3 | * |
4 | 4 | * 0 A.D. is free software: you can redistribute it and/or modify |
… |
… |
Status SavedGames::Save(const std::wstring& prefix, CSimulation2& simulation, CG
|
68 | 68 | simulation.GetScriptInterface().SetProperty(metadata.get(), "version_minor", SAVED_GAME_VERSION_MINOR); |
69 | 69 | simulation.GetScriptInterface().SetProperty(metadata.get(), "time", (double)now); |
70 | 70 | simulation.GetScriptInterface().SetProperty(metadata.get(), "player", playerID); |
| 71 | simulation.GetScriptInterface().SetProperty(metadata.get(), "savename", prefix); |
71 | 72 | simulation.GetScriptInterface().SetProperty(metadata.get(), "initAttributes", simulation.GetInitAttributes()); |
72 | 73 | if (gui) |
73 | 74 | { |
diff --git a/source/ps/SavedGame.h b/source/ps/SavedGame.h
index 019f31b..93f8881 100644
a
|
b
|
|
1 | | /* Copyright (C) 2012 Wildfire Games. |
| 1 | /* Copyright (C) 2013 Wildfire Games. |
2 | 2 | * This file is part of 0 A.D. |
3 | 3 | * |
4 | 4 | * 0 A.D. is free software: you can redistribute it and/or modify |