-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,4 +170,6 @@ class Snake : Game() { | |
} | ||
|
||
override val pip = true | ||
|
||
override val name = "Snake" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,4 +270,6 @@ class Wordle : Game() { | |
} | ||
} | ||
} | ||
|
||
override val name = "Wordle" | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/kotlin/gay/j10a1n15/sillygames/screens/GameSelector.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package gay.j10a1n15.sillygames.screens | ||
|
||
import gay.j10a1n15.sillygames.games.Snake | ||
import gay.j10a1n15.sillygames.games.wordle.Wordle | ||
import gay.j10a1n15.sillygames.utils.SillyUtils.display | ||
import gg.essential.elementa.ElementaVersion | ||
import gg.essential.elementa.WindowScreen | ||
import gg.essential.elementa.components.UIBlock | ||
import gg.essential.elementa.components.UIText | ||
import gg.essential.elementa.constraints.CenterConstraint | ||
import gg.essential.elementa.dsl.childOf | ||
import gg.essential.elementa.dsl.constrain | ||
import gg.essential.elementa.dsl.percent | ||
import gg.essential.elementa.dsl.toConstraint | ||
import gg.essential.elementa.utils.withAlpha | ||
import gg.essential.universal.GuiScale | ||
import java.awt.Color | ||
|
||
val gameFactories = setOf( | ||
{ Wordle() }, | ||
{ Snake() }, | ||
) | ||
|
||
class GameSelector : WindowScreen( | ||
version = ElementaVersion.V5, | ||
newGuiScale = GuiScale.scaleForScreenSize().ordinal, | ||
drawDefaultBackground = false, | ||
) { | ||
private val container = UIBlock().constrain { | ||
x = CenterConstraint() | ||
y = CenterConstraint() | ||
width = 75.percent() | ||
height = 75.percent() | ||
color = Color(0x212121).withAlpha(0.85f).toConstraint() | ||
} childOf window | ||
|
||
private val title = UIText("Select a game").constrain { | ||
x = CenterConstraint() | ||
y = 10.percent() | ||
} childOf container | ||
|
||
init { | ||
gameFactories.forEachIndexed { index, factory -> | ||
val button = UIBlock().constrain { | ||
x = CenterConstraint() | ||
y = (20 + 10 * index).percent() | ||
width = 50.percent() | ||
height = 5.percent() | ||
color = Color(0x424242).withAlpha(0.95f).toConstraint() | ||
} childOf container | ||
|
||
UIText(factory().name).constrain { | ||
x = CenterConstraint() | ||
y = CenterConstraint() | ||
} childOf button | ||
|
||
button.onMouseClick { | ||
FullScreen(factory.invoke()).display() | ||
} | ||
} | ||
} | ||
|
||
} |