mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-03 08:39:37 +07:00
Resolved #2894 - Map editor button only opens popup once
This commit is contained in:
@ -109,18 +109,21 @@
|
|||||||
{
|
{
|
||||||
"name": "Warrior Code",
|
"name": "Warrior Code",
|
||||||
"effect": "+20% production when training melee units",
|
"effect": "+20% production when training melee units",
|
||||||
|
"uniques":["+20% production when training melee units"],
|
||||||
"row": 1,
|
"row": 1,
|
||||||
"column": 2
|
"column": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Discipline",
|
"name": "Discipline",
|
||||||
"effect": "+15% combat strength for melee units which have another military unit in an adjacent tile",
|
"effect": "+15% combat strength for melee units which have another military unit in an adjacent tile",
|
||||||
|
"uniques":["+15% combat strength for melee units which have another military unit in an adjacent tile"],
|
||||||
"row": 1,
|
"row": 1,
|
||||||
"column": 4
|
"column": 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Military Tradition",
|
"name": "Military Tradition",
|
||||||
"effect": "Military units gain 50% more Experience from combat",
|
"effect": "Military units gain 50% more Experience from combat",
|
||||||
|
"uniques":["Military units gain 50% more Experience from combat"],
|
||||||
"requires": ["Warrior Code"],
|
"requires": ["Warrior Code"],
|
||||||
"row": 2,
|
"row": 2,
|
||||||
"column": 2
|
"column": 2
|
||||||
@ -128,6 +131,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Military Caste",
|
"name": "Military Caste",
|
||||||
"effect": "Each city with a garrison increases happiness by 1 and culture by 2",
|
"effect": "Each city with a garrison increases happiness by 1 and culture by 2",
|
||||||
|
"uniques": ["[+1 Happiness, +2 Culture] in all cities with a garrison"]
|
||||||
"requires": ["Discipline"],
|
"requires": ["Discipline"],
|
||||||
"row": 2,
|
"row": 2,
|
||||||
"column": 4
|
"column": 4
|
||||||
|
@ -96,7 +96,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
|
|||||||
table.add(multiplayerTable).row()
|
table.add(multiplayerTable).row()
|
||||||
|
|
||||||
val mapEditorScreenTable = getTableBlock("Map editor", "OtherIcons/MapEditor")
|
val mapEditorScreenTable = getTableBlock("Map editor", "OtherIcons/MapEditor")
|
||||||
{ openMapEditorPopup() }
|
{ if(stage.actors.none { it is MapEditorMainScreenPopup }) MapEditorMainScreenPopup(this) }
|
||||||
table.add(mapEditorScreenTable).padBottom(0f)
|
table.add(mapEditorScreenTable).padBottom(0f)
|
||||||
|
|
||||||
// set the same width for all buttons
|
// set the same width for all buttons
|
||||||
@ -118,56 +118,57 @@ class MainMenuScreen: CameraStageBaseScreen() {
|
|||||||
|
|
||||||
|
|
||||||
/** Shows the [Popup] with the map editor initialization options */
|
/** Shows the [Popup] with the map editor initialization options */
|
||||||
private fun openMapEditorPopup() {
|
class MapEditorMainScreenPopup(screen: MainMenuScreen):Popup(screen){
|
||||||
|
init{
|
||||||
|
defaults().pad(10f)
|
||||||
|
|
||||||
val mapEditorPopup = Popup(this)
|
val tableBackground = ImageGetter.getBackground(colorFromRGB(29, 102, 107))
|
||||||
mapEditorPopup.defaults().pad(10f)
|
|
||||||
|
|
||||||
val tableBackground = ImageGetter.getBackground(colorFromRGB(29, 102, 107))
|
val newMapButton = screen.getTableBlock("New map", "OtherIcons/New") {
|
||||||
|
screen.game.setScreen(NewMapScreen())
|
||||||
val newMapButton = getTableBlock("New map", "OtherIcons/New") {
|
screen.dispose()
|
||||||
game.setScreen(NewMapScreen())
|
|
||||||
dispose()
|
|
||||||
}
|
|
||||||
newMapButton.background = tableBackground
|
|
||||||
mapEditorPopup.add(newMapButton).row()
|
|
||||||
|
|
||||||
val loadMapButton = getTableBlock("Load map", "OtherIcons/Load") {
|
|
||||||
val loadMapScreen = LoadMapScreen(null)
|
|
||||||
loadMapScreen.closeButton.isVisible = true
|
|
||||||
loadMapScreen.closeButton.onClick {
|
|
||||||
game.setScreen(MainMenuScreen())
|
|
||||||
loadMapScreen.dispose()
|
|
||||||
}
|
}
|
||||||
game.setScreen(loadMapScreen)
|
newMapButton.background = tableBackground
|
||||||
dispose()
|
add(newMapButton).row()
|
||||||
}
|
|
||||||
|
|
||||||
loadMapButton.background = tableBackground
|
val loadMapButton = screen.getTableBlock("Load map", "OtherIcons/Load") {
|
||||||
mapEditorPopup.add(loadMapButton).row()
|
val loadMapScreen = LoadMapScreen(null)
|
||||||
|
loadMapScreen.closeButton.isVisible = true
|
||||||
if (UncivGame.Current.settings.extendedMapEditor) {
|
loadMapScreen.closeButton.onClick {
|
||||||
val loadScenarioButton = getTableBlock("Load scenario", "OtherIcons/Scenario") {
|
screen.game.setScreen(MainMenuScreen())
|
||||||
val loadScenarioScreen = LoadScenarioScreen(null)
|
loadMapScreen.dispose()
|
||||||
loadScenarioScreen.closeButton.isVisible = true
|
|
||||||
loadScenarioScreen.closeButton.onClick {
|
|
||||||
game.setScreen(MainMenuScreen())
|
|
||||||
loadScenarioScreen.dispose()
|
|
||||||
}
|
}
|
||||||
game.setScreen(loadScenarioScreen)
|
screen.game.setScreen(loadMapScreen)
|
||||||
dispose()
|
screen.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
loadScenarioButton.background = tableBackground
|
loadMapButton.background = tableBackground
|
||||||
mapEditorPopup.add(loadScenarioButton).row()
|
add(loadMapButton).row()
|
||||||
|
|
||||||
|
if (UncivGame.Current.settings.extendedMapEditor) {
|
||||||
|
val loadScenarioButton = screen.getTableBlock("Load scenario", "OtherIcons/Scenario") {
|
||||||
|
val loadScenarioScreen = LoadScenarioScreen(null)
|
||||||
|
loadScenarioScreen.closeButton.isVisible = true
|
||||||
|
loadScenarioScreen.closeButton.onClick {
|
||||||
|
screen.game.setScreen(MainMenuScreen())
|
||||||
|
loadScenarioScreen.dispose()
|
||||||
|
}
|
||||||
|
screen.game.setScreen(loadScenarioScreen)
|
||||||
|
screen.dispose()
|
||||||
|
}
|
||||||
|
|
||||||
|
loadScenarioButton.background = tableBackground
|
||||||
|
add(loadScenarioButton).row()
|
||||||
|
}
|
||||||
|
|
||||||
|
add(screen.getTableBlock("Close", "OtherIcons/Close") { close() }
|
||||||
|
.apply { background=tableBackground })
|
||||||
|
|
||||||
|
open(force = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
mapEditorPopup.add(getTableBlock("Close", "OtherIcons/Close") { mapEditorPopup.close() }
|
|
||||||
.apply { background=tableBackground })
|
|
||||||
|
|
||||||
mapEditorPopup.open(force = true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun autoLoadGame() {
|
private fun autoLoadGame() {
|
||||||
try {
|
try {
|
||||||
game.loadGame(autosave)
|
game.loadGame(autosave)
|
||||||
|
@ -236,7 +236,7 @@ object Battle {
|
|||||||
return
|
return
|
||||||
|
|
||||||
var XPModifier = 1f
|
var XPModifier = 1f
|
||||||
if (thisCombatant.getCivInfo().policies.isAdopted("Military Tradition")) XPModifier += 0.5f
|
if (thisCombatant.getCivInfo().hasUnique("Military units gain 50% more Experience from combat")) XPModifier += 0.5f
|
||||||
if (thisCombatant.unit.hasUnique("50% Bonus XP gain")) XPModifier += 0.5f
|
if (thisCombatant.unit.hasUnique("50% Bonus XP gain")) XPModifier += 0.5f
|
||||||
|
|
||||||
val XPGained = (amount * XPModifier).toInt()
|
val XPGained = (amount * XPModifier).toInt()
|
||||||
|
@ -71,7 +71,7 @@ object BattleDamage {
|
|||||||
modifiers["Populism"] = 0.25f
|
modifiers["Populism"] = 0.25f
|
||||||
}
|
}
|
||||||
|
|
||||||
if (civInfo.policies.hasEffect("+15% combat strength for melee units which have another military unit in an adjacent tile")
|
if (civInfo.hasUnique("+15% combat strength for melee units which have another military unit in an adjacent tile")
|
||||||
&& combatant.isMelee()
|
&& combatant.isMelee()
|
||||||
&& combatant.getTile().neighbors.flatMap { it.getUnits() }
|
&& combatant.getTile().neighbors.flatMap { it.getUnits() }
|
||||||
.any { it.civInfo == civInfo && !it.type.isCivilian() && !it.type.isAirUnit() })
|
.any { it.civInfo == civInfo && !it.type.isCivilian() && !it.type.isAirUnit() })
|
||||||
|
@ -14,6 +14,7 @@ import com.unciv.models.stats.Stat
|
|||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
import com.unciv.models.translations.equalsPlaceholderText
|
import com.unciv.models.translations.equalsPlaceholderText
|
||||||
import com.unciv.models.translations.getPlaceholderParameters
|
import com.unciv.models.translations.getPlaceholderParameters
|
||||||
|
import com.unciv.models.translations.getPlaceholderText
|
||||||
|
|
||||||
|
|
||||||
class CityStats {
|
class CityStats {
|
||||||
@ -215,9 +216,11 @@ class CityStats {
|
|||||||
if (civInfo.hasUnique("+1 happiness for every city connected to capital")
|
if (civInfo.hasUnique("+1 happiness for every city connected to capital")
|
||||||
&& cityInfo.isConnectedToCapital())
|
&& cityInfo.isConnectedToCapital())
|
||||||
happinessFromPolicies += 1f
|
happinessFromPolicies += 1f
|
||||||
if (civInfo.policies.hasEffect("Each city with a garrison increases happiness by 1 and culture by 2"
|
|
||||||
) && cityInfo.getCenterTile().militaryUnit != null)
|
if (cityInfo.getCenterTile().militaryUnit != null)
|
||||||
happinessFromPolicies += 1
|
for (unique in civInfo.policies.policyEffects)
|
||||||
|
if (unique.equalsPlaceholderText("[] in all cities with a garrison"))
|
||||||
|
happinessFromPolicies += Stats.parse(unique.getPlaceholderParameters()[0]).happiness
|
||||||
|
|
||||||
newHappinessList["Policies"] = happinessFromPolicies
|
newHappinessList["Policies"] = happinessFromPolicies
|
||||||
|
|
||||||
@ -230,7 +233,7 @@ class CityStats {
|
|||||||
newHappinessList["Wonders"] = 1f
|
newHappinessList["Wonders"] = 1f
|
||||||
|
|
||||||
newHappinessList["Tile yields"] = getStatsFromTiles().happiness
|
newHappinessList["Tile yields"] = getStatsFromTiles().happiness
|
||||||
|
|
||||||
// we don't want to modify the existing happiness list because that leads
|
// we don't want to modify the existing happiness list because that leads
|
||||||
// to concurrency problems if we iterate on it while changing
|
// to concurrency problems if we iterate on it while changing
|
||||||
happinessList = newHappinessList
|
happinessList = newHappinessList
|
||||||
@ -267,9 +270,10 @@ class CityStats {
|
|||||||
if (adoptedPolicies.hasEffect("+3 culture in capital") && cityInfo.isCapital())
|
if (adoptedPolicies.hasEffect("+3 culture in capital") && cityInfo.isCapital())
|
||||||
stats.culture += 3f
|
stats.culture += 3f
|
||||||
for(effect in adoptedPolicies.policyEffects) {
|
for(effect in adoptedPolicies.policyEffects) {
|
||||||
if (effect.equalsPlaceholderText("[] in capital") && cityInfo.isCapital())
|
val placeholderText = effect.getPlaceholderText()
|
||||||
stats.add(Stats.parse(effect.getPlaceholderParameters()[0]))
|
if ((placeholderText == "[] in capital" && cityInfo.isCapital())
|
||||||
else if(effect.equalsPlaceholderText("[] in all cities"))
|
|| placeholderText == "[] in all cities"
|
||||||
|
|| (placeholderText == "[] in all cities with a garrison" && cityInfo.getCenterTile().militaryUnit != null))
|
||||||
stats.add(Stats.parse(effect.getPlaceholderParameters()[0]))
|
stats.add(Stats.parse(effect.getPlaceholderParameters()[0]))
|
||||||
}
|
}
|
||||||
if (adoptedPolicies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital") && cityInfo.isCapital())
|
if (adoptedPolicies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital") && cityInfo.isCapital())
|
||||||
@ -278,8 +282,6 @@ class CityStats {
|
|||||||
stats.culture += 1f
|
stats.culture += 1f
|
||||||
if (adoptedPolicies.hasEffect("+1 production in every city, +5% production when constructing buildings"))
|
if (adoptedPolicies.hasEffect("+1 production in every city, +5% production when constructing buildings"))
|
||||||
stats.production += 1f
|
stats.production += 1f
|
||||||
if (adoptedPolicies.hasEffect("Each city with a garrison increases happiness by 1 and culture by 2") && cityInfo.getCenterTile().militaryUnit != null)
|
|
||||||
stats.culture += 2
|
|
||||||
if (adoptedPolicies.hasEffect("+1 production per 5 population"))
|
if (adoptedPolicies.hasEffect("+1 production per 5 population"))
|
||||||
stats.production += (cityInfo.population.population / 5).toFloat()
|
stats.production += (cityInfo.population.population / 5).toFloat()
|
||||||
if (adoptedPolicies.hasEffect("+1 culture for every 2 citizens"))
|
if (adoptedPolicies.hasEffect("+1 culture for every 2 citizens"))
|
||||||
@ -337,7 +339,8 @@ class CityStats {
|
|||||||
stats.production += 50f
|
stats.production += 50f
|
||||||
if (policies.contains("Republic") && currentConstruction is Building)
|
if (policies.contains("Republic") && currentConstruction is Building)
|
||||||
stats.production += 5f
|
stats.production += 5f
|
||||||
if (policies.contains("Warrior Code") && currentConstruction is BaseUnit && currentConstruction.unitType.isMelee())
|
if (cityInfo.civInfo.hasUnique("+20% production when training melee units")
|
||||||
|
&& currentConstruction is BaseUnit && currentConstruction.unitType.isMelee())
|
||||||
stats.production += 20
|
stats.production += 20
|
||||||
if (policies.contains("Piety")
|
if (policies.contains("Piety")
|
||||||
&& listOf("Monument", "Temple", "Opera House", "Museum", "Broadcast Tower").contains(currentConstruction.name))
|
&& listOf("Monument", "Temple", "Opera House", "Museum", "Broadcast Tower").contains(currentConstruction.name))
|
||||||
|
Reference in New Issue
Block a user