Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce0203 committed Aug 3, 2023
1 parent e8b1da4 commit 3536402
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
7 changes: 7 additions & 0 deletions client/src/commonMain/kotlin/ui/custom/TextEditController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import korlibs.korge.component.*
import korlibs.korge.input.*
import korlibs.korge.time.*
import korlibs.korge.ui.*
import korlibs.korge.ui.UIText
import korlibs.korge.view.*
import korlibs.korge.view.align.alignX
import korlibs.korge.view.align.centerOn
import korlibs.korge.view.align.centerXOn
import korlibs.korge.view.align.centerYOn
import korlibs.korge.view.debug.*
import korlibs.math.geom.*
import korlibs.math.geom.bezier.*
Expand All @@ -27,6 +32,7 @@ class TextEditController(
val textView: Text,
val caretContainer: Container = textView,
val eventHandler: View = textView,
val hint: View? = null,
val bg: RenderableView? = null,
) : Closeable, UIFocusable, ISoftKeyboardConfig by SoftKeyboardConfig() {
init {
Expand Down Expand Up @@ -101,6 +107,7 @@ class TextEditController(
var text: String
get() = textView.text
set(value) {
hint?.visible = value == " "
val snapshot = setTextNoSnapshot(value)
if (snapshot != null) {
textSnapshots.push(snapshot)
Expand Down
14 changes: 9 additions & 5 deletions client/src/commonMain/kotlin/ui/custom/uiTextInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import korlibs.image.font.*
import korlibs.io.async.*
import korlibs.korge.annotations.*
import korlibs.korge.style.*
import korlibs.korge.ui.UIView
import korlibs.korge.ui.blur
import korlibs.korge.ui.focus
import korlibs.korge.ui.uiContainer
import korlibs.korge.ui.*
import korlibs.korge.view.*
import korlibs.korge.view.align.alignX
import korlibs.korge.view.align.centerYOn
import korlibs.math.geom.*

@KorgeExperimental
Expand Down Expand Up @@ -40,7 +39,12 @@ class UITextInput(initialText: String = "", size: Size = Size(128, 24)) :
//private val container = fixedSizeContainer(width - 4.0, height - 4.0).position(2.0, 3.0)
private val textView = customUiText(initialText, this.size)
//private val textView = container.text(initialText, 16.0, color = Colors.BLACK, font = DefaultTtfFont)
val controller = TextEditController(textView.textView, uiContainer(textView.size) { }, this, bg)
val controller = TextEditController(textView.textView, uiContainer(textView.size) { }, this, bg = bg,
hint = textView.uiText(" 채팅을 입력하세요...", size = size) {
centerYOn(textView).alignX(textView, 0.1, true)
alpha = 0.5f
}
)

//init { uiScrollable { } }

Expand Down
19 changes: 15 additions & 4 deletions client/src/commonMain/kotlin/ui/waitingRoom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ package ui
import korlibs.image.color.Colors
import korlibs.image.text.HorizontalAlign
import korlibs.image.text.TextAlignment
import korlibs.io.lang.Cancellable
import korlibs.korge.annotations.KorgeExperimental
import korlibs.korge.input.onClick
import korlibs.korge.input.onMouseDragCloseable
import korlibs.korge.input.onUp
import korlibs.korge.input.onUpAnywhere
import korlibs.korge.style.styles
import korlibs.korge.style.textAlignment
import korlibs.korge.ui.uiButton
Expand All @@ -24,12 +28,14 @@ import ui.custom.customUiButton
import ui.custom.customUiText
import ui.custom.customUiTextInput
import util.ColorPalette
import util.launchNow
import kotlin.math.abs

@OptIn(KorgeExperimental::class)
suspend fun waitingRoom(room: UUID) {
lateinit var waitingRoom: View
waitingRoom = sceneContainer.uiContainer {
sceneContainer.uiContainer {
waitingRoom = this
val padding = 25f
val sidebarSize = Size(sceneContainer.width / 3.5f, sceneContainer.height)
styles(styler)
Expand All @@ -39,9 +45,14 @@ suspend fun waitingRoom(room: UUID) {
val inputBarSize = Size(sceneContainer.width - sidebarSize.width - padding*2 - leaveButton.width - padding*2, belowElementHeight)
customUiButton(size = leaveButton) {
val back = solidRect(size, color = ColorPalette.out).centerOn(this)
customUiText("나가기").centerOn(this).onClick {
waitingRoom.removeFromParent()
MainMenuState().mainMenu()
var isDone = false
customUiText("나가기").centerOn(this).onMouseDragCloseable {
onUpAnywhere {
if (isDone) return@onUpAnywhere
isDone = true
waitingRoom.removeFromParent()
MainMenuState().mainMenu()
}
}
positionX(padding)
positionY(sceneContainer.height - padding - size.height)
Expand Down

0 comments on commit 3536402

Please sign in to comment.