mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
hacky credits screen
This commit is contained in:
parent
c920eaf781
commit
47ef9dab59
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -20,6 +20,7 @@ import de.bixilon.minosoft.data.registries.other.game.event.handlers.gradients.R
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.gradients.ThunderGradientSetGameEventHandler
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.rain.RainStartGameEventHandler
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.rain.RainStopGameEventHandler
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.win.WinGameEventHandler
|
||||
|
||||
object DefaultGameEventHandlers : DefaultFactory<GameEventHandler>(
|
||||
GamemodeChangeGameEventHandler,
|
||||
@ -27,4 +28,5 @@ object DefaultGameEventHandlers : DefaultFactory<GameEventHandler>(
|
||||
RainStopGameEventHandler,
|
||||
RainGradientSetGameEventHandler,
|
||||
ThunderGradientSetGameEventHandler,
|
||||
WinGameEventHandler,
|
||||
)
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.registries.other.game.event.handlers.win
|
||||
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
|
||||
class WinGameEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val showCredits: Boolean,
|
||||
) : PlayConnectionEvent(connection, initiator)
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.registries.other.game.event.handlers.win
|
||||
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.GameEventHandler
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.ClientActionC2SP
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
object WinGameEventHandler : GameEventHandler {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:win_game".toResourceLocation()
|
||||
|
||||
override fun handle(data: Float, connection: PlayConnection) {
|
||||
val credits = data.toInt() == 0x01
|
||||
connection.fireEvent(WinGameEvent(connection, EventInitiators.SERVER, credits))
|
||||
if (!credits) {
|
||||
connection.sendPacket(ClientActionC2SP(ClientActionC2SP.ClientActions.PERFORM_RESPAWN))
|
||||
}
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.Dragged
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.CreditsScreen
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.SignEditorScreen
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.container.ContainerGUIManager
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.pause.PauseMenu
|
||||
@ -60,6 +61,7 @@ class GUIManager(
|
||||
ContainerGUIManager.register(guiRenderer)
|
||||
SignEditorScreen.register(guiRenderer)
|
||||
RespawnMenu.register(guiRenderer)
|
||||
CreditsScreen.register(guiRenderer)
|
||||
}
|
||||
|
||||
override fun postInit() {
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.gui.screen
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.win.WinGameEvent
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments.Companion.getOffset
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.ClientActionC2SP
|
||||
|
||||
@Deprecated("ToDo")
|
||||
class CreditsScreen(
|
||||
guiRenderer: GUIRenderer,
|
||||
) : Screen(guiRenderer) {
|
||||
private val headerElement = TextElement(guiRenderer, "Minecraft", background = false, scale = 3.0f, parent = this)
|
||||
private val textElement = TextElement(guiRenderer, "Ähm, yes. This is not yet implemented -/-\nI am so sorry...", background = false, parent = this)
|
||||
|
||||
|
||||
override fun forceRender(offset: Vec2i, consumer: GUIVertexConsumer, options: GUIVertexOptions?) {
|
||||
super.forceRender(offset, consumer, options)
|
||||
|
||||
val size = size
|
||||
|
||||
headerElement.render(offset + HorizontalAlignments.CENTER.getOffset(size, headerElement.size), consumer, options)
|
||||
offset.y += headerElement.size.y
|
||||
|
||||
offset.y += size.y / 30
|
||||
textElement.render(offset + HorizontalAlignments.CENTER.getOffset(size, textElement.size), consumer, options)
|
||||
}
|
||||
|
||||
override fun onClose() {
|
||||
super.onClose()
|
||||
guiRenderer.connection.sendPacket(ClientActionC2SP(ClientActionC2SP.ClientActions.PERFORM_RESPAWN))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun register(guiRenderer: GUIRenderer) {
|
||||
guiRenderer.connection.registerEvent(CallbackEventInvoker.of<WinGameEvent> {
|
||||
if (!it.showCredits) {
|
||||
return@of
|
||||
}
|
||||
guiRenderer.gui.push(CreditsScreen(guiRenderer))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
@ -527,7 +527,7 @@
|
||||
"minecraft:gamemode_change": {
|
||||
"id": 3
|
||||
},
|
||||
"minecraft:show_credits": {
|
||||
"minecraft:win_game": {
|
||||
"id": 4
|
||||
},
|
||||
"minecraft:hide_demo_messages": {
|
||||
@ -562,7 +562,7 @@
|
||||
"minecraft:gamemode_change": {
|
||||
"id": 3
|
||||
},
|
||||
"minecraft:show_credits": {
|
||||
"minecraft:win_game": {
|
||||
"id": 4
|
||||
},
|
||||
"minecraft:hide_demo_messages": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user