Files
GabsPuNs-Project_Zenith_Main/Minecraft.Client/Common/UI/UIScene_InGameHostOptionsMenu.cpp
GabsPuNs 3bfd7d9bde Menu Progress
LaunchMoreOptionsMenu and SettingsGraphicsMenu works now.
Change seed dont work.
Label update for sliders dont work.
InGameHostOptionsMenu is disabled for now.
2026-05-22 23:48:03 -04:00

213 lines
8.5 KiB
C++

#include "UI.h"
#include "UIScene_InGameHostOptionsMenu.h"
#include "..\..\MultiPlayerLocalPlayer.h"
#include "..\..\ClientConnection.h"
#include "..\..\MultiPlayerLevel.h"
int m_iGamemodeTitleSetting[3]=
{
IDS_SURVIVAL,
IDS_CREATIVE,
IDS_ADVENTURE
};
int m_iDifficultyTitleSetting[4]=
{
IDS_DIFFICULTY_TITLE_PEACEFUL,
IDS_DIFFICULTY_TITLE_EASY,
IDS_DIFFICULTY_TITLE_NORMAL,
IDS_DIFFICULTY_TITLE_HARD
};
UIScene_InGameHostOptionsMenu::UIScene_InGameHostOptionsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
// Setup all the Iggy references we need for this scene
initialiseMovie();
Init();
}
void UIScene_InGameHostOptionsMenu::Init()
{
m_hostOptionsList.AddNewCheckbox(app.GetString(IDS_FIRE_SPREADS), eControl_FireSpreads, app.GetGameHostOption(eGameHostOption_FireSpreads) != 0);
m_hostOptionsList.AddNewCheckbox(app.GetString(IDS_TNT_EXPLODES), eControl_TNT, app.GetGameHostOption(eGameHostOption_TNT) != 0);
if (app.GetGameHostOption(eGameHostOption_CheatsEnabled))
{
m_hostOptionsList.AddNewCheckbox(app.GetString(IDS_MOB_LOOT), eControl_DoMobLoot, app.GetGameHostOption(eGameHostOption_DoMobLoot));
m_hostOptionsList.AddNewCheckbox(app.GetString(IDS_TILE_DROPS), eControl_DoTileDrops, app.GetGameHostOption(eGameHostOption_DoTileDrops));
m_hostOptionsList.AddNewCheckbox(app.GetString(IDS_NATURAL_REGEN), eControl_NaturalRegeneration, app.GetGameHostOption(eGameHostOption_NaturalRegeneration));
m_hostOptionsList.AddNewButton(L"Set Day", eControl_TimeSetDay);
m_hostOptionsList.AddNewButton(L"Set Night", eControl_TimeSetNight);
int m_CurrentDifficulty = app.GetGameSettings(m_iPad, eGameSetting_Difficulty);
WCHAR TempString[256];
swprintf_s(TempString, 256, L"%ls: %ls", app.GetString(IDS_SLIDER_DIFFICULTY), app.GetString(m_iDifficultyTitleSetting[app.GetGameSettings(m_iPad, eGameSetting_Difficulty)]));
m_hostOptionsList.AddNewSlider(TempString, eControl_Difficulty, 0, 3, app.GetGameSettings(m_iPad, eGameSetting_Difficulty));
swprintf_s(TempString, 256, L"Game Mode: %ls", app.GetString(m_iGamemodeTitleSetting[0]));
m_hostOptionsList.AddNewSlider(TempString, eControl_GameType, 0, 2, app.GetGameHostOption(eGameHostOption_GameType));
m_hostOptionsList.AddNewButton(L"Set World Spawn Point", eControl_PlayerPermissions);
auto* pMinecraft = Minecraft::GetInstance();
if (pMinecraft->getLevel(0))
{
m_hostOptionsList.AddNewLabel(L"");
m_hostOptionsList.AddNewLabel(L"Weather");
int weatherState = pMinecraft->getLevel(0)->getWeatherState();
std::wstring weatherString = L"";
// TODO: Confirm if these names are correct
if (weatherState == 1)
weatherString = L"Rain";
else if (weatherState == 2)
weatherString = L"Thunder";
else
weatherString = L"Clear";
m_hostOptionsList.AddNewSlider(weatherString, eControl_Weather, 0, 2, 0);
}
m_hostOptionsList.AddNewCheckbox(L"Weather Cycle", eControl_ShowCoordinates, 0);
}
m_hostOptionsList.AddNewCheckbox(app.GetString(IDS_MOB_GRIEFING), eControl_MobGriefing, app.GetGameHostOption(eGameHostOption_MobGriefing));
m_hostOptionsList.AddNewCheckbox(app.GetString(IDS_KEEP_INVENTORY), eControl_KeepInventory, app.GetGameHostOption(eGameHostOption_KeepInventory));
m_hostOptionsList.AddNewCheckbox(app.GetString(IDS_MOB_SPAWNING), eControl_DoMobSpawning, app.GetGameHostOption(eGameHostOption_DoMobSpawning));
auto* localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(m_iPad);
if (!localPlayer)
{
app.DebugPrintf("<UIScene_InGameHostOptionsMenu::UIScene_InGameHostOptionsMenu> Error: couldn't retrieve network player %d\n", localPlayer->GetOnlineName());
return;
}
unsigned int privs = app.GetPlayerPrivileges(localPlayer->GetSmallId());
const bool canTeleport = app.GetGameHostOption(eGameHostOption_CheatsEnabled) && Player::getPlayerGamePrivilege(privs, Player::ePlayerGamePrivilege_CanTeleport) && g_NetworkManager.GetPlayerCount() > 1;
if (canTeleport)
{
m_hostOptionsList.AddNewButton(app.GetString(IDS_TELEPORT_TO_PLAYER), eControl_TeleportToPlayer);
m_hostOptionsList.AddNewButton(app.GetString(IDS_TELEPORT_TO_ME), eControl_TeleportToMe);
}
}
wstring UIScene_InGameHostOptionsMenu::getMoviePath()
{
if(app.GetLocalPlayerCount() > 1)
return L"InGameHostOptionsSplit";
else
return L"InGameHostOptions";
}
void UIScene_InGameHostOptionsMenu::updateTooltips()
{
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
}
void UIScene_InGameHostOptionsMenu::handleReload()
{
Init();
}
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)
{
//Disable this for now
/*
unsigned int hostOptions = app.GetGameHostOption(eGameHostOption_All);
app.SetGameHostOption(hostOptions, eGameHostOption_FireSpreads, m_hostOptionsList.GetCheckboxValue(eControl_FireSpreads));
app.SetGameHostOption(hostOptions, eGameHostOption_TNT, m_hostOptionsList.GetCheckboxValue(eControl_TNT));
app.SetGameHostOption(hostOptions, eGameHostOption_DoMobLoot, m_hostOptionsList.GetCheckboxValue(eControl_DoMobLoot));
app.SetGameHostOption(hostOptions, eGameHostOption_DoTileDrops, m_hostOptionsList.GetCheckboxValue(eControl_DoTileDrops));
app.SetGameHostOption(hostOptions, eGameHostOption_NaturalRegeneration, m_hostOptionsList.GetCheckboxValue(eControl_NaturalRegeneration));
// If cheats are enabled, set cheat values
if (app.GetGameHostOption(eGameHostOption_CheatsEnabled))
{
app.SetGameHostOption(hostOptions, eGameHostOption_MobGriefing, m_hostOptionsList.GetCheckboxValue(eControl_MobGriefing));
app.SetGameHostOption(hostOptions, eGameHostOption_KeepInventory, m_hostOptionsList.GetCheckboxValue(eControl_KeepInventory));
app.SetGameHostOption(hostOptions, eGameHostOption_DoMobSpawning, m_hostOptionsList.GetCheckboxValue(eControl_DoMobSpawning));
//app.SetGameHostOption(hostOptions, eGameHostOption_DoDaylightCycle, m_hostOptionsList.GetCheckboxValue(eControl_DoDayLightCycle));
auto pMinecraft = Minecraft::GetInstance();
auto localPlayer = pMinecraft->localplayers[m_iPad];
int oldDifficulty = app.GetGameSettings(m_iPad, eGameSetting_Difficulty);
int newDifficulty = m_hostOptionsList.GetSliderValue(eControl_Difficulty);
if (oldDifficulty != newDifficulty && localPlayer && localPlayer->connection)
{
//GameDifficultyCommand packet(newDifficulty);
//localPlayer->connection->send(packet);
}
int oldGameMode = app.GetGameHostOption(eGameHostOption_GameType);
int newGameMode = m_hostOptionsList.GetSliderValue(eControl_GameType);
if (oldGameMode != newGameMode && localPlayer && localPlayer->connection)
{
//DefaultGameModeCommand packet(newGameMode);
//localPlayer->connection->send(packet);
}
auto level = pMinecraft->getLevel(0);
if (level)
{
int oldWeather = level->getWeatherState();
int newWeather = m_hostOptionsList.GetSliderValue(eControl_Weather);
if (oldWeather != newWeather && localPlayer && localPlayer->connection)
{
//WeatherCommand packet(newWeather);
//localPlayer->connection->send(packet);
}
}
}
// Send update settings packet to server
if(hostOptions != app.GetGameHostOption(eGameHostOption_All) )
{
auto *pMinecraft = Minecraft::GetInstance();
auto localPlayer = pMinecraft->localplayers[m_iPad];
if(localPlayer->connection)
localPlayer->connection->send(std::make_shared<ServerSettingsChangedPacket>(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions));
}
*/
navigateBack();
handled = true;
}
break;
case ACTION_MENU_OK:
#ifdef __ORBIS__
case ACTION_MENU_TOUCHPAD_PRESS:
#endif
sendInputToMovie(key, repeat, pressed, released);
break;
case ACTION_MENU_UP:
case ACTION_MENU_DOWN:
sendInputToMovie(key, repeat, pressed, released);
break;
}
}
void UIScene_InGameHostOptionsMenu::handlePress(F64 controlId, F64 childId)
{
auto *initData = new TeleportMenuInitData();
initData->iPad = m_iPad;
initData->teleportToPlayer = false;
if( static_cast<int>(childId) == eControl_TeleportToPlayer )
initData->teleportToPlayer = true;
ui.NavigateToScene(m_iPad,eUIScene_TeleportMenu,(void*)initData);
}