UnitActions seprated into own atlas (#8102)

Co-authored-by: tunerzinc@gmail.com <vfylfhby>
This commit is contained in:
vegeta1k95 2022-12-09 11:46:46 +01:00 committed by GitHub
parent d9d0414477
commit 58c57d6626
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 257 additions and 64 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1 +1 @@
[AbsoluteUnits,Construction,EasterEggs,Flags,NationIcons,PolicyIcons,ReligionIcons,Skin,Tech,Tilesets,UnitPromotionIcons]
[AbsoluteUnits,Construction,EasterEggs,Flags,NationIcons,PolicyIcons,ReligionIcons,Skin,Tech,Tilesets,UnitPromotionIcons,UnitActionIcons]

View File

@ -0,0 +1,216 @@
UnitActionIcons.png
size: 2048, 1024
format: RGBA8888
filter: MipMapLinearLinear, MipMapLinearLinear
repeat: none
UnitActionIcons/AirSweep
rotate: false
xy: 0, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/DisbandUnit
rotate: false
xy: 100, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Fortify
rotate: false
xy: 200, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Pillage
rotate: false
xy: 300, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Present
rotate: false
xy: 400, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/RemoveHeresy
rotate: false
xy: 500, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Sleep
rotate: false
xy: 600, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Star
rotate: false
xy: 700, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Stop
rotate: false
xy: 800, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Swap
rotate: false
xy: 900, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Wait
rotate: false
xy: 1000, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Automate
rotate: false
xy: 1100, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Explore
rotate: false
xy: 1200, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Promote
rotate: false
xy: 1300, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Paradrop
rotate: false
xy: 1400, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/SetUp
rotate: false
xy: 1500, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/FoundCity
rotate: false
xy: 1600, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/ConstructImprovement
rotate: false
xy: 1700, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Repair
rotate: false
xy: 1800, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/HurryResearch
rotate: false
xy: 0, 100
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/StartGoldenAge
rotate: false
xy: 100, 100
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/HurryConstruction
rotate: false
xy: 200, 100
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/FoundReligion
rotate: false
xy: 300, 100
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/EnhanceReligion
rotate: false
xy: 400, 100
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/AddInCapital
rotate: false
xy: 500, 100
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/ShowMore
rotate: false
xy: 725, 125
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
UnitActionIcons/HideMore
rotate: false
xy: 825, 125
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
UnitActionIcons/StopMove
rotate: false
xy: 925, 125
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
UnitActionIcons/FortifyUntilHealed
rotate: false
xy: 1000, 100
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Upgrade
rotate: false
xy: 1100, 100
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -16,18 +16,15 @@ import com.unciv.ui.utils.extensions.darken
* Note this is for the buttons offering actions, not the ongoing action stored with a [MapUnit][com.unciv.logic.map.MapUnit]
*/
data class UnitAction(
val type: UnitActionType,
val title: String = type.value,
val isCurrentAction: Boolean = false,
val uncivSound: UncivSound = type.uncivSound,
val action: (() -> Unit)? = null
val type: UnitActionType,
val title: String = type.value,
val isCurrentAction: Boolean = false,
val uncivSound: UncivSound = type.uncivSound,
val action: (() -> Unit)? = null
) {
fun getIcon(): Actor {
if (type.imageGetter != null) return type.imageGetter.invoke()
return when (type) {
UnitActionType.Upgrade -> {
ImageGetter.getUnitIcon(title.getPlaceholderParameters()[0])
}
UnitActionType.Create -> {
ImageGetter.getImprovementIcon(title.getPlaceholderParameters()[0])
}
@ -38,19 +35,9 @@ data class UnitAction(
else "Pantheon"
).apply { color = Color.BLACK }
}
UnitActionType.Fortify, UnitActionType.FortifyUntilHealed -> {
val match = fortificationRegex.matchEntire(title)
val percentFortified = match?.groups?.get(1)?.value?.toInt() ?: 0
ImageGetter.getImage("OtherIcons/Shield").apply {
color = Color.GREEN.darken(1f - percentFortified / 80f)
}
}
else -> ImageGetter.getImage("OtherIcons/Star").apply { color = Color.BLACK }
else -> ImageGetter.getImage("UnitActionIcons/Star").apply { color = Color.BLACK }
}
}
companion object {
private val fortificationRegex = Regex(""".* (\d+)%""")
}
}
/** Unit Actions - generic enum with static properties
@ -71,80 +58,77 @@ enum class UnitActionType(
val uncivSound: UncivSound = UncivSound.Click
) {
SwapUnits("Swap units",
{ ImageGetter.getImage("OtherIcons/Swap") }, 'y'),
{ ImageGetter.getImage("UnitActionIcons/Swap") }, 'y'),
Automate("Automate",
{ ImageGetter.getUnitIcon("Great Engineer") }, 'm'),
{ ImageGetter.getImage("UnitActionIcons/Automate") }, 'm'),
StopAutomation("Stop automation",
{ ImageGetter.getImage("OtherIcons/Stop") }, 'm'),
{ ImageGetter.getImage("UnitActionIcons/Stop") }, 'm'),
StopMovement("Stop movement",
{ imageGetStopMove() }, '.'),
{ ImageGetter.getImage("UnitActionIcons/StopMove") }, '.'),
Sleep("Sleep",
{ ImageGetter.getImage("OtherIcons/Sleep") }, 'f'),
{ ImageGetter.getImage("UnitActionIcons/Sleep") }, 'f'),
SleepUntilHealed("Sleep until healed",
{ ImageGetter.getImage("OtherIcons/Sleep") }, 'h'),
// Note: Both Fortify actions are a special case. The button starting fortification uses the `value` here,
// the button label as shown when the unit is already fortifying is "Fortification".tr() + " nn%".
// For now we keep it simple, and the unit test `allUnitActionsHaveTranslation` does not know about the latter.
{ ImageGetter.getImage("UnitActionIcons/Sleep") }, 'h'),
Fortify("Fortify",
null, 'f', UncivSound.Fortify),
{ ImageGetter.getImage("UnitActionIcons/Fortify") }, 'f', UncivSound.Fortify),
FortifyUntilHealed("Fortify until healed",
null, 'h', UncivSound.Fortify),
{ ImageGetter.getImage("UnitActionIcons/FortifyUntilHealed") }, 'h', UncivSound.Fortify),
Explore("Explore",
{ ImageGetter.getUnitIcon("Scout") }, 'x'),
{ ImageGetter.getImage("UnitActionIcons/Explore") }, 'x'),
StopExploration("Stop exploration",
{ ImageGetter.getImage("OtherIcons/Stop") }, 'x'),
{ ImageGetter.getImage("UnitActionIcons/Stop") }, 'x'),
Promote("Promote",
{ imageGetPromote() }, 'o', UncivSound.Promote),
{ ImageGetter.getImage("UnitActionIcons/Promote") }, 'o', UncivSound.Promote),
Upgrade("Upgrade",
null, 'u', UncivSound.Upgrade),
{ ImageGetter.getImage("UnitActionIcons/Upgrade") }, 'u', UncivSound.Upgrade),
Pillage("Pillage",
{ ImageGetter.getImage("OtherIcons/Pillage") }, 'p'),
{ ImageGetter.getImage("UnitActionIcons/Pillage") }, 'p'),
Paradrop("Paradrop",
{ ImageGetter.getUnitIcon("Paratrooper") }, 'p'),
{ ImageGetter.getImage("UnitActionIcons/Paradrop") }, 'p'),
AirSweep("Air Sweep",
{ ImageGetter.getImage("OtherIcons/AirSweep") }, 'a'),
{ ImageGetter.getImage("UnitActionIcons/AirSweep") }, 'a'),
SetUp("Set up",
{ ImageGetter.getUnitIcon("Catapult") }, 't', UncivSound.Setup),
{ ImageGetter.getImage("UnitActionIcons/SetUp") }, 't', UncivSound.Setup),
FoundCity("Found city",
{ ImageGetter.getUnitIcon(Constants.settler) }, 'c', UncivSound.Silent),
{ ImageGetter.getImage("UnitActionIcons/FoundCity") }, 'c', UncivSound.Silent),
ConstructImprovement("Construct improvement",
{ ImageGetter.getUnitIcon(Constants.worker) }, 'i'),
{ ImageGetter.getImage("UnitActionIcons/ConstructImprovement") }, 'i'),
Repair(Constants.repair,
{ ImageGetter.getUnitIcon(Constants.worker) }, 'r', UncivSound.Construction),
{ ImageGetter.getImage("UnitActionIcons/Repair") }, 'r', UncivSound.Construction),
Create("Create",
null, 'i', UncivSound.Chimes),
HurryResearch("Hurry Research",
{ ImageGetter.getUnitIcon("Great Scientist") }, 'g', UncivSound.Chimes),
{ ImageGetter.getImage("UnitActionIcons/HurryResearch") }, 'g', UncivSound.Chimes),
StartGoldenAge("Start Golden Age",
{ ImageGetter.getUnitIcon("Great Artist") }, 'g', UncivSound.Chimes),
{ ImageGetter.getImage("UnitActionIcons/StartGoldenAge") }, 'g', UncivSound.Chimes),
HurryWonder("Hurry Wonder",
{ ImageGetter.getUnitIcon("Great Engineer") }, 'g', UncivSound.Chimes),
{ ImageGetter.getImage("UnitActionIcons/HurryConstruction") }, 'g', UncivSound.Chimes),
HurryBuilding("Hurry Construction",
{ ImageGetter.getUnitIcon("Great Engineer") }, 'g', UncivSound.Chimes),
{ ImageGetter.getImage("UnitActionIcons/HurryConstruction") }, 'g', UncivSound.Chimes),
ConductTradeMission("Conduct Trade Mission",
{ ImageGetter.getUnitIcon("Great Merchant") }, 'g', UncivSound.Chimes),
{ ImageGetter.getImage("UnitActionIcons/ConductTradeMission") }, 'g', UncivSound.Chimes),
FoundReligion("Found a Religion",
{ ImageGetter.getUnitIcon("Great Prophet") }, 'g', UncivSound.Choir),
{ ImageGetter.getImage("UnitActionIcons/FoundReligion") }, 'g', UncivSound.Choir),
TriggerUnique("Trigger unique",
{ ImageGetter.getImage("OtherIcons/Star") }, 'g', UncivSound.Chimes),
{ ImageGetter.getImage("UnitActionIcons/Star") }, 'g', UncivSound.Chimes),
SpreadReligion("Spread Religion",
null, 'g', UncivSound.Choir),
RemoveHeresy("Remove Heresy",
{ ImageGetter.getImage("OtherIcons/Remove Heresy") }, 'h', UncivSound.Fire),
{ ImageGetter.getImage("UnitActionIcons/RemoveHeresy") }, 'h', UncivSound.Fire),
EnhanceReligion("Enhance a Religion",
{ ImageGetter.getUnitIcon("Great Prophet") }, 'g', UncivSound.Choir),
{ ImageGetter.getImage("UnitActionIcons/EnhanceReligion") }, 'g', UncivSound.Choir),
DisbandUnit("Disband unit",
{ ImageGetter.getImage("OtherIcons/DisbandUnit") }, KeyCharAndCode.DEL),
{ ImageGetter.getImage("UnitActionIcons/DisbandUnit") }, KeyCharAndCode.DEL),
GiftUnit("Gift unit",
{ ImageGetter.getImage("OtherIcons/Present") }, UncivSound.Silent),
{ ImageGetter.getImage("UnitActionIcons/Present") }, UncivSound.Silent),
Wait("Wait",
{ ImageGetter.getImage("OtherIcons/Wait") }, 'z', UncivSound.Silent),
{ ImageGetter.getImage("UnitActionIcons/Wait") }, 'z', UncivSound.Silent),
ShowAdditionalActions("Show more",
{ imageGetShowMore() }, KeyCharAndCode(Input.Keys.PAGE_DOWN)),
{ ImageGetter.getImage("UnitActionIcons/ShowMore") }, KeyCharAndCode(Input.Keys.PAGE_DOWN)),
HideAdditionalActions("Back",
{ imageGetHideMore() }, KeyCharAndCode(Input.Keys.PAGE_UP)),
{ ImageGetter.getImage("UnitActionIcons/HideMore") }, KeyCharAndCode(Input.Keys.PAGE_UP)),
AddInCapital( "Add in capital",
{ ImageGetter.getUnitIcon("SS Cockpit")}, 'g', UncivSound.Chimes),
{ ImageGetter.getImage("UnitActionIcons/AddInCapital")}, 'g', UncivSound.Chimes),
;
// Allow shorter initializations
@ -153,11 +137,4 @@ enum class UnitActionType(
constructor(value: String, imageGetter: (() -> Actor)?, uncivSound: UncivSound = UncivSound.Click)
: this(value, imageGetter, KeyCharAndCode.UNKNOWN, uncivSound)
companion object {
// readability factories
private fun imageGetStopMove() = ImageGetter.getStatIcon("Movement").apply { color = Color.RED }
private fun imageGetPromote() = ImageGetter.getImage("OtherIcons/Star").apply { color = Color.GOLD }
private fun imageGetShowMore() = ImageGetter.getArrowImage(Align.right).apply { color = Color.BLACK }
private fun imageGetHideMore() = ImageGetter.getArrowImage(Align.left).apply { color = Color.BLACK }
}
}