mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-08 14:17:13 +00:00
feat(jui): add world leaving
You will now be able to leave the world from all places where you'd usually be able to (Pause screen, death screen) Should be identical to the way it's done on Iggy/XUI
This commit is contained in:
parent
6d50ac4771
commit
0fbbac1cde
|
|
@ -122,6 +122,7 @@ Minecraft::Minecraft(Component* mouseComponent, Canvas* parent,
|
|||
user = NULL;
|
||||
parent = NULL;
|
||||
pause = false;
|
||||
exitingWorldRightNow = false;
|
||||
textures = NULL;
|
||||
font = NULL;
|
||||
screen = NULL;
|
||||
|
|
@ -1254,6 +1255,15 @@ void Minecraft::run_middle() {
|
|||
if (lastTime == 0) lastTime = System::nanoTime();
|
||||
static int frames = 0;
|
||||
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
// 4jcraft: while the java ui is leaving world, don't run the rest of
|
||||
// run_middle
|
||||
if (exitingWorldRightNow) {
|
||||
screen->render(0, 0, 1);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
EnterCriticalSection(&m_setLevelCS);
|
||||
|
||||
if (running) {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ public:
|
|||
|
||||
// 4J - per player ?
|
||||
volatile bool pause;
|
||||
volatile bool exitingWorldRightNow;
|
||||
|
||||
Textures* textures;
|
||||
Font *font, *altFont;
|
||||
|
|
|
|||
|
|
@ -2826,7 +2826,7 @@ void CMinecraftApp::HandleXuiActions(void)
|
|||
#endif
|
||||
|
||||
case eAppAction_ExitWorld:
|
||||
|
||||
pMinecraft->exitingWorldRightNow = true;
|
||||
SetAction(i,eAppAction_Idle);
|
||||
|
||||
// If we're already leaving don't exit
|
||||
|
|
|
|||
|
|
@ -627,6 +627,7 @@ void IUIScene_PauseMenu::_ExitWorld(void *lpParameter)
|
|||
|
||||
app.SetChangingSessionType(false);
|
||||
app.SetReallyChangingSessionType(false);
|
||||
pMinecraft->exitingWorldRightNow = false;
|
||||
|
||||
#if defined(_XBOX_ONE) || defined(__ORBIS__)
|
||||
// Make sure we don't think saving is disabled in the menus
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "DeathScreen.h"
|
||||
#include "../Button.h"
|
||||
#include "../../Player/MultiPlayerLocalPlayer.h"
|
||||
#include "PauseScreen.h"
|
||||
#include "TitleScreen.h"
|
||||
|
||||
void DeathScreen::init() {
|
||||
|
|
@ -30,9 +31,11 @@ void DeathScreen::buttonClicked(Button* button) {
|
|||
// minecraft.setScreen(new NewLevelScreen(this));
|
||||
}
|
||||
if (button->id == 2) {
|
||||
// TODO: proper world exits
|
||||
// minecraft->setLevel(NULL);
|
||||
// minecraft->setScreen(new TitleScreen());
|
||||
|
||||
// 4jcraft: use the static method from PauseScreen to exit
|
||||
PauseScreen::exitWorld(minecraft, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "PauseScreen.h"
|
||||
#include "../Button.h"
|
||||
#include "../../GameState/StatsCounter.h"
|
||||
#include "MessageScreen.h"
|
||||
#include "OptionsScreen.h"
|
||||
#include "TitleScreen.h"
|
||||
#include "../../Level/MultiPlayerLevel.h"
|
||||
|
|
@ -48,12 +49,23 @@ void PauseScreen::init() {
|
|||
*/
|
||||
}
|
||||
|
||||
void PauseScreen::exitWorld(Minecraft* minecraft, bool save) {
|
||||
// 4jcraft: made our own static method for use in the java gui (other
|
||||
// places such as the deathscreen need this)
|
||||
MinecraftServer* server = MinecraftServer::getInstance();
|
||||
|
||||
minecraft->setScreen(new MessageScreen(L"Leaving world"));
|
||||
if (g_NetworkManager.IsHost()) {
|
||||
server->setSaveOnExit(save);
|
||||
}
|
||||
app.SetAction(minecraft->player->GetXboxPad(), eAppAction_ExitWorld);
|
||||
}
|
||||
|
||||
void PauseScreen::buttonClicked(Button* button) {
|
||||
if (button->id == 0) {
|
||||
minecraft->setScreen(new OptionsScreen(this, minecraft->options));
|
||||
}
|
||||
if (button->id == 1) {
|
||||
// TODO: proper disconnects
|
||||
// if (minecraft->isClientSide())
|
||||
// {
|
||||
// minecraft->level->disconnect();
|
||||
|
|
@ -61,6 +73,9 @@ void PauseScreen::buttonClicked(Button* button) {
|
|||
|
||||
// minecraft->setLevel(NULL);
|
||||
// minecraft->setScreen(new TitleScreen());
|
||||
|
||||
// 4jcraft: exit with our new exitWorld method
|
||||
exitWorld(minecraft, true);
|
||||
}
|
||||
if (button->id == 4) {
|
||||
minecraft->setScreen(NULL);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ private:
|
|||
public:
|
||||
PauseScreen(); // 4J added
|
||||
virtual void init();
|
||||
static void exitWorld(Minecraft* minecraft, bool save);
|
||||
|
||||
protected:
|
||||
using Screen::buttonClicked;
|
||||
|
|
|
|||
Loading…
Reference in a new issue