mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 00:11:55 +07:00
core lua api is almost complete
This commit is contained in:
@@ -129,6 +129,11 @@ namespace e2d
|
|||||||
|
|
||||||
const char* mouse_button_to_cstr(mouse_button btn) noexcept;
|
const char* mouse_button_to_cstr(mouse_button btn) noexcept;
|
||||||
const char* keyboard_key_to_cstr(keyboard_key key) noexcept;
|
const char* keyboard_key_to_cstr(keyboard_key key) noexcept;
|
||||||
const char* mouse_button_action_to_cstr(mouse_button_action action) noexcept;
|
const char* mouse_button_action_to_cstr(mouse_button_action act) noexcept;
|
||||||
const char* keyboard_key_action_to_cstr(keyboard_key_action action) noexcept;
|
const char* keyboard_key_action_to_cstr(keyboard_key_action act) noexcept;
|
||||||
|
|
||||||
|
bool parse_mouse_button(str_view str, mouse_button& btn) noexcept;
|
||||||
|
bool parse_keyboard_key(str_view str, keyboard_key& key) noexcept;
|
||||||
|
bool parse_mouse_button_action(str_view str, mouse_button_action& act) noexcept;
|
||||||
|
bool parse_keyboard_key_action(str_view str, keyboard_key_action& act) noexcept;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,6 +468,88 @@ namespace e2d::strings
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// trs2
|
||||||
|
//
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
class format_arg<trs2<T>, std::enable_if_t<std::is_integral_v<T>>> {
|
||||||
|
trs2<T> value_;
|
||||||
|
u8 width_;
|
||||||
|
public:
|
||||||
|
template < typename U >
|
||||||
|
explicit format_arg(U&& value, u8 width = 0) noexcept
|
||||||
|
: value_(std::forward<U>(value)), width_(width) {}
|
||||||
|
|
||||||
|
std::ptrdiff_t write(char* dst, size_t size) const {
|
||||||
|
return math::numeric_cast<std::ptrdiff_t>(
|
||||||
|
format(dst, size, "(%0,%1,%2)",
|
||||||
|
make_format_arg(value_.translation, width_),
|
||||||
|
make_format_arg(value_.rotation, width_),
|
||||||
|
make_format_arg(value_.scale, width_)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
class format_arg<trs2<T>, std::enable_if_t<std::is_floating_point_v<T>>> {
|
||||||
|
trs2<T> value_;
|
||||||
|
u8 width_;
|
||||||
|
u8 precision_;
|
||||||
|
public:
|
||||||
|
template < typename U >
|
||||||
|
explicit format_arg(U&& value, u8 width = 0, u8 precision = 6) noexcept
|
||||||
|
: value_(std::forward<U>(value)), width_(width), precision_(precision) {}
|
||||||
|
|
||||||
|
std::ptrdiff_t write(char* dst, size_t size) const {
|
||||||
|
return math::numeric_cast<std::ptrdiff_t>(
|
||||||
|
format(dst, size, "(%0,%1,%2)",
|
||||||
|
make_format_arg(value_.translation, width_, precision_),
|
||||||
|
make_format_arg(value_.rotation, width_, precision_),
|
||||||
|
make_format_arg(value_.scale, width_, precision_)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// trs3
|
||||||
|
//
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
class format_arg<trs3<T>, std::enable_if_t<std::is_integral_v<T>>> {
|
||||||
|
trs3<T> value_;
|
||||||
|
u8 width_;
|
||||||
|
public:
|
||||||
|
template < typename U >
|
||||||
|
explicit format_arg(U&& value, u8 width = 0) noexcept
|
||||||
|
: value_(std::forward<U>(value)), width_(width) {}
|
||||||
|
|
||||||
|
std::ptrdiff_t write(char* dst, size_t size) const {
|
||||||
|
return math::numeric_cast<std::ptrdiff_t>(
|
||||||
|
format(dst, size, "(%0,%1,%2)",
|
||||||
|
make_format_arg(value_.translation, width_),
|
||||||
|
make_format_arg(value_.rotation, width_),
|
||||||
|
make_format_arg(value_.scale, width_)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
class format_arg<trs3<T>, std::enable_if_t<std::is_floating_point_v<T>>> {
|
||||||
|
trs3<T> value_;
|
||||||
|
u8 width_;
|
||||||
|
u8 precision_;
|
||||||
|
public:
|
||||||
|
template < typename U >
|
||||||
|
explicit format_arg(U&& value, u8 width = 0, u8 precision = 6) noexcept
|
||||||
|
: value_(std::forward<U>(value)), width_(width), precision_(precision) {}
|
||||||
|
|
||||||
|
std::ptrdiff_t write(char* dst, size_t size) const {
|
||||||
|
return math::numeric_cast<std::ptrdiff_t>(
|
||||||
|
format(dst, size, "(%0,%1,%2)",
|
||||||
|
make_format_arg(value_.translation, width_, precision_),
|
||||||
|
make_format_arg(value_.rotation, width_, precision_),
|
||||||
|
make_format_arg(value_.scale, width_, precision_)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// url
|
// url
|
||||||
//
|
//
|
||||||
|
|||||||
8
samples/bin/library/scripts/emmy/core/dbgui.lua
Normal file
8
samples/bin/library/scripts/emmy/core/dbgui.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---@class dbgui
|
||||||
|
local dbgui = {
|
||||||
|
---@type boolean
|
||||||
|
visible = false
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type dbgui
|
||||||
|
_G.the_dbgui = _G.the_dbgui or dbgui
|
||||||
17
samples/bin/library/scripts/emmy/core/debug.lua
Normal file
17
samples/bin/library/scripts/emmy/core/debug.lua
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---@class debug
|
||||||
|
local debug = {
|
||||||
|
---@type fun(self: debug, message: string)
|
||||||
|
trace = function(self, message) end,
|
||||||
|
|
||||||
|
---@type fun(self: debug, message: string)
|
||||||
|
warning = function(self, message) end,
|
||||||
|
|
||||||
|
---@type fun(self: debug, message: string)
|
||||||
|
error = function(self, message) end,
|
||||||
|
|
||||||
|
---@type fun(self: debug, message: string)
|
||||||
|
fatal = function(self, message) end
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type debug
|
||||||
|
_G.the_debug = _G.the_debug or debug
|
||||||
20
samples/bin/library/scripts/emmy/core/engine.lua
Normal file
20
samples/bin/library/scripts/emmy/core/engine.lua
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---@class engine
|
||||||
|
local engine = {
|
||||||
|
---@type number
|
||||||
|
time = 0,
|
||||||
|
|
||||||
|
---@type number
|
||||||
|
delta_time = 0,
|
||||||
|
|
||||||
|
---@type number
|
||||||
|
frame_rate = 0,
|
||||||
|
|
||||||
|
---@type number
|
||||||
|
frame_count = 0,
|
||||||
|
|
||||||
|
---@type number
|
||||||
|
realtime_time = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type engine
|
||||||
|
_G.the_engine = _G.the_engine or engine
|
||||||
11
samples/bin/library/scripts/emmy/core/input.lua
Normal file
11
samples/bin/library/scripts/emmy/core/input.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---@class input
|
||||||
|
local input = {
|
||||||
|
---@type mouse
|
||||||
|
mouse = {},
|
||||||
|
|
||||||
|
---@type keyboard
|
||||||
|
keyboard = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type input
|
||||||
|
_G.the_input = _G.the_input or input
|
||||||
35
samples/bin/library/scripts/emmy/core/keyboard.lua
Normal file
35
samples/bin/library/scripts/emmy/core/keyboard.lua
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
---@class keyboard
|
||||||
|
local keyboard = {
|
||||||
|
---@type fun(self: keyboard, key : string): boolean
|
||||||
|
is_key_pressed = function(self, key) return false end,
|
||||||
|
|
||||||
|
---@type fun(self: keyboard, key : string): boolean
|
||||||
|
is_key_just_pressed = function(self, key) return false end,
|
||||||
|
|
||||||
|
---@type fun(self: keyboard, key : string): boolean
|
||||||
|
is_key_just_released = function(self, key) return false end,
|
||||||
|
|
||||||
|
---@type string
|
||||||
|
input_text = "",
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
is_any_key_pressed = false,
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
is_any_key_just_pressed = false,
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
is_any_key_just_released = false,
|
||||||
|
|
||||||
|
---@type string[]
|
||||||
|
pressed_keys = {},
|
||||||
|
|
||||||
|
---@type string[]
|
||||||
|
just_pressed_keys = {},
|
||||||
|
|
||||||
|
---@type string[]
|
||||||
|
just_released_keys = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type keyboard
|
||||||
|
_G.the_keyboard = _G.the_keyboard or keyboard
|
||||||
38
samples/bin/library/scripts/emmy/core/mouse.lua
Normal file
38
samples/bin/library/scripts/emmy/core/mouse.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---@class mouse
|
||||||
|
local mouse = {
|
||||||
|
---@type fun(self: mouse, button : string): boolean
|
||||||
|
is_button_pressed = function(self, button) return false end,
|
||||||
|
|
||||||
|
---@type fun(self: mouse, button : string): boolean
|
||||||
|
is_button_just_pressed = function(self, button) return false end,
|
||||||
|
|
||||||
|
---@type fun(self: mouse, button : string): boolean
|
||||||
|
is_button_just_released = function(self, button) return false end,
|
||||||
|
|
||||||
|
---@type v2f
|
||||||
|
cursor_pos = v2f.zero(),
|
||||||
|
|
||||||
|
---@type v2f
|
||||||
|
scroll_delta = v2f.zero(),
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
is_any_button_pressed = false,
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
is_any_button_just_pressed = false,
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
is_any_button_just_released = false,
|
||||||
|
|
||||||
|
---@type string[]
|
||||||
|
pressed_buttons = {},
|
||||||
|
|
||||||
|
---@type string[]
|
||||||
|
just_pressed_buttons = {},
|
||||||
|
|
||||||
|
---@type string[]
|
||||||
|
just_released_buttons = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type mouse
|
||||||
|
_G.the_mouse = _G.the_mouse or mouse
|
||||||
50
samples/bin/library/scripts/emmy/core/window.lua
Normal file
50
samples/bin/library/scripts/emmy/core/window.lua
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
---@class window
|
||||||
|
local window = {
|
||||||
|
---@type fun(self: window)
|
||||||
|
hide = function(self) end,
|
||||||
|
|
||||||
|
---@type fun(self: window)
|
||||||
|
show = function(self) end,
|
||||||
|
|
||||||
|
---@type fun(self: window)
|
||||||
|
restore = function(self) end,
|
||||||
|
|
||||||
|
---@type fun(self: window)
|
||||||
|
minimize = function(self) end,
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
enable = true,
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
visible = true,
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
focused = true,
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
minimized = true,
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
fullscreen = false,
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
cursor_hidden = false,
|
||||||
|
|
||||||
|
---@type v2f
|
||||||
|
real_size = v2f.zero(),
|
||||||
|
|
||||||
|
---@type v2f
|
||||||
|
virtual_size = v2f.zero(),
|
||||||
|
|
||||||
|
---@type v2f
|
||||||
|
framebuffer_size = v2f.zero(),
|
||||||
|
|
||||||
|
---@type string
|
||||||
|
title = "",
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
should_close = false
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type window
|
||||||
|
_G.the_window = _G.the_window or window
|
||||||
@@ -194,3 +194,176 @@ namespace e2d
|
|||||||
#undef DEFINE_CASE
|
#undef DEFINE_CASE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace e2d
|
||||||
|
{
|
||||||
|
bool parse_mouse_button(str_view str, mouse_button& btn) noexcept {
|
||||||
|
#define DEFINE_IF(x) if ( str == #x ) { btn = mouse_button::x; return true; }
|
||||||
|
DEFINE_IF(left);
|
||||||
|
DEFINE_IF(right);
|
||||||
|
DEFINE_IF(middle);
|
||||||
|
DEFINE_IF(x1);
|
||||||
|
DEFINE_IF(x2);
|
||||||
|
DEFINE_IF(unknown);
|
||||||
|
#undef DEFINE_IF
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool parse_keyboard_key(str_view str, keyboard_key& key) noexcept {
|
||||||
|
#define DEFINE_IF(x) if ( str == #x ) { key = keyboard_key::x; return true; }
|
||||||
|
DEFINE_IF(_0);
|
||||||
|
DEFINE_IF(_1);
|
||||||
|
DEFINE_IF(_2);
|
||||||
|
DEFINE_IF(_3);
|
||||||
|
DEFINE_IF(_4);
|
||||||
|
DEFINE_IF(_5);
|
||||||
|
DEFINE_IF(_6);
|
||||||
|
DEFINE_IF(_7);
|
||||||
|
DEFINE_IF(_8);
|
||||||
|
DEFINE_IF(_9);
|
||||||
|
|
||||||
|
DEFINE_IF(a);
|
||||||
|
DEFINE_IF(b);
|
||||||
|
DEFINE_IF(c);
|
||||||
|
DEFINE_IF(d);
|
||||||
|
DEFINE_IF(e);
|
||||||
|
DEFINE_IF(f);
|
||||||
|
DEFINE_IF(g);
|
||||||
|
DEFINE_IF(h);
|
||||||
|
DEFINE_IF(i);
|
||||||
|
DEFINE_IF(j);
|
||||||
|
DEFINE_IF(k);
|
||||||
|
DEFINE_IF(l);
|
||||||
|
DEFINE_IF(m);
|
||||||
|
DEFINE_IF(n);
|
||||||
|
DEFINE_IF(o);
|
||||||
|
DEFINE_IF(p);
|
||||||
|
DEFINE_IF(q);
|
||||||
|
DEFINE_IF(r);
|
||||||
|
DEFINE_IF(s);
|
||||||
|
DEFINE_IF(t);
|
||||||
|
DEFINE_IF(u);
|
||||||
|
DEFINE_IF(v);
|
||||||
|
DEFINE_IF(w);
|
||||||
|
DEFINE_IF(x);
|
||||||
|
DEFINE_IF(y);
|
||||||
|
DEFINE_IF(z);
|
||||||
|
|
||||||
|
DEFINE_IF(f1);
|
||||||
|
DEFINE_IF(f2);
|
||||||
|
DEFINE_IF(f3);
|
||||||
|
DEFINE_IF(f4);
|
||||||
|
DEFINE_IF(f5);
|
||||||
|
DEFINE_IF(f6);
|
||||||
|
DEFINE_IF(f7);
|
||||||
|
DEFINE_IF(f8);
|
||||||
|
DEFINE_IF(f9);
|
||||||
|
DEFINE_IF(f10);
|
||||||
|
DEFINE_IF(f11);
|
||||||
|
DEFINE_IF(f12);
|
||||||
|
DEFINE_IF(f13);
|
||||||
|
DEFINE_IF(f14);
|
||||||
|
DEFINE_IF(f15);
|
||||||
|
DEFINE_IF(f16);
|
||||||
|
DEFINE_IF(f17);
|
||||||
|
DEFINE_IF(f18);
|
||||||
|
DEFINE_IF(f19);
|
||||||
|
DEFINE_IF(f20);
|
||||||
|
DEFINE_IF(f21);
|
||||||
|
DEFINE_IF(f22);
|
||||||
|
DEFINE_IF(f23);
|
||||||
|
DEFINE_IF(f24);
|
||||||
|
DEFINE_IF(f25);
|
||||||
|
|
||||||
|
DEFINE_IF(minus);
|
||||||
|
DEFINE_IF(equal);
|
||||||
|
DEFINE_IF(backspace);
|
||||||
|
DEFINE_IF(section_sign);
|
||||||
|
DEFINE_IF(grave_accent);
|
||||||
|
|
||||||
|
DEFINE_IF(lbracket);
|
||||||
|
DEFINE_IF(rbracket);
|
||||||
|
DEFINE_IF(semicolon);
|
||||||
|
DEFINE_IF(apostrophe);
|
||||||
|
DEFINE_IF(backslash);
|
||||||
|
|
||||||
|
DEFINE_IF(comma);
|
||||||
|
DEFINE_IF(period);
|
||||||
|
DEFINE_IF(slash);
|
||||||
|
|
||||||
|
DEFINE_IF(escape);
|
||||||
|
DEFINE_IF(tab);
|
||||||
|
DEFINE_IF(caps_lock);
|
||||||
|
DEFINE_IF(space);
|
||||||
|
DEFINE_IF(enter);
|
||||||
|
|
||||||
|
DEFINE_IF(lshift);
|
||||||
|
DEFINE_IF(rshift);
|
||||||
|
DEFINE_IF(lcontrol);
|
||||||
|
DEFINE_IF(rcontrol);
|
||||||
|
DEFINE_IF(lalt);
|
||||||
|
DEFINE_IF(ralt);
|
||||||
|
DEFINE_IF(lsuper);
|
||||||
|
DEFINE_IF(rsuper);
|
||||||
|
DEFINE_IF(menu);
|
||||||
|
|
||||||
|
DEFINE_IF(print_screen);
|
||||||
|
DEFINE_IF(scroll_lock);
|
||||||
|
DEFINE_IF(pause);
|
||||||
|
|
||||||
|
DEFINE_IF(insert);
|
||||||
|
DEFINE_IF(del);
|
||||||
|
DEFINE_IF(home);
|
||||||
|
DEFINE_IF(end);
|
||||||
|
DEFINE_IF(page_up);
|
||||||
|
DEFINE_IF(page_down);
|
||||||
|
|
||||||
|
DEFINE_IF(left);
|
||||||
|
DEFINE_IF(up);
|
||||||
|
DEFINE_IF(right);
|
||||||
|
DEFINE_IF(down);
|
||||||
|
|
||||||
|
DEFINE_IF(kp_0);
|
||||||
|
DEFINE_IF(kp_1);
|
||||||
|
DEFINE_IF(kp_2);
|
||||||
|
DEFINE_IF(kp_3);
|
||||||
|
DEFINE_IF(kp_4);
|
||||||
|
DEFINE_IF(kp_5);
|
||||||
|
DEFINE_IF(kp_6);
|
||||||
|
DEFINE_IF(kp_7);
|
||||||
|
DEFINE_IF(kp_8);
|
||||||
|
DEFINE_IF(kp_9);
|
||||||
|
|
||||||
|
DEFINE_IF(kp_num_lock);
|
||||||
|
DEFINE_IF(kp_divide);
|
||||||
|
DEFINE_IF(kp_multiply);
|
||||||
|
DEFINE_IF(kp_subtract);
|
||||||
|
DEFINE_IF(kp_add);
|
||||||
|
DEFINE_IF(kp_enter);
|
||||||
|
DEFINE_IF(kp_equal);
|
||||||
|
DEFINE_IF(kp_decimal);
|
||||||
|
|
||||||
|
DEFINE_IF(unknown);
|
||||||
|
#undef DEFINE_IF
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool parse_mouse_button_action(str_view str, mouse_button_action& act) noexcept {
|
||||||
|
#define DEFINE_IF(x) if ( str == #x ) { act = mouse_button_action::x; return true; }
|
||||||
|
DEFINE_IF(press);
|
||||||
|
DEFINE_IF(release);
|
||||||
|
DEFINE_IF(unknown);
|
||||||
|
#undef DEFINE_IF
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool parse_keyboard_key_action(str_view str, keyboard_key_action& act) noexcept {
|
||||||
|
#define DEFINE_IF(x) if ( str == #x ) { act = keyboard_key_action::x; return true; }
|
||||||
|
DEFINE_IF(press);
|
||||||
|
DEFINE_IF(repeat);
|
||||||
|
DEFINE_IF(release);
|
||||||
|
DEFINE_IF(unknown);
|
||||||
|
#undef DEFINE_IF
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,33 @@
|
|||||||
|
|
||||||
#include "_core_binds.hpp"
|
#include "_core_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
vector<str> convert_keys_to_strings(const vector<keyboard_key>& keys) {
|
||||||
|
vector<str> strings;
|
||||||
|
strings.reserve(keys.size());
|
||||||
|
std::transform(
|
||||||
|
keys.begin(),
|
||||||
|
keys.end(),
|
||||||
|
std::back_inserter(strings),
|
||||||
|
&keyboard_key_to_cstr);
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<str> convert_buttons_to_strings(const vector<mouse_button>& buttons) {
|
||||||
|
vector<str> strings;
|
||||||
|
strings.reserve(buttons.size());
|
||||||
|
std::transform(
|
||||||
|
buttons.begin(),
|
||||||
|
buttons.end(),
|
||||||
|
std::back_inserter(strings),
|
||||||
|
&mouse_button_to_cstr);
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace e2d::bindings::core
|
namespace e2d::bindings::core
|
||||||
{
|
{
|
||||||
void bind_input(sol::state& l) {
|
void bind_input(sol::state& l) {
|
||||||
@@ -23,20 +50,65 @@ namespace e2d::bindings::core
|
|||||||
.new_usertype<mouse>("mouse",
|
.new_usertype<mouse>("mouse",
|
||||||
sol::no_constructor,
|
sol::no_constructor,
|
||||||
|
|
||||||
"cursor_pos", sol::property(&mouse::cursor_pos),
|
"cursor_pos", sol::property([](const mouse& m){
|
||||||
"scroll_delta", sol::property(&mouse::scroll_delta),
|
return m.cursor_pos();
|
||||||
|
}),
|
||||||
|
|
||||||
|
"scroll_delta", sol::property([](const mouse& m){
|
||||||
|
return m.scroll_delta();
|
||||||
|
}),
|
||||||
|
|
||||||
"is_any_button_pressed", sol::property(&mouse::is_any_button_pressed),
|
"is_any_button_pressed", sol::property(&mouse::is_any_button_pressed),
|
||||||
"is_any_button_just_pressed", sol::property(&mouse::is_any_button_just_pressed),
|
"is_any_button_just_pressed", sol::property(&mouse::is_any_button_just_pressed),
|
||||||
"is_any_button_just_released", sol::property(&mouse::is_any_button_just_released),
|
"is_any_button_just_released", sol::property(&mouse::is_any_button_just_released),
|
||||||
|
|
||||||
"is_button_pressed", &mouse::is_button_pressed,
|
"is_button_pressed", [](const mouse& m, const char* n){
|
||||||
"is_button_just_pressed", &mouse::is_button_just_pressed,
|
mouse_button btn = mouse_button::unknown;
|
||||||
"is_button_just_released", &mouse::is_button_just_released,
|
if ( parse_mouse_button(n, btn) ) {
|
||||||
|
return m.is_button_pressed(btn);
|
||||||
|
}
|
||||||
|
the<debug>().error("MOUSE: unknown button name:\n"
|
||||||
|
"--> Function: `is_button_pressed`\n"
|
||||||
|
"--> Button: %0",
|
||||||
|
n);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
"pressed_buttons", sol::property(&mouse::pressed_buttons),
|
"is_button_just_pressed", [](const mouse& m, const char* n){
|
||||||
"just_pressed_buttons", sol::property(&mouse::pressed_buttons),
|
mouse_button btn = mouse_button::unknown;
|
||||||
"just_released_buttons", sol::property(&mouse::just_released_buttons)
|
if ( parse_mouse_button(n, btn) ) {
|
||||||
|
return m.is_button_just_pressed(btn);
|
||||||
|
}
|
||||||
|
the<debug>().error("MOUSE: unknown button name:\n"
|
||||||
|
"--> Function: `is_button_just_pressed`\n"
|
||||||
|
"--> Button: %0",
|
||||||
|
n);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
"is_button_just_released", [](const mouse& m, const char* n){
|
||||||
|
mouse_button btn = mouse_button::unknown;
|
||||||
|
if ( parse_mouse_button(n, btn) ) {
|
||||||
|
return m.is_button_just_released(btn);
|
||||||
|
}
|
||||||
|
the<debug>().error("MOUSE: unknown button name:\n"
|
||||||
|
"--> Function: `is_button_just_released`\n"
|
||||||
|
"--> Button: %0",
|
||||||
|
n);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
"pressed_buttons", sol::property([](const mouse& m){
|
||||||
|
return convert_buttons_to_strings(m.pressed_buttons());
|
||||||
|
}),
|
||||||
|
|
||||||
|
"just_pressed_buttons", sol::property([](const mouse& m){
|
||||||
|
return convert_buttons_to_strings(m.just_pressed_buttons());
|
||||||
|
}),
|
||||||
|
|
||||||
|
"just_released_buttons", sol::property([](const mouse& m){
|
||||||
|
return convert_buttons_to_strings(m.just_released_buttons());
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l["e2d"].get_or_create<sol::table>()
|
||||||
@@ -52,161 +124,53 @@ namespace e2d::bindings::core
|
|||||||
"is_any_key_just_pressed", sol::property(&keyboard::is_any_key_just_pressed),
|
"is_any_key_just_pressed", sol::property(&keyboard::is_any_key_just_pressed),
|
||||||
"is_any_key_just_released", sol::property(&keyboard::is_any_key_just_released),
|
"is_any_key_just_released", sol::property(&keyboard::is_any_key_just_released),
|
||||||
|
|
||||||
"is_key_pressed", &keyboard::is_key_pressed,
|
"is_key_pressed", [](const keyboard& k, const char* n){
|
||||||
"is_key_just_pressed", &keyboard::is_key_just_pressed,
|
keyboard_key key = keyboard_key::unknown;
|
||||||
"is_key_just_released", &keyboard::is_key_just_released,
|
if ( parse_keyboard_key(n, key) ) {
|
||||||
|
return k.is_key_pressed(key);
|
||||||
|
}
|
||||||
|
the<debug>().error("KEYBOARD: unknown key name:\n"
|
||||||
|
"--> Function: `is_key_pressed`\n"
|
||||||
|
"--> Key: %0",
|
||||||
|
n);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
"pressed_keys", sol::property(&keyboard::pressed_keys),
|
"is_key_just_pressed", [](const keyboard& k, const char* n){
|
||||||
"just_pressed_keys", sol::property(&keyboard::pressed_keys),
|
keyboard_key key = keyboard_key::unknown;
|
||||||
"just_released_keys", sol::property(&keyboard::just_released_keys)
|
if ( parse_keyboard_key(n, key) ) {
|
||||||
|
return k.is_key_just_pressed(key);
|
||||||
|
}
|
||||||
|
the<debug>().error("KEYBOARD: unknown key name:\n"
|
||||||
|
"--> Function: `is_key_just_pressed`\n"
|
||||||
|
"--> Key: %0",
|
||||||
|
n);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
"is_key_just_released", [](const keyboard& k, const char* n){
|
||||||
|
keyboard_key key = keyboard_key::unknown;
|
||||||
|
if ( parse_keyboard_key(n, key) ) {
|
||||||
|
return k.is_key_just_released(key);
|
||||||
|
}
|
||||||
|
the<debug>().error("KEYBOARD: unknown key name:\n"
|
||||||
|
"--> Function: `is_key_just_released`\n"
|
||||||
|
"--> Key: %0",
|
||||||
|
n);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
"pressed_keys", sol::property([](const keyboard& k){
|
||||||
|
return convert_keys_to_strings(k.pressed_keys());
|
||||||
|
}),
|
||||||
|
|
||||||
|
"just_pressed_keys", sol::property([](const keyboard& k){
|
||||||
|
return convert_keys_to_strings(k.just_pressed_keys());
|
||||||
|
}),
|
||||||
|
|
||||||
|
"just_released_keys", sol::property([](const keyboard& k){
|
||||||
|
return convert_keys_to_strings(k.just_released_keys());
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
#define MOUSE_BUTTON_PAIR(x) {#x, mouse_button::x},
|
|
||||||
l["e2d"].get_or_create<sol::table>()
|
|
||||||
.new_enum<mouse_button>("mouse_button", {
|
|
||||||
MOUSE_BUTTON_PAIR(left)
|
|
||||||
MOUSE_BUTTON_PAIR(right)
|
|
||||||
MOUSE_BUTTON_PAIR(middle)
|
|
||||||
MOUSE_BUTTON_PAIR(x1)
|
|
||||||
MOUSE_BUTTON_PAIR(x2)
|
|
||||||
});
|
|
||||||
#undef MOUSE_BUTTON_PAIR
|
|
||||||
|
|
||||||
#define KEYBOARD_KEY_PAIR(x) {#x, keyboard_key::x},
|
|
||||||
l["e2d"].get_or_create<sol::table>()
|
|
||||||
.new_enum<keyboard_key>("keyboard_key", {
|
|
||||||
KEYBOARD_KEY_PAIR(_0)
|
|
||||||
KEYBOARD_KEY_PAIR(_1)
|
|
||||||
KEYBOARD_KEY_PAIR(_2)
|
|
||||||
KEYBOARD_KEY_PAIR(_3)
|
|
||||||
KEYBOARD_KEY_PAIR(_4)
|
|
||||||
KEYBOARD_KEY_PAIR(_5)
|
|
||||||
KEYBOARD_KEY_PAIR(_6)
|
|
||||||
KEYBOARD_KEY_PAIR(_7)
|
|
||||||
KEYBOARD_KEY_PAIR(_8)
|
|
||||||
KEYBOARD_KEY_PAIR(_9)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(a)
|
|
||||||
KEYBOARD_KEY_PAIR(b)
|
|
||||||
KEYBOARD_KEY_PAIR(c)
|
|
||||||
KEYBOARD_KEY_PAIR(d)
|
|
||||||
KEYBOARD_KEY_PAIR(e)
|
|
||||||
KEYBOARD_KEY_PAIR(f)
|
|
||||||
KEYBOARD_KEY_PAIR(g)
|
|
||||||
KEYBOARD_KEY_PAIR(h)
|
|
||||||
KEYBOARD_KEY_PAIR(i)
|
|
||||||
KEYBOARD_KEY_PAIR(j)
|
|
||||||
KEYBOARD_KEY_PAIR(k)
|
|
||||||
KEYBOARD_KEY_PAIR(l)
|
|
||||||
KEYBOARD_KEY_PAIR(m)
|
|
||||||
KEYBOARD_KEY_PAIR(n)
|
|
||||||
KEYBOARD_KEY_PAIR(o)
|
|
||||||
KEYBOARD_KEY_PAIR(p)
|
|
||||||
KEYBOARD_KEY_PAIR(q)
|
|
||||||
KEYBOARD_KEY_PAIR(r)
|
|
||||||
KEYBOARD_KEY_PAIR(s)
|
|
||||||
KEYBOARD_KEY_PAIR(t)
|
|
||||||
KEYBOARD_KEY_PAIR(u)
|
|
||||||
KEYBOARD_KEY_PAIR(v)
|
|
||||||
KEYBOARD_KEY_PAIR(w)
|
|
||||||
KEYBOARD_KEY_PAIR(x)
|
|
||||||
KEYBOARD_KEY_PAIR(y)
|
|
||||||
KEYBOARD_KEY_PAIR(z)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(f1)
|
|
||||||
KEYBOARD_KEY_PAIR(f2)
|
|
||||||
KEYBOARD_KEY_PAIR(f3)
|
|
||||||
KEYBOARD_KEY_PAIR(f4)
|
|
||||||
KEYBOARD_KEY_PAIR(f5)
|
|
||||||
KEYBOARD_KEY_PAIR(f6)
|
|
||||||
KEYBOARD_KEY_PAIR(f7)
|
|
||||||
KEYBOARD_KEY_PAIR(f8)
|
|
||||||
KEYBOARD_KEY_PAIR(f9)
|
|
||||||
KEYBOARD_KEY_PAIR(f10)
|
|
||||||
KEYBOARD_KEY_PAIR(f11)
|
|
||||||
KEYBOARD_KEY_PAIR(f12)
|
|
||||||
KEYBOARD_KEY_PAIR(f13)
|
|
||||||
KEYBOARD_KEY_PAIR(f14)
|
|
||||||
KEYBOARD_KEY_PAIR(f15)
|
|
||||||
KEYBOARD_KEY_PAIR(f16)
|
|
||||||
KEYBOARD_KEY_PAIR(f17)
|
|
||||||
KEYBOARD_KEY_PAIR(f18)
|
|
||||||
KEYBOARD_KEY_PAIR(f19)
|
|
||||||
KEYBOARD_KEY_PAIR(f20)
|
|
||||||
KEYBOARD_KEY_PAIR(f21)
|
|
||||||
KEYBOARD_KEY_PAIR(f22)
|
|
||||||
KEYBOARD_KEY_PAIR(f23)
|
|
||||||
KEYBOARD_KEY_PAIR(f24)
|
|
||||||
KEYBOARD_KEY_PAIR(f25)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(minus)
|
|
||||||
KEYBOARD_KEY_PAIR(equal)
|
|
||||||
KEYBOARD_KEY_PAIR(backspace)
|
|
||||||
KEYBOARD_KEY_PAIR(section_sign)
|
|
||||||
KEYBOARD_KEY_PAIR(grave_accent)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(lbracket)
|
|
||||||
KEYBOARD_KEY_PAIR(rbracket)
|
|
||||||
KEYBOARD_KEY_PAIR(semicolon)
|
|
||||||
KEYBOARD_KEY_PAIR(apostrophe)
|
|
||||||
KEYBOARD_KEY_PAIR(backslash)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(comma)
|
|
||||||
KEYBOARD_KEY_PAIR(period)
|
|
||||||
KEYBOARD_KEY_PAIR(slash)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(escape)
|
|
||||||
KEYBOARD_KEY_PAIR(tab)
|
|
||||||
KEYBOARD_KEY_PAIR(caps_lock)
|
|
||||||
KEYBOARD_KEY_PAIR(space)
|
|
||||||
KEYBOARD_KEY_PAIR(enter)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(lshift)
|
|
||||||
KEYBOARD_KEY_PAIR(rshift)
|
|
||||||
KEYBOARD_KEY_PAIR(lcontrol)
|
|
||||||
KEYBOARD_KEY_PAIR(rcontrol)
|
|
||||||
KEYBOARD_KEY_PAIR(lalt)
|
|
||||||
KEYBOARD_KEY_PAIR(ralt)
|
|
||||||
KEYBOARD_KEY_PAIR(lsuper)
|
|
||||||
KEYBOARD_KEY_PAIR(rsuper)
|
|
||||||
KEYBOARD_KEY_PAIR(menu)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(print_screen)
|
|
||||||
KEYBOARD_KEY_PAIR(scroll_lock)
|
|
||||||
KEYBOARD_KEY_PAIR(pause)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(insert)
|
|
||||||
KEYBOARD_KEY_PAIR(del)
|
|
||||||
KEYBOARD_KEY_PAIR(home)
|
|
||||||
KEYBOARD_KEY_PAIR(end)
|
|
||||||
KEYBOARD_KEY_PAIR(page_up)
|
|
||||||
KEYBOARD_KEY_PAIR(page_down)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(left)
|
|
||||||
KEYBOARD_KEY_PAIR(up)
|
|
||||||
KEYBOARD_KEY_PAIR(right)
|
|
||||||
KEYBOARD_KEY_PAIR(down)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(kp_0)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_1)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_2)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_3)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_4)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_5)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_6)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_7)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_8)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_9)
|
|
||||||
|
|
||||||
KEYBOARD_KEY_PAIR(kp_num_lock)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_divide)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_multiply)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_subtract)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_add)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_enter)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_equal)
|
|
||||||
KEYBOARD_KEY_PAIR(kp_decimal)
|
|
||||||
});
|
|
||||||
#undef KEYBOARD_KEY_PAIR
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_aabb_t(const str& name, sol::state& l) {
|
void bind_aabb_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<aabb<T>>(name,
|
||||||
.new_usertype<aabb<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
aabb<T>(),
|
aabb<T>(),
|
||||||
aabb<T>(aabb<T>),
|
aabb<T>(aabb<T>),
|
||||||
@@ -28,6 +27,10 @@ namespace
|
|||||||
"position", &aabb<T>::position,
|
"position", &aabb<T>::position,
|
||||||
"size", &aabb<T>::size,
|
"size", &aabb<T>::size,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const aabb<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator==),
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator<),
|
sol::meta_function::less_than, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator<),
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator<=),
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator<=),
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_mat2_t(const str& name, sol::state& l) {
|
void bind_mat2_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<mat2<T>>(name,
|
||||||
.new_usertype<mat2<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
mat2<T>(),
|
mat2<T>(),
|
||||||
mat2<T>(const vec2<T>&, const vec2<T>&)
|
mat2<T>(const vec2<T>&, const vec2<T>&)
|
||||||
@@ -24,6 +23,10 @@ namespace
|
|||||||
|
|
||||||
"rows", &mat2<T>::rows,
|
"rows", &mat2<T>::rows,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const mat2<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const mat2<T>&, const mat2<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const mat2<T>&, const mat2<T>&)>(::operator==),
|
||||||
sol::meta_function::unary_minus, sol::resolve<mat2<T>(const mat2<T>&)>(::operator-),
|
sol::meta_function::unary_minus, sol::resolve<mat2<T>(const mat2<T>&)>(::operator-),
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_mat3_t(const str& name, sol::state& l) {
|
void bind_mat3_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<mat3<T>>(name,
|
||||||
.new_usertype<mat3<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
mat3<T>(),
|
mat3<T>(),
|
||||||
mat3<T>(const vec3<T>&, const vec3<T>&, const vec3<T>&)
|
mat3<T>(const vec3<T>&, const vec3<T>&, const vec3<T>&)
|
||||||
@@ -24,6 +23,10 @@ namespace
|
|||||||
|
|
||||||
"rows", &mat3<T>::rows,
|
"rows", &mat3<T>::rows,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const mat3<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const mat3<T>&, const mat3<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const mat3<T>&, const mat3<T>&)>(::operator==),
|
||||||
sol::meta_function::unary_minus, sol::resolve<mat3<T>(const mat3<T>&)>(::operator-),
|
sol::meta_function::unary_minus, sol::resolve<mat3<T>(const mat3<T>&)>(::operator-),
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_mat4_t(const str& name, sol::state& l) {
|
void bind_mat4_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<mat4<T>>(name,
|
||||||
.new_usertype<mat4<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
mat4<T>(),
|
mat4<T>(),
|
||||||
mat4<T>(const vec4<T>&, const vec4<T>&, const vec4<T>&, const vec4<T>&)
|
mat4<T>(const vec4<T>&, const vec4<T>&, const vec4<T>&, const vec4<T>&)
|
||||||
@@ -24,6 +23,10 @@ namespace
|
|||||||
|
|
||||||
"rows", &mat4<T>::rows,
|
"rows", &mat4<T>::rows,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const mat4<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const mat4<T>&, const mat4<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const mat4<T>&, const mat4<T>&)>(::operator==),
|
||||||
sol::meta_function::unary_minus, sol::resolve<mat4<T>(const mat4<T>&)>(::operator-),
|
sol::meta_function::unary_minus, sol::resolve<mat4<T>(const mat4<T>&)>(::operator-),
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_quat_t(const str& name, sol::state& l) {
|
void bind_quat_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<quat<T>>(name,
|
||||||
.new_usertype<quat<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
quat<T>(),
|
quat<T>(),
|
||||||
quat<T>(quat<T>),
|
quat<T>(quat<T>),
|
||||||
@@ -25,6 +24,10 @@ namespace
|
|||||||
"z", &quat<T>::z,
|
"z", &quat<T>::z,
|
||||||
"w", &quat<T>::w,
|
"w", &quat<T>::w,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const quat<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator==),
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator<),
|
sol::meta_function::less_than, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator<),
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator<=),
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator<=),
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_rect_t(const str& name, sol::state& l) {
|
void bind_rect_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<rect<T>>(name,
|
||||||
.new_usertype<rect<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
rect<T>(),
|
rect<T>(),
|
||||||
rect<T>(rect<T>),
|
rect<T>(rect<T>),
|
||||||
@@ -28,6 +27,10 @@ namespace
|
|||||||
"position", &rect<T>::position,
|
"position", &rect<T>::position,
|
||||||
"size", &rect<T>::size,
|
"size", &rect<T>::size,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const rect<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator==),
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator<),
|
sol::meta_function::less_than, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator<),
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator<=),
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator<=),
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_trs2_t(const str& name, sol::state& l) {
|
void bind_trs2_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<trs2<T>>(name,
|
||||||
.new_usertype<trs2<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
trs2<T>(),
|
trs2<T>(),
|
||||||
trs2<T>(trs2<T>),
|
trs2<T>(trs2<T>),
|
||||||
@@ -27,6 +26,10 @@ namespace
|
|||||||
"rotation", &trs2<T>::rotation,
|
"rotation", &trs2<T>::rotation,
|
||||||
"scale", &trs2<T>::scale,
|
"scale", &trs2<T>::scale,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const trs2<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const trs2<T>&, const trs2<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const trs2<T>&, const trs2<T>&)>(::operator==),
|
||||||
|
|
||||||
"make_translation_trs2", sol::resolve<trs2<T>(const vec2<T>&)>(&math::make_translation_trs2),
|
"make_translation_trs2", sol::resolve<trs2<T>(const vec2<T>&)>(&math::make_translation_trs2),
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_trs3_t(const str& name, sol::state& l) {
|
void bind_trs3_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<trs3<T>>(name,
|
||||||
.new_usertype<trs3<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
trs3<T>(),
|
trs3<T>(),
|
||||||
trs3<T>(trs3<T>),
|
trs3<T>(trs3<T>),
|
||||||
@@ -26,6 +25,10 @@ namespace
|
|||||||
"rotation", &trs3<T>::rotation,
|
"rotation", &trs3<T>::rotation,
|
||||||
"scale", &trs3<T>::scale,
|
"scale", &trs3<T>::scale,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const trs3<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const trs3<T>&, const trs3<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const trs3<T>&, const trs3<T>&)>(::operator==),
|
||||||
|
|
||||||
"make_translation_trs3", sol::resolve<trs3<T>(const vec3<T>&)>(&math::make_translation_trs3),
|
"make_translation_trs3", sol::resolve<trs3<T>(const vec3<T>&)>(&math::make_translation_trs3),
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T, typename Tag >
|
template < typename T, typename Tag >
|
||||||
void bind_unit_t(const str& name, sol::state& l) {
|
void bind_unit_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<unit<T,Tag>>(name,
|
||||||
.new_usertype<unit<T,Tag>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
unit<T,Tag>(),
|
unit<T,Tag>(),
|
||||||
unit<T,Tag>(T),
|
unit<T,Tag>(T),
|
||||||
@@ -21,6 +20,10 @@ namespace
|
|||||||
|
|
||||||
"value", &unit<T,Tag>::value,
|
"value", &unit<T,Tag>::value,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const unit<T,Tag>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator==),
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator<),
|
sol::meta_function::less_than, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator<),
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator<=),
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator<=),
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_vec2_t(const str& name, sol::state& l) {
|
void bind_vec2_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<vec2<T>>(name,
|
||||||
.new_usertype<vec2<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
vec2<T>(),
|
vec2<T>(),
|
||||||
vec2<T>(T),
|
vec2<T>(T),
|
||||||
@@ -30,6 +29,10 @@ namespace
|
|||||||
"x", &vec2<T>::x,
|
"x", &vec2<T>::x,
|
||||||
"y", &vec2<T>::y,
|
"y", &vec2<T>::y,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const vec2<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator==),
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator<),
|
sol::meta_function::less_than, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator<),
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator<=),
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator<=),
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_vec3_t(const str& name, sol::state& l) {
|
void bind_vec3_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<vec3<T>>(name,
|
||||||
.new_usertype<vec3<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
vec3<T>(),
|
vec3<T>(),
|
||||||
vec3<T>(T),
|
vec3<T>(T),
|
||||||
@@ -32,6 +31,10 @@ namespace
|
|||||||
"y", &vec3<T>::y,
|
"y", &vec3<T>::y,
|
||||||
"z", &vec3<T>::z,
|
"z", &vec3<T>::z,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const vec3<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator==),
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator<),
|
sol::meta_function::less_than, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator<),
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator<=),
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator<=),
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ namespace
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void bind_vec4_t(const str& name, sol::state& l) {
|
void bind_vec4_t(const str& name, sol::state& l) {
|
||||||
l["e2d"].get_or_create<sol::table>()
|
l.new_usertype<vec4<T>>(name,
|
||||||
.new_usertype<vec4<T>>(name,
|
|
||||||
sol::constructors<
|
sol::constructors<
|
||||||
vec4<T>(),
|
vec4<T>(),
|
||||||
vec4<T>(T),
|
vec4<T>(T),
|
||||||
@@ -34,6 +33,10 @@ namespace
|
|||||||
"z", &vec4<T>::z,
|
"z", &vec4<T>::z,
|
||||||
"w", &vec4<T>::w,
|
"w", &vec4<T>::w,
|
||||||
|
|
||||||
|
sol::meta_function::to_string, [](const vec4<T>& v){
|
||||||
|
return strings::rformat("%0", v);
|
||||||
|
},
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator==),
|
sol::meta_function::equal_to, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator==),
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator<),
|
sol::meta_function::less_than, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator<),
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator<=),
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator<=),
|
||||||
|
|||||||
@@ -16,12 +16,17 @@ namespace e2d
|
|||||||
luasol::luasol() {
|
luasol::luasol() {
|
||||||
state_.open_libraries(
|
state_.open_libraries(
|
||||||
sol::lib::base,
|
sol::lib::base,
|
||||||
sol::lib::package,
|
//sol::lib::package,
|
||||||
sol::lib::coroutine,
|
sol::lib::coroutine,
|
||||||
sol::lib::string,
|
sol::lib::string,
|
||||||
|
//sol::lib::os,
|
||||||
sol::lib::math,
|
sol::lib::math,
|
||||||
sol::lib::table,
|
sol::lib::table,
|
||||||
|
//sol::lib::debug,
|
||||||
|
//sol::lib::bit32
|
||||||
|
//sol::lib::io
|
||||||
sol::lib::utf8);
|
sol::lib::utf8);
|
||||||
|
|
||||||
bindings::bind_math(state_);
|
bindings::bind_math(state_);
|
||||||
bindings::bind_utils(state_);
|
bindings::bind_utils(state_);
|
||||||
bindings::bind_core(state_);
|
bindings::bind_core(state_);
|
||||||
@@ -29,6 +34,7 @@ namespace e2d
|
|||||||
}
|
}
|
||||||
|
|
||||||
void luasol::collect_garbage() {
|
void luasol::collect_garbage() {
|
||||||
|
E2D_ASSERT(is_in_main_thread());
|
||||||
state_.collect_garbage();
|
state_.collect_garbage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,18 +20,28 @@ namespace
|
|||||||
using namespace e2d;
|
using namespace e2d;
|
||||||
|
|
||||||
void init_core_table(sol::state& s) {
|
void init_core_table(sol::state& s) {
|
||||||
auto e2d_table = s["e2d"].get_or_create<sol::table>();
|
s["the_dbgui"] = &the<dbgui>();
|
||||||
e2d_table["debug"] = &the<debug>();
|
s["the_debug"] = &the<debug>();
|
||||||
e2d_table["engine"] = &the<engine>();
|
s["the_engine"] = &the<engine>();
|
||||||
e2d_table["input"] = &the<input>();
|
s["the_input"] = &the<input>();
|
||||||
e2d_table["window"] = &the<window>();
|
s["the_keyboard"] = &the<input>().keyboard();
|
||||||
|
s["the_mouse"] = &the<input>().mouse();
|
||||||
|
s["the_window"] = &the<window>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_high_table(sol::state& s) {
|
void init_high_table(sol::state& s) {
|
||||||
auto e2d_table = s["e2d"].get_or_create<sol::table>();
|
s["the_library"] = &the<library>();
|
||||||
e2d_table["library"] = &the<library>();
|
s["the_luasol"] = &the<luasol>();
|
||||||
e2d_table["luasol"] = &the<luasol>();
|
s["the_world"] = &the<world>();
|
||||||
e2d_table["world"] = &the<world>();
|
}
|
||||||
|
|
||||||
|
void init_base_functions(sol::state& s) {
|
||||||
|
s["require"] = [](const char* package){
|
||||||
|
the<debug>().error(
|
||||||
|
"LUASOL: Require function is not allowed:\n"
|
||||||
|
"--> Package: %0",
|
||||||
|
package);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_spine_player_events(ecs::registry& owner) {
|
void process_spine_player_events(ecs::registry& owner) {
|
||||||
@@ -76,6 +86,7 @@ namespace e2d
|
|||||||
the<luasol>().with_state([](sol::state& s){
|
the<luasol>().with_state([](sol::state& s){
|
||||||
init_core_table(s);
|
init_core_table(s);
|
||||||
init_high_table(s);
|
init_high_table(s);
|
||||||
|
init_base_functions(s);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
~internal_state() noexcept = default;
|
~internal_state() noexcept = default;
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
# Dbgui
|
# DBGUI
|
||||||
|
|
||||||
## Properties
|
## PROPERTIES
|
||||||
|
|
||||||
- `visible: boolean, RW`
|
- `visible: boolean` (read/write)
|
||||||
|
|
||||||
## Examples
|
## EXAMPLE
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local d = e2d.dbgui
|
if the_keyboard:is_key_just_pressed("f12") then
|
||||||
local k = e2d.input.keyboard
|
the_dbgui.visible = not the_dbgui.visible
|
||||||
|
|
||||||
local toggle_dbgui_key = e2d.keyboard_key.f12
|
|
||||||
if k:is_key_just_pressed(toggle_dbgui_key) then
|
|
||||||
d.visible = not d.visible
|
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
# Debug
|
# DEBUG
|
||||||
|
|
||||||
## Functions
|
## FUNCTIONS
|
||||||
|
|
||||||
- `trace(message: string) -> void`
|
- `trace(message: string): void`
|
||||||
- `warning(message: string) -> void`
|
- `warning(message: string): void`
|
||||||
- `error(message: string) -> void`
|
- `error(message: string): void`
|
||||||
- `fatal(message: string) -> void`
|
- `fatal(message: string): void`
|
||||||
|
|
||||||
## Examples
|
## EXAMPLE
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local d = e2d.debug
|
the_debug:trace("Hello World")
|
||||||
d:warning("Hello World")
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
# Engine
|
# ENGINE
|
||||||
|
|
||||||
## Properties
|
## PROPERTIES
|
||||||
|
|
||||||
- `time: number, RO`
|
- `time: number` (read_only)
|
||||||
- `delta_time: number, RO`
|
- `delta_time: number` (read_only)
|
||||||
- `frame_rate: number, RO`
|
- `frame_rate: number` (read_only)
|
||||||
- `frame_count: number, RO`
|
- `frame_count: number` (read_only)
|
||||||
- `realtime_time: number, RO`
|
- `realtime_time: number` (read_only)
|
||||||
|
|
||||||
## Examples
|
## EXAMPLE
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local d = e2d.debug
|
the_debug:trace("FPS: " .. the_engine.frame_rate)
|
||||||
local e = e2d.engine
|
|
||||||
d:trace("FPS: " .. e.frame_rate)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,122 +1,18 @@
|
|||||||
# Input
|
# INPUT
|
||||||
|
|
||||||
## Properties
|
## PROPERTIES
|
||||||
|
|
||||||
- `mouse: mouse, RO`
|
- `mouse: mouse` (read_only)
|
||||||
- `keyboard: keyboard, RO`
|
- `keyboard: keyboard` (read_only)
|
||||||
|
|
||||||
# Mouse
|
## EXAMPLE
|
||||||
|
|
||||||
## Enums
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
e2d.mouse_button = {
|
if the_input.mouse.is_any_button_just_pressed then
|
||||||
left, right, middle, x1, x2
|
the_debug:trace("some mouse button was pressed")
|
||||||
}
|
end
|
||||||
```
|
|
||||||
|
|
||||||
## Properties
|
if the_input.keyboard:is_key_just_pressed("space") then
|
||||||
|
the_debug:trace("`space` key was pressed")
|
||||||
- `cursor_pos: v2f, RO`
|
|
||||||
- `scroll_delta: v2f, RO`
|
|
||||||
|
|
||||||
- `is_any_button_pressed: boolean, RO`
|
|
||||||
- `is_any_button_just_pressed: boolean, RO`
|
|
||||||
- `is_any_button_just_released: boolean, RO`
|
|
||||||
|
|
||||||
- `pressed_buttons: [mouse_button], RO`
|
|
||||||
- `just_pressed_buttons: [mouse_button], RO`
|
|
||||||
- `just_released_buttons: [mouse_button], RO`
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
- `is_button_pressed(button: mouse_button) -> boolean`
|
|
||||||
- `is_button_just_pressed(button: mouse_button) -> boolean`
|
|
||||||
- `is_button_just_released(button: mouse_button) -> boolean`
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```lua
|
|
||||||
local d = e2d.debug
|
|
||||||
local m = e2d.input.mouse
|
|
||||||
|
|
||||||
d:trace("Cursor position: " .. m.cursor_pos)
|
|
||||||
|
|
||||||
local left_button = e2d.mouse_button.left
|
|
||||||
if m:is_button_just_pressed(left_button) then
|
|
||||||
d:trace("Mouse just pressed")
|
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
# Keyboard
|
|
||||||
|
|
||||||
## Enums
|
|
||||||
|
|
||||||
```lua
|
|
||||||
e2d.keyboard_key = {
|
|
||||||
_0, _1, _2, _3, _4, _5, _6, _7, _8, _9,
|
|
||||||
|
|
||||||
a, b, c, d, e, f, g, h, i, j, k, l, m,
|
|
||||||
n, o, p, q, r, s, t, u, v, w, x, y, z,
|
|
||||||
|
|
||||||
f1, f2, f3, f4, f5,
|
|
||||||
f6, f7, f8, f9, f10,
|
|
||||||
f11, f12, f13, f14, f15,
|
|
||||||
f16, f17, f18, f19, f20,
|
|
||||||
f21, f22, f23, f24, f25,
|
|
||||||
|
|
||||||
minus, equal, backspace, section_sign, grave_accent,
|
|
||||||
|
|
||||||
lbracket, rbracket, semicolon, apostrophe, backslash,
|
|
||||||
|
|
||||||
comma, period, slash,
|
|
||||||
|
|
||||||
escape, tab, caps_lock, space, enter,
|
|
||||||
|
|
||||||
lshift, rshift, lcontrol, rcontrol,
|
|
||||||
lalt, ralt, lsuper, rsuper, menu,
|
|
||||||
|
|
||||||
print_screen, scroll_lock, pause,
|
|
||||||
|
|
||||||
insert, del, home, end, page_up, page_down,
|
|
||||||
|
|
||||||
left, up, right, down,
|
|
||||||
|
|
||||||
kp_0, kp_1, kp_2, kp_3, kp_4,
|
|
||||||
kp_5, kp_6, kp_7, kp_8, kp_9,
|
|
||||||
|
|
||||||
kp_num_lock, kp_divide, kp_multiply, kp_subtract,
|
|
||||||
kp_add, kp_enter, kp_equal, kp_decimal
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
- `input_text: string, RO`
|
|
||||||
|
|
||||||
- `is_any_key_pressed: boolean, RO`
|
|
||||||
- `is_any_key_just_pressed: boolean, RO`
|
|
||||||
- `is_any_key_just_released: boolean, RO`
|
|
||||||
|
|
||||||
- `pressed_keys: [keyboard_key], RO`
|
|
||||||
- `just_pressed_keys: [keyboard_key], RO`
|
|
||||||
- `just_released_keys: [keyboard_key], RO`
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
- `is_key_pressed(key: keyboard_key) -> boolean`
|
|
||||||
- `is_key_just_pressed(key: keyboard_key) -> boolean`
|
|
||||||
- `is_key_just_released(key: keyboard_key) -> boolean`
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```lua
|
|
||||||
local d = e2d.debug
|
|
||||||
local k = e2d.input.keyboard
|
|
||||||
|
|
||||||
local forward_key = e2d.keyboard_key.w
|
|
||||||
if k:is_key_pressed(forward_key) then
|
|
||||||
d:trace("Move forward")
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|||||||
25
support/modules/keyboard.md
Normal file
25
support/modules/keyboard.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# KEYBOARD
|
||||||
|
|
||||||
|
## FUNCTIONS
|
||||||
|
|
||||||
|
- `is_key_pressed(key: string): boolean`
|
||||||
|
- `is_key_just_pressed(key: string): boolean`
|
||||||
|
- `is_key_just_released(key: string): boolean`
|
||||||
|
|
||||||
|
## PROPERTIES
|
||||||
|
|
||||||
|
- `input_text: string` (read_only)
|
||||||
|
- `is_any_key_pressed: boolean` (read_only)
|
||||||
|
- `is_any_key_just_pressed: boolean` (read_only)
|
||||||
|
- `is_any_key_just_released: boolean` (read_only)
|
||||||
|
- `pressed_keys: [string]` (read_only)
|
||||||
|
- `just_pressed_keys: [string]` (read_only)
|
||||||
|
- `just_released_keys: [string]` (read_only)
|
||||||
|
|
||||||
|
## EXAMPLE
|
||||||
|
|
||||||
|
```lua
|
||||||
|
if the_keyboard:is_key_pressed("w") then
|
||||||
|
the_debug:trace("move forward")
|
||||||
|
end
|
||||||
|
```
|
||||||
@@ -1 +1 @@
|
|||||||
# Library
|
# LIBRARY
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
# Luasol
|
# LUASOL
|
||||||
|
|||||||
28
support/modules/mouse.md
Normal file
28
support/modules/mouse.md
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# MOUSE
|
||||||
|
|
||||||
|
## FUNCTIONS
|
||||||
|
|
||||||
|
- `is_button_pressed(button: string): boolean`
|
||||||
|
- `is_button_just_pressed(button: string): boolean`
|
||||||
|
- `is_button_just_released(button: string): boolean`
|
||||||
|
|
||||||
|
## PROPERTIES
|
||||||
|
|
||||||
|
- `cursor_pos: v2f` (read_only)
|
||||||
|
- `scroll_delta: v2f` (read_only)
|
||||||
|
- `is_any_button_pressed: boolean` (read_only)
|
||||||
|
- `is_any_button_just_pressed: boolean` (read_only)
|
||||||
|
- `is_any_button_just_released: boolean` (read_only)
|
||||||
|
- `pressed_buttons: [string]` (read_only)
|
||||||
|
- `just_pressed_buttons: [string]` (read_only)
|
||||||
|
- `just_released_buttons: [string]` (read_only)
|
||||||
|
|
||||||
|
## EXAMPLE
|
||||||
|
|
||||||
|
```lua
|
||||||
|
the_debug:trace("cursor position: " .. tostring(the_mouse.cursor_pos))
|
||||||
|
|
||||||
|
if the_mouse:is_button_just_pressed("left") then
|
||||||
|
the_debug:trace("mouse button was pressed")
|
||||||
|
end
|
||||||
|
```
|
||||||
@@ -1,46 +1,42 @@
|
|||||||
# Window
|
# WINDOW
|
||||||
|
|
||||||
## Properties
|
## FUNCTIONS
|
||||||
|
|
||||||
- `enabled: boolean, RO`
|
- `hide(): void`
|
||||||
- `visible: boolean, RO`
|
- `show(): void`
|
||||||
- `focused: boolean, RO`
|
- `restore(): void`
|
||||||
- `minimized: boolean, RO`
|
- `minimize(): void`
|
||||||
|
|
||||||
- `fullscreen: boolean, RW`
|
## PROPERTIES
|
||||||
- `cursor_hidden: boolean, RW`
|
|
||||||
|
|
||||||
- `real_size: v2f, RO`
|
- `enabled: boolean` (read_only)
|
||||||
- `virtual_size: v2f, RO`
|
- `visible: boolean` (read_only)
|
||||||
- `framebuffer_size: v2f, RO`
|
- `focused: boolean` (read_only)
|
||||||
|
- `minimized: boolean` (read_only)
|
||||||
|
|
||||||
- `title: string, RW`
|
- `fullscreen: boolean` (read/write)
|
||||||
- `should_close: boolean, RW`
|
- `cursor_hidden: boolean` (read/write)
|
||||||
|
|
||||||
## Functions
|
- `real_size: v2f` (read_only)
|
||||||
|
- `virtual_size: v2f` (read_only)
|
||||||
|
- `framebuffer_size: v2f` (read_only)
|
||||||
|
|
||||||
- `hide() -> void`
|
- `title: string` (read/write)
|
||||||
- `show() -> void`
|
- `should_close: boolean` (read/write)
|
||||||
- `restore() -> void`
|
|
||||||
- `minimize() -> void`
|
|
||||||
|
|
||||||
## Example
|
## EXAMPLE
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local w = e2d.window
|
|
||||||
local k = e2d.input.keyboard
|
|
||||||
|
|
||||||
local close_window =
|
local close_window =
|
||||||
k:is_key_just_pressed(e2d.keyboard_key.f32)
|
the_keyboard:is_key_just_pressed("f12")
|
||||||
|
|
||||||
local toggle_fullscreen =
|
local toggle_fullscreen =
|
||||||
k:is_key_pressed(e2d.keyboard_key.lsuper) and
|
the_keyboard:is_key_pressed("lsuper") and
|
||||||
k:is_key_just_released(e2d.keyboard_key.enter)
|
the_keyboard:is_key_just_released("enter")
|
||||||
|
|
||||||
if close_window then
|
if close_window then
|
||||||
w.should_close = true
|
the_window.should_close = true
|
||||||
elseif toggle_fullscreen then
|
elseif toggle_fullscreen then
|
||||||
w.fullscreen = not w.fullscreen
|
the_window.fullscreen = not the_window.fullscreen
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
# World
|
# WORLD
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user