Agora ele olha pra frente deitado
[Projeto-PCG.git] / configmanager.cpp
blob31688ed1a6895ab37863a7b90ce1c4900b291f79
1 #include "configmanager.h"
2 #include "luaenv.h"
4 static std::map<std::string, int> *scr = NULL;
5 static std::map<std::string, Ponto> *play = NULL;
6 static std::list<std::string> *m = NULL;
8 static int regscreen(lua_State *L) {
9 const char *name = lua_tostring(L, 1);
10 double value = lua_tonumber(L, 2);
11 (*scr)[name] = (int) value;
12 return 0;
15 static int regplayer(lua_State *L) {
16 const char *name = lua_tostring(L, 1);
17 double x = lua_tonumber(L, 2);
18 double y = lua_tonumber(L, 3);
19 (*play)[name] = Ponto(x, y);
20 return 0;
23 static int regmap(lua_State *L) {
24 m->push_back(lua_tostring(L, 1));
25 return 0;
28 ConfigManager::ConfigManager() {
29 lstate = NULL;
32 std::string ConfigManager::previousMap() {
33 return map != maps.begin() ? *(--map) : *map;
36 std::string ConfigManager::currentMap() {
37 return *map;
40 std::string ConfigManager::nextMap() {
41 return map != --(maps.end()) ? *(++map) : *map;
44 void ConfigManager::load() {
45 if (lstate != NULL)
46 lua_close(lstate);
47 screen.clear();
48 player.clear();
49 maps.clear();
50 scr = &screen;
51 play = &player;
52 m = &maps;
53 lstate = newState();
54 registerFunction(lstate, "regscreen", regscreen);
55 registerFunction(lstate, "regplayer", regplayer);
56 registerFunction(lstate, "regmap", regmap);
57 doLuaFile(lstate,"configmanager.lua");
58 doLuaFile(lstate,"config.lua");
59 map = maps.begin();