/** * @brief Opens a file with a language strings list editor in a new tab. * @param quest A Solarus quest. * @param language_id Language id of the strings file to open. */ void EditorTabs::open_strings_editor( Quest& quest, const QString& language_id) { // Get the strings file path. QString path = quest.get_strings_path(language_id); if (!quest.is_in_root_path(path)) { // Not a file of this quest. return; } // Find the existing tab if any. int index = find_editor(path); if (index != -1) { // Already open. setCurrentIndex(index); return; } try { add_editor(new StringsEditor(quest, language_id)); } catch (const EditorException& ex) { ex.show_dialog(); } }
/** * @brief Slot called when the user attempts to open a file. * @param quest The quest that holds this file. * @param path Path of the file to open. */ void EditorTabs::open_file_requested(Quest& quest, const QString& path) { if (path.isEmpty()) { return; } QFileInfo file_info(path); QString canonical_path = file_info.canonicalFilePath(); if (!quest.is_in_root_path(canonical_path)) { // Not a file of this quest. return; } ResourceType resource_type; QString element_id; if (quest.is_resource_element(canonical_path, resource_type, element_id)) { // A resource element declared in the quest. // Possibly a map data file, an enemy Lua script, // a language directory, etc. open_resource(quest, resource_type, element_id); } else if (quest.is_dialogs_file(canonical_path, element_id)) { open_dialogs_editor(quest, element_id); } else if (quest.is_strings_file(canonical_path, element_id)) { open_strings_editor(quest, element_id); } else if (quest.is_script(canonical_path)) { // A Lua script that is not a resource element. open_text_editor(quest, canonical_path); } else if (quest.is_data_path(canonical_path)) { open_quest_properties_editor(quest); } }
/** * @brief Opens a file with a sprite editor in a new tab. * @param quest A Solarus quest. * @param path Path of the sprite data file to open. */ void EditorTabs::open_sprite_editor( Quest& quest, const QString& path) { if (!quest.is_in_root_path(path)) { // Not a file of this quest. return; } // Find the existing tab if any. int index = find_editor(path); if (index != -1) { // Already open. setCurrentIndex(index); return; } try { add_editor(new SpriteEditor(quest, path)); } catch (const EditorException& ex) { ex.show_dialog(); } }