diff --git a/4J.Input/4J_Input.cpp b/4J.Input/4J_Input.cpp index b0946a810..8f6f880a8 100644 --- a/4J.Input/4J_Input.cpp +++ b/4J.Input/4J_Input.cpp @@ -534,3 +534,11 @@ bool C_4JInput::VerifyStrings(WCHAR ** /*pwStringA*/, int /*iStringC*/, int(*/*Func*/)(LPVOID, STRING_VERIFY_RESPONSE *), LPVOID /*lpParam*/) { return true; } void C_4JInput::CancelQueuedVerifyStrings(int(*/*Func*/)(LPVOID, STRING_VERIFY_RESPONSE *), LPVOID /*lpParam*/) {} void C_4JInput::CancelAllVerifyInProgress(void) {} + +float C_4JInput::GetMouseX() { + return (float)s_lastCursorX; +} + +float C_4JInput::GetMouseY() { + return (float)s_lastCursorY; +} \ No newline at end of file diff --git a/4J.Input/4J_Input.h b/4J.Input/4J_Input.h index 9ac5c55d1..b0120927b 100644 --- a/4J.Input/4J_Input.h +++ b/4J.Input/4J_Input.h @@ -131,6 +131,9 @@ public: void CancelAllVerifyInProgress(void); //bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput); + + float GetMouseX(); + float GetMouseY(); }; // Singleton diff --git a/Minecraft.Assets/Common/res/gui/furnace.png b/Minecraft.Assets/Common/res/gui/furnace.png index a5834e195..8527289e5 100644 Binary files a/Minecraft.Assets/Common/res/gui/furnace.png and b/Minecraft.Assets/Common/res/gui/furnace.png differ diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 80c75bad5..5684c065b 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -1,6 +1,7 @@ #include "Platform/stdafx.h" #include "Minecraft.h" #include "GameState/GameMode.h" +#include "UI/Screens/PauseScreen.h" #include "Utils/Timer.h" #include "Rendering/EntityRenderers/ProgressRenderer.h" #include "Rendering/LevelRenderer.h" @@ -423,7 +424,7 @@ void Minecraft::renderLoadingScreen() { // 4J Unused // testing stuff on vita just now -#ifdef __PSVITA__ +#if (defined (__PSVITA__) || defined (ENABLE_JAVA_GUIS)) ScreenSizeCalculator ssc(options, width, height); // xxx @@ -464,7 +465,7 @@ void Minecraft::renderLoadingScreen() glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1f); - Display::swapBuffers(); + // Display::swapBuffers(); // xxx RenderManager.Present(); #endif @@ -557,8 +558,9 @@ void Minecraft::setScreen(Screen *screen) } else if (player != NULL && !ui.GetMenuDisplayed(player->GetXboxPad()) && player->getHealth() <= 0) { - //screen = new DeathScreen(); - +#ifdef ENABLE_JAVA_GUIS + screen = new DeathScreen(); +#else // 4J Stu - If we exit from the death screen then we are saved as being dead. In the Java // game when you load the game you are still dead, but this is silly so only show the dead // screen if we have died during gameplay @@ -570,9 +572,10 @@ void Minecraft::setScreen(Screen *screen) { ui.NavigateToScene(player->GetXboxPad(),eUIScene_DeathMenu,NULL); } +#endif } - if (dynamic_cast(screen)!=NULL) + if (screen != NULL && dynamic_cast(screen)!=NULL) { options->renderDebug = false; gui->clearMessages(); @@ -595,29 +598,22 @@ void Minecraft::setScreen(Screen *screen) // 4J-PB - if a screen has been set, go into menu mode // it's possible that player doesn't exist here yet - /*if(screen!=NULL) +#ifdef ENABLE_JAVA_GUIS + if (screen!=NULL) { - if(player && player->GetXboxPad()!=-1) - { - InputManager.SetMenuDisplayed(player->GetXboxPad(),true); + if (player && player->GetXboxPad()!=-1) + { + InputManager.SetMenuDisplayed(player->GetXboxPad(),true); + } } else { - // set all - //InputManager.SetMenuDisplayed(XUSER_INDEX_ANY,true); + if(player && player->GetXboxPad()!=-1) + { + InputManager.SetMenuDisplayed(player->GetXboxPad(),false); + } } - } - else - { - if(player && player->GetXboxPad()!=-1) - { - InputManager.SetMenuDisplayed(player->GetXboxPad(),false); - } - else - { - //InputManager.SetMenuDisplayed(XUSER_INDEX_ANY,false); - } - }*/ +#endif } void Minecraft::checkGlError(const std::wstring& string) @@ -1434,6 +1430,9 @@ void Minecraft::run_middle() { localplayers[i]->ullButtonsPressed|=1LL<ullButtonsPressed|=1LL<updateEvents(); + } + ui.HandleGameTick(); setLocalPlayerIdx(ProfileManager.GetPrimaryPad()); @@ -1948,8 +1952,11 @@ void Minecraft::run_middle() MemSect(0); frames++; //pause = !isClientSide() && screen != NULL && screen->isPauseScreen(); - //pause = g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && app.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()); +#ifdef ENABLE_JAVA_GUIS + pause = g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && screen != nullptr && screen->isPauseScreen(); +#else pause = app.IsAppPaused(); +#endif #ifndef _CONTENT_PACKAGE while (System::nanoTime() >= lastTime + 1000000000) @@ -2098,9 +2105,14 @@ void Minecraft::stop() void Minecraft::pauseGame() { - if (screen != NULL) return; - - // setScreen(new PauseScreen()); // 4J - TODO put back in + if (screen != NULL) + { + setScreen(NULL); + return; + } +#ifdef ENABLE_JAVA_GUIS + setScreen(new PauseScreen()); // 4J - TODO put back in +#endif } void Minecraft::resize(int width, int height) @@ -2161,7 +2173,9 @@ void Minecraft::levelTickThreadInitFunc() // 4J - added bUpdateTextures, which is true if the actual renderer textures are to be updated - this will be true for the last time this tick runs with bFirst true void Minecraft::tick(bool bFirst, bool bUpdateTextures) { - int iPad=player->GetXboxPad(); + int iPad = -1; + if (player) + iPad = player->GetXboxPad(); //OutputDebugString("Minecraft::tick\n"); //4J-PB - only tick this player's stats @@ -2228,12 +2242,12 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) setScreen(NULL); } - if (screen != NULL) - { - player->missTime = 10000; - player->lastClickTick[0] = ticks + 10000; - player->lastClickTick[1] = ticks + 10000; - } + // if (screen != NULL) + // { + // player->missTime = 10000; + // player->lastClickTick[0] = ticks + 10000; + // player->lastClickTick[1] = ticks + 10000; + // } if (screen != NULL) { @@ -3371,7 +3385,11 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { std::shared_ptr player = std::dynamic_pointer_cast( Minecraft::GetInstance()->player ); ui.PlayUISFX(eSFX_Press); +#ifdef ENABLE_JAVA_GUIS + setScreen(new InventoryScreen(player)); +#else app.LoadInventoryMenu(iPad,player); +#endif } if((player->ullButtonsPressed&(1LL<isInputAllowed(MINECRAFT_ACTION_CRAFTING)) @@ -3410,7 +3428,9 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { app.DebugPrintf("PAUSE PRESS PROCESSING - ipad = %d, NavigateToScene\n",player->GetXboxPad()); ui.PlayUISFX(eSFX_Press); +#ifndef ENABLE_JAVA_GUIS ui.NavigateToScene(iPad, eUIScene_PauseMenu, NULL, eUILayer_Scene); +#endif } if((player->ullButtonsPressed&(1LL<isInputAllowed(MINECRAFT_ACTION_DROP)) @@ -3455,10 +3475,10 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) else { // 4J-PB - if (InputManager.GetValue(iPad, ACTION_MENU_CANCEL) > 0 && gameMode->isInputAllowed(ACTION_MENU_CANCEL)) - { - setScreen(NULL); - } + // if (InputManager.GetValue(iPad, ACTION_MENU_CANCEL) > 0 && gameMode->isInputAllowed(ACTION_MENU_CANCEL)) + // { + // setScreen(NULL); + // } } // monitor for keyboard input diff --git a/Minecraft.Client/Platform/Common/UI/UIController.cpp b/Minecraft.Client/Platform/Common/UI/UIController.cpp index e697b6369..3a7811ff7 100644 --- a/Minecraft.Client/Platform/Common/UI/UIController.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIController.cpp @@ -10,6 +10,7 @@ #include "../../Minecraft.World/Headers/net.minecraft.world.entity.boss.enderdragon.h" #include "../../Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.h" #include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h" +#include "../../Minecraft.Client/UI/Screens/TitleScreen.h" #include "UIFontData.h" #ifdef __PSVITA__ #include @@ -1585,6 +1586,9 @@ void UIController::NavigateToHomeMenu() else { ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_MainMenu); +#ifdef ENABLE_JAVA_GUIS + pMinecraft->setScreen(new TitleScreen()); +#endif } } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp index 207dc28a5..1a2d9fe11 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp @@ -1809,8 +1809,10 @@ void UIScene_MainMenu::tick() if(s_mainMenuTickCount % 60 == 1) { fprintf(stderr, "[MM] tick %d\n", s_mainMenuTickCount); fflush(stderr); } if(s_mainMenuTickCount == 90) // ~3 seconds at 30fps { +#ifndef ENABLE_JAVA_GUIS fprintf(stderr, "[Linux] Auto-starting trial world from MainMenu after %d ticks\n", s_mainMenuTickCount); LoadTrial(); +#endif return; } } diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index dee185522..673014470 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -585,25 +585,37 @@ void LocalPlayer::closeContainer() void LocalPlayer::openTextEdit(std::shared_ptr sign) { +#ifdef ENABLE_JAVA_GUIS + minecraft->setScreen(new TextEditScreen(sign)); + bool success = true; +#else bool success = app.LoadSignEntryMenu(GetXboxPad(), sign ); if( success ) ui.PlayUISFX(eSFX_Press); - //minecraft->setScreen(new TextEditScreen(sign)); +#endif } bool LocalPlayer::openContainer(std::shared_ptr container) { +#ifdef ENABLE_JAVA_GUIS + minecraft->setScreen(new ContainerScreen(inventory, container)); + bool success = true; +#else bool success = app.LoadContainerMenu(GetXboxPad(), inventory, container ); if( success ) ui.PlayUISFX(eSFX_Press); - //minecraft->setScreen(new ContainerScreen(inventory, container)); +#endif return success; } bool LocalPlayer::startCrafting(int x, int y, int z) { +#ifdef ENABLE_JAVA_GUIS + minecraft->setScreen(new CraftingScreen(inventory, level, x, y, z)); + bool success = true; +#else bool success = app.LoadCrafting3x3Menu(GetXboxPad(), std::dynamic_pointer_cast( shared_from_this() ), x, y, z ); if( success ) ui.PlayUISFX(eSFX_Press); +#endif //app.LoadXuiCraftMenu(0,inventory, level, x, y, z); - //minecraft->setScreen(new CraftingScreen(inventory, level, x, y, z)); return success; } @@ -617,17 +629,26 @@ bool LocalPlayer::startEnchanting(int x, int y, int z) bool LocalPlayer::startRepairing(int x, int y, int z) { +#ifdef ENABLE_JAVA_GUIS + // minecraft.setScreen(new RepairScreen(inventory, level, x, y, z)); + // FUCK YOU 4J FIRST AND FOREMOST + bool success = true; +#else bool success = app.LoadRepairingMenu(GetXboxPad(), inventory, level, x, y, z ); if( success ) ui.PlayUISFX(eSFX_Press); - //minecraft.setScreen(new RepairScreen(inventory, level, x, y, z)); +#endif return success; } bool LocalPlayer::openFurnace(std::shared_ptr furnace) { +#ifdef ENABLE_JAVA_GUIS + minecraft->setScreen(new FurnaceScreen(inventory, furnace)); + bool success = true; +#else bool success = app.LoadFurnaceMenu(GetXboxPad(),inventory, furnace); if( success ) ui.PlayUISFX(eSFX_Press); - //minecraft->setScreen(new FurnaceScreen(inventory, furnace)); +#endif return success; } @@ -759,10 +780,10 @@ void LocalPlayer::awardStat(Stat *stat, byteArray param) Achievement *ach = (Achievement *) stat; // 4J-PB - changed to attempt to award everytime - the award may need a storage device, so needs a primary player, and the player may not have been a primary player when they first 'got' the award // so let the award manager figure it out - //if (!minecraft->stats[m_iPad]->hasTaken(ach)) + if (!minecraft->stats[m_iPad]->hasTaken(ach)) { // 4J-PB - Don't display the java popup - //minecraft->achievementPopup->popup(ach); + minecraft->achievementPopup->popup(ach); // 4J Stu - Added this function in the libraries as some achievements don't get awarded to all players // e.g. Splitscreen players cannot get theme/avatar/gamerpic and Trial players cannot get any diff --git a/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp index 6e3ecce1d..b93ac4d4a 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp @@ -327,6 +327,7 @@ extern IDirect3DDevice9 *g_pD3DDevice; // 4J - this used to take x and y as ints, and no scale and alpha - but this interface is now implemented as a wrapper round this more fully featured one void ItemRenderer::renderGuiItem(Font *font, Textures *textures, std::shared_ptr item, float x, float y, float fScaleX,float fScaleY, float fAlpha, bool useCompiled) { + if (!item) return; int itemId = item->id; int itemAuxValue = item->getAuxValue(); Icon *itemIcon = item->getIcon(); diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index 3a135655b..f8fd858fd 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -1,6 +1,7 @@ #include "../Platform/stdafx.h" #include "GameRenderer.h" #include "EntityRenderers/ItemInHandRenderer.h" +#include "Input/Input.h" #include "LevelRenderer.h" #include "Frustum.h" #include "FrustumCuller.h" @@ -1071,8 +1072,8 @@ void GameRenderer::render(float a, bool bFirst) ScreenSizeCalculator ssc(mc->options, mc->width, mc->height); int screenWidth = ssc.getWidth(); int screenHeight = ssc.getHeight(); - int xMouse = Mouse::getX() * screenWidth / fbw; - int yMouse = screenHeight - Mouse::getY() * screenHeight / fbh - 1; + int xMouse = InputManager.GetMouseX() * screenWidth / fbw; + int yMouse = InputManager.GetMouseY() * screenHeight / fbh - 1; int maxFps = 0;//getFpsCap(mc->options->framerateLimit); @@ -1116,8 +1117,14 @@ void GameRenderer::render(float a, bool bFirst) if (mc->screen != NULL) { glClear(GL_DEPTH_BUFFER_BIT); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.01f); mc->screen->render(xMouse, yMouse, a); if (mc->screen != NULL && mc->screen->particles != NULL) mc->screen->particles->render(a); + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); } } diff --git a/Minecraft.Client/Textures/Textures.cpp b/Minecraft.Client/Textures/Textures.cpp index 0974a3f66..3e380cbbb 100644 --- a/Minecraft.Client/Textures/Textures.cpp +++ b/Minecraft.Client/Textures/Textures.cpp @@ -29,14 +29,26 @@ int Textures::preLoadedIdx[TN_COUNT]; const wchar_t *Textures::preLoaded[TN_COUNT] = { L"%blur%misc/pumpkinblur", -// L"%blur%/misc/vignette", // Not currently used +#ifdef ENABLE_JAVA_GUIS + L"%blur%/misc/vignette", // Not currently used +#endif L"%clamp%misc/shadow", -// L"/achievement/bg", // Not currently used +#ifdef ENABLE_JAVA_GUIS + L"/achievement/bg", // Not currently used +#endif L"art/kz", L"environment/clouds", L"environment/rain", L"environment/snow", L"gui/gui", +#ifdef ENABLE_JAVA_GUIS + L"gui/background", + L"gui/inventory", + L"gui/container", + L"gui/crafting", + L"gui/furnace", + L"title/mclogo", +#endif L"gui/icons", L"item/arrows", L"item/boat", diff --git a/Minecraft.Client/Textures/Textures.h b/Minecraft.Client/Textures/Textures.h index a96947384..0c8994169 100644 --- a/Minecraft.Client/Textures/Textures.h +++ b/Minecraft.Client/Textures/Textures.h @@ -17,14 +17,26 @@ class PreStitchedTextureMap; typedef enum _TEXTURE_NAME { TN__BLUR__MISC_PUMPKINBLUR, -// TN__BLUR__MISC_VIGNETTE, // Not currently used +#ifdef ENABLE_JAVA_GUIS + TN__BLUR__MISC_VIGNETTE, // Not currently used +#endif TN__CLAMP__MISC_SHADOW, -// TN_ACHIEVEMENT_BG, // Not currently used +#ifdef ENABLE_JAVA_GUIS + TN_ACHIEVEMENT_BG, // Not currently used +#endif TN_ART_KZ, TN_ENVIRONMENT_CLOUDS, TN_ENVIRONMENT_RAIN, TN_ENVIRONMENT_SNOW, TN_GUI_GUI, +#ifdef ENABLE_JAVA_GUIS + TN_GUI_BACKGROUND, + TN_GUI_INVENTORY, + TN_GUI_CONTAINER, + TN_GUI_CRAFTING, + TN_GUI_FURNACE, + TN_TITLE_MCLOGO, +#endif TN_GUI_ICONS, TN_ITEM_ARROWS, TN_ITEM_BOAT, diff --git a/Minecraft.Client/UI/Gui.cpp b/Minecraft.Client/UI/Gui.cpp index 87213ba19..c4dae6b23 100644 --- a/Minecraft.Client/UI/Gui.cpp +++ b/Minecraft.Client/UI/Gui.cpp @@ -28,7 +28,11 @@ #include "../../Minecraft.World/Level/LevelChunk.h" #include "../../Minecraft.World/WorldGen/Biomes/Biome.h" +#ifdef ENABLE_JAVA_GUIS #define RENDER_HUD 1 +#else +#define RENDER_HUD 0 +#endif // #ifndef _XBOX // #undef RENDER_HUD @@ -860,7 +864,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) lastTickA = a; // 4J Stu - This is now displayed in a xui scene -#if 0 +#ifdef ENABLE_JAVA_GUIS // Jukebox CD message if (overlayMessageTime > 0) { @@ -908,7 +912,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) glDisable(GL_ALPHA_TEST); // 4J Stu - We have moved the chat text to a xui -#if 0 +#ifdef ENABLE_JAVA_GUIS glPushMatrix(); // 4J-PB we need to move this up a bit because we've moved the quick select //glTranslatef(0, ((float)screenHeight) - 48, 0); @@ -1090,7 +1094,7 @@ void Gui::renderVignette(float br, int w, int h) if (br > 1) br = 1; tbr += (br - tbr) * 0.01f; -#if 0 // 4J - removed - TODO put back when we have blend functions implemented +#ifdef ENABLE_JAVA_GUIS // 4J - removed - TODO put back when we have blend functions implemented glDisable(GL_DEPTH_TEST); glDepthMask(false); glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); diff --git a/Minecraft.Client/UI/Screen.cpp b/Minecraft.Client/UI/Screen.cpp index 3fe91d598..ff6bee12d 100644 --- a/Minecraft.Client/UI/Screen.cpp +++ b/Minecraft.Client/UI/Screen.cpp @@ -5,6 +5,7 @@ #include "../Rendering/Tesselator.h" #include "../Textures/Textures.h" #include "../../Minecraft.World/Util/SoundTypes.h" +#include @@ -103,6 +104,47 @@ void Screen::init() void Screen::updateEvents() { +// TODO: update for SDL if we ever get around to that +#if (defined (ENABLE_JAVA_GUIS)) + int fbw, fbh; + RenderManager.GetFramebufferSize(fbw, fbh); + glViewport(0, 0, fbw, fbh); + ScreenSizeCalculator ssc(minecraft->options, minecraft->width, minecraft->height); + int screenWidth = ssc.getWidth(); + int screenHeight = ssc.getHeight(); + + GLFWwindow* window = glfwGetCurrentContext(); + if (!window) return; + + double xpos, ypos; + glfwGetCursorPos(window, &xpos, &ypos); + + int xMouse = (int)xpos * screenWidth / fbw; + int yMouse = (int)ypos * screenHeight / fbh - 1; + + static bool prevLeftState = false; + static bool prevRightState = false; + + bool leftState = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS; + bool rightState = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS; + + if (leftState && !prevLeftState) { + mouseClicked(xMouse, yMouse, 0); + } + else if (!leftState && prevLeftState) { + mouseReleased(xMouse, yMouse, 0); + } + + if (rightState && !prevRightState) { + mouseClicked(xMouse, yMouse, 1); + } + else if (!rightState && prevRightState) { + mouseReleased(xMouse, yMouse, 1); + } + + prevLeftState = leftState; + prevRightState = rightState; +#else /* 4J - TODO while (Mouse.next()) { mouseEvent(); @@ -112,7 +154,7 @@ void Screen::updateEvents() keyboardEvent(); } */ - +#endif } void Screen::mouseEvent() @@ -171,6 +213,21 @@ void Screen::renderBackground(int vo) void Screen::renderDirtBackground(int vo) { // 4J Unused - Iggy Flash UI renders the background on consoles +#ifdef ENABLE_JAVA_GUIS + glDisable(GL_LIGHTING); + glDisable(GL_FOG); + Tesselator *t = Tesselator::getInstance(); + glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadTexture(TN_GUI_BACKGROUND)); + glColor4f(1, 1, 1, 1); + float s = 32; + t->begin(); + t->color(0x404040); + t->vertexUV(static_cast(0), static_cast(height), static_cast(0), static_cast(0), static_cast(height / s + vo)); + t->vertexUV(static_cast(width), static_cast(height), static_cast(0), static_cast(width / s), static_cast(height / s + vo)); + t->vertexUV(static_cast(width), static_cast(0), static_cast(0), static_cast(width / s), static_cast(0 + vo)); + t->vertexUV(static_cast(0), static_cast(0), static_cast(0), static_cast(0), static_cast(0 + vo)); + t->end(); +#endif } bool Screen::isPauseScreen() diff --git a/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp b/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp index 56e5ed54e..147251dc7 100644 --- a/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp +++ b/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp @@ -33,7 +33,7 @@ void AbstractContainerScreen::init() void AbstractContainerScreen::render(int xm, int ym, float a) { // 4J Stu - Not used -#if 0 +#if ENABLE_JAVA_GUIS renderBackground(); int xo = (width - imageWidth) / 2; int yo = (height - imageHeight) / 2; @@ -96,7 +96,8 @@ void AbstractContainerScreen::render(int xm, int ym, float a) if (inventory->getCarried() == NULL && hoveredSlot != NULL && hoveredSlot->hasItem()) { - std::wstring elementName = trimString(Language::getInstance()->getElementName(hoveredSlot->getItem()->getDescriptionId())); + // std::wstring elementName = trimString(Language::getInstance()->getElementName(hoveredSlot->getItem()->getDescriptionId())); + std::wstring elementName = L""; if (elementName.length() > 0) { @@ -125,23 +126,23 @@ void AbstractContainerScreen::renderLabels() void AbstractContainerScreen::renderSlot(Slot *slot) { // 4J Unused -#if 0 +#if ENABLE_JAVA_GUIS int x = slot->x; int y = slot->y; std::shared_ptr item = slot->getItem(); - if (item == NULL) - { - int icon = slot->getNoItemIcon(); - if (icon >= 0) - { - glDisable(GL_LIGHTING); - minecraft->textures->bind(minecraft->textures->loadTexture(TN_GUI_ITEMS));//L"/gui/items.png")); - blit(x, y, icon % 16 * 16, icon / 16 * 16, 16, 16); - glEnable(GL_LIGHTING); - return; - } - } + // if (item == NULL) + // { + // int icon = slot->getNoItemIcon(); + // if (icon >= 0) + // { + // glDisable(GL_LIGHTING); + // minecraft->textures->bind(minecraft->textures->loadTexture(TN_GUI_ITEMS));//L"/gui/items.png")); + // blit(x, y, icon % 16 * 16, icon / 16 * 16, 16, 16); + // glEnable(GL_LIGHTING); + // return; + // } + // } itemRenderer->renderGuiItem(font, minecraft->textures, item, x, y); itemRenderer->renderGuiItemDecorations(font, minecraft->textures, item, x, y); diff --git a/Minecraft.Client/UI/Screens/AchievementPopup.cpp b/Minecraft.Client/UI/Screens/AchievementPopup.cpp index 16c4e378b..b715538e2 100644 --- a/Minecraft.Client/UI/Screens/AchievementPopup.cpp +++ b/Minecraft.Client/UI/Screens/AchievementPopup.cpp @@ -73,7 +73,7 @@ void AchievementPopup::prepareWindow() void AchievementPopup::render() { // 4J Unused -#if 0 +#if ENABLE_JAVA_GUIS if (Minecraft::warezTime > 0) { glDisable(GL_DEPTH_TEST); @@ -119,7 +119,7 @@ void AchievementPopup::render() int xx = width - 160; int yy = 0 - (int) (yo * 36); - int tex = mc->textures->loadTexture(L"/achievement/bg.png"); + int tex = mc->textures->loadTexture(TN_ACHIEVEMENT_BG); glColor4f(1, 1, 1, 1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex); @@ -127,15 +127,15 @@ void AchievementPopup::render() blit(xx, yy, 96, 202, 160, 32); - if (isHelper) - { - mc->font->drawWordWrap(desc, xx + 30, yy + 7, 120, 0xffffffff); - } - else - { + // if (isHelper) + // { + // mc->font->drawWordWrap(desc, xx + 30, yy + 7, 120, 0xffffffff); + // } + // else + // { mc->font->draw(title, xx + 30, yy + 7, 0xffffff00); mc->font->draw(desc, xx + 30, yy + 18, 0xffffffff); - } + // } glPushMatrix(); glRotatef(180, 1, 0, 0); diff --git a/Minecraft.Client/UI/Screens/ContainerScreen.cpp b/Minecraft.Client/UI/Screens/ContainerScreen.cpp index e3d6d1ffd..c8027ed41 100644 --- a/Minecraft.Client/UI/Screens/ContainerScreen.cpp +++ b/Minecraft.Client/UI/Screens/ContainerScreen.cpp @@ -28,8 +28,8 @@ void ContainerScreen::renderLabels() void ContainerScreen::renderBg(float a) { // 4J Unused -#if 0 - int tex = minecraft->textures->loadTexture(L"/gui/container.png"); +#ifdef ENABLE_JAVA_GUIS + int tex = minecraft->textures->loadTexture(TN_GUI_CONTAINER); glColor4f(1, 1, 1, 1); minecraft->textures->bind(tex); int xo = (width - imageWidth) / 2; diff --git a/Minecraft.Client/UI/Screens/CraftingScreen.cpp b/Minecraft.Client/UI/Screens/CraftingScreen.cpp index 8935e0191..0a3febbdf 100644 --- a/Minecraft.Client/UI/Screens/CraftingScreen.cpp +++ b/Minecraft.Client/UI/Screens/CraftingScreen.cpp @@ -23,8 +23,8 @@ void CraftingScreen::renderLabels() void CraftingScreen::renderBg(float a) { // 4J Unused -#if 0 - int tex = minecraft->textures->loadTexture(L"/gui/crafting.png"); +#ifdef ENABLE_JAVA_GUIS + int tex = minecraft->textures->loadTexture(TN_GUI_CRAFTING); glColor4f(1, 1, 1, 1); minecraft->textures->bind(tex); int xo = (width - imageWidth) / 2; diff --git a/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp b/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp index 6629a420f..ad71177aa 100644 --- a/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp +++ b/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp @@ -9,6 +9,9 @@ #include "../../../Minecraft.World/Headers/net.minecraft.world.level.storage.h" #include "../../../Minecraft.World/Util/SharedConstants.h" #include "../../../Minecraft.World/Util/Random.h" +#include "../../MinecraftServer.h" +#include "../../GameState/Options.h" +#include CreateWorldScreen::CreateWorldScreen(Screen *lastScreen) { @@ -97,24 +100,132 @@ void CreateWorldScreen::buttonClicked(Button *button) if (done) return; done = true; - __int64 seedValue = (new Random())->nextLong(); + MoreOptionsParams* moreOptionsParams = new MoreOptionsParams(); + + // these r just the defaults from the createworldmenu UIscene + // i had higher ambitions for what id do with these but its not worth it for a temp ui + moreOptionsParams->bGenerateOptions = TRUE; + moreOptionsParams->bStructures = TRUE; + moreOptionsParams->bFlatWorld = FALSE; + moreOptionsParams->bBonusChest = FALSE; + moreOptionsParams->bPVP = TRUE; + moreOptionsParams->bTrust = TRUE; + moreOptionsParams->bFireSpreads = TRUE; + moreOptionsParams->bTNT = TRUE; + moreOptionsParams->bHostPrivileges = FALSE; + moreOptionsParams->bOnlineGame = FALSE; + moreOptionsParams->bInviteOnly = FALSE; + moreOptionsParams->bAllowFriendsOfFriends = FALSE; + moreOptionsParams->bOnlineSettingChangedBySystem = FALSE; + moreOptionsParams->iPad = 0; + + moreOptionsParams->worldName = nameEdit->getValue(); + moreOptionsParams->seed = seedEdit->getValue(); + + moreOptionsParams->dwTexturePack = 0; + + bool bGameModeSurvival = true; + + std::wstring worldName = nameEdit->getValue(); + if (worldName.empty()) + { + worldName = L"2slimey"; + } + + StorageManager.ResetSaveData(); + StorageManager.SetSaveTitle((wchar_t *)worldName.c_str()); + std::wstring seedString = seedEdit->getValue(); + + __int64 seedValue = 0; + NetworkGameInitData *param = new NetworkGameInitData(); if (seedString.length() != 0) { // try to convert it to a long first // try { // 4J - removed try/catch __int64 value = _fromString<__int64>(seedString); + + bool isNumber = true; + for (unsigned int i = 0; i < seedString.length(); ++i) + { + if (seedString.at(i) < L'0' || seedString.at(i) > L'9') + { + if (!(i == 0 && seedString.at(i) == L'-')) + { + isNumber = false; + break; + } + } + } + + if (isNumber) + value = _fromString<__int64>(seedString); + if (value != 0) { seedValue = value; } + else + { + int hashValue = 0; + for (unsigned int i = 0; i < seedString.length(); ++i) + hashValue = 31 * hashValue + seedString.at(i); + seedValue = hashValue; + } // } catch (NumberFormatException e) { // // not a number, fetch hash value // seedValue = seedString.hashCode(); // } } + else + { + param->findSeed = true; + } + param->seed = seedValue; + param->saveData = NULL; + param->texturePackId = 0; + param->settings = 0; + + app.SetGameHostOption(eGameHostOption_Difficulty, minecraft->options->difficulty); + app.SetGameHostOption(eGameHostOption_FriendsOfFriends, moreOptionsParams->bAllowFriendsOfFriends); + app.SetGameHostOption(eGameHostOption_Gamertags, 1); + app.SetGameHostOption(eGameHostOption_BedrockFog, 0); + app.SetGameHostOption(eGameHostOption_GameType, bGameModeSurvival ? GameType::SURVIVAL->getId() : GameType::CREATIVE->getId()); // TODO: gamemode switch + app.SetGameHostOption(eGameHostOption_LevelType, moreOptionsParams->bFlatWorld); + app.SetGameHostOption(eGameHostOption_Structures, moreOptionsParams->bStructures); + app.SetGameHostOption(eGameHostOption_BonusChest, moreOptionsParams->bBonusChest); + app.SetGameHostOption(eGameHostOption_PvP, moreOptionsParams->bPVP); + app.SetGameHostOption(eGameHostOption_TrustPlayers, moreOptionsParams->bTrust); + app.SetGameHostOption(eGameHostOption_FireSpreads, moreOptionsParams->bFireSpreads); + app.SetGameHostOption(eGameHostOption_TNT, moreOptionsParams->bTNT); + app.SetGameHostOption(eGameHostOption_HostCanFly, moreOptionsParams->bHostPrivileges); + app.SetGameHostOption(eGameHostOption_HostCanChangeHunger, moreOptionsParams->bHostPrivileges); + app.SetGameHostOption(eGameHostOption_HostCanBeInvisible, moreOptionsParams->bHostPrivileges); + + param->settings = app.GetGameHostOption(eGameHostOption_All); + param->xzSize = LEVEL_MAX_WIDTH; + param->hellScale = HELL_LEVEL_MAX_SCALE; + + g_NetworkManager.HostGame(0, false, false, MINECRAFT_NET_MAX_PLAYERS, 0); + + g_NetworkManager.FakeLocalPlayerJoined(); + + LoadingInputParams *loadingParams = new LoadingInputParams(); + loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; + loadingParams->lpParam = (LPVOID)param; + + app.SetAutosaveTimerTime(); + + UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); + completionData->bShowBackground = TRUE; + completionData->bShowLogo = TRUE; + completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes; + completionData->iPad = 0; + loadingParams->completionData = completionData; + + ui.NavigateToScene(0, eUIScene_FullscreenProgress, loadingParams); // 4J Stu - This screen is not used, so removing this to stop the build failing #if 0 minecraft->gameMode = new SurvivalMode(minecraft); diff --git a/Minecraft.Client/UI/Screens/CreateWorldScreen.h b/Minecraft.Client/UI/Screens/CreateWorldScreen.h index 96ca5b113..d2d7bcea8 100644 --- a/Minecraft.Client/UI/Screens/CreateWorldScreen.h +++ b/Minecraft.Client/UI/Screens/CreateWorldScreen.h @@ -29,4 +29,36 @@ protected: public: virtual void render(int xm, int ym, float a); virtual void tabPressed(); + +private: + int m_iGameModeId; + bool m_bGameModeCreative; + + struct MoreOptionsParams + { + bool bGenerateOptions; + bool bStructures; + bool bFlatWorld; + bool bBonusChest; + bool bPVP; + bool bTrust; + bool bFireSpreads; + bool bHostPrivileges; + bool bTNT; + bool bMobGriefing; + bool bKeepInventory; + bool bDoMobSpawning; + bool bDoMobLoot; + bool bDoTileDrops; + bool bNaturalRegeneration; + bool bDoDaylightCycle; + bool bOnlineGame; + bool bInviteOnly; + bool bAllowFriendsOfFriends; + bool bOnlineSettingChangedBySystem; + int dwTexturePack; + int iPad; + std::wstring worldName; + std::wstring seed; + } m_MoreOptionsParams; }; \ No newline at end of file diff --git a/Minecraft.Client/UI/Screens/FurnaceScreen.cpp b/Minecraft.Client/UI/Screens/FurnaceScreen.cpp index 20d19c04c..3b1409390 100644 --- a/Minecraft.Client/UI/Screens/FurnaceScreen.cpp +++ b/Minecraft.Client/UI/Screens/FurnaceScreen.cpp @@ -20,8 +20,8 @@ void FurnaceScreen::renderLabels() void FurnaceScreen::renderBg(float a) { // 4J Unused -#if 0 - int tex = minecraft->textures->loadTexture(L"/gui/furnace.png"); +#ifdef ENABLE_JAVA_GUIS + int tex = minecraft->textures->loadTexture(TN_GUI_FURNACE); glColor4f(1, 1, 1, 1); minecraft->textures->bind(tex); int xo = (width - imageWidth) / 2; diff --git a/Minecraft.Client/UI/Screens/InventoryScreen.cpp b/Minecraft.Client/UI/Screens/InventoryScreen.cpp index 61dd3f139..841eeb4e5 100644 --- a/Minecraft.Client/UI/Screens/InventoryScreen.cpp +++ b/Minecraft.Client/UI/Screens/InventoryScreen.cpp @@ -38,8 +38,8 @@ void InventoryScreen::render(int xm, int ym, float a) void InventoryScreen::renderBg(float a) { // 4J Unused -#if 0 - int tex = minecraft->textures->loadTexture(L"/gui/inventory.png"); +#ifdef ENABLE_JAVA_GUIS + int tex = minecraft->textures->loadTexture(TN_GUI_INVENTORY); glColor4f(1, 1, 1, 1); minecraft->textures->bind(tex); int xo = (width - imageWidth) / 2; diff --git a/Minecraft.Client/UI/Screens/PauseScreen.cpp b/Minecraft.Client/UI/Screens/PauseScreen.cpp index 759c2b1fc..5fafa8561 100644 --- a/Minecraft.Client/UI/Screens/PauseScreen.cpp +++ b/Minecraft.Client/UI/Screens/PauseScreen.cpp @@ -9,6 +9,8 @@ #include "../../../Minecraft.World/Headers/net.minecraft.world.level.h" #include "../../../Minecraft.World/Headers/net.minecraft.stats.h" #include "../../Player/LocalPlayer.h" +#include "../../Player/MultiPlayerLocalPlayer.h" +#include "../../MinecraftServer.h" PauseScreen::PauseScreen() { @@ -41,33 +43,34 @@ void PauseScreen::init() } -void PauseScreen::buttonClicked(Button button) +void PauseScreen::buttonClicked(Button* button) { - if (button.id == 0) + if (button->id == 0) { minecraft->setScreen(new OptionsScreen(this, minecraft->options)); } - if (button.id == 1) + if (button->id == 1) { - if (minecraft->isClientSide()) - { - minecraft->level->disconnect(); - } + // TODO: proper disconnects + // if (minecraft->isClientSide()) + // { + // minecraft->level->disconnect(); + // } - minecraft->setLevel(NULL); - minecraft->setScreen(new TitleScreen()); + // minecraft->setLevel(NULL); + // minecraft->setScreen(new TitleScreen()); } - if (button.id == 4) + if (button->id == 4) { minecraft->setScreen(NULL); // minecraft->grabMouse(); // 4J - removed } - if (button.id == 5) + if (button->id == 5) { // minecraft->setScreen(new AchievementScreen(minecraft->stats)); // 4J TODO - put back } - if (button.id == 6) + if (button->id == 6) { // minecraft->setScreen(new StatsScreen(this, minecraft->stats)); // 4J TODO - put back } diff --git a/Minecraft.Client/UI/Screens/PauseScreen.h b/Minecraft.Client/UI/Screens/PauseScreen.h index 4603947fa..0f6cc8bf9 100644 --- a/Minecraft.Client/UI/Screens/PauseScreen.h +++ b/Minecraft.Client/UI/Screens/PauseScreen.h @@ -11,7 +11,7 @@ public: virtual void init(); protected:using Screen::buttonClicked; - virtual void buttonClicked(Button button); + virtual void buttonClicked(Button* button); public: virtual void tick(); virtual void render(int xm, int ym, float a); diff --git a/Minecraft.Client/UI/Screens/TitleScreen.cpp b/Minecraft.Client/UI/Screens/TitleScreen.cpp index 09889b5f4..e9948e408 100644 --- a/Minecraft.Client/UI/Screens/TitleScreen.cpp +++ b/Minecraft.Client/UI/Screens/TitleScreen.cpp @@ -10,6 +10,7 @@ #include "../../../Minecraft.World/Headers/net.minecraft.locale.h" #include "../../../Minecraft.World/Platform/System.h" #include "../../../Minecraft.World/Util/Random.h" +#include #include "TitleScreen.h" Random *TitleScreen::random = new Random(); @@ -20,7 +21,7 @@ TitleScreen::TitleScreen() vo = 0; multiplayerButton = NULL; - splash = L"missingno"; + splash = L"4JCraft!"; // try { // 4J - removed try/catch std::vector splashes; @@ -41,7 +42,7 @@ TitleScreen::TitleScreen() delete br; */ - splash = L""; //splashes.at(random->nextInt(splashes.size())); + //splash = L""; //splashes.at(random->nextInt(splashes.size())); // } catch (Exception e) { // } @@ -127,4 +128,34 @@ void TitleScreen::buttonClicked(Button *button) void TitleScreen::render(int xm, int ym, float a) { // 4J Unused - Iggy Flash UI renders the title screen on consoles +#ifdef ENABLE_JAVA_GUIS + renderBackground(); + Tesselator *t = Tesselator::getInstance(); + + int logoWidth = 155 + 119; + int logoX = width / 2 - logoWidth / 2; + int logoY = 30; + + glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadTexture(TN_TITLE_MCLOGO)); + glColor4f(1, 1, 1, 1); + blit(logoX + 0, logoY + 0, 0, 0, 155, 44); + blit(logoX + 155, logoY + 0, 0, 45, 155, 44); + t->color(0xffffff); + glPushMatrix(); + glTranslatef((float)width / 2 + 90, 70, 0); + + glRotatef(-20, 0, 0, 1); + float sss = 1.8f - Mth::abs(Mth::sin(System::currentTimeMillis() % 1000 / 1000.0f * PI * 2) * 0.1f); + + sss = sss * 100 / (font->width(splash) + 8 * 4); + glScalef(sss, sss, sss); + drawCenteredString(font, splash, 0, -8, 0xffff00); + glPopMatrix(); + + drawString(font, ClientConstants::VERSION_STRING, 2, 2, 0x505050); + wstring msg = L"Copyright Mojang AB. Do not distribute."; + drawString(font, msg, width - font->width(msg) - 2, height - 10, 0xffffff); + + Screen::render(xm, ym, a); +#endif } diff --git a/meson.build b/meson.build index 3cc9b0c41..fbec8dca4 100644 --- a/meson.build +++ b/meson.build @@ -38,6 +38,10 @@ global_cpp_defs = [ '-DDEBUG', ] +if get_option('enable_java_guis') + global_cpp_defs += '-DENABLE_JAVA_GUIS' +endif + if host_machine.system() == 'linux' global_cpp_defs += [ '-Dlinux', diff --git a/meson.options b/meson.options new file mode 100644 index 000000000..4e0b87ec5 --- /dev/null +++ b/meson.options @@ -0,0 +1,4 @@ +option('enable_java_guis', + type : 'boolean', + value : false, + description : 'Re-enable the Java UI remnants in the code (for testing only)') \ No newline at end of file