removed InputEvent and Image

This commit is contained in:
Karroffel
2017-05-23 23:03:57 +02:00
parent 9caeb8d296
commit ad3720440e
15 changed files with 10 additions and 890 deletions

View File

@@ -7,8 +7,6 @@
#include "Basis.hpp"
#include "Color.hpp"
#include "Dictionary.hpp"
#include "Image.hpp"
#include "InputEvent.hpp"
#include "NodePath.hpp"
#include "Plane.hpp"
#include "PoolArrays.hpp"

View File

@@ -38,8 +38,6 @@ public:
Array keys() const;
int parse_json(const String& json);
Variant &operator [](const Variant& key);
const Variant &operator [](const Variant& key) const;

View File

@@ -2,6 +2,7 @@
#define GODOT_HPP
#include <cstdlib>
#include <cstring>
#include <godot.h>

View File

@@ -1,139 +0,0 @@
#ifndef IMAGE_H
#define IMAGE_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Defs.hpp"
#include "Vector2.hpp"
#include "Rect2.hpp"
#include "Color.hpp"
#include "String.hpp"
#include <godot/godot_image.h>
namespace godot {
class PoolByteArray;
class GD_CPP_CORE_API Image {
godot_image _godot_image;
public:
enum Format {
FORMAT_L8, //luminance
FORMAT_LA8, //luminance-alpha
FORMAT_R8,
FORMAT_RG8,
FORMAT_RGB8,
FORMAT_RGBA8,
FORMAT_RGB565, //16 bit
FORMAT_RGBA4444,
FORMAT_RGBA5551,
FORMAT_RF, //float
FORMAT_RGF,
FORMAT_RGBF,
FORMAT_RGBAF,
FORMAT_RH, //half float
FORMAT_RGH,
FORMAT_RGBH,
FORMAT_RGBAH,
FORMAT_DXT1, //s3tc bc1
FORMAT_DXT3, //bc2
FORMAT_DXT5, //bc3
FORMAT_ATI1, //bc4
FORMAT_ATI2, //bc5
FORMAT_BPTC_RGBA, //btpc bc6h
FORMAT_BPTC_RGBF, //float /
FORMAT_BPTC_RGBFU, //unsigned float
FORMAT_PVRTC2, //pvrtc
FORMAT_PVRTC2A,
FORMAT_PVRTC4,
FORMAT_PVRTC4A,
FORMAT_ETC, //etc1
FORMAT_ETC2_R11, //etc2
FORMAT_ETC2_R11S, //signed, NOT srgb.
FORMAT_ETC2_RG11,
FORMAT_ETC2_RG11S,
FORMAT_ETC2_RGB8,
FORMAT_ETC2_RGBA8,
FORMAT_ETC2_RGB8A1,
FORMAT_MAX
};
enum Interpolation {
INTERPOLATE_NEAREST,
INTERPOLATE_BILINEAR,
INTERPOLATE_CUBIC,
/* INTERPOLATE GAUSS */
};
enum CompressMode {
COMPRESS_16BIT,
COMPRESS_S3TC,
COMPRESS_PVRTC2,
COMPRESS_PVRTC4,
COMPRESS_ETC,
COMPRESS_ETC2
};
Image();
Image(const int width, const int height, const bool mipmaps, const Format format);
void blit_rect(const Image& src, const Rect2& src_rect, const Vector2& dest = Vector2(0, 0));
void brush_transfer(const Image& src, const Image& brush, const Vector2& pos = Vector2(0, 0));
Image brushed(const Image& src, const Image& brush, const Vector2& pos = Vector2(0, 0));
Image compressed(const Format format);
Image converted(const Format format);
Image decompressed();
bool empty() const;
void fix_alpha_edges();
PoolByteArray get_data();
Format get_format() const;
int get_height() const;
Color get_pixel(const int x, const int y, const int mipmap_level = 0);
Image get_rect(const Rect2& area = Rect2());
Rect2 get_used_rect() const;
int get_width() const;
Error load(const String& path);
void put_pixel(const int x, const int y, const Color& color, int mipmap_level = 0);
Image resized(const int x, const int y, const Interpolation interpolation = INTERPOLATE_NEAREST);
Error save_png(const String& path);
~Image();
};
}
#endif // IMAGE_H

View File

