Add queuing functionality (#10609)

This commit is contained in:
Will Allen 2023-11-28 06:37:34 -06:00 committed by GitHub
parent 4b261a9257
commit 57fd00ad14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,7 @@ import com.unciv.ui.components.extensions.surroundWithCircle
import com.unciv.ui.components.extensions.toLabel import com.unciv.ui.components.extensions.toLabel
import com.unciv.ui.components.fonts.Fonts import com.unciv.ui.components.fonts.Fonts
import com.unciv.ui.components.input.onClick import com.unciv.ui.components.input.onClick
import com.unciv.ui.components.input.onRightClick
import com.unciv.ui.components.input.onDoubleClick import com.unciv.ui.components.input.onDoubleClick
import com.unciv.ui.images.ImageGetter import com.unciv.ui.images.ImageGetter
import com.unciv.ui.popups.ToastPopup import com.unciv.ui.popups.ToastPopup
@ -95,7 +96,7 @@ class TechPickerScreen(
if (tech != null) { if (tech != null) {
// select only if there it doesn't mess up tempTechsToResearch // select only if there it doesn't mess up tempTechsToResearch
if (civInfo.tech.isResearched(tech.name) || civInfo.tech.techsToResearch.size <= 1) if (civInfo.tech.isResearched(tech.name) || civInfo.tech.techsToResearch.size <= 1)
selectTechnology(tech, true) selectTechnology(tech, queue = false, center = true)
else centerOnTechnology(tech) else centerOnTechnology(tech)
} else { } else {
// center on any possible technology which is ready for the research right now // center on any possible technology which is ready for the research right now
@ -191,7 +192,8 @@ class TechPickerScreen(
val techButton = TechButton(tech.name, civTech, false) val techButton = TechButton(tech.name, civTech, false)
table.add(techButton) table.add(techButton)
techNameToButton[tech.name] = techButton techNameToButton[tech.name] = techButton
techButton.onClick { selectTechnology(tech, false) } techButton.onClick { selectTechnology(tech, queue = false, center = false) }
techButton.onRightClick { selectTechnology(tech, queue = true, center = false) }
techButton.onDoubleClick(UncivSound.Paper) { tryExit() } techButton.onDoubleClick(UncivSound.Paper) { tryExit() }
techTable.add(table).fillX() techTable.add(table).fillX()
} }
@ -364,7 +366,7 @@ class TechPickerScreen(
orderIndicators.toFront() orderIndicators.toFront()
} }
private fun selectTechnology(tech: Technology?, center: Boolean = false, switchFromWorldScreen: Boolean = true) { private fun selectTechnology(tech: Technology?, queue: Boolean = false, center: Boolean = false, switchFromWorldScreen: Boolean = true) {
val previousSelectedTech = selectedTech val previousSelectedTech = selectedTech
selectedTech = tech selectedTech = tech
@ -412,8 +414,16 @@ class TechPickerScreen(
} }
} }
if(queue){
for (pathTech in pathToTech) {
if (pathTech.name !in tempTechsToResearch) {
tempTechsToResearch.add(pathTech.name)
}
}
}else{
tempTechsToResearch.clear() tempTechsToResearch.clear()
tempTechsToResearch.addAll(pathToTech.map { it.name }) tempTechsToResearch.addAll(pathToTech.map { it.name })
}
val label = "Research [${tempTechsToResearch[0]}]".tr() val label = "Research [${tempTechsToResearch[0]}]".tr()
val techProgression = getTechProgressLabel(tempTechsToResearch) val techProgression = getTechProgressLabel(tempTechsToResearch)