-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSaveLoadGameGUI.asc
More file actions
181 lines (166 loc) · 3.85 KB
/
SaveLoadGameGUI.asc
File metadata and controls
181 lines (166 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// new module script
/**
* http://www.adventuregamestudio.co.uk/wiki/Creating_Custom_Save_and_Load_Dialogs
*/
function initSaveLoadGameDialog(bool isSaveGameDialog)
{
mouse.UseModeGraphic(eModePointer);
gIconbar.Visible = false;
if(gOptions.Visible) gOptions.Visible = false;
lstSaveGames.FillSaveGameList();
lstSaveGames.SelectedIndex = 0;
if(lstSaveGames.SelectedIndex != -1)
{
txtSaveName.Text = lstSaveGames.Items[lstSaveGames.SelectedIndex];
}
if(isSaveGameDialog)
{
lblSaveLoadDescription.Text = "Type the description of the saved game.";
txtSaveName.Visible = true;
btnSave.Visible = true;
btnLoad.Visible = false;
}
else
{
lblSaveLoadDescription.Text = "Select the game you would like to load.";
txtSaveName.Visible = false;
btnSave.Visible = false;
btnLoad.Visible = true;
}
gSaveLoadGame.Visible = true;
}
/**
* http://www.adventuregamestudio.co.uk/wiki/Creating_Custom_Save_and_Load_Dialogs
*/
function cancelSaveLoadGame_OnClick()
{
if(cEgo.Room != 100)
{
mouse.reloadCursor();
mouse.UseDefaultGraphic();
}
gIconbar.Visible = true;
gSaveLoadGame.Visible = false;
UnPauseGame();
}
/*
* http://www.adventuregamestudio.co.uk/wiki/Creating_Custom_Save_and_Load_Dialogs
*/
function save_OnClick(GUIControl *control, MouseButton button)
{
int totalSaves = lstSaveGames.ItemCount;
String saveName = txtSaveName.Text;
if(saveName == "")
{
Display("Please enter a name for your savegame");
return;
}
if(lstSaveGames.SelectedIndex == -1)
{
SaveGameSlot(totalSaves+1, saveName);
cancelSaveLoadGame_OnClick();
return;
}
else
{
int checkSave = 0;
while(checkSave != totalSaves)
{
if(saveName == lstSaveGames.Items[checkSave])
{
SaveGameSlot(savegameindex[checkSave], saveName);
cancelSaveLoadGame_OnClick();
return;
}
checkSave++;
}
SaveGameSlot(totalSaves+1, saveName);
cancelSaveLoadGame_OnClick();
}
}
/**
* http://www.adventuregamestudio.co.uk/wiki/Creating_Custom_Save_and_Load_Dialogs
*/
function load_OnClick(GUIControl *control, MouseButton button)
{
int totalLoads = lstSaveGames.ItemCount;
if(lstSaveGames.SelectedIndex == -1)
{
Display("Please select a slot to load.");
}
else if(lstSaveGames.SelectedIndex >= 0)
{
RestoreGameSlot(savegameindex[lstSaveGames.SelectedIndex]);
cancelSaveLoadGame_OnClick();
}
}
/**
* http://www.adventuregamestudio.co.uk/wiki/Creating_Custom_Save_and_Load_Dialogs
*/
function deleteSaveGame_OnClick(GUIControl *control, MouseButton button)
{
if(lstSaveGames.SelectedIndex != -1)
{
DeleteSaveSlot(savegameindex[lstSaveGames.SelectedIndex]);
lstSaveGames.FillSaveGameList();
}
else
{
Display("Please select a save slot to delete.");
}
}
/**
* http://www.adventuregamestudio.co.uk/wiki/Creating_Custom_Save_and_Load_Dialogs
*/
function saveGames_OnSelectionChange(GUIControl *control)
{
txtSaveName.Text = lstSaveGames.Items[lstSaveGames.SelectedIndex];
}
function game_start () {
gSaveLoadGame.Visible = false;
gSaveLoadGame.Centre();
}
function on_key_press(int keycode)
{
if (cEgo.Room != 100 && cEgo.Room != 101)
{
if(keycode==363)// F5
{
if(gSaveLoadGame.Visible)
{
cancelSaveLoadGame_OnClick();
}
else
{
PauseGame();
initSaveLoadGameDialog(true);
}
}
if (keycode==365)// F7
{
if(gSaveLoadGame.Visible)
{
cancelSaveLoadGame_OnClick();
}
else
{
PauseGame();
initSaveLoadGameDialog(false);
}
}
}
}
function on_mouse_click(MouseButton button)
{
if(gSaveLoadGame.Visible)
{
if(button == eMouseWheelNorth)
{
lstSaveGames.ScrollUp();
}
else if(button == eMouseWheelSouth)
{
lstSaveGames.ScrollDown();
}
}
}