2021-11-23 16:53:47 +01:00
|
|
|
/*
|
2022-02-21 17:09:00 +01:00
|
|
|
Copyright (c) 2019-2022 Péter Magyar
|
2021-11-23 16:53:47 +01:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2022-02-21 22:07:03 +01:00
|
|
|
#ifndef PROP_2D_UTILS_H
|
|
|
|
#define PROP_2D_UTILS_H
|
2021-11-23 16:53:47 +01:00
|
|
|
|
|
|
|
#include "core/version.h"
|
|
|
|
|
|
|
|
#if VERSION_MAJOR > 3
|
|
|
|
#include "core/object/object.h"
|
|
|
|
#include "core/object/reference.h"
|
|
|
|
#include "core/templates/vector.h"
|
|
|
|
#include "scene/3d/node_3d.h"
|
|
|
|
#else
|
|
|
|
#include "core/object.h"
|
|
|
|
#include "core/reference.h"
|
|
|
|
#include "core/vector.h"
|
|
|
|
#include "scene/3d/spatial.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "scene/main/node.h"
|
|
|
|
|
2022-02-21 22:12:25 +01:00
|
|
|
class Prop2DData;
|
|
|
|
class Prop2DDataEntry;
|
2021-11-23 16:53:47 +01:00
|
|
|
|
|
|
|
#if VERSION_MINOR >= 4
|
|
|
|
class Room;
|
|
|
|
#endif
|
|
|
|
|
2022-02-21 22:12:25 +01:00
|
|
|
class Prop2DUtils : public Object {
|
|
|
|
GDCLASS(Prop2DUtils, Object);
|
2021-11-23 16:53:47 +01:00
|
|
|
|
|
|
|
public:
|
2022-02-21 22:12:25 +01:00
|
|
|
static Prop2DUtils *get_singleton();
|
2021-11-23 16:53:47 +01:00
|
|
|
|
2022-02-21 22:12:25 +01:00
|
|
|
Ref<Prop2DData> convert_tree(Node *root);
|
2022-02-22 19:05:10 +01:00
|
|
|
void _convert_tree(Ref<Prop2DData> prop_data, Node *node, const Transform2D &transform);
|
2021-11-23 16:53:47 +01:00
|
|
|
|
2022-02-21 22:12:25 +01:00
|
|
|
static int add_processor(const Ref<Prop2DDataEntry> &processor);
|
|
|
|
static Ref<Prop2DDataEntry> get_processor(const int index);
|
2021-11-23 16:53:47 +01:00
|
|
|
static void swap_processors(const int index1, const int index2);
|
|
|
|
static void remove_processor(const int index);
|
|
|
|
static int get_processor_count();
|
|
|
|
|
2022-02-21 22:12:25 +01:00
|
|
|
Prop2DUtils();
|
|
|
|
~Prop2DUtils();
|
2021-11-23 16:53:47 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
private:
|
2022-02-21 22:12:25 +01:00
|
|
|
int _add_processor_bind(const Ref<Prop2DDataEntry> &processor);
|
|
|
|
Ref<Prop2DDataEntry> _get_processor_bind(const int index);
|
2021-11-23 16:53:47 +01:00
|
|
|
void _swap_processors_bind(const int index1, const int index2);
|
|
|
|
void _remove_processor_bind(const int index);
|
|
|
|
int _get_processor_count_bind();
|
|
|
|
|
2022-02-21 22:12:25 +01:00
|
|
|
static Vector<Ref<Prop2DDataEntry>> _processors;
|
|
|
|
static Prop2DUtils *_instance;
|
2021-11-23 16:53:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|