From 59972aee3a2a2d6524af1d8768699f5157cac23f Mon Sep 17 00:00:00 2001 From: rexim Date: Fri, 22 Mar 2024 20:10:17 +0700 Subject: Change working directory to the application directory --- build-linux.sh | 4 ++-- game.adb | 17 +++++++++-------- raylib.ads | 17 +++++++++++++++++ test.adb | 33 +++------------------------------ 4 files changed, 31 insertions(+), 40 deletions(-) diff --git a/build-linux.sh b/build-linux.sh index 64aaa00..732d4f9 100755 --- a/build-linux.sh +++ b/build-linux.sh @@ -5,5 +5,5 @@ set -xe gnatmake -O3 -f -Wall -Wextra -gnat2022 game.adb -bargs -static -largs -L./raylib/raylib-5.0_linux_amd64/lib/ -l:libraylib.a -lm ./game -# gnatmake -gnat2022 test.adb -largs -L./raylib/raylib-5.0_linux_amd64/lib/ -l:libraylib.a -lm -# ./test +#gnatmake -f -Wall -Wextra -gnat2022 test.adb -largs -L./raylib/raylib-5.0_linux_amd64/lib/ -l:libraylib.a -lm +#./test diff --git a/game.adb b/game.adb index ba145d5..690693a 100644 --- a/game.adb +++ b/game.adb @@ -1244,6 +1244,10 @@ procedure Game is Palette_Editor_Component: HSV_Comp := Hue; begin + if not Change_Directory(Get_Application_Directory) then + Put_Line("WARNING: Could not change working directory to the application directory"); + end if; + Set_Config_Flags(FLAG_WINDOW_RESIZABLE); Init_Window(1600, 900, Title); Set_Target_FPS(60); @@ -1396,7 +1400,10 @@ begin Close_Window; end; --- TODO: Window title icon +-- TODO: Eye Angle Speed +-- For smoother transitions. Especially from Open to Closed if we decide +-- that the Closed eyes should always point down +-- TODO: Closed eyes should always point down -- TODO: If you are standing on the refilled bomb gen and place a bomb you should refill your bomb in that turn. -- TODO: Checkpoints should be circles (like all the items) -- TODO: Custom font @@ -1409,15 +1416,9 @@ end; -- - Closed -- - Open -- - Happy (very important to indicate that he's not hostile) --- TODO: Eye Angle Speed --- For smoother transitions. Especially from Open to Closed if we decide --- that the Closed eyes should always point down --- TODO: Set working directory to where the exe is --- So it will search the resources there. -- TODO: Eyes for the Player. -- The denote last direction of the step. -- TODO: Enemies should attack on zero just like a bomb. --- TODO: Desaturate the colors -- TODO: Properly disablable DEV features -- TODO: Fullscreen mode -- TODO: Don't reset cooldown timer for eepers (might be duplicate) @@ -1425,7 +1426,7 @@ end; -- TODO: Try MSAA (if too slow, don't) -- TODO: Rename executable to "eepers" -- TODO: Icon on for Windows build --- TODO: Closed eyes should always point down +-- TODO: Window title icon -- TODO: Show Eeper Cooldown timer outside of the screen somehow -- TODO: Visual Clue that the Eeper is about to kill the Player when Completely outside of the Screen -- - Cooldown ball is shaking diff --git a/raylib.ads b/raylib.ads index a58c34c..dc8a8f0 100644 --- a/raylib.ads +++ b/raylib.ads @@ -1,4 +1,5 @@ with Interfaces.C; use Interfaces.C; +with Interfaces.C.Strings; use Interfaces.C.Strings; with Raymath; use Raymath; package Raylib is @@ -209,4 +210,20 @@ package Raylib is type Vector2_Array is array (size_t range <>) of aliased Vector2; procedure Draw_Triangle_Strip(Points: Vector2_Array; C: Color); + + function Get_Working_Directory return chars_ptr + with + Import => True, + Convention => C, + External_Name => "GetWorkingDirectory"; + function Get_Application_Directory return chars_ptr + with + Import => True, + Convention => C, + External_Name => "GetApplicationDirectory"; + function Change_Directory(dir: chars_ptr) return C_Bool + with + Import => True, + Convention => C, + External_Name => "ChangeDirectory"; end Raylib; diff --git a/test.adb b/test.adb index 795e9a1..aa8b5fe 100644 --- a/test.adb +++ b/test.adb @@ -1,39 +1,12 @@ -with Ada.Text_IO; with Text_IO; use Text_IO; -with Ada.Strings.Fixed; use Ada.Strings.Fixed; -with Ada.Strings; use Ada.Strings; -with Ada.Containers.Vectors; -with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; -with Ada.Numerics.Discrete_Random; with Raylib; use Raylib; with Interfaces.C; use Interfaces.C; -with Interfaces.C.Pointers; +with Interfaces.C.Strings; use Interfaces.C.Strings; with Ada.Unchecked_Conversion; -with Raylib; use Raylib; -with Raymath; use Raymath; function Test return Integer is - type Palette is ( - COLOR_BACKGROUND, - COLOR_FLOOR, - COLOR_WALL, - COLOR_BARRICADE, - COLOR_PLAYER, - COLOR_DOOR_KEY, - COLOR_BOMB, - COLOR_LABEL, - COLOR_GUARD, - COLOR_URMOM, - COLOR_GNOME, - COLOR_CHECKPOINT, - COLOR_EXPLOSION, - COLOR_HEALTHBAR, - COLOR_NEW_GAME, - COLOR_EYES, - COLOR_FINAL); begin - for C in Palette loop - Put_Line(To_Unbounded_String(C'Image)); - end loop; + Put_Line("Working Directory: " & To_Ada(Value(Get_Working_Directory))); + Put_Line("Application Directory: " & To_Ada(Value(Get_Application_Directory))); return 0; end; -- cgit v1.2.3