Path: blob/master/editor/settings/action_map_editor.h
9896 views
/**************************************************************************/1/* action_map_editor.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/gui/control.h"3334class AcceptDialog;35class Button;36class CheckButton;37class EditorEventSearchBar;38class EventListenerLineEdit;39class HBoxContainer;40class InputEventConfigurationDialog;41class LineEdit;42class Tree;4344class ActionMapEditor : public Control {45GDCLASS(ActionMapEditor, Control);4647public:48struct ActionInfo {49String name;50Dictionary action;51bool has_initial = false;52Dictionary action_initial;5354Ref<Texture2D> icon;55bool editable = true;56};5758private:59enum ItemButton {60BUTTON_ADD_EVENT,61BUTTON_EDIT_EVENT,62BUTTON_REMOVE_ACTION,63BUTTON_REMOVE_EVENT,64BUTTON_REVERT_ACTION,65};6667Vector<ActionInfo> actions_cache;68Tree *action_tree = nullptr;6970// Storing which action/event is currently being edited in the InputEventConfigurationDialog.7172Dictionary current_action;73String current_action_name;74int current_action_event_index = -1;7576// Popups7778InputEventConfigurationDialog *event_config_dialog = nullptr;79AcceptDialog *message = nullptr;8081// Filtering and Adding actions8283bool show_builtin_actions = false;84CheckButton *show_builtin_actions_checkbutton = nullptr;85EditorEventSearchBar *action_list_search_bar = nullptr;8687HBoxContainer *add_hbox = nullptr;88LineEdit *add_edit = nullptr;89Button *add_button = nullptr;9091void _event_config_confirmed();9293void _add_action_pressed();94void _add_edit_text_changed(const String &p_name);95String _check_new_action_name(const String &p_name);96bool _has_action(const String &p_name) const;97void _add_action(const String &p_name);98void _action_edited();99100void _tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);101void _tree_item_activated();102void _on_search_bar_value_changed();103bool _should_display_action(const String &p_name, const Array &p_events) const;104105Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);106bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;107void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);108109void _set_show_builtin_actions(bool p_show);110111protected:112void _notification(int p_what);113static void _bind_methods();114115public:116LineEdit *get_search_box() const;117LineEdit *get_path_box() const;118InputEventConfigurationDialog *get_configuration_dialog();119120// Dictionary represents an Action with "events" (Array) and "deadzone" (float) items. Pass with no param to update list from cached action map.121void update_action_list(const Vector<ActionInfo> &p_action_infos = Vector<ActionInfo>());122void show_message(const String &p_message);123124ActionMapEditor();125};126127128