Skip to content

Commit

Permalink
refactor: continue work on move showModuleInfoCommand to Nim
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 3b283671d0f8a3525fa6c56d2540e580535c7e9dce5bf784abd9a9be3b18f104
  • Loading branch information
thindil committed Mar 7, 2024
1 parent f906cb5 commit 43cb5f2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nim/src/ui/shipsuimodules.nim
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ proc showModuleInfoCommand(clientData: cint; interp: PInterp; argc: cint;
" -image cancelicon -command {" & closeDialogButton &
" invoke;StopUpgrading " & $argv[1] & "} -style Small.TButton")
tclEval(script = "tooltip::tooltip " & infoButton & " \"Stop upgrading cabin quality\"")
tclEval(script = "grid " & infoButton & " -row " & $currentRow & " -column 2 -sticky n -padx {5 0}")
tclEval(script = "bind " & infoButton & " <Escape> {" &
closeDialogButton & " invoke; break}")
height = height + tclEval2(script = "winfo reqheight " &
Expand All @@ -289,6 +290,23 @@ proc showModuleInfoCommand(clientData: cint; interp: PInterp; argc: cint;
ownersText.add(", ")
haveOwner = true
ownersText.add(playerShip.crew[owner].name)
if not haveOwner:
ownersText.add("none")
addLabel(name = moduleFrame & ".lblowners2", labelText = ownersText,
row = row, column = 1, secondary = true)
if addButton:
infoButton = moduleFrame & ".ownersbutton"
tclEval(script = "ttk::button " & infoButton &
" -image cancelicon -command {" & closeDialogButton &
" invoke;ShowAssignCrew " & $(moduleIndex + 1) & "} -style Small.TButton")
tclEval(script = "tooltip::tooltip " & infoButton & " \"Assign crew members to the module.\"")
tclEval(script = "grid " & infoButton & " -row " & $row & " -column 2 -sticky n -padx {5 0}")
tclEval(script = "bind " & infoButton & " <Escape> {" &
closeDialogButton & " invoke; break}")
tclEval(script = "SetScrollbarBindings " & infoButton & " " & yScroll)
height = height + tclEval2(script = "winfo reqheight " &
infoButton).parseInt


# Show information specific to the module's type
case module.mType
Expand Down Expand Up @@ -373,6 +391,7 @@ proc showModuleInfoCommand(clientData: cint; interp: PInterp; argc: cint;
infoButton).parseInt
# Show information about cabin
of cabin:
# Show information about cabin's owners
currentRow.inc
var isPassenger = false
block missionLoop:
Expand All @@ -382,6 +401,8 @@ proc showModuleInfoCommand(clientData: cint; interp: PInterp; argc: cint;
if mission.data == owner:
isPassenger = true
break missionLoop
addOwnersInfo(ownersName = "Owner", addButton = not isPassenger,
row = currentRow)
else:
discard
return tclOk
Expand Down

0 comments on commit 43cb5f2

Please sign in to comment.