Skip to content

Commit

Permalink
added arcade help dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
mingli1 committed Oct 4, 2020
1 parent d28789f commit 88ecaaf
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/src/com/tetrea/game/res/GameColor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 16,7 @@ val GAME_DARK_GRAY_BLUE = Color(55 / 255f, 66 / 255f, 96 / 255f, 1f)
val GAME_DARK_RED = Color(75 / 255f, 25 / 255f, 32 / 255f, 1f)
val GAME_LIGHT_RED = Color(229 / 255f, 126 / 255f, 141 / 255f, 1f)
val GAME_LIGHT_GREEN = Color(112 / 255f, 1f, 167 / 255f, 1f)
val GAME_VERY_LIGHT_GREEN = Color(191 / 255f, 1f, 215 / 255f, 1f)
val GAME_VERSUS_BLUE = Color(48 / 255f, 95 / 255f, 204 / 255f, 1f)
val GAME_VERSUS_ORANGE = Color(1f, 143 / 255f, 38 / 255f, 1f)
val GAME_VICTORY_GREEN = Color(200 / 255f, 1f, 200 / 255f, 1f)
Expand Down
66 changes: 66 additions & 0 deletions core/src/com/tetrea/game/scene/dialog/ArcadeHelpDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 1,66 @@
package com.tetrea.game.scene.dialog

import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable
import com.badlogic.gdx.utils.Align
import com.tetrea.game.res.*

class ArcadeHelpDialog(res: Resources) : Table() {

init {
touchable = Touchable.enabled
background = NinePatchDrawable(res.getNinePatch("green_bg"))

add(res.getLabel("ABOUT", fontScale = 1f, color = GAME_LIGHT_GREEN))
.top().left().padLeft(8f).padTop(8f).row()

val content = Table()
val scrollPane = ScrollPane(content).apply {
setOverscroll(false, false)
fadeScrollBars = false
layout()
}
add(scrollPane).expand().width(205f).top()

content.add(res.getLabel("ARCADE", fontScale = 1f, color = GAME_YELLOW))
.left().padTop(8f).padLeft(8f).expandX().row()
content.add(
res.getLabel("PLAY SINGLEPLAYER MODES HERE. YOU CAN SEE YOUR RECORDS ON YOUR PROFILE.").apply {
setWrap(true)
setAlignment(Align.left)
}
).left().width(189f).padLeft(8f).padTop(2f).row()

content.add(
res.getLabel("SPRINT", color = GAME_VERY_LIGHT_GREEN)
).left().padLeft(8f).expandX().padTop(8f).row()
content.add(
res.getLabel("CLEAR 40 LINES AS FAST AS POSSIBLE.").apply {
setWrap(true)
setAlignment(Align.left)
}
).left().width(189f).padLeft(12f).padTop(2f).row()

content.add(
res.getLabel("ULTRA", color = GAME_VERY_LIGHT_GREEN)
).left().padLeft(8f).expandX().padTop(8f).row()
content.add(
res.getLabel("ACHIEVE THE HIGHEST SCORE POSSIBLE WITHIN 2 MINUTES.").apply {
setWrap(true)
setAlignment(Align.left)
}
).left().width(189f).padLeft(12f).padTop(2f).row()

content.add(
res.getLabel("CHEESE", color = GAME_VERY_LIGHT_GREEN)
).left().padLeft(8f).expandX().padTop(8f).row()
content.add(
res.getLabel("CLEAR THROUGH 100 LINES OF GARBAGE AS FAST AS POSSIBLE.").apply {
setWrap(true)
setAlignment(Align.left)
}
).left().width(189f).padLeft(12f).padTop(2f).row()
}
}
51 changes: 50 additions & 1 deletion core/src/com/tetrea/game/screen/ArcadeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 3,25 @@ package com.tetrea.game.screen
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.GL20
import com.badlogic.gdx.scenes.scene2d.actions.Actions
import com.badlogic.gdx.scenes.scene2d.ui.Image
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable
import com.tetrea.game.extension.onTap
import com.tetrea.game.global.TetreaGame
import com.tetrea.game.res.GAME_LIGHT_GREEN
import com.tetrea.game.scene.dialog.ArcadeHelpDialog

private const val DIALOG_FADE_DURATION = 0.4f

class ArcadeScreen(game: TetreaGame) : BaseScreen(game) {

private lateinit var parentTable: Table

private lateinit var helpTable: Table
private lateinit var helpBg: Image
private val helpDialog = ArcadeHelpDialog(game.res)

override fun show() {
super.show()

Expand All @@ -36,7 45,20 @@ class ArcadeScreen(game: TetreaGame) : BaseScreen(game) {
game.soundManager.onPrimaryButtonClicked()
}
}
parentTable.add(backButton).top().left().size(76f, 28f).padTop(6f).row()
parentTable.add(backButton).top().left().size(76f, 28f).padTop(6f)

val helpButton = game.res.getNinePatchTextButton(
text = "HELP",
key = "arcade_green_button",
colorUp = GAME_LIGHT_GREEN,
colorDown = Color.WHITE
).apply {
onTap {
showHelpDialog()
game.soundManager.onPrimaryButtonClicked()
}
}
parentTable.add(helpButton).top().right().size(76f, 28f).padTop(6f).row()

val bodyTable = Table().apply {
add(game.res.getButtonWithImage(
Expand Down Expand Up @@ -78,6 100,19 @@ class ArcadeScreen(game: TetreaGame) : BaseScreen(game) {
}
parentTable.add(bodyTable).top().padTop(24f).colspan(2).expandY()

helpBg = Image(game.res.getTexture("black_150_opacity")).apply {
setSize(this@ArcadeScreen.stage.width, this@ArcadeScreen.stage.height)
isVisible = false
onTap { hideHelpDialog() }
}
stage.addActor(helpBg)
helpTable = Table().apply {
setFillParent(true)
isVisible = false
}
helpTable.add(helpDialog).size(205f, 280f)
stage.addActor(helpTable)

Gdx.input.inputProcessor = multiplexer
}

Expand All @@ -99,4 134,18 @@ class ArcadeScreen(game: TetreaGame) : BaseScreen(game) {
stage.act(dt)
stage.draw()
}

private fun showHelpDialog() {
helpBg.isVisible = true
helpBg.addAction(Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DIALOG_FADE_DURATION)))
helpTable.isVisible = true
helpTable.addAction(Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DIALOG_FADE_DURATION)))
}

private fun hideHelpDialog() {
helpBg.addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(DIALOG_FADE_DURATION),
Actions.run { helpBg.isVisible = false }))
helpTable.addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(DIALOG_FADE_DURATION),
Actions.run { helpTable.isVisible = false }))
}
}

0 comments on commit 88ecaaf

Please sign in to comment.