mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-07-07 20:21:33 +00:00
refactor: replace XuiActionPayload polling with server-owned typed action queue
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleSchematicFile.h"
|
||||
#include "app/common/UI/Controls/UIControl_Button.h"
|
||||
#include "app/common/UI/Controls/UIControl_CheckBox.h"
|
||||
#include "app/common/UI/Controls/UIControl_Label.h"
|
||||
@@ -13,6 +12,8 @@
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/linux/Linux_UIController.h"
|
||||
#include "minecraft/GameEnums.h"
|
||||
#include "minecraft/server/MinecraftServer.h"
|
||||
#include "minecraft/server/ServerAction.h"
|
||||
#include "minecraft/world/level/Level.h"
|
||||
#include "minecraft/world/level/chunk/ChunkSource.h"
|
||||
#include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h"
|
||||
@@ -52,7 +53,8 @@ UIScene_DebugCreateSchematic::UIScene_DebugCreateSchematic(int iPad,
|
||||
|
||||
m_buttonCreate.init("Create", eControl_Create);
|
||||
|
||||
m_data = new ConsoleSchematicFile::XboxSchematicInitParam();
|
||||
m_data = {};
|
||||
m_data.compressionType = Compression::eCompressionType_None;
|
||||
}
|
||||
|
||||
std::string UIScene_DebugCreateSchematic::getMoviePath() {
|
||||
@@ -86,40 +88,36 @@ void UIScene_DebugCreateSchematic::handlePress(F64 controlId, F64 childId) {
|
||||
switch ((int)controlId) {
|
||||
case eControl_Create: {
|
||||
// We want the start to be even
|
||||
if (m_data->startX > 0 && m_data->startX % 2 != 0)
|
||||
m_data->startX -= 1;
|
||||
else if (m_data->startX < 0 && m_data->startX % 2 != 0)
|
||||
m_data->startX -= 1;
|
||||
if (m_data->startY < 0)
|
||||
m_data->startY = 0;
|
||||
else if (m_data->startY > 0 && m_data->startY % 2 != 0)
|
||||
m_data->startY -= 1;
|
||||
if (m_data->startZ > 0 && m_data->startZ % 2 != 0)
|
||||
m_data->startZ -= 1;
|
||||
else if (m_data->startZ < 0 && m_data->startZ % 2 != 0)
|
||||
m_data->startZ -= 1;
|
||||
if (m_data.startX > 0 && m_data.startX % 2 != 0)
|
||||
m_data.startX -= 1;
|
||||
else if (m_data.startX < 0 && m_data.startX % 2 != 0)
|
||||
m_data.startX -= 1;
|
||||
if (m_data.startY < 0)
|
||||
m_data.startY = 0;
|
||||
else if (m_data.startY > 0 && m_data.startY % 2 != 0)
|
||||
m_data.startY -= 1;
|
||||
if (m_data.startZ > 0 && m_data.startZ % 2 != 0)
|
||||
m_data.startZ -= 1;
|
||||
else if (m_data.startZ < 0 && m_data.startZ % 2 != 0)
|
||||
m_data.startZ -= 1;
|
||||
|
||||
// We want the end to be odd to have a total size that is even
|
||||
if (m_data->endX > 0 && m_data->endX % 2 == 0)
|
||||
m_data->endX += 1;
|
||||
else if (m_data->endX < 0 && m_data->endX % 2 == 0)
|
||||
m_data->endX += 1;
|
||||
if (m_data->endY > Level::maxBuildHeight)
|
||||
m_data->endY = Level::maxBuildHeight;
|
||||
else if (m_data->endY > 0 && m_data->endY % 2 == 0)
|
||||
m_data->endY += 1;
|
||||
else if (m_data->endY < 0 && m_data->endY % 2 == 0)
|
||||
m_data->endY += 1;
|
||||
if (m_data->endZ > 0 && m_data->endZ % 2 == 0)
|
||||
m_data->endZ += 1;
|
||||
else if (m_data->endZ < 0 && m_data->endZ % 2 == 0)
|
||||
m_data->endZ += 1;
|
||||
if (m_data.endX > 0 && m_data.endX % 2 == 0)
|
||||
m_data.endX += 1;
|
||||
else if (m_data.endX < 0 && m_data.endX % 2 == 0)
|
||||
m_data.endX += 1;
|
||||
if (m_data.endY > Level::maxBuildHeight)
|
||||
m_data.endY = Level::maxBuildHeight;
|
||||
else if (m_data.endY > 0 && m_data.endY % 2 == 0)
|
||||
m_data.endY += 1;
|
||||
else if (m_data.endY < 0 && m_data.endY % 2 == 0)
|
||||
m_data.endY += 1;
|
||||
if (m_data.endZ > 0 && m_data.endZ % 2 == 0)
|
||||
m_data.endZ += 1;
|
||||
else if (m_data.endZ < 0 && m_data.endZ % 2 == 0)
|
||||
m_data.endZ += 1;
|
||||
|
||||
std::unique_ptr<minecraft::XuiActionOwnedPayload> payload(m_data);
|
||||
m_data = nullptr; // ownership transferred to the action
|
||||
app.SetXuiServerAction(PlatformProfile.GetPrimaryPad(),
|
||||
eXuiServerAction_ExportSchematic,
|
||||
std::move(payload));
|
||||
MinecraftServer::getInstance()->queueServerAction(m_data);
|
||||
|
||||
navigateBack();
|
||||
} break;
|
||||
@@ -145,13 +143,13 @@ void UIScene_DebugCreateSchematic::handleCheckboxToggled(F64 controlId,
|
||||
bool selected) {
|
||||
switch ((int)controlId) {
|
||||
case eControl_SaveMobs:
|
||||
m_data->bSaveMobs = selected;
|
||||
m_data.saveMobs = selected;
|
||||
break;
|
||||
case eControl_UseCompression:
|
||||
if (selected)
|
||||
m_data->compressionType = APPROPRIATE_COMPRESSION_TYPE;
|
||||
m_data.compressionType = APPROPRIATE_COMPRESSION_TYPE;
|
||||
else
|
||||
m_data->compressionType = Compression::eCompressionType_RLE;
|
||||
m_data.compressionType = Compression::eCompressionType_RLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -166,9 +164,9 @@ int UIScene_DebugCreateSchematic::handleKeyboardComplete(bool bRes) {
|
||||
case eControl_Name:
|
||||
m_textInputName.setLabel(value);
|
||||
if (!value.empty()) {
|
||||
snprintf(m_data->name, 64, "%s", value.c_str());
|
||||
snprintf(m_data.name, 64, "%s", value.c_str());
|
||||
} else {
|
||||
snprintf(m_data->name, 64, "schematic");
|
||||
snprintf(m_data.name, 64, "schematic");
|
||||
}
|
||||
break;
|
||||
case eControl_StartX:
|
||||
@@ -176,7 +174,7 @@ int UIScene_DebugCreateSchematic::handleKeyboardComplete(bool bRes) {
|
||||
|
||||
if (iVal >= (LEVEL_MAX_WIDTH * -16) ||
|
||||
iVal < (LEVEL_MAX_WIDTH * 16)) {
|
||||
m_data->startX = iVal;
|
||||
m_data.startX = iVal;
|
||||
}
|
||||
break;
|
||||
case eControl_StartY:
|
||||
@@ -184,7 +182,7 @@ int UIScene_DebugCreateSchematic::handleKeyboardComplete(bool bRes) {
|
||||
|
||||
if (iVal >= (LEVEL_MAX_WIDTH * -16) ||
|
||||
iVal < (LEVEL_MAX_WIDTH * 16)) {
|
||||
m_data->startY = iVal;
|
||||
m_data.startY = iVal;
|
||||
}
|
||||
break;
|
||||
case eControl_StartZ:
|
||||
@@ -192,7 +190,7 @@ int UIScene_DebugCreateSchematic::handleKeyboardComplete(bool bRes) {
|
||||
|
||||
if (iVal >= (LEVEL_MAX_WIDTH * -16) ||
|
||||
iVal < (LEVEL_MAX_WIDTH * 16)) {
|
||||
m_data->startZ = iVal;
|
||||
m_data.startZ = iVal;
|
||||
}
|
||||
break;
|
||||
case eControl_EndX:
|
||||
@@ -200,7 +198,7 @@ int UIScene_DebugCreateSchematic::handleKeyboardComplete(bool bRes) {
|
||||
|
||||
if (iVal >= (LEVEL_MAX_WIDTH * -16) ||
|
||||
iVal < (LEVEL_MAX_WIDTH * 16)) {
|
||||
m_data->endX = iVal;
|
||||
m_data.endX = iVal;
|
||||
}
|
||||
break;
|
||||
case eControl_EndY:
|
||||
@@ -208,7 +206,7 @@ int UIScene_DebugCreateSchematic::handleKeyboardComplete(bool bRes) {
|
||||
|
||||
if (iVal >= (LEVEL_MAX_WIDTH * -16) ||
|
||||
iVal < (LEVEL_MAX_WIDTH * 16)) {
|
||||
m_data->endY = iVal;
|
||||
m_data.endY = iVal;
|
||||
}
|
||||
break;
|
||||
case eControl_EndZ:
|
||||
@@ -216,7 +214,7 @@ int UIScene_DebugCreateSchematic::handleKeyboardComplete(bool bRes) {
|
||||
|
||||
if (iVal >= (LEVEL_MAX_WIDTH * -16) ||
|
||||
iVal < (LEVEL_MAX_WIDTH * 16)) {
|
||||
m_data->endZ = iVal;
|
||||
m_data.endZ = iVal;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user