2023-07-21 09:50:06 +00:00
|
|
|
/**
|
|
|
|
* limbo_utility.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.
|
|
|
|
* =============================================================================
|
|
|
|
*/
|
2022-08-28 10:54:34 +00:00
|
|
|
|
|
|
|
#ifndef LIMBO_UTILITY_H
|
|
|
|
#define LIMBO_UTILITY_H
|
|
|
|
|
2024-01-09 12:34:24 +00:00
|
|
|
#include "limbo_compat.h"
|
|
|
|
|
2024-01-06 20:04:34 +00:00
|
|
|
#ifdef LIMBOAI_MODULE
|
2022-12-15 07:26:52 +00:00
|
|
|
#include "core/object/object.h"
|
2023-08-15 15:49:13 +00:00
|
|
|
|
2024-01-09 12:34:24 +00:00
|
|
|
#include "core/input/shortcut.h"
|
2023-08-15 15:49:13 +00:00
|
|
|
#include "core/object/class_db.h"
|
2023-11-15 13:45:10 +00:00
|
|
|
#include "core/variant/binder_common.h"
|
2023-08-10 11:04:53 +00:00
|
|
|
#include "core/variant/variant.h"
|
2023-04-13 07:29:45 +00:00
|
|
|
#include "scene/resources/texture.h"
|
2024-01-06 20:04:34 +00:00
|
|
|
#endif // LIMBOAI_MODULE
|
|
|
|
|
|
|
|
#ifdef LIMBOAI_GDEXTENSION
|
|
|
|
#include <godot_cpp/classes/object.hpp>
|
2024-01-09 12:34:24 +00:00
|
|
|
#include <godot_cpp/classes/shortcut.hpp>
|
2024-01-06 20:04:34 +00:00
|
|
|
#include <godot_cpp/classes/texture2d.hpp>
|
|
|
|
#include <godot_cpp/core/binder_common.hpp>
|
|
|
|
#include <godot_cpp/core/class_db.hpp>
|
2024-01-09 12:34:24 +00:00
|
|
|
#include <godot_cpp/templates/hash_map.hpp>
|
2024-01-06 20:04:34 +00:00
|
|
|
using namespace godot;
|
|
|
|
#endif // LIMBOAI_GDEXTENSION
|
2022-08-28 10:54:34 +00:00
|
|
|
|
2023-08-26 13:41:11 +00:00
|
|
|
#define LOGICAL_XOR(a, b) (a) ? !(b) : (b)
|
|
|
|
|
2024-01-13 21:40:27 +00:00
|
|
|
#define LIMBO_DOC_VERSION "latest"
|
|
|
|
|
2022-08-28 10:54:34 +00:00
|
|
|
class LimboUtility : public Object {
|
|
|
|
GDCLASS(LimboUtility, Object);
|
|
|
|
|
2024-01-09 12:34:24 +00:00
|
|
|
private:
|
2024-01-14 15:35:19 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
2024-01-09 12:34:24 +00:00
|
|
|
HashMap<String, Ref<Shortcut>> shortcuts;
|
2024-01-14 15:35:19 +00:00
|
|
|
#endif // TOOLS_ENABLED
|
2024-01-09 12:34:24 +00:00
|
|
|
|
2023-08-10 11:04:53 +00:00
|
|
|
public:
|
|
|
|
enum CheckType : unsigned int {
|
|
|
|
CHECK_EQUAL,
|
|
|
|
CHECK_LESS_THAN,
|
|
|
|
CHECK_LESS_THAN_OR_EQUAL,
|
|
|
|
CHECK_GREATER_THAN,
|
|
|
|
CHECK_GREATER_THAN_OR_EQUAL,
|
|
|
|
CHECK_NOT_EQUAL
|
|
|
|
};
|
|
|
|
|
2023-11-15 13:45:10 +00:00
|
|
|
enum Operation {
|
2023-11-15 14:40:07 +00:00
|
|
|
OPERATION_NONE,
|
|
|
|
OPERATION_ADDITION,
|
|
|
|
OPERATION_SUBTRACTION,
|
|
|
|
OPERATION_MULTIPLICATION,
|
|
|
|
OPERATION_DIVISION,
|
|
|
|
OPERATION_MODULO,
|
|
|
|
OPERATION_POWER,
|
|
|
|
OPERATION_BIT_SHIFT_LEFT,
|
|
|
|
OPERATION_BIT_SHIFT_RIGHT,
|
|
|
|
OPERATION_BIT_AND,
|
|
|
|
OPERATION_BIT_OR,
|
|
|
|
OPERATION_BIT_XOR,
|
2023-11-15 13:45:10 +00:00
|
|
|
};
|
|
|
|
|
2022-08-28 10:54:34 +00:00
|
|
|
protected:
|
2022-09-21 21:56:04 +00:00
|
|
|
static LimboUtility *singleton;
|
2022-08-28 10:54:34 +00:00
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2022-09-21 21:56:04 +00:00
|
|
|
static LimboUtility *get_singleton();
|
|
|
|
|
2022-11-01 13:03:20 +00:00
|
|
|
String decorate_var(String p_variable) const;
|
|
|
|
String get_status_name(int p_status) const;
|
2023-04-13 07:29:45 +00:00
|
|
|
Ref<Texture2D> get_task_icon(String p_class_or_script_path) const;
|
2022-09-21 21:56:04 +00:00
|
|
|
|
2023-11-15 13:45:10 +00:00
|
|
|
String get_check_operator_string(CheckType p_check_type) const;
|
2023-08-10 11:04:53 +00:00
|
|
|
bool perform_check(CheckType p_check_type, const Variant &left_value, const Variant &right_value);
|
|
|
|
|
2023-11-15 13:45:10 +00:00
|
|
|
String get_operation_string(Operation p_operation) const;
|
|
|
|
Variant perform_operation(Operation p_operation, const Variant &left_value, const Variant &right_value);
|
|
|
|
|
2024-01-24 22:11:09 +00:00
|
|
|
String get_property_hint_text(PropertyHint p_hint) const;
|
|
|
|
|
2024-01-14 15:35:19 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
2024-01-09 12:34:24 +00:00
|
|
|
Ref<Shortcut> add_shortcut(const String &p_path, const String &p_name, Key p_keycode = LW_KEY(NONE));
|
|
|
|
bool is_shortcut(const String &p_path, const Ref<InputEvent> &p_event) const;
|
|
|
|
Ref<Shortcut> get_shortcut(const String &p_path) const;
|
|
|
|
|
2024-01-13 21:40:27 +00:00
|
|
|
void open_doc_introduction();
|
|
|
|
void open_doc_online();
|
2024-01-17 13:49:43 +00:00
|
|
|
void open_doc_gdextension_limitations();
|
2024-01-17 14:51:24 +00:00
|
|
|
void open_doc_custom_tasks();
|
2024-01-13 21:40:27 +00:00
|
|
|
void open_doc_class(const String &p_class_name);
|
2024-01-14 15:35:19 +00:00
|
|
|
#endif // TOOLS_ENABLED
|
2024-01-13 21:40:27 +00:00
|
|
|
|
2022-09-21 21:56:04 +00:00
|
|
|
LimboUtility();
|
|
|
|
~LimboUtility();
|
2022-08-28 10:54:34 +00:00
|
|
|
};
|
|
|
|
|
2023-08-10 11:04:53 +00:00
|
|
|
VARIANT_ENUM_CAST(LimboUtility::CheckType);
|
2023-11-15 13:45:10 +00:00
|
|
|
VARIANT_ENUM_CAST(LimboUtility::Operation);
|
2023-08-10 11:04:53 +00:00
|
|
|
|
2024-01-09 12:34:24 +00:00
|
|
|
#define LW_SHORTCUT(m_path, m_name, m_keycode) (LimboUtility::get_singleton()->add_shortcut(m_path, m_name, m_keycode))
|
|
|
|
#define LW_IS_SHORTCUT(m_path, m_event) (LimboUtility::get_singleton()->is_shortcut(m_path, m_event))
|
|
|
|
#define LW_GET_SHORTCUT(m_path) (LimboUtility::get_singleton()->get_shortcut(m_path))
|
|
|
|
|
2024-01-13 16:10:42 +00:00
|
|
|
#endif // LIMBO_UTILITY_H
|