Skip to content

Commit

Permalink
refactor: continue work on move updateModulesInfo to Nim
Browse files Browse the repository at this point in the history
FossilOrigin-Name: a9fbb3ddf3cede827d3c8a8ee739c8f0dc4c5ba174146a653a2939402bdba6d9
  • Loading branch information
thindil committed Nov 20, 2023
1 parent f73c8a4 commit e8cf7a9
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions nim/src/ui/shipsuimodules.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with Steam Sky. If not, see <http://www.gnu.org/licenses/>.

import std/tables
import ../[game, config, crafts, types]
import ../[game, config, crafts, tk, types]
import coreui, table

var
Expand Down Expand Up @@ -109,7 +109,9 @@ proc updateModulesInfo*(page: Positive = 1) =
modulesIndexes.add(index)
clearTable(modulesTable)
let startRow = ((page - 1) * gameSettings.listsLimit) + 1
var currentRow = 1
var
currentRow = 1
row = 2
for index in modulesIndexes:
if currentRow < startRow:
currentRow.inc
Expand All @@ -124,3 +126,22 @@ proc updateModulesInfo*(page: Positive = 1) =
addButton(table = modulesTable, text = getModuleInfo(moduleIndex = index),
tooltip = "Show the module's info", command = "ShowModuleInfo " &
$index, column = 3, newRow = true)
row.inc
if modulesTable.row == gameSettings.listsLimit + 1:
break
if page > 1:
if modulesTable.row < gameSettings.listsLimit + 1:
addPagination(table = modulesTable, previousCommand = "ShowModules " &
$(page - 1))
else:
addPagination(table = modulesTable, previousCommand = "ShowModules " &
$(page - 1), nextCommand = "ShowModules " & $(page + 1))
elif modulesTable.row == gameSettings.listsLimit + 1:
addPagination(table = modulesTable, nextCommand = "ShowModules " & $(
page + 1))
updateTable(table = modulesTable)
tclEval(script = "update")
tclEval(script = shipCanvas & " configure -scrollregion [list " & tclEval2(
script = shipCanvas & " bbox all") & "]")
tclEval(script = shipCanvas & " xview moveto 0.0")
tclEval(script = shipCanvas & " yview moveto 0.0")

0 comments on commit e8cf7a9

Please sign in to comment.