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/lang/en_us.json b/game/assets/lang/en_us.json
index 337c2ace6..94ed3b226 100644
--- a/game/assets/lang/en_us.json
+++ b/game/assets/lang/en_us.json
@@ -79,7 +79,6 @@
"options.dynamicHand": "Dynamic Hand Movement",
"options.autoJump": "Auto Jump",
"options.splitControls": "Split Controls",
- "options.useController": "Use Controller",
"options.flightHax": "Flight Hax",
"options.serverVisibleDefault": "Local Server Multiplayer",
"options.debugText": "Debug Text",
diff --git a/game/assets/materials/ui.material b/game/assets/materials/ui.material
index 73b1858d0..c9a574953 100644
--- a/game/assets/materials/ui.material
+++ b/game/assets/materials/ui.material
@@ -222,4 +222,4 @@
"vertexShader": "shaders/uv.vertex",
"fragmentShader": "shaders/texture.fragment"
}
-}
+}
\ No newline at end of file
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/Client/Client.vcxproj b/platforms/windows/projects/Client/Client.vcxproj
index c046d534d..3d035bcd8 100644
--- a/platforms/windows/projects/Client/Client.vcxproj
+++ b/platforms/windows/projects/Client/Client.vcxproj
@@ -258,6 +258,7 @@
+
diff --git a/platforms/windows/projects/Client/Client.vcxproj.filters b/platforms/windows/projects/Client/Client.vcxproj.filters
index 55cd0f467..c83e56ddc 100644
--- a/platforms/windows/projects/Client/Client.vcxproj.filters
+++ b/platforms/windows/projects/Client/Client.vcxproj.filters
@@ -677,6 +677,9 @@
Header Files\GUI\Screens\Inventory
+
+ Header Files\Player\Input
+
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..22c43e14d 100644
--- a/source/client/app/Minecraft.cpp
+++ b/source/client/app/Minecraft.cpp
@@ -51,6 +51,7 @@ int Minecraft::width = C_DEFAULT_SCREEN_WIDTH;
int Minecraft::height = C_DEFAULT_SCREEN_HEIGHT;
bool Minecraft::useAmbientOcclusion = false;
int Minecraft::customDebugId = 0;
+InputType::Name Minecraft::_inputType = InputType::KEYBOARD;
//@HUH: For the demo, this is defined as TRUE.
//@HUH: deadmau5 had camera cheats? That's interesting.
@@ -181,14 +182,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 +205,9 @@ void Minecraft::_reloadInput()
new MouseTurnInput(this),
new MouseBuildInput()
);
+
+ if (m_bGrabbedMouse)
+ platform()->setMouseGrabbed(true);
}
m_mouseHandler.setTurnInput(m_pInputHolder->getTurnInput());
@@ -262,7 +273,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 +287,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 +373,17 @@ bool Minecraft::isOnlineClient() const
bool Minecraft::isTouchscreen() const
{
- return m_bIsTouchscreen;
+ return getInputType() == InputType::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 getInputType() == InputType::CONTROLLER;
}
void Minecraft::setGameMode(GameType gameType)
@@ -505,6 +517,12 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action)
void Minecraft::tickInput()
{
+ if (!platform()->hasGamepad() && useController())
+ setInputType(platform()->isTouchscreen() ? InputType::TOUCHSCREEN : InputType::KEYBOARD);
+
+ if (!m_pInputHolder->allowsType(getInputType()))
+ _reloadInput();
+
if (m_pScreen)
{
if (!m_pScreen->m_bPassEvents)
@@ -550,93 +568,131 @@ void Minecraft::tickInput()
#endif
}
- while (Keyboard::next())
+ if (useController())
{
- int keyCode = Keyboard::getEventKey();
- bool bPressed = Keyboard::getEventKeyState() == 1;
-
- m_pLocalPlayer->m_pMoveInput->setKey(keyCode, bPressed);
+ //Clearing, so the events don't accumulate
+ Keyboard::reset();
- 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->handleButtonPressed(ButtonInfo(-1, button));
- if (getOptions()->isKey(KM_TOGGLE3RD, keyCode))
+ for (size_t i = 0; i < BM_COUNT; ++i)
{
- getOptions()->m_thirdPerson.toggle();
+ eButtonMappingIndex ctrl = (eButtonMappingIndex)i;
+ if (!getOptions()->getButton(ctrl).isControllerButton(button)) continue;
+
+ m_pLocalPlayer->m_pMoveInput->setKey(ctrl, bPressed);
+ if (bPressed)
+ getOptions()->getButtonMapping(ctrl).pressed();
+ else
+ getOptions()->getButtonMapping(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->handleButtonPressed(ButtonInfo(keyCode, GameController::BUTTON_NONE));
+
+ for (size_t i = 0; i < BM_COUNT; ++i)
{
- handleBack(false);
+ eButtonMappingIndex ctrl = (eButtonMappingIndex)i;
+ if (!getOptions()->isKey(ctrl, keyCode)) continue;
+
+ m_pLocalPlayer->m_pMoveInput->setKey(ctrl, bPressed);
+ if (bPressed)
+ getOptions()->getButtonMapping(ctrl).pressed();
+ else
+ getOptions()->getButtonMapping(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(BM_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(BM_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()->getButtonMapping(eButtonMappingIndex(BM_SLOT_1 + i)).consume())
+ m_pLocalPlayer->m_pInventory->selectSlot(i);
+ }
- // @TODO: Replace with KeyboardBuildInput
- if (!useController() && getTimeMs() - field_2B4 <= 200)
+ while (getOptions()->getButtonMapping(BM_TOGGLE3RD).consume())
+ {
+ getOptions()->m_thirdPerson.toggle();
+ }
+
+ while (getOptions()->getButtonMapping(BM_MENU_PAUSE).consume())
+ {
+ handleBack(false);
+ }
+
+ while (getOptions()->getButtonMapping(BM_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()->getButtonMapping(BM_TOGGLEGUI).consume())
+ {
+ getOptions()->m_hideGui.toggle();
+ }
+
+ while (getOptions()->getButtonMapping(BM_TOGGLEDEBUG).consume())
+ {
+ getOptions()->m_debugText.toggle();
+ }
+#ifdef ENH_ALLOW_AO_TOGGLE
+ while (getOptions()->getButtonMapping(BM_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()
@@ -794,6 +850,10 @@ void Minecraft::tick()
setScreen(new DeathScreen);
}
}
+ else
+ {
+ m_pScreen->validate(this);
+ }
tickInput();
@@ -847,6 +907,9 @@ void Minecraft::tick()
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 +1064,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 +1100,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 +1209,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/Minecraft.hpp b/source/client/app/Minecraft.hpp
index edd594852..24b1d12dc 100644
--- a/source/client/app/Minecraft.hpp
+++ b/source/client/app/Minecraft.hpp
@@ -115,9 +115,13 @@ class Minecraft : public App
UITheme getUiTheme();
//const Entity& getCameraEntity() const { return *m_pCameraEntity; }
+ static InputType::Name getInputType() { return _inputType; }
+ static void setInputType(InputType::Name inputType) { _inputType = inputType; }
+
private:
// Value provided by the OS
static float _renderScaleMultiplier;
+ static InputType::Name _inputType;
public:
static float getRenderScaleMultiplier() { return _renderScaleMultiplier; }
static void setRenderScaleMultiplier(float value) { _renderScaleMultiplier = value; }
diff --git a/source/client/app/NinecraftApp.cpp b/source/client/app/NinecraftApp.cpp
index 1c7bd839c..2bc05a62b 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())
+ setInputType(InputType::CONTROLLER);
+ else if (platform()->isTouchscreen())
+ setInputType(InputType::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..26e7914dd 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::handleButtonPressed(const ButtonInfo& info)
{
Options* options = m_pMinecraft->getOptions();
- if (options->isKey(KM_INVENTORY, keyCode))
+ if (options->isButton(BM_INVENTORY, info))
{
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->isButton(BM_SLOT_L, info);
+ bool slotR = options->isButton(BM_SLOT_R, info);
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->isButton(BM_CHAT, info) || options->isButton(BM_CHAT_CMD, info))
{
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()->isButton(BM_CHAT_CMD, info)));
}
}
diff --git a/source/client/gui/Gui.hpp b/source/client/gui/Gui.hpp
index 9957d2f65..8adc206a2 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 handleButtonPressed(const ButtonInfo&);
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..de8ea7dd5 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::handleButtonPress(Minecraft* pMinecraft, const ButtonInfo& key)
{
}
diff --git a/source/client/gui/GuiElement.hpp b/source/client/gui/GuiElement.hpp
index 8ac2bc45c..3350dd2bc 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 handleButtonPress(Minecraft* pMinecraft, const ButtonInfo& button);
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..94e024246 100644
--- a/source/client/gui/Screen.cpp
+++ b/source/client/gui/Screen.cpp
@@ -47,7 +47,8 @@ Screen::Screen()
m_bRenderPointer = false;
m_lastTimeMoved = 0;
m_cursorTick = 0;
- m_uiTheme = UI_GENERIC;
+ m_screenType = SCREEN_GENERIC;
+ m_uiTheme = UI_POCKET;
}
Screen::~Screen()
@@ -56,7 +57,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 +140,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_screenType == SCREEN_UNIVERSAL || (m_screenType == SCREEN_GENERIC && userTheme != UI_CONSOLE))
+ m_uiTheme = userTheme;
setSize(width, height);
initMenuPointer();
@@ -150,44 +151,44 @@ void Screen::init(Minecraft* pMinecraft, int width, int height)
m_bLastPointerPressedState = false;
}
-void Screen::keyPressed(int key)
+void Screen::buttonPressed(const ButtonInfo& info)
{
Options& options = *m_pMinecraft->getOptions();
GuiElement* element = _getSelectedElement();
- if (options.isKey(KM_MENU_CANCEL, key))
+ if (options.isButton(BM_MENU_CANCEL, info))
{
m_pMinecraft->handleBack(false);
}
- if (m_pMinecraft->getOptions()->isKey(KM_MENU_TAB_LEFT, key))
+ if (options.isButton(BM_MENU_TAB_LEFT, info))
{
prevTab();
}
- if (m_pMinecraft->getOptions()->isKey(KM_MENU_TAB_RIGHT, key))
+ if (options.isButton(BM_MENU_TAB_RIGHT, info))
{
nextTab();
}
if (doElementTabbing())
{
- if (options.isKey(KM_MENU_DOWN, key))
+ if (options.isButton(BM_MENU_DOWN, info))
{
_areaNavigation(AreaNavigation::DOWN);
}
- else if (options.isKey(KM_MENU_UP, key))
+ else if (options.isButton(BM_MENU_UP, info))
{
_areaNavigation(AreaNavigation::UP);
}
- else if (options.isKey(KM_MENU_RIGHT, key))
+ else if (options.isButton(BM_MENU_RIGHT, info))
{
_areaNavigation(AreaNavigation::RIGHT);
}
- else if (options.isKey(KM_MENU_LEFT, key))
+ else if (options.isButton(BM_MENU_LEFT, info))
{
_areaNavigation(AreaNavigation::LEFT);
}
- else if (options.isKey(KM_MENU_OK, key))
+ else if (options.isButton(BM_MENU_OK, info))
{
if (element && element->isEnabled())
{
@@ -204,7 +205,7 @@ void Screen::keyPressed(int key)
if (element && element->isEnabled())
{
- element->handleButtonPress(m_pMinecraft, key);
+ element->handleButtonPress(m_pMinecraft, info);
}
}
@@ -255,6 +256,11 @@ void Screen::handleKeyboardClosed()
}
}
+bool Screen::validate(Minecraft*)
+{
+ return true;
+}
+
static const char* g_panoramaList[] =
{
"gui/background/panorama_0.png",
@@ -530,11 +536,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 +732,14 @@ void Screen::updateEvents()
if (_useController())
{
checkForPointerEvent(MOUSE_BUTTON_LEFT);
- controllerEvent();
+
+ while(GameControllerManager::next())
+ controllerEvent();
+
+ _processControllerDirection(1);
+ _processControllerDirection(2);
+
+ controllerStickEvent(2);
}
}
@@ -747,7 +763,7 @@ void Screen::keyboardEvent()
// Ugly hack
if (!doElementTabbing())
{
- if (Keyboard::getEventKeyState() && m_pMinecraft->getOptions()->isKey(KM_MENU_OK, Keyboard::getEventKey()))
+ if (Keyboard::getEventKeyState() && m_pMinecraft->getOptions()->isKey(BM_MENU_OK, Keyboard::getEventKey()))
{
m_menuPointer.isPressed = true;
}
@@ -758,15 +774,26 @@ void Screen::keyboardEvent()
}
if (Keyboard::getEventKeyState())
- keyPressed(Keyboard::getEventKey());
+ buttonPressed(ButtonInfo(Keyboard::getEventKey(), GameController::BUTTON_NONE));
}
void Screen::controllerEvent()
{
- _processControllerDirection(1);
- _processControllerDirection(2);
+ // Ugly hack x2
+ if (!doElementTabbing())
+ {
+ if (GameControllerManager::getEventButtonState() && m_pMinecraft->getOptions()->getButton(BM_MENU_OK).isControllerButton(GameControllerManager::getEventButton()))
+ {
+ m_menuPointer.isPressed = true;
+ }
+ else
+ {
+ m_menuPointer.isPressed = false;
+ }
+ }
- controllerEvent(2);
+ if (GameControllerManager::getEventButtonState())
+ buttonPressed(ButtonInfo(-1, GameControllerManager::getEventButton()));
}
void Screen::checkForPointerEvent(MouseButtonType button)
diff --git a/source/client/gui/Screen.hpp b/source/client/gui/Screen.hpp
index a936e10ed..d1968b786 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 buttonPressed(const ButtonInfo&);
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,6 +153,13 @@ class Screen : public GuiComponent
Screen* m_pScreen;
};
+ enum Type
+ {
+ SCREEN_SPECIFIC, // The Screen handles a specific UI Theme
+ SCREEN_GENERIC, // The Screen is a Java / Pocket mix
+ SCREEN_UNIVERSAL // The Screen automatically handles all UI themes
+ };
+
int m_width;
int m_height;
bool m_bPassEvents;
@@ -162,6 +170,7 @@ class Screen : public GuiComponent
GuiElement* m_pSelectedElement;
Font* m_pFont;
GuiElement* m_pClickedElement;
+ Type m_screenType;
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/Button.cpp b/source/client/gui/components/Button.cpp
index a1d0b1eee..bbe56d909 100644
--- a/source/client/gui/components/Button.cpp
+++ b/source/client/gui/components/Button.cpp
@@ -32,7 +32,7 @@ void Button::_renderBgPocket(Minecraft* mc, const MenuPointer& pointer)
int iXPos = isSelected() ? 66 : 0;
currentShaderColor = isEnabled() ? Color::WHITE : Color::GREY;
mc->m_pTextures->loadAndBindTexture("gui/touchgui.png");
- blit(m_xPos, m_yPos, iXPos, 0, m_width, m_height, 66, 26, &m_materials.ui_textured_and_glcolor);
+ blitNineSlice(*mc->m_pTextures, TextureAtlasSprite(iXPos, 0, 66, 26, "gui/touchgui.png", 256, 256), m_xPos, m_yPos, m_width, m_height, 3, &m_materials.ui_textured_and_glcolor);
}
void Button::_renderBgConsole(Minecraft* mc, const MenuPointer& pointer)
@@ -47,8 +47,8 @@ void Button::_renderBgConsole(Minecraft* mc, const MenuPointer& pointer)
float timer = (getTimeMs() % 1200) / 1200.0f;
currentShaderColor.a *= 0.5f + (timer >= 0.5f ? 1 - timer : timer);
blitSprite(texs, "gui/console/Graphics/MainMenuButton_Over.png", m_xPos, m_yPos, m_width, m_height, &m_materials.ui_textured_and_glcolor);
- currentShaderColor = m_color;
}
+ currentShaderColor = m_color;
}
void Button::_renderMessage(Font& font)
@@ -69,14 +69,18 @@ void Button::_renderMessageConsole(Font& font)
if (hasFocus())
{
float timer = (getTimeMs() % 1200) / 1200.0f;
- textColor = Color(220, 220, Mth::round((0.5f - (timer >= 0.5f ? 1 - timer : timer)) * 220), currentShaderColor.a);
+ textColor = Color(220, 220, Mth::round((0.5f - (timer >= 0.5f ? 1 - timer : timer)) * 220));
}
else if (isSelected())
{
- textColor = Color(220, 220, 0, currentShaderColor.a); // 0xDCDC00
+ textColor = Color(220, 220, 0); // 0xDCDC00
}
else
- textColor = Color(224, 224, 224, currentShaderColor.a); // 0xE0E0E0U
+ textColor = Color(224, 224, 224); // 0xE0E0E0U
+
+ if (!isEnabled())
+ textColor.a *= 0.5f;
+
int textWidth = font.width(getMessage()) * 2;
font.drawScalableShadow(getMessage(), m_xPos + (m_width - textWidth) / 2, m_yPos + (m_height - 16) / 2, textColor);
}
diff --git a/source/client/gui/components/OptionList.cpp b/source/client/gui/components/OptionList.cpp
index 062f32f5e..643294e25 100644
--- a/source/client/gui/components/OptionList.cpp
+++ b/source/client/gui/components/OptionList.cpp
@@ -165,7 +165,7 @@ void OptionList::initControlsMenu()
{
Options* pOptions = m_pMinecraft->getOptions();
int currentIndex = -1;
- int idxSplit = -1, idxController = -1;
+ int idxSplit = -1;
OPTIONS_LIST_CONTROLS_CONTROLS;
OPTIONS_LIST_CONTROLS_FEEDBACK;
@@ -173,7 +173,6 @@ void OptionList::initControlsMenu()
if (!m_pMinecraft->isTouchscreen())
m_items[idxSplit]->setEnabled(false);
- 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..badb258f0 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::handleButtonPress(Minecraft* pMinecraft, const ButtonInfo& info)
{
Options& options = *pMinecraft->getOptions();
if (!hasFocus())
{
- if (options.isKey(KM_MENU_OK, key))
+ if (options.isButton(BM_MENU_OK, info))
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 (info.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..4bd3a15af 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 handleButtonPress(Minecraft* pMinecraft, const ButtonInfo&) 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..3f948f0a6 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::buttonPressed(const ButtonInfo& button)
{
if (!_useController())
{
- if (m_pMinecraft->getOptions()->isKey(KM_MENU_OK, keyCode))
+ if (m_pMinecraft->getOptions()->isButton(BM_MENU_OK, button))
sendMessageAndExit();
}
- Screen::keyPressed(keyCode);
+ Screen::buttonPressed(button);
}
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..65763a80d 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 buttonPressed(const ButtonInfo& info) override;
void handleKeyboardClosed() override;
+ bool isPauseScreen() override;
void sendMessageAndExit();
diff --git a/source/client/gui/screens/CreateWorldScreen_Console.cpp b/source/client/gui/screens/CreateWorldScreen_Console.cpp
index 3de2b5952..7352049d4 100644
--- a/source/client/gui/screens/CreateWorldScreen_Console.cpp
+++ b/source/client/gui/screens/CreateWorldScreen_Console.cpp
@@ -9,8 +9,10 @@ CreateWorldScreen_Console::CreateWorldScreen_Console(Options& options, Screen* p
m_inviteOnly(0, 0, false, Language::get("playGame.inviteOnly")),
m_textName(this, 0, 0, 400, 38, "", "New World"),
m_textSeed(this, 0, 0, 400, 38, ""),
+ m_btnGameMode(0, 0, 400, 40, ""),
m_difficultySlider(0, 0, 400, 32, &options.m_difficulty, options.m_difficulty.getMessage(), options.m_difficulty.toFloat()),
- m_btnCreate(0, 0, 400, 40, Language::get("playGame.createNewWorld"))
+ m_btnCreate(0, 0, 400, 40, Language::get("playGame.createNewWorld")),
+ m_gameMode(GAME_TYPE_SURVIVAL)
{
m_onlineGame.setEnabled(false);
m_inviteOnly.setEnabled(false);
@@ -38,15 +40,20 @@ void CreateWorldScreen_Console::_buttonClicked(Button* pButton)
seed = Util::hashCode(seedThing);
}
- LevelSettings levelSettings(seed);
+ LevelSettings levelSettings(seed, m_gameMode);
m_pMinecraft->selectLevel(levelUniqueName, levelNickname, levelSettings);
}
+ else if (pButton->getId() == m_btnGameMode.getId())
+ {
+ m_gameMode = static_cast((static_cast(m_gameMode) + 1) % (GAME_TYPES_MAX + 1));
+ m_btnGameMode.setMessage("Game Mode: " + GameTypeConv::GameTypeToNonLocString(m_gameMode));
+ }
}
void CreateWorldScreen_Console::init()
{
m_panel.w = 450;
- m_panel.h = 390;
+ m_panel.h = 418;
m_panel.x = (m_width - m_panel.w) / 2;
m_panel.y = (m_height - m_panel.h) / 2 + 45;
@@ -67,12 +74,18 @@ void CreateWorldScreen_Console::init()
m_textSeed.m_yPos = m_panel.y + 188;
_addElement(m_textSeed);
+ m_btnGameMode.setMessage("Game Mode: " + GameTypeConv::GameTypeToNonLocString(m_gameMode));
+
+ m_btnGameMode.m_xPos = left;
+ m_btnGameMode.m_yPos = m_panel.y + 259;
+ _addElement(m_btnGameMode);
+
m_difficultySlider.m_xPos = left;
- m_difficultySlider.m_yPos = m_panel.y + 267;
+ m_difficultySlider.m_yPos = m_panel.y + 308;
_addElement(m_difficultySlider);
m_btnCreate.m_xPos = left;
- m_btnCreate.m_yPos = m_panel.y + 322;
+ m_btnCreate.m_yPos = m_panel.y + 350;
_addElement(m_btnCreate);
m_textName.init(m_pFont);
diff --git a/source/client/gui/screens/CreateWorldScreen_Console.hpp b/source/client/gui/screens/CreateWorldScreen_Console.hpp
index 7643a1196..88de45a6e 100644
--- a/source/client/gui/screens/CreateWorldScreen_Console.hpp
+++ b/source/client/gui/screens/CreateWorldScreen_Console.hpp
@@ -24,6 +24,8 @@ class CreateWorldScreen_Console : public PanelScreen_Console
TickBox m_inviteOnly;
TextBox m_textName;
TextBox m_textSeed;
+ Button m_btnGameMode;
SliderButton m_difficultySlider;
Button m_btnCreate;
+ GameType m_gameMode;
};
\ No newline at end of file
diff --git a/source/client/gui/screens/CreditsScreen.cpp b/source/client/gui/screens/CreditsScreen.cpp
index b5bfb604d..fd70417bb 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::buttonPressed(const ButtonInfo& info)
{
- Screen::keyPressed(code);
+ Screen::buttonPressed(info);
}
void CreditsScreen::tick()
diff --git a/source/client/gui/screens/CreditsScreen.hpp b/source/client/gui/screens/CreditsScreen.hpp
index 27185894e..29f2af1be 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 buttonPressed(const ButtonInfo&) 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..f67756031 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::buttonPressed(const ButtonInfo& info)
{
- if (!_useController() && m_pMinecraft->getOptions()->isKey(KM_INVENTORY, keyCode))
+ if (!_useController() && m_pMinecraft->getOptions()->isButton(BM_INVENTORY, info))
{
m_pMinecraft->handleBack(false);
}
else
{
- Screen::keyPressed(keyCode);
+ Screen::buttonPressed(info);
}
}
+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..f80726b82 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 buttonPressed(const ButtonInfo&) 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..e28f2195a 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)
@@ -77,7 +87,7 @@ ControlsPanelScreen::ControlsPanelScreen(Screen* parent, Minecraft* mc) : PanelS
{
Options& options = *mc->getOptions();
int currentIndex = -1;
- int idxSplit = -1, idxController = -1;
+ int idxSplit = -1;
OPTIONS_LIST_CONTROLS_CONTROLS;
OPTIONS_LIST_CONTROLS_FEEDBACK;
@@ -85,7 +95,6 @@ ControlsPanelScreen::ControlsPanelScreen(Screen* parent, Minecraft* mc) : PanelS
if (!mc->isTouchscreen())
m_layout.m_elements[idxSplit]->setEnabled(false);
- m_layout.m_elements[idxController]->setEnabled(false);
}
void ControlsPanelScreen::removed()
@@ -134,6 +143,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..03d7c0560 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_screenType = SCREEN_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..113ca9b72 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_screenType = SCREEN_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..6d1df8468 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::buttonPressed(const ButtonInfo& button)
{
+ Options& options = *m_pMinecraft->getOptions();
#ifndef ORIGINAL_CODE
- if (m_pMinecraft->getOptions()->getKey(KM_MENU_OK) == code)
+ if (options.isButton(BM_MENU_OK, button))
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.isButton(BM_LEFT, button))
m_pWorldSelectionList->stepLeft();
- if (m_pMinecraft->getOptions()->getKey(KM_RIGHT) == code)
+ if (options.isButton(BM_RIGHT, button))
m_pWorldSelectionList->stepRight();
}
- Screen::keyPressed(code);
+ Screen::buttonPressed(button);
}
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..7b4e6010f 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 buttonPressed(const ButtonInfo&) 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..76f177862 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_screenType = SCREEN_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..fb1c0ea2f 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_screenType = SCREEN_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::buttonPressed(const ButtonInfo& button)
{
- if (!_useController() && m_pMinecraft->getOptions()->isKey(KM_INVENTORY, keyCode))
+ Options& options = *m_pMinecraft->getOptions();
+ if (!_useController() && options.isButton(BM_INVENTORY, button))
{
m_pMinecraft->handleBack(false);
}
- else if (m_pMinecraft->getOptions()->isKey(KM_CONTAINER_QUICKMOVE, keyCode) && _useController())
+ else if (options.isButton(BM_CONTAINER_QUICKMOVE, button) && _useController())
{
slotClicked(m_menuPointer, MOUSE_BUTTON_LEFT, true);
}
- else if (m_pMinecraft->getOptions()->isKey(KM_CONTAINER_SPLIT, keyCode) && _useController())
+ else if (options.isButton(BM_CONTAINER_SPLIT, button) && _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.isButton(BM_MENU_UP, button) && _selectSlotInDirection(AreaNavigation::UP)) ||
+ (options.isButton(BM_MENU_DOWN, button) && _selectSlotInDirection(AreaNavigation::DOWN)) ||
+ (options.isButton(BM_MENU_RIGHT, button) && _selectSlotInDirection(AreaNavigation::RIGHT)) ||
+ (options.isButton(BM_MENU_LEFT, button) && _selectSlotInDirection(AreaNavigation::LEFT))))
{
_playSelectSound();
return;
}
- Screen::keyPressed(keyCode);
+ Screen::buttonPressed(button);
}
}
diff --git a/source/client/gui/screens/inventory/ContainerScreen.hpp b/source/client/gui/screens/inventory/ContainerScreen.hpp
index 274120153..a6d76d022 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 buttonPressed(const ButtonInfo&) override;
const SlotDisplay& getSlotDisplay(const Slot&) const;
diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp
index 4aea60bbc..c168658e7 100644
--- a/source/client/options/Options.cpp
+++ b/source/client/options/Options.cpp
@@ -86,7 +86,6 @@ Options::Options(Minecraft* mc, const std::string& folderPath) :
, m_fancyGrass("gfx_fancygrass", "options.fancyGrass", true)
, m_biomeColors("gfx_biomecolors", "options.biomeColors", true)
, m_splitControls("ctrl_split", "options.splitControls", false)
- , m_bUseController("ctrl_usecontroller", "options.useController", false)
, m_dynamicHand("gfx_dynamichand", "options.dynamicHand", false)
, m_menuPanorama("misc_menupano", "options.menuPanorama", true)
, m_guiScale("gfx_guiscale", "options.guiScale", 0, ValuesBuilder().add("options.guiScale.auto").add("options.guiScale.small").add("options.guiScale.normal").add(("options.guiScale.large")))
@@ -152,9 +151,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 +403,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,223 +417,196 @@ 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)
- KM(KM_FORWARD, "key.forward", 'W');
- KM(KM_LEFT, "key.left", 'A');
- KM(KM_BACKWARD, "key.back", 'S');
- KM(KM_RIGHT, "key.right", 'D');
- KM(KM_JUMP, "key.jump", ' ');
- KM(KM_INVENTORY, "key.inventory", 'E');
- KM(KM_DROP, "key.drop", 'Q');
- KM(KM_CHAT, "key.chat", 'T');
- KM(KM_FOG, "key.fog", 'F');
- KM(KM_SNEAK, "key.sneak", 0x10); // VK_SHIFT. In original, it's 10 (misspelling?)
- KM(KM_DESTROY, "key.destroy", 'K'); // was 'X'
- KM(KM_PLACE, "key.place", 'L'); // was 'C'
- KM(KM_MENU_UP, "key.menu.up", 0x26); // VK_UP
- KM(KM_MENU_DOWN, "key.menu.down", 0x28); // VK_DOWN
- KM(KM_MENU_LEFT, "key.menu.left", 0x25); // VK_LEFT
- KM(KM_MENU_RIGHT, "key.menu.right", 0x27); // VK_RIGHT
- KM(KM_MENU_TAB_LEFT,"key.menu.tab.left", 0x25); // VK_LEFT
- KM(KM_MENU_TAB_RIGHT, "key.menu.tab.right", 0x27);// VK_RIGHT
- KM(KM_MENU_OK, "key.menu.ok", 0x0D); // VK_RETURN
- KM(KM_MENU_CANCEL, "key.menu.cancel", 0x1B); // VK_ESCAPE, was 0x08 = VK_BACK
- KM(KM_MENU_PAUSE, "key.menu.pause", 0x1B); // VK_ESCAPE
- KM(KM_SLOT_1, "key.slot.1", '1');
- KM(KM_SLOT_2, "key.slot.2", '2');
- KM(KM_SLOT_3, "key.slot.3", '3');
- KM(KM_SLOT_4, "key.slot.4", '4');
- KM(KM_SLOT_5, "key.slot.5", '5');
- KM(KM_SLOT_6, "key.slot.6", '6');
- KM(KM_SLOT_7, "key.slot.7", '7');
- KM(KM_SLOT_8, "key.slot.8", '8');
- KM(KM_SLOT_9, "key.slot.9", '9');
- KM(KM_SLOT_L, "key.slot.left", 'Y');
- KM(KM_SLOT_R, "key.slot.right", 'U');
- KM(KM_CONTAINER_QUICKMOVE, "key.container.quickmove", 0x10); // VK_SHIFT
- KM(KM_CONTAINER_SPLIT, "key.container.split", 0xBF); // VK_OEM_2 (keymap is unused on mouse & keyboard)
- KM(KM_TOGGLEGUI, "key.fn.gui", 0x70); // VK_F1
- KM(KM_SCREENSHOT, "key.fn.screenshot", 0x71); // VK_F2
- KM(KM_TOGGLEDEBUG, "key.fn.debug", 0x72); // VK_F3
- KM(KM_TOGGLEAO, "key.fn.ao", 0x73); // VK_F4
- KM(KM_TOGGLE3RD, "key.fn.3rd", 0x74); // VK_F5
- KM(KM_FLY_UP, "key.fly.up", 'X');
- KM(KM_FLY_DOWN, "key.fly.down", 'C');
- KM(KM_CHAT_CMD, "key.chat.cmd", 0xBF); // VK_OEM_2
-#undef KM
+#define BM(idx, name, code) m_buttonMappings[idx] = ButtonMapping(name, code)
+ BM(BM_FORWARD, "key.forward", 'W');
+ BM(BM_LEFT, "key.left", 'A');
+ BM(BM_BACKWARD, "key.back", 'S');
+ BM(BM_RIGHT, "key.right", 'D');
+ BM(BM_JUMP, "key.jump", ' ');
+ BM(BM_INVENTORY, "key.inventory", 'E');
+ BM(BM_DROP, "key.drop", 'Q');
+ BM(BM_CHAT, "key.chat", 'T');
+ BM(BM_FOG, "key.fog", 'F');
+ BM(BM_SNEAK, "key.sneak", 0x10); // VK_SHIFT. In original, it's 10 (misspelling?)
+ BM(BM_DESTROY, "key.destroy", 'K'); // was 'X'
+ BM(BM_PLACE, "key.place", 'L'); // was 'C'
+ BM(BM_MENU_UP, "key.menu.up", 0x26); // VK_UP
+ BM(BM_MENU_DOWN, "key.menu.down", 0x28); // VK_DOWN
+ BM(BM_MENU_LEFT, "key.menu.left", 0x25); // VK_LEFT
+ BM(BM_MENU_RIGHT, "key.menu.right", 0x27); // VK_RIGHT
+ BM(BM_MENU_TAB_LEFT,"key.menu.tab.left", 0x25); // VK_LEFT
+ BM(BM_MENU_TAB_RIGHT, "key.menu.tab.right", 0x27);// VK_RIGHT
+ BM(BM_MENU_OK, "key.menu.ok", 0x0D); // VK_RETURN
+ BM(BM_MENU_CANCEL, "key.menu.cancel", 0x1B); // VK_ESCAPE, was 0x08 = VK_BACK
+ BM(BM_MENU_PAUSE, "key.menu.pause", 0x1B); // VK_ESCAPE
+ BM(BM_SLOT_1, "key.slot.1", '1');
+ BM(BM_SLOT_2, "key.slot.2", '2');
+ BM(BM_SLOT_3, "key.slot.3", '3');
+ BM(BM_SLOT_4, "key.slot.4", '4');
+ BM(BM_SLOT_5, "key.slot.5", '5');
+ BM(BM_SLOT_6, "key.slot.6", '6');
+ BM(BM_SLOT_7, "key.slot.7", '7');
+ BM(BM_SLOT_8, "key.slot.8", '8');
+ BM(BM_SLOT_9, "key.slot.9", '9');
+ BM(BM_SLOT_L, "key.slot.left", 'Y');
+ BM(BM_SLOT_R, "key.slot.right", 'U');
+ BM(BM_CONTAINER_QUICKMOVE, "key.container.quickmove", 0x10); // VK_SHIFT
+ BM(BM_CONTAINER_SPLIT, "key.container.split", 0xBF); // VK_OEM_2 (keymap is unused on mouse & keyboard)
+ BM(BM_TOGGLEGUI, "key.fn.gui", 0x70); // VK_F1
+ BM(BM_SCREENSHOT, "key.fn.screenshot", 0x71); // VK_F2
+ BM(BM_TOGGLEDEBUG, "key.fn.debug", 0x72); // VK_F3
+ BM(BM_TOGGLEAO, "key.fn.ao", 0x73); // VK_F4
+ BM(BM_TOGGLE3RD, "key.fn.3rd", 0x74); // VK_F5
+ BM(BM_FLY_UP, "key.fly.up", 'X');
+ BM(BM_FLY_DOWN, "key.fly.down", 'C');
+ BM(BM_CHAT_CMD, "key.chat.cmd", 0xBF); // VK_OEM_2
+#undef BM
// @TODO: These should **really** not be defined in here. How about AppPlatform?
-#define KM(idx,code) m_keyMappings[idx].value = code
+#define BM(idx,code) m_buttonMappings[idx].info.keyId = code
#ifdef USE_SDL
- KM(KM_FORWARD, SDLVK_w);
- KM(KM_LEFT, SDLVK_a);
- KM(KM_BACKWARD, SDLVK_s);
- KM(KM_RIGHT, SDLVK_d);
- KM(KM_JUMP, SDLVK_SPACE);
- KM(KM_DESTROY, SDLVK_x);
- KM(KM_PLACE, SDLVK_c);
- KM(KM_MENU_UP, SDLVK_UP);
- KM(KM_MENU_DOWN, SDLVK_DOWN);
- KM(KM_MENU_LEFT, SDLVK_LEFT);
- KM(KM_MENU_RIGHT, SDLVK_RIGHT);
- KM(KM_MENU_TAB_LEFT, SDLVK_LEFT);
- KM(KM_MENU_TAB_RIGHT, SDLVK_RIGHT);
- KM(KM_MENU_OK, SDLVK_RETURN);
- KM(KM_MENU_CANCEL, SDLVK_ESCAPE);
- KM(KM_MENU_PAUSE, SDLVK_ESCAPE);
- KM(KM_DROP, SDLVK_q);
- KM(KM_CHAT, SDLVK_t);
- KM(KM_FOG, SDLVK_f);
- KM(KM_INVENTORY, SDLVK_e);
- KM(KM_SNEAK, SDLVK_LSHIFT);
- KM(KM_SLOT_1, SDLVK_1);
- KM(KM_SLOT_2, SDLVK_2);
- KM(KM_SLOT_3, SDLVK_3);
- KM(KM_SLOT_4, SDLVK_4);
- KM(KM_SLOT_5, SDLVK_5);
- KM(KM_SLOT_6, SDLVK_6);
- KM(KM_SLOT_7, SDLVK_7);
- KM(KM_SLOT_8, SDLVK_8);
- KM(KM_SLOT_9, SDLVK_9);
- KM(KM_CONTAINER_QUICKMOVE, SDLVK_LSHIFT);
- KM(KM_TOGGLEGUI, SDLVK_F1);
- KM(KM_SCREENSHOT, SDLVK_F2);
- KM(KM_TOGGLEDEBUG, SDLVK_F3);
- KM(KM_TOGGLEAO, SDLVK_F4);
- KM(KM_TOGGLE3RD, SDLVK_F5);
- KM(KM_SLOT_L, SDLVK_y);
- KM(KM_SLOT_R, SDLVK_u);
- KM(KM_FLY_UP, SDLVK_c);
- KM(KM_FLY_DOWN, SDLVK_x);
- KM(KM_CHAT_CMD, SDLVK_SLASH);
+ BM(BM_FORWARD, SDLVK_w);
+ BM(BM_LEFT, SDLVK_a);
+ BM(BM_BACKWARD, SDLVK_s);
+ BM(BM_RIGHT, SDLVK_d);
+ BM(BM_JUMP, SDLVK_SPACE);
+ BM(BM_DESTROY, SDLVK_x);
+ BM(BM_PLACE, SDLVK_c);
+ BM(BM_MENU_UP, SDLVK_UP);
+ BM(BM_MENU_DOWN, SDLVK_DOWN);
+ BM(BM_MENU_LEFT, SDLVK_LEFT);
+ BM(BM_MENU_RIGHT, SDLVK_RIGHT);
+ BM(BM_MENU_TAB_LEFT, SDLVK_LEFT);
+ BM(BM_MENU_TAB_RIGHT, SDLVK_RIGHT);
+ BM(BM_MENU_OK, SDLVK_RETURN);
+ BM(BM_MENU_CANCEL, SDLVK_ESCAPE);
+ BM(BM_MENU_PAUSE, SDLVK_ESCAPE);
+ BM(BM_DROP, SDLVK_q);
+ BM(BM_CHAT, SDLVK_t);
+ BM(BM_FOG, SDLVK_f);
+ BM(BM_INVENTORY, SDLVK_e);
+ BM(BM_SNEAK, SDLVK_LSHIFT);
+ BM(BM_SLOT_1, SDLVK_1);
+ BM(BM_SLOT_2, SDLVK_2);
+ BM(BM_SLOT_3, SDLVK_3);
+ BM(BM_SLOT_4, SDLVK_4);
+ BM(BM_SLOT_5, SDLVK_5);
+ BM(BM_SLOT_6, SDLVK_6);
+ BM(BM_SLOT_7, SDLVK_7);
+ BM(BM_SLOT_8, SDLVK_8);
+ BM(BM_SLOT_9, SDLVK_9);
+ BM(BM_CONTAINER_QUICKMOVE, SDLVK_LSHIFT);
+ BM(BM_TOGGLEGUI, SDLVK_F1);
+ BM(BM_SCREENSHOT, SDLVK_F2);
+ BM(BM_TOGGLEDEBUG, SDLVK_F3);
+ BM(BM_TOGGLEAO, SDLVK_F4);
+ BM(BM_TOGGLE3RD, SDLVK_F5);
+ BM(BM_SLOT_L, SDLVK_y);
+ BM(BM_SLOT_R, SDLVK_u);
+ BM(BM_FLY_UP, SDLVK_c);
+ BM(BM_FLY_DOWN, SDLVK_x);
+ BM(BM_CHAT_CMD, SDLVK_SLASH);
#elif defined(USE_NATIVE_ANDROID)
// -- Original xperia play controls
- //KM(KM_FORWARD, AKEYCODE_DPAD_UP);
- //KM(KM_LEFT, AKEYCODE_DPAD_LEFT);
- //KM(KM_BACKWARD, AKEYCODE_DPAD_DOWN);
- //KM(KM_RIGHT, AKEYCODE_DPAD_RIGHT);
- //KM(KM_JUMP, AKEYCODE_DPAD_CENTER);
- //KM(KM_DESTROY, AKEYCODE_BUTTON_L1);
- //KM(KM_PLACE, AKEYCODE_BUTTON_R1);
- //KM(KM_MENU_UP, AKEYCODE_DPAD_UP);
- //KM(KM_MENU_DOWN, AKEYCODE_DPAD_DOWN);
- //KM(KM_MENU_LEFT, AKEYCODE_DPAD_LEFT);
- //KM(KM_MENU_RIGHT, AKEYCODE_DPAD_RIGHT);
- //KM(KM_MENU_OK, AKEYCODE_DPAD_CENTER);
- //KM(KM_MENU_CANCEL, AKEYCODE_BACK);
+ //BM(BM_FORWARD, AKEYCODE_DPAD_UP);
+ //BM(BM_LEFT, AKEYCODE_DPAD_LEFT);
+ //BM(BM_BACKWARD, AKEYCODE_DPAD_DOWN);
+ //BM(BM_RIGHT, AKEYCODE_DPAD_RIGHT);
+ //BM(BM_JUMP, AKEYCODE_DPAD_CENTER);
+ //BM(BM_DESTROY, AKEYCODE_BUTTON_L1);
+ //BM(BM_PLACE, AKEYCODE_BUTTON_R1);
+ //BM(BM_MENU_UP, AKEYCODE_DPAD_UP);
+ //BM(BM_MENU_DOWN, AKEYCODE_DPAD_DOWN);
+ //BM(BM_MENU_LEFT, AKEYCODE_DPAD_LEFT);
+ //BM(BM_MENU_RIGHT, AKEYCODE_DPAD_RIGHT);
+ //BM(BM_MENU_OK, AKEYCODE_DPAD_CENTER);
+ //BM(BM_MENU_CANCEL, AKEYCODE_BACK);
//custom
- //KM(KM_INVENTORY, AKEYCODE_BUTTON_Y);
- //KM(KM_SLOT_R, AKEYCODE_BACK);
- //KM(KM_SLOT_L, AKEYCODE_BUTTON_X);
- //KM(KM_FLY_UP, AKEYCODE_BUTTON_R1);
- //KM(KM_FLY_DOWN, AKEYCODE_BUTTON_L1);
+ //BM(BM_INVENTORY, AKEYCODE_BUTTON_Y);
+ //BM(BM_SLOT_R, AKEYCODE_BACK);
+ //BM(BM_SLOT_L, AKEYCODE_BUTTON_X);
+ //BM(BM_FLY_UP, AKEYCODE_BUTTON_R1);
+ //BM(BM_FLY_DOWN, AKEYCODE_BUTTON_L1);
//use controller input on android for now.
- KM(KM_FORWARD, AKEYCODE_W);
- KM(KM_LEFT, AKEYCODE_A);
- KM(KM_BACKWARD, AKEYCODE_S);
- KM(KM_RIGHT, AKEYCODE_D);
- KM(KM_JUMP, AKEYCODE_BUTTON_A);
- KM(KM_DESTROY, AKEYCODE_X);
- KM(KM_PLACE, AKEYCODE_C);
- KM(KM_MENU_UP, AKEYCODE_DPAD_UP);
- KM(KM_MENU_DOWN, AKEYCODE_DPAD_DOWN);
- KM(KM_MENU_LEFT, AKEYCODE_DPAD_LEFT);
- KM(KM_MENU_RIGHT, AKEYCODE_DPAD_RIGHT);
- KM(KM_MENU_TAB_LEFT, AKEYCODE_BUTTON_L1);
- KM(KM_MENU_TAB_RIGHT, AKEYCODE_BUTTON_R1);
- KM(KM_MENU_OK, AKEYCODE_ENTER);
- KM(KM_MENU_CANCEL, AKEYCODE_BUTTON_B);
- KM(KM_MENU_PAUSE, AKEYCODE_BUTTON_START);
+ BM(BM_FORWARD, AKEYCODE_W);
+ BM(BM_LEFT, AKEYCODE_A);
+ BM(BM_BACKWARD, AKEYCODE_S);
+ BM(BM_RIGHT, AKEYCODE_D);
+ BM(BM_JUMP, AKEYCODE_BUTTON_A);
+ BM(BM_DESTROY, AKEYCODE_X);
+ BM(BM_PLACE, AKEYCODE_C);
+ BM(BM_MENU_UP, AKEYCODE_DPAD_UP);
+ BM(BM_MENU_DOWN, AKEYCODE_DPAD_DOWN);
+ BM(BM_MENU_LEFT, AKEYCODE_DPAD_LEFT);
+ BM(BM_MENU_RIGHT, AKEYCODE_DPAD_RIGHT);
+ BM(BM_MENU_TAB_LEFT, AKEYCODE_BUTTON_L1);
+ BM(BM_MENU_TAB_RIGHT, AKEYCODE_BUTTON_R1);
+ BM(BM_MENU_OK, AKEYCODE_ENTER);
+ BM(BM_MENU_CANCEL, AKEYCODE_BUTTON_B);
+ BM(BM_MENU_PAUSE, AKEYCODE_BUTTON_START);
// custom
- KM(KM_SLOT_L, AKEYCODE_BUTTON_L1);
- KM(KM_SLOT_R, AKEYCODE_BUTTON_R1);
- KM(KM_DROP, AKEYCODE_Q);
- KM(KM_CHAT, AKEYCODE_T);
- KM(KM_FOG, AKEYCODE_F);
- KM(KM_INVENTORY, AKEYCODE_BUTTON_Y);
- KM(KM_SNEAK, AKEYCODE_SHIFT_LEFT);
- KM(KM_SLOT_1, AKEYCODE_1);
- KM(KM_SLOT_2, AKEYCODE_2);
- KM(KM_SLOT_3, AKEYCODE_3);
- KM(KM_SLOT_4, AKEYCODE_4);
- KM(KM_SLOT_5, AKEYCODE_5);
- KM(KM_SLOT_6, AKEYCODE_6);
- KM(KM_SLOT_7, AKEYCODE_7);
- KM(KM_SLOT_8, AKEYCODE_8);
- KM(KM_SLOT_9, AKEYCODE_9);
- KM(KM_CONTAINER_QUICKMOVE, AKEYCODE_BUTTON_Y);
- KM(KM_CONTAINER_SPLIT, AKEYCODE_BUTTON_X);
- KM(KM_TOGGLEGUI, AKEYCODE_F1);
- KM(KM_SCREENSHOT, AKEYCODE_F2);
- KM(KM_TOGGLEDEBUG, AKEYCODE_F3);
- KM(KM_TOGGLEAO, AKEYCODE_F4);
- KM(KM_TOGGLE3RD, AKEYCODE_F5);
- KM(KM_FLY_UP, AKEYCODE_C);
- KM(KM_FLY_DOWN, AKEYCODE_X);
- KM(KM_CHAT_CMD, AKEYCODE_SLASH);
+ BM(BM_SLOT_L, AKEYCODE_BUTTON_L1);
+ BM(BM_SLOT_R, AKEYCODE_BUTTON_R1);
+ BM(BM_DROP, AKEYCODE_Q);
+ BM(BM_CHAT, AKEYCODE_T);
+ BM(BM_FOG, AKEYCODE_F);
+ BM(BM_INVENTORY, AKEYCODE_BUTTON_Y);
+ BM(BM_SNEAK, AKEYCODE_SHIFT_LEFT);
+ BM(BM_SLOT_1, AKEYCODE_1);
+ BM(BM_SLOT_2, AKEYCODE_2);
+ BM(BM_SLOT_3, AKEYCODE_3);
+ BM(BM_SLOT_4, AKEYCODE_4);
+ BM(BM_SLOT_5, AKEYCODE_5);
+ BM(BM_SLOT_6, AKEYCODE_6);
+ BM(BM_SLOT_7, AKEYCODE_7);
+ BM(BM_SLOT_8, AKEYCODE_8);
+ BM(BM_SLOT_9, AKEYCODE_9);
+ BM(BM_CONTAINER_QUICKMOVE, AKEYCODE_BUTTON_Y);
+ BM(BM_CONTAINER_SPLIT, AKEYCODE_BUTTON_X);
+ BM(BM_TOGGLEGUI, AKEYCODE_F1);
+ BM(BM_SCREENSHOT, AKEYCODE_F2);
+ BM(BM_TOGGLEDEBUG, AKEYCODE_F3);
+ BM(BM_TOGGLEAO, AKEYCODE_F4);
+ BM(BM_TOGGLE3RD, AKEYCODE_F5);
+ BM(BM_FLY_UP, AKEYCODE_C);
+ BM(BM_FLY_DOWN, AKEYCODE_X);
+ BM(BM_CHAT_CMD, AKEYCODE_SLASH);
#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
- }
+#undef BM
+
+#define BTN(idx,code) m_buttonMappings[idx].info.controllerButtonId = code
+ BTN(BM_TOGGLEDEBUG, GameController::BUTTON_GUIDE);
+ BTN(BM_JUMP, GameController::BUTTON_A);
+ BTN(BM_MENU_UP, GameController::BUTTON_DPAD_UP);
+ BTN(BM_MENU_DOWN, GameController::BUTTON_DPAD_DOWN);
+ BTN(BM_MENU_LEFT, GameController::BUTTON_DPAD_LEFT);
+ BTN(BM_MENU_RIGHT, GameController::BUTTON_DPAD_RIGHT);
+ BTN(BM_MENU_TAB_LEFT, GameController::BUTTON_LEFTSHOULDER);
+ BTN(BM_MENU_TAB_RIGHT, GameController::BUTTON_RIGHTSHOULDER);
+ BTN(BM_MENU_OK, GameController::BUTTON_A);
+ BTN(BM_MENU_CANCEL, GameController::BUTTON_B);
+ BTN(BM_MENU_PAUSE, GameController::BUTTON_START);
+ BTN(BM_DROP, GameController::BUTTON_B);
+ BTN(BM_CHAT, GameController::BUTTON_BACK);
+ BTN(BM_INVENTORY, GameController::BUTTON_Y);
+ BTN(BM_SNEAK, GameController::BUTTON_RIGHTSTICK);
+ BTN(BM_CONTAINER_QUICKMOVE, GameController::BUTTON_Y);
+ BTN(BM_CONTAINER_SPLIT, GameController::BUTTON_X);
+ BTN(BM_TOGGLE3RD, GameController::BUTTON_LEFTSTICK);
+ BTN(BM_SLOT_L, GameController::BUTTON_LEFTSHOULDER);
+ BTN(BM_SLOT_R, GameController::BUTTON_RIGHTSHOULDER);
+ BTN(BM_FLY_UP, GameController::BUTTON_A);
+ BTN(BM_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..c38e42eeb 100644
--- a/source/client/options/Options.hpp
+++ b/source/client/options/Options.hpp
@@ -15,73 +15,103 @@
#include
#include