mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Added "permanent visual mods" option to mod management
This commit is contained in:
parent
7ba12ad5c6
commit
c98100f1a7
@ -85,9 +85,9 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
|||||||
* - Font (hence Fonts.resetFont() inside setSkin())
|
* - Font (hence Fonts.resetFont() inside setSkin())
|
||||||
*/
|
*/
|
||||||
ImageGetter.atlas = TextureAtlas("game.atlas")
|
ImageGetter.atlas = TextureAtlas("game.atlas")
|
||||||
ImageGetter.setNewRuleset(ImageGetter.ruleset)
|
settings = GameSaver.getGeneralSettings() // needed for the screen
|
||||||
|
ImageGetter.setNewRuleset(ImageGetter.ruleset) // This needs to come after the settings, since we may have default visual mods
|
||||||
CameraStageBaseScreen.setSkin() // needs to come AFTER the Texture reset, since the buttons depend on it
|
CameraStageBaseScreen.setSkin() // needs to come AFTER the Texture reset, since the buttons depend on it
|
||||||
settings = GameSaver.getGeneralSettings() // needed for the screen - this also needs the atlas to be configured
|
|
||||||
|
|
||||||
Gdx.graphics.isContinuousRendering = settings.continuousRendering
|
Gdx.graphics.isContinuousRendering = settings.continuousRendering
|
||||||
screen = LoadingScreen()
|
screen = LoadingScreen()
|
||||||
|
@ -115,11 +115,6 @@ object GameSaver {
|
|||||||
GameSettings().apply { isFreshlyCreated = true }
|
GameSettings().apply { isFreshlyCreated = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
val atlas = ImageGetter.atlas
|
|
||||||
val currentTileSets = atlas.regions.asSequence()
|
|
||||||
.filter { it.name.startsWith("TileSets") }
|
|
||||||
.map { it.name.split("/")[1] }.distinct()
|
|
||||||
if (settings.tileSet !in currentTileSets) settings.tileSet = "Default"
|
|
||||||
return settings
|
return settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ class GameSettings {
|
|||||||
var orderTradeOffersByAmount = true
|
var orderTradeOffersByAmount = true
|
||||||
var windowState = WindowState()
|
var windowState = WindowState()
|
||||||
var isFreshlyCreated = false
|
var isFreshlyCreated = false
|
||||||
|
var visualMods = HashSet<String>()
|
||||||
|
|
||||||
var showExperimentalWorldWrap = false
|
var showExperimentalWorldWrap = false
|
||||||
|
|
||||||
|
@ -114,13 +114,30 @@ class ModManagementScreen: PickerScreen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun refreshModActions(mod: Ruleset) {
|
||||||
|
modActionTable.clear()
|
||||||
|
val visualMods = game.settings.visualMods
|
||||||
|
if (!visualMods.contains(mod.name))
|
||||||
|
modActionTable.add("Enable as permanent visual mod".toTextButton().onClick {
|
||||||
|
visualMods.add(mod.name); game.settings.save()
|
||||||
|
ImageGetter.setNewRuleset(ImageGetter.ruleset)
|
||||||
|
refreshModActions(mod)
|
||||||
|
})
|
||||||
|
else modActionTable.add("Disable as permanent visual mod".toTextButton().onClick {
|
||||||
|
visualMods.remove(mod.name)
|
||||||
|
game.settings.save()
|
||||||
|
ImageGetter.setNewRuleset(ImageGetter.ruleset)
|
||||||
|
refreshModActions(mod)
|
||||||
|
})
|
||||||
|
modActionTable.row()
|
||||||
|
}
|
||||||
|
|
||||||
fun refreshModTable(){
|
fun refreshModTable(){
|
||||||
modTable.clear()
|
modTable.clear()
|
||||||
val currentMods = RulesetCache.values.filter { it.name != "" }
|
val currentMods = RulesetCache.values.filter { it.name != "" }
|
||||||
for (mod in currentMods) {
|
for (mod in currentMods) {
|
||||||
val button = mod.name.toTextButton().onClick {
|
val button = mod.name.toTextButton().onClick {
|
||||||
// modActionTable.add("Last updated: ${mod.getSummary()}")
|
refreshModActions(mod)
|
||||||
|
|
||||||
rightSideButton.setText("Delete [${mod.name}]".tr())
|
rightSideButton.setText("Delete [${mod.name}]".tr())
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
descriptionLabel.setText(mod.getSummary())
|
descriptionLabel.setText(mod.getSummary())
|
||||||
|
@ -15,6 +15,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable
|
|||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.UncivGame
|
||||||
import com.unciv.models.ruleset.Nation
|
import com.unciv.models.ruleset.Nation
|
||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.ruleset.tile.ResourceType
|
import com.unciv.models.ruleset.tile.ResourceType
|
||||||
@ -65,7 +66,7 @@ object ImageGetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// These are from the mods
|
// These are from the mods
|
||||||
for (mod in ruleset.mods) {
|
for (mod in UncivGame.Current.settings.visualMods + ruleset.mods) {
|
||||||
val modAtlasFile = Gdx.files.local("mods/$mod/game.atlas")
|
val modAtlasFile = Gdx.files.local("mods/$mod/game.atlas")
|
||||||
if (!modAtlasFile.exists()) continue
|
if (!modAtlasFile.exists()) continue
|
||||||
val modAtlas = TextureAtlas(modAtlasFile)
|
val modAtlas = TextureAtlas(modAtlasFile)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user