// Initializes GUI. int init_module_gui() { shortcuts = new std::vector<Shortcut*>; int w, h; bool maximized; load_gui_config(w, h, maximized); try { if (w > 0 && h > 0) main_display = she::instance()->createDisplay(w, h, screen_scaling); } catch (const she::DisplayCreationException&) { // Do nothing, the display wasn't created. } if (!main_display) { for (int c=0; try_resolutions[c].width; ++c) { try { main_display = she::instance()->createDisplay(try_resolutions[c].width, try_resolutions[c].height, try_resolutions[c].scale); screen_scaling = try_resolutions[c].scale; break; } catch (const she::DisplayCreationException&) { // Ignore } } } if (!main_display) { she::error_message("Unable to create a user-interface display.\n"); return -1; } main_clipboard = she::instance()->createClipboard(); // Create the default-manager manager = new CustomizedGuiManager(); manager->setDisplay(main_display); manager->setClipboard(main_clipboard); // Setup the GUI theme for all widgets CurrentTheme::set(ase_theme = new SkinTheme()); if (maximized) main_display->maximize(); gui_setup_screen(true); // Set graphics options for next time save_gui_config(); return 0; }
void exit_module_gui() { save_gui_config(); delete manager; // Now we can destroy theme CurrentTheme::set(NULL); delete ase_theme; main_clipboard->dispose(); main_display->dispose(); }
void exit_module_gui() { save_gui_config(); // destroy shortcuts ASSERT(shortcuts != NULL); for (Shortcut* shortcut : *shortcuts) delete shortcut; delete shortcuts; shortcuts = NULL; delete manager; // Now we can destroy theme CurrentTheme::set(NULL); delete ase_theme; remove_keyboard(); remove_mouse(); main_clipboard->dispose(); main_display->dispose(); }
// Refresh the UI display, font, etc. void gui_setup_screen(bool reload_font) { bool regen = false; bool reinit = false; main_display->setScale(screen_scaling); ui::set_display(main_display); // Update guiscale factor int old_guiscale = jguiscale(); CurrentTheme::get()->guiscale = (screen_scaling == 1 && ui::display_w() > 512 && ui::display_h() > 256) ? 2: 1; // If the guiscale have changed if (old_guiscale != jguiscale()) { reload_font = true; regen = true; } if (reload_font) { reload_default_font(); reinit = true; } // Regenerate the theme if (regen) { CurrentTheme::get()->regenerate(); reinit = true; } if (reinit) reinitThemeForAllWidgets(); // Set the configuration save_gui_config(); }