mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 02:40:41 +07:00
when a unit is selected, use the ? button to read about it in the Civilopedia
This commit is contained in:
@ -1058,7 +1058,7 @@
|
|||||||
Russian:"Город будет расширяться между раундами [turnsToExpansion]"
|
Russian:"Город будет расширяться между раундами [turnsToExpansion]"
|
||||||
French:"La ville se développera entre [turnsToExpansion] tours"
|
French:"La ville se développera entre [turnsToExpansion] tours"
|
||||||
Romanian:"Orașul se va extinde între rundă [turnsToExpansion]"
|
Romanian:"Orașul se va extinde între rundă [turnsToExpansion]"
|
||||||
German:"Die Stadt wird sich zwischen [turnsToExpansion]-Runden erweitern"
|
German:"Erweiterung in [turnsToExpansion] Runden"
|
||||||
Dutch:"De stad breidt zich uit tussen [turnsToExpansion]-rondes"
|
Dutch:"De stad breidt zich uit tussen [turnsToExpansion]-rondes"
|
||||||
Spanish:"La ciudad se expandirá entre [turnsToExpansion] rondas"
|
Spanish:"La ciudad se expandirá entre [turnsToExpansion] rondas"
|
||||||
Simplified_Chinese:"这座城市将在[turnsToExpansion]回合后扩张"
|
Simplified_Chinese:"这座城市将在[turnsToExpansion]回合后扩张"
|
||||||
@ -1084,7 +1084,7 @@
|
|||||||
Russian:"В городе будет новый житель в раундах [turnsToPopulation]"
|
Russian:"В городе будет новый житель в раундах [turnsToPopulation]"
|
||||||
French:"La ville aura un nouveau résident dans [turnsToPopulation]"
|
French:"La ville aura un nouveau résident dans [turnsToPopulation]"
|
||||||
Romanian:"Orașul va avea un nou rezident în runde [turnsToPopulation]"
|
Romanian:"Orașul va avea un nou rezident în runde [turnsToPopulation]"
|
||||||
German:"Die Stadt wird einen neuen Einwohner in [turnsToPopulation]-Runden haben"
|
German:"Neuer Einwohner in [turnsToPopulation] Runden"
|
||||||
Dutch:"De stad krijgt een nieuwe inwoner in [turnsToPopulation]-rondes"
|
Dutch:"De stad krijgt een nieuwe inwoner in [turnsToPopulation]-rondes"
|
||||||
Spanish:"La ciudad tendrá un nuevo residente en las rondas de [turnsToPopulation]"
|
Spanish:"La ciudad tendrá un nuevo residente en las rondas de [turnsToPopulation]"
|
||||||
Simplified_Chinese:"这座城市将在[turnsToPopulation]轮后有1个新市民"
|
Simplified_Chinese:"这座城市将在[turnsToPopulation]轮后有1个新市民"
|
||||||
@ -1863,8 +1863,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
"Technologies":{ //You misses this translation, said Smashfanful
|
"Technologies":{ //You misses this translation, said Smashfanful
|
||||||
Italian:"Tecnologie"
|
Italian:"Tecnologie",
|
||||||
French:"Technologies"
|
German:"Technologien",
|
||||||
|
French:"Technologies",
|
||||||
Simplified_Chinese:"科技"
|
Simplified_Chinese:"科技"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3009,7 +3010,7 @@
|
|||||||
|
|
||||||
"Terrains":{
|
"Terrains":{
|
||||||
Italian:"Terreni e caratteristiche"
|
Italian:"Terreni e caratteristiche"
|
||||||
German:"Gelände und Geländearten"
|
German:"Gelände"
|
||||||
French:"Terrains"
|
French:"Terrains"
|
||||||
Simplified_Chinese:"地形"
|
Simplified_Chinese:"地形"
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,32 @@ import com.unciv.ui.utils.CameraStageBaseScreen
|
|||||||
import com.unciv.ui.utils.onClick
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.toLabel
|
import com.unciv.ui.utils.toLabel
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
class CivilopediaScreen : CameraStageBaseScreen() {
|
class CivilopediaScreen : CameraStageBaseScreen() {
|
||||||
|
|
||||||
|
val categoryToInfos = LinkedHashMap<String, Collection<ICivilopedia>>()
|
||||||
|
val categoryToButtons = LinkedHashMap<String, Button>()
|
||||||
|
val civPediaEntries = Array<ICivilopedia>()
|
||||||
|
|
||||||
|
val nameList = List<String>(skin)
|
||||||
|
val description = "".toLabel()
|
||||||
|
|
||||||
|
fun select(category: String, entry: String? = null) {
|
||||||
|
val nameItems=Array<String>()
|
||||||
|
civPediaEntries.clear()
|
||||||
|
for (civilopediaEntry in categoryToInfos[category]!!.sortedBy { it.toString().tr() }){ // Alphabetical order of localized names
|
||||||
|
civPediaEntries.add(civilopediaEntry)
|
||||||
|
nameItems.add(civilopediaEntry.toString().tr())
|
||||||
|
}
|
||||||
|
nameList.setItems(nameItems)
|
||||||
|
val index = max(0, nameList.items.indexOf(entry?.tr()))
|
||||||
|
nameList.selected = nameList.items.get(index)
|
||||||
|
description.setText(civPediaEntries.get(index).description)
|
||||||
|
for (btn in categoryToButtons.values) btn.isChecked = false
|
||||||
|
categoryToButtons[category]?.isChecked = true
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
onBackButtonClicked { UnCivGame.Current.setWorldScreen() }
|
onBackButtonClicked { UnCivGame.Current.setWorldScreen() }
|
||||||
val buttonTable = Table()
|
val buttonTable = Table()
|
||||||
@ -27,8 +51,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
stage.addActor(splitPane)
|
stage.addActor(splitPane)
|
||||||
|
|
||||||
val label = "".toLabel()
|
description.setWrap(true)
|
||||||
label.setWrap(true)
|
|
||||||
|
|
||||||
val goToGameButton = TextButton("Close".tr(), skin)
|
val goToGameButton = TextButton("Close".tr(), skin)
|
||||||
goToGameButton.onClick {
|
goToGameButton.onClick {
|
||||||
@ -37,7 +60,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
}
|
}
|
||||||
buttonTable.add(goToGameButton)
|
buttonTable.add(goToGameButton)
|
||||||
|
|
||||||
val categoryToInfos = LinkedHashMap<String, Collection<ICivilopedia>>()
|
|
||||||
|
|
||||||
val language = UnCivGame.Current.settings.language.replace(" ","_")
|
val language = UnCivGame.Current.settings.language.replace(" ","_")
|
||||||
val basicHelpFileName = if(Gdx.files.internal("jsons/BasicHelp/BasicHelp_$language.json").exists())"BasicHelp/BasicHelp_$language"
|
val basicHelpFileName = if(Gdx.files.internal("jsons/BasicHelp/BasicHelp_$language.json").exists())"BasicHelp/BasicHelp_$language"
|
||||||
@ -51,49 +74,27 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
categoryToInfos["Units"] = GameBasics.Units.values
|
categoryToInfos["Units"] = GameBasics.Units.values
|
||||||
categoryToInfos["Technologies"] = GameBasics.Technologies.values
|
categoryToInfos["Technologies"] = GameBasics.Technologies.values
|
||||||
|
|
||||||
val nameList = List<String>(skin)
|
nameList.onClick {
|
||||||
val newArray = Array<ICivilopedia>()
|
if(nameList.selected!=null) description.setText(civPediaEntries.get(nameList.selectedIndex).description)
|
||||||
val nameListClickListener = {
|
|
||||||
if(nameList.selected!=null) label.setText(newArray.get(nameList.selectedIndex).description)
|
|
||||||
}
|
}
|
||||||
nameList.onClick (nameListClickListener)
|
|
||||||
nameList.style = List.ListStyle(nameList.style)
|
nameList.style = List.ListStyle(nameList.style)
|
||||||
nameList.style.fontColorSelected = Color.BLACK
|
nameList.style.fontColorSelected = Color.BLACK
|
||||||
|
|
||||||
val buttons = ArrayList<Button>()
|
for (category in categoryToInfos.keys) {
|
||||||
var first = true
|
val button = TextButton(category.tr(), skin)
|
||||||
for (str in categoryToInfos.keys) {
|
|
||||||
val button = TextButton(str.tr(), skin)
|
|
||||||
button.style = TextButton.TextButtonStyle(button.style)
|
button.style = TextButton.TextButtonStyle(button.style)
|
||||||
button.style.checkedFontColor = Color.BLACK
|
button.style.checkedFontColor = Color.YELLOW
|
||||||
buttons.add(button)
|
categoryToButtons[category] = button
|
||||||
val buttonClicked = {
|
button.onClick { select(category) }
|
||||||
newArray.clear()
|
|
||||||
val civArray=Array<String>()
|
|
||||||
for (civilopediaEntry in categoryToInfos[str]!!.sortedBy { it.toString() }){ // Alphabetical order
|
|
||||||
newArray.add(civilopediaEntry)
|
|
||||||
civArray.add(civilopediaEntry.toString().tr())
|
|
||||||
}
|
|
||||||
nameList.setItems(civArray)
|
|
||||||
nameList.selected = nameList.items.get(0)
|
|
||||||
label.setText(newArray.get(0).description)
|
|
||||||
for (btn in buttons) btn.isChecked = false
|
|
||||||
button.isChecked = true
|
|
||||||
}
|
|
||||||
button.onClick(buttonClicked)
|
|
||||||
if (first) {// Fake-click the first button so that the user sees results immediately
|
|
||||||
first = false
|
|
||||||
buttonClicked()
|
|
||||||
}
|
|
||||||
|
|
||||||
buttonTable.add(button)
|
buttonTable.add(button)
|
||||||
}
|
}
|
||||||
|
select("Basics")
|
||||||
|
|
||||||
val sp = ScrollPane(nameList)
|
val sp = ScrollPane(nameList)
|
||||||
sp.setupOverscroll(5f, 1f, 200f)
|
sp.setupOverscroll(5f, 1f, 200f)
|
||||||
entryTable.add(sp).width(Value.percentWidth(0.25f, entryTable)).height(Value.percentHeight(0.7f, entryTable))
|
entryTable.add(sp).width(Value.percentWidth(0.25f, entryTable)).height(Value.percentHeight(0.7f, entryTable))
|
||||||
.pad(Value.percentWidth(0.02f, entryTable))
|
.pad(Value.percentWidth(0.02f, entryTable))
|
||||||
entryTable.add(label).colspan(4).width(Value.percentWidth(0.65f, entryTable)).height(Value.percentHeight(0.7f, entryTable))
|
entryTable.add(description).colspan(4).width(Value.percentWidth(0.65f, entryTable)).height(Value.percentHeight(0.7f, entryTable))
|
||||||
.pad(Value.percentWidth(0.02f, entryTable))
|
.pad(Value.percentWidth(0.02f, entryTable))
|
||||||
// Simply changing these to x*width, y*height won't work
|
// Simply changing these to x*width, y*height won't work
|
||||||
|
|
||||||
|
@ -49,7 +49,13 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
helpUnitButton.add(Label("?",CameraStageBaseScreen.skin).setFontColor(Color.WHITE)).pad(10f)
|
helpUnitButton.add(Label("?",CameraStageBaseScreen.skin).setFontColor(Color.WHITE)).pad(10f)
|
||||||
helpUnitButton.pack()
|
helpUnitButton.pack()
|
||||||
helpUnitButton.touchable = Touchable.enabled
|
helpUnitButton.touchable = Touchable.enabled
|
||||||
helpUnitButton.onClick { UnCivGame.Current.screen = CivilopediaScreen() }
|
helpUnitButton.onClick {
|
||||||
|
val pedia = CivilopediaScreen()
|
||||||
|
if (selectedUnit != null) {
|
||||||
|
pedia.select("Units", selectedUnit?.name)
|
||||||
|
}
|
||||||
|
UnCivGame.Current.screen = pedia
|
||||||
|
}
|
||||||
addActor(helpUnitButton)
|
addActor(helpUnitButton)
|
||||||
|
|
||||||
}).left()
|
}).left()
|
||||||
|
Reference in New Issue
Block a user