Initializes GUI.
| 157 | |
| 158 | // Initializes GUI. |
| 159 | int init_module_gui() |
| 160 | { |
| 161 | bool maximized = false; |
| 162 | std::string lastError = "Unknown error"; |
| 163 | bool gpuAccel = Preferences::instance().general.gpuAcceleration(); |
| 164 | |
| 165 | if (!create_main_display(gpuAccel, maximized, lastError)) { |
| 166 | // If we've created the display with hardware acceleration, |
| 167 | // now we try to do it without hardware acceleration. |
| 168 | if (gpuAccel && |
| 169 | (int(she::instance()->capabilities()) & |
| 170 | int(she::Capabilities::GpuAccelerationSwitch)) == int(she::Capabilities::GpuAccelerationSwitch)) { |
| 171 | if (create_main_display(false, maximized, lastError)) { |
| 172 | // Disable hardware acceleration |
| 173 | Preferences::instance().general.gpuAcceleration(false); |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | if (!main_display) { |
| 179 | she::error_message( |
| 180 | ("Unable to create a user-interface display.\nDetails: "+lastError+"\n").c_str()); |
| 181 | return -1; |
| 182 | } |
| 183 | |
| 184 | // Create the default-manager |
| 185 | manager = new CustomizedGuiManager(); |
| 186 | manager->setDisplay(main_display); |
| 187 | |
| 188 | setLanguage(Preferences::instance().general.language()); |
| 189 | |
| 190 | // Setup the GUI theme for all widgets |
| 191 | gui_theme = new SkinTheme(); |
| 192 | { |
| 193 | auto uiScale = Preferences::instance().experimental.uiScale(); |
| 194 | if (uiScale < 1) { |
| 195 | #ifdef EMSCRIPTEN |
| 196 | uiScale = 2; |
| 197 | #else |
| 198 | uiScale = 2 + (ui::display_h() > 400) + (ui::display_h() > 800); |
| 199 | #endif |
| 200 | Preferences::instance().experimental.uiScale(uiScale); |
| 201 | } |
| 202 | gui_theme->setScale(uiScale); |
| 203 | } |
| 204 | CurrentTheme::set(gui_theme); |
| 205 | |
| 206 | if (maximized) |
| 207 | main_display->maximize(); |
| 208 | |
| 209 | // Set graphics options for next time |
| 210 | save_gui_config(); |
| 211 | |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | void exit_module_gui() |
| 216 | { |
nothing calls this directly
no test coverage detected