2023-12-08 20:56:14 +00:00
|
|
|
/**
|
|
|
|
* editor_property_bb_param.h
|
|
|
|
* =============================================================================
|
2024-03-12 17:06:10 +00:00
|
|
|
* Copyright 2021-2024 Serhii Snitsaruk
|
2023-12-08 20:56:14 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* =============================================================================
|
|
|
|
*/
|
|
|
|
|
2024-01-11 10:22:02 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
|
2023-12-08 20:56:14 +00:00
|
|
|
#ifndef EDITOR_PROPERTY_BB_PARAM_H
|
|
|
|
#define EDITOR_PROPERTY_BB_PARAM_H
|
|
|
|
|
2024-01-07 12:36:59 +00:00
|
|
|
#ifdef LIMBOAI_MODULE
|
|
|
|
|
2023-12-08 20:56:14 +00:00
|
|
|
#include "editor/editor_inspector.h"
|
|
|
|
|
2024-02-29 15:00:09 +00:00
|
|
|
#include "../blackboard/bb_param/bb_param.h"
|
|
|
|
#include "../blackboard/blackboard_plan.h"
|
|
|
|
#include "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"
|
2024-01-15 20:57:31 +00:00
|
|
|
#include "scene/gui/margin_container.h"
|
2023-12-10 13:35:28 +00:00
|
|
|
#include "scene/gui/menu_button.h"
|
|
|
|
|
2024-01-28 18:24:59 +00:00
|
|
|
class EditorPropertyVariableName;
|
|
|
|
|
2023-12-08 20:56:14 +00:00
|
|
|
class EditorPropertyBBParam : public EditorProperty {
|
|
|
|
GDCLASS(EditorPropertyBBParam, EditorProperty);
|
|
|
|
|
|
|
|
private:
|
2024-03-12 17:06:10 +00:00
|
|
|
const int ID_BIND_VAR = 1000;
|
|
|
|
|
|
|
|
bool initialized = false;
|
2023-12-09 18:31:51 +00:00
|
|
|
|
2024-05-18 11:37:24 +00:00
|
|
|
Ref<BlackboardPlan> plan;
|
2023-12-08 20:56:14 +00:00
|
|
|
StringName param_type;
|
|
|
|
PropertyHint property_hint = PROPERTY_HINT_NONE;
|
|
|
|
|
|
|
|
HBoxContainer *hbox = nullptr;
|
2024-01-15 20:57:31 +00:00
|
|
|
MarginContainer *bottom_container = nullptr;
|
2023-12-10 13:35:28 +00:00
|
|
|
HBoxContainer *editor_hbox = nullptr;
|
2023-12-08 20:56:14 +00:00
|
|
|
EditorProperty *value_editor = nullptr;
|
2024-01-28 18:24:59 +00:00
|
|
|
EditorPropertyVariableName *variable_editor = 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);
|
2024-01-28 18:24:59 +00:00
|
|
|
void _variable_edited(const String &p_property, Variant p_value, const String &p_name = "", bool p_changing = false);
|
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;
|
2024-01-28 18:24:59 +00:00
|
|
|
void setup(PropertyHint p_hint, const String &p_hint_text, const Ref<BlackboardPlan> &p_plan);
|
2023-12-08 20:56:14 +00:00
|
|
|
|
|
|
|
EditorPropertyBBParam();
|
|
|
|
};
|
|
|
|
|
|
|
|
class EditorInspectorPluginBBParam : public EditorInspectorPlugin {
|
|
|
|
GDCLASS(EditorInspectorPluginBBParam, EditorInspectorPlugin);
|
|
|
|
|
2024-01-28 18:24:59 +00:00
|
|
|
private:
|
|
|
|
Callable plan_getter;
|
|
|
|
|
2023-12-08 20:56:14 +00:00
|
|
|
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;
|
2024-01-28 18:24:59 +00:00
|
|
|
|
|
|
|
void set_plan_getter(const Callable &p_getter) { plan_getter = p_getter; }
|
2023-12-08 20:56:14 +00:00
|
|
|
};
|
|
|
|
|
2024-01-11 10:22:02 +00:00
|
|
|
#endif // ! LIMBOAI_MODULE
|
|
|
|
|
|
|
|
#endif // ! EDITOR_PROPERTY_BB_PARAM_H
|
2024-01-07 12:36:59 +00:00
|
|
|
|
2024-01-11 10:22:02 +00:00
|
|
|
#endif // ! TOOLS_ENABLED
|