mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 01:08:25 +07:00
Added Missions, to replace wall-of-text tutorials in bite-sized pieces! Very pleased with this =D
This commit is contained in:
@ -123,7 +123,8 @@ class UncivGame(val version: String) : Game() {
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
GameSaver().autoSave(gameInfo)
|
||||
if(::gameInfo.isInitialized)
|
||||
GameSaver().autoSave(gameInfo)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -254,6 +254,8 @@ class CivilizationInfo {
|
||||
.apply { diplomaticStatus = DiplomaticStatus.Peace }
|
||||
|
||||
popupAlerts.add(PopupAlert(AlertType.FirstContact,otherCiv.civName))
|
||||
if(isCurrentPlayer() || otherCiv.isCurrentPlayer())
|
||||
UncivGame.Current.settings.addMissionCompleted("Meet another civilization")
|
||||
}
|
||||
|
||||
override fun toString(): String {return civName} // for debug
|
||||
|
@ -3,6 +3,7 @@ package com.unciv.logic.map
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.automation.UnitAutomation
|
||||
import com.unciv.logic.automation.WorkerAutomation
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
@ -324,6 +325,9 @@ class MapUnit {
|
||||
val tile=getTile()
|
||||
tile.turnsToImprovement -= 1
|
||||
if (tile.turnsToImprovement != 0) return
|
||||
|
||||
if(civInfo.isCurrentPlayer())
|
||||
UncivGame.Current.settings.addMissionCompleted("Construct an improvement")
|
||||
when {
|
||||
tile.improvementInProgress!!.startsWith("Remove") -> {
|
||||
val tileImprovement = tile.getTileImprovement()
|
||||
|
@ -10,6 +10,7 @@ class GameSettings {
|
||||
var language: String = "English"
|
||||
var resolution: String = "900x600"
|
||||
var tutorialsShown = ArrayList<String>()
|
||||
var missionsCompleted = ArrayList<String>()
|
||||
var hasCrashedRecently = false
|
||||
var soundEffectsVolume = 0.5f
|
||||
var musicVolume = 0.5f
|
||||
@ -28,4 +29,9 @@ class GameSettings {
|
||||
fun save(){
|
||||
GameSaver().setGeneralSettings(this)
|
||||
}
|
||||
|
||||
fun addMissionCompleted(mission:String){
|
||||
missionsCompleted.add(mission)
|
||||
save()
|
||||
}
|
||||
}
|
@ -423,7 +423,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
||||
labelText = "???"
|
||||
}
|
||||
|
||||
civGroup.background = ImageGetter.getTableBackground(backgroundColor)
|
||||
civGroup.background = ImageGetter.getRoundedEdgeTableBackground(backgroundColor)
|
||||
val label = labelText.toLabel(labelColor)
|
||||
label.setAlignment(Align.center)
|
||||
|
||||
|
@ -48,6 +48,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
||||
init {
|
||||
onBackButtonClicked { game.setWorldScreen() }
|
||||
addTiles()
|
||||
UncivGame.Current.settings.addMissionCompleted("Enter city screen")
|
||||
|
||||
val tableBackgroundColor = ImageGetter.getBlue().lerp(Color.BLACK,0.5f)
|
||||
|
||||
@ -214,8 +215,10 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
||||
if (!city.isPuppet) {
|
||||
selectedTile = tileInfo
|
||||
if (tileGroup.isWorkable && UncivGame.Current.worldScreen.isPlayersTurn) {
|
||||
if (!tileInfo.isWorked() && city.population.getFreePopulation() > 0)
|
||||
if (!tileInfo.isWorked() && city.population.getFreePopulation() > 0) {
|
||||
city.workedTiles.add(tileInfo.position)
|
||||
game.settings.addMissionCompleted("Reassign worked tiles")
|
||||
}
|
||||
else if (tileInfo.isWorked()) city.workedTiles.remove(tileInfo.position)
|
||||
city.cityStats.update()
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
cityScreen.city.cityConstructions.currentConstructionIsUserSet = true
|
||||
cityScreen.city.cityStats.update()
|
||||
cityScreen.update()
|
||||
cityScreen.game.settings.addMissionCompleted("Pick construction")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.unciv.ui.newgamescreen
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin
|
||||
import com.badlogic.gdx.utils.Array
|
||||
@ -31,7 +32,8 @@ class NewGameScreen: PickerScreen(){
|
||||
setDefaultCloseAction()
|
||||
|
||||
val playerPickerTable = PlayerPickerTable(this, newGameParameters)
|
||||
topTable.add(NewGameScreenOptionsTable(this) { playerPickerTable.update() })
|
||||
val newGameScreenOptionsTable = NewGameScreenOptionsTable(this) { playerPickerTable.update() }
|
||||
topTable.add(ScrollPane(newGameScreenOptionsTable)).height(topTable.parent.height)
|
||||
topTable.add(playerPickerTable).pad(10f)
|
||||
topTable.pack()
|
||||
topTable.setFillParent(true)
|
||||
|
@ -23,7 +23,7 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val onMultipla
|
||||
val ruleset = newGameScreen.ruleSet
|
||||
|
||||
init {
|
||||
|
||||
pad(10f)
|
||||
add("Map options".toLabel(fontSize = 24)).colspan(2).row()
|
||||
addMapTypeSelection()
|
||||
|
||||
|
@ -16,7 +16,7 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
|
||||
init {
|
||||
touchable = Touchable.enabled
|
||||
defaults().pad(10f)
|
||||
background = ImageGetter.getTableBackground()
|
||||
background = ImageGetter.getRoundedEdgeTableBackground()
|
||||
if (ImageGetter.techIconExists(techName))
|
||||
add(ImageGetter.getTechIconGroup(techName, 60f))
|
||||
|
||||
|
@ -51,6 +51,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||
setButtonsInfo()
|
||||
rightSideButton.setText("Pick a tech".tr())
|
||||
rightSideButton.onClick("paper") {
|
||||
game.settings.addMissionCompleted("Pick technology")
|
||||
if (isFreeTechPick) civTech.getFreeTechnology(selectedTech!!.name)
|
||||
else civTech.techsToResearch = tempTechsToResearch
|
||||
|
||||
@ -59,7 +60,6 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||
dispose()
|
||||
}
|
||||
|
||||
displayTutorials("Technology")
|
||||
|
||||
// per default show current/recent technology,
|
||||
// and possibly select it to show description,
|
||||
|
@ -47,7 +47,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
|
||||
if (tileGroup.tileInfo.airUnits.isEmpty()) return
|
||||
val secondarycolor = city.civInfo.nation.getInnerColor()
|
||||
val airUnitTable = Table().apply { defaults().pad(5f) }
|
||||
airUnitTable.background = ImageGetter.getTableBackground(city.civInfo.nation.getOuterColor())
|
||||
airUnitTable.background = ImageGetter.getRoundedEdgeTableBackground(city.civInfo.nation.getOuterColor())
|
||||
val aircraftImage = ImageGetter.getImage("OtherIcons/Aircraft")
|
||||
aircraftImage.color = secondarycolor
|
||||
airUnitTable.add(aircraftImage).size(15f)
|
||||
@ -92,7 +92,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
|
||||
val secondaryColor = city.civInfo.nation.getInnerColor()
|
||||
val iconTable = Table()
|
||||
iconTable.touchable=Touchable.enabled
|
||||
iconTable.background = ImageGetter.getTableBackground(city.civInfo.nation.getOuterColor())
|
||||
iconTable.background = ImageGetter.getRoundedEdgeTableBackground(city.civInfo.nation.getOuterColor())
|
||||
|
||||
if (city.resistanceCounter > 0) {
|
||||
val resistanceImage = ImageGetter.getImage("StatIcons/Resistance")
|
||||
|
@ -65,7 +65,7 @@ object ImageGetter {
|
||||
else return textureRegionDrawables[whiteDotLocation]!!
|
||||
}
|
||||
|
||||
fun getTableBackground(tintColor: Color?=null): Drawable? {
|
||||
fun getRoundedEdgeTableBackground(tintColor: Color?=null): Drawable? {
|
||||
val drawable = getDrawable("OtherIcons/civTableBackground")
|
||||
drawable.minHeight=0f
|
||||
drawable.minWidth=0f
|
||||
|
@ -35,7 +35,7 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu
|
||||
|
||||
listItem.add(ImageGetter.getCircle()
|
||||
.apply { color=notification.color }).size(10f).pad(5f)
|
||||
listItem.background = ImageGetter.getTableBackground()
|
||||
listItem.background = ImageGetter.getRoundedEdgeTableBackground()
|
||||
listItem.add(label).pad(5f).padRight(10f)
|
||||
|
||||
// using a large click area with no gap in between each message item.
|
||||
|
@ -205,6 +205,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
|
||||
if (dto.unit.currentMovement > 0)
|
||||
moveHereButton.onClick(""){
|
||||
UncivGame.Current.settings.addMissionCompleted("Move unit")
|
||||
UnitContextMenu(this, dto.unit, dto.tileInfo).onMoveButtonClick()
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.GameSaver
|
||||
@ -50,6 +51,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
private val techButtonHolder = Table()
|
||||
private val diplomacyButtonWrapper = Table()
|
||||
private val nextTurnButton = createNextTurnButton()
|
||||
private val missionTable=Table().apply { background=ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) }
|
||||
|
||||
private val notificationsScroll: NotificationsScroll
|
||||
var alertPopupIsOpen = false // if we have an alert popup and then we changed screens, the old one shouldn't affect us
|
||||
@ -87,6 +89,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
stage.addActor(nextTurnButton)
|
||||
stage.addActor(techPolicyandVictoryHolder)
|
||||
stage.addActor(notificationsScroll)
|
||||
stage.addActor(missionTable)
|
||||
|
||||
|
||||
diplomacyButtonWrapper.defaults().pad(5f)
|
||||
@ -99,8 +102,8 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
|
||||
stage.addActor(unitActionsTable)
|
||||
|
||||
displayTutorials("New_Game")
|
||||
displayTutorials("World_Map")
|
||||
// displayTutorials("New_Game")
|
||||
// displayTutorials("World_Map")
|
||||
|
||||
createNextTurnButton() // needs civ table to be positioned
|
||||
|
||||
@ -165,6 +168,17 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
bottomTileInfoTable.y=if(UncivGame.Current.settings.showMinimap)minimapWrapper.height else 0f
|
||||
battleTable.update()
|
||||
|
||||
missionTable.clear()
|
||||
val mission =getCurrentMission()
|
||||
if(mission==""){missionTable.isVisible=false}
|
||||
else {
|
||||
missionTable.add(mission.toLabel()
|
||||
.apply { setAlignment(Align.center) }).pad(10f)
|
||||
missionTable.pack()
|
||||
missionTable.centerX(stage)
|
||||
missionTable.y = topBar.y - missionTable.height
|
||||
}
|
||||
|
||||
minimapWrapper.update(viewingCiv)
|
||||
unitActionsTable.update(bottomUnitTable.selectedUnit)
|
||||
unitActionsTable.y = bottomUnitTable.height
|
||||
@ -200,6 +214,35 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
|
||||
}
|
||||
|
||||
private fun getCurrentMission(): String {
|
||||
val completedMissions = game.settings.missionsCompleted
|
||||
if(!completedMissions.contains("Move unit"))
|
||||
return "Move a unit!\nClick on a unit > Click on a destination > Click the arrow popup"
|
||||
if(!completedMissions.contains("Found city"))
|
||||
return "Found a city!\nSelect the Settler (flag unit) > Click on 'Found city' (bottom-left corner)"
|
||||
if(!completedMissions.contains("Enter city screen"))
|
||||
return "Enter the city screen!\nClick the city button twice"
|
||||
if(!completedMissions.contains("Pick technology"))
|
||||
return "Pick a technology to research!\nClick on the tech button (greenish, top left) > \n select technology > click 'Research' (bottom right)"
|
||||
if(!completedMissions.contains("Pick construction"))
|
||||
return "Pick a construction!\nEnter city screen > Click on a unit or building (left side)"
|
||||
if(!completedMissions.contains("Pass a turn"))
|
||||
return "Pass a turn!\nCycle through units with 'Next unit' > Click 'Next turn'"
|
||||
if(!completedMissions.contains("Reassign worked tiles"))
|
||||
return "Reassign worked tiles!\nEnter city screen > click the assigned (green) tile to unassign > " +
|
||||
"\n click an unassigned tile to assign population"
|
||||
if(!completedMissions.contains("Meet another civilization"))
|
||||
return "Meet another civilization!\nExplore the map until you encounter another civilization!"
|
||||
if(!completedMissions.contains("Open the options table"))
|
||||
return "Open the options table!\nClick the menu button (top left) > click 'Options'"
|
||||
if(!completedMissions.contains("Construct an improvement"))
|
||||
return "Construct an improvement!\nConstruct a Worker unit > Move to a Plains or Grassland tile > " +
|
||||
"\n Choose 'Create improvement' > Choose the farm > " +
|
||||
"\n Leave the worker there until it's finished"
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
private fun displayTutorialsOnUpdate() {
|
||||
if (UncivGame.Current.settings.hasCrashedRecently) {
|
||||
displayTutorials("_GameCrashed")
|
||||
@ -208,13 +251,6 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
UncivGame.Current.settings.save()
|
||||
}
|
||||
|
||||
if (bottomUnitTable.selectedUnit != null) displayTutorials("Unit_Selected")
|
||||
if (viewingCiv.cities.isNotEmpty()){
|
||||
displayTutorials("_City_Founded")
|
||||
displayTutorials("First_Steps")
|
||||
}
|
||||
if (UncivGame.Current.settings.tutorialsShown.contains("Cities")) displayTutorials("Next_Turn")
|
||||
|
||||
|
||||
if (!UncivGame.Current.settings.tutorialsShown.contains("_EnemyCityNeedsConqueringWithMeleeUnit")) {
|
||||
for (enemyCity in viewingCiv.diplomacy.values.filter { it.diplomaticStatus == DiplomaticStatus.War }
|
||||
@ -260,7 +296,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
|
||||
if (viewingCiv.tech.currentTechnology() == null) {
|
||||
val buttonPic = Table()
|
||||
buttonPic.background = ImageGetter.getTableBackground(colorFromRGB(7, 46, 43))
|
||||
buttonPic.background = ImageGetter.getRoundedEdgeTableBackground(colorFromRGB(7, 46, 43))
|
||||
buttonPic.defaults().pad(20f)
|
||||
buttonPic.add("{Pick a tech}!".toLabel(Color.WHITE,30))
|
||||
techButtonHolder.add(buttonPic)
|
||||
@ -312,6 +348,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
return@onClick
|
||||
}
|
||||
|
||||
game.settings.addMissionCompleted("Pass a turn")
|
||||
nextTurn() // If none of the above
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||
var selectedLanguage: String = "English"
|
||||
|
||||
init {
|
||||
UncivGame.Current.settings.addMissionCompleted("Open the options table")
|
||||
update()
|
||||
open()
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ class UnitActions {
|
||||
unit.currentMovement >0 &&
|
||||
!tile.getTilesInDistance(3).any { it.isCityCenter() })
|
||||
{
|
||||
UncivGame.Current.settings.addMissionCompleted("Found city")
|
||||
unit.civInfo.addCity(tile.position)
|
||||
tile.improvement = null
|
||||
unit.destroy()
|
||||
|
Reference in New Issue
Block a user