mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-25 18:12:41 +01:00
Patch Notes: Blocks + Colored shulker boxes + Concrete powder + Concrete + Glazed terracotta Items + Shulker shell + Iron nugget UI Changes + Added Custom Controls to Keyboard & Mouse, as well as Controller + Added Custom SuperFlat + Added Edit Server Menu + Added Firework Crafting Feature Changes + Host Options + Added Pick Block + Added off-hand slot for maps and arrows. Bug Fixes & changes + TU47: Banner hitbox wrong (and inventory model fixed) + TU47/48: Ice not melting properly + TU48: Dead bushes not dropping sticks + TU48: Guardians and polar bears not dropping cooked fish when on fire + TU48: Bonus chest missing saplings and seeds + TU48: Frosted ice obtainable + TU48: Hoppers not collecting items + TU48: Wither skeletons spawning in 2-high gaps + TU48: End crystals exploding with “TNT Explodes” off + TU48: Tamed ocelots staying hostile + TU48: Signs not placing on tall grass + TU51: Skeleton hitbox wrong + TU53: Fall damage in shallow water + TU53: Squids not spawning in man-made pools + Elytra has been improved to be more accurate to the source material + Removed Spectral Arrow from crafting + Fixed several broken item descriptions + You can no longer cook Pufferfish or Clownfish + Fixed scaling issue with paperdoll and chat + Iron and gold armor can now be smelted into nuggets. + More items can now be used as fuel in a furnace. + Using a firework rocket while gliding with elytra will now give the player a boost. + Changed the color of dyes, wool, carpets, and banners. + Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items. + Fishing rods can now hook on entities without causing knockback or pseudo-damage. + Fixed banner crafting + Fixed Map colors for certain blocks + Fixed Path block height + Fixed String block issues + Fixed Item frame culling. + Fixed Tutorial world NBT/Block State issues + Fixed World Slider + Fixed Enderman AI + Fixed Player animation bug + HUD Flash text changes + Generation accuracy changes + Many other small accuracy changes and fixes
389 lines
13 KiB
C++
389 lines
13 KiB
C++
#include "stdafx.h"
|
|
#include "UI.h"
|
|
#include "UIScene_InGameHostOptionsMenu.h"
|
|
#include "../../Minecraft.h"
|
|
#include "../../MultiPlayerLocalPlayer.h"
|
|
#include "../../MultiPlayerLevel.h"
|
|
#include "../../ClientConnection.h"
|
|
#include "../../../Minecraft.World/net.minecraft.network.h"
|
|
#include "../../../Minecraft.World/net.minecraft.network.packet.h"
|
|
#include "../../../Minecraft.World/net.minecraft.world.level.h"
|
|
#include "../../../Minecraft.World/net.minecraft.commands.common.h"
|
|
#include "../../../Minecraft.World/LevelSettings.h"
|
|
|
|
static const int s_difficultyTitles[4] =
|
|
{
|
|
IDS_DIFFICULTY_TITLE_PEACEFUL,
|
|
IDS_DIFFICULTY_TITLE_EASY,
|
|
IDS_DIFFICULTY_TITLE_NORMAL,
|
|
IDS_DIFFICULTY_TITLE_HARD
|
|
};
|
|
|
|
static const int s_gameModeTitles[3] =
|
|
{
|
|
IDS_GAMEMODE_SURVIVAL,
|
|
IDS_GAMEMODE_CREATIVE,
|
|
IDS_GAMEMODE_ADVENTURE
|
|
};
|
|
|
|
UIScene_InGameHostOptionsMenu::UIScene_InGameHostOptionsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
|
{
|
|
initialiseMovie();
|
|
|
|
m_bNeedsMultiListPopulate = true;
|
|
m_bInitialPopulateDone = false;
|
|
m_bPendingSliderUpdate = false;
|
|
m_iPendingSliderId = 0;
|
|
m_iPendingSliderValue = 0;
|
|
m_iPendingTeleport = -1;
|
|
|
|
for (int i = 0; i < eControl_Count; ++i) m_bChecked[i] = false;
|
|
m_bChecked[eControl_FireSpreads] = app.GetGameHostOption(eGameHostOption_FireSpreads) != 0;
|
|
m_bChecked[eControl_TNT] = app.GetGameHostOption(eGameHostOption_TNT) != 0;
|
|
m_bChecked[eControl_DoDaylightCycle] = app.GetGameHostOption(eGameHostOption_DoDaylightCycle) != 0;
|
|
m_bChecked[eControl_KeepInventory] = app.GetGameHostOption(eGameHostOption_KeepInventory) != 0;
|
|
m_bChecked[eControl_DoMobSpawning] = app.GetGameHostOption(eGameHostOption_DoMobSpawning) != 0;
|
|
m_bChecked[eControl_MobGriefing] = app.GetGameHostOption(eGameHostOption_MobGriefing) != 0;
|
|
m_bChecked[eControl_DoWeatherCycle] = app.GetGameHostOption(eGameHostOption_DoWeatherCycle) != 0;
|
|
m_bChecked[eControl_DoMobLoot] = app.GetGameHostOption(eGameHostOption_DoMobLoot) != 0;
|
|
m_bChecked[eControl_DoTileDrops] = app.GetGameHostOption(eGameHostOption_DoTileDrops) != 0;
|
|
m_bChecked[eControl_NaturalRegeneration] = app.GetGameHostOption(eGameHostOption_NaturalRegeneration) != 0;
|
|
|
|
m_iDifficulty = app.GetGameHostOption(eGameHostOption_Difficulty);
|
|
if (m_iDifficulty < 0 || m_iDifficulty > 3) m_iDifficulty = 2;
|
|
m_iGameType = app.GetGameHostOption(eGameHostOption_GameType);
|
|
if (m_iGameType < 0 || m_iGameType > 2) m_iGameType = 0;
|
|
|
|
m_iWeather = 0;
|
|
Minecraft *pMinecraft = Minecraft::GetInstance();
|
|
m_bHasWeather = pMinecraft->level != nullptr;
|
|
if (m_bHasWeather)
|
|
{
|
|
if (pMinecraft->level->isThundering()) m_iWeather = 2;
|
|
else if (pMinecraft->level->isRaining()) m_iWeather = 1;
|
|
}
|
|
|
|
m_iStartDifficulty = m_iDifficulty;
|
|
m_iStartGameType = m_iGameType;
|
|
m_iStartWeather = m_iWeather;
|
|
|
|
doHorizontalResizeCheck();
|
|
}
|
|
|
|
wstring UIScene_InGameHostOptionsMenu::getMoviePath()
|
|
{
|
|
if(app.GetLocalPlayerCount() > 1)
|
|
{
|
|
return L"MultilistMenuSplit";
|
|
}
|
|
else
|
|
{
|
|
return L"MultilistMenu";
|
|
}
|
|
}
|
|
|
|
bool UIScene_InGameHostOptionsMenu::cheatsEnabled()
|
|
{
|
|
return app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0;
|
|
}
|
|
|
|
bool UIScene_InGameHostOptionsMenu::canTeleport()
|
|
{
|
|
INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(m_iPad);
|
|
if (localPlayer == nullptr) return false;
|
|
unsigned int privs = app.GetPlayerPrivileges(localPlayer->GetSmallId());
|
|
return cheatsEnabled()
|
|
&& Player::getPlayerGamePrivilege(privs, Player::ePlayerGamePrivilege_CanTeleport)
|
|
&& g_NetworkManager.GetPlayerCount() > 1;
|
|
}
|
|
|
|
wstring UIScene_InGameHostOptionsMenu::difficultyLabel(int value)
|
|
{
|
|
if (value < 0 || value > 3) value = 2;
|
|
WCHAR TempString[256];
|
|
swprintf(TempString, 256, L"%ls: %ls", app.GetString(IDS_SLIDER_DIFFICULTY), app.GetString(s_difficultyTitles[value]));
|
|
return TempString;
|
|
}
|
|
|
|
wstring UIScene_InGameHostOptionsMenu::gameModeLabel(int value)
|
|
{
|
|
if (value < 0 || value > 2) value = 0;
|
|
return app.GetString(s_gameModeTitles[value]);
|
|
}
|
|
|
|
wstring UIScene_InGameHostOptionsMenu::weatherLabel(int value)
|
|
{
|
|
if (value == 2) return app.GetString(IDS_WEATHER_THUNDER);
|
|
if (value == 1) return app.GetString(IDS_WEATHER_RAIN);
|
|
return app.GetString(IDS_WEATHER_CLEAR);
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::populateList()
|
|
{
|
|
bool alreadyRegistered = false;
|
|
for (size_t i = 0; i < m_controls.size(); ++i)
|
|
{
|
|
if (m_controls[i] == &m_multiList) alreadyRegistered = true;
|
|
}
|
|
m_multiList.setupControl(this, m_rootPath, "MultiList");
|
|
if (!alreadyRegistered) m_controls.push_back(&m_multiList);
|
|
m_multiList.clearList();
|
|
m_multiList.init(eControl_MultiList);
|
|
|
|
bool cheats = cheatsEnabled();
|
|
bool hardcore = app.GetGameHostOption(eGameHostOption_Hardcore) != 0;
|
|
|
|
m_multiList.AddNewCheckbox(app.GetString(IDS_FIRE_SPREADS), eControl_FireSpreads, m_bChecked[eControl_FireSpreads]);
|
|
m_multiList.AddNewCheckbox(app.GetString(IDS_TNT_EXPLODES), eControl_TNT, m_bChecked[eControl_TNT]);
|
|
if (cheats)
|
|
{
|
|
m_multiList.AddNewCheckbox(app.GetString(IDS_DAYLIGHT_CYCLE), eControl_DoDaylightCycle, m_bChecked[eControl_DoDaylightCycle]);
|
|
m_multiList.AddNewCheckbox(app.GetString(IDS_KEEP_INVENTORY), eControl_KeepInventory, m_bChecked[eControl_KeepInventory]);
|
|
m_multiList.AddNewCheckbox(app.GetString(IDS_MOB_SPAWNING), eControl_DoMobSpawning, m_bChecked[eControl_DoMobSpawning]);
|
|
m_multiList.AddNewCheckbox(app.GetString(IDS_MOB_GRIEFING), eControl_MobGriefing, m_bChecked[eControl_MobGriefing]);
|
|
m_multiList.AddNewButton(app.GetString(IDS_TIME_SET_DAY), eControl_SetDay);
|
|
m_multiList.AddNewButton(app.GetString(IDS_TIME_SET_NIGHT), eControl_SetNight);
|
|
if (!hardcore)
|
|
{
|
|
m_multiList.AddNewSlider(difficultyLabel(m_iDifficulty), eControl_Difficulty, 0, 3, 1, m_iDifficulty);
|
|
m_multiList.AddNewSlider(gameModeLabel(m_iGameType), eControl_GameMode, 0, 2, 1, m_iGameType);
|
|
}
|
|
m_multiList.AddNewButton(app.GetString(IDS_SET_WORLD_SPAWN), eControl_SetWorldSpawn);
|
|
if (m_bHasWeather)
|
|
{
|
|
m_multiList.AddNewLabel(L" ");
|
|
m_multiList.AddNewLabel(app.GetString(IDS_WEATHER));
|
|
m_multiList.AddNewSlider(weatherLabel(m_iWeather), eControl_Weather, 0, 2, 1, m_iWeather);
|
|
}
|
|
m_multiList.AddNewCheckbox(app.GetString(IDS_WEATHER_CYCLE), eControl_DoWeatherCycle, m_bChecked[eControl_DoWeatherCycle]);
|
|
}
|
|
m_multiList.AddNewCheckbox(app.GetString(IDS_MOB_LOOT), eControl_DoMobLoot, m_bChecked[eControl_DoMobLoot]);
|
|
m_multiList.AddNewCheckbox(app.GetString(IDS_TILE_DROPS), eControl_DoTileDrops, m_bChecked[eControl_DoTileDrops]);
|
|
m_multiList.AddNewCheckbox(app.GetString(IDS_NATURAL_REGEN), eControl_NaturalRegeneration, m_bChecked[eControl_NaturalRegeneration]);
|
|
|
|
if (canTeleport())
|
|
{
|
|
m_multiList.AddNewButton(app.GetString(IDS_TELEPORT_TO_PLAYER), eControl_TeleportToPlayer);
|
|
m_multiList.AddNewButton(app.GetString(IDS_TELEPORT_TO_ME), eControl_TeleportToMe);
|
|
}
|
|
|
|
IggyName funcDoVert = registerFastName(L"DoVerticalResizeCheck");
|
|
IggyName funcHideDesc = registerFastName(L"HideDescription");
|
|
IggyDataValue result;
|
|
IggyPlayerCallMethodRS(getMovie(), &result, m_rootPath, funcDoVert, 0, nullptr);
|
|
doHorizontalResizeCheck();
|
|
IggyPlayerCallMethodRS(getMovie(), &result, m_rootPath, funcHideDesc, 0, nullptr);
|
|
m_multiList.HighlightItem(eControl_TNT);
|
|
m_multiList.HighlightItem(eControl_FireSpreads);
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::tick()
|
|
{
|
|
if (m_bNeedsMultiListPopulate)
|
|
{
|
|
m_bNeedsMultiListPopulate = false;
|
|
m_bInitialPopulateDone = false;
|
|
populateList();
|
|
}
|
|
|
|
if (m_bPendingSliderUpdate)
|
|
{
|
|
m_bPendingSliderUpdate = false;
|
|
m_multiList.SetSliderValue(m_iPendingSliderId, m_iPendingSliderValue);
|
|
switch (m_iPendingSliderId)
|
|
{
|
|
case eControl_Difficulty:
|
|
m_iDifficulty = m_iPendingSliderValue;
|
|
m_multiList.SetSliderLabel(eControl_Difficulty, difficultyLabel(m_iDifficulty));
|
|
break;
|
|
case eControl_GameMode:
|
|
m_iGameType = m_iPendingSliderValue;
|
|
m_multiList.SetSliderLabel(eControl_GameMode, gameModeLabel(m_iGameType));
|
|
break;
|
|
case eControl_Weather:
|
|
m_iWeather = m_iPendingSliderValue;
|
|
m_multiList.SetSliderLabel(eControl_Weather, weatherLabel(m_iWeather));
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (m_iPendingTeleport >= 0)
|
|
{
|
|
TeleportMenuInitData *initData = new TeleportMenuInitData();
|
|
initData->iPad = m_iPad;
|
|
initData->teleportToPlayer = m_iPendingTeleport == eControl_TeleportToPlayer;
|
|
m_iPendingTeleport = -1;
|
|
ui.NavigateToScene(m_iPad, eUIScene_TeleportMenu, (void*)initData);
|
|
}
|
|
|
|
UIScene::tick();
|
|
m_bInitialPopulateDone = true;
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::updateTooltips()
|
|
{
|
|
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::handleReload()
|
|
{
|
|
UIScene::handleReload();
|
|
m_bNeedsMultiListPopulate = true;
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::handleGainFocus(bool navBack)
|
|
{
|
|
if (navBack)
|
|
{
|
|
m_bNeedsMultiListPopulate = true;
|
|
}
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::sendCommand(shared_ptr<Packet> packet)
|
|
{
|
|
Minecraft *pMinecraft = Minecraft::GetInstance();
|
|
shared_ptr<MultiplayerLocalPlayer> player = pMinecraft->localplayers[m_iPad];
|
|
if (player != nullptr && player->connection && packet != nullptr)
|
|
{
|
|
player->connection->send(packet);
|
|
}
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::applyAndClose()
|
|
{
|
|
for (int i = 0; i < m_multiList.getItemCount(); ++i)
|
|
{
|
|
int id = m_multiList.getIdFromIndex(i);
|
|
switch (id)
|
|
{
|
|
case eControl_FireSpreads:
|
|
case eControl_TNT:
|
|
case eControl_DoDaylightCycle:
|
|
case eControl_KeepInventory:
|
|
case eControl_DoMobSpawning:
|
|
case eControl_MobGriefing:
|
|
case eControl_DoWeatherCycle:
|
|
case eControl_DoMobLoot:
|
|
case eControl_DoTileDrops:
|
|
case eControl_NaturalRegeneration:
|
|
m_bChecked[id] = m_multiList.GetCheckboxValue(id);
|
|
break;
|
|
}
|
|
}
|
|
|
|
unsigned int hostOptions = app.GetGameHostOption(eGameHostOption_All);
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_FireSpreads, m_bChecked[eControl_FireSpreads]);
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_TNT, m_bChecked[eControl_TNT]);
|
|
if (cheatsEnabled())
|
|
{
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_DoDaylightCycle, m_bChecked[eControl_DoDaylightCycle]);
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_KeepInventory, m_bChecked[eControl_KeepInventory]);
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_DoMobSpawning, m_bChecked[eControl_DoMobSpawning]);
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_MobGriefing, m_bChecked[eControl_MobGriefing]);
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_DoWeatherCycle, m_bChecked[eControl_DoWeatherCycle]);
|
|
|
|
if (app.GetGameHostOption(eGameHostOption_Hardcore) == 0)
|
|
{
|
|
if (m_iDifficulty != m_iStartDifficulty)
|
|
{
|
|
sendCommand(GameDifficultyCommand::preparePacket(m_iDifficulty));
|
|
}
|
|
if (m_iGameType != m_iStartGameType)
|
|
{
|
|
sendCommand(DefaultGameModeCommand::preparePacket(m_iGameType));
|
|
}
|
|
}
|
|
if (m_bHasWeather && m_iWeather != m_iStartWeather)
|
|
{
|
|
sendCommand(WeatherCommand::preparePacket(m_iWeather));
|
|
}
|
|
}
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_DoMobLoot, m_bChecked[eControl_DoMobLoot]);
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_DoTileDrops, m_bChecked[eControl_DoTileDrops]);
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_NaturalRegeneration, m_bChecked[eControl_NaturalRegeneration]);
|
|
|
|
if (hostOptions != app.GetGameHostOption(eGameHostOption_All))
|
|
{
|
|
sendCommand(std::make_shared<ServerSettingsChangedPacket>(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions));
|
|
}
|
|
|
|
navigateBack();
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
|
|
{
|
|
ui.AnimateKeyPress(iPad, key, repeat, pressed, released);
|
|
switch(key)
|
|
{
|
|
case ACTION_MENU_CANCEL:
|
|
if(pressed)
|
|
{
|
|
applyAndClose();
|
|
handled = true;
|
|
}
|
|
break;
|
|
case ACTION_MENU_OK:
|
|
#ifdef __ORBIS__
|
|
case ACTION_MENU_TOUCHPAD_PRESS:
|
|
#endif
|
|
case ACTION_MENU_UP:
|
|
case ACTION_MENU_DOWN:
|
|
case ACTION_MENU_LEFT:
|
|
case ACTION_MENU_RIGHT:
|
|
case ACTION_MENU_PAGEUP:
|
|
case ACTION_MENU_PAGEDOWN:
|
|
sendInputToMovie(key, repeat, pressed, released);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::handlePress(F64 controlId, F64 childId)
|
|
{
|
|
ui.PlayUISFX(eSFX_Press);
|
|
switch (static_cast<int>(childId))
|
|
{
|
|
case eControl_TeleportToPlayer:
|
|
case eControl_TeleportToMe:
|
|
m_iPendingTeleport = static_cast<int>(childId);
|
|
break;
|
|
case eControl_SetDay:
|
|
sendCommand(TimeCommand::preparePacket(1000));
|
|
break;
|
|
case eControl_SetNight:
|
|
sendCommand(TimeCommand::preparePacket(14000));
|
|
break;
|
|
case eControl_SetWorldSpawn:
|
|
sendCommand(SetDefaultSpawnpointCommand::preparePacket());
|
|
break;
|
|
}
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::handleSliderMove(F64 sliderId, F64 currentValue)
|
|
{
|
|
int id = static_cast<int>(sliderId);
|
|
int value = static_cast<int>(currentValue);
|
|
m_multiList.handleSliderMove(id, value);
|
|
|
|
switch (id)
|
|
{
|
|
case eControl_Difficulty:
|
|
case eControl_GameMode:
|
|
case eControl_Weather:
|
|
if (m_bInitialPopulateDone) ui.PlayUISFX(eSFX_Scroll);
|
|
m_bPendingSliderUpdate = true;
|
|
m_iPendingSliderId = id;
|
|
m_iPendingSliderValue = value;
|
|
break;
|
|
}
|
|
}
|
|
|
|
void UIScene_InGameHostOptionsMenu::handleCheckboxToggled(F64 controlId, bool selected)
|
|
{
|
|
if (m_bInitialPopulateDone) ui.PlayUISFX(eSFX_Press);
|
|
int id = static_cast<int>(controlId);
|
|
if (id > eControl_MultiList && id < eControl_Count)
|
|
{
|
|
m_bChecked[id] = selected;
|
|
}
|
|
}
|