From 85c1095699d44a78a2e23498f128d8b376d9319a Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 10 Jun 2024 14:02:14 -0400 Subject: [PATCH] Minor changes, removing global variables soon... --- source/core.ads | 2 + source/main.adb | 125 +++++++++---------------------------------------------- source/ui.adb | 5 +-- source/world.adb | 106 +++++++++++++++++++++++++++++++++++++++++++--- source/world.ads | 6 ++- 5 files changed, 127 insertions(+), 117 deletions(-) diff --git a/source/core.ads b/source/core.ads index b3d5ecc..b8e11d4 100644 --- a/source/core.ads +++ b/source/core.ads @@ -83,6 +83,8 @@ package core is icon : constant natural := 32; base : constant natural := 16; + more : constant natural := 10; + less : constant natural := 5; gameplay_framerate : constant natural := 60; animation_framerate : constant natural := 4; diff --git a/source/main.adb b/source/main.adb index 75e6237..d68487e 100644 --- a/source/main.adb +++ b/source/main.adb @@ -157,26 +157,26 @@ procedure main is offset : constant integer := 8; width : constant integer := side_panel - 2 * core.icon; height : constant integer := chad.view_height + 11 * core.icon + 4 * core.base + 2 * offset; - more : constant natural := 10; - less : constant natural := 5; side : constant integer := chad.view_width + attribute.count * core.icon; at_x : integer := x + offset; at_y : integer := y + offset; begin - ui.draw_frame (x, y, width, height); - ui.draw_sprite (chad.view (player_1.index), chad.description (player_1.index).name.all, at_x, at_y, 0); - ui.draw_text_box (at_x + chad.view_width, at_y, width - chad.view_width - 2 * offset, core.icon); - ui.write (chad.description (player_1.index).name.all, at_x + chad.view_width + less, at_y + less); + world.review_chad_data := player_1.index; -- - ui.draw_text (chad.description (player_1.index).title.all, at_x + side, at_y + 1 * core.icon, width - side - 2 * offset, core.icon, more); - ui.draw_text ("Level" & player_1.level'image, at_x + side, at_y + 2 * core.icon, width - side - 2 * offset, core.icon, more); + ui.draw_frame (x, y, width, height); + ui.draw_sprite (chad.view (player_1.index), chad.description (player_1.index).name.all, at_x, at_y, 0, world.review_chad'access); + ui.draw_text_box (at_x + chad.view_width, at_y, width - chad.view_width - 2 * offset, core.icon); + ui.write (chad.description (player_1.index).name.all, at_x + chad.view_width + core.less, at_y + core.less); + -- + ui.draw_text (chad.description (player_1.index).title.all, at_x + side, at_y + 1 * core.icon, width - side - 2 * offset, core.icon, core.more); + ui.draw_text ("Level" & player_1.level'image, at_x + side, at_y + 2 * core.icon, width - side - 2 * offset, core.icon, core.more); -- at_x := x + chad.view_width + offset; at_y := y + core.icon + offset; -- for index in attribute.enumeration loop ui.draw_icon (attribute.icon (index), attribute.description (index).text.all, at_x, at_y); - ui.draw_text (player_1.attributes (index).value'image, at_x, at_y + core.icon, core.icon, core.icon, more); + ui.draw_text (player_1.attributes (index).value'image, at_x, at_y + core.icon, core.icon, core.icon, core.more); -- at_x := at_x + core.icon; end loop; @@ -192,13 +192,13 @@ procedure main is ui.draw_tiny_fill_bar (at_x, at_y + 1 * core.icon, side, float (player_1.mana.value) / float (player_1.mana.limit), (0, 0, 127, 255)); ui.draw_tiny_fill_bar (at_x, at_y + 2 * core.icon, side, float (player_1.movement.value) / float (player_1.movement.limit), (0, 127, 0, 255)); -- - ui.draw_text ("Health", at_x + side, at_y - core.icon, width - side - 2 * offset, core.icon, more); - ui.draw_text ("Mana", at_x + side, at_y, width - side - 2 * offset, core.icon, more); - ui.draw_text ("Movement", at_x + side, at_y + core.icon, width - side - 2 * offset, core.icon, more); + ui.draw_text ("Health", at_x + side, at_y - core.icon, width - side - 2 * offset, core.icon, core.more); + ui.draw_text ("Mana", at_x + side, at_y, width - side - 2 * offset, core.icon, core.more); + ui.draw_text ("Movement", at_x + side, at_y + core.icon, width - side - 2 * offset, core.icon, core.more); -- - ui.write (player_1.health.value'image & " /" & player_1.health.limit'image, at_x + core.icon, at_y - core.icon + more, code => true); - ui.write (player_1.mana.value'image & " /" & player_1.mana.limit'image, at_x + core.icon, at_y + more, code => true); - ui.write (player_1.movement.value'image & " /" & player_1.movement.limit'image, at_x + core.icon, at_y + core.icon + more, code => true); + ui.write (player_1.health.value'image & " /" & player_1.health.limit'image, at_x + core.icon, at_y - core.icon + core.more, code => true); + ui.write (player_1.mana.value'image & " /" & player_1.mana.limit'image, at_x + core.icon, at_y + core.more, code => true); + ui.write (player_1.movement.value'image & " /" & player_1.movement.limit'image, at_x + core.icon, at_y + core.icon + core.more, code => true); -- at_y := at_y + 2 * core.icon; -- @@ -220,15 +220,15 @@ procedure main is end if; end loop; -- - ui.draw_text ("Equipment", at_x + 8 * core.icon, at_y, width - 8 * core.icon - 2 * offset, core.icon, more); + ui.draw_text ("Equipment", at_x + 8 * core.icon, at_y, width - 8 * core.icon - 2 * offset, core.icon, core.more); -- at_y := at_y + core.icon; -- - ui.draw_text ("Skills", at_x + side, at_y, width - side - 2 * offset, core.icon, more); + ui.draw_text ("Skills", at_x + side, at_y, width - side - 2 * offset, core.icon, core.more); -- for index in 0 .. skill.limit - 1 loop ui.draw_icon (skill.icon (player_1.skills (index).index), skill.description (player_1.skills (index).index).text.all, at_x + index * core.icon, at_y); - --~ui.write (player_1.points (index).value'image, at_x + index * core.icon + more, at_y + more, code => true); + --~ui.write (player_1.points (index).value'image, at_x + index * core.icon + core.more, at_y + core.more, code => true); end loop; -- at_y := at_y + core.icon; @@ -295,93 +295,6 @@ begin --~core.play (core.import_song (core.c_string (core.folder & "/song/main_menu.ogg")).index); - core.echo (core.comment, "Configuring" & attribute.count'image & " attribute components..."); - -- - for index in attribute.enumeration loop - attribute.icon (index) := core.import_sprite (core.folder & "/icon/attribute/" & core.lowercase (attribute.enumeration'image (index)) & ".png", 1, 1); - end loop; - - core.echo (core.comment, "Configuring" & skill.count'image & " skill components..."); - -- - for index in skill.enumeration loop - skill.icon (index) := core.import_sprite (core.folder & "/icon/skill/" & core.lowercase (skill.enumeration'image (index)) & ".png", 1, 1); - end loop; - - core.echo (core.comment, "Configuring" & resource.count'image & " resource components..."); - -- - for index in resource.enumeration loop - resource.icon (index) := core.import_sprite (core.folder & "/icon/resource/" & core.lowercase (resource.enumeration'image (index)) & ".png", 1, 1); - end loop; - - core.echo (core.comment, "Configuring" & magic.count'image & " magic components..."); - -- - for index in magic.enumeration loop - declare folder : constant string := core.lowercase (magic.school'image (magic.description (index).kind)); - file : constant string := core.lowercase (magic.enumeration'image (index)); - begin - magic.view (index) := core.import_sprite (core.folder & "/view/magic/" & folder & "/" & file & ".png", 1, 1); - end; - end loop; - - core.echo (core.comment, "Configuring" & material.count'image & " material components..."); - -- - for index in material.enumeration loop - material.icon (index) := core.import_sprite (core.folder & "/icon/material/" & core.lowercase (material.enumeration'image (index)) & ".png", 1, 1); - end loop; - - core.echo (core.comment, "Configuring" & equipment.count'image & " equipment components..."); - -- - for index in equipment.enumeration loop - declare folder : constant string := core.lowercase (equipment.kind'image (equipment.description (index).slot)); - file : constant string := core.lowercase (equipment.enumeration'image (index)); - begin - equipment.game (index) := core.import_sprite (core.folder & "/game/equipment/" & folder & "/" & file & ".png", 4, 6); - equipment.icon (index) := core.import_sprite (core.folder & "/icon/equipment/" & folder & "/" & file & ".png", 1, 1); - end; - end loop; - -- - for index in equipment.kind loop - declare file : constant string := core.lowercase (equipment.kind'image (index)); - begin - equipment.slot (index) := core.import_sprite (core.folder & "/icon/engine/" & file & ".png", 1, 1); - end; - end loop; - - core.echo (core.comment, "Configuring" & unit.count'image & " unit components..."); - -- - for index in faction.enumeration loop - unit.base (index) := core.import_sprite (core.folder & "/game/unit/" & core.lowercase (faction.enumeration'image (index)) & "/base.png", 4, 6); - end loop; - -- - for index in unit.enumeration loop - unit.icon (index) := core.import_sprite (core.folder & "/icon/unit/" & core.lowercase (unit.enumeration'image (index)) & ".png", 1, 1); - unit.view (index) := core.import_sprite (core.folder & "/view/unit/" & core.lowercase (unit.enumeration'image (index)) & ".png", 1, 1); - end loop; - - core.echo (core.comment, "Configuring" & deity.count'image & " deity components..."); - -- - for index in deity.enumeration loop - deity.sprite (index) := core.import_sprite (core.folder & "/game/deity/" & deity.enumeration'image (index) & ".png", 4, 1); - end loop; - - core.echo (core.comment, "Configuring" & construction.count'image & " construction components..."); - -- - for index in construction.enumeration loop - declare folder : constant string := core.lowercase (faction.enumeration'image (construction.description (index).kind)); - file : constant string := core.lowercase (construction.enumeration'image (index)); - frames : constant integer := construction.description (index).frames; - begin - construction.game (index) := core.import_sprite (core.folder & "/game/construction/" & folder & "/" & file & ".png", frames, 1); - end; - end loop; - - core.echo (core.comment, "Configuring" & chad.count'image & " chad components..."); - -- - for index in chad.enumeration loop - chad.game (index) := core.import_sprite (core.folder & "/game/chad/" & core.lowercase (chad.enumeration'image (index)) & ".png", 4, 6); - chad.view (index) := core.import_sprite (core.folder & "/view/chad/" & core.lowercase (chad.enumeration'image (index)) & ".png", 1, 1); - end loop; - world.configure; --~ai.configure; @@ -448,7 +361,7 @@ begin --~core.cursor_mode := core.cursor_none; - --~world.load ("heyo"); + world.load ("heyo"); ui.active := ui.style'val (faction.enumeration'pos (chad.description (player.index).kind) + 1); diff --git a/source/ui.adb b/source/ui.adb index 7d681ce..6d36a49 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -218,9 +218,8 @@ package body ui is -- core.write_help_box (text); -- - if core.cursor_mode = core.cursor_left then + if core.cursor_mode = core.cursor_right then action.all; - core.cursor_mode := core.cursor_none; end if; end if; end draw_sprite; @@ -484,7 +483,7 @@ package body ui is -- core.write_help_box (text); -- - if core.cursor_mode = core.cursor_left then + if core.cursor_mode = core.cursor_right then action.all; end if; end if; diff --git a/source/world.adb b/source/world.adb index c17c928..e62d650 100644 --- a/source/world.adb +++ b/source/world.adb @@ -87,6 +87,93 @@ package body world is frames => location.description (index).frames, states => 2); end loop; + -- + core.echo (core.comment, "Configuring" & attribute.count'image & " attribute components..."); + -- + for index in attribute.enumeration loop + attribute.icon (index) := core.import_sprite (core.folder & "/icon/attribute/" & core.lowercase (attribute.enumeration'image (index)) & ".png", 1, 1); + end loop; + -- + core.echo (core.comment, "Configuring" & skill.count'image & " skill components..."); + -- + for index in skill.enumeration loop + skill.icon (index) := core.import_sprite (core.folder & "/icon/skill/" & core.lowercase (skill.enumeration'image (index)) & ".png", 1, 1); + end loop; + -- + core.echo (core.comment, "Configuring" & resource.count'image & " resource components..."); + -- + for index in resource.enumeration loop + resource.icon (index) := core.import_sprite (core.folder & "/icon/resource/" & core.lowercase (resource.enumeration'image (index)) & ".png", 1, 1); + end loop; + -- + core.echo (core.comment, "Configuring" & magic.count'image & " magic components..."); + -- + for index in magic.enumeration loop + declare folder : constant string := core.lowercase (magic.school'image (magic.description (index).kind)); + file : constant string := core.lowercase (magic.enumeration'image (index)); + begin + magic.view (index) := core.import_sprite (core.folder & "/view/magic/" & folder & "/" & file & ".png", 1, 1); + end; + end loop; + -- + core.echo (core.comment, "Configuring" & material.count'image & " material components..."); + -- + for index in material.enumeration loop + material.icon (index) := core.import_sprite (core.folder & "/icon/material/" & core.lowercase (material.enumeration'image (index)) & ".png", 1, 1); + end loop; + -- + core.echo (core.comment, "Configuring" & equipment.count'image & " equipment components..."); + -- + for index in equipment.enumeration loop + declare folder : constant string := core.lowercase (equipment.kind'image (equipment.description (index).slot)); + file : constant string := core.lowercase (equipment.enumeration'image (index)); + begin + equipment.game (index) := core.import_sprite (core.folder & "/game/equipment/" & folder & "/" & file & ".png", 4, 6); + equipment.icon (index) := core.import_sprite (core.folder & "/icon/equipment/" & folder & "/" & file & ".png", 1, 1); + end; + end loop; + -- + for index in equipment.kind loop + declare file : constant string := core.lowercase (equipment.kind'image (index)); + begin + equipment.slot (index) := core.import_sprite (core.folder & "/icon/engine/" & file & ".png", 1, 1); + end; + end loop; + -- + core.echo (core.comment, "Configuring" & unit.count'image & " unit components..."); + -- + for index in faction.enumeration loop + unit.base (index) := core.import_sprite (core.folder & "/game/unit/" & core.lowercase (faction.enumeration'image (index)) & "/base.png", 4, 6); + end loop; + -- + for index in unit.enumeration loop + unit.icon (index) := core.import_sprite (core.folder & "/icon/unit/" & core.lowercase (unit.enumeration'image (index)) & ".png", 1, 1); + unit.view (index) := core.import_sprite (core.folder & "/view/unit/" & core.lowercase (unit.enumeration'image (index)) & ".png", 1, 1); + end loop; + -- + core.echo (core.comment, "Configuring" & deity.count'image & " deity components..."); + -- + for index in deity.enumeration loop + deity.sprite (index) := core.import_sprite (core.folder & "/game/deity/" & deity.enumeration'image (index) & ".png", 4, 1); + end loop; + -- + core.echo (core.comment, "Configuring" & construction.count'image & " construction components..."); + -- + for index in construction.enumeration loop + declare folder : constant string := core.lowercase (faction.enumeration'image (construction.description (index).kind)); + file : constant string := core.lowercase (construction.enumeration'image (index)); + frames : constant integer := construction.description (index).frames; + begin + construction.game (index) := core.import_sprite (core.folder & "/game/construction/" & folder & "/" & file & ".png", frames, 1); + end; + end loop; + -- + core.echo (core.comment, "Configuring" & chad.count'image & " chad components..."); + -- + for index in chad.enumeration loop + chad.game (index) := core.import_sprite (core.folder & "/game/chad/" & core.lowercase (chad.enumeration'image (index)) & ".png", 4, 6); + chad.view (index) := core.import_sprite (core.folder & "/view/chad/" & core.lowercase (chad.enumeration'image (index)) & ".png", 1, 1); + end loop; end configure; ------------------------------------------------------------------------------------------ @@ -350,15 +437,15 @@ package body world is from : faction.definition := faction.description (data.kind); -- offset : constant integer := 8; - more : constant natural := 10; - less : constant natural := 5; - boxy : constant natural := 3 * ui.monoheight + 2 * more; + boxy : constant natural := 3 * ui.monoheight + 2 * core.more; width : constant integer := chad.view_width + 3 * 2 * core.icon + 2 * offset; height : constant integer := chad.view_height + 8 * core.icon + 2 * core.base + boxy + 2 * offset; begin + if unit.enumeration'pos (review_unit_data) = unit.enumeration'pos (unit.none) then return; end if; + -- ui.draw_frame (core.center_x (width), core.center_y (height), width, height); ui.draw_sprite (unit.view (review_unit_data), data.name.all, core.center_x (width) + offset, core.center_y (height) + offset, 0); - ui.write (data.name.all, core.center_x (width) + offset + unit.view_width + less, core.center_y (height) + offset + less); + ui.write (data.name.all, core.center_x (width) + offset + unit.view_width + core.less, core.center_y (height) + offset + core.less); -- for index in attribute.enumeration loop ui.draw_icon_and_text (data => attribute.icon (index), @@ -375,8 +462,8 @@ package body world is "Battle fee:" & data.battle_fee'image, x => core.center_x (width) + offset, y => core.center_y (height) + offset + unit.view_height + core.base, - width => width - 2 * (offset + more), - border => more); + width => width - 2 * (offset + core.more), + border => core.more); -- ui.draw_separator (core.center_x (width) + offset, core.center_y (height) + offset + unit.view_height + core.base + boxy, width - 2 * offset); -- @@ -391,6 +478,13 @@ package body world is ------------------------------------------------------------------------------------------ + procedure review_chad is + begin + null; + end review_chad; + + ------------------------------------------------------------------------------------------ + procedure make (index : in biome.enumeration; width, height, landmark_limit, location_limit, construction_limit, equipment_limit, unit_limit, chad_limit : in natural) is begin core.echo (core.comment, "-- Procedurally generating new map..."); diff --git a/source/world.ads b/source/world.ads index 8600263..d1db735 100644 --- a/source/world.ads +++ b/source/world.ads @@ -2,7 +2,7 @@ -- -- GNU General Public Licence (version 3 or later) -with core, ui, attribute, skill, resource, material, lore, biome, landmark, location, faction, equipment, unit, construction, chad, effect; +with core, ui, attribute, skill, resource, material, lore, biome, landmark, location, faction, equipment, magic, deity, unit, construction, chad, effect; use type core.cursor_code; use type core.signal_code; @@ -45,7 +45,8 @@ package world is battle_left : chad.information; battle_right : chad.information; - review_unit_data : unit.enumeration := unit.none; + review_unit_data : unit.enumeration; + review_chad_data : chad.enumeration; ------------------------------------------------------------------------------------------ @@ -74,6 +75,7 @@ package world is procedure draw_chad (data : in chad.information; state : in core.animation; x, y, factor : in integer); procedure review_unit; + procedure review_chad; procedure make (index : in biome.enumeration; width, height, landmark_limit, location_limit, construction_limit, equipment_limit, unit_limit, chad_limit : in natural);