Skip to content

Commit

Permalink
fix: setting current position on map
Browse files Browse the repository at this point in the history
FossilOrigin-Name: aea233cc722c1f786c4ccc89b5eaebf05ea95a391104b5b4b3b955faeb75d60b
  • Loading branch information
thindil committed Jan 15, 2024
1 parent 50d9518 commit 14b46d4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
39 changes: 39 additions & 0 deletions src/ui/maps-ui.adb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,45 @@ package body Maps.UI is
return Map_View;
end Get_Map_View;

procedure Draw_Map is
Center_X, Center_Y: Positive;
Map_Height, Map_Width: Positive;
End_X, End_Y: Integer;
procedure Draw_Ada_Map with
Import => True,
Convention => C,
External_Name => "drawAdaMap";
begin
Get_Center_Point(X => Center_X, Y => Center_Y);
Map_Height :=
Positive'Value(cget(Widgt => Get_Map_View, option => "-height"));
Map_Width :=
Positive'Value(cget(Widgt => Get_Map_View, option => "-width"));
--## rule off SIMPLIFIABLE_EXPRESSIONS
Start_Y := Center_Y - (Map_Height / 2);
Start_X := Center_X - (Map_Width / 2);
End_Y := Center_Y + (Map_Height / 2);
End_X := Center_X + (Map_Width / 2);
--## rule on SIMPLIFIABLE_EXPRESSIONS
if Start_Y < 1 then
Start_Y := 1;
End_Y := Map_Height;
end if;
if Start_X < 1 then
Start_X := 1;
End_X := Map_Width;
end if;
if End_Y > 1_024 then
End_Y := 1_024;
Start_Y := 1_025 - Map_Height;
end if;
if End_X > 1_024 then
End_X := 1_024;
Start_X := 1_025 - Map_Width;
end if;
Draw_Ada_Map;
end Draw_Map;

-- procedure Draw_Map is
-- use Ada.Strings.UTF_Encoding.Wide_Strings;
--
Expand Down
5 changes: 1 addition & 4 deletions src/ui/maps-ui.ads
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ package Maps.UI is
-- FUNCTION
-- Draw map on the screen
-- SOURCE
procedure Draw_Map with
Import => True,
Convention => C,
External_Name => "drawAdaMap";
procedure Draw_Map;
-- ****

-- ****f* MUI/MUI.Create_Game_Ui
Expand Down

0 comments on commit 14b46d4

Please sign in to comment.