quantumde1 2 місяців тому
батько
коміт
dda7ac1ea8
4 змінених файлів з 50 додано та 52 видалено
  1. 43 45
      source/graphics/engine.d
  2. 1 0
      source/graphics/gamelogic.d
  3. 6 6
      source/graphics/playback.d
  4. 0 1
      source/ui/menu.d

+ 43 - 45
source/graphics/engine.d

@@ -63,55 +63,53 @@ void engine_loader()
     {
         switch (currentGameState)
         {
-        case GameState.MainMenu:
-            debugWriteln("Showing menu.");
-            showMainMenu();
-            break;
-        case GameState.InGame:
-            gameInit();
-            luaExec = systemSettings.script_path;
-            while (!WindowShouldClose())
-            {
-            
-                if (luaReload) {
-                    resetAllScriptValues();
-                    int luaExecutionCode = luaInit(luaExec);
-                    if (luaExecutionCode != EngineExitCodes.EXIT_OK) {
-                        writeln("[ERROR] Engine stops execution according to error code: ", 
-                        luaExecutionCode.to!EngineExitCodes);
-                        currentGameState = GameState.Exit;
-                        break;
+            case GameState.MainMenu:
+                debugWriteln("Showing menu.");
+                showMainMenu();
+                break;
+            case GameState.InGame:
+                gameInit();
+                while (!WindowShouldClose())
+                {
+                    if (luaReload) {
+                        resetAllScriptValues();
+                        int luaExecutionCode = luaInit(luaExec);
+                        if (luaExecutionCode != EngineExitCodes.EXIT_OK) {
+                            writeln("[ERROR] Engine stops execution according to error code: ", 
+                            luaExecutionCode.to!EngineExitCodes);
+                            currentGameState = GameState.Exit;
+                            break;
+                        }
+                        luaReload = false;
                     }
-                    luaReload = false;
-                }
-                SetExitKey(0);
-                if (IsKeyPressed(KeyboardKey.KEY_F11)) {
-                    ToggleFullscreen();
+                    SetExitKey(0);
+                    if (IsKeyPressed(KeyboardKey.KEY_F11)) {
+                        ToggleFullscreen();
+                    }
+                    BeginDrawing();
+                    ClearBackground(Colors.BLACK);
+                    // main logic
+                    BeginMode2D(camera);
+                    backgroundLogic();
+                    characterLogic();
+                    // effects logic
+                    effectsLogic();
+                    EndMode2D();
+                    //drawing dialogs
+                    dialogLogic();
+                    luaEventLoop();
+                    EndDrawing();
                 }
-                BeginDrawing();
-                ClearBackground(Colors.BLACK);
-                // main logic
-                BeginMode2D(camera);
-                backgroundLogic();
-                characterLogic();
-                // effects logic
-                effectsLogic();
-                EndMode2D();
-                //drawing dialogs
-                dialogLogic();
-                luaEventLoop();
+                break;
+            case GameState.Exit:
                 EndDrawing();
-            }
-            break;
-        case GameState.Exit:
-            EndDrawing();
-            unloadResourcesLogic();
-            CloseAudioDevice();
-            CloseWindow();
-            return;
+                unloadResourcesLogic();
+                CloseAudioDevice();
+                CloseWindow();
+                return;
 
-        default:
-            break;
+            default:
+                break;
         }
     }
 }

+ 1 - 0
source/graphics/gamelogic.d

@@ -31,6 +31,7 @@ void gameInit()
     } else {
         debugWriteln("Game initializing.");
         systemSettings = loadSettingsFromConfigFile();
+        luaExec = systemSettings.script_path;
     }
 }
 

+ 6 - 6
source/graphics/playback.d

@@ -197,7 +197,7 @@ void cleanup_video(Video* video)
     free(video);
 }
 
-extern (C) int playVideoInternal(char* argv)
+extern (C) void playVideoInternal(char* argv)
 {
     const(char)*[] vlcArgs;
     debug
@@ -219,7 +219,7 @@ extern (C) int playVideoInternal(char* argv)
     {
         debug debugWriteln("Something went wrong with libvlc init. Turn on DEBUG in conf/build_type.conf at BUILD_TYPE field to get more logs.");
         videoFinished = true;
-        return 0;
+        return;
     }
 
     Video*[] video_list;
@@ -227,7 +227,7 @@ extern (C) int playVideoInternal(char* argv)
     if (new_video is null)
     {
         libvlc_release(libvlc);
-        return 0;
+        return;
     }
 
     video_list ~= new_video;
@@ -315,7 +315,7 @@ extern (C) int playVideoInternal(char* argv)
         }
 
         
-        if (IsKeyPressed(KeyboardKey.KEY_ENTER))
+        if (IsKeyPressed(KeyboardKey.KEY_ENTER) || IsMouseButtonPressed(MouseButton.MOUSE_BUTTON_LEFT))
         {
             foreach (video; video_list)
             {
@@ -326,7 +326,7 @@ extern (C) int playVideoInternal(char* argv)
             video_list.length = 0;
             EndDrawing();
             libvlc_release(libvlc);
-            return 0;
+            return;
         }
 
         EndDrawing();
@@ -339,7 +339,7 @@ extern (C) int playVideoInternal(char* argv)
     videoFinished = true;
     video_list.length = 0;
     libvlc_release(libvlc);
-    return 0;
+    return;
 }
 
 void playVideo(string filename) {

+ 0 - 1
source/ui/menu.d

@@ -93,7 +93,6 @@ int showMainMenu() {
         EndDrawing();
     }
     debugWriteln("menu assets unloading");
-    UnloadFont(textFont);
     StopMusicStream(music);
     UnloadMusicStream(music);
     luaReload = true;