Ajuste leve na velocidade permitindo movimentos mais sutis
[Projeto-PCG.git] / configmanager.cpp
blob01a47793f53bd7b56265c089e394816e24642c5a
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 regplayerhp(lua_State *L) {
24 const char *name = lua_tostring(L, 1);
25 double x = lua_tonumber(L, 2);
26 (*scr)[name] = x;
27 return 0;
30 static int regmap(lua_State *L) {
31 m->push_back(lua_tostring(L, 1));
32 return 0;
35 ConfigManager::ConfigManager() {
36 lstate = NULL;
39 std::string ConfigManager::previousMap() {
40 return map != maps.begin() ? *(--map) : *map;
43 std::string ConfigManager::currentMap() {
44 return *map;
47 std::string ConfigManager::nextMap() {
48 return map != --(maps.end()) ? *(++map) : *map;
51 void ConfigManager::load() {
52 if (lstate != NULL)
53 lua_close(lstate);
54 integer.clear();
55 ponto.clear();
56 maps.clear();
57 scr = &integer;
58 play = &ponto;
59 m = &maps;
60 lstate = newState();
61 registerFunction(lstate, "regscreen", regscreen);
62 registerFunction(lstate, "regplayer", regplayer);
63 registerFunction(lstate, "regplayerhp", regplayerhp);
64 registerFunction(lstate, "regmap", regmap);
65 doLuaFile(lstate,"configmanager.lua");
66 doLuaFile(lstate,"config.lua");
67 map = maps.begin();