@@ -1,281 +0,0 @@
#ifndef INPUTEVENT_H
#define INPUTEVENT_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include <cstdint>
#include <memory.h>
#include "String.hpp"
namespace godot {
enum {
BUTTON_LEFT=1,
BUTTON_RIGHT=2,
BUTTON_MIDDLE=3,
BUTTON_WHEEL_UP=4,
BUTTON_WHEEL_DOWN=5,
BUTTON_WHEEL_LEFT=6,
BUTTON_WHEEL_RIGHT=7,
BUTTON_MASK_LEFT=(1<<(BUTTON_LEFT-1)),
BUTTON_MASK_RIGHT=(1<<(BUTTON_RIGHT-1)),
BUTTON_MASK_MIDDLE=(1<<(BUTTON_MIDDLE-1)),
};
enum {
JOY_BUTTON_0 = 0,
JOY_BUTTON_1 = 1,
JOY_BUTTON_2 = 2,
JOY_BUTTON_3 = 3,
JOY_BUTTON_4 = 4,
JOY_BUTTON_5 = 5,
JOY_BUTTON_6 = 6,
JOY_BUTTON_7 = 7,
JOY_BUTTON_8 = 8,
JOY_BUTTON_9 = 9,
JOY_BUTTON_10 = 10,
JOY_BUTTON_11 = 11,
JOY_BUTTON_12 = 12,
JOY_BUTTON_13 = 13,
JOY_BUTTON_14 = 14,
JOY_BUTTON_15 = 15,
JOY_BUTTON_MAX = 16,
JOY_L = JOY_BUTTON_4,
JOY_R = JOY_BUTTON_5,
JOY_L2 = JOY_BUTTON_6,
JOY_R2 = JOY_BUTTON_7,
JOY_L3 = JOY_BUTTON_8,
JOY_R3 = JOY_BUTTON_9,
JOY_SELECT = JOY_BUTTON_10,
JOY_START = JOY_BUTTON_11,
JOY_DPAD_UP = JOY_BUTTON_12,
JOY_DPAD_DOWN = JOY_BUTTON_13,
JOY_DPAD_LEFT = JOY_BUTTON_14,
JOY_DPAD_RIGHT = JOY_BUTTON_15,
// a little history about game controllers (who copied who)
JOY_SNES_B = JOY_BUTTON_0,
JOY_SNES_A = JOY_BUTTON_1,
JOY_SNES_Y = JOY_BUTTON_2,
JOY_SNES_X = JOY_BUTTON_3,
JOY_SONY_CIRCLE=JOY_SNES_A,
JOY_SONY_X=JOY_SNES_B,
JOY_SONY_SQUARE=JOY_SNES_Y,
JOY_SONY_TRIANGLE=JOY_SNES_X,
JOY_SEGA_B=JOY_SNES_A,
JOY_SEGA_A=JOY_SNES_B,
JOY_SEGA_X=JOY_SNES_Y,
JOY_SEGA_Y=JOY_SNES_X,
JOY_XBOX_B=JOY_SEGA_B,
JOY_XBOX_A=JOY_SEGA_A,
JOY_XBOX_X=JOY_SEGA_X,
JOY_XBOX_Y=JOY_SEGA_Y,
JOY_DS_A = JOY_SNES_A,
JOY_DS_B = JOY_SNES_B,
JOY_DS_X = JOY_SNES_X,
JOY_DS_Y = JOY_SNES_Y,
JOY_WII_C = JOY_BUTTON_5,
JOY_WII_Z = JOY_BUTTON_6,
JOY_WII_MINUS = JOY_BUTTON_9,
JOY_WII_PLUS = JOY_BUTTON_10,
// end of history
JOY_AXIS_0=0,
JOY_AXIS_1=1,
JOY_AXIS_2=2,
JOY_AXIS_3=3,
JOY_AXIS_4=4,
JOY_AXIS_5=5,
JOY_AXIS_6=6,
JOY_AXIS_7=7,
JOY_AXIS_MAX=8,
JOY_ANALOG_0_X = JOY_AXIS_0,
JOY_ANALOG_0_Y = JOY_AXIS_1,
JOY_ANALOG_1_X = JOY_AXIS_2,
JOY_ANALOG_1_Y = JOY_AXIS_3,
JOY_ANALOG_2_X = JOY_AXIS_4,
JOY_ANALOG_2_Y = JOY_AXIS_5,
JOY_ANALOG_L2 = JOY_AXIS_6,
JOY_ANALOG_R2 = JOY_AXIS_7,
};
/**
* Input Modifier Status
* for keyboard/mouse events.
*/
struct GD_CPP_CORE_API InputModifierState {
bool shift;
bool alt;
#ifdef APPLE_STYLE_KEYS
union {
bool command;
bool meta; //< windows/mac key
};
bool control;
#else
union {
bool command; //< windows/mac key
bool control;
};
bool meta; //< windows/mac key
#endif
inline bool operator==(const InputModifierState& rvalue) const {
return ( (shift==rvalue.shift) && (alt==rvalue.alt) && (control==rvalue.control) && (meta==rvalue.meta));
}
};
struct InputEventKey {
InputModifierState mod;
bool pressed; /// otherwise release
uint32_t scancode; ///< check keyboard.h , KeyCode enum, without modifier masks
uint32_t unicode; ///unicode
bool echo; /// true if this is an echo key
};
struct InputEventMouse {
InputModifierState mod;
int button_mask;
float x,y;
float global_x,global_y;
int pointer_index;
};
struct InputEventMouseButton : public InputEventMouse {
int button_index;
bool pressed; //otherwise released
bool doubleclick; //last even less than doubleclick time
};
struct InputEventMouseMotion : public InputEventMouse {
float relative_x,relative_y;
float speed_x,speed_y;
};
struct InputEventJoypadMotion {
int axis; ///< Joypad axis
float axis_value; ///< -1 to 1
};
struct InputEventJoypadButton {
int button_index;
bool pressed;
float pressure; //0 to 1
};
struct InputEventScreenTouch {
int index;
float x,y;
bool pressed;
};
struct InputEventScreenDrag {
int index;
float x,y;
float relative_x,relative_y;
float speed_x,speed_y;
};
struct InputEventAction {
int action;
bool pressed;
};
class Transform2D;
struct GD_CPP_CORE_API InputEvent {
enum Type {
NONE,
KEY,
MOUSE_MOTION,
MOUSE_BUTTON,
JOYPAD_MOTION,
JOYPAD_BUTTON,
SCREEN_TOUCH,
SCREEN_DRAG,
ACTION,
TYPE_MAX
};
uint32_t ID;
int type;
int device;
union {
InputEventMouseMotion mouse_motion;
InputEventMouseButton mouse_button;
InputEventJoypadMotion joy_motion;
InputEventJoypadButton joy_button;
InputEventKey key;
InputEventScreenTouch screen_touch;
InputEventScreenDrag screen_drag;
InputEventAction action;
};
bool is_pressed() const;
bool is_action(const String& p_action) const;
bool is_action_pressed(const String& p_action) const;
bool is_action_released(const String& p_action) const;
bool is_echo() const;
void set_as_action(const String& p_action, bool p_pressed);
InputEvent xform_by(const Transform2D& p_xform) const;
bool operator==(const InputEvent &p_event) const;
operator String() const;
inline InputEvent() { memset(this,0,sizeof(InputEvent)); }
};
}
#endif // INPUTEVENT_H

