mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-28 05:39:10 +07:00
Clean up refactored pixel unit resolving. (#5979)
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 368 B After Width: | Height: | Size: 387 B |
Binary file not shown.
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 368 B |
@ -655,7 +655,7 @@ open class TileGroup(var tileInfo: TileInfo, val tileSetStrings:TileSetStrings,
|
||||
fun TileSetStrings.getThisUnit(): String? {
|
||||
val specificUnitIconLocation = this.unitsLocation + militaryUnit.name
|
||||
return ImageAttempter(militaryUnit)
|
||||
.forceImage { if (!UncivGame.Current.settings.showPixelUnits) "" else null } // For now I am just converting existing logic, but this should be made into a short-circuit at the very start.
|
||||
.forceImage { if (!UncivGame.Current.settings.showPixelUnits) "" else null }
|
||||
.tryImage { if (civInfo.nation.style.isEmpty()) specificUnitIconLocation else null }
|
||||
.tryImage { "$specificUnitIconLocation-${civInfo.nation.style}" }
|
||||
.tryImage { specificUnitIconLocation }
|
||||
@ -668,7 +668,7 @@ open class TileGroup(var tileInfo: TileInfo, val tileSetStrings:TileSetStrings,
|
||||
null
|
||||
} // .tryImage/.tryImages takes functions as parameters, for lazy eval. Include the check as part of the .tryImage's lazy candidate parameter, and *not* as part of the .map's transform parameter, so even the name check will be skipped by ImageAttempter if an image has already been found.
|
||||
)
|
||||
.tryImage { if (type.isLandUnit()) landUnit else null } // FIXME: Based on FantasyHex's structure this also needs to be in .unitsLocation. But again I am just converting existing logic right now, will do later after this refactor has had a chance to be validated.
|
||||
.tryImage { if (type.isLandUnit()) landUnit else null }
|
||||
.tryImage { if (type.isWaterUnit()) waterUnit else null }
|
||||
.getPathOrNull()
|
||||
}
|
||||
@ -699,10 +699,10 @@ open class TileGroup(var tileInfo: TileInfo, val tileSetStrings:TileSetStrings,
|
||||
fun TileSetStrings.getThisUnit(): String? {
|
||||
val specificUnitIconLocation = this.unitsLocation + civilianUnit.name
|
||||
return ImageAttempter(civilianUnit)
|
||||
.forceImage { if (!UncivGame.Current.settings.showPixelUnits) "" else null } // For now I am just converting existing logic, but this should be made into a short-circuit at the very start.
|
||||
.tryImage { if (civInfo.nation.style.isEmpty()) specificUnitIconLocation else null }
|
||||
.tryImage { "$specificUnitIconLocation-${civInfo.nation.style}" }
|
||||
.tryImage { specificUnitIconLocation } // This seems redundant with the one above… But right now I'm just converting the existing code. Could remove if you can confirm they're redundant.
|
||||
.forceImage { if (!UncivGame.Current.settings.showPixelUnits) "" else null }
|
||||
.tryImage { if (civInfo.nation.style.isNotEmpty()) "$specificUnitIconLocation-${civInfo.nation.style}" else null }
|
||||
.tryImage { specificUnitIconLocation }
|
||||
.tryImage { civilianLandUnit }
|
||||
.getPathOrNull()
|
||||
}
|
||||
newImageLocation = tileSetStrings.getThisUnit() ?: tileSetStrings.fallback?.getThisUnit() ?: ""
|
||||
|
@ -35,6 +35,7 @@ class TileSetStrings(tileSet: String = UncivGame.Current.settings.tileSet, fallb
|
||||
val unitsLocation = tileSetLocation + "Units/"
|
||||
val landUnit = unitsLocation + "LandUnit"
|
||||
val waterUnit = unitsLocation + "WaterUnit"
|
||||
val civilianLandUnit = unitsLocation + "CivilianLandUnit"
|
||||
|
||||
val bordersLocation = tileSetLocation + "Borders/"
|
||||
|
||||
|
Reference in New Issue
Block a user