Redraw skin Images, edit skin load method (#4080)

This commit is contained in:
lishaoxia1985 2021-06-10 15:10:13 -05:00 committed by GitHub
parent 91154aed34
commit 7e284f998b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 2183 additions and 2278 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 951 B

BIN
android/Skin/checkbox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

View File

Before

Width:  |  Height:  |  Size: 832 B

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

BIN
android/Skin/select-box.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

View File

@ -2,7 +2,7 @@
BuildingIcons.png
size: 2048, 1024
format: RGBA8888
filter: MipMapLinearLinear, MipMapLinearLinear
filter: Nearest, Nearest
repeat: none
Alhambra
rotate: false

View File

@ -2,7 +2,7 @@
FlagIcons.png
size: 2048, 512
format: RGBA8888
filter: MipMapLinearLinear, MipMapLinearLinear
filter: Nearest, Nearest
repeat: none
Brazilian_Portuguese
rotate: false

48
android/assets/Skin.atlas Normal file
View File

@ -0,0 +1,48 @@
Skin.png
size: 256, 64
format: RGBA8888
filter: Linear, Linear
repeat: none
checkbox
rotate: false
xy: 140, 26
size: 31, 31
orig: 31, 31
offset: 0, 0
index: -1
checkbox-pressed
rotate: false
xy: 173, 26
size: 31, 31
orig: 31, 31
offset: 0, 0
index: -1
rectangleWithOutline
rotate: false
xy: 2, 2
size: 3, 3
orig: 3, 3
offset: 0, 0
index: -1
roundedEdgeRectangle
rotate: false
xy: 2, 7
size: 52, 50
orig: 52, 50
offset: 0, 0
index: -1
select-box
rotate: false
xy: 56, 27
size: 40, 30
orig: 40, 30
offset: 0, 0
index: -1
select-box-pressed
rotate: false
xy: 98, 27
size: 40, 30
orig: 40, 30
offset: 0, 0
index: -1

View File

@ -50,128 +50,88 @@ com.badlogic.gdx.graphics.Color: {
}
com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable: {
button-c: {
name: "Button"
name: "RoundedEdgeRectangle"
color: color
}
button-pressed-c: {
name: "Button"
color: color
button-p: {
name: "RoundedEdgeRectangle"
color: pressed
}
button-h: {
name: "Button"
name: "RoundedEdgeRectangle"
color: highlight
}
checkbox-c: {
name: checkbox
name: "Checkbox"
color: color
}
checkbox-pressed-c: {
name: checkbox-pressed
name: "Checkbox-pressed"
color: color
}
list-c: {
name: list
name: "RectangleWithOutline"
color: color
}
scrollbar-c: {
name: scrollbar
name: "Scrollbar"
color: color
}
select-box-c: {
name: select-box
name: "Select-box"
color: color
}
select-box-pressed-c: {
name: select-box-pressed
name: "Select-box-pressed"
color: color
}
slider-horizontal-c: {
name: slider-horizontal
color: color
select-box-h: {
name: "Select-box"
color: highlight
}
slider-knob-c: {
name: slider-knob
name: "Circle"
color: color
}
slider-vertical-c: {
name: slider-vertical
color: color
}
splitpane-horizontal-c: {
name: splitpane-horizontal
color: color
}
splitpane-vertical-c: {
name: splitpane-vertical
color: color
}
textfield-c: {
name: "Button"
color: color
}
color: {
name: white
color: color
}
selection: {
name: white
color: selection
}
slider-horizontal-s: {
name: slider-horizontal
name: "Rectangle"
color: selection
}
slider-vertical-s: {
name: slider-vertical
name: "Rectangle"
color: selection
}
select-box-pressed-h: {
name: select-box-pressed
color: highlight
}
select-box-h: {
name: select-box
color: highlight
}
slider-knob-h: {
name: slider-knob
name: "Circle"
color: highlight
}
slider-horizontal-p: {
name: slider-horizontal
name: "Rectangle"
color: pressed
}
slider-vertical-p: {
name: slider-vertical
name: "Rectangle"
color: pressed
}
black: {
name: white
color: black
splitpane-horizontal-c: {
name: "RectangleWithOutline"
color: color
}
button-p: {
name: "Button"
color: pressed
splitpane-vertical-c: {
name: "RectangleWithOutline"
color: color
}
slider-fancy-p: {
name: slider-fancy
color: pressed
textfield-c: {
name: "RoundedEdgeRectangle"
color: color
}
checkbox-h: {
name: checkbox
color: highlight
selection: {
name: "Rectangle"
color: selection
}
checkbox-pressed-h: {
name: checkbox-pressed
color: highlight
}
checkbox-p: {
name: checkbox
color: pressed
}
checkbox-pressed-p: {
name: checkbox-pressed
color: pressed
white: {
name: "Rectangle"
color: white
}
}
com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: {
@ -238,13 +198,6 @@ com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: {
knob: slider-knob-c
knobBefore: slider-vertical-s
}
fancy: {
knobOver: slider-knob-h
knobDown: slider-knob-h
background: slider-fancy-p
knob: slider-knob-c
knobBefore: slider-fancy-knob
}
}
com.badlogic.gdx.scenes.scene2d.ui.SplitPane$SplitPaneStyle: {
default-horizontal: {

BIN
android/assets/Skin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -2,7 +2,7 @@
UnitIcons.png
size: 2048, 512
format: RGBA8888
filter: MipMapLinearLinear, MipMapLinearLinear
filter: Nearest, Nearest
repeat: none
Anti-Aircraft Gun
rotate: false

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 958 KiB

After

Width:  |  Height:  |  Size: 968 KiB

View File

@ -1,118 +0,0 @@
flat-earth-ui.png
size: 512,512
format: RGBA8888
filter: Linear,Linear
repeat: none
checkbox
rotate: false
xy: 183, 304
size: 29, 24
orig: 29, 24
offset: 0, 0
index: -1
checkbox-pressed
rotate: false
xy: 183, 278
size: 29, 24
orig: 29, 24
offset: 0, 0
index: -1
list
rotate: false
xy: 142, 280
size: 39, 39
split: 1, 1, 1, 1
pad: 2, 2, 2, 2
orig: 39, 39
offset: 0, 0
index: -1
scrollbar
rotate: false
xy: 161, 182
size: 10, 10
orig: 10, 10
offset: 0, 0
index: -1
select-box
rotate: false
xy: 181, 330
size: 39, 20
split: 4, 15, 4, 4
pad: 2, 16, 2, 2
orig: 39, 20
offset: 0, 0
index: -1
select-box-pressed
rotate: false
xy: 142, 258
size: 39, 20
split: 4, 15, 4, 4
pad: 2, 16, 2, 2
orig: 39, 20
offset: 0, 0
index: -1
slider-fancy
rotate: false
xy: 1, 500
size: 261, 11
orig: 261, 11
offset: 0, 0
index: -1
slider-fancy-knob
rotate: false
xy: 1, 487
size: 261, 11
orig: 261, 11
offset: 0, 0
index: -1
slider-horizontal
rotate: false
xy: 142, 181
size: 17, 11
split: 4, 4, 0, 0
pad: 0, 0, 0, 0
orig: 17, 11
offset: 0, 0
index: -1
slider-knob
rotate: false
xy: 214, 267
size: 18, 18
orig: 18, 18
offset: 0, 0
index: -1
slider-vertical
rotate: false
xy: 247, 399
size: 11, 17
split: 0, 0, 4, 4
pad: 0, 0, 0, 0
orig: 11, 17
offset: 0, 0
index: -1
splitpane-horizontal
rotate: false
xy: 85, 77
size: 4, 11
split: 1, 1, 1, 1
pad: 0, 0, 0, 0
orig: 4, 11
offset: 0, 0
index: -1
splitpane-vertical
rotate: false
xy: 214, 261
size: 11, 4
split: 1, 1, 1, 1
pad: 0, 0, 0, 0
orig: 11, 4
offset: 0, 0
index: -1
white
rotate: false
xy: 91, 89
size: 1, 1
orig: 1, 1
offset: 0, 0
index: -1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

View File

@ -30,7 +30,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
private fun getTableBlock(text: String, icon: String, function: () -> Unit): Table {
val table = Table().pad(15f, 30f, 15f, 30f)
table.background = ImageGetter.getRoundedEdgeTableBackground(ImageGetter.getBlue())
table.background = ImageGetter.getRoundedEdgeRectangle(ImageGetter.getBlue())
table.add(ImageGetter.getImage(icon)).size(50f).padRight(30f)
table.add(text.toLabel().setFontSize(30)).minWidth(200f)
table.touchable = Touchable.enabled

View File

@ -14,7 +14,7 @@ class CityScreenCityPickerTable(private val cityScreen: CityScreen) : Table() {
fun update() {
val city = cityScreen.city
val civInfo = city.civInfo
background = ImageGetter.getRoundedEdgeTableBackground(civInfo.nation.getOuterColor())
background = ImageGetter.getRoundedEdgeRectangle(civInfo.nation.getOuterColor())
clear()
if (civInfo.cities.size > 1) {

View File

@ -513,7 +513,7 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
labelText = "???"
}
civGroup.background = ImageGetter.getRoundedEdgeTableBackground(backgroundColor)
civGroup.background = ImageGetter.getRoundedEdgeRectangle(backgroundColor)
val label = labelText.toLabel(labelColor)
label.setAlignment(Align.center)

View File

@ -12,7 +12,7 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
init {
touchable = Touchable.enabled
background = ImageGetter.getRoundedEdgeTableBackground()
background = ImageGetter.getRoundedEdgeRectangle()
pad(10f)
if (ImageGetter.techIconExists(techName))

View File

@ -129,7 +129,7 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
if (!showAdditionalInfoTags || tileGroup.tileInfo.airUnits.isEmpty()) return
val secondarycolor = city.civInfo.nation.getInnerColor()
val airUnitTable = Table()
airUnitTable.background = ImageGetter.getRoundedEdgeTableBackground(city.civInfo.nation.getOuterColor()).apply { setMinSize(0f,0f) }
airUnitTable.background = ImageGetter.getRoundedEdgeRectangle(city.civInfo.nation.getOuterColor()).apply { setMinSize(0f,0f) }
val aircraftImage = ImageGetter.getImage("OtherIcons/Aircraft")
aircraftImage.color = secondarycolor
airUnitTable.add(aircraftImage).size(15f)
@ -185,7 +185,7 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
}
val iconTable = IconTable()
iconTable.touchable=Touchable.enabled
iconTable.background = ImageGetter.getRoundedEdgeTableBackground(city.civInfo.nation.getOuterColor())
iconTable.background = ImageGetter.getRoundedEdgeRectangle(city.civInfo.nation.getOuterColor())
if (city.isInResistance()) {
val resistanceImage = ImageGetter.getImage("StatIcons/Resistance")

View File

@ -7,8 +7,7 @@ import com.badlogic.gdx.graphics.GL20
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureAtlas
import com.badlogic.gdx.scenes.scene2d.*
import com.badlogic.gdx.scenes.scene2d.Stage
import com.badlogic.gdx.scenes.scene2d.ui.*
import com.badlogic.gdx.scenes.scene2d.utils.Drawable
import com.badlogic.gdx.utils.viewport.ExtendViewport
@ -76,9 +75,16 @@ open class CameraStageBaseScreen : Screen {
Fonts.resetFont()
skin = Skin().apply {
add("Nativefont", Fonts.font, BitmapFont::class.java)
add("Button", ImageGetter.getRoundedEdgeTableBackground(), Drawable::class.java)
addRegions(TextureAtlas("skin/flat-earth-ui.atlas"))
load(Gdx.files.internal("skin/flat-earth-ui.json"))
add("RoundedEdgeRectangle", ImageGetter.getRoundedEdgeRectangle(), Drawable::class.java)
add("Rectangle", ImageGetter.getDrawable(""), Drawable::class.java)
add("Circle", ImageGetter.getDrawable("OtherIcons/Circle").apply { setMinSize(20f, 20f) }, Drawable::class.java)
add("Scrollbar", ImageGetter.getDrawable("").apply { setMinSize(10f, 10f) }, Drawable::class.java)
add("RectangleWithOutline", ImageGetter.getRectangleWithOutline(), Drawable::class.java)
add("Select-box", ImageGetter.getSelectBox(), Drawable::class.java)
add("Select-box-pressed", ImageGetter.getSelectBoxPressed(), Drawable::class.java)
add("Checkbox", ImageGetter.getCheckBox(), Drawable::class.java)
add("Checkbox-pressed", ImageGetter.getCheckBoxPressed(), Drawable::class.java)
load(Gdx.files.internal("Skin.json"))
}
skin.get(TextButton.TextButtonStyle::class.java).font = Fonts.font.apply { data.setScale(20 / Fonts.ORIGINAL_FONT_SIZE) }
skin.get(CheckBox.CheckBoxStyle::class.java).font = Fonts.font.apply { data.setScale(20 / Fonts.ORIGINAL_FONT_SIZE) }

View File

@ -66,6 +66,12 @@ object ImageGetter {
}
}
if (!atlases.containsKey("Skin")) atlases["Skin"] = TextureAtlas("Skin.atlas")
for (region in atlases["Skin"]!!.regions) {
val drawable = TextureRegionDrawable(region)
textureRegionDrawables["Skin/" + region.name] = drawable
}
// These are from the mods
for (mod in UncivGame.Current.settings.visualMods + ruleset.mods) {
val modAtlasFile = Gdx.files.local("mods/$mod/game.atlas")
@ -152,8 +158,8 @@ object ImageGetter {
else textureRegionDrawables[whiteDotLocation]!!
}
fun getRoundedEdgeTableBackground(tintColor: Color? = null): NinePatchDrawable {
val region = getDrawable("OtherIcons/buttonBackground").region
fun getRoundedEdgeRectangle(tintColor: Color? = null): NinePatchDrawable {
val region = getDrawable("Skin/roundedEdgeRectangle").region
val drawable = NinePatchDrawable(NinePatch(region, 25, 25, 0, 0))
drawable.setPadding(5f, 15f, 5f, 15f)
@ -161,6 +167,28 @@ object ImageGetter {
return drawable.tint(tintColor)
}
fun getRectangleWithOutline(): NinePatchDrawable {
val region = getDrawable("Skin/rectangleWithOutline").region
return NinePatchDrawable(NinePatch(region, 1, 1, 1, 1))
}
fun getSelectBox(): NinePatchDrawable {
val region = getDrawable("Skin/select-box").region
return NinePatchDrawable(NinePatch(region, 10, 25, 5, 5))
}
fun getSelectBoxPressed(): NinePatchDrawable {
val region = getDrawable("Skin/select-box-pressed").region
return NinePatchDrawable(NinePatch(region, 10, 25, 5, 5))
}
fun getCheckBox(): Drawable {
return getDrawable("Skin/checkbox")
}
fun getCheckBoxPressed(): Drawable {
return getDrawable("Skin/checkbox-pressed")
}
fun imageExists(fileName: String) = textureRegionDrawables.containsKey(fileName)
fun techIconExists(techName: String) = imageExists("TechIcons/$techName")

View File

@ -48,7 +48,7 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu
listItem.add(image).size(iconSize).padRight(5f)
}
}
listItem.background = ImageGetter.getRoundedEdgeTableBackground()
listItem.background = ImageGetter.getRoundedEdgeRectangle()
listItem.add(label)
// using a large click area with no gap in between each message item.

View File

@ -511,7 +511,7 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Cam
innerButton.text.setText(currentTech.tr() + "\r\n" + turnsToTech + Fonts.turn)
} else if (viewingCiv.tech.canResearchTech() || viewingCiv.tech.researchedTechnologies.any()) {
val buttonPic = Table()
buttonPic.background = ImageGetter.getRoundedEdgeTableBackground(colorFromRGB(7, 46, 43))
buttonPic.background = ImageGetter.getRoundedEdgeRectangle(colorFromRGB(7, 46, 43))
buttonPic.defaults().pad(20f)
val text = if (viewingCiv.tech.canResearchTech()) "{Pick a tech}!" else "Technologies"
buttonPic.add(text.toLabel(Color.WHITE, 30))

View File

@ -147,10 +147,6 @@ internal object DesktopLauncher {
settings.pot = true
settings.fast = true
// This is so they don't look all pixelated
settings.filterMag = Texture.TextureFilter.MipMapLinearLinear
settings.filterMin = Texture.TextureFilter.MipMapLinearLinear
if (File("../Images").exists()) { // So we don't run this from within a fat JAR
packImagesIfOutdated(settings, "../Images", ".", "game")
packImagesIfOutdated(settings, "../ImagesToPackSeparately/BuildingIcons", ".", "BuildingIcons")
@ -158,6 +154,12 @@ internal object DesktopLauncher {
packImagesIfOutdated(settings, "../ImagesToPackSeparately/UnitIcons", ".", "UnitIcons")
}
if (File("../Skin").exists()) {
settings.filterMag = Texture.TextureFilter.Linear
settings.filterMin = Texture.TextureFilter.Linear
packImagesIfOutdated(settings, "../Skin", ".", "Skin")
}
// pack for mods as well
val modDirectory = File("mods")
if (modDirectory.exists()) {