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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
/*-- Setup Menu --*/
#strict 2
static const
SETTING_Deathmatch = 0, SETTING_SuddenDeath = 1, SETTING_RotateInJump = 2,
SETTING_RelaunchesInc = 3, SETTING_RelaunchesDec = 4,
SETTING_DeathmatchScoreInc = 5, SETTING_DeathmatchScoreDec = 6,
SETTING_Ambience = 7;
local Sections, Modes;
local clonk, setupPlayer;
// Selected values
local section, mode;
local suddendeathEnabled, rotateInJumpEnabled;
local ambienceEnabled;
local numRelaunches;
local deathmatchEnabled, deathmatchWinScore;
protected func Initialize()
{
Sections = [];
for (var i = 0, def; def = GetDefinition(i, C4D_StaticBack); ++i)
{
if (DefinitionCall(def, "SectionName")) Sections[GetLength(Sections)] = def;
}
section = Sections[0];
Modes = [
[MODE_Classic, "$ModeClassic$", CLSC],
[MODE_Magic, "$ModeMagic$", MLPG],
[MODE_Knightly, "$ModeKnightly$", MKNI],
[MODE_Apocalyptic, "$ModeApocalyptic$", APCE],
[MODE_Festive, "$ModeFestive$", FSTV]];
}
private func ShowSetup()
{
ShowMessage();
ShowSectionMenu();
}
private func ShowSectionMenu()
{
CreateMenu(GetID(), clonk, 0, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
for (var i = 0; i < GetLength(Sections); ++i)
{
clonk->AddMenuItem(GetName(0, Sections[i]), Format("SelectSection(%i)", Sections[i]), Sections[i]);
CheckPreselect(Sections[i] == section, i);
}
}
private func SelectSection(id selectedSection)
{
section = selectedSection;
ShowMessage();
ShowModeMenu();
}
private func ShowModeMenu()
{
CreateMenu(GetID(), clonk, 0, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
var menuItemIndex = 0;
for (var m in Modes)
{
clonk->AddMenuItem(m[1], Format("SelectMode(%d)", m[0]), m[2]);
CheckPreselect(m[0] == mode, menuItemIndex++);
}
clonk->AddMenuItem("$Back$", "ShowSectionMenu()", SBCK);
}
private func SelectMode(int selectedMode)
{
mode = selectedMode;
ShowMessage();
ShowSettingsMenu();
}
private func ShowSettingsMenu(bool preselect, int selectedSetting)
{
CreateMenu(GetID(), clonk, 0, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
var menuItemIndex = 0;
// Deathmatch entry
AddOptionMenuItem(GetName(0, DTHM), deathmatchEnabled, "SelectSetting(SETTING_Deathmatch)", DTHM);
CheckPreselect(preselect && selectedSetting == SETTING_Deathmatch, menuItemIndex++);
// Sudden Death entry
AddOptionMenuItem(GetName(0, SDDT), suddendeathEnabled, "SelectSetting(SETTING_SuddenDeath)", SDDT);
CheckPreselect(preselect && selectedSetting == SETTING_SuddenDeath, menuItemIndex++);
// "Turn in jump" entry
AddOptionMenuItem(GetName(0, RIJP), rotateInJumpEnabled, "SelectSetting(SETTING_RotateInJump)", RIJP);
CheckPreselect(preselect && selectedSetting == SETTING_RotateInJump, menuItemIndex++);
// Ambience entry
AddOptionMenuItem("$Ambience$", ambienceEnabled, "SelectSetting(SETTING_Ambience)", SABC);
CheckPreselect(preselect && selectedSetting == SETTING_Ambience, menuItemIndex++);
if (!deathmatchEnabled)
{
clonk->AddMenuItem("$Relaunches$ +", "SelectSetting(SETTING_RelaunchesInc)", SREL);
CheckPreselect(preselect && selectedSetting == SETTING_RelaunchesInc, menuItemIndex++);
clonk->AddMenuItem("$Relaunches$ -", "SelectSetting(SETTING_RelaunchesDec)", SREL);
CheckPreselect(preselect && selectedSetting == SETTING_RelaunchesDec, menuItemIndex++);
}
else
{
clonk->AddMenuItem("$Kills$ +", "SelectSetting(SETTING_DeathmatchScoreInc)", SKIL);
CheckPreselect(preselect && selectedSetting == SETTING_DeathmatchScoreInc, menuItemIndex++);
clonk->AddMenuItem("$Kills$ -", "SelectSetting(SETTING_DeathmatchScoreDec)", SKIL);
CheckPreselect(preselect && selectedSetting == SETTING_DeathmatchScoreDec, menuItemIndex++);
}
clonk->AddMenuItem("$Done$", "SetupDone()", SDNE);
CheckPreselect(!preselect, menuItemIndex++);
clonk->AddMenuItem("$Back$", "ShowModeMenu()", SBCK);
}
private func SelectSetting(int selectedSetting)
{
if (selectedSetting == SETTING_Deathmatch)
{
deathmatchEnabled = !deathmatchEnabled;
}
else if (selectedSetting == SETTING_SuddenDeath)
{
suddendeathEnabled = !suddendeathEnabled;
}
else if (selectedSetting == SETTING_RotateInJump)
{
rotateInJumpEnabled = !rotateInJumpEnabled;
}
else if (selectedSetting == SETTING_Ambience)
{
ambienceEnabled = !ambienceEnabled;
}
else if (selectedSetting == SETTING_RelaunchesInc)
{
numRelaunches = Min(numRelaunches + 1, 10);
}
else if (selectedSetting == SETTING_RelaunchesDec)
{
numRelaunches = Max(numRelaunches - 1, 3);
}
else if (selectedSetting == SETTING_DeathmatchScoreInc)
{
++deathmatchWinScore;
}
else if (selectedSetting == SETTING_DeathmatchScoreDec)
{
deathmatchWinScore = Max(deathmatchWinScore - 1, 1);
}
ShowMessage();
ShowSettingsMenu(true, selectedSetting);
}
private func SetupDone()
{
ShowMessage();
GameCall("SetupDone", this, GetMessage());
}
private func AddOptionMenuItem(string caption, bool enabled, string command, id idItem)
{
clonk->AddMenuItem(IIf(enabled, caption, Format("<c a0a0a0>%s</c>", caption)), command, idItem);
}
private func CheckPreselect(bool preselect, int menuItemIndex)
{
if (preselect) clonk->SelectMenuItem(menuItemIndex);
}
private func KeepMenuOpen()
{
// Find new player?
if (!GetPlayerID(setupPlayer))
{
clonk = 0;
if (GetPlayerCount() == 0) return;
setupPlayer = GetPlayerByIndex(0);
}
// Find clonk
if (!clonk || !clonk->GetAlive()) clonk = GetCrew(setupPlayer);
// (Re)open menu
if (clonk && !clonk->GetMenu()) ShowSetup();
}
private func ShowMessage() { CustomMessage(Format("@%s", GetMessage()), this, NO_OWNER, 0, 0, 0, 0, 0, MSG_NoLinebreak); }
private func GetMessage()
{
var msgSection = Format("$Landscape$: {{%i}} %s", section, GetName(0, section));
var msgMode;
for (var m in Modes)
{
if (m[0] == mode)
{
msgMode = Format("$Mode$: {{%i}} %s", m[2], m[1]);
break;
}
}
var msgWinScore;
if (!deathmatchEnabled)
{
msgWinScore = Format("{{SREL}} $Relaunches$: %d", numRelaunches);
}
else
{
msgWinScore = Format("{{SKIL}} %s: %d $Kills$", GetName(0, DTHM), deathmatchWinScore);
}
var msgSuddenDeath = Format("{{SDDT}} %s: %s", GetName(0, SDDT), IIf(suddendeathEnabled, "$Enabled$", "$Disabled$"));
var msgRotateInJump = Format("{{RIJP}} %s: %s", GetName(0, RIJP), IIf(rotateInJumpEnabled, "$Enabled$", "$Disabled$"));
var msgAmbience = Format("{{SABC}} $Ambience$: %s", IIf(ambienceEnabled, "$Enabled$", "$Disabled$"));
return Format("%s|%s|%s|%s|%s|%s", msgSection, msgMode, msgWinScore, msgSuddenDeath, msgRotateInJump, msgAmbience);
}
|