Added display option to change screen resolution
This commit is contained in:
parent
1175f06aa1
commit
5aef49955a
4 changed files with 35 additions and 8 deletions
|
@ -28,4 +28,13 @@ class GameSettings : LinkedHashMap<String, String>() {
|
|||
set(value) {
|
||||
this["Language"]=value
|
||||
}
|
||||
|
||||
var resolution:String
|
||||
get() {
|
||||
if(this.containsKey("Resolution")) return get("Resolution")!!
|
||||
else return "900x600"
|
||||
}
|
||||
set(value) {
|
||||
this["Resolution"]=value
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@ open class CameraStageBaseScreen : Screen {
|
|||
private var isTutorialShowing = false
|
||||
|
||||
init {
|
||||
stage = Stage(ExtendViewport(1000f, 600f), batch)// FitViewport(1000,600)
|
||||
val resolutions: List<Float> = game.settings.resolution.split("x").map { it.toInt().toFloat() }
|
||||
stage = Stage(ExtendViewport(resolutions[0], resolutions[1]), batch)// FitViewport(1000,600)
|
||||
Gdx.input.inputProcessor = stage
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
|||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.addClickListener
|
||||
import com.unciv.ui.utils.tr
|
||||
|
||||
open class OptionsTable: Table(){
|
||||
init {
|
||||
|
@ -18,7 +19,7 @@ open class OptionsTable: Table(){
|
|||
}
|
||||
|
||||
fun addButton(text:String, action:()->Unit){
|
||||
val button = TextButton(text, CameraStageBaseScreen.skin).apply { color= ImageGetter.getBlue() }
|
||||
val button = TextButton(text.tr(), CameraStageBaseScreen.skin).apply { color= ImageGetter.getBlue() }
|
||||
button.addClickListener(action)
|
||||
add(button).row()
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.unciv.logic.GameSaver
|
|||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.center
|
||||
import com.unciv.ui.utils.tr
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
|
||||
class WorldScreenDisplayOptionsTable() : OptionsTable(){
|
||||
|
@ -20,12 +19,12 @@ class WorldScreenDisplayOptionsTable() : OptionsTable(){
|
|||
clear()
|
||||
val tileMapHolder = UnCivGame.Current.worldScreen.tileMapHolder
|
||||
val settings = UnCivGame.Current.settings
|
||||
if (settings.showWorkedTiles) addButton("Hide worked tiles") { settings.showWorkedTiles = false; update() }
|
||||
else addButton("Show worked tiles") { settings.showWorkedTiles = true; update() }
|
||||
if (settings.showWorkedTiles) addButton("{Hide} {worked tiles}") { settings.showWorkedTiles = false; update() }
|
||||
else addButton("{Show} {worked tiles}") { settings.showWorkedTiles = true; update() }
|
||||
|
||||
if (settings.showResourcesAndImprovements)
|
||||
addButton("Hide resources and improvements") { settings.showResourcesAndImprovements = false; update() }
|
||||
else addButton("Show resources and improvements") { settings.showResourcesAndImprovements = true; update() }
|
||||
addButton("{Hide} {resources and improvements}") { settings.showResourcesAndImprovements = false; update() }
|
||||
else addButton("{Show} {resources and improvements}") { settings.showResourcesAndImprovements = true; update() }
|
||||
|
||||
val languageSelectBox = SelectBox<String>(CameraStageBaseScreen.skin)
|
||||
val languageArray = com.badlogic.gdx.utils.Array<String>()
|
||||
|
@ -39,11 +38,28 @@ class WorldScreenDisplayOptionsTable() : OptionsTable(){
|
|||
GameSaver().setGeneralSettings(UnCivGame.Current.settings)
|
||||
UnCivGame.Current.worldScreen = WorldScreen()
|
||||
UnCivGame.Current.setWorldScreen()
|
||||
UnCivGame.Current.worldScreen.stage.addActor(WorldScreenDisplayOptionsTable())
|
||||
}
|
||||
})
|
||||
|
||||
val resolutionSelectBox= SelectBox<String>(CameraStageBaseScreen.skin)
|
||||
val resolutionArray = com.badlogic.gdx.utils.Array<String>()
|
||||
resolutionArray.addAll("900x600","1200x800","1500x1000")
|
||||
resolutionSelectBox.setItems(resolutionArray)
|
||||
resolutionSelectBox.selected = UnCivGame.Current.settings.resolution
|
||||
add(resolutionSelectBox).pad(10f).row()
|
||||
|
||||
addButton("Close".tr()){ remove() }
|
||||
resolutionSelectBox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
UnCivGame.Current.settings.resolution = resolutionSelectBox.selected
|
||||
GameSaver().setGeneralSettings(UnCivGame.Current.settings)
|
||||
UnCivGame.Current.worldScreen = WorldScreen()
|
||||
UnCivGame.Current.setWorldScreen()
|
||||
UnCivGame.Current.worldScreen.stage.addActor(WorldScreenDisplayOptionsTable())
|
||||
}
|
||||
})
|
||||
|
||||
addButton("Close"){ remove() }
|
||||
|
||||
pack() // Needed to show the background.
|
||||
center(UnCivGame.Current.worldScreen.stage)
|
||||
|
|
Loading…
Reference in a new issue