2023-12-08 20:56:14 +00:00
|
|
|
/**
|
|
|
|
* editor_property_bb_param.h
|
|
|
|
* =============================================================================
|
|
|
|
* Copyright 2021-2023 Serhii Snitsaruk
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
|
|
|
* =============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EDITOR_PROPERTY_BB_PARAM_H
|
|
|
|
#define EDITOR_PROPERTY_BB_PARAM_H
|
|
|
|
|
|
|
|
#include "editor/editor_inspector.h"
|
|
|
|
|
|
|
|
#include "modules/limboai/blackboard/bb_param/bb_param.h"
|
2023-12-09 18:31:51 +00:00
|
|
|
#include "modules/limboai/editor/mode_switch_button.h"
|
2023-12-08 20:56:14 +00:00
|
|
|
|
2023-12-10 13:35:28 +00:00
|
|
|
#include "scene/gui/box_container.h"
|
|
|
|
#include "scene/gui/menu_button.h"
|
|
|
|
|
2023-12-08 20:56:14 +00:00
|
|
|
class EditorPropertyBBParam : public EditorProperty {
|
|
|
|
GDCLASS(EditorPropertyBBParam, EditorProperty);
|
|
|
|
|
|
|
|
private:
|
2023-12-09 18:31:51 +00:00
|
|
|
enum Mode {
|
|
|
|
SPECIFY_VALUE,
|
|
|
|
BIND_VAR,
|
|
|
|
};
|
|
|
|
|
2023-12-08 20:56:14 +00:00
|
|
|
StringName param_type;
|
|
|
|
PropertyHint property_hint = PROPERTY_HINT_NONE;
|
2023-12-09 18:31:51 +00:00
|
|
|
Mode mode = Mode::SPECIFY_VALUE;
|
2023-12-08 20:56:14 +00:00
|
|
|
|
|
|
|
HBoxContainer *hbox = nullptr;
|
2023-12-10 13:35:28 +00:00
|
|
|
HBoxContainer *editor_hbox = nullptr;
|
2023-12-09 18:31:51 +00:00
|
|
|
ModeSwitchButton *mode_button = nullptr;
|
2023-12-08 20:56:14 +00:00
|
|
|
EditorProperty *value_editor = nullptr;
|
|
|
|
LineEdit *variable_edit = nullptr;
|
2023-12-10 13:35:28 +00:00
|
|
|
MenuButton *type_choice = nullptr;
|
2023-12-08 20:56:14 +00:00
|
|
|
|
|
|
|
Ref<BBParam> _get_edited_param();
|
|
|
|
|
|
|
|
void _create_value_editor(Variant::Type p_type);
|
|
|
|
void _remove_value_editor();
|
|
|
|
|
|
|
|
void _value_edited(const String &p_property, Variant p_value, const String &p_name = "", bool p_changing = false);
|
|
|
|
void _variable_edited(const String &p_text);
|
|
|
|
void _mode_changed();
|
2023-12-10 13:35:28 +00:00
|
|
|
void _type_selected(int p_index);
|
2023-12-08 20:56:14 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void update_property() override;
|
|
|
|
void setup(PropertyHint p_hint, const String &p_hint_text);
|
|
|
|
|
|
|
|
EditorPropertyBBParam();
|
|
|
|
};
|
|
|
|
|
|
|
|
class EditorInspectorPluginBBParam : public EditorInspectorPlugin {
|
|
|
|
GDCLASS(EditorInspectorPluginBBParam, EditorInspectorPlugin);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual bool can_handle(Object *p_object) override;
|
|
|
|
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // EDITOR_PROPERTY_BB_PARAM_H
|