mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-19 22:43:32 +00:00
TextBox / removed BuyButton / impoved CreateWorldScreen
This commit is contained in:
@@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 14)
|
|||||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
CPMAddPackage("gh:madler/zlib@1.3.2")
|
CPMAddPackage("gh:madler/zlib@1.3.2")
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ void Screen::render( int xm, int ym, float a )
|
|||||||
Button* button = buttons[i];
|
Button* button = buttons[i];
|
||||||
button->render(minecraft, xm, ym);
|
button->render(minecraft, xm, ym);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < textBoxes.size(); i++) {
|
||||||
|
TextBox* textbox = textBoxes[i];
|
||||||
|
textbox->render(minecraft, xm, ym);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::init( Minecraft* minecraft, int width, int height )
|
void Screen::init( Minecraft* minecraft, int width, int height )
|
||||||
@@ -157,6 +162,11 @@ void Screen::keyPressed( int eventKey )
|
|||||||
minecraft->setScreen(NULL);
|
minecraft->setScreen(NULL);
|
||||||
//minecraft->grabMouse();
|
//minecraft->grabMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto& textbox : textBoxes) {
|
||||||
|
textbox->handleKey(eventKey);
|
||||||
|
}
|
||||||
|
|
||||||
if (minecraft->useTouchscreen())
|
if (minecraft->useTouchscreen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -181,6 +191,14 @@ void Screen::keyPressed( int eventKey )
|
|||||||
updateTabButtonSelection();
|
updateTabButtonSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Screen::keyboardNewChar(char inputChar) {
|
||||||
|
// yeah im using these modern cpp features in this project :sunglasses:
|
||||||
|
|
||||||
|
for (auto& textbox : textBoxes) {
|
||||||
|
textbox->handleChar(inputChar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Screen::updateTabButtonSelection()
|
void Screen::updateTabButtonSelection()
|
||||||
{
|
{
|
||||||
if (minecraft->useTouchscreen())
|
if (minecraft->useTouchscreen())
|
||||||
@@ -210,6 +228,10 @@ void Screen::mouseClicked( int x, int y, int buttonNum )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto& textbox : textBoxes) {
|
||||||
|
textbox->mouseClicked(minecraft, x, y, buttonNum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::mouseReleased( int x, int y, int buttonNum )
|
void Screen::mouseReleased( int x, int y, int buttonNum )
|
||||||
@@ -253,3 +275,9 @@ void Screen::toGUICoordinate( int& x, int& y ) {
|
|||||||
x = x * width / minecraft->width;
|
x = x * width / minecraft->width;
|
||||||
y = y * height / minecraft->height - 1;
|
y = y * height / minecraft->height - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Screen::tick() {
|
||||||
|
for (auto& textbox : textBoxes) {
|
||||||
|
textbox->tick(minecraft);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
virtual void keyboardTextEvent();
|
virtual void keyboardTextEvent();
|
||||||
virtual bool handleBackEvent(bool isDown);
|
virtual bool handleBackEvent(bool isDown);
|
||||||
|
|
||||||
virtual void tick() {}
|
virtual void tick();
|
||||||
|
|
||||||
virtual void removed() {}
|
virtual void removed() {}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ protected:
|
|||||||
virtual void mouseReleased(int x, int y, int buttonNum);
|
virtual void mouseReleased(int x, int y, int buttonNum);
|
||||||
|
|
||||||
virtual void keyPressed(int eventKey);
|
virtual void keyPressed(int eventKey);
|
||||||
virtual void keyboardNewChar(char inputChar) {}
|
virtual void keyboardNewChar(char inputChar);
|
||||||
public:
|
public:
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
#include "TextBox.h"
|
#include "TextBox.h"
|
||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
#include "../../../AppPlatform.h"
|
#include "../../../AppPlatform.h"
|
||||||
TextBox::TextBox( int id, const std::string& msg )
|
#include "platform/input/Mouse.h"
|
||||||
: id(0), w(0), h(0), x(0), y(0), text(msg), focused(false) {
|
|
||||||
|
|
||||||
}
|
TextBox::TextBox( int id, const std::string& msg )
|
||||||
|
: TextBox(id, 0, 0, msg) {}
|
||||||
|
|
||||||
TextBox::TextBox( int id, int x, int y, const std::string& msg )
|
TextBox::TextBox( int id, int x, int y, const std::string& msg )
|
||||||
: id(id), w(0), h(0), x(x), y(y), text(msg), focused(false) {
|
: TextBox(id, x, y, 24, msg) {}
|
||||||
|
|
||||||
}
|
TextBox::TextBox( int id, int x, int y, int w, const std::string& msg )
|
||||||
|
: GuiElement(true, true, x, y, w, Font::DefaultLineHeight + 4),
|
||||||
TextBox::TextBox( int id, int x, int y, int w, int h, const std::string& msg )
|
id(id), hint(msg), focused(false), blink(false) {}
|
||||||
: id(id), w(w), h(h), x(x), y(y), text(msg) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextBox::setFocus(Minecraft* minecraft) {
|
void TextBox::setFocus(Minecraft* minecraft) {
|
||||||
if(!focused) {
|
if(!focused) {
|
||||||
minecraft->platform()->showKeyboard();
|
minecraft->platform()->showKeyboard();
|
||||||
focused = true;
|
focused = true;
|
||||||
|
|
||||||
|
blinkTicks = 0;
|
||||||
|
blink = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +32,59 @@ bool TextBox::loseFocus(Minecraft* minecraft) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBox::render( Minecraft* minecraft, int xm, int ym ) {
|
void TextBox::mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {
|
||||||
|
if (buttonNum == MouseAction::ACTION_LEFT) {
|
||||||
|
if (pointInside(x, y)) {
|
||||||
|
setFocus(minecraft);
|
||||||
|
} else {
|
||||||
|
loseFocus(minecraft);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextBox::handleChar(char c) {
|
||||||
|
if (focused) {
|
||||||
|
text.push_back(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextBox::handleKey(int key) {
|
||||||
|
if (focused && key == Keyboard::KEY_BACKSPACE && !text.empty()) {
|
||||||
|
text.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextBox::tick(Minecraft* minecraft) {
|
||||||
|
blinkTicks++;
|
||||||
|
|
||||||
|
if (blinkTicks >= 5) {
|
||||||
|
blink = !blink;
|
||||||
|
blinkTicks = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextBox::render( Minecraft* minecraft, int xm, int ym ) {
|
||||||
|
// textbox like in beta 1.7.3
|
||||||
|
fill(x, y, x + width, y + height, 0xffa0a0a0);
|
||||||
|
fill(x + 1, y + 1, x + width - 1, y + height - 1, 0xff000000);
|
||||||
|
|
||||||
|
glEnable2(GL_SCISSOR_TEST);
|
||||||
|
glScissor(
|
||||||
|
Gui::GuiScale * (x + 2),
|
||||||
|
minecraft->height - Gui::GuiScale * (y + height - 2),
|
||||||
|
Gui::GuiScale * (width - 2),
|
||||||
|
Gui::GuiScale * (height - 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (text.empty() && !focused) {
|
||||||
|
drawString(minecraft->font, hint, x + 2, y + 2, 0xff5e5e5e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (focused && blink) text.push_back('_');
|
||||||
|
|
||||||
|
drawString(minecraft->font, text, x + 2, y + 2, 0xffffffff);
|
||||||
|
|
||||||
|
if (focused && blink) text.pop_back();
|
||||||
|
|
||||||
|
glDisable2(GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,31 +4,39 @@
|
|||||||
//package net.minecraft.client.gui;
|
//package net.minecraft.client.gui;
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../GuiComponent.h"
|
#include "GuiElement.h"
|
||||||
#include "../../Options.h"
|
#include "../../Options.h"
|
||||||
|
|
||||||
class Font;
|
class Font;
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
|
|
||||||
class TextBox: public GuiComponent
|
class TextBox: public GuiElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextBox(int id, const std::string& msg);
|
TextBox(int id, const std::string& msg);
|
||||||
TextBox(int id, int x, int y, const std::string& msg);
|
TextBox(int id, int x, int y, const std::string& msg);
|
||||||
TextBox(int id, int x, int y, int w, int h, const std::string& msg);
|
TextBox(int id, int x, int y, int w, const std::string& msg);
|
||||||
|
|
||||||
|
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum);
|
||||||
|
|
||||||
virtual void setFocus(Minecraft* minecraft);
|
virtual void setFocus(Minecraft* minecraft);
|
||||||
virtual bool loseFocus(Minecraft* minecraft);
|
virtual bool loseFocus(Minecraft* minecraft);
|
||||||
|
|
||||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||||
|
|
||||||
|
virtual void handleKey(int key);
|
||||||
|
virtual void handleChar(char c);
|
||||||
|
virtual void tick(Minecraft* minecraft);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int w, h;
|
std::string hint;
|
||||||
int x, y;
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
|
int blinkTicks;
|
||||||
|
|
||||||
bool focused;
|
bool focused;
|
||||||
|
bool blink;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__TextBox_H__*/
|
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__TextBox_H__*/
|
||||||
|
|||||||
@@ -5,52 +5,74 @@
|
|||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
#include "../../../world/level/LevelSettings.h"
|
#include "../../../world/level/LevelSettings.h"
|
||||||
#include "../../../platform/time.h"
|
#include "../../../platform/time.h"
|
||||||
|
#include "client/gamemode/GameMode.h"
|
||||||
|
|
||||||
SimpleChooseLevelScreen::SimpleChooseLevelScreen(const std::string& levelName)
|
SimpleChooseLevelScreen::SimpleChooseLevelScreen(const std::string& levelName)
|
||||||
: bCreative(0),
|
:
|
||||||
bSurvival(0),
|
// bCreative(0),
|
||||||
|
bGamemode(0),
|
||||||
bBack(0),
|
bBack(0),
|
||||||
|
bCreate(0),
|
||||||
levelName(levelName),
|
levelName(levelName),
|
||||||
hasChosen(false)
|
hasChosen(false),
|
||||||
|
gamemode(GameType::Survival),
|
||||||
|
tLevelName(0, "World name"),
|
||||||
|
tSeed(1, "World seed")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleChooseLevelScreen::~SimpleChooseLevelScreen()
|
SimpleChooseLevelScreen::~SimpleChooseLevelScreen()
|
||||||
{
|
{
|
||||||
delete bCreative;
|
// delete bCreative;
|
||||||
delete bSurvival;
|
delete bGamemode;
|
||||||
delete bBack;
|
delete bBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleChooseLevelScreen::init()
|
void SimpleChooseLevelScreen::init()
|
||||||
{
|
{
|
||||||
if (minecraft->useTouchscreen()) {
|
if (minecraft->useTouchscreen()) {
|
||||||
bCreative = new Touch::TButton(1, "Creative mode");
|
// bCreative = new Touch::TButton(1, "Creative mode");
|
||||||
bSurvival = new Touch::TButton(2, "Survival mode");
|
bGamemode = new Touch::TButton(2, "Survival mode");
|
||||||
bBack = new Touch::TButton(3, "Back");
|
bBack = new Touch::TButton(3, "Back");
|
||||||
|
bCreate = new Touch::TButton(4, "Create");
|
||||||
} else {
|
} else {
|
||||||
bCreative = new Button(1, "Creative mode");
|
// bCreative = new Button(1, "Creative mode");
|
||||||
bSurvival = new Button(2, "Survival mode");
|
bGamemode = new Button(2, "Survival mode");
|
||||||
bBack = new Button(3, "Back");
|
bBack = new Button(3, "Back");
|
||||||
|
bCreate = new Button(4, "Create");
|
||||||
}
|
}
|
||||||
buttons.push_back(bCreative);
|
// buttons.push_back(bCreative);
|
||||||
buttons.push_back(bSurvival);
|
buttons.push_back(bGamemode);
|
||||||
buttons.push_back(bBack);
|
buttons.push_back(bBack);
|
||||||
|
buttons.push_back(bCreate);
|
||||||
|
|
||||||
tabButtons.push_back(bCreative);
|
textBoxes.push_back(&tLevelName);
|
||||||
tabButtons.push_back(bSurvival);
|
textBoxes.push_back(&tSeed);
|
||||||
|
|
||||||
|
// tabButtons.push_back(bCreative);
|
||||||
|
tabButtons.push_back(bGamemode);
|
||||||
tabButtons.push_back(bBack);
|
tabButtons.push_back(bBack);
|
||||||
|
tabButtons.push_back(bCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleChooseLevelScreen::setupPositions()
|
void SimpleChooseLevelScreen::setupPositions()
|
||||||
{
|
{
|
||||||
bCreative->width = bSurvival->width = bBack->width = 120;
|
const int padding = 5;
|
||||||
bCreative->x = (width - bCreative->width) / 2;
|
|
||||||
bCreative->y = height/3 - 40;
|
/* bCreative->width = */ bGamemode->width = 120;
|
||||||
bSurvival->x = (width - bSurvival->width) / 2;
|
tLevelName.width = tSeed.width = 120;
|
||||||
bSurvival->y = 2*height/3 - 40;
|
bBack->width = bCreate->width = 60 - padding;
|
||||||
bBack->x = bSurvival->x + bSurvival->width - bBack->width;
|
// bCreative->x = (width - bCreative->width) / 2;
|
||||||
bBack->y = height - 40;
|
// bCreative->y = height/3 - 40;
|
||||||
|
bGamemode->x = (width - bGamemode->width) / 2;
|
||||||
|
bGamemode->y = 2*height/3 - 30;
|
||||||
|
bBack->x = bGamemode->x;
|
||||||
|
bCreate->x = bGamemode->x + bGamemode->width - bCreate->width;
|
||||||
|
bBack->y = bCreate->y = height - 40;
|
||||||
|
|
||||||
|
tLevelName.x = tSeed.x = bGamemode->x;
|
||||||
|
tLevelName.y = 20;
|
||||||
|
tSeed.y = tLevelName.y + 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleChooseLevelScreen::render( int xm, int ym, float a )
|
void SimpleChooseLevelScreen::render( int xm, int ym, float a )
|
||||||
@@ -58,9 +80,21 @@ void SimpleChooseLevelScreen::render( int xm, int ym, float a )
|
|||||||
renderDirtBackground(0);
|
renderDirtBackground(0);
|
||||||
glEnable2(GL_BLEND);
|
glEnable2(GL_BLEND);
|
||||||
|
|
||||||
drawCenteredString(minecraft->font, "Mobs, health and gather resources", width/2, bSurvival->y + bSurvival->height + 4, 0xffcccccc);
|
const char* str = NULL;
|
||||||
drawCenteredString(minecraft->font, "Unlimited resources and flying", width/2, bCreative->y + bCreative->height + 4, 0xffcccccc);
|
|
||||||
|
|
||||||
|
if (gamemode == GameType::Survival) {
|
||||||
|
str = "Mobs, health and gather resources";
|
||||||
|
} else if (gamemode == GameType::Creative) {
|
||||||
|
str = "Unlimited resources and flying";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str) {
|
||||||
|
drawCenteredString(minecraft->font, str, width/2, bGamemode->y + bGamemode->height + 4, 0xffcccccc);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawString(minecraft->font, "World name:", tLevelName.x, tLevelName.y - Font::DefaultLineHeight - 2, 0xffcccccc);
|
||||||
|
drawString(minecraft->font, "World seed:", tSeed.x, tSeed.y - Font::DefaultLineHeight - 2, 0xffcccccc);
|
||||||
|
|
||||||
Screen::render(xm, ym, a);
|
Screen::render(xm, ym, a);
|
||||||
glDisable2(GL_BLEND);
|
glDisable2(GL_BLEND);
|
||||||
}
|
}
|
||||||
@@ -74,20 +108,33 @@ void SimpleChooseLevelScreen::buttonClicked( Button* button )
|
|||||||
if (hasChosen)
|
if (hasChosen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int gameType;
|
if (button == bGamemode) {
|
||||||
|
gamemode ^= 1;
|
||||||
|
bGamemode->msg = (gamemode == GameType::Survival) ? "Survival mode" : "Creative mode";
|
||||||
|
}
|
||||||
|
|
||||||
if (button == bCreative)
|
if (button == bCreate) {
|
||||||
gameType = GameType::Creative;
|
int seed = getEpochTimeS();
|
||||||
|
|
||||||
if (button == bSurvival)
|
if (!tSeed.text.empty()) {
|
||||||
gameType = GameType::Survival;
|
std::string seedString = Util::stringTrim(tSeed.text);
|
||||||
|
int tmpSeed;
|
||||||
|
// Try to read it as an integer
|
||||||
|
if (sscanf(seedString.c_str(), "%d", &tmpSeed) > 0) {
|
||||||
|
seed = tmpSeed;
|
||||||
|
} // Hash the "seed"
|
||||||
|
else {
|
||||||
|
seed = Util::hashCode(seedString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string levelId = getUniqueLevelName(levelName);
|
std::string levelId = getUniqueLevelName(tLevelName.text);
|
||||||
LevelSettings settings(getEpochTimeS(), gameType);
|
LevelSettings settings(seed, gamemode);
|
||||||
minecraft->selectLevel(levelId, levelId, settings);
|
minecraft->selectLevel(levelId, levelId, settings);
|
||||||
minecraft->hostMultiplayer();
|
minecraft->hostMultiplayer();
|
||||||
minecraft->setScreen(new ProgressScreen());
|
minecraft->setScreen(new ProgressScreen());
|
||||||
hasChosen = true;
|
hasChosen = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimpleChooseLevelScreen::handleBackEvent(bool isDown) {
|
bool SimpleChooseLevelScreen::handleBackEvent(bool isDown) {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__
|
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__
|
||||||
|
|
||||||
#include "ChooseLevelScreen.h"
|
#include "ChooseLevelScreen.h"
|
||||||
|
#include "../components/TextBox.h"
|
||||||
|
|
||||||
class Button;
|
class Button;
|
||||||
|
|
||||||
class SimpleChooseLevelScreen: public ChooseLevelScreen
|
class SimpleChooseLevelScreen: public ChooseLevelScreen
|
||||||
@@ -21,12 +23,18 @@ public:
|
|||||||
bool handleBackEvent(bool isDown);
|
bool handleBackEvent(bool isDown);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Button* bCreative;
|
// Button* bCreative;
|
||||||
Button* bSurvival;
|
Button* bGamemode;
|
||||||
Button* bBack;
|
Button* bBack;
|
||||||
|
Button* bCreate;
|
||||||
bool hasChosen;
|
bool hasChosen;
|
||||||
|
|
||||||
std::string levelName;
|
std::string levelName;
|
||||||
|
|
||||||
|
int gamemode;
|
||||||
|
|
||||||
|
TextBox tLevelName;
|
||||||
|
TextBox tSeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__*/
|
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__*/
|
||||||
|
|||||||
@@ -22,62 +22,6 @@
|
|||||||
#include "../DialogDefinitions.h"
|
#include "../DialogDefinitions.h"
|
||||||
#include "../SimpleChooseLevelScreen.h"
|
#include "../SimpleChooseLevelScreen.h"
|
||||||
|
|
||||||
//
|
|
||||||
// Buy Button implementation
|
|
||||||
//
|
|
||||||
BuyButton::BuyButton(int id)
|
|
||||||
: super(id, "")
|
|
||||||
{
|
|
||||||
ImageDef def;
|
|
||||||
// Setup the source rectangle
|
|
||||||
def.setSrc(IntRectangle(64, 182, 190, 55));
|
|
||||||
def.width = 75;//rc.w / 3;
|
|
||||||
def.height = 75 * (55.0f / 190.0f);//rc.h / 3;
|
|
||||||
def.name = "gui/gui.png";
|
|
||||||
|
|
||||||
setImageDef(def, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuyButton::render(Minecraft* minecraft, int xm, int ym) {
|
|
||||||
glColor4f2(1, 1, 1, 1);
|
|
||||||
bool hovered = active && (minecraft->useTouchscreen()? (xm >= x && ym >= y && xm < x + width && ym < y + height) : false);
|
|
||||||
renderBg(minecraft, xm, ym);
|
|
||||||
TextureId texId = (_imageDef.name.length() > 0)? minecraft->textures->loadAndBindTexture(_imageDef.name) : Textures::InvalidId;
|
|
||||||
if ( Textures::isTextureIdValid(texId) ) {
|
|
||||||
const ImageDef& d = _imageDef;
|
|
||||||
Tesselator& t = Tesselator::instance;
|
|
||||||
|
|
||||||
t.begin();
|
|
||||||
if (!active) t.color(0xff808080);
|
|
||||||
else if (hovered||selected) t.color(0xffcccccc);
|
|
||||||
//else t.color(0xffe0e0e0);
|
|
||||||
else t.color(0xffffffff);
|
|
||||||
|
|
||||||
float hx = ((float) d.width) * 0.5f;
|
|
||||||
float hy = ((float) d.height) * 0.5f;
|
|
||||||
const float cx = ((float)x+d.x) + hx;
|
|
||||||
const float cy = ((float)y+d.y) + hy;
|
|
||||||
if (hovered) {
|
|
||||||
hx *= 0.95f;
|
|
||||||
hy *= 0.95f;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TextureData* td = minecraft->textures->getTemporaryTextureData(texId);
|
|
||||||
const IntRectangle* src = _imageDef.getSrc();
|
|
||||||
if (td != NULL && src != NULL) {
|
|
||||||
float u0 = (src->x) / (float)td->w;
|
|
||||||
float u1 = (src->x+src->w) / (float)td->w;
|
|
||||||
float v0 = (src->y) / (float)td->h;
|
|
||||||
float v1 = (src->y+src->h) / (float)td->h;
|
|
||||||
t.vertexUV(cx-hx, cy-hy, blitOffset, u0, v0);
|
|
||||||
t.vertexUV(cx-hx, cy+hy, blitOffset, u0, v1);
|
|
||||||
t.vertexUV(cx+hx, cy+hy, blitOffset, u1, v1);
|
|
||||||
t.vertexUV(cx+hx, cy-hy, blitOffset, u1, v0);
|
|
||||||
}
|
|
||||||
t.draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Touch {
|
namespace Touch {
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -88,9 +32,7 @@ namespace Touch {
|
|||||||
StartMenuScreen::StartMenuScreen()
|
StartMenuScreen::StartMenuScreen()
|
||||||
: bHost( 2, "Start Game"),
|
: bHost( 2, "Start Game"),
|
||||||
bJoin( 3, "Join Game"),
|
bJoin( 3, "Join Game"),
|
||||||
bOptions( 4, "Options"),
|
bOptions( 4, "Options")
|
||||||
bBuy( 5),
|
|
||||||
bTest( 9, "Create")
|
|
||||||
{
|
{
|
||||||
ImageDef def;
|
ImageDef def;
|
||||||
bJoin.width = 75;
|
bJoin.width = 75;
|
||||||
@@ -125,11 +67,6 @@ void StartMenuScreen::init()
|
|||||||
tabButtons.push_back(&bJoin);
|
tabButtons.push_back(&bJoin);
|
||||||
tabButtons.push_back(&bOptions);
|
tabButtons.push_back(&bOptions);
|
||||||
|
|
||||||
#ifdef DEMO_MODE
|
|
||||||
buttons.push_back(&bBuy);
|
|
||||||
tabButtons.push_back(&bBuy);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
copyright = "\xffMojang AB";//. Do not distribute!";
|
copyright = "\xffMojang AB";//. Do not distribute!";
|
||||||
|
|
||||||
#ifdef PRE_ANDROID23
|
#ifdef PRE_ANDROID23
|
||||||
@@ -173,20 +110,14 @@ void StartMenuScreen::setupPositions() {
|
|||||||
bJoin.x = 0*buttonWidth + (int)(1*spacing);
|
bJoin.x = 0*buttonWidth + (int)(1*spacing);
|
||||||
bHost.x = 1*buttonWidth + (int)(2*spacing);
|
bHost.x = 1*buttonWidth + (int)(2*spacing);
|
||||||
bOptions.x = 2*buttonWidth + (int)(3*spacing);
|
bOptions.x = 2*buttonWidth + (int)(3*spacing);
|
||||||
//bBuy.y = bOptions.y - bBuy.h - 6;
|
|
||||||
//bBuy.x = bOptions.x + bOptions.w - bBuy.w;
|
|
||||||
|
|
||||||
bBuy.y = height - bBuy.height - 3;
|
|
||||||
bBuy.x = (width - bBuy.width) / 2;
|
|
||||||
|
|
||||||
bTest.x = 4;
|
|
||||||
bTest.y = height - bTest.height - 4;
|
|
||||||
|
|
||||||
copyrightPosX = width - minecraft->font->width(copyright) - 1;
|
copyrightPosX = width - minecraft->font->width(copyright) - 1;
|
||||||
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
|
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuScreen::tick() {
|
void StartMenuScreen::tick() {
|
||||||
|
Screen::tick();
|
||||||
|
|
||||||
_updateLicense();
|
_updateLicense();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,11 +149,6 @@ void StartMenuScreen::buttonClicked(::Button* button) {
|
|||||||
{
|
{
|
||||||
minecraft->setScreen(new OptionsScreen());
|
minecraft->setScreen(new OptionsScreen());
|
||||||
}
|
}
|
||||||
if (button->id == bBuy.id)
|
|
||||||
{
|
|
||||||
minecraft->platform()->buyGame();
|
|
||||||
//minecraft->setScreen(new BuyGameScreen());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartMenuScreen::isInGameScreen() { return false; }
|
bool StartMenuScreen::isInGameScreen() { return false; }
|
||||||
|
|||||||
@@ -3,15 +3,7 @@
|
|||||||
|
|
||||||
#include "../../Screen.h"
|
#include "../../Screen.h"
|
||||||
#include "../../components/LargeImageButton.h"
|
#include "../../components/LargeImageButton.h"
|
||||||
|
#include "../../components/TextBox.h"
|
||||||
|
|
||||||
class BuyButton: public ImageButton {
|
|
||||||
typedef ImageButton super;
|
|
||||||
public:
|
|
||||||
BuyButton(int id);
|
|
||||||
void render(Minecraft* minecraft, int xm, int ym);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
namespace Touch {
|
namespace Touch {
|
||||||
|
|
||||||
@@ -36,8 +28,6 @@ private:
|
|||||||
LargeImageButton bHost;
|
LargeImageButton bHost;
|
||||||
LargeImageButton bJoin;
|
LargeImageButton bJoin;
|
||||||
LargeImageButton bOptions;
|
LargeImageButton bOptions;
|
||||||
TButton bTest;
|
|
||||||
BuyButton bBuy;
|
|
||||||
|
|
||||||
std::string copyright;
|
std::string copyright;
|
||||||
int copyrightPosX;
|
int copyrightPosX;
|
||||||
|
|||||||
Reference in New Issue
Block a user