diff --git a/GameMods.hpp b/GameMods.hpp
index f3b2234c9..af788fb83 100644
--- a/GameMods.hpp
+++ b/GameMods.hpp
@@ -39,7 +39,6 @@
#define ENH_USE_OWN_AO // Use own ambient occlusion engine - looks pretty much the same except it fixes the corners
#define ENH_ADD_OPTIONS_PAUSE // Add an 'options' button in the pause menu
#define ENH_ALLOW_SAND_GRAVITY // Allow sand to fall.
-#define ENH_USE_GUI_SCALE_2 // Use a 2x GUI scale instead of 3x. Looks better on PC
#define ENH_ALLOW_SCROLL_WHEEL // Allow use of the scroll wheel to change selected inventory slots
#define ENH_3D_INVENTORY_TILES // Uses 3D rendered inventory tiles, use with ENH_SHADE_HELD_TILES to render correctly.
#define ENH_MENU_BACKGROUND // Renders a spinning panorama (if it's available) in the background of the main menu
diff --git a/game/assets/materials/ui.material b/game/assets/materials/ui.material
index 73b1858d0..7c086d6ab 100644
--- a/game/assets/materials/ui.material
+++ b/game/assets/materials/ui.material
@@ -35,7 +35,7 @@
"states": ["DisableCulling"]
},
- "ui_text:ui_texture_and_color": {
+ "ui_text:ui_textured_and_glcolor": {
"fragmentShader": "shaders/text.fragment"
},
diff --git a/platforms/input/xinput/GameControllerHandler_xinput.cpp b/platforms/input/xinput/GameControllerHandler_xinput.cpp
index 02701c6f2..ea7eb7e87 100644
--- a/platforms/input/xinput/GameControllerHandler_xinput.cpp
+++ b/platforms/input/xinput/GameControllerHandler_xinput.cpp
@@ -42,11 +42,6 @@ void GameControllerHandler_xinput::_initButtonMap()
m[XINPUT_GAMEPAD_START] = GameController::BUTTON_START;
}
-Keyboard::KeyState _getKeyState(bool value)
-{
- return value ? Keyboard::DOWN : Keyboard::UP;
-}
-
void GameControllerHandler_xinput::_processButton(GameController::ID controllerId, const XINPUT_STATE& state, GameController::NativeButtonID nativeBtn, GameController::EngineButtonID engineBtn, bool& joinGameAlreadyFired)
{
bool bButtonPressed = (state.Gamepad.wButtons & nativeBtn) != 0;
@@ -63,8 +58,7 @@ void GameControllerHandler_xinput::_processButton(GameController::ID controllerI
joinGameAlreadyFired = true;
}
- // @TODO: should call GameControllerManager::feedButton() instead
- Keyboard::feed(_getKeyState(bButtonPressed), engineBtn);
+ GameControllerManager::feedButton(btnState, engineBtn);
lastBtnState = btnState;
}
@@ -95,9 +89,9 @@ void GameControllerHandler_xinput::refresh()
{
XINPUT_STATE& inputState = m_inputStates.m_inputState[id];
bool joinGameAlreadyFired = false;
- for (ButtonIDMap::const_iterator it = m_buttonIdMap.begin(); it != m_buttonIdMap.end(); it++)
+ for (ButtonIDMap::iterator it = m_buttonIdMap.begin(); it != m_buttonIdMap.end(); it++)
{
- _processButton(id, inputState, it->first, it->second, joinGameAlreadyFired);
+ _processButton(id, inputState, it.key(), it.value(), joinGameAlreadyFired);
}
GameControllerManager::feedTrigger(1, (float)inputState.Gamepad.bLeftTrigger / 255.0f);
diff --git a/platforms/sdl/base/AppPlatform_sdl.cpp b/platforms/sdl/base/AppPlatform_sdl.cpp
index ecacb41fb..52ee56012 100644
--- a/platforms/sdl/base/AppPlatform_sdl.cpp
+++ b/platforms/sdl/base/AppPlatform_sdl.cpp
@@ -309,10 +309,39 @@ void AppPlatform_sdl::handleKeyEvent(const SDL_Event& event)
return _handleKeyEvent(key, state);
}
+static GameController::EngineButtonID _getEngineButton(uint8_t button)
+{
+ switch (button)
+ {
+ case SDL_CONTROLLER_BUTTON_A: return GameController::BUTTON_A;
+ case SDL_CONTROLLER_BUTTON_B: return GameController::BUTTON_B;
+ case SDL_CONTROLLER_BUTTON_X: return GameController::BUTTON_X;
+ case SDL_CONTROLLER_BUTTON_Y: return GameController::BUTTON_Y;
+ case SDL_CONTROLLER_BUTTON_DPAD_UP: return GameController::BUTTON_DPAD_UP;
+ case SDL_CONTROLLER_BUTTON_DPAD_DOWN: return GameController::BUTTON_DPAD_DOWN;
+ case SDL_CONTROLLER_BUTTON_DPAD_LEFT: return GameController::BUTTON_DPAD_LEFT;
+ case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: return GameController::BUTTON_DPAD_RIGHT;
+ case SDL_CONTROLLER_BUTTON_LEFTSTICK: return GameController::BUTTON_LEFTSTICK;
+ case SDL_CONTROLLER_BUTTON_RIGHTSTICK: return GameController::BUTTON_RIGHTSTICK;
+ case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: return GameController::BUTTON_LEFTSHOULDER;
+ case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: return GameController::BUTTON_RIGHTSHOULDER;
+ case SDL_CONTROLLER_BUTTON_BACK: return GameController::BUTTON_BACK;
+ case SDL_CONTROLLER_BUTTON_START: return GameController::BUTTON_START;
+ case SDL_CONTROLLER_BUTTON_GUIDE: return GameController::BUTTON_GUIDE;
+ case SDL_CONTROLLER_BUTTON_MISC1: return GameController::BUTTON_MISC1;
+ case SDL_CONTROLLER_BUTTON_PADDLE1: return GameController::BUTTON_PADDLE1;
+ case SDL_CONTROLLER_BUTTON_PADDLE2: return GameController::BUTTON_PADDLE2;
+ case SDL_CONTROLLER_BUTTON_PADDLE3: return GameController::BUTTON_PADDLE3;
+ case SDL_CONTROLLER_BUTTON_PADDLE4: return GameController::BUTTON_PADDLE4;
+ case SDL_CONTROLLER_BUTTON_TOUCHPAD: return GameController::BUTTON_TOUCHPAD;
+ default: return GameController::BUTTON_NONE;
+ }
+}
+
void AppPlatform_sdl::handleControllerButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state)
{
// Normal Key Press
- Keyboard::feed(GetKeyState(state), button);
+ GameControllerManager::feedButton(state == SDL_PRESSED ? GameController::BTN_STATE_DOWN : GameController::BTN_STATE_UP, _getEngineButton(button));
}
void AppPlatform_sdl::handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value)
diff --git a/platforms/sdl/base/AppPlatform_sdl.hpp b/platforms/sdl/base/AppPlatform_sdl.hpp
index c93d4f4b2..9b6c8bfc2 100644
--- a/platforms/sdl/base/AppPlatform_sdl.hpp
+++ b/platforms/sdl/base/AppPlatform_sdl.hpp
@@ -8,6 +8,7 @@
#include "client/player/input/Mouse.hpp"
#include "client/player/input/Keyboard.hpp"
+#include "client/player/input/GameController.hpp"
#include "common/Logger.hpp"
class AppPlatform_sdl : public AppPlatform
diff --git a/platforms/sdl/sdl2/main.cpp b/platforms/sdl/sdl2/main.cpp
index 68c341b10..280a86b72 100644
--- a/platforms/sdl/sdl2/main.cpp
+++ b/platforms/sdl/sdl2/main.cpp
@@ -233,7 +233,8 @@ static void handle_events()
float x = event.button.x * scale;
float y = event.button.y * scale;
Mouse::feed(type, state, x, y);
- Multitouch::feed(type, state, x, y, 0);
+ if (g_pAppPlatform->isTouchscreen())
+ Multitouch::feed(type, state, x, y, 0);
}
break;
}
@@ -244,7 +245,8 @@ static void handle_events()
float scale = g_fPointToPixelScale;
float x = event.motion.x * scale;
float y = event.motion.y * scale;
- Multitouch::feed(MOUSE_BUTTON_NONE, false, x, y, 0);
+ if (g_pAppPlatform->isTouchscreen())
+ Multitouch::feed(MOUSE_BUTTON_NONE, false, x, y, 0);
Mouse::feed(MOUSE_BUTTON_NONE, false, x, y);
g_pAppPlatform->setMouseDiff(event.motion.xrel * scale, event.motion.yrel * scale);
}
diff --git a/platforms/windows/main.cpp b/platforms/windows/main.cpp
index 00f703ea1..4848500a9 100644
--- a/platforms/windows/main.cpp
+++ b/platforms/windows/main.cpp
@@ -61,7 +61,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
posY = Mouse::getY();
}
Mouse::feed(buttonType, buttonState, posX, posY);
- Multitouch::feed(buttonType, buttonState, posX, posY, 0);
+ if (g_AppPlatform.isTouchscreen())
+ Multitouch::feed(buttonType, buttonState, posX, posY, 0);
break;
}
diff --git a/platforms/windows/projects/Common/Common.vcxproj b/platforms/windows/projects/Common/Common.vcxproj
index a497af7e0..9ee2aa6ef 100644
--- a/platforms/windows/projects/Common/Common.vcxproj
+++ b/platforms/windows/projects/Common/Common.vcxproj
@@ -115,6 +115,7 @@
+
diff --git a/platforms/windows/projects/Common/Common.vcxproj.filters b/platforms/windows/projects/Common/Common.vcxproj.filters
index 56d68fb15..fdd8109f3 100644
--- a/platforms/windows/projects/Common/Common.vcxproj.filters
+++ b/platforms/windows/projects/Common/Common.vcxproj.filters
@@ -127,5 +127,8 @@
Header Files\Threading
+
+ Header Files\Utility
+
\ No newline at end of file
diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp
index 27a162a15..888bb09a9 100644
--- a/source/client/app/Minecraft.cpp
+++ b/source/client/app/Minecraft.cpp
@@ -181,14 +181,21 @@ void Minecraft::_reloadInput()
if (isTouchscreen())
{
m_pInputHolder = new TouchInputHolder(this, getOptions());
+
+ if (m_bGrabbedMouse)
+ platform()->setMouseGrabbed(false);
}
else if (useController())
{
m_pInputHolder = new CustomInputHolder(
new ControllerMoveInput(getOptions()),
new ControllerTurnInput(),
- new ControllerBuildInput()
+ new ControllerBuildInput(),
+ true
);
+
+ if (m_bGrabbedMouse)
+ platform()->setMouseGrabbed(false);
}
else
{
@@ -197,6 +204,9 @@ void Minecraft::_reloadInput()
new MouseTurnInput(this),
new MouseBuildInput()
);
+
+ if (m_bGrabbedMouse)
+ platform()->setMouseGrabbed(true);
}
m_mouseHandler.setTurnInput(m_pInputHolder->getTurnInput());
@@ -262,7 +272,6 @@ void Minecraft::recenterMouse()
void Minecraft::setScreen(Screen* pScreen)
{
- float lastScale = getBestScaleForThisScreenSize(Minecraft::width, Minecraft::height);
#ifndef ORIGINAL_CODE
if (pScreen == nullptr && !isLevelGenerated())
{
@@ -277,13 +286,15 @@ void Minecraft::setScreen(Screen* pScreen)
return;
}
- if (pScreen && pScreen->isErrorScreen())
+ if (pScreen && (pScreen->isErrorScreen() || !pScreen->validate(this)))
{
// not in original
delete pScreen;
return;
}
+ float lastScale = getBestScaleForThisScreenSize(Minecraft::width, Minecraft::height);
+
if (m_pScreen)
{
m_pScreen->removed();
@@ -361,17 +372,17 @@ bool Minecraft::isOnlineClient() const
bool Minecraft::isTouchscreen() const
{
- return m_bIsTouchscreen;
+ return IInputHolder::activeType == IInputHolder::TOUCHSCREEN;
}
bool Minecraft::useSplitControls() const
{
- return !m_bIsTouchscreen || getOptions()->m_splitControls.get();
+ return !isTouchscreen() || getOptions()->m_splitControls.get();
}
bool Minecraft::useController() const
{
- return m_pPlatform->hasGamepad() && getOptions()->m_bUseController.get();
+ return m_pPlatform->hasGamepad() && (IInputHolder::activeType == IInputHolder::CONTROLLER || getOptions()->m_bUseController.get());
}
void Minecraft::setGameMode(GameType gameType)
@@ -505,6 +516,9 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action)
void Minecraft::tickInput()
{
+ if (!m_pInputHolder->allowsType(IInputHolder::activeType))
+ _reloadInput();
+
if (m_pScreen)
{
if (!m_pScreen->m_bPassEvents)
@@ -550,93 +564,131 @@ void Minecraft::tickInput()
#endif
}
- while (Keyboard::next())
+ if (useController())
{
- int keyCode = Keyboard::getEventKey();
- bool bPressed = Keyboard::getEventKeyState() == 1;
+ //Clearing, so the events don't accumulate
+ Keyboard::reset();
- m_pLocalPlayer->m_pMoveInput->setKey(keyCode, bPressed);
-
- if (bPressed)
+ while (GameControllerManager::next())
{
- m_pGui->handleKeyPressed(keyCode);
+ GameController::EngineButtonID button = GameControllerManager::getEventButton();
+ bool bPressed = GameControllerManager::getEventButtonState() == GameController::BTN_STATE_DOWN;
- for (int i = 0; i < m_pGui->getNumUsableSlots(); i++)
- {
- if (getOptions()->isKey(eKeyMappingIndex(KM_SLOT_1 + i), keyCode))
- m_pLocalPlayer->m_pInventory->selectSlot(i);
- }
+ if (bPressed)
+ m_pGui->handleControlPressed(ControlBind(-1, button));
- if (getOptions()->isKey(KM_TOGGLE3RD, keyCode))
+ for (size_t i = 0; i < KM_COUNT; ++i)
{
- getOptions()->m_thirdPerson.toggle();
+ eControlMappingIndex ctrl = (eControlMappingIndex)i;
+ if (!getOptions()->getControl(ctrl).isButton(button)) continue;
+
+ m_pLocalPlayer->m_pMoveInput->setKey(ctrl, bPressed);
+ if (bPressed)
+ getOptions()->getControlMapping(ctrl).pressed();
+ else
+ getOptions()->getControlMapping(ctrl).reset();
}
- else if (getOptions()->isKey(KM_MENU_PAUSE, keyCode))
+ }
+ }
+ else
+ {
+ //Clearing, so the events don't accumulate
+ GameControllerManager::clear();
+ while (Keyboard::next())
+ {
+ int keyCode = Keyboard::getEventKey();
+ bool bPressed = Keyboard::getEventKeyState() == Keyboard::DOWN;
+
+ if (bPressed)
+ m_pGui->handleControlPressed(ControlBind(keyCode, GameController::BUTTON_NONE));
+
+ for (size_t i = 0; i < KM_COUNT; ++i)
{
- handleBack(false);
+ eControlMappingIndex ctrl = (eControlMappingIndex)i;
+ if (!getOptions()->isKey(ctrl, keyCode)) continue;
+
+ m_pLocalPlayer->m_pMoveInput->setKey(ctrl, bPressed);
+ if (bPressed)
+ getOptions()->getControlMapping(ctrl).pressed();
+ else
+ getOptions()->getControlMapping(ctrl).reset();
}
- else if (getOptions()->isKey(KM_DROP, keyCode))
+
+ if (getOptions()->field_19)
+ continue;
+
+ // @TODO: Replace with KeyboardBuildInput
+ if (getTimeMs() - field_2B4 <= 200)
{
- ItemStack& item = m_pLocalPlayer->m_pInventory->getSelected();
- if (!item.isEmpty())
+ if (getOptions()->isKey(KM_DESTROY, keyCode) && bPressed)
{
- ItemStack itemDrop(item);
- itemDrop.m_count = 1;
-
- if (m_pLocalPlayer->isSurvival())
- item.shrink(1);
+ BuildActionIntention intention(BuildActionIntention::KEY_DESTROY);
+ handleBuildAction(intention);
+ }
- m_pLocalPlayer->drop(itemDrop);
+ if (getOptions()->isKey(KM_PLACE, keyCode) && bPressed)
+ {
+ BuildActionIntention intention(BuildActionIntention::KEY_USE);
+ handleBuildAction(intention);
}
}
- else if (getOptions()->isKey(KM_TOGGLEGUI, keyCode))
- {
- getOptions()->m_hideGui.toggle();
- }
- else if (getOptions()->isKey(KM_TOGGLEDEBUG, keyCode))
- {
- getOptions()->m_debugText.toggle();
- }
-#ifdef ENH_ALLOW_AO_TOGGLE
- else if (getOptions()->isKey(KM_TOGGLEAO, keyCode))
- {
- // Toggle ambient occlusion.
- getOptions()->m_ambientOcclusion.toggle();
- Minecraft::useAmbientOcclusion = getOptions()->m_ambientOcclusion.get();
- m_pLevelRenderer->allChanged();
- }
-#endif
}
+ }
- if (getOptions()->field_19)
- continue;
+ for (int i = 0; i < m_pGui->getNumUsableSlots(); i++)
+ {
+ while (getOptions()->getControlMapping(eControlMappingIndex(KM_SLOT_1 + i)).consume())
+ m_pLocalPlayer->m_pInventory->selectSlot(i);
+ }
- // @TODO: Replace with KeyboardBuildInput
- if (!useController() && getTimeMs() - field_2B4 <= 200)
+ while (getOptions()->getControlMapping(KM_TOGGLE3RD).consume())
+ {
+ getOptions()->m_thirdPerson.toggle();
+ }
+
+ while (getOptions()->getControlMapping(KM_MENU_PAUSE).consume())
+ {
+ handleBack(false);
+ }
+
+ while (getOptions()->getControlMapping(KM_DROP).consume())
+ {
+ ItemStack& item = m_pLocalPlayer->m_pInventory->getSelected();
+ if (!item.isEmpty())
{
- if (getOptions()->getKey(KM_DESTROY) == keyCode && bPressed)
- {
- BuildActionIntention intention(BuildActionIntention::KEY_DESTROY);
- handleBuildAction(intention);
- }
+ ItemStack itemDrop(item);
+ itemDrop.m_count = 1;
- if (getOptions()->getKey(KM_PLACE) == keyCode && bPressed)
- {
- BuildActionIntention intention(BuildActionIntention::KEY_USE);
- handleBuildAction(intention);
- }
+ item.shrink(1);
+
+ m_pLocalPlayer->drop(itemDrop);
}
}
+ while (getOptions()->getControlMapping(KM_TOGGLEGUI).consume())
+ {
+ getOptions()->m_hideGui.toggle();
+ }
+
+ while (getOptions()->getControlMapping(KM_TOGGLEDEBUG).consume())
+ {
+ getOptions()->m_debugText.toggle();
+ }
+#ifdef ENH_ALLOW_AO_TOGGLE
+ while (getOptions()->getControlMapping(KM_TOGGLEAO).consume())
+ {
+ // Toggle ambient occlusion.
+ getOptions()->m_ambientOcclusion.toggle();
+ m_pLevelRenderer->allChanged();
+ }
+#endif
+
BuildActionIntention bai;
IBuildInput* buildInput = m_pInputHolder->getBuildInput();
if (buildInput && buildInput->tickBuild(m_pLocalPlayer, &bai))
handleBuildAction(bai);
field_2B4 = getTimeMs();
-
- Keyboard::reset();
- Mouse::reset();
}
void Minecraft::tickMouse()
@@ -844,9 +896,15 @@ void Minecraft::tick()
}
if (m_pScreen)
+ {
+ m_pScreen->validate(this);
m_pScreen->tick();
+ }
Multitouch::reset();
+
+ // Actually pause the game, because fuck bedrock edition
+ m_bIsGamePaused = (!isOnline() || (m_pLevel && m_pLevel->m_players.size() == 1)) && (m_pScreen && m_pScreen->isPauseScreen());
}
}
@@ -1001,13 +1059,12 @@ void Minecraft::prepareLevel(const std::string& unused)
void Minecraft::sizeUpdate(int newWidth, int newHeight)
{
// re-calculate the GUI scale.
- Gui::GuiScale = getBestScaleForThisScreenSize(newWidth, newHeight) / getRenderScaleMultiplier();
+ Gui::GuiScale = getBestScaleForThisScreenSize(newWidth, newHeight) / getRenderScaleMultiplier();
// The ceil gives an extra pixel to the screen's width and height, in case the GUI scale doesn't
// divide evenly into width or height, so that none of the game screen is uncovered.
+ Gui::GuiWidth = ceilf(Minecraft::width * Gui::GuiScale);
Gui::GuiHeight = ceilf(Minecraft::height * Gui::GuiScale);
- Gui::GuiScale = float(Gui::GuiHeight) / height;
- Gui::GuiWidth = ceilf(Minecraft::width * Gui::GuiScale);
if (m_pScreen)
m_pScreen->setSize(
@@ -1038,20 +1095,14 @@ float Minecraft::getBestScaleForThisScreenSize(int width, int height)
else if (m_pOptions->getUiTheme() == UI_CONSOLE)
return Screen::GetConsoleScale(height);
-#if MC_PLATFORM_XBOX
-#define USE_JAVA_SCREEN_SCALING
-#endif
-#ifdef USE_JAVA_SCREEN_SCALING
- // @HACK: the scaling code for Java/Pocket Screens when using the Console theme is pretty broken
- if (m_pOptions->getUiTheme() != UI_CONSOLE)
+ if (getUiTheme() == UI_JAVA)
{
int scale;
for (scale = 1; width / (scale + 1) >= 320 && height / (scale + 1) >= 240; ++scale)
{
}
- return scale;
+ return 1.0f / scale;
}
-#endif
if (height > 1800)
return 1.0f / 8.0f;
@@ -1153,11 +1204,6 @@ bool Minecraft::pauseGame()
{
if (isGamePaused() || m_pScreen) return false;
- if (!isOnline() || m_pLevel->m_players.size() == 1)
- {
- // Actually pause the game, because fuck bedrock edition
- m_bIsGamePaused = true;
- }
m_pLevel->savePlayerData();
getScreenChooser()->pushPauseScreen();
diff --git a/source/client/app/NinecraftApp.cpp b/source/client/app/NinecraftApp.cpp
index 1c7bd839c..f0c610914 100644
--- a/source/client/app/NinecraftApp.cpp
+++ b/source/client/app/NinecraftApp.cpp
@@ -102,7 +102,13 @@ void NinecraftApp::_initRenderMaterials()
void NinecraftApp::_initInput()
{
m_bIsTouchscreen = platform()->isTouchscreen();
- getOptions()->m_bUseController.set(platform()->hasGamepad());
+
+ //If someone has a gamepad connected, certainly they want to use it
+ if (platform()->hasGamepad())
+ IInputHolder::activeType = IInputHolder::CONTROLLER;
+ else if (platform()->isTouchscreen())
+ IInputHolder::activeType = IInputHolder::TOUCHSCREEN;
+
getOptions()->loadControls();
_reloadInput();
}
@@ -365,13 +371,10 @@ void NinecraftApp::update()
Multitouch::commit();
- if (getOptions()->m_bUseController.get())
+ GameControllerHandler* pControllerHandler = platform()->getGameControllerHandler();
+ if (pControllerHandler)
{
- GameControllerHandler* pControllerHandler = platform()->getGameControllerHandler();
- if (pControllerHandler)
- {
- pControllerHandler->refresh();
- }
+ pControllerHandler->refresh();
}
Minecraft::update();
diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp
index 38ccbf65c..944f4b1bf 100644
--- a/source/client/gui/Gui.cpp
+++ b/source/client/gui/Gui.cpp
@@ -366,11 +366,11 @@ void Gui::handleScrollWheel(bool down)
m_pMinecraft->m_pLocalPlayer->m_pInventory->selectSlot(slot);
}
-void Gui::handleKeyPressed(int keyCode)
+void Gui::handleControlPressed(const ControlBind& bind)
{
Options* options = m_pMinecraft->getOptions();
- if (options->isKey(KM_INVENTORY, keyCode))
+ if (options->isControl(KM_INVENTORY, bind))
{
if (m_pMinecraft->m_pGameMode->isSurvivalType())
m_pMinecraft->setScreen(new InventoryScreen(m_pMinecraft->m_pLocalPlayer));
@@ -379,8 +379,8 @@ void Gui::handleKeyPressed(int keyCode)
return;
}
- bool slotL = options->isKey(KM_SLOT_L, keyCode);
- bool slotR = options->isKey(KM_SLOT_R, keyCode);
+ bool slotL = options->isControl(KM_SLOT_L, bind);
+ bool slotR = options->isControl(KM_SLOT_R, bind);
if (slotL || slotR)
{
int maxItems = getNumSlots() - 1;
@@ -405,10 +405,10 @@ void Gui::handleKeyPressed(int keyCode)
return;
}
- if (options->isKey(KM_CHAT, keyCode) || options->isKey(KM_CHAT_CMD, keyCode))
+ if (options->isControl(KM_CHAT, bind) || options->isControl(KM_CHAT_CMD, bind))
{
if (!m_pMinecraft->m_pScreen)
- m_pMinecraft->setScreen(new ChatScreen(m_pMinecraft->getOptions()->isKey(KM_CHAT_CMD, keyCode)));
+ m_pMinecraft->setScreen(new ChatScreen(m_pMinecraft->getOptions()->isControl(KM_CHAT_CMD, bind)));
}
}
diff --git a/source/client/gui/Gui.hpp b/source/client/gui/Gui.hpp
index 9957d2f65..8d6167b34 100644
--- a/source/client/gui/Gui.hpp
+++ b/source/client/gui/Gui.hpp
@@ -65,7 +65,7 @@ class Gui : public GuiComponent
bool isInside(int mx, int my);
void handleClick(int id, int mx, int my);
void handleScrollWheel(bool down);
- void handleKeyPressed(int keyCode);
+ void handleControlPressed(const ControlBind&);
void renderMessages(bool bShowAll);
void renderHearts(bool topLeft);
void renderArmor(bool topLeft);
diff --git a/source/client/gui/GuiElement.cpp b/source/client/gui/GuiElement.cpp
index 2ddae5136..67e2a20fd 100644
--- a/source/client/gui/GuiElement.cpp
+++ b/source/client/gui/GuiElement.cpp
@@ -63,7 +63,7 @@ bool GuiElement::areaNavigation(Minecraft* pMinecraft, AreaNavigation::Direction
return false;
}
-void GuiElement::handleButtonPress(Minecraft* pMinecraft, int key)
+void GuiElement::handleControlPress(Minecraft* pMinecraft, const ControlBind& key)
{
}
diff --git a/source/client/gui/GuiElement.hpp b/source/client/gui/GuiElement.hpp
index 8ac2bc45c..95072c66c 100644
--- a/source/client/gui/GuiElement.hpp
+++ b/source/client/gui/GuiElement.hpp
@@ -42,7 +42,7 @@ class GuiElement : public GuiComponent
virtual bool pointerPressed(Minecraft* pMinecraft, const MenuPointer& pointer);
virtual bool pointerReleased(Minecraft* pMinecraft, const MenuPointer& pointer);
virtual bool areaNavigation(Minecraft* pMinecraft, AreaNavigation::Direction);
- virtual void handleButtonPress(Minecraft* pMinecraft, int key);
+ virtual void handleControlPress(Minecraft* pMinecraft, const ControlBind& key);
virtual void handleTextChar(Minecraft* pMinecraft, int chr);
virtual void handleClipboardPaste(const std::string& content);
virtual void handleScroll(float force);
diff --git a/source/client/gui/Screen.cpp b/source/client/gui/Screen.cpp
index 5c029da2b..6611bbab2 100644
--- a/source/client/gui/Screen.cpp
+++ b/source/client/gui/Screen.cpp
@@ -47,7 +47,9 @@ Screen::Screen()
m_bRenderPointer = false;
m_lastTimeMoved = 0;
m_cursorTick = 0;
- m_uiTheme = UI_GENERIC;
+ m_themeSelection = UI_GENERIC;
+ m_uiTheme = UI_POCKET;
+ m_bUniversalUiTheme = false;
}
Screen::~Screen()
@@ -56,7 +58,7 @@ Screen::~Screen()
m_elements.clear();
}
-void Screen::controllerEvent(GameController::StickID stickID, double deltaTime)
+void Screen::controllerStickEvent(GameController::StickID stickID, double deltaTime)
{
// @TODO: this probably shouldn't be here
GameController::StickEvent event;
@@ -139,10 +141,10 @@ void Screen::init(Minecraft* pMinecraft, int width, int height)
m_pFont = pMinecraft->m_pFont;
// Apply UI theme to current Screen based on user preference
- UITheme userTheme = m_pMinecraft->getOptions()->getUiTheme();
+ UITheme userTheme = pMinecraft->getOptions()->getUiTheme();
// We don't bother applying the console theme automatically for generic screens because this completely fucks scaling
- if (m_uiTheme == UI_UNIVERSAL || (m_uiTheme == UI_GENERIC && userTheme != UI_CONSOLE))
- m_uiTheme = m_pMinecraft->getOptions()->getUiTheme();
+ if (m_themeSelection == UI_UNIVERSAL || (m_themeSelection == UI_GENERIC && userTheme != UI_CONSOLE))
+ m_uiTheme = userTheme;
setSize(width, height);
initMenuPointer();
@@ -150,44 +152,44 @@ void Screen::init(Minecraft* pMinecraft, int width, int height)
m_bLastPointerPressedState = false;
}
-void Screen::keyPressed(int key)
+void Screen::controlPressed(const ControlBind& bind)
{
Options& options = *m_pMinecraft->getOptions();
GuiElement* element = _getSelectedElement();
- if (options.isKey(KM_MENU_CANCEL, key))
+ if (options.isControl(KM_MENU_CANCEL, bind))
{
m_pMinecraft->handleBack(false);
}
- if (m_pMinecraft->getOptions()->isKey(KM_MENU_TAB_LEFT, key))
+ if (options.isControl(KM_MENU_TAB_LEFT, bind))
{
prevTab();
}
- if (m_pMinecraft->getOptions()->isKey(KM_MENU_TAB_RIGHT, key))
+ if (options.isControl(KM_MENU_TAB_RIGHT, bind))
{
nextTab();
}
if (doElementTabbing())
{
- if (options.isKey(KM_MENU_DOWN, key))
+ if (options.isControl(KM_MENU_DOWN, bind))
{
_areaNavigation(AreaNavigation::DOWN);
}
- else if (options.isKey(KM_MENU_UP, key))
+ else if (options.isControl(KM_MENU_UP, bind))
{
_areaNavigation(AreaNavigation::UP);
}
- else if (options.isKey(KM_MENU_RIGHT, key))
+ else if (options.isControl(KM_MENU_RIGHT, bind))
{
_areaNavigation(AreaNavigation::RIGHT);
}
- else if (options.isKey(KM_MENU_LEFT, key))
+ else if (options.isControl(KM_MENU_LEFT, bind))
{
_areaNavigation(AreaNavigation::LEFT);
}
- else if (options.isKey(KM_MENU_OK, key))
+ else if (options.isControl(KM_MENU_OK, bind))
{
if (element && element->isEnabled())
{
@@ -204,7 +206,7 @@ void Screen::keyPressed(int key)
if (element && element->isEnabled())
{
- element->handleButtonPress(m_pMinecraft, key);
+ element->handleControlPress(m_pMinecraft, bind);
}
}
@@ -255,6 +257,11 @@ void Screen::handleKeyboardClosed()
}
}
+bool Screen::validate(Minecraft*)
+{
+ return true;
+}
+
static const char* g_panoramaList[] =
{
"gui/background/panorama_0.png",
@@ -530,11 +537,14 @@ void Screen::selectElement(GuiElement* element)
bool Screen::_areaNavigation(AreaNavigation::Direction dir)
{
- if (!m_pSelectedElement) return false;
+ if (m_pSelectedElement && m_pSelectedElement->areaNavigation(m_pMinecraft, dir)) return true;
- if (m_pSelectedElement->areaNavigation(m_pMinecraft, dir)) return true;
-
- if (selectElementById(Navigation(this).navigateCyclic(dir, m_pSelectedElement->m_xPos + m_pSelectedElement->m_width / 2, m_pSelectedElement->m_yPos + m_pSelectedElement->m_height / 2)))
+ if ((m_pSelectedElement && selectElementById(Navigation(this).navigateCyclic(dir,
+ m_pSelectedElement->m_xPos + m_pSelectedElement->m_width / 2,
+ m_pSelectedElement->m_yPos + m_pSelectedElement->m_height / 2))) ||
+ (!m_pSelectedElement && selectElementById(Navigation(this).navigate(dir,
+ m_width / 2,
+ m_height / 2, true))))
{
_playSelectSound();
return true;
@@ -723,7 +733,14 @@ void Screen::updateEvents()
if (_useController())
{
checkForPointerEvent(MOUSE_BUTTON_LEFT);
- controllerEvent();
+
+ while(GameControllerManager::next())
+ controllerEvent();
+
+ _processControllerDirection(1);
+ _processControllerDirection(2);
+
+ controllerStickEvent(2);
}
}
@@ -758,15 +775,26 @@ void Screen::keyboardEvent()
}
if (Keyboard::getEventKeyState())
- keyPressed(Keyboard::getEventKey());
+ controlPressed(ControlBind(Keyboard::getEventKey(), GameController::BUTTON_NONE));
}
void Screen::controllerEvent()
{
- _processControllerDirection(1);
- _processControllerDirection(2);
+ // Ugly hack x2
+ if (!doElementTabbing())
+ {
+ if (GameControllerManager::getEventButtonState() && m_pMinecraft->getOptions()->getControl(KM_MENU_OK).isButton(GameControllerManager::getEventButton()))
+ {
+ m_menuPointer.isPressed = true;
+ }
+ else
+ {
+ m_menuPointer.isPressed = false;
+ }
+ }
- controllerEvent(2);
+ if (GameControllerManager::getEventButtonState())
+ controlPressed(ControlBind(-1, GameControllerManager::getEventButton()));
}
void Screen::checkForPointerEvent(MouseButtonType button)
diff --git a/source/client/gui/Screen.hpp b/source/client/gui/Screen.hpp
index a936e10ed..316d2d59b 100644
--- a/source/client/gui/Screen.hpp
+++ b/source/client/gui/Screen.hpp
@@ -76,7 +76,7 @@ class Screen : public GuiComponent
int getYOffset();
unsigned int getCursorMoveThrottle() const { return 65; }
bool doElementTabbing() const;
- void controllerEvent(GameController::StickID stickId, double deltaTime = 0.0);
+ void controllerStickEvent(GameController::StickID stickId, double deltaTime = 0.0);
protected:
virtual bool _areaNavigation(AreaNavigation::Direction);
@@ -117,13 +117,14 @@ class Screen : public GuiComponent
virtual void onTextBoxUpdated(int id) {};
virtual void pointerPressed(const MenuPointer& pointer, MouseButtonType btn);
virtual void pointerReleased(const MenuPointer& pointer, MouseButtonType btn);
- virtual void keyPressed(int);
+ virtual void controlPressed(const ControlBind&);
virtual void handleTextChar(char);
virtual void keyboardTextPaste(const std::string& text);
virtual float getScale(int width, int height);
static float GetConsoleScale(int height);
virtual void setTextboxText(const std::string& text);
virtual void handleKeyboardClosed();
+ virtual bool validate(Minecraft*);
// ported from 0.8
virtual void renderMenuBackground(float f);
@@ -152,16 +153,25 @@ class Screen : public GuiComponent
Screen* m_pScreen;
};
+ enum ThemeSelection
+ {
+ UI_SPECIFIC, // The Screen handles a specific UI Theme
+ UI_GENERIC, // The Screen is a Java / Pocket mix
+ UI_UNIVERSAL // The Screen automatically handles all UI themes
+ };
+
int m_width;
int m_height;
bool m_bPassEvents;
//@NOTE: This should be enabled only if the the actual screen handles the deletion of the previous screen, otherwise, there will be a memory leak!
bool m_bDeletePrevious;
+ bool m_bUniversalUiTheme;
Minecraft* m_pMinecraft;
GuiElementList m_elements;
GuiElement* m_pSelectedElement;
Font* m_pFont;
GuiElement* m_pClickedElement;
+ ThemeSelection m_themeSelection;
UITheme m_uiTheme;
#ifndef ORIGINAL_CODE
diff --git a/source/client/gui/ScreenChooser.cpp b/source/client/gui/ScreenChooser.cpp
index d2620083f..f48be2e22 100644
--- a/source/client/gui/ScreenChooser.cpp
+++ b/source/client/gui/ScreenChooser.cpp
@@ -6,7 +6,6 @@
#include "screens/inventory/CraftingScreen.hpp"
#include "screens/inventory/ChestScreen.hpp"
#include "screens/OptionsScreen.hpp"
-#include "screens/OptionsScreen_Console.hpp"
#include "screens/CreateWorldScreen.hpp"
#include "screens/ProgressScreen.hpp"
#include "screens/CreditsScreen.hpp"
diff --git a/source/client/gui/VerticalLayout.cpp b/source/client/gui/VerticalLayout.cpp
index b85fc8847..d5e4795e1 100644
--- a/source/client/gui/VerticalLayout.cpp
+++ b/source/client/gui/VerticalLayout.cpp
@@ -26,6 +26,11 @@ GuiElement* VerticalLayout::getElement(ID index) const
return nullptr;
}
+bool VerticalLayout::isLastIn(AreaNavigation::Direction dir)
+{
+ return m_pSelectedElement && Navigation(this).navigate(dir, m_pSelectedElement->m_xPos + m_pSelectedElement->m_width / 2, m_pSelectedElement->m_yPos + m_pSelectedElement->m_height / 2) < 0;
+}
+
bool VerticalLayout::selectElementById(ID id, bool sound)
{
GuiElement* element = getElement(id);
@@ -99,7 +104,7 @@ void VerticalLayout::organize()
}
if (isSelected() && !m_pSelectedElement && m_pScreen->_useController())
- selectElementById(0, false);
+ startNavigation();
}
void VerticalLayout::clear()
@@ -115,18 +120,24 @@ void VerticalLayout::clear()
}
}
+void VerticalLayout::startNavigation()
+{
+ AreaNavigation::ID id = Navigation(this).navigate(AreaNavigation::DOWN, m_pScreen->m_width / 2, 0);
+ if (id >= 0)
+ selectElementById(m_scrollAmount + id);
+}
+
bool VerticalLayout::areaNavigation(Minecraft* mc, AreaNavigation::Direction dir)
{
if (m_pSelectedElement && m_pSelectedElement->areaNavigation(mc, dir)) return true;
if (dir == AreaNavigation::DOWN)
{
- GuiElement* element = m_pSelectedElement;
- if (element && isBottomElement(*element))
+ if (isLastIn(dir))
{
- if (m_bCyclic && !m_bCanScrollDown && m_scrollAmount > 0)
+ if (m_bCyclic && !m_bCanScrollDown)
{
- int x = element->m_xPos + element->m_width / 2;
+ int x = m_pSelectedElement->m_xPos + m_pSelectedElement->m_width / 2;
updateScroll(0);
AreaNavigation::ID id = Navigation(this).navigate(dir, x, 0, true);
if (id >= 0)
@@ -134,21 +145,28 @@ bool VerticalLayout::areaNavigation(Minecraft* mc, AreaNavigation::Direction dir
return true;
}
- handleScroll(false);
- areaNavigation(dir, element == getElement(ID(m_elements.size() - 1)));
- return true;
+ if (m_bCanScrollDown)
+ {
+ GuiElement* oldElement = m_pSelectedElement;
+ while (oldElement == m_pSelectedElement)
+ {
+ handleScroll(false);
+ areaNavigation(dir, false);
+ }
+
+ return true;
+ }
}
areaNavigation(dir);
return true;
}
else if (dir == AreaNavigation::UP)
{
- GuiElement* element = m_pSelectedElement;
- if (element && isTopElement(*element))
+ if (isLastIn(dir))
{
if (m_bCyclic && !m_scrollAmount)
{
- int x = element->m_xPos + element->m_width / 2;
+ int x = m_pSelectedElement->m_xPos + m_pSelectedElement->m_width / 2;
while (m_bCanScrollDown)
{
updateScroll(m_scrollAmount + 1);
@@ -189,7 +207,7 @@ void VerticalLayout::setSelected(bool b)
GuiElement::setSelected(b);
if (b && !m_pSelectedElement && m_pScreen->_useController())
- selectElementById(0, false);
+ startNavigation();
if (!b)
selectElement(nullptr);
@@ -284,5 +302,5 @@ bool VerticalLayout::Navigation::next(int& x, int& y, bool cycle)
bool VerticalLayout::Navigation::isValid(ID id)
{
- return m_pLayout->m_pSelectedElement->getId() != (m_pLayout->m_scrollAmount + id);
+ return !m_pLayout->m_pSelectedElement || m_pLayout->m_pSelectedElement->getId() != (m_pLayout->m_scrollAmount + id);
}
\ No newline at end of file
diff --git a/source/client/gui/VerticalLayout.hpp b/source/client/gui/VerticalLayout.hpp
index d3dd64699..78d0673b5 100644
--- a/source/client/gui/VerticalLayout.hpp
+++ b/source/client/gui/VerticalLayout.hpp
@@ -12,6 +12,7 @@ class VerticalLayout : public GuiElement
~VerticalLayout();
GuiElement* getElement(ID) const;
+ bool isLastIn(AreaNavigation::Direction dir);
bool isTopElement(GuiElement& element) const { return element.m_yPos == m_yPos; };
bool isBottomElement(GuiElement& element) const { return element.m_yPos == m_bottom; };
bool selectElementById(ID, bool sound = true);
@@ -21,6 +22,7 @@ class VerticalLayout : public GuiElement
void organize();
void clear();
+ void startNavigation();
bool areaNavigation(Minecraft*, AreaNavigation::Direction) override;
void areaNavigation(AreaNavigation::Direction, bool cyclic = false);
void setSelected(bool);
diff --git a/source/client/gui/components/OptionList.cpp b/source/client/gui/components/OptionList.cpp
index 062f32f5e..fdbcfeebd 100644
--- a/source/client/gui/components/OptionList.cpp
+++ b/source/client/gui/components/OptionList.cpp
@@ -173,7 +173,8 @@ void OptionList::initControlsMenu()
if (!m_pMinecraft->isTouchscreen())
m_items[idxSplit]->setEnabled(false);
- m_items[idxController]->setEnabled(false);
+ if (!m_pMinecraft->platform()->hasGamepad())
+ m_items[idxController]->setEnabled(false);
}
void OptionList::initVideoMenu()
diff --git a/source/client/gui/components/TextBox.cpp b/source/client/gui/components/TextBox.cpp
index f18371498..2351c501f 100644
--- a/source/client/gui/components/TextBox.cpp
+++ b/source/client/gui/components/TextBox.cpp
@@ -205,26 +205,26 @@ char TextBox::guessCharFromKey(int key) {
#endif
-void TextBox::handleButtonPress(Minecraft* pMinecraft, int key)
+void TextBox::handleControlPress(Minecraft* pMinecraft, const ControlBind& bind)
{
Options& options = *pMinecraft->getOptions();
if (!hasFocus())
{
- if (options.isKey(KM_MENU_OK, key))
+ if (options.isControl(KM_MENU_OK, bind))
setFocused(true);
return;
}
#ifndef HANDLE_CHARS_SEPARATELY
- char guess = guessCharFromKey(key);
+ char guess = guessCharFromKey(bind.keyId);
if (guess != '\0') {
handleTextChar(guess);
return;
}
#endif
- switch (key) {
+ switch (bind.keyId) {
case AKEYCODE_DEL:
{
// handled elsewhere, do not dupe
diff --git a/source/client/gui/components/TextBox.hpp b/source/client/gui/components/TextBox.hpp
index 59c02b0b1..ae2de1eec 100644
--- a/source/client/gui/components/TextBox.hpp
+++ b/source/client/gui/components/TextBox.hpp
@@ -40,7 +40,7 @@ class TextBox : public GuiElement
public:
void init(Font* pFont);
bool pointerPressed(Minecraft* pMinecraft, const MenuPointer& pointer) override;
- void handleButtonPress(Minecraft* pMinecraft, int key) override;
+ void handleControlPress(Minecraft* pMinecraft, const ControlBind&) override;
void handleTextChar(Minecraft* pMinecraft, int chr) override;
void handleClipboardPaste(const std::string& text) override;
void render(Minecraft* pMinecraft, const MenuPointer& pointer) override;
diff --git a/source/client/gui/components/TickBox.cpp b/source/client/gui/components/TickBox.cpp
index 2bce1cf86..a4451515d 100644
--- a/source/client/gui/components/TickBox.cpp
+++ b/source/client/gui/components/TickBox.cpp
@@ -48,11 +48,9 @@ void TickBox::render(Minecraft* mc, const MenuPointer& pointer)
if (!mc->m_pScreen->doElementTabbing())
setSelected(isHovered(mc, pointer));
- if (!isEnabled())
- currentShaderColor.a *= 0.5f;
-
Color unselectedColor = Color::TEXT_GREY;
- unselectedColor.a = currentShaderColor.a;
+ if (!isEnabled())
+ unselectedColor.a = 0.5f;
mc->m_pFont->drawScalable(
getMessage(),
m_xPos + C_TICKBOX_SIZE + 5,
@@ -64,7 +62,10 @@ void TickBox::render(Minecraft* mc, const MenuPointer& pointer)
getMessage(),
m_xPos + C_TICKBOX_SIZE + 4,
m_yPos + m_height / 2 - 9,
- Color(204, 196, 13, currentShaderColor.a));
+ Color(204, 196, 13, unselectedColor.a));
+
+ if (!isEnabled())
+ currentShaderColor.a *= 0.5f;
blitSprite(*mc->m_pTextures, isSelected() ? "gui/console/Graphics/Tickbox_Over.png" : "gui/console/Graphics/Tickbox_Norm.png", m_xPos, m_yPos + (m_height - C_TICKBOX_SIZE) / 2, C_TICKBOX_SIZE, C_TICKBOX_SIZE, &m_materials.ui_textured_and_glcolor);
diff --git a/source/client/gui/screens/ChatScreen.cpp b/source/client/gui/screens/ChatScreen.cpp
index 748b0aeac..042775d3e 100644
--- a/source/client/gui/screens/ChatScreen.cpp
+++ b/source/client/gui/screens/ChatScreen.cpp
@@ -58,15 +58,15 @@ void ChatScreen::render(float f)
Screen::render(f);
}
-void ChatScreen::keyPressed(int keyCode)
+void ChatScreen::controlPressed(const ControlBind& bind)
{
if (!_useController())
{
- if (m_pMinecraft->getOptions()->isKey(KM_MENU_OK, keyCode))
+ if (m_pMinecraft->getOptions()->isControl(KM_MENU_OK, bind))
sendMessageAndExit();
}
- Screen::keyPressed(keyCode);
+ Screen::controlPressed(bind);
}
void ChatScreen::handleKeyboardClosed()
@@ -77,6 +77,11 @@ void ChatScreen::handleKeyboardClosed()
Screen::handleKeyboardClosed();
}
+bool ChatScreen::isPauseScreen()
+{
+ return false;
+}
+
void ChatScreen::sendMessageAndExit()
{
m_pMinecraft->sendMessage(m_textChat.getText());
diff --git a/source/client/gui/screens/ChatScreen.hpp b/source/client/gui/screens/ChatScreen.hpp
index 2be599ab8..df2f8e56d 100644
--- a/source/client/gui/screens/ChatScreen.hpp
+++ b/source/client/gui/screens/ChatScreen.hpp
@@ -24,8 +24,9 @@ class ChatScreen : public Screen
void init() override;
void removed() override;
void render(float f) override;
- void keyPressed(int keyCode) override;
+ void controlPressed(const ControlBind& bind) override;
void handleKeyboardClosed() override;
+ bool isPauseScreen() override;
void sendMessageAndExit();
diff --git a/source/client/gui/screens/CreditsScreen.cpp b/source/client/gui/screens/CreditsScreen.cpp
index b5bfb604d..a3afde9ea 100644
--- a/source/client/gui/screens/CreditsScreen.cpp
+++ b/source/client/gui/screens/CreditsScreen.cpp
@@ -53,9 +53,9 @@ bool CreditsScreen::isInGameScreen()
return true;
}
-void CreditsScreen::keyPressed(int code)
+void CreditsScreen::controlPressed(const ControlBind& bind)
{
- Screen::keyPressed(code);
+ Screen::controlPressed(bind);
}
void CreditsScreen::tick()
diff --git a/source/client/gui/screens/CreditsScreen.hpp b/source/client/gui/screens/CreditsScreen.hpp
index 27185894e..e922449fc 100644
--- a/source/client/gui/screens/CreditsScreen.hpp
+++ b/source/client/gui/screens/CreditsScreen.hpp
@@ -15,7 +15,7 @@ class CreditsScreen : public Screen
public:
void init() override;
bool isInGameScreen() override;
- void keyPressed(int code) override;
+ void controlPressed(const ControlBind&) override;
void tick() override;
void render(float f) override;
bool handleBackEvent(bool b) override;
diff --git a/source/client/gui/screens/IngameBlockSelectionScreen.cpp b/source/client/gui/screens/IngameBlockSelectionScreen.cpp
index 1875b5ba9..27e7124ae 100644
--- a/source/client/gui/screens/IngameBlockSelectionScreen.cpp
+++ b/source/client/gui/screens/IngameBlockSelectionScreen.cpp
@@ -337,18 +337,23 @@ void IngameBlockSelectionScreen::removed()
m_pMinecraft->m_pGui->inventoryUpdated();
}
-void IngameBlockSelectionScreen::keyPressed(int keyCode)
+void IngameBlockSelectionScreen::controlPressed(const ControlBind& bind)
{
- if (!_useController() && m_pMinecraft->getOptions()->isKey(KM_INVENTORY, keyCode))
+ if (!_useController() && m_pMinecraft->getOptions()->isControl(KM_INVENTORY, bind))
{
m_pMinecraft->handleBack(false);
}
else
{
- Screen::keyPressed(keyCode);
+ Screen::controlPressed(bind);
}
}
+bool IngameBlockSelectionScreen::isPauseScreen()
+{
+ return false;
+}
+
void IngameBlockSelectionScreen::selectSlotAndClose()
{
Inventory* pInv = getInventory();
diff --git a/source/client/gui/screens/IngameBlockSelectionScreen.hpp b/source/client/gui/screens/IngameBlockSelectionScreen.hpp
index 097af0f64..45b14dcbc 100644
--- a/source/client/gui/screens/IngameBlockSelectionScreen.hpp
+++ b/source/client/gui/screens/IngameBlockSelectionScreen.hpp
@@ -40,7 +40,8 @@ class IngameBlockSelectionScreen : public Screen
void pointerPressed(const MenuPointer& pointer, MouseButtonType btn) override;
void pointerReleased(const MenuPointer& pointer, MouseButtonType btn) override;
void removed() override;
- void keyPressed(int key) override;
+ void controlPressed(const ControlBind&) override;
+ bool isPauseScreen() override;
private:
SlotID m_selectedSlot;
diff --git a/source/client/gui/screens/OptionsScreen_Console.cpp b/source/client/gui/screens/OptionsScreen_Console.cpp
index 934283210..b829f07e4 100644
--- a/source/client/gui/screens/OptionsScreen_Console.cpp
+++ b/source/client/gui/screens/OptionsScreen_Console.cpp
@@ -35,7 +35,7 @@ void OptionsScreen_Console::_buttonClicked(Button* btn)
void OptionsScreen_Console::init()
{
- Button* layoutButtons[] = {&m_btnHowToPlay, &m_btnControls, &m_btnSettings, &m_btnCredits, &m_btnResetToDefaults};
+ Button* layoutButtons[] = { &m_btnHowToPlay, &m_btnControls, &m_btnSettings, &m_btnCredits, &m_btnResetToDefaults };
int buttonsWidth = 450;
int buttonsHeight = 40;
@@ -70,6 +70,16 @@ bool OptionsScreen_Console::handleBackEvent(bool b)
return true;
}
+bool OptionsScreen_Console::validate(Minecraft* mc)
+{
+ if (mc->getOptions()->getUiTheme() != UI_CONSOLE)
+ {
+ mc->getScreenChooser()->pushOptionsScreen(m_pParent);
+ return false;
+ }
+ return true;
+}
+
#define HEADER(text) do { m_layout.m_elements.push_back(new OptionHeader_Console(text)); currentIndex++; } while (0)
#define OPTION(name) do { options.name.addGuiElement(m_layout.m_elements, m_uiTheme); currentIndex++; } while (0)
@@ -134,6 +144,7 @@ OptionHeader_Console::OptionHeader_Console(const std::string& text)
: m_text(text)
{
m_height = 22;
+ setNavigable(false);
}
void OptionHeader_Console::render(Minecraft* pMinecraft, const MenuPointer& pointer)
diff --git a/source/client/gui/screens/OptionsScreen_Console.hpp b/source/client/gui/screens/OptionsScreen_Console.hpp
index 3a7a3cbe7..52f4db0ee 100644
--- a/source/client/gui/screens/OptionsScreen_Console.hpp
+++ b/source/client/gui/screens/OptionsScreen_Console.hpp
@@ -32,6 +32,7 @@ class OptionsScreen_Console : public Screen
void init() override;
void render(float) override;
bool handleBackEvent(bool) override;
+ bool validate(Minecraft*) override;
private:
Screen* m_pParent;
diff --git a/source/client/gui/screens/PanelScreen_Console.cpp b/source/client/gui/screens/PanelScreen_Console.cpp
index d70b231be..6be5760fc 100644
--- a/source/client/gui/screens/PanelScreen_Console.cpp
+++ b/source/client/gui/screens/PanelScreen_Console.cpp
@@ -6,6 +6,7 @@ PanelScreen_Console::PanelScreen_Console(Screen* parent) :
m_pParent(parent)
, m_layout(this)
{
+ m_themeSelection = UI_SPECIFIC;
m_uiTheme = UI_CONSOLE;
m_bDeletePrevious = false;
}
diff --git a/source/client/gui/screens/PauseScreen.cpp b/source/client/gui/screens/PauseScreen.cpp
index 0700e676c..440ea537f 100644
--- a/source/client/gui/screens/PauseScreen.cpp
+++ b/source/client/gui/screens/PauseScreen.cpp
@@ -119,3 +119,13 @@ void PauseScreen::_buttonClicked(Button* pButton)
}
#endif
}
+
+bool PauseScreen::validate(Minecraft* mc)
+{
+ if (mc->getOptions()->getUiTheme() == UI_CONSOLE)
+ {
+ mc->getScreenChooser()->pushPauseScreen();
+ return false;
+ }
+ return true;
+}
diff --git a/source/client/gui/screens/PauseScreen.hpp b/source/client/gui/screens/PauseScreen.hpp
index 80a94bee6..8c69621a8 100644
--- a/source/client/gui/screens/PauseScreen.hpp
+++ b/source/client/gui/screens/PauseScreen.hpp
@@ -15,10 +15,11 @@ class PauseScreen : public Screen
{
public:
PauseScreen();
- virtual void init() override;
- virtual void tick() override;
- virtual void render(float f) override;
- virtual void _buttonClicked(Button*) override;
+ void init() override;
+ void tick() override;
+ void render(float f) override;
+ void _buttonClicked(Button*) override;
+ bool validate(Minecraft*) override;
void updateServerVisibilityText();
diff --git a/source/client/gui/screens/PauseScreen_Console.cpp b/source/client/gui/screens/PauseScreen_Console.cpp
index 9c20d057d..2e5380c1c 100644
--- a/source/client/gui/screens/PauseScreen_Console.cpp
+++ b/source/client/gui/screens/PauseScreen_Console.cpp
@@ -14,6 +14,7 @@ PauseScreen_Console::PauseScreen_Console() :
m_btnLeaderboards.setEnabled(false);
m_btnAchievements.setEnabled(false);
+ m_themeSelection = UI_SPECIFIC;
m_uiTheme = UI_CONSOLE;
}
@@ -54,4 +55,14 @@ void PauseScreen_Console::_buttonClicked(Button* btn)
m_pMinecraft->m_pLevel->saveGame(); // Minecraft auto-saves automatically when we hit the pause screen
else if (btn->getId() == m_btnExitGame.getId())
m_pMinecraft->leaveGame(false);
-}
\ No newline at end of file
+}
+
+bool PauseScreen_Console::validate(Minecraft* mc)
+{
+ if (mc->getOptions()->getUiTheme() != UI_CONSOLE)
+ {
+ mc->getScreenChooser()->pushPauseScreen();
+ return false;
+ }
+ return true;
+}
diff --git a/source/client/gui/screens/PauseScreen_Console.hpp b/source/client/gui/screens/PauseScreen_Console.hpp
index 018fef1e8..8243c5be9 100644
--- a/source/client/gui/screens/PauseScreen_Console.hpp
+++ b/source/client/gui/screens/PauseScreen_Console.hpp
@@ -10,6 +10,7 @@ class PauseScreen_Console : public Screen
void init() override;
void render(float) override;
void _buttonClicked(Button*) override;
+ bool validate(Minecraft*) override;
private:
Button m_btnResume;
diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp
index 18c54f512..daf86b280 100644
--- a/source/client/gui/screens/SelectWorldScreen.cpp
+++ b/source/client/gui/screens/SelectWorldScreen.cpp
@@ -76,23 +76,24 @@ bool SelectWorldScreen::isInGameScreen()
return true;
}
-void SelectWorldScreen::keyPressed(int code)
+void SelectWorldScreen::controlPressed(const ControlBind& bind)
{
+ Options& options = *m_pMinecraft->getOptions();
#ifndef ORIGINAL_CODE
- if (m_pMinecraft->getOptions()->getKey(KM_MENU_OK) == code)
+ if (options.isControl(KM_MENU_OK, bind))
m_pWorldSelectionList->selectItem(m_pWorldSelectionList->getItemAtPosition(m_width / 2, m_height / 2), false);
#endif
if (m_btnWorld.isSelected())
{
- if (m_pMinecraft->getOptions()->getKey(KM_LEFT) == code)
+ if (options.isControl(KM_LEFT, bind))
m_pWorldSelectionList->stepLeft();
- if (m_pMinecraft->getOptions()->getKey(KM_RIGHT) == code)
+ if (options.isControl(KM_RIGHT, bind))
m_pWorldSelectionList->stepRight();
}
- Screen::keyPressed(code);
+ Screen::controlPressed(bind);
}
static char g_SelectWorldFilterArray[] = { '/','\n','\r','\x09','\0','\xC','`','?','*','\\','<','>','|','"',':'};
diff --git a/source/client/gui/screens/SelectWorldScreen.hpp b/source/client/gui/screens/SelectWorldScreen.hpp
index 7d1937175..b0b722ffb 100644
--- a/source/client/gui/screens/SelectWorldScreen.hpp
+++ b/source/client/gui/screens/SelectWorldScreen.hpp
@@ -24,7 +24,7 @@ class SelectWorldScreen : public Screen
public:
void init() override;
bool isInGameScreen() override;
- void keyPressed(int code) override;
+ void controlPressed(const ControlBind&) override;
void tick() override;
void render(float f) override;
bool handleBackEvent(bool b) override;
diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp
index 4d2dc03ac..292a3ff9c 100644
--- a/source/client/gui/screens/StartMenuScreen.cpp
+++ b/source/client/gui/screens/StartMenuScreen.cpp
@@ -238,4 +238,14 @@ bool StartMenuScreen::handleBackEvent(bool b)
m_pMinecraft->quit();
}
return true;
-}
\ No newline at end of file
+}
+
+bool StartMenuScreen::validate(Minecraft* mc)
+{
+ if (mc->getOptions()->getUiTheme() == UI_CONSOLE)
+ {
+ mc->getScreenChooser()->pushStartScreen();
+ return false;
+ }
+ return true;
+}
diff --git a/source/client/gui/screens/StartMenuScreen.hpp b/source/client/gui/screens/StartMenuScreen.hpp
index f924d935f..9a44c74d3 100644
--- a/source/client/gui/screens/StartMenuScreen.hpp
+++ b/source/client/gui/screens/StartMenuScreen.hpp
@@ -33,6 +33,7 @@ class StartMenuScreen : public Screen
void drawSplash();
bool handleBackEvent(bool b) override;
+ bool validate(Minecraft*) override;
protected:
Button m_startButton;
diff --git a/source/client/gui/screens/StartMenuScreen_Console.cpp b/source/client/gui/screens/StartMenuScreen_Console.cpp
index f67c0e40d..ce84afc66 100644
--- a/source/client/gui/screens/StartMenuScreen_Console.cpp
+++ b/source/client/gui/screens/StartMenuScreen_Console.cpp
@@ -17,6 +17,7 @@ StartMenuScreen_Console::StartMenuScreen_Console() :
m_btnAchievements.setEnabled(false);
m_btnDownload.setEnabled(false);
+ m_themeSelection = UI_SPECIFIC;
m_uiTheme = UI_CONSOLE;
m_splash = SplashManager::singleton().getSplash();
@@ -72,4 +73,14 @@ void StartMenuScreen_Console::_buttonClicked(Button* btn)
m_pMinecraft->getScreenChooser()->pushOptionsScreen(this);
else if (btn->getId() == m_btnExitGame.getId())
m_pMinecraft->quit();
-}
\ No newline at end of file
+}
+
+bool StartMenuScreen_Console::validate(Minecraft* mc)
+{
+ if (mc->getOptions()->getUiTheme() != UI_CONSOLE)
+ {
+ mc->getScreenChooser()->pushStartScreen();
+ return false;
+ }
+ return true;
+}
diff --git a/source/client/gui/screens/StartMenuScreen_Console.hpp b/source/client/gui/screens/StartMenuScreen_Console.hpp
index 715122f1f..100472c68 100644
--- a/source/client/gui/screens/StartMenuScreen_Console.hpp
+++ b/source/client/gui/screens/StartMenuScreen_Console.hpp
@@ -10,6 +10,7 @@ class StartMenuScreen_Console : public Screen
void init() override;
void render(float) override;
void _buttonClicked(Button*) override;
+ bool validate(Minecraft*) override;
private:
Button m_btnPlayGame;
diff --git a/source/client/gui/screens/inventory/ContainerScreen.cpp b/source/client/gui/screens/inventory/ContainerScreen.cpp
index c751f60af..77cde805a 100644
--- a/source/client/gui/screens/inventory/ContainerScreen.cpp
+++ b/source/client/gui/screens/inventory/ContainerScreen.cpp
@@ -13,7 +13,7 @@ ContainerScreen::ContainerScreen(ContainerMenu* menu) :
m_topPos(0),
m_timeSlotDragged(0)
{
- m_uiTheme = UI_UNIVERSAL;
+ m_themeSelection = UI_UNIVERSAL;
m_bRenderPointer = true;
}
@@ -212,16 +212,17 @@ void ContainerScreen::render(float partialTicks)
if (!name.empty())
{
int w = m_pFont->width(name);
- int tx = m_menuPointer.x - m_leftPos + 12;
- int ty = m_menuPointer.y - m_topPos - 12;
if (m_uiTheme == UI_CONSOLE)
{
- blitNineSlice(*m_pMinecraft->m_pTextures, ScreenRenderer::POINTER_TEXT_PANEL_SLICES, tx - 6, ty - 6, w * 2 + 12, 28, 8);
- MatrixStack::Ref tooltipMatrix = MatrixStack::World.push();
- m_pFont->drawScalable(name, tx, ty, -1);
+ int tx = m_menuPointer.x - m_leftPos + 12;
+ int ty = m_menuPointer.y - m_topPos - 28;
+ blitNineSlice(*m_pMinecraft->m_pTextures, ScreenRenderer::POINTER_TEXT_PANEL_SLICES, tx - 6, ty - 10, w * 2 + 12, 33, 8);
+ m_pFont->drawScalableShadow(name, tx, ty, -1);
}
else
{
+ int tx = m_menuPointer.x - m_leftPos + 12;
+ int ty = m_menuPointer.y - m_topPos - 12;
fillGradient(tx - 3, ty - 3, tx + w + 3, ty + 8 + 3, 0xC0000000, 0xC0000000);
m_pFont->drawShadow(name, tx, ty, -1);
}
@@ -285,33 +286,34 @@ void ContainerScreen::slotClicked(const MenuPointer& pointer, MouseButtonType bu
slotClicked(pointer, button, m_pMinecraft->m_pPlatform->shiftPressed());
}
-void ContainerScreen::keyPressed(int keyCode)
+void ContainerScreen::controlPressed(const ControlBind& bind)
{
- if (!_useController() && m_pMinecraft->getOptions()->isKey(KM_INVENTORY, keyCode))
+ Options& options = *m_pMinecraft->getOptions();
+ if (!_useController() && options.isControl(KM_INVENTORY, bind))
{
m_pMinecraft->handleBack(false);
}
- else if (m_pMinecraft->getOptions()->isKey(KM_CONTAINER_QUICKMOVE, keyCode) && _useController())
+ else if (options.isControl(KM_CONTAINER_QUICKMOVE, bind) && _useController())
{
slotClicked(m_menuPointer, MOUSE_BUTTON_LEFT, true);
}
- else if (m_pMinecraft->getOptions()->isKey(KM_CONTAINER_SPLIT, keyCode) && _useController())
+ else if (options.isControl(KM_CONTAINER_SPLIT, bind) && _useController())
{
slotClicked(m_menuPointer, MOUSE_BUTTON_RIGHT, false);
}
else
{
if (_useController() &&
- ((m_pMinecraft->getOptions()->isKey(KM_MENU_UP, keyCode) && _selectSlotInDirection(AreaNavigation::UP)) ||
- (m_pMinecraft->getOptions()->isKey(KM_MENU_DOWN, keyCode) && _selectSlotInDirection(AreaNavigation::DOWN)) ||
- (m_pMinecraft->getOptions()->isKey(KM_MENU_RIGHT, keyCode) && _selectSlotInDirection(AreaNavigation::RIGHT)) ||
- (m_pMinecraft->getOptions()->isKey(KM_MENU_LEFT, keyCode) && _selectSlotInDirection(AreaNavigation::LEFT))))
+ ((options.isControl(KM_MENU_UP, bind) && _selectSlotInDirection(AreaNavigation::UP)) ||
+ (options.isControl(KM_MENU_DOWN, bind) && _selectSlotInDirection(AreaNavigation::DOWN)) ||
+ (options.isControl(KM_MENU_RIGHT, bind) && _selectSlotInDirection(AreaNavigation::RIGHT)) ||
+ (options.isControl(KM_MENU_LEFT, bind) && _selectSlotInDirection(AreaNavigation::LEFT))))
{
_playSelectSound();
return;
}
- Screen::keyPressed(keyCode);
+ Screen::controlPressed(bind);
}
}
diff --git a/source/client/gui/screens/inventory/ContainerScreen.hpp b/source/client/gui/screens/inventory/ContainerScreen.hpp
index 274120153..b8de9a5e1 100644
--- a/source/client/gui/screens/inventory/ContainerScreen.hpp
+++ b/source/client/gui/screens/inventory/ContainerScreen.hpp
@@ -65,7 +65,7 @@ class ContainerScreen : public Screen
void pointerPressed(const MenuPointer& pointer, MouseButtonType button) override;
void pointerReleased(const MenuPointer& pointer, MouseButtonType button) override;
void handlePointerPressed(bool isPressed) override;
- void keyPressed(int key) override;
+ void controlPressed(const ControlBind&) override;
const SlotDisplay& getSlotDisplay(const Slot&) const;
diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp
index 4aea60bbc..98ccf792b 100644
--- a/source/client/options/Options.cpp
+++ b/source/client/options/Options.cpp
@@ -152,9 +152,9 @@ void Options::_load()
{
std::string key = strings[i], value = strings[i + 1];
- std::map::iterator opt = m_options.find(key);
- if (opt != m_options.end())
- opt->second->load(value);
+ HashMap::iterator it = m_options.find(key);
+ if (it != m_options.end())
+ it.value()->load(value);
else if (key == "misc_oldtitle")
logo3d = !readBool(value);
else if (key == "gfx_resourcepacks")
@@ -404,11 +404,11 @@ std::vector Options::getOptionStrings()
#define SO(optname, value) do { vec.push_back(optname); vec.push_back(value); } while (0)
std::stringstream ss;
- for (std::map::iterator it = m_options.begin(); it != m_options.end(); ++it)
+ for (HashMap::iterator it = m_options.begin(); it != m_options.end(); ++it)
{
ss.str("");
- it->second->save(ss);
- SO(it->first, ss.str());
+ it.value()->save(ss);
+ SO(it.key(), ss.str());
}
SO("gfx_resourcepacks", savePackArray(m_resourcePacks));
@@ -418,7 +418,7 @@ std::vector Options::getOptionStrings()
void Options::loadControls()
{
// Win32 key codes are being used by default
-#define KM(idx, name, code) m_keyMappings[idx] = KeyMapping(name, code)
+#define KM(idx, name, code) m_controlMappings[idx] = ControlMapping(name, code)
KM(KM_FORWARD, "key.forward", 'W');
KM(KM_LEFT, "key.left", 'A');
KM(KM_BACKWARD, "key.back", 'S');
@@ -465,7 +465,7 @@ void Options::loadControls()
// @TODO: These should **really** not be defined in here. How about AppPlatform?
-#define KM(idx,code) m_keyMappings[idx].value = code
+#define KM(idx,code) m_controlMappings[idx].bind.keyId = code
#ifdef USE_SDL
KM(KM_FORWARD, SDLVK_w);
KM(KM_LEFT, SDLVK_a);
@@ -577,64 +577,37 @@ void Options::loadControls()
#endif
#undef KM
- if (m_bUseController.get())
- {
-#define KM(idx,code) m_keyMappings[idx].value = code
-#ifdef USE_SDL
- KM(KM_TOGGLEDEBUG, SDL_CONTROLLER_BUTTON_GUIDE);
- KM(KM_JUMP, SDL_CONTROLLER_BUTTON_A);
- KM(KM_MENU_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
- KM(KM_MENU_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
- KM(KM_MENU_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
- KM(KM_MENU_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
- KM(KM_MENU_TAB_LEFT, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
- KM(KM_MENU_TAB_RIGHT, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
- KM(KM_MENU_OK, SDL_CONTROLLER_BUTTON_A);
- KM(KM_MENU_CANCEL, SDL_CONTROLLER_BUTTON_B);
- KM(KM_DROP, SDL_CONTROLLER_BUTTON_B);
- KM(KM_CHAT, SDL_CONTROLLER_BUTTON_BACK);
- KM(KM_INVENTORY, SDL_CONTROLLER_BUTTON_Y);
- KM(KM_SNEAK, SDL_CONTROLLER_BUTTON_RIGHTSTICK);
- KM(KM_CONTAINER_QUICKMOVE, SDL_CONTROLLER_BUTTON_Y);
- KM(KM_CONTAINER_SPLIT, SDL_CONTROLLER_BUTTON_X);
- KM(KM_TOGGLE3RD, SDL_CONTROLLER_BUTTON_LEFTSTICK);
- KM(KM_SLOT_L, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
- KM(KM_SLOT_R, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
- KM(KM_FLY_UP, SDL_CONTROLLER_BUTTON_A);
- KM(KM_FLY_DOWN, SDL_CONTROLLER_BUTTON_RIGHTSTICK);
-#else
- KM(KM_TOGGLEDEBUG, GameController::BUTTON_GUIDE);
- KM(KM_JUMP, GameController::BUTTON_A);
- KM(KM_MENU_UP, GameController::BUTTON_DPAD_UP);
- KM(KM_MENU_DOWN, GameController::BUTTON_DPAD_DOWN);
- KM(KM_MENU_LEFT, GameController::BUTTON_DPAD_LEFT);
- KM(KM_MENU_RIGHT, GameController::BUTTON_DPAD_RIGHT);
- KM(KM_MENU_TAB_LEFT, GameController::BUTTON_LEFTSHOULDER);
- KM(KM_MENU_TAB_RIGHT, GameController::BUTTON_RIGHTSHOULDER);
- KM(KM_MENU_OK, GameController::BUTTON_A);
- KM(KM_MENU_CANCEL, GameController::BUTTON_B);
- KM(KM_MENU_PAUSE, GameController::BUTTON_START);
- KM(KM_DROP, GameController::BUTTON_B);
- KM(KM_CHAT, GameController::BUTTON_BACK);
- KM(KM_INVENTORY, GameController::BUTTON_Y);
- KM(KM_SNEAK, GameController::BUTTON_RIGHTSTICK);
- KM(KM_CONTAINER_QUICKMOVE, GameController::BUTTON_Y);
- KM(KM_CONTAINER_SPLIT, GameController::BUTTON_X);
- KM(KM_TOGGLE3RD, GameController::BUTTON_LEFTSTICK);
- KM(KM_SLOT_L, GameController::BUTTON_LEFTSHOULDER);
- KM(KM_SLOT_R, GameController::BUTTON_RIGHTSHOULDER);
- KM(KM_FLY_UP, GameController::BUTTON_A);
- KM(KM_FLY_DOWN, GameController::BUTTON_RIGHTSTICK);
-#endif
-#undef KM
- }
+#define BTN(idx,code) m_controlMappings[idx].bind.buttonId = code
+ BTN(KM_TOGGLEDEBUG, GameController::BUTTON_GUIDE);
+ BTN(KM_JUMP, GameController::BUTTON_A);
+ BTN(KM_MENU_UP, GameController::BUTTON_DPAD_UP);
+ BTN(KM_MENU_DOWN, GameController::BUTTON_DPAD_DOWN);
+ BTN(KM_MENU_LEFT, GameController::BUTTON_DPAD_LEFT);
+ BTN(KM_MENU_RIGHT, GameController::BUTTON_DPAD_RIGHT);
+ BTN(KM_MENU_TAB_LEFT, GameController::BUTTON_LEFTSHOULDER);
+ BTN(KM_MENU_TAB_RIGHT, GameController::BUTTON_RIGHTSHOULDER);
+ BTN(KM_MENU_OK, GameController::BUTTON_A);
+ BTN(KM_MENU_CANCEL, GameController::BUTTON_B);
+ BTN(KM_MENU_PAUSE, GameController::BUTTON_START);
+ BTN(KM_DROP, GameController::BUTTON_B);
+ BTN(KM_CHAT, GameController::BUTTON_BACK);
+ BTN(KM_INVENTORY, GameController::BUTTON_Y);
+ BTN(KM_SNEAK, GameController::BUTTON_RIGHTSTICK);
+ BTN(KM_CONTAINER_QUICKMOVE, GameController::BUTTON_Y);
+ BTN(KM_CONTAINER_SPLIT, GameController::BUTTON_X);
+ BTN(KM_TOGGLE3RD, GameController::BUTTON_LEFTSTICK);
+ BTN(KM_SLOT_L, GameController::BUTTON_LEFTSHOULDER);
+ BTN(KM_SLOT_R, GameController::BUTTON_RIGHTSHOULDER);
+ BTN(KM_FLY_UP, GameController::BUTTON_A);
+ BTN(KM_FLY_DOWN, GameController::BUTTON_RIGHTSTICK);
+#undef BTN
}
void Options::reset()
{
- for (std::map::iterator it = m_options.begin(); it != m_options.end(); ++it)
+ for (HashMap::iterator it = m_options.begin(); it != m_options.end(); ++it)
{
- it->second->reset();
+ it.value()->reset();
}
}
diff --git a/source/client/options/Options.hpp b/source/client/options/Options.hpp
index 0e1e3faeb..adeba0084 100644
--- a/source/client/options/Options.hpp
+++ b/source/client/options/Options.hpp
@@ -15,10 +15,12 @@
#include
#include