diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af9a70b..1841d12 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,7 +84,12 @@ jobs: .\install.ps1 -RunAsAdmin scoop install gh ./gradlew :client:linkReleaseExecutableMingwX64 - Rename-Item -Path "client\build\bin\mingwX64\releaseExecutable\" -NewName "\client\build\bin\mingwX64\client" + cd client\build\bin\mingwX64 + Rename-Item -Path "releaseExecutable" -NewName "client" + cd .. + cd .. + cd .. + cd .. Compress-Archive -Path .\client\build\bin\mingwX64\client -DestinationPath .\client\build\bin\mingwX64\client.zip Get-ChildItem -Path . -File -Recurse gh release upload ${{github.run_number}} .\client\build\bin\mingwX64\client.zip --repo ${{ github.repository }} diff --git a/client/src/commonMain/kotlin/ui/MainMenu.kt b/client/src/commonMain/kotlin/ui/MainMenu.kt index f3cfafa..007d306 100644 --- a/client/src/commonMain/kotlin/ui/MainMenu.kt +++ b/client/src/commonMain/kotlin/ui/MainMenu.kt @@ -83,7 +83,7 @@ suspend fun MainMenuState.mainMenu() { } } try { - val room = createRoom() + val room = createRoomMenu() joinRoom(room.uuid) serverList.removeFromParent() loading.removeFromParent() diff --git a/client/src/commonMain/kotlin/ui/createRoomMenu.kt b/client/src/commonMain/kotlin/ui/createRoomMenu.kt new file mode 100644 index 0000000..5d53994 --- /dev/null +++ b/client/src/commonMain/kotlin/ui/createRoomMenu.kt @@ -0,0 +1,125 @@ +package ui + +import korlibs.event.Key +import korlibs.image.color.Colors +import korlibs.korge.input.keys +import korlibs.korge.input.mouse +import korlibs.korge.input.onClick +import korlibs.korge.input.onMouseDragCloseable +import korlibs.korge.style.styles +import korlibs.korge.style.textColor +import korlibs.korge.style.textSize +import korlibs.korge.ui.* +import korlibs.korge.view.Container +import korlibs.korge.view.addTo +import korlibs.korge.view.align.alignY +import korlibs.korge.view.align.centerOn +import korlibs.korge.view.align.centerOnStage +import korlibs.korge.view.align.centerXOn +import korlibs.math.geom.Size +import network.* +import scene.styler +import sceneContainer +import ui.custom.UITextInput +import ui.custom.customUiButton +import ui.custom.customUiText +import util.ColorPalette +import util.launchNow + +fun createRoomMenu(container: Container) { + lateinit var inputText: UITextInput + lateinit var warningText: UIText + lateinit var loginMenu: Container + loginMenu = container.uiContainer { + styles(styler) + val padding = 15.75f + uiVerticalStack(adjustSize = false, padding = padding) { + val title = customUiText("방 생성") { + styles.textSize = styles.textSize * 1.25f + }.centerXOn(this) + uiSpacing(size = Size(0f, title.size.height * 0.25f)) + val blockSize = Size(sceneContainer.width / 3.6f, sceneContainer.width / 23f) + uiContainer(size = blockSize) { + styles.textSize = styles.textSize * 0.95f + materialInput("인원 수", padding, this, + border = Colors.TRANSPARENT, bg = ColorPalette.base + ).apply { + inputText = input + input.mouse { +// onMove { materialLayer.borderColor = ColorPalette.hover } + onMoveOutside { materialLayer.borderColor = ColorPalette.base } + } + } + }.centerXOn(this) + val horizontalSize = Size(blockSize.width / 2 - padding / 2, blockSize.height) + uiHorizontalStack(height = horizontalSize.height, adjustHeight = false, padding = padding) { + uiSpacing(Size(0f, padding / 2)) + customUiButton(size = horizontalSize) { + uiMaterialLayer(size) { + shadowColor = Colors.TRANSPARENT + bgColor = ColorPalette.base + borderColor = ColorPalette.base + borderSize = padding / 4 + this@customUiButton.mouse { + onMove { borderColor = ColorPalette.hover } + onMoveOutside { borderColor = ColorPalette.base } + } + } + uiText("입장 >").centerOn(this) + var joinOnce = false + suspend fun join() { + if (joinOnce) return + val txt = inputText.text.trim() + if (txt.isEmpty()) { + warningText.text = "닉네임을 입력해주세요" + warningText.styles.textColor = Colors.PALEVIOLETRED + return + } else if (txt.length !in 3..16) { + warningText.text = "닉네임은 3글자 이상 16글자 이하여야 합니다" + warningText.styles.textColor = Colors.PALEVIOLETRED + return + } else if (!usernameRegex.containsMatchIn(txt)) { + warningText.text = "닉네임은 한글, 영문, 숫자만 가능합니다" + warningText.styles.textColor = Colors.PALEVIOLETRED + return + } + warningText.text = "로그인 중..." + warningText.styles.textColor = ColorPalette.out + username = inputText.text.trim() + joinOnce = true + val login = login() + if (login == LoginResultType.ALREADY_JOINED) { + warningText.text = "입력하신 닉네임은 이미 사용중입니다" + joinOnce = false + return + } else if (login == LoginResultType.SERVER_IS_NOT_AVAILABLE + || runCatching { websocketClient() } + .also { it.exceptionOrNull()?.printStackTrace() }.isFailure) { + warningText.text = "죄송합니다, 지금은 인증 서버를 사용할 수 없습니다. 나중에 다시 시도해 주세요." + joinOnce = false + return + } else { + loginMenu.removeFromParent() + MainMenuState().mainMenu() + } + } + onClick { join() } + onMouseDragCloseable { launchNow { join() } } + keys { down(Key.ENTER) { join() } } + + } + }.centerXOn(this) +// uiSpacing(size = Size(0f, space.size.height / 16f)) + val guestModeText = uiText("") { + styles.textSize = styles.textSize * 0.75f + styles.textColor = ColorPalette.out + }.centerXOn(this) + warningText = guestModeText + val guestModeTextContainer = uiContainer(guestModeText.size.times(3)) { + }.centerXOn(this) + guestModeText.removeFromParent() + guestModeText.addTo(guestModeTextContainer).centerOn(guestModeTextContainer) + }.centerOn(this) + }.centerOnStage() + .alignY(container, 0.5, true) +} \ No newline at end of file