39 const int flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
40 ImGui::SetNextWindowSize(ImVec2(670.f, 400.f), ImGuiCond_FirstUseEver);
46 ImGui::SetNextWindowPosCenter(ImGuiCond_Appearing);
47 bool keep_open =
true;
48 ImGui::Begin(
_LC(
"GameSettings",
"Game settings"), &keep_open, flags);
50 ImGui::BeginTabBar(
"GameSettingsTabs");
52 const float child_height = ImGui::GetWindowHeight()
53 - ((2.f * ImGui::GetStyle().WindowPadding.y) + (3.f * ImGui::GetItemsLineHeightWithSpacing())
54 + ImGui::GetStyle().ItemSpacing.y);
56 if (ImGui::BeginTabItem(
_LC(
"GameSettings",
"Render System")))
58 ImGui::BeginChild(
"Settings-Render-scroll", ImVec2(0.f, child_height),
false);
63 if (ImGui::BeginTabItem(
_LC(
"GameSettings",
"General")))
65 ImGui::BeginChild(
"Settings-General-scroll", ImVec2(0.f, child_height),
false);
70 if (ImGui::BeginTabItem(
_LC(
"GameSettings",
"Gameplay")))
72 ImGui::BeginChild(
"Settings-Gameplay-scroll", ImVec2(0.f, child_height),
false);
77 if (ImGui::BeginTabItem(
_LC(
"GameSettings",
"Graphics")))
79 ImGui::BeginChild(
"Settings-Graphics-scroll", ImVec2(0.f, child_height),
false);
84 if (ImGui::BeginTabItem(
_LC(
"GameSettings",
"Audio")))
86 ImGui::BeginChild(
"Settings-Audio-scroll", ImVec2(0.f, child_height),
false);
91 if (ImGui::BeginTabItem(
_LC(
"GameSettings",
"Controls")))
93 ImGui::BeginChild(
"Settings-Controls-scroll", ImVec2(0.f, child_height),
false);
98 if (ImGui::BeginTabItem(
_LC(
"GameSettings",
"Diagnostic")))
100 ImGui::BeginChild(
"Settings-Diag-scroll", ImVec2(0.f, child_height),
false);
108 ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 4.f);
120 ImGui::TextDisabled(
"%s",
_LC(
"GameSettings",
"Render system (changes require a restart)"));
124 std::string text =
_LC(
"GameSettings",
"You must restart the game to make changes effective.");
125 ImVec2 box_size = ImGui::CalcTextSize(text.c_str()) + ImGui::GetStyle().FramePadding * 2;
126 ImVec2 box_pos = ImGui::GetCursorPos() + ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f - box_size.x * 0.5f, 0.f);
127 ImGui::SetCursorPos(box_pos);
128 ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.8f, 0.7f, 0.1f, 1.f));
129 ImGui::BeginChildFrame(ImGuiID(123), box_size);
130 ImGui::TextColored(ImVec4(0.1f, 0.1f, 0.1f, 1.f), text.c_str());
131 ImGui::EndChildFrame();
132 ImGui::PopStyleColor();
136 const auto render_systems = ogre_root->getAvailableRenderers();
137 std::string render_system_names;
138 for (
auto rs : render_systems)
140 render_system_names += rs->getName() +
'\0';
143 const auto rs = ro ? ro : ogre_root->getRenderSystem();
144 const auto it = std::find(render_systems.begin(), render_systems.end(), rs);
145 int render_id = it != render_systems.end() ? std::distance(render_systems.begin(), it) : 0;
147 if (ImGui::Combo(
_LC (
"GameSettings",
"Render System"), &render_id, render_system_names.c_str()))
152 const auto config_options = ogre_root->getRenderSystem()->getConfigOptions();
153 std::set<std::string> filter = {
"Allow NVPerfHUD",
"Colour Depth",
"Fixed Pipeline Enabled",
154 "Floating-point mode",
"Resource Creation Policy",
"VSync Interval",
"sRGB Gamma Conversion"};
155 for (
auto opt : config_options)
157 auto co = opt.second;
160 if (co.possibleValues.empty())
162 if (filter.find(co.name) != filter.end())
164 std::sort(co.possibleValues.rbegin(), co.possibleValues.rend());
165 std::string option_values;
166 for (
auto value : co.possibleValues)
168 option_values += value +
'\0';
170 const auto it = std::find(co.possibleValues.begin(), co.possibleValues.end(), opt.second.currentValue);
171 int option_id = it != co.possibleValues.end() ? std::distance(co.possibleValues.begin(), it) : 0;
172 if (ImGui::Combo(co.name.c_str(), &option_id, option_values.c_str()))
175 if (co.currentValue != co.possibleValues[option_id])
178 rs->setConfigOption(co.name, co.possibleValues[option_id]);
179 if (rs->validateConfigOptions().empty())
181 ogre_root->saveConfig();
187 m_bump_height = ImGui::GetTextLineHeightWithSpacing() + ImGui::GetStyle().FramePadding.y * 2;
197 ImGui::TextDisabled(
"%s",
_LC(
"GameSettings",
"Application settings"));
201 std::string lang_values;
202 for (
auto value : languages)
204 lang_values += value.first +
'\0';
206 const auto it = std::find_if(languages.begin(), languages.end(),
207 [](
const std::pair<std::string, std::string>& l) { return l.second == App::app_language->getStr(); });
208 int lang_selection = it != languages.end() ? std::distance(languages.begin(), it) : 0;
209 if (ImGui::Combo(
_LC(
"GameSettings",
"Language"), &lang_selection, lang_values.c_str()))
217 static Ogre::FileInfoListPtr fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"FlagsRG",
"*");
220 static std::vector<std::string> countries;
221 if (countries.empty())
223 for (
auto&
file : *fl)
225 std::string country = Ogre::StringUtil::replaceAll(
file.filename,
".png",
"");
226 if (country.size() == 2)
228 countries.push_back(country);
231 std::sort(countries.begin(), countries.end());
233 std::string country_values;
234 for (
auto value : countries)
236 country_values += value +
'\0';
239 int country_selection = it != countries.end() ? std::distance(countries.begin(), it) : 0;
240 if (ImGui::Combo(
_LC(
"GameSettings",
"Country"), &country_selection, country_values.c_str()))
249 if (ImGui::Combo(
_LC(
"GameSettings",
"Screenshot format"), &sshot_select,
"png\0jpg\0\0"))
251 std::string str = (sshot_select == 1) ?
"jpg" :
"png";
261 if (ImGui::Button(
_LC(
"GameSettings",
"Update cache")))
271 ImGui::TextDisabled(
"%s",
_LC(
"GameSettings",
"Simulation settings"));
311 ImGui::TextDisabled(
"%s",
_LC(
"GameSettings",
"Audio settings"));
313 static const ALCchar *devices = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
314 const ALCchar *device = devices, *next = devices + 1;
315 std::vector<std::string> audio_devices;
317 while (device && *device !=
'\0' && next && *next !=
'\0')
319 audio_devices.push_back(device);
320 size_t len = strlen(device);
326 int device_id = it != audio_devices.end() ? std::distance(audio_devices.begin(), it) : 0;
327 if (ImGui::Combo(
_LC(
"GameSettings",
"Audio device"), &device_id, devices))
340 ImGui::TextDisabled(
"%s",
_LC(
"GameSettings",
"Video settings"));
371 int selection = std::log2(anisotropy);
372 if (ImGui::Combo(
_LC(
"GameSettings",
"Anisotropy"), &selection,
"1\0""2\0""4\0""8\0""16\0\0"))
392 ImGui::PushItemWidth(125.f);
394 ImGui::PopItemWidth();
416 ImGui::TextDisabled(
"%s",
_LC(
"GameSettings",
"Diagnostic options"));
417 ImGui::TextColored(ImVec4(0.89f,0.15f,0.21f,1.0f),
"%s",
_LC(
"GameSettings",
"These settings are for advanced users only, you should only change these if you know what you're doing"));
440 if (ImGui::Button(
_LC(
"GameSettings",
"Rebuild cache")))
450 ImGui::TextDisabled(
"%s",
_LC(
"GameSettings",
"Controller options"));
460 _LC(
"GameSettings",
"Restarting input subsystem, please wait..."),
false);
473 ImGui::PushItemWidth(125.f);
478 ImGui::PopItemWidth();
485 ImGui::PushItemWidth(125.f);
489 ImGui::PopItemWidth();