| 96 | static void save_gui_config(); |
| 97 | |
| 98 | static bool create_main_display(bool gpuAccel, |
| 99 | bool& maximized, |
| 100 | std::string& lastError) |
| 101 | { |
| 102 | int w, h; |
| 103 | std::string windowLayout; |
| 104 | load_gui_config(w, h, maximized, windowLayout); |
| 105 | |
| 106 | // Scale is equal to 0 when it's the first time the program is |
| 107 | // executed. |
| 108 | int scale = Preferences::instance().general.screenScale(); |
| 109 | she::instance()->setGpuAcceleration(gpuAccel); |
| 110 | |
| 111 | try { |
| 112 | if (w > 0 && h > 0) { |
| 113 | main_display = she::instance()->createDisplay( |
| 114 | w, h, (scale == 0 ? 1 : MID(1, scale, 4))); |
| 115 | } |
| 116 | } |
| 117 | catch (const she::DisplayCreationException& e) { |
| 118 | lastError = e.what(); |
| 119 | } |
| 120 | |
| 121 | if (!main_display) { |
| 122 | for (int c=0; try_resolutions[c].width; ++c) { |
| 123 | try { |
| 124 | main_display = |
| 125 | she::instance()->createDisplay( |
| 126 | try_resolutions[c].width, |
| 127 | try_resolutions[c].height, |
| 128 | (scale == 0 ? try_resolutions[c].scale : scale)); |
| 129 | break; |
| 130 | } |
| 131 | catch (const she::DisplayCreationException& e) { |
| 132 | lastError = e.what(); |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | if (main_display) { |
| 138 | // Change the scale value only in the first run (this will be |
| 139 | // saved when the program is closed). |
| 140 | if (scale == 0) |
| 141 | Preferences::instance().general.screenScale(main_display->scale()); |
| 142 | |
| 143 | ResourceFinder rf; |
| 144 | rf.includeDataDir("icons/ase64.png"); |
| 145 | if (rf.findFirst()) |
| 146 | main_display->setIcon(she::instance()->loadRgbaSurface(rf.filename().c_str())); |
| 147 | |
| 148 | if (!windowLayout.empty()) { |
| 149 | main_display->setLayout(windowLayout); |
| 150 | if (main_display->isMinimized()) |
| 151 | main_display->maximize(); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | return (main_display != nullptr); |
no test coverage detected