Browse Source

more optimizations for the sake of god!

quantumde1 2 tháng trước cách đây
mục cha
commit
a9ad6d564f
5 tập tin đã thay đổi với 14 bổ sung38 xóa
  1. BIN
      raylib.lib
  2. 5 12
      source/graphics/effects.d
  3. 3 4
      source/graphics/engine.d
  4. 6 6
      source/scripts/lua.d
  5. 0 16
      source/variables.d

BIN
raylib.lib


+ 5 - 12
source/graphics/effects.d

@@ -8,11 +8,12 @@ import system.abstraction;
 import system.config;
 import std.algorithm;
 import system.abstraction;
+import std.file;
 
 int screenWidth;
 int screenHeight;
 
-Texture2D[] loadAnimationFramesUI(const string archivePath, const string animationName)
+Texture2D[] loadAnimationFramesUI(const string fileDir, const string animationFileName)
 {
     screenWidth = GetScreenWidth();
     screenHeight = GetScreenHeight();
@@ -20,18 +21,10 @@ Texture2D[] loadAnimationFramesUI(const string archivePath, const string animati
     uint frameIndex = 1;
     while (true)
     {
-        string frameFileName = format("%s-%03d.png", animationName, frameIndex);
-        uint image_size;
+        string frameFileName = format("%s-%03d.png", animationFileName, frameIndex);
+        if (std.file.exists(fileDir~"/"~frameFileName) == false) break;
         debug debugWriteln(frameFileName);
-        char* image_data = get_file_data_from_archive(toStringz(archivePath),
-                toStringz(frameFileName), &image_size);
-        if (image_data == null) {
-            debug debugWriteln("exiting from load anim UI");
-            break;
-        }
-        Image image = LoadImageFromMemory(".PNG", cast(const(ubyte)*) image_data, image_size);
-        Texture2D texture = LoadTextureFromImage(image);
-        UnloadImage(image);
+        Texture2D texture = LoadTexture((fileDir~"/"~frameFileName).toStringz());
         frames ~= texture;
         debug debugWriteln("Loaded frame for UI ", frameIndex, " - ", frameFileName);
         frameIndex++;

+ 3 - 4
source/graphics/engine.d

@@ -40,7 +40,6 @@ void engine_loader()
     int screenWidth = 1344;
     int screenHeight = 1008;
     // Initialization
-    debug debugWriteln("Engine version: ", ver);
     SetExitKey(0);
     Image icon = LoadImage("res/icon.png");
     // Window and Audio Initialization
@@ -49,10 +48,10 @@ void engine_loader()
     UnloadImage(icon);
     //ToggleFullscreen();
     SetTargetFPS(60);
+    //fallback font?
     textFont = LoadFont("res/font_en.png");
     // Fade In and Out Effects
     InitAudioDevice();
-    audioEnabled = systemSettings.sound_state.to!bool;
     helloScreen();
     ClearBackground(Colors.BLACK);
     EndDrawing();
@@ -69,12 +68,11 @@ void engine_loader()
             showMainMenu();
             break;
         case GameState.InGame:
-
             gameInit();
             luaExec = systemSettings.script_path;
             while (!WindowShouldClose())
             {
-                SetExitKey(0);
+            
                 if (luaReload) {
                     resetAllScriptValues();
                     int luaExecutionCode = luaInit(luaExec);
@@ -86,6 +84,7 @@ void engine_loader()
                     }
                     luaReload = false;
                 }
+                SetExitKey(0);
                 if (IsKeyPressed(KeyboardKey.KEY_F11)) {
                     ToggleFullscreen();
                 }

+ 6 - 6
source/scripts/lua.d

@@ -35,7 +35,6 @@ extern (C) nothrow int luaL_dialogBox(lua_State* L)
     foreach (i; 0..textTableLength) {
         lua_rawgeti(L, 1, i + 1);
         messageGlobal[i] = luaL_checkstring(L, -1).to!string;
-        backlogText ~= messageGlobal[i];
         lua_pop(L, 1);
     }
 
@@ -246,7 +245,7 @@ extern (C) nothrow int luaL_loadMusic(lua_State* L)
 {
     try
     {
-        musicPath = cast(char*) luaL_checkstring(L, 1);
+        char* musicPath = cast(char*)luaL_checkstring(L, 1);
         music = LoadMusicStream(musicPath);
     }
     catch (Exception e)
@@ -686,17 +685,18 @@ extern (C) nothrow void luaL_loader(lua_State* L)
     lua_register(L, "drawBackground", &luaL_draw2Dbackground);
     lua_register(L, "stopDrawBackground", &luaL_stopDraw2Dbackground);
     lua_register(L, "unloadBackground", &luaL_unload2Dbackground);
-    lua_register(L, "getTime", &luaL_getTime);
-    lua_register(L, "getDeltaTime", &luaL_getDeltaTime);
     lua_register(L, "loadScript", &luaL_loadScript);
-    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);
     lua_register(L, "isMouseButtonPressed", &luaL_isMouseButtonPressed);
     lua_register(L, "setGameState", &luaL_setGameState);
+
     //raylib direct bindings
+    lua_register(L, "unloadFont", &luaL_unloadFont);
+    lua_register(L, "loadFont", &luaL_loadFont);
+    lua_register(L, "getTime", &luaL_getTime);
+    lua_register(L, "getDeltaTime", &luaL_getDeltaTime);
     lua_register(L, "loadTexture", &luaL_loadTexture);
     lua_register(L, "drawTexture", &luaL_drawTexture);
     lua_register(L, "drawTextureEx", &luaL_drawTextureEx);

+ 0 - 16
source/variables.d

@@ -6,8 +6,6 @@ import raylib;
 import bindbc.lua;
 import system.abstraction;
 
-extern (C) char* get_file_data_from_archive(const char *input_file, const char *file_name, uint *file_size_out);
-
 nothrow void resetAllScriptValues() {
     debugWriteln("Resetting all values!");
     selectedChoice = 0;
@@ -87,20 +85,12 @@ Color characterColor = Color(255, 255, 255);
 
 bool playAnimation = false;
 
-bool audioEnabled = false;
-
-bool sfxEnabled = false;
-
-bool fullscreenEnabled = true;
-
 bool luaReload = true;
 
 bool videoFinished = false;
 
 bool isCameraMoving = false;
 
-bool neededCharacterDrawing = false;
-
 bool showDialog = false;
 
 bool isTextFullyDisplayed = false;
@@ -108,18 +98,12 @@ bool isTextFullyDisplayed = false;
 
 /* strings */
 
-string ver = "1.1.8";
-
 string[] messageGlobal;
 
 string[] choices;
 
-string[] backlogText;
-
 string luaExec;
 
-char* musicPath;
-
 
 /* floats */