From 09a348ba8386053f0e9089065d15be19b6c32eb7 Mon Sep 17 00:00:00 2001 From: thindil Date: Sat, 21 Sep 2024 03:38:49 +0000 Subject: [PATCH] refactor: moved setDestination2Command to Nim FossilOrigin-Name: 5eb36610f2ef76ae7860f9f5e09d75d58d189093ee5b1a89bc9ab2882e379be2 --- nim/src/ui/utilsui.nim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nim/src/ui/utilsui.nim b/nim/src/ui/utilsui.nim index 372c12cbc..d2258bf4d 100644 --- a/nim/src/ui/utilsui.nim +++ b/nim/src/ui/utilsui.nim @@ -418,6 +418,23 @@ proc setScrollbarBindingsCommand(clientData: cint; interp: PInterp; argc: cint; scrollbar & "]} {event generate " & scrollbar & " -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 @@ -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