summaryrefslogtreecommitdiffstats
path: root/TemplePushing.c4s/Misc.c4d/SetupMenu.c4d/Script.c
diff options
context:
space:
mode:
authorJan <>2015-02-02 17:55:29 +0100
committerJan <_>2015-07-10 17:49:45 +0200
commit32a9632fbca3dd7a88bd3154b84a3773af39c276 (patch)
treea226b9404844a73c7229e9d13db993c86b5be2c1 /TemplePushing.c4s/Misc.c4d/SetupMenu.c4d/Script.c
parent40fb3e5d61c44886b06d839a35adb0c11a5f918f (diff)
downloadtempelschubsen-32a9632fbca3dd7a88bd3154b84a3773af39c276.tar.gz
tempelschubsen-32a9632fbca3dd7a88bd3154b84a3773af39c276.zip
TemplePush v6.1.7601.18409.c4s
Diffstat (limited to 'TemplePushing.c4s/Misc.c4d/SetupMenu.c4d/Script.c')
-rw-r--r--TemplePushing.c4s/Misc.c4d/SetupMenu.c4d/Script.c243
1 files changed, 243 insertions, 0 deletions
diff --git a/TemplePushing.c4s/Misc.c4d/SetupMenu.c4d/Script.c b/TemplePushing.c4s/Misc.c4d/SetupMenu.c4d/Script.c
new file mode 100644
index 0000000..0577e73
--- /dev/null
+++ b/TemplePushing.c4s/Misc.c4d/SetupMenu.c4d/Script.c
@@ -0,0 +1,243 @@
+/*-- Setup Menu --*/
+
+#strict 2
+
+static const
+ SETTING_Deathmatch = 0, SETTING_Extinguisher = 1, SETTING_FriendlyPushing = 2, SETTING_RotateInJump = 3,
+ SETTING_RelaunchesInc = 4, SETTING_RelaunchesDec = 5,
+ SETTING_DeathmatchScoreInc = 6, SETTING_DeathmatchScoreDec = 7,
+ SETTING_Ambience = 8;
+
+local Sections, Modes;
+local clonk, setupPlayer;
+
+// Selected values
+local section, mode;
+local extinguisherEnabled, friendlyPushingEnabled, 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$", ROCK],
+ [MODE_SuddenDeath, "$ModeSuddenDeath$", SDDT],
+ [MODE_Magic, "$ModeMagic$", SMGC],
+ [MODE_Apocalyptic, "$ModeApocalyptic$", APCE]];
+}
+
+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()", ROCK);
+}
+
+private func SelectMode(int selectedMode)
+{
+ mode = selectedMode;
+ if (mode == MODE_SuddenDeath) deathmatchEnabled = false;
+ 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
+ if (mode != MODE_SuddenDeath)
+ {
+ AddOptionMenuItem(GetName(0, DTHM), deathmatchEnabled, "SelectSetting(SETTING_Deathmatch)", DTHM);
+ CheckPreselect(preselect && selectedSetting == SETTING_Deathmatch, menuItemIndex++);
+ }
+
+ // Extinguisher entry
+ AddOptionMenuItem(GetName(0, _ETG), extinguisherEnabled, "SelectSetting(SETTING_Extinguisher)", _ETG);
+ CheckPreselect(preselect && selectedSetting == SETTING_Extinguisher, menuItemIndex++);
+
+ // "Friendly Pushing" entry
+ AddOptionMenuItem(GetName(0, FYPG), friendlyPushingEnabled, "SelectSetting(SETTING_FriendlyPushing)", FYPG);
+ CheckPreselect(preselect && selectedSetting == SETTING_FriendlyPushing, 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)", SKUL);
+ CheckPreselect(preselect && selectedSetting == SETTING_RelaunchesInc, menuItemIndex++);
+ clonk->AddMenuItem("$Relaunches$ -", "SelectSetting(SETTING_RelaunchesDec)", SKUL);
+ CheckPreselect(preselect && selectedSetting == SETTING_RelaunchesDec, menuItemIndex++);
+ }
+ else
+ {
+ clonk->AddMenuItem("$Kills$ +", "SelectSetting(SETTING_DeathmatchScoreInc)", SWOR);
+ CheckPreselect(preselect && selectedSetting == SETTING_DeathmatchScoreInc, menuItemIndex++);
+ clonk->AddMenuItem("$Kills$ -", "SelectSetting(SETTING_DeathmatchScoreDec)", SWOR);
+ CheckPreselect(preselect && selectedSetting == SETTING_DeathmatchScoreDec, menuItemIndex++);
+ }
+
+ clonk->AddMenuItem("$Done$", "SetupDone()", GOLD);
+ CheckPreselect(!preselect, menuItemIndex++);
+ clonk->AddMenuItem("$Back$", "ShowModeMenu()", ROCK);
+}
+
+private func SelectSetting(int selectedSetting)
+{
+ if (selectedSetting == SETTING_Deathmatch)
+ {
+ deathmatchEnabled = !deathmatchEnabled;
+ }
+ else if (selectedSetting == SETTING_Extinguisher)
+ {
+ extinguisherEnabled = !extinguisherEnabled;
+ }
+ else if (selectedSetting == SETTING_FriendlyPushing)
+ {
+ friendlyPushingEnabled = !friendlyPushingEnabled;
+ }
+ else if (selectedSetting == SETTING_RotateInJump)
+ {
+ rotateInJumpEnabled = !rotateInJumpEnabled;
+ }
+ else if (selectedSetting == SETTING_Ambience)
+ {
+ ambienceEnabled = !ambienceEnabled;
+ }
+ else if (selectedSetting == SETTING_RelaunchesInc)
+ {
+ ++numRelaunches;
+ }
+ else if (selectedSetting == SETTING_RelaunchesDec)
+ {
+ numRelaunches = Max(numRelaunches - 1, 0);
+ }
+ 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("StartGame", 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() { Message("@%s", 0, GetMessage()); }
+
+private func GetMessage()
+{
+ var msgSection = Format("$Landscape$: %s", 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("{{SKUL}} $Relaunches$: %d", numRelaunches);
+ }
+ else
+ {
+ msgWinScore = Format("{{SWOR}} %s: %d $Kills$", GetName(0, DTHM), deathmatchWinScore);
+ }
+
+ var msgExtinguisher = Format("{{_ETG}} %s: %s", GetName(0, _ETG), IIf(extinguisherEnabled, "$Enabled$", "$Disabled$"));
+ var msgFriendlyPushing = Format("{{FYPG}} %s: %s", GetName(0, FYPG), IIf(friendlyPushingEnabled, "$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|%s", msgSection, msgMode, msgWinScore, msgExtinguisher, msgFriendlyPushing, msgRotateInJump, msgAmbience);
+} \ No newline at end of file