Sfoglia il codice sorgente

Refactored loop, record and declare keyword alignment...

master
Ognjen Milan Robovic 3 settimane fa
parent
commit
4bfc09dc08
25 ha cambiato i file con 91 aggiunte e 145 eliminazioni
  1. +1
    -2
      source/ai.adb
  2. +2
    -4
      source/ai.ads
  3. +3
    -5
      source/attribute.adb
  4. +3
    -6
      source/attribute.ads
  5. +1
    -2
      source/chad.adb
  6. +2
    -4
      source/chad.ads
  7. +3
    -5
      source/construction.adb
  8. +1
    -2
      source/construction.ads
  9. +27
    -27
      source/core.adb
  10. +2
    -5
      source/deity.ads
  11. +1
    -2
      source/effect.ads
  12. +1
    -2
      source/faction.ads
  13. +3
    -5
      source/item.adb
  14. +4
    -7
      source/magic.adb
  15. +1
    -2
      source/magic.ads
  16. +1
    -2
      source/main.adb
  17. +4
    -7
      source/might.adb
  18. +1
    -2
      source/might.ads
  19. +2
    -4
      source/resource.adb
  20. +3
    -6
      source/resource.ads
  21. +2
    -4
      source/skill.adb
  22. +3
    -6
      source/skill.ads
  23. +14
    -23
      source/ui.adb
  24. +5
    -9
      source/unit.adb
  25. +1
    -2
      source/unit.ads

+ 1
- 2
source/ai.adb Vedi File

