void ClientVersion::loadVersionExtensions(pugi::xml_node versionNode) { pugi::xml_attribute attribute; if (!(attribute = versionNode.attribute("name"))) { // Error has already been displayed earlier, no need to show another error about the same thing return; } ClientVersion* version = get(attribute.as_string()); if (!version) { // Same rationale as above return; } for (pugi::xml_node childNode = versionNode.first_child(); childNode; childNode = childNode.next_sibling()) { if (as_lower_str(childNode.name()) != "extensions") { continue; } const std::string& from = childNode.attribute("from").as_string(); const std::string& to = childNode.attribute("to").as_string(); ClientVersion* fromVersion = get(from); ClientVersion* toVersion = get(to); if ((from.empty() && to.empty()) || (!fromVersion && !toVersion)) { wxLogError(wxT("Unknown client extension data.")); continue; } if (!fromVersion) { fromVersion = client_versions.begin()->second; } if (!toVersion) { toVersion = client_versions.rbegin()->second; } for (const auto& versionEntry : client_versions) { ClientVersion* version = versionEntry.second; if (version->getID() >= fromVersion->getID() && version->getID() <= toVersion->getID()) { version->extension_versions.push_back(version); } } std::sort(version->extension_versions.begin(), version->extension_versions.end(), VersionComparisonPredicate); } }
void ClientVersion::loadVersion(pugi::xml_node versionNode) { pugi::xml_attribute attribute; if (!(attribute = versionNode.attribute("name"))) { wxLogError(wxT("Node 'client' must contain 'name', 'data_directory' and 'otb' tags.")); return; } const std::string& versionName = attribute.as_string(); if (!(attribute = versionNode.attribute("data_directory"))) { wxLogError(wxT("Node 'client' must contain 'name', 'data_directory' and 'otb' tags.")); return; } const std::string& dataPath = attribute.as_string(); if (!(attribute = versionNode.attribute("otb"))) { wxLogError(wxT("Node 'client' must contain 'name', 'data_directory' and 'otb' tags.")); return; } const std::string& otbVersionName = attribute.as_string(); if (otb_versions.find(otbVersionName) == otb_versions.end()) { wxLogError(wxT("Node 'client' 'otb' tag is invalid (couldn't find this otb version).")); return; } ClientVersion* version = newd ClientVersion(otb_versions[otbVersionName], versionName, wxstr(dataPath)); bool should_be_default = versionNode.attribute("default").as_bool(); version->visible = versionNode.attribute("visible").as_bool(); for (pugi::xml_node childNode = versionNode.first_child(); childNode; childNode = childNode.next_sibling()) { const std::string& childName = as_lower_str(childNode.name()); if (childName == "otbm") { if (!(attribute = childNode.attribute("version"))) { wxLogError(wxT("Node 'otbm' missing version.")); continue; } int32_t otbmVersion = pugi::cast<int32_t>(attribute.value()) - 1; if (otbmVersion < MAP_OTBM_1 || otbmVersion > MAP_OTBM_4) { wxLogError(wxT("Node 'otbm' unsupported version.")); continue; } if (childNode.attribute("preffered").as_bool() || version->preferred_map_version == MAP_OTBM_UNKNOWN) { version->preferred_map_version = static_cast<MapVersionID>(otbmVersion); } version->map_versions_supported.push_back(version->preferred_map_version); } else if (childName == "fucked_up_charges") { version->usesFuckedUpCharges = true; } else if (childName == "data") { if (!(attribute = childNode.attribute("sprversion"))) { wxLogError(wxT("Node 'data' does not have 'datversion' / 'sprversion' tags.")); continue; } const std::string& sprVersion = attribute.as_string(); if (!(attribute = childNode.attribute("datversion"))) { wxLogError(wxT("Node 'data' does not have 'datversion' / 'sprversion' tags.")); continue; } const std::string& datVersion = attribute.as_string(); ClientData client_data = {DAT_VERSION_74, SPR_VERSION_70, 0, 0}; if (datVersion == "7.4") { client_data.datVersion = DAT_VERSION_74; } else if (datVersion == "7.6") { client_data.datVersion = DAT_VERSION_76; } else if (datVersion == "7.8") { client_data.datVersion = DAT_VERSION_78; } else if (datVersion == "8.6") { client_data.datVersion = DAT_VERSION_86; } else if (datVersion == "9.6") { client_data.datVersion = DAT_VERSION_96; } else { wxLogError(wxT("Node 'data' 'datversion' is invalid (7.4, 7.6, 7.8, 8.6 and 9.6 are supported)")); continue; } if (sprVersion == "7.0") { client_data.sprVersion = SPR_VERSION_70; } else if (sprVersion == "9.6") { client_data.sprVersion = SPR_VERSION_96; } else { wxLogError(wxT("Node 'data' 'sprversion' is invalid (7.0 and 9.6 are supported)")); continue; } if (!(attribute = childNode.attribute("dat")) || !wxString(attribute.as_string(), wxConvUTF8).ToULong((unsigned long*)&client_data.datSignature, 16)) { wxLogError(wxT("Node 'data' 'dat' tag is not hex-formatted.")); continue; } if (!(attribute = childNode.attribute("spr")) || !wxString(attribute.as_string(), wxConvUTF8).ToULong((unsigned long*)&client_data.sprSignature, 16)) { wxLogError(wxT("Node 'data' 'spr' tag is not hex-formatted.")); continue; } version->data_versions.push_back(client_data); } } if (client_versions[version->getID()] != nullptr) { wxString error; error << wxT("Duplicate version id ") << version->getID() << wxT(", discarding version '") << version->name << wxT("'."); wxLogError(error); delete version; return; } client_versions[version->getID()] = version; if (should_be_default) latest_version = version; }
void PreferencesWindow::Apply() { bool must_restart = false; // General g_settings.setInteger(Config::ALWAYS_MAKE_BACKUP, always_make_backup_chkbox->GetValue()); g_settings.setInteger(Config::CREATE_MAP_ON_STARTUP, create_on_startup_chkbox->GetValue()); g_settings.setInteger(Config::USE_UPDATER, update_check_on_startup_chkbox->GetValue()); g_settings.setInteger(Config::ONLY_ONE_INSTANCE, only_one_instance_chkbox->GetValue()); g_settings.setInteger(Config::UNDO_SIZE, undo_size_spin->GetValue()); g_settings.setInteger(Config::UNDO_MEM_SIZE, undo_mem_size_spin->GetValue()); g_settings.setInteger(Config::WORKER_THREADS, worker_threads_spin->GetValue()); g_settings.setInteger(Config::REPLACE_SIZE, replace_size_spin->GetValue()); g_settings.setInteger(Config::COPY_POSITION_FORMAT, position_format->GetSelection()); // Editor g_settings.setInteger(Config::GROUP_ACTIONS, group_actions_chkbox->GetValue()); g_settings.setInteger(Config::WARN_FOR_DUPLICATE_ID, duplicate_id_warn_chkbox->GetValue()); g_settings.setInteger(Config::HOUSE_BRUSH_REMOVE_ITEMS, house_remove_chkbox->GetValue()); g_settings.setInteger(Config::AUTO_ASSIGN_DOORID, auto_assign_doors_chkbox->GetValue()); g_settings.setInteger(Config::ERASER_LEAVE_UNIQUE, eraser_leave_unique_chkbox->GetValue()); g_settings.setInteger(Config::DOODAD_BRUSH_ERASE_LIKE, doodad_erase_same_chkbox->GetValue()); g_settings.setInteger(Config::AUTO_CREATE_SPAWN, auto_create_spawn_chkbox->GetValue()); g_settings.setInteger(Config::RAW_LIKE_SIMONE, allow_multiple_orderitems_chkbox->GetValue()); g_settings.setInteger(Config::MERGE_MOVE, merge_move_chkbox->GetValue()); g_settings.setInteger(Config::MERGE_PASTE, merge_paste_chkbox->GetValue()); // Graphics g_settings.setInteger(Config::USE_GUI_SELECTION_SHADOW, icon_selection_shadow_chkbox->GetValue()); if(g_settings.getBoolean(Config::USE_MEMCACHED_SPRITES) != use_memcached_chkbox->GetValue()) { must_restart = true; } g_settings.setInteger(Config::USE_MEMCACHED_SPRITES_TO_SAVE, use_memcached_chkbox->GetValue()); if(icon_background_choice->GetSelection() == 0) { if(g_settings.getInteger(Config::ICON_BACKGROUND) != 0) { g_gui.gfx.cleanSoftwareSprites(); } g_settings.setInteger(Config::ICON_BACKGROUND, 0); } else if(icon_background_choice->GetSelection() == 1) { if(g_settings.getInteger(Config::ICON_BACKGROUND) != 88) { g_gui.gfx.cleanSoftwareSprites(); } g_settings.setInteger(Config::ICON_BACKGROUND, 88); } else if(icon_background_choice->GetSelection() == 2) { if(g_settings.getInteger(Config::ICON_BACKGROUND) != 255) { g_gui.gfx.cleanSoftwareSprites(); } g_settings.setInteger(Config::ICON_BACKGROUND, 255); } // Screenshots g_settings.setString(Config::SCREENSHOT_DIRECTORY, nstr(screenshot_directory_picker->GetPath())); std::string new_format = nstr(screenshot_format_choice->GetStringSelection()); if(new_format == "PNG") { g_settings.setString(Config::SCREENSHOT_FORMAT, "png"); } else if(new_format == "TGA") { g_settings.setString(Config::SCREENSHOT_FORMAT, "tga"); } else if(new_format == "JPG") { g_settings.setString(Config::SCREENSHOT_FORMAT, "jpg"); } else if(new_format == "BMP") { g_settings.setString(Config::SCREENSHOT_FORMAT, "bmp"); } wxColor clr = cursor_color_pick->GetColour(); g_settings.setInteger(Config::CURSOR_RED, clr.Red()); g_settings.setInteger(Config::CURSOR_GREEN, clr.Green()); g_settings.setInteger(Config::CURSOR_BLUE, clr.Blue()); //g_settings.setInteger(Config::CURSOR_ALPHA, clr.Alpha()); clr = cursor_alt_color_pick->GetColour(); g_settings.setInteger(Config::CURSOR_ALT_RED, clr.Red()); g_settings.setInteger(Config::CURSOR_ALT_GREEN, clr.Green()); g_settings.setInteger(Config::CURSOR_ALT_BLUE, clr.Blue()); //g_settings.setInteger(Config::CURSOR_ALT_ALPHA, clr.Alpha()); g_settings.setInteger(Config::HIDE_ITEMS_WHEN_ZOOMED, hide_items_when_zoomed_chkbox->GetValue()); /* g_settings.setInteger(Config::TEXTURE_MANAGEMENT, texture_managment_chkbox->GetValue()); g_settings.setInteger(Config::TEXTURE_CLEAN_PULSE, clean_interval_spin->GetValue()); g_settings.setInteger(Config::TEXTURE_LONGEVITY, texture_longevity_spin->GetValue()); g_settings.setInteger(Config::TEXTURE_CLEAN_THRESHOLD, texture_threshold_spin->GetValue()); g_settings.setInteger(Config::SOFTWARE_CLEAN_THRESHOLD, software_threshold_spin->GetValue()); g_settings.setInteger(Config::SOFTWARE_CLEAN_SIZE, software_clean_amount_spin->GetValue()); */ // Interface SetPaletteStyleChoice(terrain_palette_style_choice, Config::PALETTE_TERRAIN_STYLE); SetPaletteStyleChoice(doodad_palette_style_choice, Config::PALETTE_DOODAD_STYLE); SetPaletteStyleChoice(item_palette_style_choice, Config::PALETTE_ITEM_STYLE); SetPaletteStyleChoice(raw_palette_style_choice, Config::PALETTE_RAW_STYLE); g_settings.setInteger(Config::USE_LARGE_TERRAIN_TOOLBAR, large_terrain_tools_chkbox->GetValue()); g_settings.setInteger(Config::USE_LARGE_DOODAD_SIZEBAR, large_doodad_sizebar_chkbox->GetValue()); g_settings.setInteger(Config::USE_LARGE_ITEM_SIZEBAR, large_item_sizebar_chkbox->GetValue()); g_settings.setInteger(Config::USE_LARGE_HOUSE_SIZEBAR, large_house_sizebar_chkbox->GetValue()); g_settings.setInteger(Config::USE_LARGE_RAW_SIZEBAR, large_raw_sizebar_chkbox->GetValue()); g_settings.setInteger(Config::USE_LARGE_CONTAINER_ICONS, large_container_icons_chkbox->GetValue()); g_settings.setInteger(Config::USE_LARGE_CHOOSE_ITEM_ICONS, large_pick_item_icons_chkbox->GetValue()); g_settings.setInteger(Config::SWITCH_MOUSEBUTTONS, switch_mousebtn_chkbox->GetValue()); g_settings.setInteger(Config::DOUBLECLICK_PROPERTIES, doubleclick_properties_chkbox->GetValue()); float scroll_mul = 1.0; if(inversed_scroll_chkbox->GetValue()) { scroll_mul = -1.0; } g_settings.setFloat(Config::SCROLL_SPEED, scroll_mul * scroll_speed_slider->GetValue()/10.f); g_settings.setFloat(Config::ZOOM_SPEED, zoom_speed_slider->GetValue()/10.f); // Client ClientVersionList versions = ClientVersion::getAllVisible(); int version_counter = 0; for(ClientVersionList::iterator version_iter = versions.begin(); version_iter != versions.end(); ++version_iter) { ClientVersion* version = *version_iter; wxString dir = version_dir_pickers[version_counter]->GetPath(); if(dir.Length() > 0 && dir.Last() != '/' && dir.Last() != '\\') dir.Append("/"); version->setClientPath(FileName(dir)); if(version->getName() == default_version_choice->GetStringSelection()) g_settings.setInteger(Config::DEFAULT_CLIENT_VERSION, version->getID()); version_counter++; } g_settings.setInteger(Config::CHECK_SIGNATURES, check_sigs_chkbox->GetValue()); // Make sure to reload client paths ClientVersion::saveVersions(); ClientVersion::loadVersions(); g_settings.save(); if(must_restart) { g_gui.PopupDialog(this, "Notice", "You must restart the editor for the changes to take effect.", wxOK); } g_gui.RebuildPalettes(); }