void *thread_winref(void *data) { Tox *m = (Tox *) data; uint8_t draw_count = 0; init_signal_catchers(); while (true) { draw_active_window(m); draw_count++; if (Winthread.flag_resize) { on_window_resize(); Winthread.flag_resize = 0; } else if (draw_count >= INACTIVE_WIN_REFRESH_RATE) { refresh_inactive_windows(); draw_count = 0; } if (Winthread.sig_exit_toxic) { pthread_mutex_lock(&Winthread.lock); exit_toxic_success(m); } } }
void game::swap_mode() { assert(!_next_mode); if (_curr_mode == &_mode_sett) { //May be we need change size/mode _mode_puzzle.on_settings_changed(_mode_sett.level_size(), _mode_sett.wrap_mode()); settings::sound_mode(_mode_sett.sound_mode()); settings::rndlvl_mode(_mode_sett.random_mode()); settings::portrait_mode(_mode_sett.portrait_mode()); if (_mode_sett.portrait_mode()) on_window_resize(PW_SCREEN_WIDTH_PORTRAIT , PW_SCREEN_HEIGHT_PORTRAIT); else on_window_resize(PW_SCREEN_WIDTH, PW_SCREEN_HEIGHT); _next_mode = &_mode_puzzle; } else { _mode_sett.reset(); _next_mode = &_mode_sett; } _need_redisplay = true; _trans_stime = SDL_GetTicks(); }
void AddonMenu::menu_action(MenuItem* item) { if (item->id == MNID_CHECK_ONLINE) // check if "Check Online" was chosen { check_online(); } else if(item->id == MNID_LANGPACK_MODE) { m_language_pack_mode = !m_language_pack_mode; rebuild_menu(); on_window_resize(); return; } else if (MNID_ADDON_LIST_START <= item->id) { if (IS_INSTALLED_MENU_ID(item->id)) { int idx = UNPACK_INSTALLED_MENU_ID(item->id); if (0 <= idx && idx < static_cast<int>(m_installed_addons.size())) { const Addon& addon = m_addon_manager.get_installed_addon(m_installed_addons[idx]); toggle_addon(addon); } } else if (IS_REPOSITORY_MENU_ID(item->id)) { int idx = UNPACK_REPOSITORY_MENU_ID(item->id); if (0 <= idx && idx < static_cast<int>(m_repository_addons.size())) { const Addon& addon = m_addon_manager.get_repository_addon(m_repository_addons[idx]); install_addon(addon); } } } else { log_warning << "Unknown menu item clicked: " << item->id << std::endl; } }
void FileSystemMenu::refresh_items() { items.clear(); directories.clear(); files.clear(); directory = FileSystem::normalize(directory); add_label(directory); add_hl(); int item_id = 0; // Do not allow leaving the data directory if (directory != "/") { directories.push_back(".."); } char** dir_files = PHYSFS_enumerateFiles(directory.c_str()); if (dir_files) { for(const char* const* file = dir_files; *file != nullptr; ++file) { std::string filepath = FileSystem::join(directory, *file); if(PhysFSFileSystem::is_directory(filepath)) { directories.push_back(*file); } else { if (AddonManager::current()->is_from_old_addon(filepath)) { continue; } if(has_right_suffix(*file)) { files.push_back(*file); } } } PHYSFS_freeList(dir_files); } for(const auto& item : directories) { add_entry(item_id, "[" + std::string(item) + "]"); item_id++; } for(const auto& item : files) { add_entry(item_id, item); item_id++; } add_hl(); add_back(_("Cancel")); active_item = 2; // Re-center menu on_window_resize(); }