.h -> .hpp everything

This commit is contained in:
Kolyah35
2026-03-28 01:08:50 +03:00
parent 7d3257669a
commit 7418263193
845 changed files with 53732 additions and 53754 deletions

View File

@@ -1,25 +1,25 @@
#include "TouchIngameBlockSelectionScreen.h"
#include "../crafting/WorkbenchScreen.h"
#include "../../Screen.h"
#include "../../components/ImageButton.h"
#include "../../components/InventoryPane.h"
#include <gamemode/GameMode.h>
#include "../../../renderer/TileRenderer.h"
#include "../../../player/LocalPlayer.h"
#include "../../../renderer/gles.h"
#include "../../../renderer/entity/ItemRenderer.h"
#include "../../../renderer/Tesselator.h"
#include "../../../renderer/Textures.h"
#include "../../../Minecraft.h"
#include "../../../sound/SoundEngine.h"
#include "../../../../world/entity/player/Inventory.h"
#include "../../../../platform/input/Mouse.h"
#include "../../../../util/Mth.h"
#include "../../../../world/item/ItemInstance.h"
#include "../../../../world/entity/player/Player.h"
#include "../../../../world/item/crafting/Recipe.h"
#include "../../../player/input/touchscreen/TouchAreaModel.h"
#include "../ArmorScreen.h"
#include "TouchIngameBlockSelectionScreen.hpp"
#include "client/gui/screens/crafting/WorkbenchScreen.hpp"
#include "client/gui/Screen.hpp"
#include "client/gui/components/ImageButton.hpp"
#include "client/gui/components/InventoryPane.hpp"
#include <gamemode/GameMode.hpp>
#include "client/renderer/TileRenderer.hpp"
#include "client/player/LocalPlayer.hpp"
#include "client/renderer/gles.hpp"
#include "client/renderer/entity/ItemRenderer.hpp"
#include "client/renderer/Tesselator.hpp"
#include "client/renderer/Textures.hpp"
#include "client/Minecraft.hpp"
#include "client/sound/SoundEngine.hpp"
#include "world/entity/player/Inventory.hpp"
#include "platform/input/Mouse.hpp"
#include "util/Mth.hpp"
#include "world/item/ItemInstance.hpp"
#include "world/entity/player/Player.hpp"
#include "world/item/crafting/Recipe.hpp"
#include "client/player/input/touchscreen/TouchAreaModel.hpp"
#include "client/gui/screens/ArmorScreen.hpp"
namespace Touch {

View File

@@ -1,13 +1,13 @@
#pragma once
#include "../../Screen.h"
#include "../../components/InventoryPane.h"
#include "../../components/Button.h"
#include "../../components/ScrollingPane.h"
#include "../../components/ItemPane.h"
#include "../../TweenData.h"
#include "../../../player/input/touchscreen/TouchAreaModel.h"
#include "../../../../AppPlatform.h"
#include "client/gui/Screen.hpp"
#include "client/gui/components/InventoryPane.hpp"
#include "client/gui/components/Button.hpp"
#include "client/gui/components/ScrollingPane.hpp"
#include "client/gui/components/ItemPane.hpp"
#include "client/gui/TweenData.hpp"
#include "client/player/input/touchscreen/TouchAreaModel.hpp"
#include "AppPlatform.hpp"
namespace Touch {

View File

@@ -1,243 +1,243 @@
#include "TouchJoinGameScreen.h"
#include "../StartMenuScreen.h"
#include "../ProgressScreen.h"
#include "../../Font.h"
#include "../../../Minecraft.h"
#include "../../../renderer/Textures.h"
namespace Touch {
//
// Games list
//
void AvailableGamesList::selectStart( int item) {
startSelected = item;
}
void AvailableGamesList::selectCancel() {
startSelected = -1;
}
void AvailableGamesList::selectItem( int item, bool doubleClick ) {
LOGI("selected an item! %d\n", item);
selectedItem = item;
}
void AvailableGamesList::renderItem( int i, int x, int y, int h, Tesselator& t )
{
if (startSelected == i && Multitouch::getFirstActivePointerIdEx() >= 0) {
fill((int)x0, y, (int)x1, y+h, 0x809E684F);
}
//static int colors[2] = {0xffffb0, 0xcccc90};
const PingedCompatibleServer& s = copiedServerList[i];
unsigned int color = s.isSpecial? 0x6090a0 : 0xffffb0;
unsigned int color2 = 0xffffa0;//colors[i&1];
int xx1 = (int)x0 + 24;
int xx2 = xx1;
if (s.isSpecial) {
xx1 += 50;
glEnable2(GL_TEXTURE_2D);
glColor4f2(1,1,1,1);
glEnable2(GL_BLEND);
minecraft->textures->loadAndBindTexture("gui/badge/minecon140.png");
blit(xx2, y + 6, 0, 0, 37, 8, 140, 240);
}
drawString(minecraft->font, s.name.C_String(), xx1, y + 4 + 2, color);
drawString(minecraft->font, s.address.ToString(false), xx2, y + 18, color2);
/*
drawString(minecraft->font, copiedServerList[i].name.C_String(), (int)x0 + 24, y + 4, color);
drawString(minecraft->font, copiedServerList[i].address.ToString(false), (int)x0 + 24, y + 18, color);
*/
}
//
// Join Game screen
//
JoinGameScreen::JoinGameScreen()
: bJoin( 2, "Join Game"),
bBack( 3, "Back"),
bJoinByIp(4, "Join By IP"),
bHeader(0, ""),
gamesList(NULL)
{
bJoin.active = false;
//gamesList->yInertia = 0.5f;
}
JoinGameScreen::~JoinGameScreen()
{
delete gamesList;
}
void JoinGameScreen::init()
{
//buttons.push_back(&bJoin);
buttons.push_back(&bBack);
buttons.push_back(&bJoinByIp);
buttons.push_back(&bHeader);
minecraft->raknetInstance->clearServerList();
gamesList = new AvailableGamesList(minecraft, width, height);
#ifdef ANDROID
//tabButtons.push_back(&bJoin);
tabButtons.push_back(&bBack);
tabButtons.push_back(&bJoinByIp);
#endif
}
void JoinGameScreen::setupPositions() {
//int yBase = height - 26;
//#ifdef ANDROID
bJoin.y = 0;
bBack.y = 0;
bJoinByIp.y = 0;
bHeader.y = 0;
//#endif
// Center buttons
//bJoin.x = width / 2 - 4 - bJoin.w;
bBack.x = 0;//width / 2 + 4;
bJoinByIp.x = width - bJoinByIp.width;;
bHeader.x = bJoinByIp.width;
bHeader.width = width - (bBack.width + bJoinByIp.width);
}
void JoinGameScreen::buttonClicked(Button* button)
{
if (button->id == bJoin.id)
{
if (isIndexValid(gamesList->selectedItem))
{
PingedCompatibleServer selectedServer = gamesList->copiedServerList[gamesList->selectedItem];
minecraft->joinMultiplayer(selectedServer);
{
bJoin.active = false;
bBack.active = false;
minecraft->setScreen(new ProgressScreen());
}
}
//minecraft->locateMultiplayer();
//minecraft->setScreen(new JoinGameScreen());
}
if(button->id == bJoinByIp.id) {
minecraft->cancelLocateMultiplayer();
minecraft->screenChooser.setScreen(SCREEN_JOINBYIP);
}
if (button->id == bBack.id)
{
minecraft->cancelLocateMultiplayer();
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
}
}
bool JoinGameScreen::handleBackEvent(bool isDown)
{
if (!isDown)
{
minecraft->cancelLocateMultiplayer();
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
}
return true;
}
bool JoinGameScreen::isIndexValid( int index )
{
return gamesList && index >= 0 && index < gamesList->getNumberOfItems();
}
void JoinGameScreen::tick()
{
if (isIndexValid(gamesList->selectedItem)) {
buttonClicked(&bJoin);
return;
}
//gamesList->tick();
const ServerList& orgServerList = minecraft->raknetInstance->getServerList();
ServerList serverList;
for (unsigned int i = 0; i < orgServerList.size(); ++i)
if (orgServerList[i].name.GetLength() > 0)
serverList.push_back(orgServerList[i]);
if (serverList.size() != gamesList->copiedServerList.size())
{
// copy the currently selected item
PingedCompatibleServer selectedServer;
bool hasSelection = false;
if (isIndexValid(gamesList->selectedItem))
{
selectedServer = gamesList->copiedServerList[gamesList->selectedItem];
hasSelection = true;
}
gamesList->copiedServerList = serverList;
gamesList->selectItem(-1, false);
// re-select previous item if it still exists
if (hasSelection)
{
for (unsigned int i = 0; i < gamesList->copiedServerList.size(); i++)
{
if (gamesList->copiedServerList[i].address == selectedServer.address)
{
gamesList->selectItem(i, false);
break;
}
}
}
} else {
for (int i = (int)gamesList->copiedServerList.size()-1; i >= 0 ; --i) {
for (int j = 0; j < (int) serverList.size(); ++j)
if (serverList[j].address == gamesList->copiedServerList[i].address)
gamesList->copiedServerList[i].name = serverList[j].name;
}
}
bJoin.active = isIndexValid(gamesList->selectedItem);
}
void JoinGameScreen::render( int xm, int ym, float a )
{
bool hasNetwork = minecraft->platform()->isNetworkEnabled(true);
#ifdef WIN32
hasNetwork = hasNetwork && !GetAsyncKeyState(VK_TAB);
#endif
renderBackground();
if (hasNetwork) gamesList->render(xm, ym, a);
else gamesList->renderDirtBackground();
Screen::render(xm, ym, a);
const int baseX = bHeader.x + bHeader.width / 2;
if (hasNetwork) {
std::string s = "Scanning for WiFi Games...";
drawCenteredString(minecraft->font, s, baseX, 8, 0xffffffff);
const int textWidth = minecraft->font->width(s);
const int spinnerX = baseX + textWidth / 2 + 6;
static const char* spinnerTexts[] = {"-", "\\", "|", "/"};
int n = ((int)(5.5f * getTimeS()) % 4);
drawCenteredString(minecraft->font, spinnerTexts[n], spinnerX, 8, 0xffffffff);
} else {
drawCenteredString(minecraft->font, "WiFi is disabled", baseX, 8, 0xffffffff);
}
}
bool JoinGameScreen::isInGameScreen() { return false; }
};
#include "TouchJoinGameScreen.hpp"
#include "client/gui/screens/StartMenuScreen.hpp"
#include "client/gui/screens/ProgressScreen.hpp"
#include "client/gui/Font.hpp"
#include "client/Minecraft.hpp"
#include "client/renderer/Textures.hpp"
namespace Touch {
//
// Games list
//
void AvailableGamesList::selectStart( int item) {
startSelected = item;
}
void AvailableGamesList::selectCancel() {
startSelected = -1;
}
void AvailableGamesList::selectItem( int item, bool doubleClick ) {
LOGI("selected an item! %d\n", item);
selectedItem = item;
}
void AvailableGamesList::renderItem( int i, int x, int y, int h, Tesselator& t )
{
if (startSelected == i && Multitouch::getFirstActivePointerIdEx() >= 0) {
fill((int)x0, y, (int)x1, y+h, 0x809E684F);
}
//static int colors[2] = {0xffffb0, 0xcccc90};
const PingedCompatibleServer& s = copiedServerList[i];
unsigned int color = s.isSpecial? 0x6090a0 : 0xffffb0;
unsigned int color2 = 0xffffa0;//colors[i&1];
int xx1 = (int)x0 + 24;
int xx2 = xx1;
if (s.isSpecial) {
xx1 += 50;
glEnable2(GL_TEXTURE_2D);
glColor4f2(1,1,1,1);
glEnable2(GL_BLEND);
minecraft->textures->loadAndBindTexture("gui/badge/minecon140.png");
blit(xx2, y + 6, 0, 0, 37, 8, 140, 240);
}
drawString(minecraft->font, s.name.C_String(), xx1, y + 4 + 2, color);
drawString(minecraft->font, s.address.ToString(false), xx2, y + 18, color2);
/*
drawString(minecraft->font, copiedServerList[i].name.C_String(), (int)x0 + 24, y + 4, color);
drawString(minecraft->font, copiedServerList[i].address.ToString(false), (int)x0 + 24, y + 18, color);
*/
}
//
// Join Game screen
//
JoinGameScreen::JoinGameScreen()
: bJoin( 2, "Join Game"),
bBack( 3, "Back"),
bJoinByIp(4, "Join By IP"),
bHeader(0, ""),
gamesList(NULL)
{
bJoin.active = false;
//gamesList->yInertia = 0.5f;
}
JoinGameScreen::~JoinGameScreen()
{
delete gamesList;
}
void JoinGameScreen::init()
{
//buttons.push_back(&bJoin);
buttons.push_back(&bBack);
buttons.push_back(&bJoinByIp);
buttons.push_back(&bHeader);
minecraft->raknetInstance->clearServerList();
gamesList = new AvailableGamesList(minecraft, width, height);
#ifdef ANDROID
//tabButtons.push_back(&bJoin);
tabButtons.push_back(&bBack);
tabButtons.push_back(&bJoinByIp);
#endif
}
void JoinGameScreen::setupPositions() {
//int yBase = height - 26;
//#ifdef ANDROID
bJoin.y = 0;
bBack.y = 0;
bJoinByIp.y = 0;
bHeader.y = 0;
//#endif
// Center buttons
//bJoin.x = width / 2 - 4 - bJoin.w;
bBack.x = 0;//width / 2 + 4;
bJoinByIp.x = width - bJoinByIp.width;;
bHeader.x = bJoinByIp.width;
bHeader.width = width - (bBack.width + bJoinByIp.width);
}
void JoinGameScreen::buttonClicked(Button* button)
{
if (button->id == bJoin.id)
{
if (isIndexValid(gamesList->selectedItem))
{
PingedCompatibleServer selectedServer = gamesList->copiedServerList[gamesList->selectedItem];
minecraft->joinMultiplayer(selectedServer);
{
bJoin.active = false;
bBack.active = false;
minecraft->setScreen(new ProgressScreen());
}
}
//minecraft->locateMultiplayer();
//minecraft->setScreen(new JoinGameScreen());
}
if(button->id == bJoinByIp.id) {
minecraft->cancelLocateMultiplayer();
minecraft->screenChooser.setScreen(SCREEN_JOINBYIP);
}
if (button->id == bBack.id)
{
minecraft->cancelLocateMultiplayer();
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
}
}
bool JoinGameScreen::handleBackEvent(bool isDown)
{
if (!isDown)
{
minecraft->cancelLocateMultiplayer();
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
}
return true;
}
bool JoinGameScreen::isIndexValid( int index )
{
return gamesList && index >= 0 && index < gamesList->getNumberOfItems();
}
void JoinGameScreen::tick()
{
if (isIndexValid(gamesList->selectedItem)) {
buttonClicked(&bJoin);
return;
}
//gamesList->tick();
const ServerList& orgServerList = minecraft->raknetInstance->getServerList();
ServerList serverList;
for (unsigned int i = 0; i < orgServerList.size(); ++i)
if (orgServerList[i].name.GetLength() > 0)
serverList.push_back(orgServerList[i]);
if (serverList.size() != gamesList->copiedServerList.size())
{
// copy the currently selected item
PingedCompatibleServer selectedServer;
bool hasSelection = false;
if (isIndexValid(gamesList->selectedItem))
{
selectedServer = gamesList->copiedServerList[gamesList->selectedItem];
hasSelection = true;
}
gamesList->copiedServerList = serverList;
gamesList->selectItem(-1, false);
// re-select previous item if it still exists
if (hasSelection)
{
for (unsigned int i = 0; i < gamesList->copiedServerList.size(); i++)
{
if (gamesList->copiedServerList[i].address == selectedServer.address)
{
gamesList->selectItem(i, false);
break;
}
}
}
} else {
for (int i = (int)gamesList->copiedServerList.size()-1; i >= 0 ; --i) {
for (int j = 0; j < (int) serverList.size(); ++j)
if (serverList[j].address == gamesList->copiedServerList[i].address)
gamesList->copiedServerList[i].name = serverList[j].name;
}
}
bJoin.active = isIndexValid(gamesList->selectedItem);
}
void JoinGameScreen::render( int xm, int ym, float a )
{
bool hasNetwork = minecraft->platform()->isNetworkEnabled(true);
#ifdef WIN32
hasNetwork = hasNetwork && !GetAsyncKeyState(VK_TAB);
#endif
renderBackground();
if (hasNetwork) gamesList->render(xm, ym, a);
else gamesList->renderDirtBackground();
Screen::render(xm, ym, a);
const int baseX = bHeader.x + bHeader.width / 2;
if (hasNetwork) {
std::string s = "Scanning for WiFi Games...";
drawCenteredString(minecraft->font, s, baseX, 8, 0xffffffff);
const int textWidth = minecraft->font->width(s);
const int spinnerX = baseX + textWidth / 2 + 6;
static const char* spinnerTexts[] = {"-", "\\", "|", "/"};
int n = ((int)(5.5f * getTimeS()) % 4);
drawCenteredString(minecraft->font, spinnerTexts[n], spinnerX, 8, 0xffffffff);
} else {
drawCenteredString(minecraft->font, "WiFi is disabled", baseX, 8, 0xffffffff);
}
}
bool JoinGameScreen::isInGameScreen() { return false; }
};

View File

@@ -1,11 +1,11 @@
#pragma once
#include "../../Screen.h"
#include "../../components/Button.h"
#include "../../components/RolledSelectionListV.h"
#include "../../../Minecraft.h"
#include "../../../../platform/input/Multitouch.h"
#include "../../../../network/RakNetInstance.h"
#include "client/gui/Screen.hpp"
#include "client/gui/components/Button.hpp"
#include "client/gui/components/RolledSelectionListV.hpp"
#include "client/Minecraft.hpp"
#include "platform/input/Multitouch.hpp"
#include "network/RakNetInstance.hpp"
namespace Touch {

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,13 @@
#pragma once
#include "../ConfirmScreen.h"
#include "../../Screen.h"
#include "../../TweenData.h"
#include "../../components/ImageButton.h"
#include "../../components/Button.h"
#include "../../components/RolledSelectionListH.h"
#include "../../../Minecraft.h"
#include "../../../../world/level/storage/LevelStorageSource.h"
#include "client/gui/screens/ConfirmScreen.hpp"
#include "client/gui/Screen.hpp"
#include "client/gui/TweenData.hpp"
#include "client/gui/components/ImageButton.hpp"
#include "client/gui/components/Button.hpp"
#include "client/gui/components/RolledSelectionListH.hpp"
#include "client/Minecraft.hpp"
#include "world/level/storage/LevelStorageSource.hpp"
namespace Touch {

View File

@@ -1,230 +1,230 @@
#include "TouchStartMenuScreen.h"
#include "../ProgressScreen.h"
#include "../OptionsScreen.h"
#include "../PauseScreen.h"
#include "../../Font.h"
#include "../../components/ScrolledSelectionList.h"
#include "../../components/GuiElement.h"
#include "../../../Minecraft.h"
#include "../../../renderer/Tesselator.h"
#include "../../../renderer/Textures.h"
#include "../../../renderer/TextureData.h"
#include "../../../../SharedConstants.h"
#include "../../../../AppPlatform.h"
#include "../../../../LicenseCodes.h"
#include "../../../../util/Mth.h"
#include "../DialogDefinitions.h"
#include "../SimpleChooseLevelScreen.h"
namespace Touch {
//
// Start menu screen implementation
//
// Some kind of default settings, might be overridden in ::init
StartMenuScreen::StartMenuScreen()
: bHost( 2, "Start Game"),
bJoin( 3, "Join Game"),
bOptions( 4, "Options"),
bQuit( 5, "")
{
ImageDef def;
bJoin.width = 75;
def.width = def.height = (float) bJoin.width;
def.setSrc(IntRectangle(0, 26, (int)def.width, (int)def.width));
def.name = "gui/touchgui.png";
IntRectangle& defSrc = *def.getSrc();
bOptions.setImageDef(def, true);
defSrc.y += defSrc.h;
bHost.setImageDef(def, true);
defSrc.y += defSrc.h;
bJoin.setImageDef(def, true);
}
StartMenuScreen::~StartMenuScreen()
{
}
void StartMenuScreen::init()
{
buttons.push_back(&bHost);
buttons.push_back(&bJoin);
buttons.push_back(&bOptions);
// add quit icon (same look as options header)
{
ImageDef def;
def.name = "gui/touchgui.png";
def.width = 34;
def.height = 26;
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
bQuit.setImageDef(def, true);
bQuit.scaleWhenPressed = false;
buttons.push_back(&bQuit);
}
tabButtons.push_back(&bHost);
tabButtons.push_back(&bJoin);
tabButtons.push_back(&bOptions);
#ifdef DEMO_MODE
buttons.push_back(&bBuy);
tabButtons.push_back(&bBuy);
#endif
copyright = "\xffMojang AB";//. Do not distribute!";
// always show base version string
std::string versionString = Common::getGameVersionString();
std::string _username = minecraft->options.getStringValue(OPTIONS_USERNAME);
if (_username.empty()) _username = "unknown";
username = "Username: " + _username;
#ifdef DEMO_MODE
#ifdef __APPLE__
version = versionString + " (Lite)";
#else
version = versionString + " (Demo)";
#endif
#else
version = versionString;
#endif
#ifdef APPLE_DEMO_PROMOTION
version = versionString + " (Demo)";
#endif
bJoin.active = bHost.active = bOptions.active = true;
}
void StartMenuScreen::setupPositions() {
int yBase = 2 + height / 3;
int buttonWidth = bHost.width;
float spacing = (width - (3.0f * buttonWidth)) / 4;
//#ifdef ANDROID
bHost.y = yBase;
bJoin.y = yBase;
bOptions.y = yBase;
//#endif
// Center buttons
bJoin.x = 0*buttonWidth + (int)(1*spacing);
bHost.x = 1*buttonWidth + (int)(2*spacing);
bOptions.x = 2*buttonWidth + (int)(3*spacing);
// quit icon top-right (use size assigned in init)
bQuit.x = width - bQuit.width;
bQuit.y = 0;
copyrightPosX = width - minecraft->font->width(copyright) - 1;
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
}
void StartMenuScreen::buttonClicked(::Button* button) {
if (button->id == bHost.id)
{
#if defined(DEMO_MODE) || defined(APPLE_DEMO_PROMOTION)
minecraft->setScreen( new SimpleChooseLevelScreen("_DemoLevel") );
#else
minecraft->screenChooser.setScreen(SCREEN_SELECTWORLD);
#endif
}
if (button->id == bJoin.id)
{
#ifdef APPLE_DEMO_PROMOTION
minecraft->platform()->createUserInput(DialogDefinitions::DIALOG_DEMO_FEATURE_DISABLED);
#else
minecraft->locateMultiplayer();
minecraft->screenChooser.setScreen(SCREEN_JOINGAME);
#endif
}
if (button->id == bOptions.id)
{
minecraft->setScreen(new OptionsScreen());
}
if (button == &bQuit)
{
minecraft->quit();
}
}
bool StartMenuScreen::isInGameScreen() { return false; }
void StartMenuScreen::render( int xm, int ym, float a )
{
renderBackground();
// Show current username in the top-left corner
drawString(font, username, 2, 2, 0xffffffff);
glEnable2(GL_BLEND);
#if defined(RPI)
TextureId id = minecraft->textures->loadTexture("gui/pi_title.png");
#else
TextureId id = minecraft->textures->loadTexture("gui/title.png");
#endif
const TextureData* data = minecraft->textures->getTemporaryTextureData(id);
if (data) {
minecraft->textures->bind(id);
const float x = (float)width / 2;
const float y = 4;
const float wh = 0.5f * Mth::Min((float)width/2.0f, (float)data->w / 2);
const float scale = 2.0f * wh / (float)data->w;
const float h = scale * (float)data->h;
// Render title text
Tesselator& t = Tesselator::instance;
glColor4f2(1, 1, 1, 1);
t.begin();
t.vertexUV(x-wh, y+h, blitOffset, 0, 1);
t.vertexUV(x+wh, y+h, blitOffset, 1, 1);
t.vertexUV(x+wh, y+0, blitOffset, 1, 0);
t.vertexUV(x-wh, y+0, blitOffset, 0, 0);
t.draw();
drawString(font, version, versionPosX, (int)(y+h)+2, /*50,*/ 0xffcccccc);//0x666666);
drawString(font, copyright, copyrightPosX, height - 10, 0xffffff);
glColor4f2(1, 1, 1, 1);
if (Textures::isTextureIdValid(minecraft->textures->loadAndBindTexture("gui/logo/github.png")))
blit(2, height - 10, 0, 0, 8, 8, 256, 256);
drawString(font, "Kolyah35/minecraft-pe-0.6.1", 12, height - 10, 0xffcccccc);
//patch->draw(t, 0, 20);
}
Screen::render(xm, ym, a);
glDisable2(GL_BLEND);
}
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
const int logoX = 2;
const int logoW = 8 + 2 + font->width("Kolyah35/minecraft-pe-0.6.1");
const int logoY = height - 10;
const int logoH = 10;
if (x >= logoX && x <= logoX + logoW && y >= logoY && y <= logoY + logoH)
minecraft->platform()->openURL("https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1");
else
Screen::mouseClicked(x, y, buttonNum);
}
bool StartMenuScreen::handleBackEvent( bool isDown ) {
minecraft->quit();
return true;
}
} // namespace Touch
#include "TouchStartMenuScreen.hpp"
#include "client/gui/screens/ProgressScreen.hpp"
#include "client/gui/screens/OptionsScreen.hpp"
#include "client/gui/screens/PauseScreen.hpp"
#include "client/gui/Font.hpp"
#include "client/gui/components/ScrolledSelectionList.hpp"
#include "client/gui/components/GuiElement.hpp"
#include "client/Minecraft.hpp"
#include "client/renderer/Tesselator.hpp"
#include "client/renderer/Textures.hpp"
#include "client/renderer/TextureData.hpp"
#include "SharedConstants.hpp"
#include "AppPlatform.hpp"
#include "LicenseCodes.hpp"
#include "util/Mth.hpp"
#include "client/gui/screens/DialogDefinitions.hpp"
#include "client/gui/screens/SimpleChooseLevelScreen.hpp"
namespace Touch {
//
// Start menu screen implementation
//
// Some kind of default settings, might be overridden in ::init
StartMenuScreen::StartMenuScreen()
: bHost( 2, "Start Game"),
bJoin( 3, "Join Game"),
bOptions( 4, "Options"),
bQuit( 5, "")
{
ImageDef def;
bJoin.width = 75;
def.width = def.height = (float) bJoin.width;
def.setSrc(IntRectangle(0, 26, (int)def.width, (int)def.width));
def.name = "gui/touchgui.png";
IntRectangle& defSrc = *def.getSrc();
bOptions.setImageDef(def, true);
defSrc.y += defSrc.h;
bHost.setImageDef(def, true);
defSrc.y += defSrc.h;
bJoin.setImageDef(def, true);
}
StartMenuScreen::~StartMenuScreen()
{
}
void StartMenuScreen::init()
{
buttons.push_back(&bHost);
buttons.push_back(&bJoin);
buttons.push_back(&bOptions);
// add quit icon (same look as options header)
{
ImageDef def;
def.name = "gui/touchgui.png";
def.width = 34;
def.height = 26;
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
bQuit.setImageDef(def, true);
bQuit.scaleWhenPressed = false;
buttons.push_back(&bQuit);
}
tabButtons.push_back(&bHost);
tabButtons.push_back(&bJoin);
tabButtons.push_back(&bOptions);
#ifdef DEMO_MODE
buttons.push_back(&bBuy);
tabButtons.push_back(&bBuy);
#endif
copyright = "\xffMojang AB";//. Do not distribute!";
// always show base version string
std::string versionString = Common::getGameVersionString();
std::string _username = minecraft->options.getStringValue(OPTIONS_USERNAME);
if (_username.empty()) _username = "unknown";
username = "Username: " + _username;
#ifdef DEMO_MODE
#ifdef __APPLE__
version = versionString + " (Lite)";
#else
version = versionString + " (Demo)";
#endif
#else
version = versionString;
#endif
#ifdef APPLE_DEMO_PROMOTION
version = versionString + " (Demo)";
#endif
bJoin.active = bHost.active = bOptions.active = true;
}
void StartMenuScreen::setupPositions() {
int yBase = 2 + height / 3;
int buttonWidth = bHost.width;
float spacing = (width - (3.0f * buttonWidth)) / 4;
//#ifdef ANDROID
bHost.y = yBase;
bJoin.y = yBase;
bOptions.y = yBase;
//#endif
// Center buttons
bJoin.x = 0*buttonWidth + (int)(1*spacing);
bHost.x = 1*buttonWidth + (int)(2*spacing);
bOptions.x = 2*buttonWidth + (int)(3*spacing);
// quit icon top-right (use size assigned in init)
bQuit.x = width - bQuit.width;
bQuit.y = 0;
copyrightPosX = width - minecraft->font->width(copyright) - 1;
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
}
void StartMenuScreen::buttonClicked(::Button* button) {
if (button->id == bHost.id)
{
#if defined(DEMO_MODE) || defined(APPLE_DEMO_PROMOTION)
minecraft->setScreen( new SimpleChooseLevelScreen("_DemoLevel") );
#else
minecraft->screenChooser.setScreen(SCREEN_SELECTWORLD);
#endif
}
if (button->id == bJoin.id)
{
#ifdef APPLE_DEMO_PROMOTION
minecraft->platform()->createUserInput(DialogDefinitions::DIALOG_DEMO_FEATURE_DISABLED);
#else
minecraft->locateMultiplayer();
minecraft->screenChooser.setScreen(SCREEN_JOINGAME);
#endif
}
if (button->id == bOptions.id)
{
minecraft->setScreen(new OptionsScreen());
}
if (button == &bQuit)
{
minecraft->quit();
}
}
bool StartMenuScreen::isInGameScreen() { return false; }
void StartMenuScreen::render( int xm, int ym, float a )
{
renderBackground();
// Show current username in the top-left corner
drawString(font, username, 2, 2, 0xffffffff);
glEnable2(GL_BLEND);
#if defined(RPI)
TextureId id = minecraft->textures->loadTexture("gui/pi_title.png");
#else
TextureId id = minecraft->textures->loadTexture("gui/title.png");
#endif
const TextureData* data = minecraft->textures->getTemporaryTextureData(id);
if (data) {
minecraft->textures->bind(id);
const float x = (float)width / 2;
const float y = 4;
const float wh = 0.5f * Mth::Min((float)width/2.0f, (float)data->w / 2);
const float scale = 2.0f * wh / (float)data->w;
const float h = scale * (float)data->h;
// Render title text
Tesselator& t = Tesselator::instance;
glColor4f2(1, 1, 1, 1);
t.begin();
t.vertexUV(x-wh, y+h, blitOffset, 0, 1);
t.vertexUV(x+wh, y+h, blitOffset, 1, 1);
t.vertexUV(x+wh, y+0, blitOffset, 1, 0);
t.vertexUV(x-wh, y+0, blitOffset, 0, 0);
t.draw();
drawString(font, version, versionPosX, (int)(y+h)+2, /*50,*/ 0xffcccccc);//0x666666);
drawString(font, copyright, copyrightPosX, height - 10, 0xffffff);
glColor4f2(1, 1, 1, 1);
if (Textures::isTextureIdValid(minecraft->textures->loadAndBindTexture("gui/logo/github.png")))
blit(2, height - 10, 0, 0, 8, 8, 256, 256);
drawString(font, "Kolyah35/minecraft-pe-0.6.1", 12, height - 10, 0xffcccccc);
//patch->draw(t, 0, 20);
}
Screen::render(xm, ym, a);
glDisable2(GL_BLEND);
}
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
const int logoX = 2;
const int logoW = 8 + 2 + font->width("Kolyah35/minecraft-pe-0.6.1");
const int logoY = height - 10;
const int logoH = 10;
if (x >= logoX && x <= logoX + logoW && y >= logoY && y <= logoY + logoH)
minecraft->platform()->openURL("https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1");
else
Screen::mouseClicked(x, y, buttonNum);
}
bool StartMenuScreen::handleBackEvent( bool isDown ) {
minecraft->quit();
return true;
}
} // namespace Touch

View File

@@ -1,9 +1,9 @@
#pragma once
#include "../../Screen.h"
#include "../../components/LargeImageButton.h"
#include "../../components/ImageButton.h"
#include "../../components/TextBox.h"
#include "client/gui/Screen.hpp"
#include "client/gui/components/LargeImageButton.hpp"
#include "client/gui/components/ImageButton.hpp"
#include "client/gui/components/TextBox.hpp"
namespace Touch {