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: ba476b0d4a14983095e0059ef1258b819c06af6980723227a9fb68d6028588ca
  • Loading branch information
thindil committed Mar 6, 2024
1 parent 7bcabfe commit d978b7d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions nim/src/ui/shipsuimodules.nim
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ proc showModuleInfoCommand(clientData: cint; interp: PInterp; argc: cint;
if shipModule.upgradeAction == upgradeType and playerShip.upgradeModule == moduleIndex:
tclEval(script = "ttk::button " & infoButton &
" -image cancelicon -command {" & closeDialogButton &
" invoke;StopUpgrading " & $argv[1] & "} -style Small.TButton")
" invoke;StopUpgrading " & $(moduleIndex + 1) & "} -style Small.TButton")
tclEval(script = "tooltip::tooltip " & infoButton &
" \"Stop upgrading the " & buttonTooltip & "\"")
else:
tclEval(script = "ttk::button " & infoButton &
" -image upgradebuttonicon -command {" & closeDialogButton &
" invoke;SetUpgrade " & upgradeNumber & " " & $argv[1] & "} -style Small.TButton")
" invoke;SetUpgrade " & upgradeNumber & " " & $(moduleIndex + 1) & "} -style Small.TButton")
tclEval(script = "tooltip::tooltip " & infoButton &
" \"Start upgrading the " & buttonTooltip & "\"")
tclEval(script = "grid " & infoButton & " -row " & $row & " -column " &
Expand All @@ -169,6 +169,18 @@ proc showModuleInfoCommand(clientData: cint; interp: PInterp; argc: cint;
addLabel(name = moduleFrame & ".lblsize2", labelText = $modulesList[
module.protoIndex].size, row = currentRow, column = 1, countHeight = true,
secondary = true)
# Show the module's repair material
currentRow.inc
addLabel(name = moduleFrame & ".lblrepairmaterial",
labelText = "Repair material: ", row = currentRow, wrapLength = 200)
let moduleText = moduleFrame & ".info"
tclEval(script = "text " & moduleText & " -wrap char -height 5 -width 30")
tclEval(script = moduleText & " tag configure red -foreground " & tclGetVar(
varName = "ttk::theme::" & gameSettings.interfaceTheme &
"::colors(-red)"))
tclEval(script = moduleText & " tag configure gold -foreground " & tclGetVar(
varName = "ttk::theme::" & gameSettings.interfaceTheme &
"::colors(-goldenyellow)"))
return tclOk

proc getModuleInfo(moduleIndex: Natural): string {.sideEffect, raises: [],
Expand Down

0 comments on commit d978b7d

Please sign in to comment.