mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 11:28:03 +07:00
fix civilopedia category bug. (#8084)
* fix civilopedia category bug. * fix negative index.
This commit is contained in:
parent
cfedaeb0e3
commit
220c465a18
@ -291,11 +291,26 @@ class CivilopediaScreen(
|
|||||||
else
|
else
|
||||||
selectEntry(link, noScrollAnimation = true)
|
selectEntry(link, noScrollAnimation = true)
|
||||||
|
|
||||||
for (categoryKey in CivilopediaCategories.values()) {
|
for (categoryKey in categoryToEntries.keys) {
|
||||||
globalShortcuts.add(categoryKey.key) { navigateCategories(categoryKey.key) }
|
globalShortcuts.add(categoryKey.key) { navigateCategories(categoryKey.key) }
|
||||||
}
|
}
|
||||||
globalShortcuts.add(Input.Keys.LEFT) { selectCategory(currentCategory.getByOffset(-1)) }
|
globalShortcuts.add(Input.Keys.LEFT) {
|
||||||
globalShortcuts.add(Input.Keys.RIGHT) { selectCategory(currentCategory.getByOffset(1)) }
|
val categoryKey = categoryToEntries.keys
|
||||||
|
val currentIndex = categoryKey.indexOf(currentCategory)
|
||||||
|
val targetCategory = categoryKey.elementAt(
|
||||||
|
(currentIndex + categoryKey.size - 1) % categoryKey.size
|
||||||
|
)
|
||||||
|
selectCategory(targetCategory)
|
||||||
|
}
|
||||||
|
globalShortcuts.add(Input.Keys.RIGHT) {
|
||||||
|
val categoryKey = categoryToEntries.keys
|
||||||
|
val currentIndex = categoryKey.indexOf(currentCategory)
|
||||||
|
val targetCategory = categoryKey.elementAt(
|
||||||
|
(currentIndex + categoryKey.size + 1) % categoryKey.size
|
||||||
|
)
|
||||||
|
selectCategory(targetCategory)
|
||||||
|
|
||||||
|
}
|
||||||
globalShortcuts.add(Input.Keys.UP) { navigateEntries(-1) }
|
globalShortcuts.add(Input.Keys.UP) { navigateEntries(-1) }
|
||||||
globalShortcuts.add(Input.Keys.DOWN) { navigateEntries(1) }
|
globalShortcuts.add(Input.Keys.DOWN) { navigateEntries(1) }
|
||||||
globalShortcuts.add(Input.Keys.PAGE_UP) { navigateEntries(-10) }
|
globalShortcuts.add(Input.Keys.PAGE_UP) { navigateEntries(-10) }
|
||||||
|
Loading…
Reference in New Issue
Block a user