mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-20 17:14:44 +01:00
ProfileManager is now a part of ESS.
This commit is contained in:
parent
84728ccf5c
commit
87848565b4
11
SCsub
11
SCsub
@ -113,3 +113,14 @@ module_env.add_source_files(env.modules_sources,"ai/ai_spell_action.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"ai/ai_action_container.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"ai/ai_spell_action_container.cpp")
|
||||
|
||||
|
||||
env.add_source_files(env.modules_sources,"profile_manager/input/input_profile_modifier.cpp")
|
||||
env.add_source_files(env.modules_sources,"profile_manager/input/input_profile_modifier_entry.cpp")
|
||||
env.add_source_files(env.modules_sources,"profile_manager/input/input_profile.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"profile_manager/actionbar/action_bar_button_entry.cpp")
|
||||
env.add_source_files(env.modules_sources,"profile_manager/actionbar/action_bar_entry.cpp")
|
||||
env.add_source_files(env.modules_sources,"profile_manager/actionbar/action_bar_profile.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"profile_manager/class_profile.cpp")
|
||||
env.add_source_files(env.modules_sources,"profile_manager/profile_manager.cpp")
|
||||
|
115
profile_manager/actionbar/action_bar_button_entry.cpp
Normal file
115
profile_manager/actionbar/action_bar_button_entry.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
#include "action_bar_button_entry.h"
|
||||
|
||||
const String ActionBarButtonEntry::BINDING_STRING_ACTIONBAR_BUTTON_ENTRY_TYPE = "None, Spell, Item";
|
||||
|
||||
int ActionBarButtonEntry::get_action_bar_id() {
|
||||
return _action_bar_id;
|
||||
}
|
||||
|
||||
void ActionBarButtonEntry::set_action_bar_id(int value) {
|
||||
_action_bar_id = value;
|
||||
|
||||
changed();
|
||||
}
|
||||
|
||||
int ActionBarButtonEntry::get_slot_id() {
|
||||
return _slot_id;
|
||||
}
|
||||
|
||||
void ActionBarButtonEntry::set_slot_id(int value) {
|
||||
_slot_id = value;
|
||||
|
||||
changed();
|
||||
}
|
||||
|
||||
ActionBarButtonEntry::ActionBarButtonEntryType ActionBarButtonEntry::get_type() {
|
||||
return _type;
|
||||
}
|
||||
|
||||
void ActionBarButtonEntry::set_type(ActionBarButtonEntry::ActionBarButtonEntryType value) {
|
||||
_type = value;
|
||||
|
||||
changed();
|
||||
}
|
||||
|
||||
int ActionBarButtonEntry::get_item_id() {
|
||||
return _item_id;
|
||||
}
|
||||
|
||||
void ActionBarButtonEntry::set_item_id(int value) {
|
||||
_item_id = value;
|
||||
|
||||
changed();
|
||||
}
|
||||
|
||||
void ActionBarButtonEntry::changed() {
|
||||
emit_signal("changed");
|
||||
}
|
||||
|
||||
Dictionary ActionBarButtonEntry::to_dict() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["action_bar_id"] = _action_bar_id;
|
||||
dict["slot_id"] = _slot_id;
|
||||
dict["type"] = _type;
|
||||
dict["item_id"] = _item_id;
|
||||
|
||||
return dict;
|
||||
}
|
||||
void ActionBarButtonEntry::from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
_action_bar_id = dict.get("action_bar_id", 0);
|
||||
_slot_id = dict.get("slot_id", 0);
|
||||
_type = VariantCaster<ActionBarButtonEntryType>().cast(dict.get("type", ACTION_BAR_BUTTON_ENTRY_TYPE_NONE));
|
||||
_item_id = dict.get("item_id", 0);
|
||||
}
|
||||
|
||||
ActionBarButtonEntry::ActionBarButtonEntry() {
|
||||
_action_bar_id = 0;
|
||||
_slot_id = 0;
|
||||
_type = ACTION_BAR_BUTTON_ENTRY_TYPE_NONE;
|
||||
_item_id = 0;
|
||||
}
|
||||
|
||||
ActionBarButtonEntry::ActionBarButtonEntry(int actionBarId, int slotId) {
|
||||
_action_bar_id = actionBarId;
|
||||
_slot_id = slotId;
|
||||
|
||||
_type = ACTION_BAR_BUTTON_ENTRY_TYPE_NONE;
|
||||
_item_id = 0;
|
||||
}
|
||||
|
||||
ActionBarButtonEntry::ActionBarButtonEntry(int actionBarId, int slotId, ActionBarButtonEntryType type, int itemId) {
|
||||
_action_bar_id = actionBarId;
|
||||
_slot_id = slotId;
|
||||
_type = type;
|
||||
_item_id = itemId;
|
||||
}
|
||||
|
||||
void ActionBarButtonEntry::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("changed"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_action_bar_id"), &ActionBarButtonEntry::get_action_bar_id);
|
||||
ClassDB::bind_method(D_METHOD("set_action_bar_id", "value"), &ActionBarButtonEntry::set_action_bar_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "action_bar_id"), "set_action_bar_id", "get_action_bar_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_slot_id"), &ActionBarButtonEntry::get_slot_id);
|
||||
ClassDB::bind_method(D_METHOD("set_slot_id", "value"), &ActionBarButtonEntry::set_slot_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "slot_id"), "set_slot_id", "get_slot_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_type"), &ActionBarButtonEntry::get_type);
|
||||
ClassDB::bind_method(D_METHOD("set_type", "value"), &ActionBarButtonEntry::set_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, ActionBarButtonEntry::BINDING_STRING_ACTIONBAR_BUTTON_ENTRY_TYPE), "set_type", "get_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_item_id"), &ActionBarButtonEntry::get_item_id);
|
||||
ClassDB::bind_method(D_METHOD("set_item_id", "value"), &ActionBarButtonEntry::set_item_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "item_id"), "set_item_id", "get_item_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("from_dict", "dict"), &ActionBarButtonEntry::from_dict);
|
||||
ClassDB::bind_method(D_METHOD("to_dict"), &ActionBarButtonEntry::to_dict);
|
||||
|
||||
BIND_ENUM_CONSTANT(ACTION_BAR_BUTTON_ENTRY_TYPE_NONE);
|
||||
BIND_ENUM_CONSTANT(ACTION_BAR_BUTTON_ENTRY_TYPE_SPELL);
|
||||
BIND_ENUM_CONSTANT(ACTION_BAR_BUTTON_ENTRY_TYPE_ITEM);
|
||||
}
|
52
profile_manager/actionbar/action_bar_button_entry.h
Normal file
52
profile_manager/actionbar/action_bar_button_entry.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef ACTION_BAR_BUTTON_ENTRY_H
|
||||
#define ACTION_BAR_BUTTON_ENTRY_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/dictionary.h"
|
||||
|
||||
class ActionBarButtonEntry : public Reference {
|
||||
GDCLASS(ActionBarButtonEntry, Reference);
|
||||
|
||||
public:
|
||||
static const String BINDING_STRING_ACTIONBAR_BUTTON_ENTRY_TYPE;
|
||||
|
||||
enum ActionBarButtonEntryType {
|
||||
ACTION_BAR_BUTTON_ENTRY_TYPE_NONE,
|
||||
ACTION_BAR_BUTTON_ENTRY_TYPE_SPELL,
|
||||
ACTION_BAR_BUTTON_ENTRY_TYPE_ITEM
|
||||
};
|
||||
|
||||
int get_action_bar_id();
|
||||
void set_action_bar_id(int value);
|
||||
|
||||
int get_slot_id();
|
||||
void set_slot_id(int value);
|
||||
|
||||
ActionBarButtonEntryType get_type();
|
||||
void set_type(ActionBarButtonEntryType value);
|
||||
|
||||
int get_item_id();
|
||||
void set_item_id(int value);
|
||||
|
||||
void changed();
|
||||
|
||||
Dictionary to_dict() const;
|
||||
void from_dict(const Dictionary &dict);
|
||||
|
||||
ActionBarButtonEntry();
|
||||
ActionBarButtonEntry(int actionBarId, int slotId);
|
||||
ActionBarButtonEntry(int actionBarId, int slotId, ActionBarButtonEntryType type, int itemId);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _action_bar_id;
|
||||
int _slot_id;
|
||||
ActionBarButtonEntryType _type;
|
||||
int _item_id;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(ActionBarButtonEntry::ActionBarButtonEntryType);
|
||||
|
||||
#endif
|
128
profile_manager/actionbar/action_bar_entry.cpp
Normal file
128
profile_manager/actionbar/action_bar_entry.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
#include "action_bar_entry.h"
|
||||
|
||||
float ActionBarEntry::get_size() {
|
||||
return _size;
|
||||
}
|
||||
|
||||
void ActionBarEntry::set_size(float value) {
|
||||
_size = value;
|
||||
|
||||
emit_signal("changed");
|
||||
}
|
||||
|
||||
int ActionBarEntry::get_action_bar_id() {
|
||||
return _action_bar_id;
|
||||
}
|
||||
|
||||
void ActionBarEntry::set_action_bar_id(int value) {
|
||||
_action_bar_id = value;
|
||||
|
||||
emit_signal("changed");
|
||||
}
|
||||
|
||||
int ActionBarEntry::get_slot_num() {
|
||||
return _slot_num;
|
||||
}
|
||||
|
||||
void ActionBarEntry::set_slot_num(int value) {
|
||||
_slot_num = value;
|
||||
|
||||
emit_signal("changed");
|
||||
}
|
||||
|
||||
int ActionBarEntry::get_action_bar_entry_count() {
|
||||
return _button_entries.size();
|
||||
}
|
||||
|
||||
Ref<ActionBarButtonEntry> ActionBarEntry::get_button_for_slotid(int slotId) {
|
||||
for (int i = 0; i < _button_entries.size(); ++i) {
|
||||
if (_button_entries.get(i)->get_slot_id() == slotId) {
|
||||
return _button_entries.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<ActionBarButtonEntry> abe = Ref<ActionBarButtonEntry>(memnew(ActionBarButtonEntry(_action_bar_id, slotId, ActionBarButtonEntry::ACTION_BAR_BUTTON_ENTRY_TYPE_NONE, 0)));
|
||||
_button_entries.push_back(abe);
|
||||
return Ref<ActionBarButtonEntry>(abe);
|
||||
}
|
||||
|
||||
Ref<ActionBarButtonEntry> ActionBarEntry::get_button(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _button_entries.size(), Ref<ActionBarButtonEntry>(NULL));
|
||||
|
||||
return _button_entries.get(index);
|
||||
}
|
||||
|
||||
int _action_bar_id;
|
||||
int _slot_num;
|
||||
Vector<Ref<ActionBarButtonEntry> > _button_entries;
|
||||
|
||||
Dictionary ActionBarEntry::to_dict() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["action_bar_id"] = _action_bar_id;
|
||||
dict["slot_num"] = _slot_num;
|
||||
|
||||
Array arr;
|
||||
|
||||
for (int i = 0; i < _button_entries.size(); ++i) {
|
||||
Dictionary d = _button_entries[i]->to_dict();
|
||||
|
||||
arr.append(d);
|
||||
}
|
||||
|
||||
dict["button_entries"] = arr;
|
||||
|
||||
return dict;
|
||||
}
|
||||
void ActionBarEntry::from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
_button_entries.clear();
|
||||
|
||||
_action_bar_id = dict.get("action_bar_id", 0);
|
||||
_slot_num = dict.get("slot_num", 0);
|
||||
|
||||
Array arr = dict.get("button_entries", Array());
|
||||
|
||||
for (int i = 0; i < arr.size(); ++i) {
|
||||
Ref<ActionBarButtonEntry> e;
|
||||
e.instance();
|
||||
|
||||
e->from_dict(arr.get(i));
|
||||
|
||||
_button_entries.push_back(e);
|
||||
}
|
||||
}
|
||||
|
||||
ActionBarEntry::ActionBarEntry() {
|
||||
_size = 45;
|
||||
_slot_num = 12;
|
||||
}
|
||||
|
||||
ActionBarEntry::~ActionBarEntry() {
|
||||
_button_entries.clear();
|
||||
}
|
||||
|
||||
void ActionBarEntry::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("changed"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_size"), &ActionBarEntry::get_size);
|
||||
ClassDB::bind_method(D_METHOD("set_size", "value"), &ActionBarEntry::set_size);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "size"), "set_size", "get_size");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_action_bar_id"), &ActionBarEntry::get_action_bar_id);
|
||||
ClassDB::bind_method(D_METHOD("set_action_bar_id", "value"), &ActionBarEntry::set_action_bar_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "action_bar_id"), "set_action_bar_id", "get_action_bar_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_slot_num"), &ActionBarEntry::get_slot_num);
|
||||
ClassDB::bind_method(D_METHOD("set_slot_num", "value"), &ActionBarEntry::set_slot_num);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "slot_num"), "set_slot_num", "get_slot_num");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_action_bar_entry_count"), &ActionBarEntry::get_action_bar_entry_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_button_for_slotid", "slot_id"), &ActionBarEntry::get_button_for_slotid);
|
||||
ClassDB::bind_method(D_METHOD("get_button", "index"), &ActionBarEntry::get_button);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("from_dict", "dict"), &ActionBarEntry::from_dict);
|
||||
ClassDB::bind_method(D_METHOD("to_dict"), &ActionBarEntry::to_dict);
|
||||
}
|
46
profile_manager/actionbar/action_bar_entry.h
Normal file
46
profile_manager/actionbar/action_bar_entry.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef ACTION_BAR_ENTRY_H
|
||||
#define ACTION_BAR_ENTRY_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
#include "core/dictionary.h"
|
||||
#include "core/array.h"
|
||||
|
||||
#include "action_bar_button_entry.h"
|
||||
|
||||
class ActionBarEntry : public Reference {
|
||||
GDCLASS(ActionBarEntry, Reference);
|
||||
|
||||
public:
|
||||
float get_size();
|
||||
void set_size(float value);
|
||||
|
||||
int get_action_bar_id();
|
||||
void set_action_bar_id(int value);
|
||||
|
||||
int get_slot_num();
|
||||
void set_slot_num(int value);
|
||||
|
||||
int get_action_bar_entry_count();
|
||||
|
||||
Ref<ActionBarButtonEntry> get_button_for_slotid(int slotId);
|
||||
Ref<ActionBarButtonEntry> get_button(int index);
|
||||
|
||||
Dictionary to_dict() const;
|
||||
void from_dict(const Dictionary &dict);
|
||||
|
||||
ActionBarEntry();
|
||||
~ActionBarEntry();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _action_bar_id;
|
||||
int _slot_num;
|
||||
Vector<Ref<ActionBarButtonEntry> > _button_entries;
|
||||
|
||||
float _size;
|
||||
};
|
||||
|
||||
#endif
|
120
profile_manager/actionbar/action_bar_profile.cpp
Normal file
120
profile_manager/actionbar/action_bar_profile.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
#include "action_bar_profile.h"
|
||||
|
||||
String ActionBarProfile::get_action_bar_profile_name() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
void ActionBarProfile::set_action_bar_profile_name(String value) {
|
||||
_name = value;
|
||||
}
|
||||
|
||||
Vector<Ref<ActionBarEntry> > &ActionBarProfile::get_action_bars() {
|
||||
return _action_bars;
|
||||
}
|
||||
|
||||
void ActionBarProfile::load_defaults() {
|
||||
_action_bars.clear();
|
||||
|
||||
Ref<ActionBarEntry> actionBarEntry = Ref<ActionBarEntry>(memnew(ActionBarEntry()));
|
||||
actionBarEntry->set_action_bar_id(1);
|
||||
actionBarEntry->set_slot_num(12);
|
||||
_action_bars.push_back(Ref<ActionBarEntry>(actionBarEntry));
|
||||
|
||||
actionBarEntry = Ref<ActionBarEntry>(memnew(ActionBarEntry()));
|
||||
actionBarEntry->set_action_bar_id(2);
|
||||
actionBarEntry->set_slot_num(12);
|
||||
_action_bars.push_back(Ref<ActionBarEntry>(actionBarEntry));
|
||||
|
||||
actionBarEntry = Ref<ActionBarEntry>(memnew(ActionBarEntry()));
|
||||
actionBarEntry->set_action_bar_id(3);
|
||||
actionBarEntry->set_slot_num(12);
|
||||
_action_bars.push_back(Ref<ActionBarEntry>(actionBarEntry));
|
||||
|
||||
actionBarEntry = Ref<ActionBarEntry>(memnew(ActionBarEntry()));
|
||||
actionBarEntry->set_action_bar_id(4);
|
||||
actionBarEntry->set_slot_num(12);
|
||||
_action_bars.push_back(Ref<ActionBarEntry>(actionBarEntry));
|
||||
}
|
||||
|
||||
int ActionBarProfile::get_action_bar_count() {
|
||||
return _action_bars.size();
|
||||
}
|
||||
|
||||
void ActionBarProfile::add_action_bar(Ref<ActionBarEntry> actionbar) {
|
||||
_action_bars.push_back(Ref<ActionBarEntry>(actionbar));
|
||||
}
|
||||
|
||||
Ref<ActionBarEntry> ActionBarProfile::get_action_bar(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _action_bars.size(), Ref<ActionBarEntry>(NULL));
|
||||
|
||||
return _action_bars.get(index);
|
||||
}
|
||||
|
||||
void ActionBarProfile::remove_action_bar(int index) {
|
||||
_action_bars.remove(index);
|
||||
}
|
||||
|
||||
void ActionBarProfile::clear_action_bars() {
|
||||
_action_bars.clear();
|
||||
}
|
||||
|
||||
Dictionary ActionBarProfile::to_dict() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["name"] = _name;
|
||||
|
||||
Array arr;
|
||||
|
||||
for (int i = 0; i < _action_bars.size(); ++i) {
|
||||
Dictionary d = _action_bars[i]->to_dict();
|
||||
|
||||
arr.append(d);
|
||||
}
|
||||
|
||||
dict["action_bars"] = arr;
|
||||
|
||||
return dict;
|
||||
}
|
||||
void ActionBarProfile::from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
_action_bars.clear();
|
||||
|
||||
_name = dict.get("name", "");
|
||||
|
||||
Array arr = dict.get("action_bars", Array());
|
||||
|
||||
for (int i = 0; i < arr.size(); ++i) {
|
||||
Ref<ActionBarEntry> e;
|
||||
e.instance();
|
||||
|
||||
e->from_dict(arr.get(i));
|
||||
|
||||
_action_bars.push_back(e);
|
||||
}
|
||||
}
|
||||
|
||||
ActionBarProfile::ActionBarProfile() {
|
||||
}
|
||||
|
||||
ActionBarProfile::~ActionBarProfile() {
|
||||
_action_bars.clear();
|
||||
}
|
||||
|
||||
void ActionBarProfile::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_action_bar_profile_name"), &ActionBarProfile::get_action_bar_profile_name);
|
||||
ClassDB::bind_method(D_METHOD("set_action_bar_profile_name", "value"), &ActionBarProfile::set_action_bar_profile_name);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "action_bar_profile_name"), "set_action_bar_profile_name", "get_action_bar_profile_name");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("load_defaults"), &ActionBarProfile::load_defaults);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_action_bar_count"), &ActionBarProfile::get_action_bar_count);
|
||||
ClassDB::bind_method(D_METHOD("add_action_bar", "actionbar"), &ActionBarProfile::add_action_bar);
|
||||
ClassDB::bind_method(D_METHOD("get_action_bar", "index"), &ActionBarProfile::get_action_bar);
|
||||
ClassDB::bind_method(D_METHOD("remove_action_bar", "index"), &ActionBarProfile::remove_action_bar);
|
||||
ClassDB::bind_method(D_METHOD("clear_action_bars"), &ActionBarProfile::clear_action_bars);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("from_dict", "dict"), &ActionBarProfile::from_dict);
|
||||
ClassDB::bind_method(D_METHOD("to_dict"), &ActionBarProfile::to_dict);
|
||||
}
|
||||
|
40
profile_manager/actionbar/action_bar_profile.h
Normal file
40
profile_manager/actionbar/action_bar_profile.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef ACTION_BAR_PROFILE_H
|
||||
#define ACTION_BAR_PROFILE_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
#include "core/dictionary.h"
|
||||
#include "core/array.h"
|
||||
|
||||
#include "action_bar_entry.h"
|
||||
|
||||
class ActionBarProfile : public Reference {
|
||||
GDCLASS(ActionBarProfile, Reference);
|
||||
|
||||
public:
|
||||
String get_action_bar_profile_name();
|
||||
void set_action_bar_profile_name(String value);
|
||||
Vector<Ref<ActionBarEntry> > &get_action_bars();
|
||||
void load_defaults();
|
||||
|
||||
int get_action_bar_count();
|
||||
void add_action_bar(Ref<ActionBarEntry> actionbar);
|
||||
Ref<ActionBarEntry> get_action_bar(int index);
|
||||
void remove_action_bar(int index);
|
||||
void clear_action_bars();
|
||||
|
||||
Dictionary to_dict() const;
|
||||
void from_dict(const Dictionary &dict);
|
||||
|
||||
ActionBarProfile();
|
||||
~ActionBarProfile();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
String _name;
|
||||
Vector<Ref<ActionBarEntry> > _action_bars;
|
||||
};
|
||||
|
||||
#endif
|
170
profile_manager/class_profile.cpp
Normal file
170
profile_manager/class_profile.cpp
Normal file
@ -0,0 +1,170 @@
|
||||
#include "class_profile.h"
|
||||
|
||||
|
||||
int ClassProfile::get_class_id() {
|
||||
return _class_id;
|
||||
}
|
||||
|
||||
void ClassProfile::set_class_id(int value)
|
||||
{
|
||||
_class_id = value;
|
||||
}
|
||||
|
||||
String ClassProfile::get_character_class_name()
|
||||
{
|
||||
return _character_class_name;
|
||||
}
|
||||
|
||||
void ClassProfile::set_character_class_name(String value)
|
||||
{
|
||||
_character_class_name = value;
|
||||
}
|
||||
|
||||
int ClassProfile::get_level()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
void ClassProfile::set_level(int value)
|
||||
{
|
||||
_level = value;
|
||||
}
|
||||
|
||||
int ClassProfile::get_xp()
|
||||
{
|
||||
return _xp;
|
||||
}
|
||||
|
||||
void ClassProfile::set_xp(int value)
|
||||
{
|
||||
_xp = value;
|
||||
}
|
||||
|
||||
bool ClassProfile::get_actionbar_locked() {
|
||||
return _actionbar_locked;
|
||||
}
|
||||
|
||||
void ClassProfile::set_actionbar_locked(bool value) {
|
||||
_actionbar_locked = value;
|
||||
}
|
||||
|
||||
Ref<InputProfile> ClassProfile::get_input_profile()
|
||||
{
|
||||
return _input_profile;
|
||||
}
|
||||
|
||||
Ref<ActionBarProfile> ClassProfile::get_action_bar_profile()
|
||||
{
|
||||
return _action_bar_profile;
|
||||
}
|
||||
|
||||
Dictionary ClassProfile::get_custom_data() {
|
||||
return _custom_data;
|
||||
}
|
||||
void ClassProfile::set_custom_data(const Dictionary &dict) {
|
||||
_custom_data = dict;
|
||||
}
|
||||
|
||||
Dictionary ClassProfile::to_dict() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["character_class_name"] = _character_class_name;
|
||||
dict["class_id"] = _class_id;
|
||||
dict["level"] = _level;
|
||||
dict["xp"] = _xp;
|
||||
dict["actionbar_locked"] = _actionbar_locked;
|
||||
|
||||
dict["actionbar_profile"] = _action_bar_profile->to_dict();
|
||||
|
||||
dict["custom_data"] = _custom_data;
|
||||
|
||||
return dict;
|
||||
}
|
||||
void ClassProfile::from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
_character_class_name = dict.get("character_class_name", "");
|
||||
_class_id = dict.get("class_id", 0);
|
||||
_level = dict.get("level", 1);
|
||||
_xp = dict.get("xp", 0);
|
||||
_actionbar_locked = dict.get("actionbar_locked", false);
|
||||
|
||||
_action_bar_profile->from_dict(dict.get("actionbar_profile", Dictionary()));
|
||||
|
||||
_custom_data = dict.get("custom_data", Dictionary());
|
||||
}
|
||||
|
||||
ClassProfile::ClassProfile()
|
||||
{
|
||||
_action_bar_profile = Ref<ActionBarProfile>(memnew( ActionBarProfile()));
|
||||
_input_profile = Ref<InputProfile>(memnew(InputProfile()));
|
||||
|
||||
_class_id = 0;
|
||||
_level = 0;
|
||||
_xp = 0;
|
||||
_actionbar_locked = false;
|
||||
}
|
||||
|
||||
ClassProfile::ClassProfile(int class_id)
|
||||
{
|
||||
_action_bar_profile = Ref<ActionBarProfile>(memnew( ActionBarProfile()));
|
||||
_input_profile = Ref<InputProfile>(memnew(InputProfile()));
|
||||
|
||||
_class_id = class_id;
|
||||
_level = 50;
|
||||
_xp = 0;
|
||||
_actionbar_locked = false;
|
||||
load_defaults();
|
||||
}
|
||||
|
||||
ClassProfile::ClassProfile(String class_name, int class_id, int level, int xp, bool locked, bool pload_defaults)
|
||||
{
|
||||
_action_bar_profile = Ref<ActionBarProfile>(memnew( ActionBarProfile()));
|
||||
_input_profile = Ref<InputProfile>(memnew(InputProfile()));
|
||||
|
||||
_character_class_name = class_name;
|
||||
_class_id = class_id;
|
||||
_level = level;
|
||||
_xp = xp;
|
||||
_actionbar_locked = true;
|
||||
|
||||
if (pload_defaults) {
|
||||
load_defaults();
|
||||
}
|
||||
}
|
||||
|
||||
void ClassProfile::load_defaults()
|
||||
{
|
||||
_action_bar_profile->load_defaults();
|
||||
}
|
||||
|
||||
void ClassProfile::_bind_methods()
|
||||
{
|
||||
ClassDB::bind_method(D_METHOD("get_class_id"), &ClassProfile::get_class_id);
|
||||
ClassDB::bind_method(D_METHOD("set_class_id", "value"), &ClassProfile::set_class_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "class_id"), "set_class_id", "get_class_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_character_class_name"), &ClassProfile::get_character_class_name);
|
||||
ClassDB::bind_method(D_METHOD("set_character_class_name", "value"), &ClassProfile::set_character_class_name);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "character_class_name"), "set_character_class_name", "get_character_class_name");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_level"), &ClassProfile::get_level);
|
||||
ClassDB::bind_method(D_METHOD("set_level", "value"), &ClassProfile::set_level);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "level"), "set_class_id", "get_level");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_xp"), &ClassProfile::get_xp);
|
||||
ClassDB::bind_method(D_METHOD("set_xp", "value"), &ClassProfile::set_xp);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "xp"), "set_xp", "get_xp");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_actionbar_locked"), &ClassProfile::get_actionbar_locked);
|
||||
ClassDB::bind_method(D_METHOD("set_actionbar_locked", "value"), &ClassProfile::set_actionbar_locked);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "actionbar_locked"), "set_actionbar_locked", "get_actionbar_locked");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_input_profile"), &ClassProfile::get_input_profile);
|
||||
ClassDB::bind_method(D_METHOD("get_action_bar_profile"), &ClassProfile::get_action_bar_profile);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("from_dict", "dict"), &ClassProfile::from_dict);
|
||||
ClassDB::bind_method(D_METHOD("to_dict"), &ClassProfile::to_dict);
|
||||
}
|
||||
|
||||
|
56
profile_manager/class_profile.h
Normal file
56
profile_manager/class_profile.h
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef CLASS_PROFILE_H
|
||||
#define CLASS_PROFILE_H
|
||||
|
||||
|
||||
#include "core/ustring.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/dictionary.h"
|
||||
|
||||
#include "actionbar/action_bar_profile.h"
|
||||
#include "input/input_profile.h"
|
||||
|
||||
class ClassProfile : public Reference {
|
||||
GDCLASS(ClassProfile, Reference);
|
||||
|
||||
public:
|
||||
int get_class_id();
|
||||
void set_class_id(int value);
|
||||
String get_character_class_name();
|
||||
void set_character_class_name(String value);
|
||||
int get_level();
|
||||
void set_level(int value);
|
||||
int get_xp();
|
||||
void set_xp(int value);
|
||||
bool get_actionbar_locked();
|
||||
void set_actionbar_locked(bool value);
|
||||
Ref<InputProfile> get_input_profile();
|
||||
Ref<ActionBarProfile> get_action_bar_profile();
|
||||
|
||||
Dictionary get_custom_data();
|
||||
void set_custom_data(const Dictionary &dict);
|
||||
|
||||
Dictionary to_dict() const;
|
||||
void from_dict(const Dictionary &dict);
|
||||
|
||||
ClassProfile();
|
||||
ClassProfile(int class_id);
|
||||
ClassProfile(String class_name, int class_id, int level, int xp, bool locked, bool load_defaults);
|
||||
void load_defaults();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
String _character_class_name;
|
||||
int _class_id;
|
||||
int _level;
|
||||
int _xp;
|
||||
bool _actionbar_locked;
|
||||
|
||||
Ref<InputProfile> _input_profile;
|
||||
Ref<ActionBarProfile> _action_bar_profile;
|
||||
|
||||
Dictionary _custom_data;
|
||||
};
|
||||
|
||||
#endif
|
1
profile_manager/input/input_profile.cpp
Normal file
1
profile_manager/input/input_profile.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "input_profile.h"
|
23
profile_manager/input/input_profile.h
Normal file
23
profile_manager/input/input_profile.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef INPUT_PROFILE_H
|
||||
#define INPUT_PROFILE_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/ustring.h"
|
||||
|
||||
class InputProfile : public Reference {
|
||||
GDCLASS(InputProfile, Reference);
|
||||
|
||||
public:
|
||||
|
||||
InputProfile() {}
|
||||
|
||||
protected:
|
||||
static void _bind_methods() {}
|
||||
|
||||
private:
|
||||
int placeholder;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
79
profile_manager/input/input_profile_modifier.cpp
Normal file
79
profile_manager/input/input_profile_modifier.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
#include "input_profile_modifier.h"
|
||||
|
||||
int InputProfileModifier::get_modifier_count() {
|
||||
return _modifier_actions->size();
|
||||
}
|
||||
|
||||
void InputProfileModifier::clear_modifiers() {
|
||||
_modifier_actions->clear();
|
||||
}
|
||||
|
||||
void InputProfileModifier::add_modifier(String modifier) {
|
||||
_modifier_actions->push_back(modifier);
|
||||
}
|
||||
|
||||
String InputProfileModifier::get_modifier(int index) {
|
||||
return _modifier_actions->get(index);
|
||||
}
|
||||
|
||||
void InputProfileModifier::set_modifier(int index, String value) {
|
||||
_modifier_actions->set(index, value);
|
||||
}
|
||||
|
||||
void InputProfileModifier::remove_modifier(int index) {
|
||||
_modifier_actions->remove(index);
|
||||
}
|
||||
|
||||
int InputProfileModifier::get_entry_count() {
|
||||
return _entries->size();
|
||||
}
|
||||
|
||||
void InputProfileModifier::clear_entries() {
|
||||
_entries->clear();
|
||||
}
|
||||
|
||||
void InputProfileModifier::add_entry(Ref<InputProfileModifierEntry> modifier) {
|
||||
_entries->push_back(Ref<InputProfileModifierEntry>(modifier));
|
||||
}
|
||||
|
||||
Ref<InputProfileModifierEntry> InputProfileModifier::get_entry(int index) {
|
||||
return _entries->get(index);
|
||||
}
|
||||
|
||||
void InputProfileModifier::set_entry(int index, Ref<InputProfileModifierEntry> value) {
|
||||
_entries->set(index, Ref<InputProfileModifierEntry>(value));
|
||||
}
|
||||
|
||||
void InputProfileModifier::remove_entry(int index) {
|
||||
_entries->remove(index);
|
||||
}
|
||||
|
||||
InputProfileModifier::InputProfileModifier() {
|
||||
_modifier_actions = memnew(Vector<String>());
|
||||
_entries = memnew(Vector<Ref<InputProfileModifierEntry> >());
|
||||
}
|
||||
|
||||
InputProfileModifier::~InputProfileModifier() {
|
||||
_modifier_actions->clear();
|
||||
_entries->clear();
|
||||
|
||||
memdelete(_modifier_actions);
|
||||
memdelete(_entries);
|
||||
}
|
||||
|
||||
void InputProfileModifier::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_modifier_count"), &InputProfileModifier::get_modifier_count);
|
||||
ClassDB::bind_method(D_METHOD("clear_modifiers"), &InputProfileModifier::clear_modifiers);
|
||||
ClassDB::bind_method(D_METHOD("add_modifier", "modifier"), &InputProfileModifier::add_modifier);
|
||||
ClassDB::bind_method(D_METHOD("get_modifier", "index"), &InputProfileModifier::get_modifier);
|
||||
ClassDB::bind_method(D_METHOD("set_modifier", "index", "value"), &InputProfileModifier::set_modifier);
|
||||
ClassDB::bind_method(D_METHOD("remove_modifier", "index"), &InputProfileModifier::remove_modifier);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entry_count"), &InputProfileModifier::get_entry_count);
|
||||
ClassDB::bind_method(D_METHOD("clear_entries"), &InputProfileModifier::clear_entries);
|
||||
ClassDB::bind_method(D_METHOD("add_entry", "entry"), &InputProfileModifier::add_entry);
|
||||
ClassDB::bind_method(D_METHOD("get_entry", "index"), &InputProfileModifier::get_entry);
|
||||
ClassDB::bind_method(D_METHOD("set_entry", "index", "value"), &InputProfileModifier::set_entry);
|
||||
ClassDB::bind_method(D_METHOD("remove_entry", "index"), &InputProfileModifier::remove_entry);
|
||||
|
||||
}
|
40
profile_manager/input/input_profile_modifier.h
Normal file
40
profile_manager/input/input_profile_modifier.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef INPUT_PROFILE_MODIFIER_H
|
||||
#define INPUT_PROFILE_MODIFIER_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/ustring.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "input_profile_modifier_entry.h"
|
||||
|
||||
|
||||
class InputProfileModifier : public Reference {
|
||||
GDCLASS(InputProfileModifier, Reference);
|
||||
|
||||
public:
|
||||
int get_modifier_count();
|
||||
void clear_modifiers();
|
||||
void add_modifier(String modifier);
|
||||
String get_modifier(int index);
|
||||
void set_modifier(int index, String value);
|
||||
void remove_modifier(int index);
|
||||
|
||||
int get_entry_count();
|
||||
void clear_entries();
|
||||
void add_entry(Ref<InputProfileModifierEntry> modifier);
|
||||
Ref<InputProfileModifierEntry> get_entry(int index);
|
||||
void set_entry(int index, Ref<InputProfileModifierEntry> value);
|
||||
void remove_entry(int index);
|
||||
|
||||
InputProfileModifier();
|
||||
~InputProfileModifier();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Vector<String> *_modifier_actions;
|
||||
Vector<Ref<InputProfileModifierEntry> > *_entries;
|
||||
};
|
||||
|
||||
#endif
|
32
profile_manager/input/input_profile_modifier_entry.cpp
Normal file
32
profile_manager/input/input_profile_modifier_entry.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "input_profile_modifier_entry.h"
|
||||
|
||||
String InputProfileModifierEntry::get_action() {
|
||||
return _action;
|
||||
}
|
||||
|
||||
void InputProfileModifierEntry::set_action(String value) {
|
||||
_action = value;
|
||||
}
|
||||
|
||||
String InputProfileModifierEntry::get_translate_to() {
|
||||
return _translate_to;
|
||||
}
|
||||
|
||||
void InputProfileModifierEntry::set_translate_to(String value) {
|
||||
_action = _translate_to;
|
||||
}
|
||||
|
||||
InputProfileModifierEntry::InputProfileModifierEntry() {
|
||||
|
||||
}
|
||||
|
||||
void InputProfileModifierEntry::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_action"), &InputProfileModifierEntry::get_action);
|
||||
ClassDB::bind_method(D_METHOD("set_action", "value"), &InputProfileModifierEntry::set_action);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), "set_action", "get_action");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_translate_to"), &InputProfileModifierEntry::get_translate_to);
|
||||
ClassDB::bind_method(D_METHOD("set_translate_to", "value"), &InputProfileModifierEntry::set_translate_to);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "translate_to"), "set_translate_to", "get_translate_to");
|
||||
}
|
||||
|
28
profile_manager/input/input_profile_modifier_entry.h
Normal file
28
profile_manager/input/input_profile_modifier_entry.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef INPUT_PROFILE_MODIFIER_ENTRY_H
|
||||
#define INPUT_PROFILE_MODIFIER_ENTRY_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/ustring.h"
|
||||
|
||||
class InputProfileModifierEntry : public Reference {
|
||||
GDCLASS(InputProfileModifierEntry, Reference);
|
||||
|
||||
public:
|
||||
String get_action();
|
||||
void set_action(String value);
|
||||
|
||||
String get_translate_to();
|
||||
void set_translate_to(String value);
|
||||
|
||||
InputProfileModifierEntry();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
String _action;
|
||||
String _translate_to;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
177
profile_manager/profile_manager.cpp
Normal file
177
profile_manager/profile_manager.cpp
Normal file
@ -0,0 +1,177 @@
|
||||
#include "profile_manager.h"
|
||||
|
||||
const String ProfileManager::DEFAULT_PROFILE_FILE_NAME = "default.profile";
|
||||
|
||||
ProfileManager *ProfileManager::_instance;
|
||||
|
||||
ProfileManager *ProfileManager::get_instance() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
int ProfileManager::get_last_used_class() {
|
||||
return _last_used_class;
|
||||
}
|
||||
|
||||
void ProfileManager::set_last_used_class(int value) {
|
||||
_last_used_class = value;
|
||||
}
|
||||
|
||||
int ProfileManager::get_class_profile_count() {
|
||||
return _class_profiles.size();
|
||||
}
|
||||
|
||||
Ref<ClassProfile> ProfileManager::get_class_profile_index(int index) {
|
||||
return _class_profiles.get(index);
|
||||
}
|
||||
|
||||
void ProfileManager::add_class_profile(Ref<ClassProfile> profile) {
|
||||
_class_profiles.push_back(profile);
|
||||
}
|
||||
|
||||
void ProfileManager::clear_class_profiles() {
|
||||
_class_profiles.clear();
|
||||
}
|
||||
|
||||
void ProfileManager::remove_class_profile(int index) {
|
||||
_class_profiles.remove(index);
|
||||
}
|
||||
|
||||
Vector<Ref<ClassProfile> > &ProfileManager::get_class_profiles() {
|
||||
return _class_profiles;
|
||||
}
|
||||
|
||||
Ref<ClassProfile> ProfileManager::get_class_profile(int class_id) {
|
||||
for (int i = 0; i < _class_profiles.size(); ++i) {
|
||||
if (_class_profiles.get(i)->get_class_id() == class_id) {
|
||||
return Ref<ClassProfile>(_class_profiles.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
Ref<ClassProfile> class_profile = Ref<ClassProfile>(memnew(ClassProfile(class_id)));
|
||||
|
||||
class_profile->load_defaults();
|
||||
|
||||
_class_profiles.push_back(Ref<ClassProfile>(class_profile));
|
||||
|
||||
emit_signal("changed");
|
||||
|
||||
return Ref<ClassProfile>(class_profile);
|
||||
}
|
||||
|
||||
void ProfileManager::save() {
|
||||
if (has_method("_save")) {
|
||||
call("_save");
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileManager::load() {
|
||||
if (has_method("_load")) {
|
||||
call("_load");
|
||||
} //else {
|
||||
//load_defaults();
|
||||
//}
|
||||
}
|
||||
|
||||
void ProfileManager::save_profile(String name) {
|
||||
}
|
||||
|
||||
void ProfileManager::load_profile(String name) {
|
||||
load_defaults();
|
||||
}
|
||||
|
||||
int _last_used_class;
|
||||
|
||||
String _profile_name;
|
||||
|
||||
Vector<Ref<ClassProfile> > _class_profiles;
|
||||
|
||||
void ProfileManager::load_defaults() {
|
||||
_class_profiles.clear();
|
||||
|
||||
_class_profiles.push_back(memnew(ClassProfile("Naturalist", 1, 1, 0, false, true)));
|
||||
_class_profiles.push_back(memnew(ClassProfile("Berserker", 3, 1, 0, false, true)));
|
||||
_class_profiles.push_back(memnew(ClassProfile("IceArcher", 4, 1, 0, false, true)));
|
||||
_class_profiles.push_back(memnew(ClassProfile("Chronomancer", 6, 1, 0, false, true)));
|
||||
|
||||
for (int i = 0; i < _class_profiles.size(); ++i) {
|
||||
_class_profiles.get(i)->load_defaults();
|
||||
}
|
||||
|
||||
emit_signal("changed");
|
||||
}
|
||||
|
||||
Dictionary ProfileManager::to_dict() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["last_used_class"] = _last_used_class;
|
||||
dict["profile_name"] = _profile_name;
|
||||
|
||||
Array arr;
|
||||
|
||||
for (int i = 0; i < _class_profiles.size(); ++i) {
|
||||
Dictionary d = _class_profiles[i]->to_dict();
|
||||
|
||||
arr.append(d);
|
||||
}
|
||||
|
||||
dict["class_profiles"] = arr;
|
||||
|
||||
return dict;
|
||||
}
|
||||
void ProfileManager::from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
_last_used_class = dict.get("last_used_class", "");
|
||||
_profile_name = dict.get("profile_name", 0);
|
||||
|
||||
Array arr = dict.get("class_profiles", Array());
|
||||
|
||||
for (int i = 0; i < arr.size(); ++i) {
|
||||
Ref<ClassProfile> c;
|
||||
c.instance();
|
||||
|
||||
c->from_dict(arr.get(i));
|
||||
|
||||
_class_profiles.push_back(c);
|
||||
}
|
||||
}
|
||||
|
||||
ProfileManager::ProfileManager() {
|
||||
_instance = this;
|
||||
_last_used_class = 0;
|
||||
|
||||
_profile_name = ProfileManager::DEFAULT_PROFILE_FILE_NAME;
|
||||
}
|
||||
|
||||
ProfileManager::~ProfileManager() {
|
||||
_instance = NULL;
|
||||
|
||||
_class_profiles.clear();
|
||||
}
|
||||
|
||||
void ProfileManager::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("changed"));
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_save"));
|
||||
BIND_VMETHOD(MethodInfo("_load"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_last_used_class"), &ProfileManager::get_last_used_class);
|
||||
ClassDB::bind_method(D_METHOD("set_last_used_class", "value"), &ProfileManager::set_last_used_class);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "last_used_class"), "set_last_used_class", "get_last_used_class");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_class_profile_count"), &ProfileManager::get_class_profile_count);
|
||||
ClassDB::bind_method(D_METHOD("get_class_profile_index", "index"), &ProfileManager::get_class_profile_index);
|
||||
ClassDB::bind_method(D_METHOD("add_class_profile", "profile"), &ProfileManager::add_class_profile);
|
||||
ClassDB::bind_method(D_METHOD("clear_class_profiles"), &ProfileManager::clear_class_profiles);
|
||||
ClassDB::bind_method(D_METHOD("remove_class_profile", "index"), &ProfileManager::remove_class_profile);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_class_profile", "class_id"), &ProfileManager::get_class_profile);
|
||||
ClassDB::bind_method(D_METHOD("save"), &ProfileManager::save);
|
||||
ClassDB::bind_method(D_METHOD("load"), &ProfileManager::load);
|
||||
ClassDB::bind_method(D_METHOD("save_profile", "name"), &ProfileManager::save_profile);
|
||||
ClassDB::bind_method(D_METHOD("load_profile", "name"), &ProfileManager::load_profile);
|
||||
ClassDB::bind_method(D_METHOD("load_defaults"), &ProfileManager::load_defaults);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("from_dict", "dict"), &ProfileManager::from_dict);
|
||||
ClassDB::bind_method(D_METHOD("to_dict"), &ProfileManager::to_dict);
|
||||
}
|
56
profile_manager/profile_manager.h
Normal file
56
profile_manager/profile_manager.h
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef PROFILE_MANAGER_H
|
||||
#define PROFILE_MANAGER_H
|
||||
|
||||
#include "core/vector.h"
|
||||
#include "scene/main/node.h"
|
||||
|
||||
#include "class_profile.h"
|
||||
|
||||
class ProfileManager : public Node {
|
||||
GDCLASS(ProfileManager, Node);
|
||||
|
||||
public:
|
||||
static const String DEFAULT_PROFILE_FILE_NAME;
|
||||
|
||||
static ProfileManager *get_instance();
|
||||
|
||||
int get_last_used_class();
|
||||
void set_last_used_class(int value);
|
||||
|
||||
int get_class_profile_count();
|
||||
Ref<ClassProfile> get_class_profile_index(int index);
|
||||
void add_class_profile(Ref<ClassProfile> profile);
|
||||
void clear_class_profiles();
|
||||
void remove_class_profile(int index);
|
||||
|
||||
Vector<Ref<ClassProfile> > &get_class_profiles();
|
||||
Ref<ClassProfile> get_class_profile(int class_id);
|
||||
|
||||
void save();
|
||||
void load();
|
||||
|
||||
void save_profile(String name);
|
||||
void load_profile(String name);
|
||||
|
||||
void load_defaults();
|
||||
|
||||
Dictionary to_dict() const;
|
||||
void from_dict(const Dictionary &dict);
|
||||
|
||||
ProfileManager();
|
||||
~ProfileManager();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
static ProfileManager* _instance;
|
||||
|
||||
int _last_used_class;
|
||||
|
||||
String _profile_name;
|
||||
|
||||
Vector<Ref<ClassProfile> > _class_profiles;
|
||||
};
|
||||
|
||||
#endif
|
@ -103,6 +103,17 @@
|
||||
#include "ai/ai_action_container.h"
|
||||
#include "ai/ai_spell_action_container.h"
|
||||
|
||||
#include "profile_manager/input/input_profile_modifier.h"
|
||||
#include "profile_manager/input/input_profile_modifier_entry.h"
|
||||
#include "profile_manager/input/input_profile.h"
|
||||
|
||||
#include "profile_manager/actionbar/action_bar_button_entry.h"
|
||||
#include "profile_manager/actionbar/action_bar_entry.h"
|
||||
#include "profile_manager/actionbar/action_bar_profile.h"
|
||||
|
||||
#include "profile_manager/class_profile.h"
|
||||
#include "profile_manager/profile_manager.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "editor/editor_plugin.h"
|
||||
|
||||
@ -229,6 +240,18 @@ void register_entity_spell_system_types() {
|
||||
//meshes
|
||||
ClassDB::register_class<MeshDataResource>();
|
||||
|
||||
//ProfileManager
|
||||
ClassDB::register_class<InputProfileModifier>();
|
||||
ClassDB::register_class<InputProfileModifierEntry>();
|
||||
ClassDB::register_class<InputProfile>();
|
||||
|
||||
ClassDB::register_class<ActionBarButtonEntry>();
|
||||
ClassDB::register_class<ActionBarEntry>();
|
||||
ClassDB::register_class<ActionBarProfile>();
|
||||
|
||||
ClassDB::register_class<ClassProfile>();
|
||||
ClassDB::register_class<ProfileManager>();
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
EditorPlugins::add_by_type<EditorPluginColladaMdr>();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user