|
|
|
|
@@ -1,64 +1,109 @@
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "UI.h"
|
|
|
|
|
#include "UIScene_InGameHostOptionsMenu.h"
|
|
|
|
|
#include "..\..\Minecraft.h"
|
|
|
|
|
#include "..\..\MultiPlayerLocalPlayer.h"
|
|
|
|
|
#include "..\..\ClientConnection.h"
|
|
|
|
|
#include "..\..\..\Minecraft.World\net.minecraft.network.h"
|
|
|
|
|
#include "..\..\..\Minecraft.World\net.minecraft.network.packet.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();
|
|
|
|
|
|
|
|
|
|
m_checkboxFireSpreads.init(app.GetString(IDS_FIRE_SPREADS), eControl_FireSpreads, app.GetGameHostOption(eGameHostOption_FireSpreads)!=0);
|
|
|
|
|
m_checkboxTNT.init(app.GetString(IDS_TNT_EXPLODES), eControl_TNT, app.GetGameHostOption(eGameHostOption_TNT)!=0);
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_checkboxDoMobLoot.init(app.GetString(IDS_MOB_LOOT), eControl_DoMobLoot, app.GetGameHostOption(eGameHostOption_DoMobLoot));
|
|
|
|
|
m_checkboxDoTileDrops.init(app.GetString(IDS_TILE_DROPS), eControl_DoTileDrops, app.GetGameHostOption(eGameHostOption_DoTileDrops));
|
|
|
|
|
m_checkboxNaturalRegeneration.init(app.GetString(IDS_NATURAL_REGEN), eControl_NaturalRegeneration, app.GetGameHostOption(eGameHostOption_NaturalRegeneration));
|
|
|
|
|
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 cheats are disabled, remove checkboxes
|
|
|
|
|
if (!app.GetGameHostOption(eGameHostOption_CheatsEnabled))
|
|
|
|
|
if (app.GetGameHostOption(eGameHostOption_CheatsEnabled))
|
|
|
|
|
{
|
|
|
|
|
removeControl(&m_checkboxMobGriefing, true);
|
|
|
|
|
removeControl(&m_checkboxKeepInventory, true);
|
|
|
|
|
removeControl(&m_checkboxDoMobSpawning, true);
|
|
|
|
|
removeControl(&m_checkboxDoDaylightCycle, true);
|
|
|
|
|
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, 0);
|
|
|
|
|
|
|
|
|
|
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_checkboxMobGriefing.init(app.GetString(IDS_MOB_GRIEFING), eControl_MobGriefing, app.GetGameHostOption(eGameHostOption_MobGriefing));
|
|
|
|
|
m_checkboxKeepInventory.init(app.GetString(IDS_KEEP_INVENTORY), eControl_KeepInventory, app.GetGameHostOption(eGameHostOption_KeepInventory));
|
|
|
|
|
m_checkboxDoMobSpawning.init(app.GetString(IDS_MOB_SPAWNING), eControl_DoMobSpawning, app.GetGameHostOption(eGameHostOption_DoMobSpawning));
|
|
|
|
|
m_checkboxDoDaylightCycle.init(app.GetString(IDS_DAYLIGHT_CYCLE), eControl_DoDaylightCycle, app.GetGameHostOption(eGameHostOption_DoDaylightCycle));
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad );
|
|
|
|
|
unsigned int privs = app.GetPlayerPrivileges(localPlayer->GetSmallId());
|
|
|
|
|
if(app.GetGameHostOption(eGameHostOption_CheatsEnabled)
|
|
|
|
|
&& Player::getPlayerGamePrivilege(privs,Player::ePlayerGamePrivilege_CanTeleport)
|
|
|
|
|
&& g_NetworkManager.GetPlayerCount() > 1)
|
|
|
|
|
|
|
|
|
|
const bool canTeleport = app.GetGameHostOption(eGameHostOption_CheatsEnabled) && Player::getPlayerGamePrivilege(privs, Player::ePlayerGamePrivilege_CanTeleport) && g_NetworkManager.GetPlayerCount() > 1;
|
|
|
|
|
if (canTeleport)
|
|
|
|
|
{
|
|
|
|
|
m_buttonTeleportToPlayer.init(app.GetString(IDS_TELEPORT_TO_PLAYER), eControl_TeleportToPlayer);
|
|
|
|
|
m_buttonTeleportToMe.init(app.GetString(IDS_TELEPORT_TO_ME), eControl_TeleportToMe);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
removeControl(&m_buttonTeleportToPlayer, true);
|
|
|
|
|
removeControl(&m_buttonTeleportToMe, true);
|
|
|
|
|
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()
|
|
|
|
|
@@ -70,6 +115,7 @@ void UIScene_InGameHostOptionsMenu::handleReload()
|
|
|
|
|
{
|
|
|
|
|
UIScene::handleReload();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// If cheats are disabled, remove checkboxes
|
|
|
|
|
if (!app.GetGameHostOption(eGameHostOption_CheatsEnabled))
|
|
|
|
|
{
|
|
|
|
|
@@ -78,31 +124,31 @@ void UIScene_InGameHostOptionsMenu::handleReload()
|
|
|
|
|
removeControl(&m_checkboxDoMobSpawning, true);
|
|
|
|
|
removeControl(&m_checkboxDoDaylightCycle, true);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad );
|
|
|
|
|
if (!localPlayer)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
unsigned int privs = app.GetPlayerPrivileges(localPlayer->GetSmallId());
|
|
|
|
|
if(app.GetGameHostOption(eGameHostOption_CheatsEnabled)
|
|
|
|
|
&& Player::getPlayerGamePrivilege(privs,Player::ePlayerGamePrivilege_CanTeleport)
|
|
|
|
|
&& g_NetworkManager.GetPlayerCount() > 1)
|
|
|
|
|
const bool canTeleport = app.GetGameHostOption(eGameHostOption_CheatsEnabled) && Player::getPlayerGamePrivilege(privs, Player::ePlayerGamePrivilege_CanTeleport) && g_NetworkManager.GetPlayerCount() > 1;
|
|
|
|
|
|
|
|
|
|
if(!canTeleport)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
removeControl(&m_buttonTeleportToPlayer, true);
|
|
|
|
|
removeControl(&m_buttonTeleportToMe, true);
|
|
|
|
|
//removeControl(&m_buttonTeleportToPlayer, true);
|
|
|
|
|
//removeControl(&m_buttonTeleportToMe, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
|
|
|
|
|
{
|
|
|
|
|
//app.DebugPrintf("UIScene_DebugOverlay handling input for pad %d, key %d, down- %s, pressed- %s, released- %s\n", iPad, key, down?"TRUE":"FALSE", pressed?"TRUE":"FALSE", released?"TRUE":"FALSE");
|
|
|
|
|
|
|
|
|
|
ui.AnimateKeyPress(iPad, key, repeat, pressed, released);
|
|
|
|
|
switch(key)
|
|
|
|
|
{
|
|
|
|
|
case ACTION_MENU_CANCEL:
|
|
|
|
|
if(pressed)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
unsigned int hostOptions = app.GetGameHostOption(eGameHostOption_All);
|
|
|
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_FireSpreads, m_checkboxFireSpreads.IsChecked());
|
|
|
|
|
app.SetGameHostOption(hostOptions, eGameHostOption_TNT, m_checkboxTNT.IsChecked());
|
|
|
|
|
@@ -125,10 +171,9 @@ void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat,
|
|
|
|
|
Minecraft *pMinecraft = Minecraft::GetInstance();
|
|
|
|
|
shared_ptr<MultiplayerLocalPlayer> player = pMinecraft->localplayers[m_iPad];
|
|
|
|
|
if(player->connection)
|
|
|
|
|
{
|
|
|
|
|
player->connection->send(std::make_shared<ServerSettingsChangedPacket>(ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
navigateBack();
|
|
|
|
|
|
|
|
|
|
@@ -150,12 +195,11 @@ void UIScene_InGameHostOptionsMenu::handleInput(int iPad, int key, bool repeat,
|
|
|
|
|
|
|
|
|
|
void UIScene_InGameHostOptionsMenu::handlePress(F64 controlId, F64 childId)
|
|
|
|
|
{
|
|
|
|
|
TeleportMenuInitData *initData = new TeleportMenuInitData();
|
|
|
|
|
auto *initData = new TeleportMenuInitData();
|
|
|
|
|
initData->iPad = m_iPad;
|
|
|
|
|
initData->teleportToPlayer = false;
|
|
|
|
|
if( static_cast<int>(controlId) == eControl_TeleportToPlayer )
|
|
|
|
|
{
|
|
|
|
|
initData->teleportToPlayer = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui.NavigateToScene(m_iPad,eUIScene_TeleportMenu,(void*)initData);
|
|
|
|
|
}
|
|
|
|
|
|