-
-
Notifications
You must be signed in to change notification settings - Fork 994
/
game_lua_kernel.hpp
161 lines (137 loc) · 5.19 KB
/
game_lua_kernel.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
Copyright (C) 2009 - 2014 by Guillaume Melquiond <guillaume.melquiond@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef SCRIPTING_LUA_HPP
#define SCRIPTING_LUA_HPP
#include "scripting/lua_kernel_base.hpp" // for lua_kernel_base
#include "game_events/action_wml.hpp" // for wml_action, etc
#include <stack>
#include <string> // for string
class config;
class CVideo;
class unit;
class vconfig;
namespace ai { class engine_lua; }
namespace ai { class lua_ai_action_handler; }
namespace ai { class lua_ai_context; }
namespace game_events { struct queued_event; }
class game_display;
class game_state;
class game_board;
class unit_map;
class gamemap;
class team;
class game_data;
class tod_manager;
class play_controller;
class reports;
typedef int (*lua_CFunction) (lua_State *L);
class game_lua_kernel : public lua_kernel_base
{
game_display * game_display_;
game_state & game_state_;
play_controller & play_controller_;
reports & reports_;
// Private functions to ease access to parts of game_state
game_board & board();
unit_map & units();
const gamemap & map();
std::vector<team> & teams();
game_data & gamedata();
tod_manager & tod_man();
const config &level_;
std::stack<game_events::queued_event const * > queued_events_;
static void extract_preload_scripts(config const & game_config);
static std::vector<config> preload_scripts;
static config preload_config;
friend class game_config_manager; // to allow it to call extract_preload_scripts
// Private lua callbacks
int intf_allow_end_turn(lua_State *);
int intf_allow_undo(lua_State *);
int intf_add_time_area(lua_State *);
int intf_remove_time_area(lua_State *);
int intf_get_unit(lua_State *);
int intf_get_units(lua_State *);
int intf_get_displayed_unit(lua_State*);
int intf_match_unit(lua_State *L);
int intf_get_recall_units(lua_State *L);
int intf_get_variable(lua_State *L);
int intf_set_variable(lua_State *L);
int intf_highlight_hex(lua_State *L);
int intf_is_enemy(lua_State *L);
int intf_view_locked(lua_State *L);
int intf_lock_view(lua_State *L);
int intf_get_terrain(lua_State *L);
int intf_set_terrain(lua_State *L);
int intf_get_terrain_info(lua_State *L);
int intf_get_time_of_day(lua_State *L);
int intf_get_village_owner(lua_State *L);
int intf_set_village_owner(lua_State *L);
int intf_get_map_size(lua_State *L);
int intf_get_mouseover_tile(lua_State *L);
int intf_get_selected_tile(lua_State *L);
int intf_get_starting_location(lua_State* L);
int impl_game_config_get(lua_State *L);
int impl_game_config_set(lua_State *L);
int impl_current_get(lua_State *L);
int intf_clear_messages(lua_State*);
int intf_find_path(lua_State *L);
int intf_find_reach(lua_State *L);
int intf_find_cost_map(lua_State *L);
int intf_message(lua_State *L);
int intf_play_sound(lua_State *L);
int intf_put_unit(lua_State *L);
int intf_put_recall_unit(lua_State *L);
int intf_extract_unit(lua_State *L);
int intf_find_vacant_tile(lua_State *L);
int intf_float_label(lua_State *L);
int intf_clear_menu_item(lua_State *L);
int intf_set_menu_item(lua_State *L);
int intf_shroud_op(lua_State *L, bool place_shroud);
int intf_simulate_combat(lua_State *L);
int intf_scroll_to_tile(lua_State *L);
int intf_select_hex(lua_State *L);
int intf_synchronize_choice(lua_State *L);
int intf_get_locations(lua_State *L);
int intf_get_villages(lua_State *L);
int intf_match_location(lua_State *L);
int intf_match_side(lua_State *L);
int intf_get_sides(lua_State* L);
int intf_add_tile_overlay(lua_State *L);
int intf_remove_tile_overlay(lua_State *L);
int intf_delay(lua_State *L);
int intf_get_all_vars(lua_State *L);
int impl_theme_item(lua_State *L, std::string name);
int impl_theme_items_get(lua_State *L);
int impl_theme_items_set(lua_State *L);
int cfun_wml_action(lua_State *L);
int intf_fire_event(lua_State *L);
//private helpers
std::string synced_state();
void lua_chat(std::string const &caption, std::string const &msg);
std::vector<int> get_sides_vector(const vconfig& cfg);
public:
game_lua_kernel(const config &, CVideo *, game_state &, play_controller &, reports &);
void set_game_display(game_display * gd);
virtual std::string my_name() { return "Game Lua Kernel"; }
void initialize();
void save_game(config &);
void load_game();
bool run_event(game_events::queued_event const &);
void set_wml_action(std::string const &, game_events::wml_action::handler);
bool run_wml_action(std::string const &, vconfig const &,
game_events::queued_event const &);
bool run_filter(char const *name, unit const &u);
virtual void log_error(char const* msg, char const* context = "Lua error");
ai::lua_ai_context* create_lua_ai_context(char const *code, ai::engine_lua *engine);
ai::lua_ai_action_handler* create_lua_ai_action_handler(char const *code, ai::lua_ai_context &context);
};
#endif