View File

@@ -27,7 +27,6 @@ public:
int32_t get_rid() const;
~RID();
};
}

View File

@@ -17,8 +17,6 @@
#include "Basis.hpp"
#include "Color.hpp"
#include "Image.hpp"
#include "InputEvent.hpp"
#include "NodePath.hpp"
#include "Plane.hpp"
#include "PoolArrays.hpp"
@@ -67,21 +65,19 @@ public:
// misc types
COLOR,
IMAGE, // 15
NODE_PATH,
NODE_PATH, // 15
_RID,
OBJECT,
INPUT_EVENT,
DICTIONARY, // 20
DICTIONARY,
ARRAY,
// arrays
POOL_BYTE_ARRAY,
POOL_BYTE_ARRAY, // 20
POOL_INT_ARRAY,
POOL_REAL_ARRAY,
POOL_STRING_ARRAY, // 25
POOL_STRING_ARRAY,
POOL_VECTOR2_ARRAY,
POOL_VECTOR3_ARRAY,
POOL_VECTOR3_ARRAY, // 25
POOL_COLOR_ARRAY,
VARIANT_MAX
@@ -140,16 +136,12 @@ public:
Variant(const Color& p_color);
Variant(const Image& p_image);
Variant(const NodePath& p_path);
Variant(const RID& p_rid);
Variant(const Object* p_object);
Variant(const InputEvent& p_input_event);
Variant(const Dictionary& p_dictionary);
Variant(const Array& p_array);
@@ -201,10 +193,8 @@ public:
operator Color() const;
operator Image() const;
operator NodePath() const;
operator RID() const;
operator InputEvent() const;
operator Object*() const;
operator Dictionary() const;