quantumde1 преди 6 часа
родител
ревизия
1b8fb918ab
променени са 5 файла, в които са добавени 14 реда и са изтрити 14 реда
  1. 1 1
      conf/settings.conf
  2. 1 0
      source/graphics/engine.d
  3. 10 11
      source/scripts/lua.d
  4. 1 1
      source/system/config.d
  5. 1 1
      source/variables.d

+ 1 - 1
conf/settings.conf

@@ -5,5 +5,5 @@ LEFT:A
 RIGHT:D
 DIALOG:K
 OPMENU:M
-SCRIPT:scripts/SA02.lua
+SCRIPT:scripts/SA00.lua
 FULLSCREEN:0

+ 1 - 0
source/graphics/engine.d

@@ -76,6 +76,7 @@ void engine_loader()
             {
                 SetExitKey(0);
                 if (luaReload) {
+                    resetAllScriptValues();
                     int luaExecutionCode = luaInit(luaExec);
                     if (luaExecutionCode != EngineExitCodes.EXIT_OK) {
                         writeln("[ERROR] Engine stops execution according to error code: ", 

+ 10 - 11
source/scripts/lua.d

@@ -402,7 +402,12 @@ extern (C) nothrow int luaL_2dModeDisable(lua_State* L)
     return 0;
 }
 
-extern (C) nothrow int luaL_setGameFont(lua_State* L)
+extern (C) nothrow int luaL_unloadFont(lua_State *L) {
+    UnloadFont(textFont);
+    return 0;
+}
+
+extern (C) nothrow int luaL_loadFont(lua_State* L)
 {
     const char* x = luaL_checkstring(L, 1);
     debugWriteln("Setting custom font: ", x.to!string);
@@ -503,18 +508,9 @@ extern (C) nothrow int luaL_isMouseButtonPressed(lua_State* L)
 
 extern (C) nothrow int luaL_loadScript(lua_State* L)
 {
-    for (int i = cast(int)characterTextures.length; i < characterTextures.length; i++)
-    {
-        UnloadTexture(characterTextures[i].texture);
-    }
-    for (int i = cast(int)backgroundTextures.length; i < backgroundTextures.length; i++)
-    {
-        UnloadTexture(backgroundTextures[i].texture);
-    }
     try
     {
         luaExec = luaL_checkstring(L, 1).to!string;
-        resetAllScriptValues();
     }
     catch (Exception e)
     {
@@ -706,7 +702,8 @@ extern (C) nothrow void luaL_loader(lua_State* L)
     lua_register(L, "getTime", &luaL_getTime);
     lua_register(L, "getDeltaTime", &luaL_getDeltaTime);
     lua_register(L, "loadScript", &luaL_loadScript);
-    lua_register(L, "setFont", &luaL_setGameFont);
+    lua_register(L, "loadFont", &luaL_loadFont);
+    lua_register(L, "unloadFont", &luaL_unloadFont);
     lua_register(L, "getScreenHeight", &luaL_getScreenHeight);
     lua_register(L, "getScreenWidth", &luaL_getScreenWidth);
     lua_register(L, "isKeyPressed", &luaL_isKeyPressed);
@@ -723,6 +720,8 @@ extern (C) nothrow void luaL_loader(lua_State* L)
     lua_register(L, "measureTextY", &luaL_measureTextY);
     lua_register(L, "getTextureWidth", &luaL_getTextureWidth);
     lua_register(L, "getTextureHeight", &luaL_getTextureHeight);
+    //compat
+    lua_register(L, "setFont", &luaL_loadFont);
 
     debugWriteln("strict mode enabled");
     const char* strict_lua =

+ 1 - 1
source/system/config.d

@@ -15,7 +15,7 @@ nothrow auto parseConf(string type)(string filename)
         auto file = File(filename);
         auto config = file.byLineCopy();
         
-        auto typeMap = [
+        static immutable typeMap = [
             "sound": "SOUND:",
             "backward": "BACKWARD:",
             "forward": "FORWARD:",

+ 1 - 1
source/variables.d

@@ -8,7 +8,7 @@ import system.abstraction;
 
 extern (C) char* get_file_data_from_archive(const char *input_file, const char *file_name, uint *file_size_out);
 
-void resetAllScriptValues() {
+nothrow void resetAllScriptValues() {
     debugWriteln("Resetting all values!");
     selectedChoice = 0;
     foreach (i; 0..characterTextures.length)