mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-22 16:03:31 +00:00
FIX: Rewrite options
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
//package net.minecraft.client.gui;
|
||||
|
||||
#include "../Screen.h"
|
||||
#include "../components/SmallButton.h"
|
||||
#include <string>
|
||||
|
||||
class ConfirmScreen: public Screen
|
||||
|
||||
@@ -48,7 +48,7 @@ void ConsoleScreen::keyPressed(int eventKey)
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleScreen::keyboardNewChar(char inputChar)
|
||||
void ConsoleScreen::charPressed(char inputChar)
|
||||
{
|
||||
if (inputChar >= 32 && inputChar < 127)
|
||||
_input += inputChar;
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
virtual bool isPauseScreen() { return false; }
|
||||
|
||||
virtual void keyPressed(int eventKey);
|
||||
virtual void keyboardNewChar(char inputChar);
|
||||
virtual void charPressed(char inputChar);
|
||||
virtual bool handleBackEvent(bool isDown);
|
||||
|
||||
private:
|
||||
|
||||
@@ -169,19 +169,19 @@ void IngameBlockSelectionScreen::keyPressed(int eventKey)
|
||||
int tmpSelectedSlot = selectedItem;
|
||||
|
||||
Options& o = minecraft->options;
|
||||
if (eventKey == o.keyLeft.key && selX > 0)
|
||||
if (eventKey == o.getIntValue(OPTIONS_KEY_LEFT) && selX > 0)
|
||||
{
|
||||
tmpSelectedSlot -= 1;
|
||||
}
|
||||
else if (eventKey == o.keyRight.key && selX < (InventoryCols - 1))
|
||||
else if (eventKey == o.getIntValue(OPTIONS_KEY_RIGHT) && selX < (InventoryCols - 1))
|
||||
{
|
||||
tmpSelectedSlot += 1;
|
||||
}
|
||||
else if (eventKey == o.keyDown.key && selY < (InventoryRows - 1))
|
||||
else if (eventKey == o.getIntValue(OPTIONS_KEY_BACK) && selY < (InventoryRows - 1))
|
||||
{
|
||||
tmpSelectedSlot += InventoryCols;
|
||||
}
|
||||
else if (eventKey == o.keyUp.key && selY > 0)
|
||||
else if (eventKey == o.getIntValue(OPTIONS_KEY_FORWARD) && selY > 0)
|
||||
{
|
||||
tmpSelectedSlot -= InventoryCols;
|
||||
}
|
||||
@@ -189,15 +189,15 @@ void IngameBlockSelectionScreen::keyPressed(int eventKey)
|
||||
if (isAllowed(tmpSelectedSlot))
|
||||
selectedItem = tmpSelectedSlot;
|
||||
|
||||
if (eventKey == o.keyMenuOk.key)
|
||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_OK))
|
||||
selectSlotAndClose();
|
||||
|
||||
#ifdef RPI
|
||||
if (eventKey == o.keyMenuCancel.key
|
||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_CANCEL)
|
||||
|| eventKey == Keyboard::KEY_ESCAPE)
|
||||
minecraft->setScreen(NULL);
|
||||
#else
|
||||
if (eventKey == o.keyMenuCancel.key)
|
||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_CANCEL))
|
||||
minecraft->setScreen(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "../Screen.h"
|
||||
#include "../components/Button.h"
|
||||
#include "../components/SmallButton.h"
|
||||
#include "../components/ScrolledSelectionList.h"
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../../network/RakNetInstance.h"
|
||||
|
||||
@@ -7,14 +7,12 @@
|
||||
#include "../../../AppPlatform.h"
|
||||
#include "CreditsScreen.h"
|
||||
|
||||
#include "../components/OptionsPane.h"
|
||||
#include "../components/ImageButton.h"
|
||||
#include "../components/OptionsGroup.h"
|
||||
|
||||
OptionsScreen::OptionsScreen()
|
||||
: btnClose(NULL),
|
||||
bHeader(NULL),
|
||||
btnChangeUsername(NULL),
|
||||
btnCredits(NULL),
|
||||
selectedCategory(0) {
|
||||
}
|
||||
@@ -31,11 +29,6 @@ OptionsScreen::~OptionsScreen() {
|
||||
bHeader = NULL;
|
||||
}
|
||||
|
||||
if (btnChangeUsername != NULL) {
|
||||
delete btnChangeUsername;
|
||||
btnChangeUsername = NULL;
|
||||
}
|
||||
|
||||
if (btnCredits != NULL) {
|
||||
delete btnCredits;
|
||||
btnCredits = NULL;
|
||||
@@ -48,7 +41,7 @@ OptionsScreen::~OptionsScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
for (std::vector<OptionsPane*>::iterator it = optionPanes.begin(); it != optionPanes.end(); ++it) {
|
||||
for (std::vector<OptionsGroup*>::iterator it = optionPanes.begin(); it != optionPanes.end(); ++it) {
|
||||
if (*it != NULL) {
|
||||
delete* it;
|
||||
*it = NULL;
|
||||
@@ -72,17 +65,15 @@ void OptionsScreen::init() {
|
||||
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
|
||||
btnClose->setImageDef(def, true);
|
||||
|
||||
categoryButtons.push_back(new Touch::TButton(2, "Login"));
|
||||
categoryButtons.push_back(new Touch::TButton(2, "General"));
|
||||
categoryButtons.push_back(new Touch::TButton(3, "Game"));
|
||||
categoryButtons.push_back(new Touch::TButton(4, "Controls"));
|
||||
categoryButtons.push_back(new Touch::TButton(5, "Graphics"));
|
||||
|
||||
btnChangeUsername = new Touch::TButton(10, "Username");
|
||||
btnCredits = new Touch::TButton(11, "Credits");
|
||||
|
||||
buttons.push_back(bHeader);
|
||||
buttons.push_back(btnClose);
|
||||
buttons.push_back(btnChangeUsername);
|
||||
buttons.push_back(btnCredits);
|
||||
|
||||
for (std::vector<Touch::TButton*>::iterator it = categoryButtons.begin(); it != categoryButtons.end(); ++it) {
|
||||
@@ -118,27 +109,13 @@ void OptionsScreen::setupPositions() {
|
||||
bHeader->width = width - btnClose->width;
|
||||
bHeader->height = btnClose->height;
|
||||
|
||||
// Username button (bottom-left)
|
||||
if (btnChangeUsername != NULL) {
|
||||
|
||||
btnChangeUsername->width = categoryButtons.empty() ? 80 : categoryButtons[0]->width;
|
||||
btnChangeUsername->height = btnClose->height;
|
||||
|
||||
btnChangeUsername->x = 0;
|
||||
btnChangeUsername->y = height - btnChangeUsername->height;
|
||||
}
|
||||
|
||||
// Credits button (bottom-right)
|
||||
if (btnCredits != NULL) {
|
||||
|
||||
btnCredits->width = btnChangeUsername->width;
|
||||
btnCredits->height = btnChangeUsername->height;
|
||||
|
||||
btnCredits->x = width - btnCredits->width;
|
||||
btnCredits->y = height - btnCredits->height;
|
||||
}
|
||||
|
||||
for (std::vector<OptionsPane*>::iterator it = optionPanes.begin(); it != optionPanes.end(); ++it) {
|
||||
for (std::vector<OptionsGroup*>::iterator it = optionPanes.begin(); it != optionPanes.end(); ++it) {
|
||||
|
||||
if (categoryButtons.size() > 0 && categoryButtons[0] != NULL) {
|
||||
|
||||
@@ -158,13 +135,13 @@ void OptionsScreen::render(int xm, int ym, float a) {
|
||||
|
||||
renderBackground();
|
||||
|
||||
super::render(xm, ym, a);
|
||||
|
||||
int xmm = xm * width / minecraft->width;
|
||||
int ymm = ym * height / minecraft->height - 1;
|
||||
|
||||
if (currentOptionPane != NULL)
|
||||
currentOptionPane->render(minecraft, xmm, ymm);
|
||||
if (currentOptionsGroup != NULL)
|
||||
currentOptionsGroup->render(minecraft, xmm, ymm);
|
||||
|
||||
super::render(xm, ym, a);
|
||||
}
|
||||
|
||||
void OptionsScreen::removed() {
|
||||
@@ -173,16 +150,9 @@ void OptionsScreen::removed() {
|
||||
void OptionsScreen::buttonClicked(Button* button) {
|
||||
|
||||
if (button == btnClose) {
|
||||
|
||||
minecraft->options.save();
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
|
||||
}
|
||||
else if (button == btnChangeUsername) {
|
||||
|
||||
minecraft->options.save();
|
||||
minecraft->setScreen(new UsernameScreen());
|
||||
|
||||
}
|
||||
else if (button->id > 1 && button->id < 7) {
|
||||
|
||||
@@ -212,63 +182,88 @@ void OptionsScreen::selectCategory(int index) {
|
||||
}
|
||||
|
||||
if (index < (int)optionPanes.size())
|
||||
currentOptionPane = optionPanes[index];
|
||||
currentOptionsGroup = optionPanes[index];
|
||||
}
|
||||
|
||||
void OptionsScreen::generateOptionScreens() {
|
||||
// how the fuck it works
|
||||
|
||||
optionPanes.push_back(new OptionsPane());
|
||||
optionPanes.push_back(new OptionsPane());
|
||||
optionPanes.push_back(new OptionsPane());
|
||||
optionPanes.push_back(new OptionsPane());
|
||||
optionPanes.push_back(new OptionsGroup("options.group.general"));
|
||||
optionPanes.push_back(new OptionsGroup("options.group.game"));
|
||||
optionPanes.push_back(new OptionsGroup("options.group.control"));
|
||||
optionPanes.push_back(new OptionsGroup("options.group.graphics"));
|
||||
|
||||
// Login Pane
|
||||
optionPanes[0]->createOptionsGroup("options.group.mojang")
|
||||
.addOptionItem(&Options::Option::SENSITIVITY, minecraft);
|
||||
// General Pane
|
||||
optionPanes[0]->addOptionItem(OPTIONS_USERNAME, minecraft)
|
||||
.addOptionItem(OPTIONS_SENSITIVITY, minecraft);
|
||||
|
||||
// Game Pane
|
||||
optionPanes[1]->createOptionsGroup("options.group.game")
|
||||
.addOptionItem(&Options::Option::DIFFICULTY, minecraft)
|
||||
.addOptionItem(&Options::Option::SERVER_VISIBLE, minecraft)
|
||||
.addOptionItem(&Options::Option::THIRD_PERSON, minecraft)
|
||||
.addOptionItem(&Options::Option::GUI_SCALE, minecraft);
|
||||
optionPanes[1]->addOptionItem(OPTIONS_DIFFICULTY, minecraft)
|
||||
.addOptionItem(OPTIONS_SERVER_VISIBLE, minecraft)
|
||||
.addOptionItem(OPTIONS_THIRD_PERSON_VIEW, minecraft)
|
||||
.addOptionItem(OPTIONS_GUI_SCALE, minecraft)
|
||||
.addOptionItem(OPTIONS_SENSITIVITY, minecraft)
|
||||
.addOptionItem(OPTIONS_MUSIC_VOLUME, minecraft)
|
||||
.addOptionItem(OPTIONS_SOUND_VOLUME, minecraft)
|
||||
.addOptionItem(OPTIONS_SMOOTH_CAMERA, minecraft)
|
||||
.addOptionItem(OPTIONS_DESTROY_VIBRATION, minecraft)
|
||||
.addOptionItem(OPTIONS_IS_LEFT_HANDED, minecraft);
|
||||
|
||||
// Controls Pane
|
||||
optionPanes[2]->createOptionsGroup("options.group.controls")
|
||||
.addOptionItem(&Options::Option::INVERT_MOUSE, minecraft);
|
||||
// // Controls Pane
|
||||
optionPanes[2]->addOptionItem(OPTIONS_INVERT_Y_MOUSE, minecraft)
|
||||
.addOptionItem(OPTIONS_USE_TOUCHSCREEN, minecraft);
|
||||
|
||||
// Graphics Pane
|
||||
optionPanes[3]->createOptionsGroup("options.group.graphics")
|
||||
.addOptionItem(&Options::Option::GRAPHICS, minecraft)
|
||||
.addOptionItem(&Options::Option::VIEW_BOBBING, minecraft)
|
||||
.addOptionItem(&Options::Option::AMBIENT_OCCLUSION, minecraft)
|
||||
.addOptionItem(&Options::Option::ANAGLYPH, minecraft)
|
||||
.addOptionItem(&Options::Option::LIMIT_FRAMERATE, minecraft)
|
||||
.addOptionItem(&Options::Option::VSYNC, minecraft)
|
||||
.addOptionItem(&Options::Option::MUSIC, minecraft)
|
||||
.addOptionItem(&Options::Option::SOUND, minecraft);
|
||||
for (int i = OPTIONS_KEY_FORWARD; i <= OPTIONS_KEY_USE; i++) {
|
||||
optionPanes[2]->addOptionItem((OptionId)i, minecraft);
|
||||
}
|
||||
|
||||
// // Graphics Pane
|
||||
optionPanes[3]->addOptionItem(OPTIONS_FANCY_GRAPHICS, minecraft)
|
||||
// .addOptionItem(&Options::Option::VIEW_BOBBING, minecraft)
|
||||
// .addOptionItem(&Options::Option::AMBIENT_OCCLUSION, minecraft)
|
||||
// .addOptionItem(&Options::Option::ANAGLYPH, minecraft)
|
||||
.addOptionItem(OPTIONS_LIMIT_FRAMERATE, minecraft)
|
||||
.addOptionItem(OPTIONS_VSYNC, minecraft)
|
||||
.addOptionItem(OPTIONS_RENDER_DEBUG, minecraft)
|
||||
.addOptionItem(OPTIONS_ANAGLYPH_3D, minecraft)
|
||||
.addOptionItem(OPTIONS_VIEW_BOBBING, minecraft)
|
||||
.addOptionItem(OPTIONS_AMBIENT_OCCLUSION, minecraft);
|
||||
}
|
||||
|
||||
void OptionsScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||
|
||||
if (currentOptionPane != NULL)
|
||||
currentOptionPane->mouseClicked(minecraft, x, y, buttonNum);
|
||||
if (currentOptionsGroup != NULL)
|
||||
currentOptionsGroup->mouseClicked(minecraft, x, y, buttonNum);
|
||||
|
||||
super::mouseClicked(x, y, buttonNum);
|
||||
}
|
||||
|
||||
void OptionsScreen::mouseReleased(int x, int y, int buttonNum) {
|
||||
|
||||
if (currentOptionPane != NULL)
|
||||
currentOptionPane->mouseReleased(minecraft, x, y, buttonNum);
|
||||
if (currentOptionsGroup != NULL)
|
||||
currentOptionsGroup->mouseReleased(minecraft, x, y, buttonNum);
|
||||
|
||||
super::mouseReleased(x, y, buttonNum);
|
||||
}
|
||||
|
||||
void OptionsScreen::keyPressed(int eventKey) {
|
||||
if (currentOptionsGroup != NULL)
|
||||
currentOptionsGroup->keyPressed(minecraft, eventKey);
|
||||
|
||||
super::keyPressed(eventKey);
|
||||
}
|
||||
|
||||
void OptionsScreen::charPressed(char inputChar) {
|
||||
if (currentOptionsGroup != NULL)
|
||||
currentOptionsGroup->charPressed(minecraft, inputChar);
|
||||
|
||||
super::keyPressed(inputChar);
|
||||
}
|
||||
|
||||
void OptionsScreen::tick() {
|
||||
|
||||
if (currentOptionPane != NULL)
|
||||
currentOptionPane->tick(minecraft);
|
||||
if (currentOptionsGroup != NULL)
|
||||
currentOptionsGroup->tick(minecraft);
|
||||
|
||||
super::tick();
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "../Screen.h"
|
||||
#include "../components/Button.h"
|
||||
#include "../components/OptionsGroup.h"
|
||||
|
||||
class ImageButton;
|
||||
class OptionsPane;
|
||||
@@ -26,19 +27,21 @@ public:
|
||||
|
||||
virtual void mouseClicked(int x, int y, int buttonNum);
|
||||
virtual void mouseReleased(int x, int y, int buttonNum);
|
||||
virtual void keyPressed(int eventKey);
|
||||
virtual void charPressed(char inputChar);
|
||||
|
||||
virtual void tick();
|
||||
|
||||
private:
|
||||
Touch::THeader* bHeader;
|
||||
ImageButton* btnClose;
|
||||
|
||||
Button* btnChangeUsername;
|
||||
Button* btnCredits; // <-- ADD THIS
|
||||
|
||||
std::vector<Touch::TButton*> categoryButtons;
|
||||
std::vector<OptionsPane*> optionPanes;
|
||||
std::vector<OptionsGroup*> optionPanes;
|
||||
|
||||
OptionsPane* currentOptionPane;
|
||||
OptionsGroup* currentOptionsGroup;
|
||||
|
||||
int selectedCategory;
|
||||
};
|
||||
|
||||
@@ -15,9 +15,9 @@ PauseScreen::PauseScreen(bool wasBackPaused)
|
||||
bServerVisibility(0),
|
||||
// bThirdPerson(0),
|
||||
wasBackPaused(wasBackPaused),
|
||||
bSound(&Options::Option::SOUND, 1, 0),
|
||||
bThirdPerson(&Options::Option::THIRD_PERSON),
|
||||
bHideGui(&Options::Option::HIDE_GUI)
|
||||
// bSound(OPTIONS_SOUND_VOLUME, 1, 0),
|
||||
bThirdPerson(OPTIONS_THIRD_PERSON_VIEW),
|
||||
bHideGui(OPTIONS_HIDEGUI)
|
||||
{
|
||||
ImageDef def;
|
||||
def.setSrc(IntRectangle(160, 144, 39, 31));
|
||||
@@ -27,7 +27,7 @@ PauseScreen::PauseScreen(bool wasBackPaused)
|
||||
def.width = defSrc.w * 0.666667f;
|
||||
def.height = defSrc.h * 0.666667f;
|
||||
|
||||
bSound.setImageDef(def, true);
|
||||
// bSound.setImageDef(def, true);
|
||||
defSrc.y += defSrc.h;
|
||||
bThirdPerson.setImageDef(def, true);
|
||||
bHideGui.setImageDef(def, true);
|
||||
@@ -60,10 +60,10 @@ void PauseScreen::init() {
|
||||
buttons.push_back(bContinue);
|
||||
buttons.push_back(bQuit);
|
||||
|
||||
bSound.updateImage(&minecraft->options);
|
||||
// bSound.updateImage(&minecraft->options);
|
||||
bThirdPerson.updateImage(&minecraft->options);
|
||||
bHideGui.updateImage(&minecraft->options);
|
||||
buttons.push_back(&bSound);
|
||||
// buttons.push_back(&bSound);
|
||||
buttons.push_back(&bThirdPerson);
|
||||
//buttons.push_back(&bHideGui);
|
||||
|
||||
@@ -88,7 +88,7 @@ void PauseScreen::init() {
|
||||
// buttons.push_back(bThirdPerson);
|
||||
|
||||
for (unsigned int i = 0; i < buttons.size(); ++i) {
|
||||
if (buttons[i] == &bSound) continue;
|
||||
// if (buttons[i] == &bSound) continue;
|
||||
if (buttons[i] == &bThirdPerson) continue;
|
||||
if (buttons[i] == &bHideGui) continue;
|
||||
tabButtons.push_back(buttons[i]);
|
||||
@@ -115,10 +115,10 @@ void PauseScreen::setupPositions() {
|
||||
bQuitAndSaveLocally->x = bServerVisibility->x = (width - bQuitAndSaveLocally->width) / 2;
|
||||
bQuitAndSaveLocally->y = bServerVisibility->y = yBase + 32 * 3;
|
||||
|
||||
bSound.y = bThirdPerson.y = 8;
|
||||
bSound.x = 4;
|
||||
bThirdPerson.x = bSound.x + 4 + bSound.width;
|
||||
bHideGui.x = bThirdPerson.x + 4 + bThirdPerson.width;
|
||||
// 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;
|
||||
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
Button* bServerVisibility;
|
||||
// Button* bThirdPerson;
|
||||
|
||||
OptionButton bSound;
|
||||
// OptionButton bSound;
|
||||
OptionButton bThirdPerson;
|
||||
OptionButton bHideGui;
|
||||
};
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#include "../../Minecraft.h"
|
||||
|
||||
#include <client/gui/screens/UsernameScreen.h>
|
||||
|
||||
Screen* ScreenChooser::createScreen( ScreenId id )
|
||||
{
|
||||
Screen* screen = NULL;
|
||||
|
||||
@@ -415,9 +415,9 @@ bool SelectWorldScreen::isInGameScreen() { return true; }
|
||||
void SelectWorldScreen::keyPressed( int eventKey )
|
||||
{
|
||||
if (bWorldView.selected) {
|
||||
if (eventKey == minecraft->options.keyLeft.key)
|
||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_RIGHT))
|
||||
worldsList->stepLeft();
|
||||
if (eventKey == minecraft->options.keyRight.key)
|
||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_LEFT))
|
||||
worldsList->stepRight();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "../Screen.h"
|
||||
#include "../TweenData.h"
|
||||
#include "../components/Button.h"
|
||||
#include "../components/SmallButton.h"
|
||||
#include "../components/RolledSelectionListH.h"
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../../world/level/storage/LevelStorageSource.h"
|
||||
|
||||
@@ -223,12 +223,6 @@ void SimpleChooseLevelScreen::keyPressed(int eventKey)
|
||||
Screen::keyPressed(eventKey);
|
||||
}
|
||||
|
||||
void SimpleChooseLevelScreen::keyboardNewChar(char inputChar)
|
||||
{
|
||||
// forward character input to focused textbox(s)
|
||||
for (auto* tb : textBoxes) tb->handleChar(inputChar);
|
||||
}
|
||||
|
||||
bool SimpleChooseLevelScreen::handleBackEvent(bool isDown) {
|
||||
if (!isDown)
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
|
||||
@@ -23,7 +23,6 @@ public:
|
||||
void buttonClicked(Button* button);
|
||||
bool handleBackEvent(bool isDown);
|
||||
virtual void keyPressed(int eventKey);
|
||||
virtual void keyboardNewChar(char inputChar);
|
||||
virtual void mouseClicked(int x, int y, int buttonNum);
|
||||
|
||||
private:
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "../../../util/Mth.h"
|
||||
|
||||
#include "../Font.h"
|
||||
#include "../components/SmallButton.h"
|
||||
#include "../components/ScrolledSelectionList.h"
|
||||
|
||||
#include "../../Minecraft.h"
|
||||
@@ -38,7 +37,7 @@ void StartMenuScreen::init()
|
||||
|
||||
bJoin.active = bHost.active = bOptions.active = true;
|
||||
|
||||
if (minecraft->options.username.empty()) {
|
||||
if (minecraft->options.getStringValue(OPTIONS_USERNAME).empty()) {
|
||||
return; // tick() will redirect to UsernameScreen
|
||||
}
|
||||
|
||||
@@ -105,7 +104,7 @@ void StartMenuScreen::setupPositions() {
|
||||
}
|
||||
|
||||
void StartMenuScreen::tick() {
|
||||
if (minecraft->options.username.empty()) {
|
||||
if (minecraft->options.getStringValue(OPTIONS_USERNAME).empty()) {
|
||||
minecraft->setScreen(new UsernameScreen());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ void TextEditScreen::keyPressed( int eventKey ) {
|
||||
}
|
||||
}
|
||||
|
||||
void TextEditScreen::keyboardNewChar( char inputChar ) {
|
||||
void TextEditScreen::charPressed( char inputChar ) {
|
||||
std::string fullstring = sign->messages[line] + inputChar;
|
||||
if(fullstring.length() < 16) {
|
||||
sign->messages[line] = fullstring;
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
void render(int xm, int ym, float a);
|
||||
virtual void lostFocus();
|
||||
virtual void keyPressed(int eventKey);
|
||||
virtual void keyboardNewChar(char inputChar);
|
||||
virtual void charPressed(char inputChar);
|
||||
void setupPositions();
|
||||
void buttonClicked(Button* button);
|
||||
protected:
|
||||
|
||||
@@ -63,30 +63,6 @@ void UsernameScreen::keyPressed(int eventKey)
|
||||
Screen::keyPressed(eventKey);
|
||||
}
|
||||
|
||||
void UsernameScreen::keyboardNewChar(char inputChar)
|
||||
{
|
||||
for (auto* tb : textBoxes) tb->handleChar(inputChar);
|
||||
}
|
||||
|
||||
void UsernameScreen::mouseClicked(int x, int y, int button)
|
||||
{
|
||||
int lvlTop = tUsername.y - (Font::DefaultLineHeight + 4);
|
||||
int lvlBottom = tUsername.y + tUsername.height;
|
||||
int lvlLeft = tUsername.x;
|
||||
int lvlRight = tUsername.x + tUsername.width;
|
||||
bool clickedLevel = x >= lvlLeft && x < lvlRight && y >= lvlTop && y < lvlBottom;
|
||||
|
||||
if (clickedLevel) {
|
||||
tUsername.setFocus(minecraft);
|
||||
} else {
|
||||
// click outside both fields -> blur both
|
||||
tUsername.loseFocus(minecraft);
|
||||
}
|
||||
|
||||
// also let the parent class handle button presses/etc.
|
||||
Screen::mouseClicked(x, y, button);
|
||||
}
|
||||
|
||||
void UsernameScreen::removed()
|
||||
{
|
||||
minecraft->platform()->hideKeyboard();
|
||||
@@ -95,7 +71,7 @@ void UsernameScreen::removed()
|
||||
void UsernameScreen::buttonClicked(Button* button)
|
||||
{
|
||||
if (button == &_btnDone && !tUsername.text.empty()) {
|
||||
minecraft->options.username = tUsername.text;
|
||||
minecraft->options.set(OPTIONS_USERNAME, tUsername.text);
|
||||
minecraft->options.save();
|
||||
minecraft->user->name = tUsername.text;
|
||||
minecraft->setScreen(NULL); // goes to StartMenuScreen
|
||||
|
||||
@@ -13,24 +13,22 @@ public:
|
||||
UsernameScreen();
|
||||
virtual ~UsernameScreen();
|
||||
|
||||
void init();
|
||||
void init() override;
|
||||
virtual void setupPositions() override;
|
||||
void render(int xm, int ym, float a);
|
||||
void tick();
|
||||
void render(int xm, int ym, float a) override;
|
||||
void tick() override;
|
||||
|
||||
virtual bool isPauseScreen() { return false; }
|
||||
virtual bool isPauseScreen() override { return false; }
|
||||
|
||||
virtual void keyPressed(int eventKey);
|
||||
virtual void keyboardNewChar(char inputChar);
|
||||
virtual bool handleBackEvent(bool isDown) { return true; } // block back/escape
|
||||
virtual void removed();
|
||||
virtual void mouseClicked(int x, int y, int button);
|
||||
virtual void keyPressed(int eventKey) override;
|
||||
virtual bool handleBackEvent(bool isDown) override { return true; } // block back/escape
|
||||
virtual void removed() override;
|
||||
|
||||
protected:
|
||||
virtual void buttonClicked(Button* button);
|
||||
virtual void buttonClicked(Button* button) override;
|
||||
|
||||
private:
|
||||
Button _btnDone;
|
||||
Touch::TButton _btnDone;
|
||||
TextBox tUsername;
|
||||
std::string _input;
|
||||
int _cursorBlink;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "../../Screen.h"
|
||||
#include "../../components/Button.h"
|
||||
#include "../../components/SmallButton.h"
|
||||
#include "../../components/RolledSelectionListV.h"
|
||||
#include "../../../Minecraft.h"
|
||||
#include "../../../../platform/input/Multitouch.h"
|
||||
|
||||
@@ -552,9 +552,9 @@ bool SelectWorldScreen::isInGameScreen() { return true; }
|
||||
void SelectWorldScreen::keyPressed( int eventKey )
|
||||
{
|
||||
if (bWorldView.selected) {
|
||||
if (eventKey == minecraft->options.keyLeft.key)
|
||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_LEFT))
|
||||
worldsList->stepLeft();
|
||||
if (eventKey == minecraft->options.keyRight.key)
|
||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_RIGHT))
|
||||
worldsList->stepRight();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "../PauseScreen.h"
|
||||
|
||||
#include "../../Font.h"
|
||||
#include "../../components/SmallButton.h"
|
||||
#include "../../components/ScrolledSelectionList.h"
|
||||
#include "../../components/GuiElement.h"
|
||||
|
||||
@@ -58,7 +57,6 @@ void StartMenuScreen::init()
|
||||
buttons.push_back(&bHost);
|
||||
buttons.push_back(&bJoin);
|
||||
buttons.push_back(&bOptions);
|
||||
|
||||
|
||||
|
||||
tabButtons.push_back(&bHost);
|
||||
|
||||
Reference in New Issue
Block a user