diff options
author | rexim <reximkut@gmail.com> | 2024-03-14 02:33:53 +0700 |
---|---|---|
committer | rexim <reximkut@gmail.com> | 2024-03-14 02:33:53 +0700 |
commit | ed9fa76925909f94512ef70280b90712e35c3ab7 (patch) | |
tree | 96d4e2a6258a468d37b6b61c43ce7b132aec19e3 /test.adb | |
parent | b081abc78ef9fd0c511b35eeabffdddba61cdd43 (diff) |
Introduce rough implementation of the palette editor
Diffstat (limited to 'test.adb')
-rw-r--r-- | test.adb | 53 |
1 files changed, 39 insertions, 14 deletions
@@ -1,23 +1,48 @@ +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; procedure Test is - type Item_Kind is (Key, Bomb, Checkpoint); - type Item(Kind: Item_Kind := Key) is record - case Kind is - when Key | Checkpoint => null; - when Bomb => - Cooldown: Integer; - end case; - end record; - type Map is array (Natural range <>) of Item; - type Map_Access is access Map; + File_Name: constant String := "colors.txt"; + F: File_Type; - Items: Map_Access := null; + function Chop_By(Src: in out Unbounded_String; Pattern: String) return Unbounded_String is + Space_Index: Integer := Index(Src, Pattern); + Result: Unbounded_String; + begin + if Space_Index = 0 then + Result := Src; + Src := Null_Unbounded_String; + else + Result := Unbounded_Slice(Src, 1, Space_Index - 1); + Src := Unbounded_Slice(Src, Space_Index + 1, Length(Src)); + end if; + + return Result; + end; begin - Items := new Map(1..10); - Items(1) := (Kind => Bomb, Cooldown => 10); - Put_Line(Items.all'Image); + Open(F, In_File, File_Name); + while not End_Of_File(F) loop + declare + Line: Unbounded_String := To_Unbounded_String(Get_Line(F)); + begin + Line := Trim(Line, Ada.Strings.Left); + Put_Line('"' & To_String(Chop_By(Line, " ")) & '"'); + + for Times in 1..4 loop + Line := Trim(Line, Ada.Strings.Left); + declare + Token: Unbounded_String := Chop_By(Line, " "); + begin + -- Put_Line(Float'Value(To_String(Token))'Image); + Put_Line(To_String(Token)); + end; + end loop; + end; + Put_Line("------------------------------"); + end loop; + Close(F); end; |