Kaynağa Gözat

changed config

quantumde1 2 ay önce
ebeveyn
işleme
4151b803df

+ 2 - 8
conf/settings.conf

@@ -1,9 +1,3 @@
-SOUND:0
-FORWARD:W
-BACKWARD:S
-LEFT:A
-RIGHT:D
-DIALOG:K
-OPMENU:M
 SCRIPT:scripts/SA00.lua
-FULLSCREEN:0
+TITLE:Remember11 - Self Chapter
+ICON:res/icon.png

+ 3 - 2
source/graphics/engine.d

@@ -41,9 +41,10 @@ void engine_loader()
     int screenHeight = 1008;
     // Initialization
     SetExitKey(0);
-    Image icon = LoadImage("res/icon.png");
+    systemSettings = loadSettingsFromConfigFile();
+    Image icon = LoadImage(systemSettings.iconPath.toStringz());
     // Window and Audio Initialization
-    InitWindow(screenWidth, screenHeight, "Remember11 - Self Chapter");
+    InitWindow(screenWidth, screenHeight, systemSettings.windowTitle.toStringz());
     SetWindowIcon(icon);
     UnloadImage(icon);
     //ToggleFullscreen();

+ 1 - 2
source/graphics/gamelogic.d

@@ -30,8 +30,7 @@ void gameInit()
         currentGameState = GameState.Exit;
     } else {
         debugWriteln("Game initializing.");
-        systemSettings = loadSettingsFromConfigFile();
-        luaExec = systemSettings.script_path;
+        luaExec = systemSettings.scriptPath;
     }
 }
 

+ 17 - 17
source/scripts/lua.d

