Skip to content

Commit 57fd00a

Browse files
authored
Add queuing functionality (yairm210#10609)
1 parent 4b261a9 commit 57fd00a

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

core/src/com/unciv/ui/screens/pickerscreens/TechPickerScreen.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.unciv.ui.components.extensions.surroundWithCircle
2222
import com.unciv.ui.components.extensions.toLabel
2323
import com.unciv.ui.components.fonts.Fonts
2424
import com.unciv.ui.components.input.onClick
25+
import com.unciv.ui.components.input.onRightClick
2526
import com.unciv.ui.components.input.onDoubleClick
2627
import com.unciv.ui.images.ImageGetter
2728
import com.unciv.ui.popups.ToastPopup
@@ -95,7 +96,7 @@ class TechPickerScreen(
9596
if (tech != null) {
9697
// select only if there it doesn't mess up tempTechsToResearch
9798
if (civInfo.tech.isResearched(tech.name) || civInfo.tech.techsToResearch.size <= 1)
98-
selectTechnology(tech, true)
99+
selectTechnology(tech, queue = false, center = true)
99100
else centerOnTechnology(tech)
100101
} else {
101102
// center on any possible technology which is ready for the research right now
@@ -191,7 +192,8 @@ class TechPickerScreen(
191192
val techButton = TechButton(tech.name, civTech, false)
192193
table.add(techButton)
193194
techNameToButton[tech.name] = techButton
194-
techButton.onClick { selectTechnology(tech, false) }
195+
techButton.onClick { selectTechnology(tech, queue = false, center = false) }
196+
techButton.onRightClick { selectTechnology(tech, queue = true, center = false) }
195197
techButton.onDoubleClick(UncivSound.Paper) { tryExit() }
196198
techTable.add(table).fillX()
197199
}
@@ -364,7 +366,7 @@ class TechPickerScreen(
364366
orderIndicators.toFront()
365367
}
366368

367-
private fun selectTechnology(tech: Technology?, center: Boolean = false, switchFromWorldScreen: Boolean = true) {
369+
private fun selectTechnology(tech: Technology?, queue: Boolean = false, center: Boolean = false, switchFromWorldScreen: Boolean = true) {
368370

369371
val previousSelectedTech = selectedTech
370372
selectedTech = tech
@@ -412,8 +414,16 @@ class TechPickerScreen(
412414
}
413415
}
414416

415-
tempTechsToResearch.clear()
416-
tempTechsToResearch.addAll(pathToTech.map { it.name })
417+
if(queue){
418+
for (pathTech in pathToTech) {
419+
if (pathTech.name !in tempTechsToResearch) {
420+
tempTechsToResearch.add(pathTech.name)
421+
}
422+
}
423+
}else{
424+
tempTechsToResearch.clear()
425+
tempTechsToResearch.addAll(pathToTech.map { it.name })
426+
}
417427

418428
val label = "Research [${tempTechsToResearch[0]}]".tr()
419429
val techProgression = getTechProgressLabel(tempTechsToResearch)

0 commit comments

Comments
 (0)