Skip to content

Commit

Permalink
refactor: moved setDestination2Command to Nim
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 5eb36610f2ef76ae7860f9f5e09d75d58d189093ee5b1a89bc9ab2882e379be2
  • Loading branch information
thindil committed Sep 21, 2024
1 parent c48f1a0 commit 09a348b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions nim/src/ui/utilsui.nim
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,23 @@ proc setScrollbarBindingsCommand(clientData: cint; interp: PInterp; argc: cint;
scrollbar & "]} {event generate " & scrollbar & " <MouseWheel> -delta %D}}")
return tclOk

proc setDestination2Command(clientData: cint; interp: PInterp; argc: cint;
argv: cstringArray): TclResults {.exportc.} =
let
posX = ($argv[1]).parseInt
posY = ($argv[2]).parseInt
if posX == playerShip.skyX and posY == playerShip.skyY:
showMessage(text = "You are at this location now.",
title = "Can't set destination")
return tclOk
playerShip.destinationX = posX
playerShip.destinationY = posY
addMessage(message = "You set the travel destination for your ship.",
mType = orderMessage)
tclEval(script = "InvokeButton " & closeButton)
tclEval(script = "grid remove " & closeButton)
return tclOk

proc addCommands*() {.sideEffect, raises: [], tags: [].} =
## Add Tcl commands related to the various UI elements
discard
Expand All @@ -428,6 +445,7 @@ proc addCommands*() {.sideEffect, raises: [], tags: [].} =
# addCommand("ShowOnMap", showOnMapCommand)
# addCommand("ProcessQuestion", processQuestionCommand)
# addCommand("SetScrollbarBindings", setScrollbarBindingsCommand)
# addCommand("SetDestination2", setDestination2Command)

# Temporary code for interfacing with Ada

Expand Down

0 comments on commit 09a348b

Please sign in to comment.