Skip to content

Commit 2dfb7cc

Browse files
committed
Add a default option to the new scenario settings.
1 parent 462f2a4 commit 2dfb7cc

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

scripts/scenario_00_basic.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
-- Setting[Enemies]: Configures the amount of enemies spawned in the scenario.
99
-- Enemies[Empty]: No enemies. Recommended for GM-controlled scenarios and rookie crew orientation. The scenario continues until the GM declares victory or all Human Navy ships are destroyed.
1010
-- Enemies[Easy]: Fewer enemies. Recommended for inexperienced crews.
11+
-- Enemies[Normal|Default]: Normal amount of enemies. Recommended for a normal crew.
1112
-- Enemies[Hard]: More enemies. Recommended if you have multiple player-controlled ships.
1213
-- Enemies[Extreme]: Many enemies. Inexperienced player crews will pretty surely be overwhelmed.
1314

@@ -274,8 +275,7 @@ function init()
274275
local counts = {
275276
["Extreme"] = 20,
276277
["Hard"] = 8,
277-
-- default:
278-
["None"] = 5,
278+
["Normal"] = 5,
279279
["Easy"] = 3,
280280
["Empty"] = 0
281281
}

src/menus/serverCreationScreen.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,14 @@ ServerScenarioOptionsScreen::ServerScenarioOptionsScreen(string filename)
256256
});
257257
selector->setSize(GuiElement::GuiSizeMax, 50);
258258
for(auto& option : setting.options)
259+
{
259260
selector->addEntry(option.first.capitalize(), option.first);
261+
if (option.first == setting.default_option)
262+
{
263+
selector->setSelectionIndex(selector->entryCount() - 1);
264+
gameGlobalInfo->scenario_settings[setting.key] = option.first;
265+
}
266+
}
260267
auto description = new GuiScrollText(container, "", setting.description);
261268
description->setSize(GuiElement::GuiSizeMax, 300);
262269
count++;
@@ -281,5 +288,6 @@ ServerScenarioOptionsScreen::ServerScenarioOptionsScreen(string filename)
281288
returnToShipSelection();
282289
new ScriptErrorRenderer();
283290
});
284-
start_button->setPosition(250, -50, sp::Alignment::BottomCenter)->setSize(300, 50)->disable();
291+
start_button->setPosition(250, -50, sp::Alignment::BottomCenter)->setSize(300, 50);
292+
start_button->setEnable(gameGlobalInfo->scenario_settings.size() >= info.settings.size());
285293
}

src/scenarioInfo.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,19 @@ std::vector<string> ScenarioInfo::getCategories()
126126

127127
bool ScenarioInfo::addSettingOption(string key, string option, string description)
128128
{
129+
string tag = "";
130+
if (option.find('|') > 0)
131+
{
132+
tag = option.substr(option.find('|') + 1).lower();
133+
option = option.substr(0, option.find('|'));
134+
}
129135
for(auto& setting : settings)
130136
{
131137
if (setting.key == key)
132138
{
133139
setting.options.emplace_back(option, description);
140+
if (tag == "default")
141+
setting.default_option = option;
134142
return true;
135143
}
136144
}

src/scenarioInfo.h

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class ScenarioInfo
1111
public:
1212
string key;
1313
string description;
14+
string default_option;
1415
std::vector<std::pair<string, string>> options;
1516
};
1617

0 commit comments

Comments
 (0)