Symphony Of Empires
luavm.hpp
Go to the documentation of this file.
1 // Eng3D - General purpouse game engine
2 // Copyright (C) 2021, Eng3D contributors
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <https://www.gnu.org/licenses/>.
16 //
17 // ----------------------------------------------------------------------------
18 // Name:
19 // luavm.hpp
20 //
21 // Abstract:
22 // Does some important stuff.
23 // ----------------------------------------------------------------------------
24 
25 #pragma once
26 
27 #include <string>
28 
29 struct lua_State;
30 namespace Eng3D {
31  class LuaException : public std::exception {
32  std::string buffer;
33  public:
34  LuaException(const std::string& message) {
35  buffer = message;
36  }
37  virtual const char* what() const noexcept {
38  return buffer.c_str();
39  }
40  };
41 
42  struct LuaVM {
43  LuaVM();
44  ~LuaVM();
45 
46  static int call_func(lua_State* L, int nargs, int nret);
47  int call_func(int nargs, int nret);
48  void invoke_registered_callback(const std::string& name);
49  lua_State* state = nullptr;
50  private:
51  static int ui_new_button(lua_State* L);
52  static int ui_new_image(lua_State* L);
53  static int ui_new_group(lua_State* L);
54  static int ui_new_div(lua_State* L);
55  static int ui_new_window(lua_State* L);
56  static int ui_new_checkbox(lua_State* L);
57  static int ui_set_checkbox_value(lua_State* L);
58  static int ui_get_checkbox_value(lua_State* L);
59  static int ui_new_slider(lua_State* L);
60  static int ui_get_slider_value(lua_State* L);
61  static int ui_set_slider_value(lua_State* L);
62  static int ui_new_label(lua_State* L);
63  static int ui_set_text(lua_State* L);
64  static int ui_get_image(lua_State* L);
65  static int ui_set_image(lua_State* L);
66  static int ui_set_scroll(lua_State* L);
67  static int ui_set_on_click(lua_State* L);
68  static int ui_set_window_on_click_close_btn(lua_State* L);
69  static int ui_get_widget(lua_State* L);
70  static int ui_widget_kill(lua_State* L);
71  static int ui_widget_set_tooltip(lua_State* L);
72  static int ui_register_callback(lua_State* L);
73  static int ui_widget_set_flex(lua_State* L);
74  };
75 }
virtual const char * what() const noexcept
Definition: luavm.hpp:37
LuaException(const std::string &message)
Definition: luavm.hpp:34
#define L
Definition: stb_vorbis.c:5131
void invoke_registered_callback(const std::string &name)
Some UI functions are hardcoded, for example the main menu is hardcoded to appear when the game start...
Definition: luavm.cpp:376
static int call_func(lua_State *L, int nargs, int nret)
Definition: luavm.cpp:344
lua_State * state
Definition: luavm.hpp:49