forked from Kolyah35/minecraft-pe-0.6.1
Added GUI Styles with 3 options: Java, Pi/Xperia and Pocket Hopefully fixed touch input eating and breaking blocks bug Fire should render on all mobs now Fixed only one side of the first person burning animation being animated Added Window Scaling Option for PC Users (Hasn't been tested on other platforms Render Distance is now configurable from the settings menu Tried to fix shadows again on IOS and Android, hopefully works? Block Outline Selection now has a thicker outline for better visibility
230 lines
7.0 KiB
C++
Executable File
230 lines
7.0 KiB
C++
Executable File
#include "PauseScreen.h"
|
|
#include "StartMenuScreen.h"
|
|
#include "../components/ImageButton.h"
|
|
#include "../../Minecraft.h"
|
|
#include "../../../util/Mth.h"
|
|
#include "../../../network/RakNetInstance.h"
|
|
#include "../../../network/ServerSideNetworkHandler.h"
|
|
#include "client/Options.h"
|
|
#include "client/gui/components/Button.h"
|
|
#include "client/gui/screens/OptionsScreen.h"
|
|
|
|
PauseScreen::PauseScreen(bool wasBackPaused)
|
|
: saveStep(0),
|
|
visibleTime(0),
|
|
bContinue(0),
|
|
bQuit(0),
|
|
bOptions(0),
|
|
bQuitAndSaveLocally(0),
|
|
bServerVisibility(0),
|
|
// bThirdPerson(0),
|
|
wasBackPaused(wasBackPaused),
|
|
// bSound(OPTIONS_SOUND_VOLUME, 1, 0),
|
|
bThirdPerson(OPTIONS_THIRD_PERSON_VIEW),
|
|
bHideGui(OPTIONS_HIDEGUI)
|
|
{
|
|
ImageDef def;
|
|
def.setSrc(IntRectangle(160, 144, 39, 31));
|
|
def.name = "gui/touchgui.png";
|
|
IntRectangle& defSrc = *def.getSrc();
|
|
|
|
def.width = defSrc.w * 0.666667f;
|
|
def.height = defSrc.h * 0.666667f;
|
|
|
|
// bSound.setImageDef(def, true);
|
|
defSrc.y += defSrc.h;
|
|
bThirdPerson.setImageDef(def, true);
|
|
bHideGui.setImageDef(def, true);
|
|
//void setImageDef(ImageDef& imageDef, bool setButtonSize);
|
|
}
|
|
|
|
PauseScreen::~PauseScreen() {
|
|
delete bContinue;
|
|
delete bQuit;
|
|
delete bQuitAndSaveLocally;
|
|
delete bServerVisibility;
|
|
delete bOptions;
|
|
// delete bThirdPerson;
|
|
}
|
|
|
|
void PauseScreen::init() {
|
|
if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) == 0) {
|
|
bContinue = new Touch::TButton(1, "Back to game");
|
|
bOptions = new Touch::TButton(5, "Options");
|
|
bQuit = new Touch::TButton(2, "Quit to title");
|
|
bQuitAndSaveLocally = new Touch::TButton(3, "Quit and copy map");
|
|
bServerVisibility = new Touch::TButton(4, "");
|
|
// bThirdPerson = new Touch::TButton(5, "Toggle 3:rd person view");
|
|
} else if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) == 1) {
|
|
bContinue = new Button(1, "Back to game");
|
|
bOptions = new Button(5, "Options");
|
|
bQuit = new Button(2, "Quit to title");
|
|
bQuitAndSaveLocally = new Button(3, "Quit and copy map");
|
|
bServerVisibility = new Button(4, "");
|
|
// bThirdPerson = new Button(5, "Toggle 3:rd person view");
|
|
} else {
|
|
bContinue = new Button(1, 0, 0, 200, 20, "Back to game");
|
|
bServerVisibility = new Button(4, 0, 0, 200, 20, "");
|
|
bOptions = new Button(5, 0, 0, 200, 20, "Options...");
|
|
bQuit = new Button(2, 0, 0, 200, 20, "Save and quit to title");
|
|
bQuitAndSaveLocally = new Button(3, 0, 0, 200, 20, "Copy and quit map");
|
|
// bThirdPerson = new Button(5, "Toggle 3:rd person view");
|
|
}
|
|
|
|
buttons.push_back(bContinue);
|
|
buttons.push_back(bQuit);
|
|
buttons.push_back(bOptions);
|
|
// bSound.updateImage(&minecraft->options);
|
|
bThirdPerson.updateImage(&minecraft->options);
|
|
bHideGui.updateImage(&minecraft->options);
|
|
// buttons.push_back(&bSound);
|
|
buttons.push_back(&bThirdPerson);
|
|
//buttons.push_back(&bHideGui);
|
|
|
|
// If Back wasn't pressed, set up additional items (more than Quit to menu
|
|
// and Back to game) here
|
|
|
|
#if !defined(APPLE_DEMO_PROMOTION) && !defined(RPI)
|
|
if (true || !wasBackPaused) {
|
|
if (minecraft->raknetInstance) {
|
|
if (minecraft->raknetInstance->isServer()) {
|
|
updateServerVisibilityText();
|
|
buttons.push_back(bServerVisibility);
|
|
}
|
|
else {
|
|
#if !defined(DEMO_MODE)
|
|
buttons.push_back(bQuitAndSaveLocally);
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
// buttons.push_back(bThirdPerson);
|
|
|
|
for (unsigned int i = 0; i < buttons.size(); ++i) {
|
|
// if (buttons[i] == &bSound) continue;
|
|
if (buttons[i] == &bThirdPerson) continue;
|
|
if (buttons[i] == &bHideGui) continue;
|
|
tabButtons.push_back(buttons[i]);
|
|
}
|
|
}
|
|
|
|
void PauseScreen::setupPositions() {
|
|
saveStep = 0;
|
|
int yBase = 16;
|
|
if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) == 2){
|
|
yBase = 50;
|
|
|
|
bContinue->width = bOptions->width = bQuit->width = /*bThirdPerson->w =*/ 200;
|
|
bQuitAndSaveLocally->width = bServerVisibility->width = 200;
|
|
|
|
bContinue->x = (width - bContinue->width) / 2;
|
|
bContinue->y = yBase + 24 * 1;
|
|
|
|
bQuitAndSaveLocally->x = bServerVisibility->x = (width - bQuitAndSaveLocally->width) / 2;
|
|
bQuitAndSaveLocally->y = bServerVisibility->y = yBase + 24 * 2;
|
|
|
|
bOptions->x = (width - bOptions->width) / 2;
|
|
bOptions->y = yBase + 24 * 3 + 24;
|
|
|
|
bQuit->x = (width - bQuit->width) / 2;
|
|
bQuit->y = yBase + 24 * 4 + 24;
|
|
|
|
} else {
|
|
bContinue->width = bOptions->width = bQuit->width = /*bThirdPerson->w =*/ 160;
|
|
bQuitAndSaveLocally->width = bServerVisibility->width = 160;
|
|
|
|
bContinue->x = (width - bContinue->width) / 2;
|
|
bContinue->y = yBase + 32 * 1;
|
|
|
|
bOptions->x = (width - bOptions->width) / 2;
|
|
bOptions->y = yBase + 32 * 2;
|
|
|
|
bQuit->x = (width - bQuit->width) / 2;
|
|
bQuit->y = yBase + 32 * 3;
|
|
|
|
#if APPLE_DEMO_PROMOTION
|
|
bQuit->y += 16;
|
|
#endif
|
|
|
|
bQuitAndSaveLocally->x = bServerVisibility->x = (width - bQuitAndSaveLocally->width) / 2;
|
|
bQuitAndSaveLocally->y = bServerVisibility->y = yBase + 32 * 4;
|
|
}
|
|
|
|
|
|
|
|
// bSound.y = bThirdPerson.y = 8;
|
|
// bSound.x = 4;
|
|
// bThirdPerson.x = bSound.x + 4 + bSound.width;
|
|
// bHideGui.x = bThirdPerson.x + 4 + bThirdPerson.width;
|
|
|
|
//bThirdPerson->x = (width - bThirdPerson->w) / 2;
|
|
//bThirdPerson->y = yBase + 32 * 4;
|
|
}
|
|
|
|
void PauseScreen::tick() {
|
|
super::tick();
|
|
visibleTime++;
|
|
}
|
|
|
|
void PauseScreen::render(int xm, int ym, float a) {
|
|
renderBackground();
|
|
|
|
//bool isSaving = !minecraft->level.pauseSave(saveStep++);
|
|
//if (isSaving || visibleTime < 20) {
|
|
// float col = ((visibleTime % 10) + a) / 10.0f;
|
|
// col = Mth::sin(col * Mth::PI * 2) * 0.2f + 0.8f;
|
|
// int br = (int) (255 * col);
|
|
|
|
// drawString(font, "Saving level..", 8, height - 16, br << 16 | br << 8 | br);
|
|
//}
|
|
|
|
drawCenteredString(font, "Game menu", width / 2, 24, 0xffffff);
|
|
|
|
super::render(xm, ym, a);
|
|
}
|
|
|
|
void PauseScreen::buttonClicked(Button* button) {
|
|
if (button->id == bContinue->id) {
|
|
minecraft->setScreen(NULL);
|
|
//minecraft->grabMouse();
|
|
}
|
|
if (button->id == bQuit->id) {
|
|
minecraft->leaveGame();
|
|
}
|
|
if (button->id == bQuitAndSaveLocally->id) {
|
|
minecraft->leaveGame(true);
|
|
}
|
|
if (button->id == bOptions->id) {
|
|
minecraft->setScreen(new OptionsScreen());
|
|
}
|
|
if (button->id == bServerVisibility->id) {
|
|
if (minecraft->raknetInstance && minecraft->netCallback && minecraft->raknetInstance->isServer()) {
|
|
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) minecraft->netCallback;
|
|
bool allows = !ss->allowsIncomingConnections();
|
|
ss->allowIncomingConnections(allows);
|
|
|
|
updateServerVisibilityText();
|
|
}
|
|
}
|
|
|
|
if (button->id == OptionButton::ButtonId) {
|
|
((OptionButton*)button)->toggle(&minecraft->options);
|
|
}
|
|
|
|
//if (button->id == bThirdPerson->id) {
|
|
// minecraft->options.thirdPersonView = !minecraft->options.thirdPersonView;
|
|
//}
|
|
}
|
|
|
|
void PauseScreen::updateServerVisibilityText()
|
|
{
|
|
if (!minecraft->raknetInstance || !minecraft->raknetInstance->isServer())
|
|
return;
|
|
|
|
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) minecraft->netCallback;
|
|
bServerVisibility->msg = ss->allowsIncomingConnections()?
|
|
"Server is visible"
|
|
: "Server is invisible";
|
|
}
|