format: reformat project
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
#include "api_lua.hpp"
|
||||
|
||||
#include "../../../window/input.hpp"
|
||||
#include "../../../window/Events.hpp"
|
||||
#include "../../../util/stringutil.hpp"
|
||||
#include "../../../graphics/ui/GUI.hpp"
|
||||
#include "../../../frontend/screens/Screen.hpp"
|
||||
#include "../../../frontend/hud.hpp"
|
||||
#include "../../../engine.hpp"
|
||||
#include "../../../frontend/hud.hpp"
|
||||
#include "../../../frontend/screens/Screen.hpp"
|
||||
#include "../../../graphics/ui/GUI.hpp"
|
||||
#include "../../../util/stringutil.hpp"
|
||||
#include "../../../window/Events.hpp"
|
||||
#include "../../../window/input.hpp"
|
||||
#include "api_lua.hpp"
|
||||
|
||||
namespace scripting {
|
||||
extern Hud* hud;
|
||||
@@ -15,19 +14,23 @@ using namespace scripting;
|
||||
|
||||
static int l_keycode(lua::State* L) {
|
||||
auto name = lua::require_string(L, 1);
|
||||
return lua::pushinteger(L, static_cast<int>(input_util::keycode_from(name)));
|
||||
return lua::pushinteger(
|
||||
L, static_cast<int>(input_util::keycode_from(name))
|
||||
);
|
||||
}
|
||||
|
||||
static int l_mousecode(lua::State* L) {
|
||||
auto name = lua::require_string(L, 1);
|
||||
return lua::pushinteger(L, static_cast<int>(input_util::mousecode_from(name)));
|
||||
return lua::pushinteger(
|
||||
L, static_cast<int>(input_util::mousecode_from(name))
|
||||
);
|
||||
}
|
||||
|
||||
static int l_add_callback(lua::State* L) {
|
||||
auto bindname = lua::require_string(L, 1);
|
||||
const auto& bind = Events::bindings.find(bindname);
|
||||
if (bind == Events::bindings.end()) {
|
||||
throw std::runtime_error("unknown binding "+util::quote(bindname));
|
||||
throw std::runtime_error("unknown binding " + util::quote(bindname));
|
||||
}
|
||||
lua::pushvalue(L, 2);
|
||||
runnable actual_callback = lua::create_runnable(L);
|
||||
@@ -65,7 +68,7 @@ static int l_is_active(lua::State* L) {
|
||||
auto bindname = lua::require_string(L, 1);
|
||||
const auto& bind = Events::bindings.find(bindname);
|
||||
if (bind == Events::bindings.end()) {
|
||||
throw std::runtime_error("unknown binding "+util::quote(bindname));
|
||||
throw std::runtime_error("unknown binding " + util::quote(bindname));
|
||||
}
|
||||
return lua::pushboolean(L, bind->second.active());
|
||||
}
|
||||
@@ -77,17 +80,22 @@ static int l_is_pressed(lua::State* L) {
|
||||
throw std::runtime_error("expected 'input_type:key' format");
|
||||
}
|
||||
auto prefix = code.substr(0, sep);
|
||||
auto name = code.substr(sep+1);
|
||||
auto name = code.substr(sep + 1);
|
||||
if (prefix == "key") {
|
||||
return lua::pushboolean(L, Events::pressed(static_cast<int>(input_util::keycode_from(name))));
|
||||
return lua::pushboolean(
|
||||
L, Events::pressed(static_cast<int>(input_util::keycode_from(name)))
|
||||
);
|
||||
} else if (prefix == "mouse") {
|
||||
return lua::pushboolean(L, Events::clicked(static_cast<int>(input_util::mousecode_from(name))));
|
||||
return lua::pushboolean(
|
||||
L,
|
||||
Events::clicked(static_cast<int>(input_util::mousecode_from(name)))
|
||||
);
|
||||
} else {
|
||||
throw std::runtime_error("unknown input type "+util::quote(code));
|
||||
throw std::runtime_error("unknown input type " + util::quote(code));
|
||||
}
|
||||
}
|
||||
|
||||
const luaL_Reg inputlib [] = {
|
||||
const luaL_Reg inputlib[] = {
|
||||
{"keycode", lua::wrap<l_keycode>},
|
||||
{"mousecode", lua::wrap<l_mousecode>},
|
||||
{"add_callback", lua::wrap<l_add_callback>},
|
||||
@@ -95,6 +103,4 @@ const luaL_Reg inputlib [] = {
|
||||
{"get_bindings", lua::wrap<l_get_bindings>},
|
||||
{"is_active", lua::wrap<l_is_active>},
|
||||
{"is_pressed", lua::wrap<l_is_pressed>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
{NULL, NULL}};
|
||||
|
||||
Reference in New Issue
Block a user