Files
mcpe/source/client/gui/screens/OptionsScreen.cpp
Brent a0f71c7b27 C++03 Support & Partial Xbox 360 Support (#37)
* WIP C++03 + Xbox 360 Support

* math.h & _USE_MATH_DEFINES on Level.hpp
Updated Xenon vcxproj file for new file structure.

* * Fix bad GUI scale setup.

* * Gui: Use ratios instead of hardcoded sub-1 floating point values, to make the mechanism more clear.

* Add Direct Connect Button and Screen (#30)

* Add Direct Connect Button and Screen

* Remove accidental extra build directories for wasm

* Add DirectConnectScreen.cpp to the CMake

* Use Hungarian coding style notation

* * Fix errors caused by #30

* * Improve the Chat Screen

* * Improve the DirectConnectScreen, among other things.

* * Update the game title once again.

* * Add build-wasm.bat.

* * Add info about compiling for wasm

* * Fix send to specific GUID actually broadcasting to everyone

* * Add command manager.

* * Add writeable configuration.

* * Allow dynamic screen size change on windows

* * Allow the same thing on the emscripten version.

* WIP C++03 + Xbox 360 Support

* Fixed a possible merging issue that broke RakNet?

* Additional Xbox 360 compatability fixes

---------

Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
Co-authored-by: iProgramInCpp <iprogramincpp@gmail.com>
Co-authored-by: ts <124226059+uniformization@users.noreply.github.com>
2023-08-07 15:48:52 +03:00

225 lines
5.8 KiB
C++

/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#include "OptionsScreen.hpp"
#include "StartMenuScreen.hpp"
#include "PauseScreen.hpp"
enum eOptionsButton
{
OB_BACK = 1,
OB_AO,
OB_SRV_VIS,
OB_FANCY_GFX,
OB_INVERT_Y,
OB_ANAGLYPHS,
OB_VIEW_BOB,
OB_VIEW_DIST,
OB_FLY_HAX,
OB_AUTO_JUMP
};
OptionsScreen::OptionsScreen()
#ifndef ORIGINAL_CODE
:m_BackButton (1, 0, 0, 200, 20, "Done"),
m_AOButton (2, 0, 0, 150, 20, ""),
m_srvVisButton (3, 0, 0, 150, 20, ""),
m_fancyGfxButton (4, 0, 0, 150, 20, ""),
m_invertYButton (5, 0, 0, 150, 20, ""),
m_anaglyphsButton(6, 0, 0, 150, 20, ""),
m_viewBobButton (7, 0, 0, 150, 20, ""),
m_viewDistButton (8, 0, 0, 150, 20, ""),
m_flightHaxButton(9, 0, 0, 150, 20, ""),
m_autoJumpButton (10, 0, 0, 150, 20, "")
#endif
{
}
#ifndef ORIGINAL_CODE
static std::string BoolOptionStr(bool b)
{
return b ? "ON" : "OFF";
}
static std::string ViewDistanceStr(int dist)
{
switch (dist)
{
case 0: return "EXTREME";
case 1: return "FAR";
case 2: return "NORMAL";
case 3: return "SHORT";
case 4: return "TINY";
default:
{
std::stringstream ss;
ss << dist;
return ss.str();
}
}
}
void OptionsScreen::UpdateTexts()
{
Options& o = m_pMinecraft->m_options;
m_AOButton.m_text = "Smooth lighting: " + BoolOptionStr(o.field_18);
m_invertYButton.m_text = "Invert Y-axis: " + BoolOptionStr(o.m_bInvertMouse);
m_viewBobButton.m_text = "View bobbing: " + BoolOptionStr(o.field_14);
m_anaglyphsButton.m_text = "3d Anaglyphs: " + BoolOptionStr(o.m_bAnaglyphs);
m_fancyGfxButton.m_text = "Fancy graphics: " + BoolOptionStr(o.m_bFancyGraphics);
m_flightHaxButton.m_text = "Flight hax: " + BoolOptionStr(o.m_bFlyCheat);
m_autoJumpButton.m_text = "Auto Jump: " + BoolOptionStr(o.m_bAutoJump);
m_viewDistButton.m_text = "View distance: " + ViewDistanceStr(o.field_10);
m_srvVisButton.m_text = "Server " + std::string(o.m_bServerVisibleDefault ? "visible" : "invisible") + " by default";
}
#endif
void OptionsScreen::init()
{
m_pMinecraft->platform()->showDialog(AppPlatform::DLG_OPTIONS);
m_pMinecraft->platform()->createUserInput();
#ifndef ORIGINAL_CODE
m_BackButton.m_xPos = m_width / 2 - m_BackButton.m_width / 2;
m_BackButton.m_yPos = m_height - 33;
m_BackButton.m_height = 20;
m_buttons.push_back(&m_BackButton);
m_AOButton.m_xPos =
m_srvVisButton.m_xPos =
m_fancyGfxButton.m_xPos =
m_viewDistButton.m_xPos = m_width / 2 - m_AOButton.m_width - 5;
m_invertYButton.m_xPos =
m_anaglyphsButton.m_xPos =
m_viewBobButton.m_xPos =
m_flightHaxButton.m_xPos =
m_autoJumpButton.m_xPos = m_width / 2 + 5;
int yPos = 40;
m_AOButton.m_yPos = m_invertYButton.m_yPos = yPos; yPos += 25;
m_srvVisButton.m_yPos = m_anaglyphsButton.m_yPos = yPos; yPos += 25;
m_fancyGfxButton.m_yPos = m_viewBobButton.m_yPos = yPos; yPos += 25;
m_viewDistButton.m_yPos = m_flightHaxButton.m_yPos = yPos; yPos += 25;
m_autoJumpButton.m_yPos = yPos; yPos += 25;
m_buttons.push_back(&m_AOButton);
m_buttons.push_back(&m_srvVisButton);
m_buttons.push_back(&m_fancyGfxButton);
m_buttons.push_back(&m_invertYButton);
m_buttons.push_back(&m_anaglyphsButton);
m_buttons.push_back(&m_viewBobButton);
m_buttons.push_back(&m_viewDistButton);
m_buttons.push_back(&m_flightHaxButton);
m_buttons.push_back(&m_autoJumpButton);
m_buttonTabList.push_back(&m_AOButton);
m_buttonTabList.push_back(&m_srvVisButton);
m_buttonTabList.push_back(&m_fancyGfxButton);
m_buttonTabList.push_back(&m_viewDistButton);
m_buttonTabList.push_back(&m_invertYButton);
m_buttonTabList.push_back(&m_anaglyphsButton);
m_buttonTabList.push_back(&m_viewBobButton);
m_buttonTabList.push_back(&m_flightHaxButton);
m_buttonTabList.push_back(&m_autoJumpButton);
m_buttonTabList.push_back(&m_BackButton);
UpdateTexts();
#ifdef __EMSCRIPTEN__
m_srvVisButton.m_bEnabled = false;
#endif
#endif
}
void OptionsScreen::render(int a, int b, float c)
{
renderBackground();
if (m_pMinecraft->m_pPlatform->getUserInputStatus() >= 0)
{
m_pMinecraft->setScreen(new StartMenuScreen);
}
#ifndef ORIGINAL_CODE
drawCenteredString(m_pFont, "Options", m_width / 2, 20, 0xFFFFFF);
Screen::render(a, b, c);
#endif
}
void OptionsScreen::removed()
{
#ifdef ORIGINAL_CODE // Reloading options will reload the options.txt we introduced. Don't do this
m_pMinecraft->reloadOptions();
#endif
}
#ifndef ORIGINAL_CODE
void OptionsScreen::buttonClicked(Button* pButton)
{
Options& o = m_pMinecraft->m_options;
bool* pOption = nullptr;
switch (pButton->m_buttonId)
{
case OB_BACK:
if (m_pMinecraft->isLevelGenerated())
m_pMinecraft->setScreen(new PauseScreen);
else
m_pMinecraft->setScreen(new StartMenuScreen);
return;
case OB_AO:
o.field_18 ^= 1;
Minecraft::useAmbientOcclusion = o.field_18;
m_pMinecraft->m_pLevelRenderer->allChanged();
UpdateTexts();
return;
case OB_FANCY_GFX:
o.m_bFancyGraphics ^= 1;
m_pMinecraft->m_pLevelRenderer->allChanged();
UpdateTexts();
return;
case OB_VIEW_DIST:
// @TODO: fix the 'extreme' render distance
o.field_10 = (o.field_10 + 1) % 4;
UpdateTexts();
return;
case OB_ANAGLYPHS:
pOption = &o.m_bAnaglyphs;
break;
case OB_INVERT_Y:
pOption = &o.m_bInvertMouse;
break;
case OB_SRV_VIS:
pOption = &o.m_bServerVisibleDefault;
break;
case OB_VIEW_BOB:
pOption = &o.field_14;
break;
case OB_FLY_HAX:
pOption = &o.m_bFlyCheat;
break;
case OB_AUTO_JUMP:
pOption = &o.m_bAutoJump;
break;
}
if (!pOption)
return;
*pOption ^= 1;
UpdateTexts();
}
#endif