mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-19 20:28:56 +07:00
Resolved #3035 - added nationsToRemove in modOptions
This commit is contained in:
@ -29,6 +29,7 @@ class ModOptions {
|
|||||||
var techsToRemove = HashSet<String>()
|
var techsToRemove = HashSet<String>()
|
||||||
var buildingsToRemove = HashSet<String>()
|
var buildingsToRemove = HashSet<String>()
|
||||||
var unitsToRemove = HashSet<String>()
|
var unitsToRemove = HashSet<String>()
|
||||||
|
var nationsToRemove = HashSet<String>()
|
||||||
var uniques = HashSet<String>()
|
var uniques = HashSet<String>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,18 +66,19 @@ class Ruleset {
|
|||||||
|
|
||||||
fun add(ruleset: Ruleset) {
|
fun add(ruleset: Ruleset) {
|
||||||
buildings.putAll(ruleset.buildings)
|
buildings.putAll(ruleset.buildings)
|
||||||
for(buildingToRemove in ruleset.modOptions.buildingsToRemove) buildings.remove(buildingToRemove)
|
for (buildingToRemove in ruleset.modOptions.buildingsToRemove) buildings.remove(buildingToRemove)
|
||||||
difficulties.putAll(ruleset.difficulties)
|
difficulties.putAll(ruleset.difficulties)
|
||||||
nations.putAll(ruleset.nations)
|
nations.putAll(ruleset.nations)
|
||||||
policyBranches.putAll(ruleset.policyBranches)
|
policyBranches.putAll(ruleset.policyBranches)
|
||||||
technologies.putAll(ruleset.technologies)
|
technologies.putAll(ruleset.technologies)
|
||||||
for(techToRemove in ruleset.modOptions.techsToRemove) technologies.remove(techToRemove)
|
for (techToRemove in ruleset.modOptions.techsToRemove) technologies.remove(techToRemove)
|
||||||
terrains.putAll(ruleset.terrains)
|
terrains.putAll(ruleset.terrains)
|
||||||
tileImprovements.putAll(ruleset.tileImprovements)
|
tileImprovements.putAll(ruleset.tileImprovements)
|
||||||
tileResources.putAll(ruleset.tileResources)
|
tileResources.putAll(ruleset.tileResources)
|
||||||
unitPromotions.putAll(ruleset.unitPromotions)
|
unitPromotions.putAll(ruleset.unitPromotions)
|
||||||
units.putAll(ruleset.units)
|
units.putAll(ruleset.units)
|
||||||
for(unitToRemove in ruleset.modOptions.unitsToRemove) units.remove(unitToRemove)
|
for (unitToRemove in ruleset.modOptions.unitsToRemove) units.remove(unitToRemove)
|
||||||
|
for (nationToRemove in ruleset.modOptions.unitsToRemove) nations.remove(nationToRemove)
|
||||||
mods += ruleset.mods
|
mods += ruleset.mods
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,19 +98,19 @@ class Ruleset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun load(folderHandle :FileHandle ) {
|
fun load(folderHandle: FileHandle) {
|
||||||
val gameBasicsStartTime = System.currentTimeMillis()
|
val gameBasicsStartTime = System.currentTimeMillis()
|
||||||
|
|
||||||
val modOptionsFile = folderHandle.child("ModOptions.json")
|
val modOptionsFile = folderHandle.child("ModOptions.json")
|
||||||
if(modOptionsFile.exists()){
|
if (modOptionsFile.exists()) {
|
||||||
try {
|
try {
|
||||||
modOptions = jsonParser.getFromJson(ModOptions::class.java, modOptionsFile)
|
modOptions = jsonParser.getFromJson(ModOptions::class.java, modOptionsFile)
|
||||||
|
} catch (ex: Exception) {
|
||||||
}
|
}
|
||||||
catch (ex:Exception){}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val techFile =folderHandle.child("Techs.json")
|
val techFile = folderHandle.child("Techs.json")
|
||||||
if(techFile.exists()) {
|
if (techFile.exists()) {
|
||||||
val techColumns = jsonParser.getFromJson(Array<TechColumn>::class.java, techFile)
|
val techColumns = jsonParser.getFromJson(Array<TechColumn>::class.java, techFile)
|
||||||
for (techColumn in techColumns) {
|
for (techColumn in techColumns) {
|
||||||
for (tech in techColumn.techs) {
|
for (tech in techColumn.techs) {
|
||||||
@ -120,25 +122,25 @@ class Ruleset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val buildingsFile = folderHandle.child("Buildings.json")
|
val buildingsFile = folderHandle.child("Buildings.json")
|
||||||
if(buildingsFile.exists()) buildings += createHashmap(jsonParser.getFromJson(Array<Building>::class.java, buildingsFile))
|
if (buildingsFile.exists()) buildings += createHashmap(jsonParser.getFromJson(Array<Building>::class.java, buildingsFile))
|
||||||
|
|
||||||
val terrainsFile = folderHandle.child("Terrains.json")
|
val terrainsFile = folderHandle.child("Terrains.json")
|
||||||
if(terrainsFile.exists()) terrains += createHashmap(jsonParser.getFromJson(Array<Terrain>::class.java, terrainsFile))
|
if (terrainsFile.exists()) terrains += createHashmap(jsonParser.getFromJson(Array<Terrain>::class.java, terrainsFile))
|
||||||
|
|
||||||
val resourcesFile = folderHandle.child("TileResources.json")
|
val resourcesFile = folderHandle.child("TileResources.json")
|
||||||
if(resourcesFile.exists()) tileResources += createHashmap(jsonParser.getFromJson(Array<TileResource>::class.java, resourcesFile))
|
if (resourcesFile.exists()) tileResources += createHashmap(jsonParser.getFromJson(Array<TileResource>::class.java, resourcesFile))
|
||||||
|
|
||||||
val improvementsFile = folderHandle.child("TileImprovements.json")
|
val improvementsFile = folderHandle.child("TileImprovements.json")
|
||||||
if(improvementsFile.exists()) tileImprovements += createHashmap(jsonParser.getFromJson(Array<TileImprovement>::class.java, improvementsFile))
|
if (improvementsFile.exists()) tileImprovements += createHashmap(jsonParser.getFromJson(Array<TileImprovement>::class.java, improvementsFile))
|
||||||
|
|
||||||
val unitsFile = folderHandle.child("Units.json")
|
val unitsFile = folderHandle.child("Units.json")
|
||||||
if(unitsFile.exists()) units += createHashmap(jsonParser.getFromJson(Array<BaseUnit>::class.java, unitsFile))
|
if (unitsFile.exists()) units += createHashmap(jsonParser.getFromJson(Array<BaseUnit>::class.java, unitsFile))
|
||||||
|
|
||||||
val promotionsFile = folderHandle.child("UnitPromotions.json")
|
val promotionsFile = folderHandle.child("UnitPromotions.json")
|
||||||
if(promotionsFile.exists()) unitPromotions += createHashmap(jsonParser.getFromJson(Array<Promotion>::class.java, promotionsFile))
|
if (promotionsFile.exists()) unitPromotions += createHashmap(jsonParser.getFromJson(Array<Promotion>::class.java, promotionsFile))
|
||||||
|
|
||||||
val policiesFile = folderHandle.child("Policies.json")
|
val policiesFile = folderHandle.child("Policies.json")
|
||||||
if(policiesFile.exists()) {
|
if (policiesFile.exists()) {
|
||||||
policyBranches += createHashmap(jsonParser.getFromJson(Array<PolicyBranch>::class.java, policiesFile))
|
policyBranches += createHashmap(jsonParser.getFromJson(Array<PolicyBranch>::class.java, policiesFile))
|
||||||
for (branch in policyBranches.values) {
|
for (branch in policyBranches.values) {
|
||||||
branch.requires = ArrayList()
|
branch.requires = ArrayList()
|
||||||
@ -152,13 +154,13 @@ class Ruleset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val nationsFile = folderHandle.child("Nations.json")
|
val nationsFile = folderHandle.child("Nations.json")
|
||||||
if(nationsFile.exists()) {
|
if (nationsFile.exists()) {
|
||||||
nations += createHashmap(jsonParser.getFromJson(Array<Nation>::class.java, nationsFile))
|
nations += createHashmap(jsonParser.getFromJson(Array<Nation>::class.java, nationsFile))
|
||||||
for (nation in nations.values) nation.setTransients()
|
for (nation in nations.values) nation.setTransients()
|
||||||
}
|
}
|
||||||
|
|
||||||
val difficultiesFile = folderHandle.child("Difficulties.json")
|
val difficultiesFile = folderHandle.child("Difficulties.json")
|
||||||
if(difficultiesFile.exists()) difficulties += createHashmap(jsonParser.getFromJson(Array<Difficulty>::class.java, difficultiesFile))
|
if (difficultiesFile.exists()) difficulties += createHashmap(jsonParser.getFromJson(Array<Difficulty>::class.java, difficultiesFile))
|
||||||
|
|
||||||
val gameBasicsLoadTime = System.currentTimeMillis() - gameBasicsStartTime
|
val gameBasicsLoadTime = System.currentTimeMillis() - gameBasicsStartTime
|
||||||
println("Loading game basics - " + gameBasicsLoadTime + "ms")
|
println("Loading game basics - " + gameBasicsLoadTime + "ms")
|
||||||
@ -169,7 +171,7 @@ class Ruleset {
|
|||||||
* Alternatively, if you edit a tech column's building costs, you want it to affect all buildings in that column.
|
* Alternatively, if you edit a tech column's building costs, you want it to affect all buildings in that column.
|
||||||
* This deals with that
|
* This deals with that
|
||||||
* */
|
* */
|
||||||
fun updateBuildingCosts(){
|
fun updateBuildingCosts() {
|
||||||
for (building in buildings.values) {
|
for (building in buildings.values) {
|
||||||
if (building.cost == 0) {
|
if (building.cost == 0) {
|
||||||
val column = technologies[building.requiredTech]?.column
|
val column = technologies[building.requiredTech]?.column
|
||||||
@ -183,15 +185,16 @@ class Ruleset {
|
|||||||
return technologies.values.map { it.column!!.era }.distinct()
|
return technologies.values.map { it.column!!.era }.distinct()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEraNumber(era:String) = getEras().indexOf(era)
|
fun getEraNumber(era: String) = getEras().indexOf(era)
|
||||||
fun getSummary(): String {
|
fun getSummary(): String {
|
||||||
val stringList = ArrayList<String>()
|
val stringList = ArrayList<String>()
|
||||||
|
if (modOptions.isBaseRuleset) stringList += "Base Ruleset\n"
|
||||||
if (technologies.isNotEmpty()) stringList.add(technologies.size.toString() + " Techs")
|
if (technologies.isNotEmpty()) stringList.add(technologies.size.toString() + " Techs")
|
||||||
if (nations.isNotEmpty()) stringList.add(nations.size.toString() + " Nations")
|
if (nations.isNotEmpty()) stringList.add(nations.size.toString() + " Nations")
|
||||||
if (units.isNotEmpty()) stringList.add(units.size.toString() + " Units")
|
if (units.isNotEmpty()) stringList.add(units.size.toString() + " Units")
|
||||||
if (buildings.isNotEmpty()) stringList.add(buildings.size.toString() + " Buildings")
|
if (buildings.isNotEmpty()) stringList.add(buildings.size.toString() + " Buildings")
|
||||||
if (tileResources.isNotEmpty()) stringList.add(tileResources.size.toString() + " Resources")
|
if (tileResources.isNotEmpty()) stringList.add(tileResources.size.toString() + " Resources")
|
||||||
if (tileImprovements.isNotEmpty()) stringList.add(tileResources.size.toString() + " Improvements")
|
if (tileImprovements.isNotEmpty()) stringList.add(tileImprovements.size.toString() + " Improvements")
|
||||||
stringList += ""
|
stringList += ""
|
||||||
return stringList.joinToString()
|
return stringList.joinToString()
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,13 @@ class ModManagementScreen: PickerScreen() {
|
|||||||
removeRightSideClickListeners()
|
removeRightSideClickListeners()
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
rightSideButton.setText("Download [${repo.name}]".tr())
|
rightSideButton.setText("Download [${repo.name}]".tr())
|
||||||
rightSideButton.onClick { downloadMod(repo.svn_url) }
|
rightSideButton.onClick {
|
||||||
|
rightSideButton.setText("Downloading...")
|
||||||
|
rightSideButton.disable()
|
||||||
|
downloadMod(repo.svn_url){
|
||||||
|
rightSideButton.setText("Done!".tr())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
downloadTable.add(downloadButton).row()
|
downloadTable.add(downloadButton).row()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user