Skip to content

Commit

Permalink
add new label textbutton style and fix issue that some text buttons r…
Browse files Browse the repository at this point in the history
…efer to a label style instead of a text button style
  • Loading branch information
Quillraven committed May 3, 2020
1 parent 505425f commit 6031177
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 24 deletions.
46 changes: 31 additions & 15 deletions assets/ui/ui.atlas
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,60 @@ filter: Nearest,Nearest
repeat: none
font11_gradient
rotate: false
xy: 1, 124
xy: 1, 121
size: 128, 128
orig: 128, 128
offset: 0, 0
index: -1
font8
rotate: false
xy: 1, 58
xy: 1, 55
size: 128, 64
orig: 128, 64
offset: 0, 0
index: -1
frame
rotate: false
xy: 1, 12
xy: 131, 220
size: 20, 20
split: 7, 7, 7, 7
orig: 20, 20
offset: 0, 0
index: -1
frame_transparent
rotate: false
xy: 131, 223
xy: 23, 9
size: 20, 20
split: 7, 7, 7, 7
orig: 20, 20
offset: 0, 0
index: -1
game_hud
rotate: false
xy: 1, 34
xy: 1, 31
size: 126, 22
orig: 126, 22
offset: 0, 0
index: -1
label_frame
rotate: false
xy: 1, 9
size: 20, 20
split: 7, 7, 7, 7
orig: 20, 20
offset: 0, 0
index: -1
label_frame_transparent
rotate: false
xy: 131, 198
size: 20, 20
split: 7, 7, 7, 7
orig: 20, 20
offset: 0, 0
index: -1
life_bar
rotate: false
xy: 195, 246
xy: 195, 243
size: 22, 6
split: 2, 2, 2, 2
pad: 0, 0, 0, 0
Expand All @@ -52,50 +68,50 @@ life_bar
index: -1
no_sound
rotate: false
xy: 1, 1
xy: 131, 187
size: 11, 9
orig: 11, 9
offset: 0, 0
index: -1
pause
rotate: false
xy: 138, 214
xy: 45, 11
size: 6, 7
orig: 6, 7
offset: 0, 0
index: -1
play
rotate: false
xy: 131, 188
xy: 153, 207
size: 5, 9
orig: 5, 9
offset: 0, 0
index: -1
quit
rotate: false
xy: 23, 16
xy: 160, 232
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
scroll_knob
rotate: false
xy: 219, 247
xy: 219, 244
size: 5, 5
orig: 5, 5
offset: 0, 0
index: -1
scroll_v
rotate: false
xy: 131, 199
xy: 153, 218
size: 5, 22
split: 0, 0, 8, 9
orig: 5, 22
offset: 0, 0
index: -1
shield_bar
rotate: false
xy: 23, 26
xy: 1, 1
size: 22, 6
split: 2, 2, 2, 2
pad: 0, 0, 0, 0
Expand All @@ -104,14 +120,14 @@ shield_bar
index: -1
sound
rotate: false
xy: 153, 234
xy: 45, 20
size: 11, 9
orig: 11, 9
offset: 0, 0
index: -1
warning
rotate: false
xy: 131, 245
xy: 131, 242
size: 62, 7
orig: 62, 7
offset: 0, 0
Expand Down
Binary file modified assets/ui/ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class LoadingScreen(
progressBar = image(SkinImage.LIFE_BAR.atlasKey).apply {
scaleX = 0f
}
progressText = textButton(bundle["loading"], SkinTextButton.TRANSPARENT.name)
progressText = textButton(bundle["loading"], SkinTextButton.LABEL_TRANSPARENT.name)
cell.padLeft(ELEMENT_PADDING).padRight(ELEMENT_PADDING).padBottom(ELEMENT_PADDING)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ class GameOverUI(private val bundle: I18NBundle) {
}
row()

lastScoreButton = textButton(bundle["score", 0], SkinLabel.DEFAULT.name) {
lastScoreButton = textButton(bundle["score", 0], SkinTextButton.LABEL.name) {
label.wrap = true
}
row()

highScoreButton = textButton(bundle["highscore", 0], SkinLabel.DEFAULT.name) {
highScoreButton = textButton(bundle["highscore", 0], SkinTextButton.LABEL.name) {
label.wrap = true
}
row()

backButton = textButton(bundle["backToMenu"], SkinLabel.DEFAULT.name) {
backButton = textButton(bundle["backToMenu"], SkinTextButton.DEFAULT.name) {
label.wrap = true
}
row()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ class MenuUI(private val bundle: I18NBundle) {
}
row()

highScoreButton = textButton(bundle["highscore", 0], SkinLabel.DEFAULT.name) {
highScoreButton = textButton(bundle["highscore", 0], SkinTextButton.LABEL.name) {
label.wrap = true
}
row()

creditsButton = textButton(bundle["credit"], SkinLabel.DEFAULT.name) {
creditsButton = textButton(bundle["credit"], SkinTextButton.DEFAULT.name) {
label.wrap = true
}
row()

quitGameButton = textButton(bundle["quitGame"], SkinLabel.DEFAULT.name) {
quitGameButton = textButton(bundle["quitGame"], SkinTextButton.DEFAULT.name) {
label.wrap = true
}

Expand Down
16 changes: 14 additions & 2 deletions core/src/main/kotlin/com/github/quillraven/darkmatter/ui/skin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum class SkinImageButton {
}

enum class SkinTextButton {
DEFAULT, TRANSPARENT
DEFAULT, TRANSPARENT, LABEL, LABEL_TRANSPARENT
}

enum class SkinWindow {
Expand All @@ -46,7 +46,9 @@ enum class SkinImage(val atlasKey: String) {
SOUND_ON("sound"),
SOUND_OFF("no_sound"),
SCROLL_V("scroll_v"),
SCROLL_KNOB("scroll_knob")
SCROLL_KNOB("scroll_knob"),
FRAME_LABEL("label_frame"),
FRAME_LABEL_TRANSPARENT("label_frame_transparent")
}

fun createSkin(assets: AssetStorage) {
Expand Down Expand Up @@ -93,6 +95,16 @@ private fun Skin.createTextButtonStyles(
up = skin.getDrawable(SkinImage.FRAME_TRANSPARENT.atlasKey)
down = up
}
textButton(SkinTextButton.LABEL.name) {
font = defaultFont
up = skin.getDrawable(SkinImage.FRAME_LABEL.atlasKey)
down = up
}
textButton(SkinTextButton.LABEL_TRANSPARENT.name) {
font = defaultFont
up = skin.getDrawable(SkinImage.FRAME_LABEL_TRANSPARENT.atlasKey)
down = up
}
}

private fun Skin.createImageButtonStyles(skin: Skin) {
Expand Down
Binary file added raw/ui/label_frame.9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added raw/ui/label_frame_transparent.9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6031177

Please sign in to comment.