@@ -63,8 +63,7 @@ package body ai is
--~y : integer := (core.window_height - height) / 2;
begin
--~ui.draw_tiny_menu (x, y, width, height, true);
--~for index in 1 .. actor_count
--~loop
--~for index in 1 .. actor_count loop
--~core.write ("Bot" & index'image, x + offset + 0, y * index + offset, ui.glyphs (ui.active));
--~core.write ("T =" & actor_is_thirsty (index)'image, x + offset + 120, y * index + offset, ui.glyphs (ui.active));
--~core.write ("H =" & actor_is_hungry (index)'image, x + offset + 240, y * index + offset, ui.glyphs (ui.active));


+ 2
- 4
source/ai.ads Vedi File

@@ -48,15 +48,13 @@ package ai is
--
-- Trickster ?

type action_data is
record
type action_data is record
base : data_limit;
data : core.procedure_pointer;
name : core.short_string;
end record;

type actor_data is
record
type actor_data is record
name : name_limit;
clan : clan_limit;
soul : data_limit;


+ 3
- 5
source/attribute.adb Vedi File

@@ -16,8 +16,7 @@ package body attribute is
begin
core.echo (core.comment, "Configuring attribute components...");
--
for index in enumeration
loop
for index in enumeration loop
sprite (index) := core.import_sprite ("./sprite/attribute/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);
end loop;
end configure;
@@ -34,9 +33,8 @@ package body attribute is
ui.draw_tiny_menu (move_x, move_y, width, height, true);
ui.draw_title_bar (move_x, move_y, width, "Attributes");
--
for index in enumeration
loop
ui.draw_icon (sprite (index), trait (index).text, move_x + offset, move_y + offset + enumeration'pos (index) * core.icon);
for index in enumeration loop
ui.draw_icon (sprite (index), trait (index).text, move_x + offset, move_y + offset + enumeration'pos (index) * core.icon);
ui.write (trait (index).name, move_x + offset + core.icon, move_y + offset + enumeration'pos (index) * core.icon);
end loop;
end menu;


+ 3
- 6
source/attribute.ads Vedi File

@@ -14,16 +14,13 @@ package attribute is

------------------------------------------------------------------------------------------

subtype base_limit is natural range 0 .. 12;

type information is
record
type information is record
name : core.short_string;
base : base_limit;
base : natural;
text : core.long_string;
end record;

type points is array (enumeration) of base_limit;
type points is array (enumeration) of natural;

------------------------------------------------------------------------------------------



+ 1
- 2
source/chad.adb Vedi File

@@ -16,8 +16,7 @@ package body chad is
begin
core.echo (core.comment, "Configuring chad components...");
--
for index in enumeration
loop
for index in enumeration loop
--~sprite (index) := core.import_sprite ("./sprite/chad/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);
null;
end loop;


+ 2
- 4
source/chad.ads Vedi File

@@ -14,8 +14,7 @@ package chad is

------------------------------------------------------------------------------------------

type information is
record
type information is record
name : core.short_string;
kind : faction.enumeration;
bonus_attribute : attribute.enumeration;
@@ -23,8 +22,7 @@ package chad is
bonus_resource : resource.enumeration;
end record;

type data is
record
type data is record
index : enumeration;
attributes : attribute.points;
skills : skill.points;


+ 3
- 5
source/construction.adb Vedi File

@@ -16,11 +16,9 @@ package body construction is
begin
core.echo (core.comment, "Configuring construction components...");
--
for index in enumeration
loop
declare
folder : constant string := core.lowercase (faction.enumeration'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
for index in enumeration loop
declare folder : constant string := core.lowercase (faction.enumeration'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
begin
sprite (index) := core.import_sprite ("./sprite/construction/" & folder & "/" & file & ".png", trait (index).frames, 1);
end;


+ 1
- 2
source/construction.ads Vedi File

@@ -14,8 +14,7 @@ package construction is

------------------------------------------------------------------------------------------

type information is
record
type information is record
name : core.short_string;
kind : faction.enumeration;
price : resource.points;


+ 27
- 27
source/core.adb Vedi File

@@ -53,13 +53,13 @@ package body core is
--
put ("[");
case status is
when failure => terminal (red, bold); put ("Failure");
when warning => terminal (yellow, bold); put ("Warning");
when success => terminal (green, bold); put ("Success");
when comment => terminal (grey, bold); put ("Comment");
when import => terminal (cyan, bold); put (" <-- ");
when export => terminal (blue, bold); put (" --> ");
end case; terminal;
when failure => terminal (red, bold); put ("Failure"); terminal;
when warning => terminal (yellow, bold); put ("Warning"); terminal;
when success => terminal (green, bold); put ("Success"); terminal;
when comment => terminal (grey, bold); put ("Comment"); terminal;
when import => terminal (cyan, bold); put (" <-- "); terminal;
when export => terminal (blue, bold); put (" --> "); terminal;
end case;
put ("] ");
--
put_line (text);
@@ -105,8 +105,9 @@ package body core is

function clip (value, minimum, maximum : in integer) return integer is
begin
if value < minimum then return minimum; end if;
if value > maximum then return maximum; end if;
if value < minimum then return minimum; end if;
if value > maximum then return maximum; end if;
--
return value;
end clip;

@@ -200,8 +201,7 @@ package body core is
function lowercase (text : in string) return string is
result : string (1 .. text'length);
begin
for index in text'range
loop
for index in text'range loop
if text (index) in 'A' .. 'Z' then
result (index) := character'val (character'pos (text (index)) + 32);
else
@@ -315,22 +315,22 @@ package body core is
when 65 .. 90 => signal_mode := signal - 65 + signal_code'pos (signal_a);
when 320 .. 329 => signal_mode := signal - 320 + signal_code'pos (signal_kp_0);
--
when 0 => signal_mode := signal_code'pos (signal_none);
when 32 => signal_mode := signal_code'pos (signal_space);
when 96 => signal_mode := signal_code'pos (signal_grave);
when 340 => signal_mode := signal_code'pos (signal_left_shift);
when 341 => signal_mode := signal_code'pos (signal_left_control);
when 333 => signal_mode := signal_code'pos (signal_kp_subtract);
when 334 => signal_mode := signal_code'pos (signal_kp_add);
when 256 => signal_mode := signal_code'pos (signal_escape);
when 257 => signal_mode := signal_code'pos (signal_enter);
when 258 => signal_mode := signal_code'pos (signal_tab);
when 259 => signal_mode := signal_code'pos (signal_backspace);
when 262 => signal_mode := signal_code'pos (signal_right);
when 263 => signal_mode := signal_code'pos (signal_left);
when 264 => signal_mode := signal_code'pos (signal_down);
when 265 => signal_mode := signal_code'pos (signal_up);
when others => signal_mode := signal_code'pos (signal_none);
when 0 => signal_mode := signal_code'pos (signal_none);
when 32 => signal_mode := signal_code'pos (signal_space);
when 96 => signal_mode := signal_code'pos (signal_grave);
when 340 => signal_mode := signal_code'pos (signal_left_shift);
when 341 => signal_mode := signal_code'pos (signal_left_control);
when 333 => signal_mode := signal_code'pos (signal_kp_subtract);
when 334 => signal_mode := signal_code'pos (signal_kp_add);
when 256 => signal_mode := signal_code'pos (signal_escape);
when 257 => signal_mode := signal_code'pos (signal_enter);
when 258 => signal_mode := signal_code'pos (signal_tab);
when 259 => signal_mode := signal_code'pos (signal_backspace);
when 262 => signal_mode := signal_code'pos (signal_right);
when 263 => signal_mode := signal_code'pos (signal_left);
when 264 => signal_mode := signal_code'pos (signal_down);
when 265 => signal_mode := signal_code'pos (signal_up);
when others => signal_mode := signal_code'pos (signal_none);
end case;
--
ray.begin_drawing;


+ 2
- 5
source/deity.ads Vedi File

@@ -15,12 +15,9 @@ package deity is

------------------------------------------------------------------------------------------

subtype piety_limit is integer range -30 .. 30;

type information is
record
type information is record
name : core.short_string;
base : piety_limit;
base : integer;
end record;

------------------------------------------------------------------------------------------


+ 1
- 2
source/effect.ads Vedi File

@@ -14,8 +14,7 @@ package effect is

------------------------------------------------------------------------------------------

type information is
record
type information is record
name : core.short_string;
make : boolean;
end record;


+ 1
- 2
source/faction.ads Vedi File

@@ -15,8 +15,7 @@ package faction is

------------------------------------------------------------------------------------------

type information is
record
type information is record
name : core.short_string;
bonus_attribute : attribute.enumeration;
bonus_skill : skill.enumeration;


+ 3
- 5
source/item.adb Vedi File

@@ -16,11 +16,9 @@ package body item is
begin
core.echo (core.comment, "Configuring item components...");
--
for index in enumeration
loop
declare
folder : constant string := core.lowercase (slot'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
for index in enumeration loop
declare folder : constant string := core.lowercase (slot'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
begin
sprite (index) := core.import_sprite ("./sprite/item/" & folder & "/" & file & ".png", 4, 6);
end;


+ 4
- 7
source/magic.adb Vedi File

@@ -20,11 +20,9 @@ package body magic is
begin
core.echo (core.comment, "Configuring magic components...");
--
for index in enumeration
loop
declare
folder : constant string := core.lowercase (school'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
for index in enumeration loop
declare folder : constant string := core.lowercase (school'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
begin
view_sprite (index) := core.import_sprite ("./sprite/magic/" & folder & "/" & file & ".png", 1, 1);
icon_sprite (index) := core.import_sprite ("./sprite/magic/icon/" & file & ".png", 1, 1);
@@ -63,8 +61,7 @@ package body magic is
ui.draw_tiny_menu (move_x, move_y, width, height, true);
ui.draw_title_bar (move_x, move_y, width, "Magic Abilities");
--
for index in enumeration
loop
for index in enumeration loop
icon (index, move_x + offset + school'pos (trait (index).kind) * 168, move_y + offset + next (school'pos (trait (index).kind)) * core.icon);
ui.write (trait (index).name, move_x + offset + school'pos (trait (index).kind) * 168 + core.icon, move_y + offset + next (school'pos (trait (index).kind)) * core.icon);
--


+ 1
- 2
source/magic.ads Vedi File

@@ -43,8 +43,7 @@ package magic is

subtype level_limit is natural range 0 .. 6;

type information is
record
type information is record
name : core.short_string;
kind : school;
level : level_limit;


+ 1
- 2
source/main.adb Vedi File

@@ -54,8 +54,7 @@ procedure main is
core.overlay;
end if;
--
for index in 1 .. menu_limit
loop
for index in 1 .. menu_limit loop
case menu_stack (index) is
when menu_none => null;
when menu_attribute => attribute.menu (100, 100, false);


+ 4
- 7
source/might.adb Vedi File

@@ -20,11 +20,9 @@ package body might is
begin
core.echo (core.comment, "Configuring might components...");
--
for index in enumeration
loop
declare
folder : constant string := core.lowercase (school'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
for index in enumeration loop
declare folder : constant string := core.lowercase (school'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
begin
view_sprite (index) := core.import_sprite ("./sprite/might/" & folder & "/" & file & ".png", 1, 1);
icon_sprite (index) := core.import_sprite ("./sprite/might/icon/" & file & ".png", 1, 1);
@@ -63,8 +61,7 @@ package body might is
ui.draw_tiny_menu (move_x, move_y, width, height, true);
ui.draw_title_bar (move_x, move_y, width, "Might Abilities");
--
for index in enumeration
loop
for index in enumeration loop
icon (index, move_x + offset + school'pos (trait (index).kind) * 168, move_y + offset + next (school'pos (trait (index).kind)) * core.icon);
ui.write (trait (index).name, move_x + offset + school'pos (trait (index).kind) * 168 + core.icon, move_y + offset + next (school'pos (trait (index).kind)) * core.icon);
--


+ 1
- 2
source/might.ads Vedi File

@@ -42,8 +42,7 @@ package might is

subtype level_limit is natural range 0 .. 6;

type information is
record
type information is record
name : core.short_string;
kind : school;
level : level_limit;


+ 2
- 4
source/resource.adb Vedi File

@@ -16,8 +16,7 @@ package body resource is
begin
core.echo (core.comment, "Configuring resource components...");
--
for index in enumeration
loop
for index in enumeration loop
sprite (index) := core.import_sprite ("./sprite/resource/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);
end loop;
end configure;
@@ -34,8 +33,7 @@ package body resource is
ui.draw_tiny_menu (move_x, move_y, width, height, true);
ui.draw_title_bar (move_x, move_y, width, "Resources");
--
for index in enumeration
loop
for index in enumeration loop
ui.draw_icon (sprite (index), trait (index).text, move_x + offset, move_y + offset + enumeration'pos (index) * core.icon);
ui.write (trait (index).name, move_x + offset + core.icon, move_y + offset + enumeration'pos (index) * core.icon);
end loop;


+ 3
- 6
source/resource.ads Vedi File

@@ -14,16 +14,13 @@ package resource is

------------------------------------------------------------------------------------------

subtype base_limit is natural range 0 .. 144000;

type information is
record
type information is record
name : core.short_string;
base : base_limit;
base : natural;
text : core.long_string;
end record;

type points is array (enumeration) of base_limit;
type points is array (enumeration) of natural;

------------------------------------------------------------------------------------------



+ 2
- 4
source/skill.adb Vedi File

@@ -16,8 +16,7 @@ package body skill is
begin
core.echo (core.comment, "Configuring skill components...");
--
for index in enumeration
loop
for index in enumeration loop
sprite (index) := core.import_sprite ("./sprite/skill/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);
end loop;
end configure;
@@ -35,8 +34,7 @@ package body skill is
ui.draw_tiny_menu (move_x, move_y, width, height, true);
ui.draw_title_bar (move_x, move_y, width, "Skills");
--
for index in enumeration
loop
for index in enumeration loop
ui.draw_icon (sprite (index), trait (index).text, move_x + 216 * (enumeration'pos (index) mod column) + offset, move_y + core.icon * (enumeration'pos (index) / column) + offset);
ui.write (trait (index).name, move_x + 216 * (enumeration'pos (index) mod column) + offset + core.icon, move_y + core.icon * (enumeration'pos (index) / column) + offset);
end loop;


+ 3
- 6
source/skill.ads Vedi File

@@ -15,16 +15,13 @@ package skill is

------------------------------------------------------------------------------------------

subtype base_limit is natural range 0 .. 36;

type information is
record
type information is record
name : core.short_string;
base : base_limit;
base : natural;
text : core.long_string;
end record;

type points is array (enumeration) of base_limit;
type points is array (enumeration) of natural;

------------------------------------------------------------------------------------------



+ 14
- 23
source/ui.adb Vedi File

@@ -44,8 +44,7 @@ package body ui is
procedure draw_horizontally (index : in enumeration; x, y, width : in integer) is
base : constant integer := sprite (active, index).width;
begin
for move in 0 .. width / base - 1
loop
for move in 0 .. width / base - 1 loop
draw (index, x + move * base, y);
end loop;
--
@@ -57,8 +56,7 @@ package body ui is
procedure draw_vertically (index : in enumeration; x, y, height : in integer) is
base : constant integer := sprite (active, index).height;
begin
for move in 0 .. height / base - 1
loop
for move in 0 .. height / base - 1 loop
draw (index, x, y + move * base);
end loop;
--
@@ -73,18 +71,15 @@ package body ui is
crop_width : integer := width mod base_width;
crop_height : integer := height mod base_height;
begin
for move_y in 0 .. height / base_height - 1
loop
for move_x in 0 .. width / base_width - 1
loop
for move_y in 0 .. height / base_height - 1 loop
for move_x in 0 .. width / base_width - 1 loop
draw (index, x + move_x * base_width, y + move_y * base_height);
end loop;
--
crop (index, x + width - crop_width, y + move_y * base_height, 0, 0, crop_width, base_height);
end loop;
--
for move_x in 0 .. width / base_width - 1
loop
for move_x in 0 .. width / base_width - 1 loop
crop (index, x + move_x * base_width, y + height - crop_height, 0, 0, base_width, crop_height);
end loop;
--
@@ -98,8 +93,7 @@ package body ui is
begin
glyphs (index) := core.import_font ("./sprite/ui/" & folder_path & "/font.png", (if index = default then 16 else 24), 0);
--
for this in enumeration
loop
for this in enumeration loop
sprite (index, this) := core.import_sprite ("./sprite/ui/" & folder_path & core.lowercase (enumeration'image (this)) & ".png", 1, 1);
end loop;
end load_ui;
@@ -120,7 +114,6 @@ package body ui is
core.zoom := 1;
core.draw (data, x, y);
core.zoom := 2;
--
end draw_icon;

------------------------------------------------------------------------------------------
@@ -220,11 +213,10 @@ package body ui is
draw_background (main_background, x + offset, y + offset, width - 2 * offset, height - 2 * offset);
end if;
--
declare
upper : constant integer := width - sprite (active, corner_upper_left).width - sprite (active, corner_upper_right).width;
lower : constant integer := width - sprite (active, corner_lower_left).width - sprite (active, corner_lower_right).width;
left : constant integer := height - sprite (active, corner_upper_left).height - sprite (active, corner_lower_left).height;
right : constant integer := height - sprite (active, corner_upper_right).height - sprite (active, corner_lower_right).height;
declare upper : constant integer := width - sprite (active, corner_upper_left).width - sprite (active, corner_upper_right).width;
lower : constant integer := width - sprite (active, corner_lower_left).width - sprite (active, corner_lower_right).width;
left : constant integer := height - sprite (active, corner_upper_left).height - sprite (active, corner_lower_left).height;
right : constant integer := height - sprite (active, corner_upper_right).height - sprite (active, corner_lower_right).height;
begin
draw_horizontally (border_upper, x + sprite (active, corner_upper_left).width, y, upper);
draw_horizontally (border_lower, x + sprite (active, corner_lower_left).width, y + height - sprite (active, border_lower).height, lower);
@@ -256,11 +248,10 @@ package body ui is
draw_background (main_background, x + offset, y + offset, width - 2 * offset, height - 2 * offset);
end if;
--
declare
upper : constant integer := width - sprite (active, tiny_corner_upper_left).width - sprite (active, tiny_corner_upper_right).width;
lower : constant integer := width - sprite (active, tiny_corner_lower_left).width - sprite (active, tiny_corner_lower_right).width;
left : constant integer := height - sprite (active, tiny_corner_upper_left).height - sprite (active, tiny_corner_lower_left).height;
right : constant integer := height - sprite (active, tiny_corner_upper_right).height - sprite (active, tiny_corner_lower_right).height;
declare upper : constant integer := width - sprite (active, tiny_corner_upper_left).width - sprite (active, tiny_corner_upper_right).width;
lower : constant integer := width - sprite (active, tiny_corner_lower_left).width - sprite (active, tiny_corner_lower_right).width;
left : constant integer := height - sprite (active, tiny_corner_upper_left).height - sprite (active, tiny_corner_lower_left).height;
right : constant integer := height - sprite (active, tiny_corner_upper_right).height - sprite (active, tiny_corner_lower_right).height;
begin
draw_horizontally (tiny_border_upper, x + sprite (active, tiny_corner_upper_left).width, y, upper);
draw_horizontally (tiny_border_lower, x + sprite (active, tiny_corner_lower_left).width, y + height - sprite (active, tiny_border_lower).height, lower);


+ 5
- 9
source/unit.adb Vedi File

@@ -21,11 +21,9 @@ package body unit is
begin
core.echo (core.comment, "Configuring unit components...");
--
for index in enumeration
loop
declare
folder : constant string := core.lowercase (faction.enumeration'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
for index in enumeration loop
declare folder : constant string := core.lowercase (faction.enumeration'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
begin
sprite (index) := core.import_sprite ("./sprite/unit/" & folder & "/" & file & ".png", 4, 6);
icon_sprite (index) := core.import_sprite ("./sprite/unit/icon/" & file & ".png", 1, 1);
@@ -71,8 +69,7 @@ package body unit is
ui.draw_tiny_menu (move_x, move_y, width, height, true);
ui.draw_title_bar (move_x, move_y, width, "Units");
--
for index in enumeration
loop
for index in enumeration loop
move := faction.enumeration'pos (trait (index).kind) * 168;
--
icon (index, move_x + offset + move, move_y + offset + (enumeration'pos (index) mod 14) * core.icon);
@@ -104,8 +101,7 @@ package body unit is
--~ui.write (trait (index).attributes (data)'image, move_x + view_width + 12 + offset + core.icon, move_y + offset + move);
--~end loop;
--
for animate in animation
loop
for animate in animation loop
draw (index, animate, move_x + offset + animation'pos (animate) * (sprite (index).width + 8), move_y + offset + 8 + core.icon * attribute.count);
ui.draw_icon_menu (trait (index).text, move_x + offset + animation'pos (animate) * (sprite (index).width + 8), move_y + offset + 8 + core.icon * attribute.count, sprite (index).width, sprite (index).height);
end loop;


+ 1
- 2
source/unit.ads Vedi File

@@ -18,8 +18,7 @@ package unit is

------------------------------------------------------------------------------------------

type information is
record
type information is record
name : core.short_string;
kind : faction.enumeration;
attributes : attribute.points;


Loading…
Annulla
Salva