Some refactoring and experimental work...
This commit is contained in:
parent
af4e800498
commit
642a0b5046
@ -195,6 +195,18 @@ package body core is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
function import_text (file_path : in string) return text_box_data is
|
||||
this : text_box_data;
|
||||
begin
|
||||
this.data := ray.load_text (c_string (file_path));
|
||||
this.text := null_unbounded_string;
|
||||
this.size := (0, 0);
|
||||
--
|
||||
return this;
|
||||
end import_text;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure create_image (width, height : in integer) is
|
||||
begin
|
||||
global_mapshot := ray.image_colour (width * base, height * base, (0, 0, 0, 255));
|
||||
@ -327,14 +339,14 @@ package body core is
|
||||
|
||||
function read_text_box return string is
|
||||
begin
|
||||
return to_string (text_box.data);
|
||||
return to_string (text_box.text);
|
||||
end read_text_box;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure write_text_box (text : in string) is
|
||||
begin
|
||||
text_box.data := to_unbounded_string (text);
|
||||
text_box.text := to_unbounded_string (text);
|
||||
end write_text_box;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
@ -59,7 +59,8 @@ package core is
|
||||
end record;
|
||||
|
||||
type text_box_data is record
|
||||
data : unbounded_string := null_unbounded_string;
|
||||
data : access string := null;
|
||||
text : unbounded_string := null_unbounded_string;
|
||||
size : vector := (0, 0);
|
||||
end record;
|
||||
|
||||
@ -126,6 +127,7 @@ package core is
|
||||
function import_sprite (file_path : in string; frames, states : in integer) return sprite;
|
||||
function import_font (file_path : in string; scale, space : in integer) return font;
|
||||
function import_song (file_path : in string) return song;
|
||||
function import_text (file_path : in string) return text_box_data;
|
||||
|
||||
procedure create_image (width, height : in integer);
|
||||
procedure render_image (data : in sprite; x, y, u, v, width, height : in integer);
|
||||
|
@ -9,14 +9,12 @@ with core, ui, effect, attribute, skill, resource, faction, item, unit, construc
|
||||
|
||||
use core;
|
||||
|
||||
with Ada.Text_IO; -- For text input/output operations
|
||||
with Ada.Text_IO.Text_Streams; -- For text file handling
|
||||
with Ada.Strings.Unbounded; -- For unbounded string handling
|
||||
|
||||
procedure main is
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
monospace : font;
|
||||
|
||||
side_panel : integer := 0;
|
||||
preview_width : integer := 0;
|
||||
preview_height : integer := 0;
|
||||
@ -49,7 +47,7 @@ procedure main is
|
||||
);
|
||||
|
||||
game_title : sprite;
|
||||
ashland_preview : sprite;
|
||||
game_preview : array (world.biome) of sprite; -- sand, grass, rough, snow, swamp
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
@ -91,7 +89,7 @@ procedure main is
|
||||
|
||||
procedure ui_main_style is
|
||||
begin
|
||||
ui.active := ui.style'val ((ui.style'pos (ui.active) + 1) mod (ui.style'pos (ui.style'last) + 1));
|
||||
ui.active := ui.style'val ((ui.style'pos (ui.active) + 1) mod ui.style_count);
|
||||
end ui_main_style;
|
||||
|
||||
procedure zoom_in is begin zoom := 2; end zoom_in;
|
||||
@ -112,31 +110,24 @@ procedure main is
|
||||
|
||||
procedure introduction is
|
||||
begin
|
||||
draw (ashland_preview, center_x (ashland_preview.width * 2), center_y (ashland_preview.height * 2), factor => 2);
|
||||
draw (game_preview (world.ash), center_x (game_preview (world.ash).width * 2), center_y (game_preview (world.ash).height * 2), factor => 2);
|
||||
draw (game_title, center_x (game_title.width * 2), center_y (game_title.height * 2), factor => 2);
|
||||
--
|
||||
write ("[-- Please press Spacebar to continue]", 0, center_y (24), (102, 102, 102, 255));
|
||||
ui.write ("[-- Please press Spacebar to continue]", 0, center_y (24), (102, 102, 102, 255));
|
||||
end introduction;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
File : Ada.Text_IO.File_Type;
|
||||
Line : Ada.Strings.Unbounded.unbounded_string;
|
||||
|
||||
monospace : font;
|
||||
|
||||
procedure main_menu is
|
||||
begin
|
||||
draw (ashland_preview, center_x (ashland_preview.width * 2), center_y (ashland_preview.height * 2), factor => 2);
|
||||
draw (game_preview (world.ash), center_x (game_preview (world.ash).width * 2), center_y (game_preview (world.ash).height * 2), factor => 2);
|
||||
draw (game_title, center_x (game_title.width * 2), center_y (game_title.height * 2), factor => 2);
|
||||
--
|
||||
write ("Main Menu", 0, 0);
|
||||
ui.write ("Main Menu", 0, 0);
|
||||
--
|
||||
ui.draw_check_box (0, 32, view_list (map_preview_panel), "map_preview_panel");
|
||||
ui.draw_check_box (0, 64, view_list (status_preview_panel), "status_preview_panel");
|
||||
ui.draw_check_box (0, 96, view_list (text_box_panel), "text_box_panel");
|
||||
--
|
||||
write (Ada.Strings.Unbounded.To_String (Line), 128, 64, (others => 255), 22, monospace);
|
||||
end main_menu;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
@ -189,14 +180,6 @@ procedure main is
|
||||
|
||||
begin
|
||||
|
||||
Ada.Text_IO.Open(File, Ada.Text_IO.In_File, "./source/attribute.ads"); -- Open the file for reading
|
||||
while not Ada.Text_IO.End_Of_File(File) loop
|
||||
Line := Ada.Strings.Unbounded.To_Unbounded_String (Ada.Strings.Unbounded.To_String (Line) & Character'Val (10) & Ada.Text_IO.Get_Line(File)); -- Read a line from the file
|
||||
--~Line := Line & Ada.Strings.Unbounded.To_Unbounded_String (Ada.Text_IO.Get_Line(File)); -- Read a line from the file
|
||||
Ada.Text_IO.Put_Line(Ada.Strings.Unbounded.To_String (Line)); -- Output the line to the console
|
||||
end loop;
|
||||
Ada.Text_IO.Close(File); -- Close the file after reading
|
||||
|
||||
dash;
|
||||
echo (comment, "Copyright (C) 2024 -- Ognjen 'xolatile' Milan Robovic");
|
||||
echo (comment, "Version -- 1.0.0");
|
||||
@ -208,6 +191,8 @@ begin
|
||||
|
||||
monospace := import_font ("./sprite/ui/monospace.png", 11, 0);
|
||||
|
||||
ui.active := ui.main;
|
||||
|
||||
ui.configure;
|
||||
|
||||
play (import_song (c_string ("./song/main_menu.ogg")).index);
|
||||
@ -224,7 +209,7 @@ begin
|
||||
world.configure;
|
||||
--~ai.configure;
|
||||
|
||||
world.make (world.swamp, 240, 180);
|
||||
world.make (world.grass, 240, 180);
|
||||
|
||||
dash;
|
||||
echo (success, "Successfully initialized game data, entering main gameplay loop.");
|
||||
@ -234,12 +219,11 @@ begin
|
||||
view_icon (index) := import_sprite ("./sprite/ui/icon/" & lowercase (view'image (index)) & ".png", 1, 1);
|
||||
end loop;
|
||||
|
||||
ui.active := ui.imp;
|
||||
|
||||
camera := (1, 1);
|
||||
|
||||
game_title := import_sprite ("./sprite/game_title.png", 1, 1);
|
||||
ashland_preview := import_sprite ("./sprite/ashland_preview.png", 1, 1);
|
||||
|
||||
for index in world.biome loop
|
||||
game_preview (index) := import_sprite ("./sprite/" & lowercase (world.biome'image (index)) & "land_preview.png", 1, 1);
|
||||
end loop;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
@ -254,7 +238,7 @@ begin
|
||||
main_menu_loop: loop
|
||||
synchronize;
|
||||
--
|
||||
exit when signal_mode = signal_a;
|
||||
exit when signal_mode = signal_space;
|
||||
--
|
||||
main_menu;
|
||||
end loop main_menu_loop;
|
||||
|
@ -163,6 +163,37 @@ package ray is
|
||||
procedure pause_sound (data : in sound) with import => true, convention => c, external_name => "PauseSound";
|
||||
procedure resume_sound (data : in sound) with import => true, convention => c, external_name => "ResumeSound";
|
||||
|
||||
--~void ToggleFullscreen(void);
|
||||
--~void SetWindowIcon(Image image);
|
||||
--~void SetWindowMinSize(int width, int height);
|
||||
--~void SetWindowMaxSize(int width, int height);
|
||||
--~void SetWindowSize(int width, int height);
|
||||
--~void ShowCursor(void);
|
||||
--~void HideCursor(void);
|
||||
--~double GetTime(void);
|
||||
--~void TakeScreenshot(const char *fileName);
|
||||
--~void OpenURL(const char *url);
|
||||
function load_text (file : in string) return access string with import => true, convention => c, external_name => "LoadFileText";
|
||||
--~procedure unload_file (data : in access string) with import => true, convention => c, external_name => "UnloadFileText";
|
||||
--~bool SaveFileText(const char *fileName, char *text);
|
||||
--~FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs);
|
||||
--~void UnloadDirectoryFiles(FilePathList files);
|
||||
--~unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize);
|
||||
--~unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize);
|
||||
--~void ImageDrawPixel(Image *dst, int posX, int posY, Color color);
|
||||
--~void SetTextLineSpacing(int spacing);
|
||||
--~Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing);
|
||||
--~bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2);
|
||||
--~void SetMasterVolume(float volume);
|
||||
--~Music LoadMusicStream(const char *fileName);
|
||||
--~void UnloadMusicStream(Music music);
|
||||
--~void PlayMusicStream(Music music);
|
||||
--~void PauseMusicStream(Music music);
|
||||
--~void ResumeMusicStream(Music music);
|
||||
--~void SetMusicVolume(Music music, float volume);
|
||||
--~float GetMusicTimeLength(Music music);
|
||||
--~RLAPI float GetMusicTimePlayed(Music music);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end ray;
|
||||
|
@ -47,6 +47,8 @@ package ui is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
style_count : constant natural := style'pos (style'last) + 1;
|
||||
|
||||
active : style := main;
|
||||
prioritize : boolean := false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user