diff --git a/platforms/android/main.cpp b/platforms/android/main.cpp index 802697829..d65230199 100644 --- a/platforms/android/main.cpp +++ b/platforms/android/main.cpp @@ -406,7 +406,6 @@ void android_main(struct android_app* state) { engine.androidApp = state; engine.ninecraftApp = new NinecraftApp; - engine.ninecraftApp->m_pPlatform = &g_AppPlatform; while (1) { diff --git a/platforms/ios/NBCViewController.mm b/platforms/ios/NBCViewController.mm index ce24ded9d..67de31f22 100644 --- a/platforms/ios/NBCViewController.mm +++ b/platforms/ios/NBCViewController.mm @@ -260,7 +260,6 @@ - (void)initView } App *app = self->_app; - app->m_pPlatform = self->_context->platform; app->init(); /*var1 = app->field_10; diff --git a/platforms/sdl/sdl1/main.cpp b/platforms/sdl/sdl1/main.cpp index ee2a6917d..f6db7b898 100644 --- a/platforms/sdl/sdl1/main.cpp +++ b/platforms/sdl/sdl1/main.cpp @@ -36,11 +36,15 @@ typedef AppPlatform_sdl1_desktop UsedAppPlatform; static float g_fPointToPixelScale = 1.0f; -UsedAppPlatform* g_pAppPlatform; NinecraftApp* g_pApp; SDL_Surface* screen = NULL; +static UsedAppPlatform* getPlatform() +{ + return static_cast(AppPlatform::singleton()); +} + static void initPlatform() { #ifdef XENON @@ -155,7 +159,7 @@ static void handle_events() } } - g_pAppPlatform->handleKeyEvent(event); + getPlatform()->handleKeyEvent(event); break; } case SDL_JOYBUTTONDOWN: @@ -166,7 +170,7 @@ static void handle_events() { g_pApp->pauseGame() || g_pApp->resumeGame(); } - g_pAppPlatform->handleControllerButtonEvent(event.jbutton.which, event.jbutton.button, event.jbutton.state); + getPlatform()->handleControllerButtonEvent(event.jbutton.which, event.jbutton.button, event.jbutton.state); break; } case SDL_MOUSEBUTTONDOWN: @@ -186,11 +190,11 @@ static void handle_events() float x = event.motion.x * scale; float y = event.motion.y * scale; Mouse::feed(MOUSE_BUTTON_NONE, false, x, y); - g_pAppPlatform->setMouseDiff(event.motion.xrel * scale, event.motion.yrel * scale); + getPlatform()->setMouseDiff(event.motion.xrel * scale, event.motion.yrel * scale); break; } case SDL_JOYAXISMOTION: - g_pAppPlatform->handleControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); + getPlatform()->handleControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); break; case SDL_VIDEORESIZE: { @@ -243,7 +247,7 @@ static void main_loop() { g_pApp->saveOptions(); delete g_pApp; - delete g_pAppPlatform; + delete getPlatform(); teardown(); exit(EXIT_SUCCESS); } @@ -292,11 +296,10 @@ int main(int argc, char* argv[]) createFolderIfNotExists(storagePath.c_str()); //LOG_I("Initializing AppPlatform..."); - g_pAppPlatform = new UsedAppPlatform(storagePath, screen); - g_pAppPlatform->m_externalStorageDir = storagePath; + UsedAppPlatform* appPlatform = new UsedAppPlatform(storagePath, screen); + appPlatform->m_externalStorageDir = storagePath; //LOG_I("Initializing NinecraftApp..."); g_pApp = new NinecraftApp; - g_pApp->m_pPlatform = g_pAppPlatform; g_pApp->init(); resize(); diff --git a/platforms/sdl/sdl2/main.cpp b/platforms/sdl/sdl2/main.cpp index dc6aca02e..b007c3de6 100644 --- a/platforms/sdl/sdl2/main.cpp +++ b/platforms/sdl/sdl2/main.cpp @@ -25,12 +25,16 @@ typedef AppPlatform_sdl2_desktop UsedAppPlatform; static float g_fPointToPixelScale = 1.0f; -UsedAppPlatform *g_pAppPlatform; NinecraftApp *g_pApp; SDL_Window *window = NULL; SDL_GLContext glContext = NULL; +static UsedAppPlatform* getPlatform() +{ + return static_cast(AppPlatform::singleton()); +} + static void preInitGraphics() { #if MCE_GFX_API_OGL @@ -194,7 +198,7 @@ static void handle_events() g_pApp->handleCharInput('\b'); } - if (g_pAppPlatform->controlPressed()) + if (getPlatform()->controlPressed()) { // Copy and pasting if (event.key.keysym.sym == SDLK_v && event.key.state == SDL_PRESSED) @@ -204,7 +208,7 @@ static void handle_events() } } - g_pAppPlatform->handleKeyEvent(event); + getPlatform()->handleKeyEvent(event); break; } case SDL_CONTROLLERBUTTONDOWN: @@ -215,7 +219,7 @@ static void handle_events() { g_pApp->pauseGame() || g_pApp->resumeGame(); } - g_pAppPlatform->handleControllerButtonEvent(event.cbutton.which, event.cbutton.button, event.cbutton.state); + getPlatform()->handleControllerButtonEvent(event.cbutton.which, event.cbutton.button, event.cbutton.state); break; } case SDL_MOUSEBUTTONDOWN: @@ -242,7 +246,7 @@ static void handle_events() float y = event.motion.y * scale; 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); + getPlatform()->setMouseDiff(event.motion.xrel * scale, event.motion.yrel * scale); } break; } @@ -255,7 +259,7 @@ static void handle_events() break; } case SDL_CONTROLLERAXISMOTION: - g_pAppPlatform->handleControllerAxisEvent(event.caxis.which, event.caxis.axis, event.caxis.value); + getPlatform()->handleControllerAxisEvent(event.caxis.which, event.caxis.axis, event.caxis.value); break; case SDL_FINGERDOWN: case SDL_FINGERUP: @@ -280,10 +284,10 @@ static void handle_events() break; } case SDL_CONTROLLERDEVICEADDED: - g_pAppPlatform->gameControllerAdded(event.cdevice.which); + getPlatform()->gameControllerAdded(event.cdevice.which); break; case SDL_CONTROLLERDEVICEREMOVED: - g_pAppPlatform->gameControllerRemoved(event.cdevice.which); + getPlatform()->gameControllerRemoved(event.cdevice.which); break; case SDL_WINDOWEVENT: { @@ -355,7 +359,7 @@ static EM_BOOL main_loop(double time, void *user_data) { g_pApp->saveOptions(); delete g_pApp; - delete g_pAppPlatform; + delete getPlatform(); teardown(); // Stop Looping return EM_FALSE; @@ -438,10 +442,9 @@ int main(int argc, char *argv[]) createFolderIfNotExists(storagePath.c_str()); // Start MCPE - g_pAppPlatform = new UsedAppPlatform(storagePath, window); - g_pAppPlatform->m_externalStorageDir = storagePath; + UsedAppPlatform* appPlatform = new UsedAppPlatform(storagePath, window); + appPlatform->m_externalStorageDir = storagePath; g_pApp = new NinecraftApp; - g_pApp->m_pPlatform = g_pAppPlatform; g_pApp->init(); // Set Size diff --git a/platforms/windows/main.cpp b/platforms/windows/main.cpp index e68bd2aff..064dc5db2 100644 --- a/platforms/windows/main.cpp +++ b/platforms/windows/main.cpp @@ -153,7 +153,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine goto _cleanup; g_pApp = new NinecraftApp; - g_pApp->m_pPlatform = &g_AppPlatform; // Storage Directory { diff --git a/platforms/xdk360/main.cpp b/platforms/xdk360/main.cpp index 6e932bce3..5c5596bba 100644 --- a/platforms/xdk360/main.cpp +++ b/platforms/xdk360/main.cpp @@ -54,7 +54,6 @@ void __cdecl main() goto _cleanup; g_pApp = new NinecraftApp; - g_pApp->m_pPlatform = &g_AppPlatform; g_AppPlatform.m_externalStorageDir = "savedrive:"; // initialize the app diff --git a/source/client/app/App.hpp b/source/client/app/App.hpp index 46d1455db..22e3dbe1f 100644 --- a/source/client/app/App.hpp +++ b/source/client/app/App.hpp @@ -17,7 +17,6 @@ class App : public AppPlatformListener App() { m_bWantToQuit = false; - m_pPlatform = nullptr; } public: @@ -30,8 +29,6 @@ class App : public AppPlatformListener void destroy(); void draw(); void loadState(void*, int); - AppPlatform* platform() { return m_pPlatform; } - const AppPlatform* platform() const { return m_pPlatform; } void quit(); void saveState(void**, int); bool wantToQuit(); @@ -43,7 +40,5 @@ class App : public AppPlatformListener int field_8; int field_C; int field_10; - - AppPlatform* m_pPlatform; }; diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 2ee8c5b2a..1e4993f02 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -206,7 +206,7 @@ void Minecraft::_reloadInput() { m_pInputHolder = new CustomInputHolder( new KeyboardInput(getOptions()), - new MouseTurnInput(this), + new MouseTurnInput(), new MouseBuildInput() ); } @@ -224,7 +224,7 @@ void Minecraft::_reloadInput() int Minecraft::getLicenseId() { if (m_licenseID < 0) - m_licenseID = m_pPlatform->checkLicense(); + m_licenseID = AppPlatform::singleton()->checkLicense(); return m_licenseID; } @@ -244,7 +244,7 @@ void Minecraft::releaseMouse() // the mouse handler, but we don't have access to the platform // from there! recenterMouse(); - platform()->setMouseGrabbed(false); + AppPlatform::singleton()->setMouseGrabbed(false); } void Minecraft::grabMouse() @@ -261,7 +261,7 @@ void Minecraft::grabMouse() if (useController() || isTouchscreen()) return; // don't actually try to grab the mouse - platform()->setMouseGrabbed(true); + AppPlatform::singleton()->setMouseGrabbed(true); } void Minecraft::recenterMouse() @@ -269,7 +269,7 @@ void Minecraft::recenterMouse() if (useController() || isTouchscreen()) return; - platform()->recenterMouse(); + AppPlatform::singleton()->recenterMouse(); } void Minecraft::setScreen(Screen* pScreen) @@ -343,13 +343,13 @@ void Minecraft::setScreen(Screen* pScreen) void Minecraft::saveOptions() { - if (platform()->hasFileSystemAccess()) + if (AppPlatform::singleton()->hasFileSystemAccess()) getOptions()->save().join(); } void Minecraft::saveOptionsAsync() { - if (platform()->hasFileSystemAccess()) + if (AppPlatform::singleton()->hasFileSystemAccess()) getOptions()->save(); } @@ -383,7 +383,7 @@ bool Minecraft::useSplitControls() const bool Minecraft::useController() const { - return m_pPlatform->hasGamepad() && getOptions()->m_bUseController.get(); + return AppPlatform::singleton()->hasGamepad() && getOptions()->m_bUseController.get(); } void Minecraft::setGameMode(GameType gameType) @@ -576,7 +576,7 @@ void Minecraft::tickInput() { // @HACK: on SDL1, we don't recenter the mouse every tick, meaning the user can // unintentionally click the hotbar while swinging their fist - if (platform()->getRecenterMouseEveryTick() || m_pScreen) + if (AppPlatform::singleton()->getRecenterMouseEveryTick() || m_pScreen) m_pGui->handleClick(1, Mouse::getX(), Mouse::getY()); } @@ -697,7 +697,7 @@ void Minecraft::tickMouse() if (useController() || isTouchscreen()) return; // don't actually try to recenter the mouse - if (platform()->getRecenterMouseEveryTick()) // just for SDL1 + if (AppPlatform::singleton()->getRecenterMouseEveryTick()) // just for SDL1 recenterMouse(); } @@ -896,7 +896,7 @@ void Minecraft::update() { m_timer.advanceTime(isGamePaused() && m_pLevel); - platform()->tick(); + AppPlatform::singleton()->tick(); if (m_pRakNetInstance && m_pNetEventCallback) { diff --git a/source/client/app/NinecraftApp.cpp b/source/client/app/NinecraftApp.cpp index f7f8294fe..c44cc876a 100644 --- a/source/client/app/NinecraftApp.cpp +++ b/source/client/app/NinecraftApp.cpp @@ -57,8 +57,8 @@ void NinecraftApp::_initOptions() // Must be loaded before options, certain options states are forced based on this _reloadPatchData(); - if (platform()->hasFileSystemAccess()) - m_pOptions = new Options(this, platform()->m_externalStorageDir); + if (AppPlatform::singleton()->hasFileSystemAccess()) + m_pOptions = new Options(this, AppPlatform::singleton()->m_externalStorageDir); else m_pOptions = new Options(this); @@ -101,8 +101,8 @@ void NinecraftApp::_initRenderMaterials() void NinecraftApp::_initInput() { - m_bIsTouchscreen = platform()->isTouchscreen(); - getOptions()->m_bUseController.set(platform()->hasGamepad()); + m_bIsTouchscreen = AppPlatform::singleton()->isTouchscreen(); + getOptions()->m_bUseController.set(AppPlatform::singleton()->hasGamepad()); getOptions()->loadControls(); _reloadInput(); } @@ -195,7 +195,7 @@ void NinecraftApp::_initAll() #ifdef DEMO m_pLevelStorageSource = new MemoryLevelStorageSource; #else - m_pLevelStorageSource = new ExternalFileLevelStorageSource(platform()->m_externalStorageDir); + m_pLevelStorageSource = new ExternalFileLevelStorageSource(AppPlatform::singleton()->m_externalStorageDir); #endif _initInput(); @@ -207,8 +207,8 @@ void NinecraftApp::_initAll() m_pParticleEngine = new ParticleEngine(m_pLevel, m_pTextures); m_pUser = new User(getOptions()->m_playerName.get(), ""); - platform()->initSoundSystem(); - m_pSoundEngine = new SoundEngine(platform()->getSoundSystem(), SOUND_MAX_DISTANCE); + AppPlatform::singleton()->initSoundSystem(); + m_pSoundEngine = new SoundEngine(AppPlatform::singleton()->getSoundSystem(), SOUND_MAX_DISTANCE); m_pSoundEngine->init(getOptions()); Language::singleton().init(getOptions()); @@ -334,8 +334,8 @@ void NinecraftApp::setupRenderer() void NinecraftApp::onGraphicsReset() { - platform()->_fireAppSuspended(); - platform()->_fireAppResumed(); + AppPlatform::singleton()->_fireAppSuspended(); + AppPlatform::singleton()->_fireAppResumed(); } void NinecraftApp::teardown() @@ -343,7 +343,7 @@ void NinecraftApp::teardown() teardownRenderer(); Resource::teardownLoaders(); // Stop our SoundSystem before we nuke our sound buffers and cause it to implode - platform()->getSoundSystem()->stopEngine(); + AppPlatform::singleton()->getSoundSystem()->stopEngine(); } void NinecraftApp::teardownRenderer() @@ -367,7 +367,7 @@ void NinecraftApp::update() if (getOptions()->m_bUseController.get()) { - GameControllerHandler* pControllerHandler = platform()->getGameControllerHandler(); + GameControllerHandler* pControllerHandler = AppPlatform::singleton()->getGameControllerHandler(); if (pControllerHandler) { pControllerHandler->refresh(); diff --git a/source/client/gui/Screen.cpp b/source/client/gui/Screen.cpp index 5c029da2b..e4652d203 100644 --- a/source/client/gui/Screen.cpp +++ b/source/client/gui/Screen.cpp @@ -416,7 +416,7 @@ void Screen::pointerPressed(const MenuPointer& pointer, MouseButtonType btn) // // @TODO: old code? why is this only doing this for Android? how does this work on iOS? #ifdef USE_NATIVE_ANDROID // if the keyboard is shown: - if (m_pMinecraft->platform()->getKeyboardUpOffset()) + if (AppPlatform::singleton()->getKeyboardUpOffset()) { // if there are none focused at the moment: bool areAnyFocused = false; @@ -426,7 +426,7 @@ void Screen::pointerPressed(const MenuPointer& pointer, MouseButtonType btn) // areAnyFocused = true; if (!areAnyFocused) - m_pMinecraft->platform()->hideKeyboard(0); + AppPlatform::singleton()->hideKeyboard(0); } #endif #endif @@ -567,7 +567,7 @@ bool Screen::prevTab() int Screen::getYOffset() { #ifdef USE_NATIVE_ANDROID - int keybOffset = m_pMinecraft->platform()->getKeyboardUpOffset(); + int keybOffset = AppPlatform::singleton()->getKeyboardUpOffset(); if (!keybOffset) return 0; diff --git a/source/client/gui/components/TextBox.cpp b/source/client/gui/components/TextBox.cpp index 895de827f..a2bbb2963 100644 --- a/source/client/gui/components/TextBox.cpp +++ b/source/client/gui/components/TextBox.cpp @@ -40,7 +40,7 @@ TextBox::TextBox(Screen* parent, int x, int y, int width, int height, const std: TextBox::~TextBox() { - m_pParent->m_pMinecraft->platform()->hideKeyboard(0); + AppPlatform::singleton()->hideKeyboard(0); } void TextBox::_onSelectedChanged() @@ -72,11 +72,11 @@ void TextBox::_onFocusChanged() keyboard.defaultText = m_text; - m_pParent->m_pMinecraft->platform()->showKeyboard(0, keyboard); + AppPlatform::singleton()->showKeyboard(0, keyboard); } else { - m_pParent->m_pMinecraft->platform()->hideKeyboard(0); + AppPlatform::singleton()->hideKeyboard(0); } // don't actually hide the keyboard when unfocusing diff --git a/source/client/gui/components/WorldSelectionList.cpp b/source/client/gui/components/WorldSelectionList.cpp index 6765f1afd..96fdd477b 100644 --- a/source/client/gui/components/WorldSelectionList.cpp +++ b/source/client/gui/components/WorldSelectionList.cpp @@ -192,7 +192,7 @@ void WorldSelectionList::commit() std::vector vs; vs.push_back(item.m_levelName); - vs.push_back(m_pMinecraft->platform()->getDateString(item.m_lastPlayed)); + vs.push_back(AppPlatform::singleton()->getDateString(item.m_lastPlayed)); vs.push_back(item.m_fileName); vs.push_back(GameTypeConv::GameTypeToNonLocString(item.m_gameType)); std::stringstream ss; diff --git a/source/client/gui/screens/InvalidLicenseScreen.cpp b/source/client/gui/screens/InvalidLicenseScreen.cpp index 507338f9c..1d33976e6 100644 --- a/source/client/gui/screens/InvalidLicenseScreen.cpp +++ b/source/client/gui/screens/InvalidLicenseScreen.cpp @@ -28,7 +28,7 @@ void InvalidLicenseScreen::_buttonClicked(Button* pButton) if (pButton->getId() == m_btnBuy.getId()) { - m_pMinecraft->platform()->buyGame(); + AppPlatform::singleton()->buyGame(); } } diff --git a/source/client/gui/screens/OptionsScreen.cpp b/source/client/gui/screens/OptionsScreen.cpp index 2490863a9..496411985 100644 --- a/source/client/gui/screens/OptionsScreen.cpp +++ b/source/client/gui/screens/OptionsScreen.cpp @@ -283,8 +283,8 @@ void OptionsScreen::setWidthAllButtons(int width) void OptionsScreen::init() { - m_pMinecraft->platform()->showDialog(AppPlatform::DLG_OPTIONS); - m_pMinecraft->platform()->createUserInput(); + AppPlatform::singleton()->showDialog(AppPlatform::DLG_OPTIONS); + AppPlatform::singleton()->createUserInput(); bool crampedMode = isCramped(); diff --git a/source/client/gui/screens/RenameMPLevelScreen.cpp b/source/client/gui/screens/RenameMPLevelScreen.cpp index 0e33c1e58..4da886df7 100644 --- a/source/client/gui/screens/RenameMPLevelScreen.cpp +++ b/source/client/gui/screens/RenameMPLevelScreen.cpp @@ -15,19 +15,19 @@ RenameMPLevelScreen::RenameMPLevelScreen(const std::string& levelName) : m_level void RenameMPLevelScreen::init() { - m_pMinecraft->platform()->showDialog(AppPlatform::DLG_RENAME_MP_WORLD); - m_pMinecraft->platform()->createUserInput(); + AppPlatform::singleton()->showDialog(AppPlatform::DLG_RENAME_MP_WORLD); + AppPlatform::singleton()->createUserInput(); } void RenameMPLevelScreen::render(float f) { - int userInputStatus = m_pMinecraft->platform()->getUserInputStatus(); + int userInputStatus = AppPlatform::singleton()->getUserInputStatus(); if (userInputStatus < 0) return; if (userInputStatus == 1) { - std::vector input = m_pMinecraft->platform()->getUserInput(); + std::vector input = AppPlatform::singleton()->getUserInput(); if (input.size() > 0 && !input[0].empty()) { m_pMinecraft->getLevelSource()->renameLevel(m_levelName, input[0]); diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp index 2864633c7..ef2793e3c 100644 --- a/source/client/gui/screens/SelectWorldScreen.cpp +++ b/source/client/gui/screens/SelectWorldScreen.cpp @@ -102,7 +102,7 @@ void SelectWorldScreen::tick() if (field_130 == 1) { // poll the user status to get details about the world name and seed - int userInputStatus = m_pMinecraft->platform()->getUserInputStatus(); + int userInputStatus = AppPlatform::singleton()->getUserInputStatus(); if (userInputStatus < 0) return; @@ -113,7 +113,7 @@ void SelectWorldScreen::tick() return; } - std::vector userInput = m_pMinecraft->platform()->getUserInput(); + std::vector userInput = AppPlatform::singleton()->getUserInput(); std::string levelNickname = Util::stringTrim(userInput[0]); std::string levelUniqueName = levelNickname; @@ -209,8 +209,8 @@ void SelectWorldScreen::_buttonClicked(Button* pButton) #ifndef ORIGINAL_CODE m_pMinecraft->getScreenChooser()->pushCreateWorldScreen(this); #else - m_pMinecraft->platform()->showDialog(AppPlatform::DLG_CREATE_WORLD); - m_pMinecraft->platform()->createUserInput(); + AppPlatform::singleton()->showDialog(AppPlatform::DLG_CREATE_WORLD); + AppPlatform::singleton()->createUserInput(); m_walkAnimPos = true; #endif } diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp index 4d2dc03ac..fbd49ad82 100644 --- a/source/client/gui/screens/StartMenuScreen.cpp +++ b/source/client/gui/screens/StartMenuScreen.cpp @@ -51,7 +51,7 @@ void StartMenuScreen::_updateLicense() } else { - m_pMinecraft->setScreen(new InvalidLicenseScreen(licenseID, m_pMinecraft->platform()->hasBuyButtonWhenInvalidLicense())); + m_pMinecraft->setScreen(new InvalidLicenseScreen(licenseID, AppPlatform::singleton()->hasBuyButtonWhenInvalidLicense())); } } @@ -78,7 +78,7 @@ void StartMenuScreen::_buttonClicked(Button* pButton) #endif #ifdef DEMO - m_pMinecraft->platform()->buyGame(); + AppPlatform::singleton()->buyGame(); #else m_pMinecraft->quit(); #endif diff --git a/source/client/gui/screens/inventory/ContainerScreen.cpp b/source/client/gui/screens/inventory/ContainerScreen.cpp index 46f241ead..0c035f099 100644 --- a/source/client/gui/screens/inventory/ContainerScreen.cpp +++ b/source/client/gui/screens/inventory/ContainerScreen.cpp @@ -282,7 +282,7 @@ void ContainerScreen::slotClicked(Slot* slot, int index, MouseButtonType button, void ContainerScreen::slotClicked(const MenuPointer& pointer, MouseButtonType button) { - slotClicked(pointer, button, m_pMinecraft->m_pPlatform->shiftPressed()); + slotClicked(pointer, button, AppPlatform::singleton()->shiftPressed()); } void ContainerScreen::keyPressed(int keyCode) diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp index 726edd3e2..047053448 100644 --- a/source/client/options/Options.cpp +++ b/source/client/options/Options.cpp @@ -54,12 +54,12 @@ void Options::_initDefaultValues() loadControls(); } -static UITheme GetDefaultUiTheme(Minecraft* mc) +static UITheme GetDefaultUiTheme() { #if MC_PLATFORM_XBOX360 return UI_CONSOLE; #else - return mc->platform()->isTouchscreen() ? UI_POCKET : UI_JAVA; + return AppPlatform::singleton()->isTouchscreen() ? UI_POCKET : UI_JAVA; #endif } @@ -82,7 +82,7 @@ Options::Options(Minecraft* mc, const std::string& folderPath) : , m_gamma("gfx_gamma", "options.gamma", 0.50f) , m_playerName("mp_username", "options.username", "Steve") , m_serverVisibleDefault("mp_server_visible_default", "options.serverVisibleDefault", true) - , m_autoJump("ctrl_autojump", "options.autoJump", mc->platform()->isTouchscreen()) + , m_autoJump("ctrl_autojump", "options.autoJump", AppPlatform::singleton()->isTouchscreen()) , m_debugText("info_debugtext", "options.debugText", false) , m_blockOutlines("gfx_blockoutlines", "options.blockOutlines", false) , m_fancyGrass("gfx_fancygrass", "options.fancyGrass", true) @@ -92,7 +92,7 @@ Options::Options(Minecraft* mc, const std::string& folderPath) : , m_dynamicHand("gfx_dynamichand", "options.dynamicHand", false) , m_menuPanorama("misc_menupano", "options.menuPanorama", true) , m_lang("gfx_lang", "options.lang", "en_us") - , m_uiTheme("gfx_uitheme", "options.uiTheme", GetDefaultUiTheme(m_pMinecraft), ValuesBuilder().add("options.uiTheme.pocket").add("options.uiTheme.java").add("options.uiTheme.console")) + , m_uiTheme("gfx_uitheme", "options.uiTheme", GetDefaultUiTheme(), ValuesBuilder().add("options.uiTheme.pocket").add("options.uiTheme.java").add("options.uiTheme.console")) , m_logoType("gfx_logotype", "options.logoType", LOGO_AUTO, ValuesBuilder().add("options.logoType.auto").add("options.logoType.pocket").add("options.logoType.java").add("options.logoType.console").add("options.logoType.xbox360").add("options.logoType.logo3d")) , m_hudSize("gfx_hudsize", "options.hudSize", HUD_SIZE_2) , m_classicCrafting("gfx_classiccrafting", "options.classicCrafting", true) diff --git a/source/client/player/input/MouseTurnInput.cpp b/source/client/player/input/MouseTurnInput.cpp index b67d1e9f8..921cad256 100644 --- a/source/client/player/input/MouseTurnInput.cpp +++ b/source/client/player/input/MouseTurnInput.cpp @@ -11,17 +11,16 @@ constexpr float C_SENSITIVITY = 1.0f; -MouseTurnInput::MouseTurnInput(Minecraft* pMC) +MouseTurnInput::MouseTurnInput() { - m_pMinecraft = pMC; m_lastX = m_lastY = -1; } Vec2 MouseTurnInput::getTurnDelta() { int deltaX = 0, deltaY = 0; - m_pMinecraft->platform()->getMouseDiff(deltaX, deltaY); - m_pMinecraft->platform()->clearDiff(); + AppPlatform::singleton()->getMouseDiff(deltaX, deltaY); + AppPlatform::singleton()->clearDiff(); Vec2 d; d.x = C_SENSITIVITY * deltaX; diff --git a/source/client/player/input/MouseTurnInput.hpp b/source/client/player/input/MouseTurnInput.hpp index bd99e935f..c85dc0233 100644 --- a/source/client/player/input/MouseTurnInput.hpp +++ b/source/client/player/input/MouseTurnInput.hpp @@ -15,13 +15,11 @@ class Minecraft; class MouseTurnInput : public ITurnInput { public: - MouseTurnInput(Minecraft*); + MouseTurnInput(); Vec2 getTurnDelta() override; private: int m_lastX; int m_lastY; - - Minecraft* m_pMinecraft; }; diff --git a/source/client/renderer/LevelRenderer.cpp b/source/client/renderer/LevelRenderer.cpp index d85278176..30c72f219 100644 --- a/source/client/renderer/LevelRenderer.cpp +++ b/source/client/renderer/LevelRenderer.cpp @@ -1392,12 +1392,12 @@ void LevelRenderer::takePicture(TripodCamera* pCamera, Entity* pOwner) static char str[256]; // @HUH: This has the potential to overwrite a file #ifdef ORIGINAL_CODE - sprintf(str, "%s" C_HOME_PATH "img_%.4d.jpg", m_pMinecraft->platform()->m_externalStorageDir.c_str(), getTimeMs()); + sprintf(str, "%s" C_HOME_PATH "img_%.4d.jpg", AppPlatform::singleton()->m_externalStorageDir.c_str(), getTimeMs()); #else sprintf(str, "img_%.4d.png", getTimeMs()); #endif - m_pMinecraft->platform()->saveScreenshot(std::string(str), Minecraft::width, Minecraft::height); + AppPlatform::singleton()->saveScreenshot(std::string(str), Minecraft::width, Minecraft::height); } void LevelRenderer::addParticle(const std::string& name, const Vec3& pos, const Vec3& dir)