本文整理汇总了C++中Quest::is_resource_element方法的典型用法代码示例。如果您正苦于以下问题:C++ Quest::is_resource_element方法的具体用法?C++ Quest::is_resource_element怎么用?C++ Quest::is_resource_element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quest
的用法示例。
在下文中一共展示了Quest::is_resource_element方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open_file_requested
/**
* @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);
}
}
示例2: EditorException
/**
* @brief Creates a map editor.
* @param quest The quest containing the file.
* @param path Path of the map data file to open.
* @param parent The parent object or nullptr.
* @throws EditorException If the file could not be opened.
*/
MapEditor::MapEditor(Quest& quest, const QString& path, QWidget* parent) :
Editor(quest, path, parent),
map_id(),
map(nullptr),
entity_creation_toolbar(nullptr),
status_bar(nullptr),
ignore_tileset_selection_changes(false) {
ui.setupUi(this);
build_entity_creation_toolbar();
build_status_bar();
// Get the map.
ResourceType resource_type;
QString map_id;
quest.check_exists(path);
if (!quest.is_resource_element(path, resource_type, map_id) ||
resource_type != ResourceType::MAP) {
throw EditorException(tr("File '%1' is not a map").arg(path));
}
this->map_id = map_id;
// Editor properties.
set_title(tr("Map %1").arg(get_file_name_without_extension()));
set_icon(QIcon(":/images/icon_resource_map.png"));
set_close_confirm_message(
tr("Map '%1' has been modified. Save changes?").arg(map_id));
set_select_all_supported(true);
set_zoom_supported(true);
get_view_settings().set_zoom(2.0);
set_grid_supported(true);
set_entity_type_visibility_supported(true);
// Shortcuts.
QAction* open_script_action = new QAction(this);
open_script_action->setShortcut(tr("F4"));
open_script_action->setShortcutContext(Qt::WindowShortcut);
connect(open_script_action, SIGNAL(triggered(bool)),
this, SLOT(open_script_requested()));
addAction(open_script_action);
// Open the file.
map = new MapModel(quest, map_id, this);
get_undo_stack().setClean();
// Prepare the gui.
const int side_width = 350;
ui.splitter->setSizes({ side_width, width() - side_width });
ui.map_side_splitter->setStretchFactor(0, 0); // Don't expand the map properties view
ui.map_side_splitter->setStretchFactor(1, 1); // but only the tileset view.
ui.tileset_field->set_resource_type(ResourceType::TILESET);
ui.tileset_field->set_quest(quest);
ui.music_field->set_resource_type(ResourceType::MUSIC);
ui.music_field->set_quest(quest);
ui.music_field->add_special_value("none", tr("<No music>"), 0);
ui.music_field->add_special_value("same", tr("<Same as before>"), 1);
ui.tileset_view->set_read_only(true);
ui.map_view->set_map(map);
ui.map_view->set_view_settings(get_view_settings());
ui.map_view->set_common_actions(&get_common_actions());
ui.size_field->config("x", 0, 99999, 8);
ui.size_field->set_tooltips(
tr("Width of the map in pixels"),
tr("Height of the map in pixels"));
ui.location_field->config(",", 0, 99999, 8);
ui.location_field->set_tooltips(
tr("Coordinates of the map in its world (useful to make adjacent scrolling maps)"),
tr("Coordinates of the map in its world (useful to make adjacent scrolling maps)"));
set_num_layers_visibility_supported(map->get_num_layers());
load_settings();
update();
// Make connections.
connect(&get_resources(), SIGNAL(element_description_changed(ResourceType, QString, QString)),
this, SLOT(update_description_to_gui()));
connect(ui.description_field, SIGNAL(editingFinished()),
this, SLOT(set_description_from_gui()));
connect(ui.size_field, SIGNAL(editing_finished()),
this, SLOT(change_size_requested()));
connect(map, SIGNAL(size_changed(QSize)),
this, SLOT(update_size_field()));
connect(ui.world_check_box, SIGNAL(stateChanged(int)),
this, SLOT(world_check_box_changed()));
connect(ui.world_field, SIGNAL(editingFinished()),
this, SLOT(change_world_requested()));
connect(map, SIGNAL(world_changed(QString)),
this, SLOT(update_world_field()));
//.........这里部分代码省略.........