Skip to content

Commit

Permalink
fix: some problems with showing info about the map cell
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 19e9d304a98fd8c762759f31eeee1b1e84357c22645cf2862f61d3ae08349a19
  • Loading branch information
thindil committed Jan 19, 2024
1 parent 29d3434 commit fbeca56
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions nim/src/ui/mapsui.nim
Original file line number Diff line number Diff line change
Expand Up @@ -564,20 +564,20 @@ proc updateMapInfo*(x: Positive = playerShip.skyX;

insertText(newText = "X:")
insertText(newText = " " & $x, tagName = "yellow2")
insertText(newText = "Y:")
insertText(newText = " Y:")
insertText(newText = " " & $y, tagName = "yellow2")
if playerShip.skyX != y or playerShip.skyY != y:
if playerShip.skyX != x or playerShip.skyY != y:
let
distance = countDistance(destinationX = x, destinationY = y)
travelValues = travelInfo(distance = distance)
insertText(newText = "\nDistance:")
insertText(newText = "\nDistance: ")
insertText(newText = $distance, tagName = "yellow2")
if travelValues[1] > 0:
insertText(newText = "\nETA:")
var distanceText = ""
minutesToDate(minutes = travelValues[1], infoText = distanceText)
insertText(newText = distanceText, tagName = "yellow2")
insertText(newText = "\nApprox fuel usage:")
insertText(newText = "\nApprox fuel usage: ")
insertText(newText = $travelValues[2], tagName = "yellow2")
if skyMap[x][y].baseIndex > 0:
let baseIndex = skyMap[x][y].baseIndex
Expand Down
4 changes: 3 additions & 1 deletion nim/src/ui/utilsui2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ proc getSkillMarks*(skillIndex: Positive;
if memberIndex == crewIndex:
result = result & "+"

proc travelInfo*(distance: Positive): array[1 .. 2, Natural] {.sideEffect,
proc travelInfo*(distance: Natural): array[1 .. 2, Natural] {.sideEffect,
raises: [], tags: [].} =
## Count the ETA and the fuel usage for the selected distance
##
Expand All @@ -138,6 +138,8 @@ proc travelInfo*(distance: Positive): array[1 .. 2, Natural] {.sideEffect,
## travel the distance, the second is the amount of fuel needed to travel
## the distance.
result = [0, 0]
if distance == 0:
return
let speed = try:
realSpeed(ship = playerShip, infoOnly = true) / 1_000
except:
Expand Down
1 change: 1 addition & 0 deletions src/ui/maps-ui.adb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ package body Maps.UI is
-- else " [list " & To_String(Source => Tag_Name) & "]"));
-- end Insert_Text;
begin
Get_Ada_Ship;
Update_Ada_Map_Info(X1 => X, Y1 => Y);
-- configure(Widgt => Map_Info, options => "-state normal");
-- Delete(TextWidget => Map_Info, StartIndex => "1.0", Indexes => "end");
Expand Down

0 comments on commit fbeca56

Please sign in to comment.