From c8ddf6dc6335b1580350be8d73fb7eaa317481db Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 23 May 2018 22:59:05 +0300 Subject: [PATCH] Added icons for unit actions --- android/assets/OtherIcons/Stop.png | Bin 0 -> 2860 bytes .../unciv/ui/worldscreen/unit/UnitActions.kt | 19 +--------- .../ui/worldscreen/unit/UnitActionsTable.kt | 34 ++++++++++++++++-- 3 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 android/assets/OtherIcons/Stop.png diff --git a/android/assets/OtherIcons/Stop.png b/android/assets/OtherIcons/Stop.png new file mode 100644 index 0000000000000000000000000000000000000000..11e8562a6413683c6d93bd29a32fcc2681bb4a02 GIT binary patch literal 2860 zcmW+&eLRzU8=qlV%-D#`%U*0oacF9FaF&MMGB4vec;t0G(NS%5YL#eOF^O%QWZt5w zM<_?NxdO%&0h)mm^W6=l0y6&+q=-*Y&-w@Atay-|vr07#!$l1m6aS zKp;i{gU$kX<>u0df$xThI~CxjljaSC>4Q(YK061r4LFR*Gzer1YIA8pq-7Qm2>b~^ z-xtO!dtZK_{^0l4*`3Yd)pVa^PF%`w)3oFrc-9Vpyz5ASlX*e_y2eLdThNnKjR?rg z6>_ipQoORhF&R#}0PVQlj6DJEKr%I+M?>(<=P&FU9X*TDIG=esmiF<-hUM6T@#1v+ zbnDsib6(W@?@kTEumYsF{zQq{s9s!;!kp*Q-RZ1ogLSJlQpn7has3>RNypXeZScPo-ZG!B7F8~WN7~YKV&EF> z(QUSV%r*oMyKsJ)pI7sN76Vx~(0{nJ%JT2^nPcbo8662H<#_s&7T z9IdvLil(ZFWLWeCB4JN0;7_Mu`$L&5+;szBY>cTcEGioZIt^FtKUcXN-UW5RO#uFP z_$>zgVBa|3dzMUATeSgDGPf`9-}Va!H7++l%v;8h640@I8{Pw)BN8_#lks+4G`=B~Q!PX8d`0hEan~LsrzyOAV6^G`L$h93IEjFvVQRm=1GtQm`?aM9|33gIZ z&XQ}XOlF=#BqW%Z@BLyTm*p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ANSS|NJ45=E)JxbSi)*5Ts+ZR_3GPd_j7dwdJgFW%xfc(WToZrQtRq*SIn^aZ1i z9IXa&J>K0%Zf(@!!PhS1kG?)oVD;izpZP#Lw;*K&BE|pKRQNVAu)*bO-mEPnZb&+? zX16p%sPW1lYCEtYTjoz8^(mbv?gIYSEkW4GMlYn2gamO|Amli%OCSpihn$N4`Z?nB zO6PRU&KMB!*vdbJZ>s|QBQuZ_)=bvG!o7E~5fjEt);}Lhx5lt0N}YxX_I{c4n9R#k zcd2aZO$G%k%qNmhubwr%CVDntqp5_XHfQ&1eDBt@!=4fB59SYR>dfnnWyUqSP^nCo zvxb(8N808jfjrjkSfJ=nc~E0!)-w%m;ZE}wd(9A`chvaTSX}%SB6(NF%}2c^$=3n@ z=+5EyO*utiPQFyc&LfiJzZhL)GV15PIn*DhviT5spyLz1(TvyknYKAhf)gd~hYjN) X-*#5_=|?W$xC;S%0_k_W { - return getUnitActions(unit, worldScreen).map { getUnitActionButton(it) } - } fun getUnitActions(unit:MapUnit,worldScreen: WorldScreen): List { val tile = unit.getTile() @@ -70,10 +62,7 @@ class UnitActions { } if (unit.name == "Worker") { - val improvementButtonText: String - if (tile.improvementInProgress == null) improvementButtonText = "Construct\r\nimprovement" - else improvementButtonText = tile.improvementInProgress!! + "\r\nin progress" - actionList += UnitAction(improvementButtonText, + actionList += UnitAction("Construct improvement", { worldScreen.game.screen = ImprovementPickerScreen(tile) }, unit.currentMovement != 0f && !tile.isCityCenter() || GameBasics.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }) @@ -144,11 +133,5 @@ class UnitActions { return actionList } - private fun getUnitActionButton(unitAction: UnitAction): TextButton { - val actionButton = TextButton(unitAction.name, CameraStageBaseScreen.skin) - actionButton.addClickListener({ unitAction.action(); UnCivGame.Current.worldScreen!!.update() }) - if (!unitAction.canAct) actionButton.disable() - return actionButton - } } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt index 2147fe772e..2a183e546b 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt @@ -1,10 +1,16 @@ package com.unciv.ui.worldscreen.unit import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.scenes.scene2d.ui.Button import com.badlogic.gdx.scenes.scene2d.ui.Image +import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Table +import com.unciv.UnCivGame import com.unciv.logic.map.MapUnit +import com.unciv.ui.cityscreen.addClickListener +import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.ImageGetter +import com.unciv.ui.utils.disable import com.unciv.ui.worldscreen.WorldScreen class UnitActionsTable(val worldScreen: WorldScreen) : Table(){ @@ -13,7 +19,19 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){ when(unitAction){ "Move unit" -> return ImageGetter.getStatIcon("Movement") "Stop movement"-> return ImageGetter.getStatIcon("Movement").apply { color= Color.RED } - + "Fortify" -> return ImageGetter.getImage("UnitIcons/Shield.png").apply { color= Color.BLACK } + "Construct improvement" -> return ImageGetter.getImage("UnitIcons/Worker.png") + "Automate" -> return ImageGetter.getImage("UnitIcons/Great Engineer.png") + "Stop automation" -> return ImageGetter.getImage("OtherIcons/Stop.png") + "Found city" -> return ImageGetter.getImage("UnitIcons/Settler.png") + "Discover Technology" -> return ImageGetter.getImage("UnitIcons/Great Scientist.png") + "Construct Academy" -> return ImageGetter.getImage("ImprovementIcons/Academy_(Civ5).png") + "Start Golden Age" -> return ImageGetter.getImage("UnitIcons/Great Artist.png") + "Construct Landmark" -> return ImageGetter.getImage("ImprovementIcons/Landmark_(Civ5).png") + "Hurry Wonder" -> return ImageGetter.getImage("UnitIcons/Great Engineer.png") + "Construct Manufactory" -> return ImageGetter.getImage("ImprovementIcons/Manufactory_(Civ5).png") + "Conduct Trade Mission" -> return ImageGetter.getImage("UnitIcons/Great Merchant.png") + "Construct Customs House" -> return ImageGetter.getImage("ImprovementIcons/Customs_house_(Civ5).png") else -> return ImageGetter.getImage("StatIcons/Star.png") } } @@ -21,9 +39,21 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){ fun update(unit: MapUnit?){ clear() if (unit == null) return - for (button in UnitActions().getUnitActionButtons(unit, worldScreen)) + for (button in UnitActions().getUnitActions(unit, worldScreen).map { getUnitActionButton(it) }) add(button).colspan(2).pad(5f) .size(button.width * worldScreen.buttonScale, button.height * worldScreen.buttonScale).row() pack() } + + + private fun getUnitActionButton(unitAction: UnitAction): Button { + val actionButton = Button(CameraStageBaseScreen.skin) + actionButton.add(getIconForUnitAction(unitAction.name)).size(20f).pad(5f) + actionButton.add(Label(unitAction.name,CameraStageBaseScreen.skin) + .apply { style= Label.LabelStyle(style); style.fontColor = Color.WHITE }) + actionButton.pack() + actionButton.addClickListener({ unitAction.action(); UnCivGame.Current.worldScreen!!.update() }) + if (!unitAction.canAct) actionButton.disable() + return actionButton + } } \ No newline at end of file