@@ -72,7 +72,7 @@ extern (C) nothrow int luaL_isDialogExecuted(lua_State *L) {
 
 /* background drawing and loading */
 
-extern (C) nothrow int luaL_load2Dbackground(lua_State* L)
+extern (C) nothrow int luaL_loadBackground(lua_State* L)
 {
     try
     {
@@ -94,14 +94,14 @@ extern (C) nothrow int luaL_load2Dbackground(lua_State* L)
     return 0;
 }
 
-extern (C) nothrow int luaL_draw2Dbackground(lua_State* L)
+extern (C) nothrow int luaL_drawBackground(lua_State* L)
 {
     try
     {
         int count = cast(int)luaL_checkinteger(L, 4);
         debugWriteln(backgroundTextures[count]);
         backgroundTextures[count].height = backgroundTextures[count].texture.height;
-        if (backgroundTextures.length < backgroundTextures.length) {
+        if (backgroundTextures.length < count) {
             backgroundTextures.length = backgroundTextures.length;
         }
         backgroundTextures[count].width = backgroundTextures[count].texture.width;
@@ -118,7 +118,7 @@ extern (C) nothrow int luaL_draw2Dbackground(lua_State* L)
     return 0;
 }
 
-extern (C) nothrow int luaL_stopDraw2Dbackground(lua_State* L)
+extern (C) nothrow int luaL_stopDrawBackground(lua_State* L)
 {
     try
     {
@@ -136,7 +136,7 @@ extern (C) nothrow int luaL_stopDraw2Dbackground(lua_State* L)
     return 0;
 }
 
-extern (C) nothrow int luaL_unload2Dbackground(lua_State* L)
+extern (C) nothrow int luaL_unloadBackground(lua_State* L)
 {
     int count = cast(int)luaL_checkinteger(L, 1);
     if (count >= backgroundTextures.length) {
@@ -150,7 +150,7 @@ extern (C) nothrow int luaL_unload2Dbackground(lua_State* L)
 
 /* character textures */
 
-extern (C) nothrow int luaL_load2Dcharacter(lua_State *L) {
+extern (C) nothrow int luaL_loadCharacter(lua_State *L) {
     try
     {
         
@@ -177,7 +177,7 @@ extern (C) nothrow int luaL_load2Dcharacter(lua_State *L) {
     return 0;
 }
 
-extern (C) nothrow int luaL_draw2Dcharacter(lua_State* L)
+extern (C) nothrow int luaL_drawCharacter(lua_State* L)
 {
     try {
         //configuring needed parameters in characterTextures like coordinates, scale and drawTexture(its a boolean value which checks need this texture to be drawn or not)
@@ -217,7 +217,7 @@ extern (C) nothrow int luaL_draw2Dcharacter(lua_State* L)
     return 0;
 }
 
-extern (C) nothrow int luaL_stopDraw2Dcharacter(lua_State* L)
+extern (C) nothrow int luaL_stopDrawCharacter(lua_State* L)
 {
     int count = cast(int) luaL_checkinteger(L, 1);
     if (count >= characterTextures.length) {
@@ -228,7 +228,7 @@ extern (C) nothrow int luaL_stopDraw2Dcharacter(lua_State* L)
     return 0;
 }
 
-extern (C) nothrow int luaL_unload2Dcharacter(lua_State *L) {
+extern (C) nothrow int luaL_unloadCharacter(lua_State *L) {
     int count = cast(int) luaL_checkinteger(L, 1);
     if (count >= characterTextures.length) {
         debugWriteln("error unloading not loaded character");
@@ -677,14 +677,14 @@ extern (C) nothrow void luaL_loader(lua_State* L)
     lua_register(L, "unloadMusic", &luaL_unloadMusic);
     lua_register(L, "playSfx", &luaL_playSfx);
     lua_register(L, "stopSfx", &luaL_stopSfx);
-    lua_register(L, "loadCharacter", &luaL_load2Dcharacter);
-    lua_register(L, "drawCharacter", &luaL_draw2Dcharacter);
-    lua_register(L, "stopDrawCharacter", &luaL_stopDraw2Dcharacter);
-    lua_register(L, "unloadCharacter", &luaL_unload2Dcharacter);
-    lua_register(L, "loadBackground", &luaL_load2Dbackground);
-    lua_register(L, "drawBackground", &luaL_draw2Dbackground);
-    lua_register(L, "stopDrawBackground", &luaL_stopDraw2Dbackground);
-    lua_register(L, "unloadBackground", &luaL_unload2Dbackground);
+    lua_register(L, "loadCharacter", &luaL_loadCharacter);
+    lua_register(L, "drawCharacter", &luaL_drawCharacter);
+    lua_register(L, "stopDrawCharacter", &luaL_stopDrawCharacter);
+    lua_register(L, "unloadCharacter", &luaL_unloadCharacter);
+    lua_register(L, "loadBackground", &luaL_loadBackground);
+    lua_register(L, "drawBackground", &luaL_drawBackground);
+    lua_register(L, "stopDrawBackground", &luaL_stopDrawBackground);
+    lua_register(L, "unloadBackground", &luaL_unloadBackground);
     lua_register(L, "loadScript", &luaL_loadScript);
     lua_register(L, "getScreenHeight", &luaL_getScreenHeight);
     lua_register(L, "getScreenWidth", &luaL_getScreenWidth);

+ 8 - 32
source/system/config.d

@@ -16,14 +16,9 @@ nothrow auto parseConf(string type)(string filename)
         auto config = file.byLineCopy();
         
         static immutable typeMap = [
-            "sound": "SOUND:",
-            "backward": "BACKWARD:",
-            "forward": "FORWARD:",
-            "right": "RIGHT:",
-            "left": "LEFT:",
-            "dialog": "DIALOG:",
-            "opmenu": "OPMENU:",
-            "script": "SCRIPT:"
+            "script": "SCRIPT:",
+            "title": "TITLE:",
+            "icon": "ICON:"
         ];
 
         if (type in typeMap)
@@ -36,14 +31,7 @@ nothrow auto parseConf(string type)(string filename)
                 {
                     auto value = trimmedLine[prefix.length .. $].strip();
                     debug debugWriteln("Value for ", type, ": ", value);
-                    
-                    static if (type == "sound") {
-                        return value.to!int();
-                    } else static if (type == "script") {
-                        return value;
-                    } else {
-                        return value.front.to!char();
-                    }
+                    return value;
                 }
             }
         }
@@ -52,26 +40,14 @@ nothrow auto parseConf(string type)(string filename)
     {
         debugWriteln(e.msg);
     }
-    
-    static if (type == "sound") {
-        return 0;
-    } else static if (type == "script") {
-        return "";
-    } else {
-        return 'E';
-    }
+    return "";
 }
 
 SystemSettings loadSettingsFromConfigFile()
 {
     return SystemSettings(
-        parseConf!"sound"("conf/settings.conf"),      // int
-        parseConf!"right"("conf/settings.conf"),     // char
-        parseConf!"left"("conf/settings.conf"),       // char
-        parseConf!"backward"("conf/settings.conf"),   // char
-        parseConf!"forward"("conf/settings.conf"),    // char
-        parseConf!"dialog"("conf/settings.conf"),     // char
-        parseConf!"opmenu"("conf/settings.conf"),     // char
-        parseConf!"script"("conf/settings.conf")     // string
+        parseConf!"script"("conf/settings.conf"),
+        parseConf!"title"("conf/settings.conf"),
+        parseConf!"icon"("conf/settings.conf")
     );
 }

+ 3 - 8
source/variables.d

@@ -26,14 +26,9 @@ nothrow void resetAllScriptValues() {
 /* system */
 
 struct SystemSettings {
-    int sound_state;
-    char right_button;
-    char left_button;
-    char back_button;
-    char forward_button;
-    char dialog_button;
-    char opmenu_button;
-    string script_path;
+    string scriptPath;
+    string windowTitle;
+    string iconPath;
 }
 
 struct TextureEngine {