forked from Kolyah35/minecraft-pe-0.6.1
Trying to replace pointers with references :v
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include "util/Mth.hpp"
|
||||
#include <cstring>
|
||||
|
||||
Font::Font( Options* options, const std::string& name, Textures* textures )
|
||||
Font::Font( Options* options, const std::string& name, Textures& textures )
|
||||
: options(options),
|
||||
fontTexture(0),
|
||||
fontName(name),
|
||||
@@ -23,7 +23,7 @@ Font::Font( Options* options, const std::string& name, Textures* textures )
|
||||
}
|
||||
|
||||
|
||||
//Font::Font( Options* options, const std::string& name, Textures* textures, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset )
|
||||
//Font::Font( Options* options, const std::string& name, Textures& textures, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset )
|
||||
//: options(options),
|
||||
// fontTexture(0),
|
||||
// fontName(name),
|
||||
|
||||
@@ -13,8 +13,8 @@ class Options;
|
||||
class Font
|
||||
{
|
||||
public:
|
||||
Font(Options* options, const std::string& name, Textures* textures);
|
||||
//Font(Options* options, const std::string& name, Textures* textures, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset);
|
||||
Font(Options* options, const std::string& name, Textures& textures);
|
||||
//Font(Options* options, const std::string& name, Textures& textures, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset);
|
||||
|
||||
void init(Options* options);
|
||||
void onGraphicsReset();
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#include "Gui.hpp"
|
||||
#include "Font.hpp"
|
||||
#include "MinecraftClient.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/Options.hpp"
|
||||
#include "platform/input/Keyboard.hpp"
|
||||
#include "screens/IngameBlockSelectionScreen.hpp"
|
||||
#include "screens/ChatScreen.hpp"
|
||||
#include "screens/ConsoleScreen.hpp"
|
||||
#include <Minecraft.hpp>
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
@@ -14,10 +13,10 @@
|
||||
#include "client/renderer/GameRenderer.hpp"
|
||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||
#include "client/player/input/IInputHolder.hpp"
|
||||
#include "client/gamemode/GameMode.hpp"
|
||||
#include "client/gamemode/CreativeMode.hpp"
|
||||
#include <gamemode/GameMode.hpp>
|
||||
#include "gamemode/CreativeMode.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include "AppConstants.hpp"
|
||||
// #include "AppConstants.hpp"
|
||||
#include "world/entity/player/Inventory.hpp"
|
||||
#include "world/level/material/Material.hpp"
|
||||
#include "world/item/Item.hpp"
|
||||
@@ -30,8 +29,6 @@
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
#define MAX_MESSAGE_WIDTH 240
|
||||
|
||||
float Gui::InvGuiScale = 1.0f / 3.0f;
|
||||
float Gui::GuiScale = 1.0f / Gui::InvGuiScale;
|
||||
const float Gui::DropTicks = 40.0f;
|
||||
@@ -54,16 +51,16 @@ Gui::~Gui() {
|
||||
}
|
||||
|
||||
void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
if (!minecraft.level || !minecraft.getPlayer())
|
||||
if (!minecraft.level || !minecraft.player())
|
||||
return;
|
||||
|
||||
//minecraft->gameRenderer->setupGuiScreen();
|
||||
Font* font = minecraft.getFont();
|
||||
//minecraft.gameRenderer->setupGuiScreen();
|
||||
Font* font = minecraft.font();
|
||||
|
||||
const bool isTouchInterface = minecraft.useTouchscreen();
|
||||
|
||||
const int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||
const int screenHeight = (int)(minecraft.getScreenHeigth() * InvGuiScale);
|
||||
const int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||
blitOffset = -90;
|
||||
renderProgressIndicator(isTouchInterface, screenWidth, screenHeight, a);
|
||||
|
||||
@@ -75,9 +72,9 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
// F: 3
|
||||
int ySlot = screenHeight - 16 - 3;
|
||||
|
||||
if (!minecraft.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
if (!minecraft.options().getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
if (minecraft.gameMode->canHurtPlayer()) {
|
||||
minecraft.getTextures()->loadAndBindTexture("gui/icons.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/icons.png");
|
||||
Tesselator& t = Tesselator::instance;
|
||||
t.beginOverride();
|
||||
t.colorABGR(0xffffffff);
|
||||
@@ -87,7 +84,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
}
|
||||
}
|
||||
|
||||
if(minecraft.getPlayer()->getSleepTimer() > 0) {
|
||||
if(minecraft.player()->getSleepTimer() > 0) {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
||||
@@ -96,11 +93,11 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
if (!minecraft.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
if (!minecraft.options().getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
renderToolBar(a, ySlot, screenWidth);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
bool isChatting = (minecraft->screen && (dynamic_cast<ChatScreen*>(minecraft->screen) || dynamic_cast<ConsoleScreen*>(minecraft->screen)));
|
||||
bool isChatting = minecraft.getScreen() && dynamic_cast<ChatScreen*>(minecraft.getScreen());
|
||||
unsigned int max = 10;
|
||||
if (isChatting) {
|
||||
int lineHeight = 9;
|
||||
@@ -112,20 +109,17 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
} else {
|
||||
chatScrollOffset = 0;
|
||||
}
|
||||
renderChatMessages(screenHeight, max, isChatting, font);
|
||||
#if !defined(RPI)
|
||||
renderOnSelectItemNameText(screenWidth, font, ySlot);
|
||||
#endif
|
||||
#if defined(RPI)
|
||||
renderDebugInfo();
|
||||
#endif
|
||||
if (font != nullptr) {
|
||||
renderChatMessages(screenHeight, max, isChatting, *font);
|
||||
renderOnSelectItemNameText(screenWidth, *font, ySlot);
|
||||
|
||||
if (Keyboard::isKeyDown(Keyboard::KEY_TAB)) {
|
||||
renderPlayerList(font, screenWidth, screenHeight);
|
||||
}
|
||||
if (Keyboard::isKeyDown(Keyboard::KEY_TAB)) {
|
||||
renderPlayerList(*font, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
if (minecraft->options.getBooleanValue(OPTIONS_RENDER_DEBUG))
|
||||
renderDebugInfo();
|
||||
if (minecraft.options().getBooleanValue(OPTIONS_RENDER_DEBUG))
|
||||
renderDebugInfo();
|
||||
}
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@@ -133,8 +127,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
}
|
||||
|
||||
int Gui::getSlotIdAt(int x, int y) {
|
||||
int screenWidth = (int)(minecraft->width * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
||||
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||
x = (int)(x * InvGuiScale);
|
||||
y = (int)(y * InvGuiScale);
|
||||
|
||||
@@ -164,24 +158,24 @@ void Gui::flashSlot(int slotId) {
|
||||
}
|
||||
|
||||
void Gui::getSlotPos(int slot, int& posX, int& posY) {
|
||||
int screenWidth = (int)(minecraft->width * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
||||
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||
posX = screenWidth / 2 - getNumSlots() * 10 + slot * 20,
|
||||
posY = screenHeight - 22;
|
||||
}
|
||||
|
||||
RectangleArea Gui::getRectangleArea(int extendSide) {
|
||||
const int Spacing = 3;
|
||||
const float pCenterX = 2.0f + (float)(minecraft->width / 2);
|
||||
const float pCenterX = 2.0f + (float)(minecraft.getScreenWidth() / 2);
|
||||
const float pHalfWidth = (1.0f + (getNumSlots() * 10 + Spacing)) * Gui::GuiScale;
|
||||
const float pHeight = (22 + Spacing) * Gui::GuiScale;
|
||||
|
||||
if (extendSide < 0)
|
||||
return RectangleArea(0, (float)minecraft->height-pHeight, pCenterX+pHalfWidth+2, (float)minecraft->height);
|
||||
return RectangleArea(0, (float)minecraft.getScreenHeight()-pHeight, pCenterX+pHalfWidth+2, (float)minecraft.getScreenHeight());
|
||||
if (extendSide > 0)
|
||||
return RectangleArea(pCenterX-pHalfWidth, (float)minecraft->height-pHeight, (float)minecraft->width, (float)minecraft->height);
|
||||
return RectangleArea(pCenterX-pHalfWidth, (float)minecraft.getScreenHeight()-pHeight, (float)minecraft.getScreenWidth(), (float)minecraft.getScreenHeight());
|
||||
|
||||
return RectangleArea(pCenterX-pHalfWidth, (float)minecraft->height-pHeight, pCenterX+pHalfWidth+2, (float)minecraft->height);
|
||||
return RectangleArea(pCenterX-pHalfWidth, (float)minecraft.getScreenHeight()-pHeight, pCenterX+pHalfWidth+2, (float)minecraft.getScreenHeight());
|
||||
}
|
||||
|
||||
void Gui::handleClick(int button, int x, int y) {
|
||||
@@ -190,9 +184,9 @@ void Gui::handleClick(int button, int x, int y) {
|
||||
int slot = getSlotIdAt(x, y);
|
||||
if (slot != -1) {
|
||||
if (_openInventorySlot && slot == (getNumSlots()-1)) {
|
||||
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||
minecraft.screenChooser().setScreen(SCREEN_BLOCKSELECTION);
|
||||
} else {
|
||||
minecraft->player->inventory->selectSlot(slot);
|
||||
minecraft.player()->inventory->selectSlot(slot);
|
||||
itemNameOverlayTime = 0;
|
||||
}
|
||||
}
|
||||
@@ -200,7 +194,7 @@ void Gui::handleClick(int button, int x, int y) {
|
||||
|
||||
void Gui::handleKeyPressed(int key)
|
||||
{
|
||||
bool isChatting = (minecraft->screen && (dynamic_cast<ChatScreen*>(minecraft->screen) || dynamic_cast<ConsoleScreen*>(minecraft->screen)));
|
||||
bool isChatting = (minecraft.getScreen() && dynamic_cast<ChatScreen*>(minecraft.getScreen()));
|
||||
if (isChatting) {
|
||||
// Allow scrolling the chat history with the mouse/keyboard when chat is open
|
||||
if (key == 38) { // VK_UP
|
||||
@@ -211,12 +205,12 @@ void Gui::handleKeyPressed(int key)
|
||||
return;
|
||||
} else if (key == 33) { // VK_PRIOR (Page Up)
|
||||
// Scroll by a page
|
||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||
int maxVisible = (screenHeight - 48) / 9;
|
||||
scrollChat(maxVisible);
|
||||
return;
|
||||
} else if (key == 34) { // VK_NEXT (Page Down)
|
||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||
int maxVisible = (screenHeight - 48) / 9;
|
||||
scrollChat(-maxVisible);
|
||||
return;
|
||||
@@ -224,30 +218,30 @@ void Gui::handleKeyPressed(int key)
|
||||
}
|
||||
|
||||
if (key == Keyboard::KEY_F1) {
|
||||
minecraft->options.toggle(OPTIONS_HIDEGUI);
|
||||
minecraft.options().toggle(OPTIONS_HIDEGUI);
|
||||
}
|
||||
|
||||
if (key == 99)
|
||||
{
|
||||
if (minecraft->player->inventory->selected > 0)
|
||||
if (minecraft.player()->inventory->selected > 0)
|
||||
{
|
||||
minecraft->player->inventory->selected--;
|
||||
minecraft.player()->inventory->selected--;
|
||||
}
|
||||
}
|
||||
else if (key == 4)
|
||||
{
|
||||
if (minecraft->player->inventory->selected < (getNumSlots() - 2))
|
||||
if (minecraft.player()->inventory->selected < (getNumSlots() - 2))
|
||||
{
|
||||
minecraft->player->inventory->selected++;
|
||||
minecraft.player()->inventory->selected++;
|
||||
}
|
||||
}
|
||||
else if (key == 100)
|
||||
{
|
||||
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||
minecraft.screenChooser().setScreen(SCREEN_BLOCKSELECTION);
|
||||
}
|
||||
else if (key == minecraft->options.getIntValue(OPTIONS_KEY_DROP))
|
||||
else if (key == minecraft.options().getIntValue(OPTIONS_KEY_DROP))
|
||||
{
|
||||
minecraft->player->inventory->dropSlot(minecraft->player->inventory->selected, false);
|
||||
minecraft.player()->inventory->dropSlot(minecraft.player()->inventory->selected, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +249,7 @@ void Gui::scrollChat(int delta) {
|
||||
if (delta == 0)
|
||||
return;
|
||||
|
||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||
int maxVisible = (screenHeight - 48) / 9;
|
||||
if (maxVisible <= 0)
|
||||
return;
|
||||
@@ -277,18 +271,18 @@ void Gui::tick() {
|
||||
guiMessages.at(i).ticks++;
|
||||
}
|
||||
|
||||
if (!minecraft->isCreativeMode())
|
||||
if (!minecraft.isCreativeMode())
|
||||
tickItemDrop();
|
||||
}
|
||||
|
||||
void Gui::addMessage(const std::string& _string) {
|
||||
if (!minecraft->font)
|
||||
if (!minecraft.font())
|
||||
return;
|
||||
|
||||
std::string string = _string;
|
||||
while (minecraft->font->width(string) > MAX_MESSAGE_WIDTH) {
|
||||
while (minecraft.font()->width(string) > maxMessageWidth) {
|
||||
unsigned int i = 1;
|
||||
while (i < string.length() && minecraft->font->width(string.substr(0, i + 1)) <= MAX_MESSAGE_WIDTH) {
|
||||
while (i < string.length() && minecraft.font()->width(string.substr(0, i + 1)) <= maxMessageWidth) {
|
||||
i++;
|
||||
}
|
||||
addMessage(string.substr(0, i));
|
||||
@@ -338,7 +332,7 @@ void Gui::renderVignette(float br, int w, int h) {
|
||||
glDepthMask(false);
|
||||
glBlendFunc2(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
||||
glColor4f2(tbr, tbr, tbr, 1);
|
||||
minecraft->textures->loadAndBindTexture("misc/vignette.png");
|
||||
minecraft.textures().loadAndBindTexture("misc/vignette.png");
|
||||
|
||||
Tesselator& t = Tesselator::instance;
|
||||
t.begin();
|
||||
@@ -354,14 +348,14 @@ void Gui::renderVignette(float br, int w, int h) {
|
||||
}
|
||||
|
||||
void Gui::renderSlot(int slot, int x, int y, float a) {
|
||||
ItemInstance* item = minecraft->player->inventory->getItem(slot);
|
||||
ItemInstance* item = minecraft.player()->inventory->getItem(slot);
|
||||
if (!item) {
|
||||
//LOGW("Warning: item @ Gui::renderSlot is NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
const bool fancy = true;
|
||||
ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, item, (float)x, (float)y, fancy);
|
||||
ItemRenderer::renderGuiItem(minecraft.font(), minecraft.textures(), item, (float)x, (float)y, fancy);
|
||||
}
|
||||
|
||||
void Gui::renderSlotText( const ItemInstance* item, float x, float y, bool hasFinite, bool shadow )
|
||||
@@ -381,9 +375,9 @@ void Gui::renderSlotText( const ItemInstance* item, float x, float y, bool hasFi
|
||||
|
||||
//LOGI("slot: %d - %s\n", slot, buffer);
|
||||
if (shadow)
|
||||
minecraft->font->drawShadow(buffer, x, y, item->count>0?0xffcccccc:0x60cccccc);
|
||||
minecraft.font()->drawShadow(buffer, x, y, item->count>0?0xffcccccc:0x60cccccc);
|
||||
else
|
||||
minecraft->font->draw(buffer, x, y, item->count>0?0xffcccccc:0x60cccccc);
|
||||
minecraft.font()->draw(buffer, x, y, item->count>0?0xffcccccc:0x60cccccc);
|
||||
}
|
||||
|
||||
void Gui::inventoryUpdated() {
|
||||
@@ -395,7 +389,7 @@ void Gui::onGraphicsReset() {
|
||||
}
|
||||
|
||||
void Gui::texturesLoaded( Textures* textures ) {
|
||||
//_slotFont = new Font(&minecraft->options, "gui/gui_blocks.png", textures, 0, 504, 10, 1, '0');
|
||||
//_slotFont = new Font(&minecraft.options, "gui/gui_blocks.png", textures, 0, 504, 10, 1, '0');
|
||||
}
|
||||
|
||||
void Gui::onConfigChanged( const Config& c ) {
|
||||
@@ -410,7 +404,7 @@ void Gui::onConfigChanged( const Config& c ) {
|
||||
#else
|
||||
const float mm = 50; //20
|
||||
#endif
|
||||
const float maxRadius = minecraft->pixelCalcUi.millimetersToPixels(mm);
|
||||
const float maxRadius = minecraft.pixelCalcUi().millimetersToPixels(mm);
|
||||
const float radius = Mth::Min(80.0f/2, maxRadius);
|
||||
//LOGI("radius, maxradius: %f, %f\n", radius, maxRadius);
|
||||
const float radiusInner = radius * 0.95f;
|
||||
@@ -455,10 +449,12 @@ void Gui::onConfigChanged( const Config& c ) {
|
||||
}
|
||||
rcFeedbackInner = t.end(true, rcFeedbackInner.vboId);
|
||||
|
||||
if (c.minecraft->useTouchscreen()) {
|
||||
|
||||
|
||||
if (c.minecraft.useTouchscreen()) {
|
||||
// I'll bump this up to 6.
|
||||
int num = 6; // without "..." dots
|
||||
if (!c.minecraft->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA) && c.width > 480) {
|
||||
if (!c.minecraft.options().getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA) && c.width > 480) {
|
||||
while (num < Inventory::MAX_SELECTION_SIZE - 1) {
|
||||
int x0, x1, y;
|
||||
getSlotPos(0, x0, y);
|
||||
@@ -477,7 +473,8 @@ void Gui::onConfigChanged( const Config& c ) {
|
||||
} else {
|
||||
_numSlots = Inventory::MAX_SELECTION_SIZE; // Xperia Play
|
||||
}
|
||||
MAX_MESSAGE_WIDTH = c.guiWidth;
|
||||
|
||||
maxMessageWidth = c.guiWidth;
|
||||
}
|
||||
|
||||
float Gui::floorAlignToScreenPixel(float v) {
|
||||
@@ -524,8 +521,8 @@ void Gui::tickItemDrop()
|
||||
}
|
||||
isCurrentlyActive = true;
|
||||
if ((_currentDropTicks += 1.0f) >= DropTicks) {
|
||||
minecraft->player->inventory->dropSlot(slot, false);
|
||||
minecraft->level->playSound(minecraft->player, "random.pop", 0.3f, 1);
|
||||
minecraft.player()->inventory->dropSlot(slot, false);
|
||||
minecraft.level->playSound(minecraft.player(), "random.pop", 0.3f, 1);
|
||||
isCurrentlyActive = false;
|
||||
}
|
||||
}
|
||||
@@ -552,7 +549,7 @@ void Gui::postError( int errCode )
|
||||
void Gui::setScissorRect( const IntRectangle& bbox )
|
||||
{
|
||||
GLuint x = (GLuint)(GuiScale * bbox.x);
|
||||
GLuint y = minecraft->height - (GLuint)(GuiScale * (bbox.y + bbox.h));
|
||||
GLuint y = minecraft.getScreenHeight() - (GLuint)(GuiScale * (bbox.y + bbox.h));
|
||||
GLuint w = (GLuint)(GuiScale * bbox.w);
|
||||
GLuint h = (GLuint)(GuiScale * bbox.h);
|
||||
glScissor(x, y, w, h);
|
||||
@@ -565,33 +562,33 @@ float Gui::cubeSmoothStep(float percentage, float min, float max) {
|
||||
}
|
||||
|
||||
void Gui::renderProgressIndicator( const bool isTouchInterface, const int screenWidth, const int screenHeight, float a ) {
|
||||
ItemInstance* currentItem = minecraft->player->inventory->getSelected();
|
||||
ItemInstance* currentItem = minecraft.player()->inventory->getSelected();
|
||||
bool bowEquipped = currentItem != NULL ? currentItem->getItem() == Item::bow : false;
|
||||
bool itemInUse = currentItem != NULL ? currentItem->getItem() == minecraft->player->getUseItem()->getItem() : false;
|
||||
if ((!isTouchInterface || minecraft->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)
|
||||
|| (bowEquipped && itemInUse)) && !minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
minecraft->textures->loadAndBindTexture("gui/icons.png");
|
||||
bool itemInUse = currentItem != NULL ? currentItem->getItem() == minecraft.player()->getUseItem()->getItem() : false;
|
||||
if ((!isTouchInterface || minecraft.options().getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)
|
||||
|| (bowEquipped && itemInUse)) && !minecraft.options().getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
minecraft.textures().loadAndBindTexture("gui/icons.png");
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
|
||||
blit(screenWidth/2 - 8, screenHeight/2 - 8, 0, 0, 16, 16);
|
||||
glDisable(GL_BLEND);
|
||||
} else if(!bowEquipped) {
|
||||
const float tprogress = minecraft->gameMode->destroyProgress;
|
||||
const float alpha = Mth::clamp(minecraft->inputHolder->alpha, 0.0f, 1.0f);
|
||||
const float tprogress = minecraft.gameMode->destroyProgress;
|
||||
const float alpha = Mth::clamp(minecraft.inputHolder()->alpha, 0.0f, 1.0f);
|
||||
//LOGI("alpha: %f\n", alpha);
|
||||
|
||||
if (tprogress <= 0 && minecraft->inputHolder->alpha >= 0) {
|
||||
if (tprogress <= 0 && minecraft.inputHolder()->alpha >= 0) {
|
||||
glDisable2(GL_TEXTURE_2D);
|
||||
glEnable2(GL_BLEND);
|
||||
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
if (minecraft->hitResult.isHit())
|
||||
if (minecraft.hitResult.isHit())
|
||||
glColor4f2(1, 1, 1, 0.8f * alpha);
|
||||
else
|
||||
glColor4f2(1, 1, 1, Mth::Min(0.4f, alpha*0.4f));
|
||||
|
||||
//LOGI("alpha2: %f\n", alpha);
|
||||
const float x = InvGuiScale * minecraft->inputHolder->mousex;
|
||||
const float y = InvGuiScale * minecraft->inputHolder->mousey;
|
||||
const float x = InvGuiScale * minecraft.inputHolder()->mousex;
|
||||
const float y = InvGuiScale * minecraft.inputHolder()->mousey;
|
||||
glTranslatef2(x, y, 0);
|
||||
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24);
|
||||
glTranslatef2(-x, -y, 0);
|
||||
@@ -599,7 +596,7 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
|
||||
glEnable2(GL_TEXTURE_2D);
|
||||
glDisable(GL_BLEND);
|
||||
} else if (tprogress > 0) {
|
||||
const float oProgress = minecraft->gameMode->oDestroyProgress;
|
||||
const float oProgress = minecraft.gameMode->oDestroyProgress;
|
||||
const float progress = 0.5f * (oProgress + (tprogress - oProgress) * a);
|
||||
|
||||
//static Stopwatch w;
|
||||
@@ -610,8 +607,8 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
const float x = InvGuiScale * minecraft->inputHolder->mousex;
|
||||
const float y = InvGuiScale * minecraft->inputHolder->mousey;
|
||||
const float x = InvGuiScale * minecraft.inputHolder()->mousex;
|
||||
const float y = InvGuiScale * minecraft.inputHolder()->mousey;
|
||||
glPushMatrix2();
|
||||
glTranslatef2(x, y, 0);
|
||||
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24);
|
||||
@@ -632,20 +629,20 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
|
||||
}
|
||||
|
||||
void Gui::renderHearts() {
|
||||
bool blink = (minecraft->player->invulnerableTime / 3) % 2 == 1;
|
||||
if (minecraft->player->invulnerableTime < 10) blink = false;
|
||||
int h = minecraft->player->health;
|
||||
int oh = minecraft->player->lastHealth;
|
||||
bool blink = (minecraft.player()->invulnerableTime / 3) % 2 == 1;
|
||||
if (minecraft.player()->invulnerableTime < 10) blink = false;
|
||||
int h = minecraft.player()->health;
|
||||
int oh = minecraft.player()->lastHealth;
|
||||
random.setSeed(tickCount * 312871);
|
||||
|
||||
int screenWidth = (int)(minecraft->width * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
||||
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||
|
||||
int xx = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenWidth / 2 - getNumSlots() * 10 - 1 : 2;
|
||||
int xx = (minecraft.options().getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenWidth / 2 - getNumSlots() * 10 - 1 : 2;
|
||||
|
||||
int armor = minecraft->player->getArmorValue();
|
||||
int armor = minecraft.player()->getArmorValue();
|
||||
for (int i = 0; i < Player::MAX_HEALTH / 2; i++) {
|
||||
int yo = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenHeight - 32 : 2;
|
||||
int yo = (minecraft.options().getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenHeight - 32 : 2;
|
||||
int ip2 = i + i + 1;
|
||||
|
||||
if (armor > 0) {
|
||||
@@ -672,14 +669,14 @@ void Gui::renderHearts() {
|
||||
}
|
||||
|
||||
void Gui::renderBubbles() {
|
||||
if (minecraft->player->isUnderLiquid(Material::water)) {
|
||||
int screenWidth = (int)(minecraft->width * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
||||
if (minecraft.player()->isUnderLiquid(Material::water)) {
|
||||
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||
|
||||
int xx = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenWidth / 2 - getNumSlots() * 10 - 1 : 2;
|
||||
int yo = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenHeight - 42 : 12;
|
||||
int count = (int) std::ceil((minecraft->player->airSupply - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY);
|
||||
int extra = (int) std::ceil((minecraft->player->airSupply) * 10.0f / Player::TOTAL_AIR_SUPPLY) - count;
|
||||
int xx = (minecraft.options().getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenWidth / 2 - getNumSlots() * 10 - 1 : 2;
|
||||
int yo = (minecraft.options().getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenHeight - 42 : 12;
|
||||
int count = (int) std::ceil((minecraft.player()->airSupply - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY);
|
||||
int extra = (int) std::ceil((minecraft.player()->airSupply) * 10.0f / Player::TOTAL_AIR_SUPPLY) - count;
|
||||
for (int i = 0; i < count + extra; i++) {
|
||||
int xo = i * 8 + xx;
|
||||
if (i < count) blit(xo, yo, 16, 9 * 2, 9, 9);
|
||||
@@ -690,7 +687,7 @@ void Gui::renderBubbles() {
|
||||
|
||||
static OffsetPosTranslator posTranslator;
|
||||
void Gui::onLevelGenerated() {
|
||||
if (Level* level = minecraft->level) {
|
||||
if (Level* level = minecraft.level) {
|
||||
Pos p = level->getSharedSpawnPos();
|
||||
posTranslator = OffsetPosTranslator((float)-p.x, (float)-p.y, (float)-p.z);
|
||||
}
|
||||
@@ -709,8 +706,8 @@ void Gui::renderDebugInfo() {
|
||||
fpsLastTime = now;
|
||||
}
|
||||
|
||||
LocalPlayer* p = minecraft->player;
|
||||
Level* lvl = minecraft->level;
|
||||
LocalPlayer* p = minecraft.player();
|
||||
Level* lvl = minecraft.level;
|
||||
|
||||
// Position
|
||||
float px = p->x, py = p->y - p->heightOffset, pz = p->z;
|
||||
@@ -756,7 +753,7 @@ void Gui::renderDebugInfo() {
|
||||
const float LH = (float)Font::DefaultLineHeight; // 10 font-pixels
|
||||
const float MGN = 2.0f; // left/top margin in font-pixels
|
||||
const float PAD = 2.0f; // horizontal padding for background
|
||||
Font* font = minecraft->font;
|
||||
Font* font = minecraft.font();
|
||||
|
||||
// 1) Draw semi-transparent background boxes behind each line
|
||||
for (int i = 0; i < N; i++) {
|
||||
@@ -781,12 +778,12 @@ void Gui::renderDebugInfo() {
|
||||
t.endOverrideAndDraw();
|
||||
}
|
||||
|
||||
void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) {
|
||||
void Gui::renderPlayerList(Font& font, int screenWidth, int screenHeight) {
|
||||
// only show when in game, no other screen
|
||||
// if (!minecraft->level) return;
|
||||
// if (!minecraft.level) return;
|
||||
|
||||
// only show the overlay while connected to a multiplayer server
|
||||
Level* level = minecraft->level;
|
||||
Level* level = minecraft.level;
|
||||
if (!level) return;
|
||||
if (!level->isClientSide) return;
|
||||
|
||||
@@ -808,7 +805,7 @@ void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) {
|
||||
float maxNameWidth = 0.0f;
|
||||
// find the longest name so we can size the box accordingly
|
||||
for (const std::string& name : playerNames) {
|
||||
float nameWidth = font->width(name);
|
||||
float nameWidth = font.width(name);
|
||||
if (nameWidth > maxNameWidth)
|
||||
maxNameWidth = nameWidth;
|
||||
}
|
||||
@@ -817,7 +814,7 @@ void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) {
|
||||
std::ostringstream titleStream;
|
||||
titleStream << "Players (" << playerNames.size() << ")";
|
||||
std::string titleText = titleStream.str();
|
||||
float titleWidth = font->width(titleText);
|
||||
float titleWidth = font.width(titleText);
|
||||
|
||||
if (titleWidth > maxNameWidth)
|
||||
maxNameWidth = titleWidth;
|
||||
@@ -847,21 +844,21 @@ void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) {
|
||||
//glScalef2(textScale, textScale, 1);
|
||||
|
||||
// draw title
|
||||
//font->draw(titleText, titleX * invTextScale, titleY * invTextScale, 0xFFFFFFFF);
|
||||
font->draw(titleText, titleX, titleY, 0xFFFFFFFF);
|
||||
//font.draw(titleText, titleX * invTextScale, titleY * invTextScale, 0xFFFFFFFF);
|
||||
font.draw(titleText, titleX, titleY, 0xFFFFFFFF);
|
||||
|
||||
// draw player names
|
||||
// we should add ping icons here eventually, but for now just show names
|
||||
float currentY = boxTop + padding + lineHeight;
|
||||
for (const std::string& name : playerNames) {
|
||||
font->draw(name, (boxLeft + padding), currentY, 0xFFDDDDDD);
|
||||
font.draw(name, (boxLeft + padding), currentY, 0xFFDDDDDD);
|
||||
currentY += lineHeight;
|
||||
}
|
||||
//glPopMatrix2();
|
||||
}
|
||||
|
||||
void Gui::renderSleepAnimation( const int screenWidth, const int screenHeight ) {
|
||||
int timer = minecraft->player->getSleepTimer();
|
||||
int timer = minecraft.player()->getSleepTimer();
|
||||
float amount = (float) timer / (float) Player::SLEEP_DURATION;
|
||||
if (amount > 1) {
|
||||
// waking up
|
||||
@@ -872,11 +869,11 @@ void Gui::renderSleepAnimation( const int screenWidth, const int screenHeight )
|
||||
fill(0, 0, screenWidth, screenHeight, color);
|
||||
}
|
||||
|
||||
void Gui::renderOnSelectItemNameText( const int screenWidth, Font* font, int ySlot ) {
|
||||
void Gui::renderOnSelectItemNameText( const int screenWidth, Font& font, int ySlot ) {
|
||||
if(itemNameOverlayTime < 1.0f) {
|
||||
ItemInstance* item = minecraft->player->inventory->getSelected();
|
||||
ItemInstance* item = minecraft.player()->inventory->getSelected();
|
||||
if(item != NULL) {
|
||||
float x = float(screenWidth / 2 - font->width(item->getName()) / 2);
|
||||
float x = float(screenWidth / 2 - font.width(item->getName()) / 2);
|
||||
float y = float(ySlot - 22);
|
||||
int alpha = 255;
|
||||
if(itemNameOverlayTime > 0.75) {
|
||||
@@ -885,7 +882,7 @@ void Gui::renderOnSelectItemNameText( const int screenWidth, Font* font, int ySl
|
||||
alpha = int(percentage * 255);
|
||||
}
|
||||
if(alpha != 0)
|
||||
font->drawShadow(item->getName(), x, y, 0x00ffffff + (alpha << 24));
|
||||
font.drawShadow(item->getName(), x, y, 0x00ffffff + (alpha << 24));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -933,28 +930,28 @@ static void parseColorTags(const std::string& in, std::vector<ColorSegment>& out
|
||||
}
|
||||
}
|
||||
|
||||
void Gui::drawColoredString(Font* font, const std::string& text, float x, float y, int alpha) {
|
||||
void Gui::drawColoredString(Font& font, const std::string& text, float x, float y, int alpha) {
|
||||
std::vector<ColorSegment> segs;
|
||||
parseColorTags(text, segs);
|
||||
float cx = x;
|
||||
for (auto &s : segs) {
|
||||
int color = s.color + (alpha << 24);
|
||||
font->drawShadow(s.text, cx, y, color);
|
||||
cx += font->width(s.text);
|
||||
font.drawShadow(s.text, cx, y, color);
|
||||
cx += font.width(s.text);
|
||||
}
|
||||
}
|
||||
|
||||
float Gui::getColoredWidth(Font* font, const std::string& text) {
|
||||
float Gui::getColoredWidth(Font& font, const std::string& text) {
|
||||
std::vector<ColorSegment> segs;
|
||||
parseColorTags(text, segs);
|
||||
float w = 0;
|
||||
for (auto &s : segs) {
|
||||
w += font->width(s.text);
|
||||
w += font.width(s.text);
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font* font ) {
|
||||
void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font& font ) {
|
||||
// if (minecraft.screen instanceof ChatScreen) {
|
||||
// max = 20;
|
||||
// isChatting = true;
|
||||
@@ -991,7 +988,7 @@ void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isC
|
||||
const float x = 2;
|
||||
const float y = (float)(baseY - i * 9);
|
||||
std::string msg = message.message;
|
||||
this->fill(x, y - 1, x + MAX_MESSAGE_WIDTH, y + 8, (alpha / 2) << 24);
|
||||
this->fill(x, y - 1, x + maxMessageWidth, y + 8, (alpha / 2) << 24);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
// special-case join/leave announcements
|
||||
@@ -1009,9 +1006,9 @@ void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isC
|
||||
|
||||
void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
||||
glColor4f2(1, 1, 1, .5);
|
||||
minecraft->textures->loadAndBindTexture("gui/gui.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||
|
||||
Inventory* inventory = minecraft->player->inventory;
|
||||
Inventory* inventory = minecraft.player()->inventory;
|
||||
|
||||
int xBase, yBase;
|
||||
getSlotPos(0, xBase, yBase);
|
||||
@@ -1068,7 +1065,7 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
||||
blit(screenWidth / 2 + 10 * getNumSlots() - 20 + 4, ySlot + 6, 242, 252, 14, 4, 14, 4);
|
||||
}
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/gui_blocks.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/gui_blocks.png");
|
||||
t.endOverrideAndDraw();
|
||||
|
||||
// Render damaged items (@todo: investigate if it's faster by drawing in same batch)
|
||||
@@ -1077,7 +1074,7 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
||||
t.beginOverride();
|
||||
x = baseItemX;
|
||||
for (int i = 0; i < slots; i++) {
|
||||
ItemRenderer::renderGuiItemDecorations(minecraft->player->inventory->getItem(i), x, (float)ySlot);
|
||||
ItemRenderer::renderGuiItemDecorations(minecraft.player()->inventory->getItem(i), x, (float)ySlot);
|
||||
x += 20;
|
||||
}
|
||||
t.endOverrideAndDraw();
|
||||
@@ -1094,16 +1091,16 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
||||
const float k = 0.5f * GuiScale;
|
||||
|
||||
t.beginOverride();
|
||||
if (minecraft->gameMode->isSurvivalType()) {
|
||||
if (minecraft.gameMode->isSurvivalType()) {
|
||||
x = baseItemX;
|
||||
for (int i = 0; i < slots; i++) {
|
||||
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
||||
ItemInstance* item = minecraft.player()->inventory->getItem(i);
|
||||
if (item && item->count >= 0)
|
||||
renderSlotText(item, k*x, k*ySlot + 1, true, true);
|
||||
x += 20;
|
||||
}
|
||||
}
|
||||
minecraft->textures->loadAndBindTexture("font/default8.png");
|
||||
minecraft.textures().loadAndBindTexture("font/default8.png");
|
||||
t.endOverrideAndDraw();
|
||||
|
||||
glPopMatrix2();
|
||||
|
||||
@@ -45,22 +45,22 @@ public:
|
||||
|
||||
void renderToolBar( float a, int ySlot, const int screenWidth );
|
||||
|
||||
void renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font* font );
|
||||
void renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font& font );
|
||||
|
||||
// draw a string containing simple [color]...[/color] tags; color names are matched
|
||||
// case-insensitively and default to white. alpha is applied to each segment.
|
||||
// draw tagged string (ignores simple [color]…[/color] tags)
|
||||
static void drawColoredString(Font* font, const std::string& text, float x, float y, int alpha);
|
||||
static float getColoredWidth(Font* font, const std::string& text);
|
||||
static void drawColoredString(Font& font, const std::string& text, float x, float y, int alpha);
|
||||
static float getColoredWidth(Font& font, const std::string& text);
|
||||
|
||||
void renderOnSelectItemNameText( const int screenWidth, Font* font, int ySlot );
|
||||
void renderOnSelectItemNameText( const int screenWidth, Font& font, int ySlot );
|
||||
|
||||
void renderSleepAnimation( const int screenWidth, const int screenHeight );
|
||||
|
||||
void renderBubbles();
|
||||
void renderHearts();
|
||||
void renderDebugInfo();
|
||||
void renderPlayerList(Font* font, int screenWidth, int screenHeight);
|
||||
void renderPlayerList(Font& font, int screenWidth, int screenHeight);
|
||||
|
||||
void renderProgressIndicator( const bool isTouchInterface, const int screenWidth, const int screenHeight, float a );
|
||||
|
||||
@@ -127,5 +127,7 @@ private:
|
||||
int _currentDropSlot = -1;
|
||||
|
||||
bool _openInventorySlot;
|
||||
|
||||
int maxMessageWidth = 240;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ GuiComponent::~GuiComponent()
|
||||
{
|
||||
}
|
||||
|
||||
void GuiComponent::drawCenteredString( Font* font, const std::string& str, int x, int y, int color )
|
||||
void GuiComponent::drawCenteredString( Font& font, const std::string& str, int x, int y, int color )
|
||||
{
|
||||
font->drawShadow(str, (float)(x - font->width(str) / 2), (float)(y - font->height(str) / 2), color);
|
||||
font.drawShadow(str, (float)(x - font.width(str) / 2), (float)(y - font.height(str) / 2), color);
|
||||
}
|
||||
|
||||
void GuiComponent::drawString( Font* font, const std::string& str, int x, int y, int color )
|
||||
void GuiComponent::drawString( Font& font, const std::string& str, int x, int y, int color )
|
||||
{
|
||||
font->drawShadow(str, (float)x, (float)y /*- font->height(str)/2*/, color);
|
||||
font.drawShadow(str, (float)x, (float)y /*- font.height(str)/2*/, color);
|
||||
}
|
||||
|
||||
void GuiComponent::blit( int x, int y, int sx, int sy, int w, int h, int sw/*=0*/, int sh/*=0*/ )
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <string>
|
||||
class Font;
|
||||
class Minecraft;
|
||||
|
||||
class GuiComponent
|
||||
{
|
||||
@@ -12,8 +11,8 @@ public:
|
||||
GuiComponent();
|
||||
virtual ~GuiComponent();
|
||||
|
||||
void drawString(Font* font, const std::string& str, int x, int y, int color);
|
||||
void drawCenteredString(Font* font, const std::string& str, int x, int y, int color);
|
||||
void drawString(Font& font, const std::string& str, int x, int y, int color);
|
||||
void drawCenteredString(Font& font, const std::string& str, int x, int y, int color);
|
||||
|
||||
void blit(int x, int y, int sx, int sy, int w, int h, int sw=0, int sh=0);
|
||||
void blit(float x, float y, int sx, int sy, float w, float h, int sw=0, int sh=0);
|
||||
@@ -27,6 +26,5 @@ protected:
|
||||
void fillHorizontalGradient(float x0, float y0, float x1, float y1, int col1, int col2);
|
||||
|
||||
float blitOffset;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -7,14 +7,15 @@
|
||||
#include "platform/input/Keyboard.hpp"
|
||||
#include "platform/input/Mouse.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
|
||||
Screen::Screen()
|
||||
Screen::Screen(MinecraftClient& minecraft)
|
||||
: passEvents(false),
|
||||
clickedButton(NULL),
|
||||
tabButtonIndex(0),
|
||||
width(1),
|
||||
height(1),
|
||||
minecraft(NULL),
|
||||
minecraft(minecraft),
|
||||
font(NULL)
|
||||
{
|
||||
}
|
||||
@@ -33,11 +34,10 @@ void Screen::render( int xm, int ym, float a )
|
||||
}
|
||||
}
|
||||
|
||||
void Screen::init( Minecraft* minecraft, int width, int height )
|
||||
void Screen::init(int width, int height)
|
||||
{
|
||||
//particles = /*new*/ GuiParticles(minecraft);
|
||||
this->minecraft = minecraft;
|
||||
this->font = minecraft->font;
|
||||
this->font = minecraft.font();
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
init();
|
||||
@@ -80,8 +80,8 @@ void Screen::mouseEvent()
|
||||
const MouseAction& e = Mouse::getEvent();
|
||||
// forward wheel events to subclasses
|
||||
if (e.action == MouseAction::ACTION_WHEEL) {
|
||||
int xm = e.x * width / minecraft->width;
|
||||
int ym = e.y * height / minecraft->height - 1;
|
||||
int xm = e.x * width / minecraft.getScreenWidth();
|
||||
int ym = e.y * height / minecraft.getScreenHeight() - 1;
|
||||
mouseWheel(e.dx, e.dy, xm, ym);
|
||||
return;
|
||||
}
|
||||
@@ -90,12 +90,12 @@ void Screen::mouseEvent()
|
||||
return;
|
||||
|
||||
if (Mouse::getEventButtonState()) {
|
||||
int xm = e.x * width / minecraft->width;
|
||||
int ym = e.y * height / minecraft->height - 1;
|
||||
int xm = e.x * width / minecraft.getScreenWidth();
|
||||
int ym = e.y * height / minecraft.getScreenHeight() - 1;
|
||||
mouseClicked(xm, ym, Mouse::getEventButton());
|
||||
} else {
|
||||
int xm = e.x * width / minecraft->width;
|
||||
int ym = e.y * height / minecraft->height - 1;
|
||||
int xm = e.x * width / minecraft.getScreenWidth();
|
||||
int ym = e.y * height / minecraft.getScreenHeight() - 1;
|
||||
mouseReleased(xm, ym, Mouse::getEventButton());
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ void Screen::keyboardEvent()
|
||||
{
|
||||
if (Keyboard::getEventKeyState()) {
|
||||
//if (Keyboard.getEventKey() == Keyboard.KEY_F11) {
|
||||
// minecraft->toggleFullScreen();
|
||||
// minecraft.toggleFullScreen();
|
||||
// return;
|
||||
//}
|
||||
keyPressed(Keyboard::getEventKey());
|
||||
@@ -121,7 +121,7 @@ void Screen::renderBackground()
|
||||
|
||||
void Screen::renderBackground( int vo )
|
||||
{
|
||||
if (minecraft->isLevelGenerated()) {
|
||||
if (minecraft.isLevelGenerated()) {
|
||||
fillGradient(0, 0, width, height, 0xc0101010, 0xd0101010);
|
||||
} else {
|
||||
renderDirtBackground(vo);
|
||||
@@ -133,7 +133,7 @@ void Screen::renderDirtBackground( int vo )
|
||||
//glDisable2(GL_LIGHTING);
|
||||
glDisable2(GL_FOG);
|
||||
Tesselator& t = Tesselator::instance;
|
||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
float s = 32;
|
||||
float fvo = (float) vo;
|
||||
@@ -168,8 +168,8 @@ bool Screen::closeOnPlayerHurt() {
|
||||
void Screen::keyPressed( int eventKey )
|
||||
{
|
||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||
minecraft->setScreen(NULL);
|
||||
//minecraft->grabMouse();
|
||||
minecraft.setScreen(NULL);
|
||||
//minecraft.grabMouse();
|
||||
}
|
||||
|
||||
// pass key events to any text boxes first
|
||||
@@ -178,7 +178,7 @@ void Screen::keyPressed( int eventKey )
|
||||
}
|
||||
|
||||
#ifdef TABBING
|
||||
if (minecraft->useTouchscreen())
|
||||
if (minecraft.useTouchscreen())
|
||||
return;
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ void Screen::keyPressed( int eventKey )
|
||||
if (!tabButtonCount)
|
||||
return;
|
||||
|
||||
Options& o = minecraft->options;
|
||||
Options& o = minecraft.options;
|
||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_NEXT))
|
||||
if (++tabButtonIndex == tabButtonCount) tabButtonIndex = 0;
|
||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_PREV))
|
||||
@@ -195,7 +195,7 @@ void Screen::keyPressed( int eventKey )
|
||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_OK)) {
|
||||
Button* button = tabButtons[tabButtonIndex];
|
||||
if (button->active) {
|
||||
minecraft->soundEngine->playUI("random.click", 1, 1);
|
||||
minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||
buttonClicked(button);
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ void Screen::charPressed(char inputChar) {
|
||||
void Screen::updateTabButtonSelection()
|
||||
{
|
||||
#ifdef TABBING
|
||||
if (minecraft->useTouchscreen())
|
||||
if (minecraft.useTouchscreen())
|
||||
return;
|
||||
|
||||
for (unsigned int i = 0; i < tabButtons.size(); ++i)
|
||||
@@ -233,8 +233,8 @@ void Screen::mouseClicked( int x, int y, int buttonNum )
|
||||
//LOGI("Hit-test successful: %p\n", button);
|
||||
clickedButton = button;
|
||||
/*
|
||||
#if !defined(ANDROID) && !defined(__APPLE__) //if (!minecraft->isTouchscreen()) {
|
||||
minecraft->soundEngine->playUI("random.click", 1, 1);
|
||||
#if !defined(ANDROID) && !defined(__APPLE__) //if (!minecraft.isTouchscreen()) {
|
||||
minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||
buttonClicked(button);
|
||||
#endif }
|
||||
*/
|
||||
@@ -254,12 +254,12 @@ void Screen::mouseReleased( int x, int y, int buttonNum )
|
||||
if (!clickedButton || buttonNum != MouseAction::ACTION_LEFT) return;
|
||||
|
||||
#if 1
|
||||
//#if defined(ANDROID) || defined(__APPLE__) //if (minecraft->isTouchscreen()) {
|
||||
//#if defined(ANDROID) || defined(__APPLE__) //if (minecraft.isTouchscreen()) {
|
||||
for (unsigned int i = 0; i < buttons.size(); ++i) {
|
||||
Button* button = buttons[i];
|
||||
if (clickedButton == button && button->clicked(minecraft, x, y)) {
|
||||
buttonClicked(button);
|
||||
minecraft->soundEngine->playUI("random.click", 1, 1);
|
||||
minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||
clickedButton->released(x, y);
|
||||
}
|
||||
}
|
||||
@@ -279,13 +279,13 @@ bool Screen::hasClippingArea( IntRectangle& out )
|
||||
}
|
||||
|
||||
void Screen::lostFocus() {
|
||||
for(std::vector<TextBox*>::iterator it = textBoxes.begin(); it != textBoxes.end(); ++it) {
|
||||
for(auto it = textBoxes.begin(); it != textBoxes.end(); ++it) {
|
||||
TextBox* tb = *it;
|
||||
tb->loseFocus(minecraft);
|
||||
}
|
||||
}
|
||||
|
||||
void Screen::toGUICoordinate( int& x, int& y ) {
|
||||
x = x * width / minecraft->width;
|
||||
y = y * height / minecraft->height - 1;
|
||||
x = x * width / minecraft.getScreenWidth();
|
||||
y = y * height / minecraft.getScreenHeight() - 1;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "GuiComponent.hpp"
|
||||
|
||||
class Font;
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
class Button;
|
||||
class TextBox;
|
||||
struct IntRectangle;
|
||||
@@ -14,11 +14,11 @@ struct IntRectangle;
|
||||
class Screen: public GuiComponent
|
||||
{
|
||||
public:
|
||||
Screen();
|
||||
Screen(MinecraftClient& minecraft);
|
||||
|
||||
virtual void render(int xm, int ym, float a);
|
||||
|
||||
void init(Minecraft* minecraft, int width, int height);
|
||||
void init(int width, int height);
|
||||
virtual void init();
|
||||
|
||||
void setSize(int width, int height);
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
bool passEvents;
|
||||
//GuiParticles* particles;
|
||||
protected:
|
||||
Minecraft* minecraft;
|
||||
MinecraftClient& minecraft;
|
||||
std::vector<Button*> buttons;
|
||||
std::vector<TextBox*> textBoxes;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Button.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include <cstddef>
|
||||
#include "client/renderer/Textures.hpp"
|
||||
|
||||
Button::Button(int id, const std::string& msg)
|
||||
@@ -29,12 +30,12 @@ Button::Button( int id, int x, int y, int w, int h, const std::string& msg )
|
||||
{
|
||||
}
|
||||
|
||||
void Button::render( Minecraft* minecraft, int xm, int ym )
|
||||
void Button::render( MinecraftClient& minecraft, int xm, int ym )
|
||||
{
|
||||
if (!visible) return;
|
||||
|
||||
/*
|
||||
minecraft->textures->loadAndBindTexture("gui/gui.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
|
||||
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
|
||||
@@ -52,7 +53,7 @@ void Button::released( int mx, int my ) {
|
||||
_currentlyDown = false;
|
||||
}
|
||||
|
||||
bool Button::clicked( Minecraft* minecraft, int mx, int my )
|
||||
bool Button::clicked( MinecraftClient& minecraft, int mx, int my )
|
||||
{
|
||||
return active && mx >= x && my >= y && mx < x + width && my < y + height;
|
||||
}
|
||||
@@ -69,22 +70,27 @@ int Button::getYImage( bool hovered )
|
||||
return res;
|
||||
}
|
||||
|
||||
void Button::renderFace(Minecraft* mc, int xm, int ym) {
|
||||
Font* font = mc->font;
|
||||
void Button::renderFace(MinecraftClient& mc, int xm, int ym) {
|
||||
Font* font = mc.font();
|
||||
|
||||
if (font == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!active) {
|
||||
drawCenteredString(font, msg, x + width / 2, y + (height - 8) / 2, 0xffa0a0a0);
|
||||
drawCenteredString(*font, msg, x + width / 2, y + (height - 8) / 2, 0xffa0a0a0);
|
||||
} else {
|
||||
if (hovered(mc, xm, ym) || selected) {
|
||||
drawCenteredString(font, msg, x + width / 2, y + (height - 8) / 2, 0xffffa0);
|
||||
drawCenteredString(*font, msg, x + width / 2, y + (height - 8) / 2, 0xffffa0);
|
||||
} else {
|
||||
drawCenteredString(font, msg, x + width / 2, y + (height - 8) / 2, 0xe0e0e0);
|
||||
drawCenteredString(*font, msg, x + width / 2, y + (height - 8) / 2, 0xe0e0e0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Button::renderBg( Minecraft* minecraft, int xm, int ym )
|
||||
void Button::renderBg( MinecraftClient& minecraft, int xm, int ym )
|
||||
{
|
||||
minecraft->textures->loadAndBindTexture("gui/gui.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
|
||||
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
|
||||
@@ -94,8 +100,8 @@ void Button::renderBg( Minecraft* minecraft, int xm, int ym )
|
||||
blit(x + width / 2, y, 200 - width / 2, 46 + yImage * 20, width / 2, height, 0, 20);
|
||||
}
|
||||
|
||||
bool Button::hovered(Minecraft* minecraft, int xm , int ym) {
|
||||
return minecraft->useTouchscreen()? (_currentlyDown && isInside(xm, ym)) : isInside(xm, ym);
|
||||
bool Button::hovered(MinecraftClient& minecraft, int xm , int ym) {
|
||||
return minecraft.useTouchscreen()? (_currentlyDown && isInside(xm, ym)) : isInside(xm, ym);
|
||||
}
|
||||
|
||||
bool Button::isInside( int xm, int ym ) {
|
||||
@@ -141,12 +147,12 @@ TButton::TButton( int id, int x, int y, int w, int h, const std::string& msg )
|
||||
{
|
||||
}
|
||||
|
||||
void TButton::renderBg( Minecraft* minecraft, int xm, int ym )
|
||||
void TButton::renderBg( MinecraftClient& minecraft, int xm, int ym )
|
||||
{
|
||||
bool hovered = active && (minecraft->useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||
bool hovered = active && (minecraft.useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||
// bool hovered = active && (_currentlyDown && isInside(xm, ym));
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/touchgui.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/touchgui.png");
|
||||
|
||||
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
|
||||
if (active)
|
||||
@@ -187,19 +193,22 @@ THeader::THeader( int id, int x, int y, int w, int h, const std::string& msg )
|
||||
active = false;
|
||||
}
|
||||
|
||||
void THeader::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
Font* font = minecraft->font;
|
||||
void THeader::render( MinecraftClient& minecraft, int xm, int ym ) {
|
||||
Font* font = minecraft.font();
|
||||
renderBg(minecraft, xm, ym);
|
||||
|
||||
int xx = x + width/2;
|
||||
if (xText != -99999)
|
||||
xx = xText;
|
||||
drawCenteredString(font, msg, xx, y + (height - 8) / 2, 0xe0e0e0);
|
||||
|
||||
if (font != nullptr) {
|
||||
drawCenteredString(*font, msg, xx, y + (height - 8) / 2, 0xe0e0e0);
|
||||
}
|
||||
}
|
||||
|
||||
void THeader::renderBg( Minecraft* minecraft, int xm, int ym )
|
||||
void THeader::renderBg( MinecraftClient& minecraft, int xm, int ym )
|
||||
{
|
||||
minecraft->textures->loadAndBindTexture("gui/touchgui.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/touchgui.png");
|
||||
|
||||
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "client/Options.hpp"
|
||||
|
||||
class Font;
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
|
||||
class Button: public GuiElement
|
||||
{
|
||||
@@ -16,19 +16,19 @@ public:
|
||||
Button(int id, int x, int y, const std::string& msg);
|
||||
Button(int id, int x, int y, int w, int h, const std::string& msg);
|
||||
virtual ~Button() {}
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||
virtual void render(MinecraftClient& minecraft, int xm, int ym);
|
||||
|
||||
virtual bool clicked(Minecraft* minecraft, int mx, int my);
|
||||
virtual bool clicked(MinecraftClient& minecraft, int mx, int my);
|
||||
virtual void released(int mx, int my);
|
||||
virtual void setPressed();
|
||||
|
||||
bool isInside(int xm, int ym);
|
||||
protected:
|
||||
virtual int getYImage(bool hovered);
|
||||
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
|
||||
virtual void renderBg(MinecraftClient& minecraft, int xm, int ym);
|
||||
|
||||
virtual void renderFace(Minecraft* minecraft, int xm, int ym);
|
||||
bool hovered(Minecraft* minecraft, int xm, int ym);
|
||||
virtual void renderFace(MinecraftClient& minecraft, int xm, int ym);
|
||||
bool hovered(MinecraftClient& minecraft, int xm, int ym);
|
||||
public:
|
||||
std::string msg;
|
||||
int id;
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
TButton(int id, int x, int y, const std::string& msg);
|
||||
TButton(int id, int x, int y, int w, int h, const std::string& msg);
|
||||
protected:
|
||||
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
|
||||
virtual void renderBg(MinecraftClient& minecraft, int xm, int ym);
|
||||
};
|
||||
|
||||
// "Header" in Touchscreen mode
|
||||
@@ -69,8 +69,8 @@ public:
|
||||
THeader(int id, int x, int y, const std::string& msg);
|
||||
THeader(int id, int x, int y, int w, int h, const std::string& msg);
|
||||
protected:
|
||||
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
|
||||
void render( Minecraft* minecraft, int xm, int ym );
|
||||
virtual void renderBg(MinecraftClient& minecraft, int xm, int ym);
|
||||
void render( MinecraftClient& minecraft, int xm, int ym );
|
||||
public:
|
||||
int xText;
|
||||
};
|
||||
|
||||
@@ -25,11 +25,11 @@ public:
|
||||
layers.push_back(std::make_pair(e, layerId));
|
||||
}
|
||||
|
||||
void render( Minecraft* minecraft, int xm, int ym )
|
||||
void render( MinecraftClient& minecraft, int xm, int ym )
|
||||
{
|
||||
if (!visible) return;
|
||||
|
||||
bool isHovered = minecraft->isTouchscreen()?
|
||||
bool isHovered = minecraft.isTouchscreen()?
|
||||
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height): false;
|
||||
|
||||
int layer = isHovered? LayerSelected : LayerDefault;
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
#include "client/gui/GuiComponent.hpp"
|
||||
|
||||
class Tesselator;
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
|
||||
class GuiElement : public GuiComponent {
|
||||
public:
|
||||
GuiElement(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
|
||||
virtual ~GuiElement() {}
|
||||
|
||||
virtual void tick(Minecraft* minecraft) {}
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym) { }
|
||||
virtual void tick(MinecraftClient& minecraft) {}
|
||||
virtual void render(MinecraftClient& minecraft, int xm, int ym) { }
|
||||
virtual void setupPositions() {}
|
||||
|
||||
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {}
|
||||
virtual void mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum) {}
|
||||
virtual void keyPressed(Minecraft* minecraft, int key) {}
|
||||
virtual void charPressed(Minecraft* minecraft, char key) {}
|
||||
virtual void mouseClicked(MinecraftClient& minecraft, int x, int y, int buttonNum) {}
|
||||
virtual void mouseReleased(MinecraftClient& minecraft, int x, int y, int buttonNum) {}
|
||||
virtual void keyPressed(MinecraftClient& minecraft, int key) {}
|
||||
virtual void charPressed(MinecraftClient& minecraft, char key) {}
|
||||
|
||||
virtual bool pointInside(int x, int y);
|
||||
|
||||
|
||||
@@ -13,14 +13,14 @@ GuiElementContainer::~GuiElementContainer() {
|
||||
}
|
||||
}
|
||||
|
||||
void GuiElementContainer::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
void GuiElementContainer::render( MinecraftClient& minecraft, int xm, int ym ) {
|
||||
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->render(minecraft, xm, ym);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiElementContainer::setupPositions() {
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->setupPositions();
|
||||
}
|
||||
}
|
||||
@@ -30,37 +30,37 @@ void GuiElementContainer::addChild( GuiElement* element ) {
|
||||
}
|
||||
|
||||
void GuiElementContainer::removeChild( GuiElement* element ) {
|
||||
std::vector<GuiElement*>::iterator it = std::find(children.begin(), children.end(), element);
|
||||
auto it = std::find(children.begin(), children.end(), element);
|
||||
if(it != children.end())
|
||||
children.erase(it);
|
||||
}
|
||||
|
||||
void GuiElementContainer::tick( Minecraft* minecraft ) {
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
void GuiElementContainer::tick( MinecraftClient& minecraft ) {
|
||||
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->tick(minecraft);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiElementContainer::mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
void GuiElementContainer::mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum ) {
|
||||
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->mouseClicked(minecraft, x, y, buttonNum);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiElementContainer::mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
void GuiElementContainer::mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum ) {
|
||||
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->mouseReleased(minecraft, x, y, buttonNum);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiElementContainer::keyPressed(Minecraft* minecraft, int key) {
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
void GuiElementContainer::keyPressed(MinecraftClient& minecraft, int key) {
|
||||
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->keyPressed(minecraft, key);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiElementContainer::charPressed(Minecraft* minecraft, char key) {
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
void GuiElementContainer::charPressed(MinecraftClient& minecraft, char key) {
|
||||
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->charPressed(minecraft, key);
|
||||
}
|
||||
}
|
||||
@@ -2,23 +2,23 @@
|
||||
#include "GuiElement.hpp"
|
||||
#include <vector>
|
||||
class Tesselator;
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
|
||||
class GuiElementContainer : public GuiElement {
|
||||
public:
|
||||
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
|
||||
virtual ~GuiElementContainer();
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||
virtual void render(MinecraftClient& minecraft, int xm, int ym);
|
||||
virtual void setupPositions();
|
||||
virtual void addChild(GuiElement* element);
|
||||
virtual void removeChild(GuiElement* element);
|
||||
|
||||
virtual void tick( Minecraft* minecraft );
|
||||
virtual void tick( MinecraftClient& minecraft );
|
||||
|
||||
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
|
||||
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
|
||||
virtual void keyPressed(Minecraft* minecraft, int key);
|
||||
virtual void charPressed(Minecraft* minecraft, char key);
|
||||
virtual void mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum );
|
||||
virtual void mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum );
|
||||
virtual void keyPressed(MinecraftClient& minecraft, int key);
|
||||
virtual void charPressed(MinecraftClient& minecraft, char key);
|
||||
|
||||
protected:
|
||||
std::vector<GuiElement*> children;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "ImageButton.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "platform/log.hpp"
|
||||
#include "util/Mth.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
@@ -34,15 +34,15 @@ void ImageButton::setImageDef(const ImageDef& imageDef, bool setButtonSize) {
|
||||
}
|
||||
}
|
||||
|
||||
void ImageButton::render(Minecraft* minecraft, int xm, int ym) {
|
||||
void ImageButton::render(MinecraftClient& minecraft, int xm, int ym) {
|
||||
if (!visible) return;
|
||||
|
||||
Font* font = minecraft->font;
|
||||
Font* font = minecraft.font();
|
||||
|
||||
//minecraft->textures->loadAndBindTexture("gui/gui.png");
|
||||
//minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
|
||||
bool hovered = active && (minecraft->useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||
bool hovered = active && (minecraft.useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||
bool IsSecondImage = isSecondImage(hovered);
|
||||
|
||||
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
|
||||
@@ -53,7 +53,7 @@ void ImageButton::render(Minecraft* minecraft, int xm, int ym) {
|
||||
|
||||
renderBg(minecraft, xm, ym);
|
||||
|
||||
TextureId texId = (_imageDef.name.length() > 0)? minecraft->textures->loadAndBindTexture(_imageDef.name) : Textures::InvalidId;
|
||||
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;
|
||||
@@ -75,7 +75,7 @@ void ImageButton::render(Minecraft* minecraft, int xm, int ym) {
|
||||
|
||||
const IntRectangle* src = _imageDef.getSrc();
|
||||
if (src) {
|
||||
const TextureData* d = minecraft->textures->getTemporaryTextureData(texId);
|
||||
const TextureData* d = minecraft.textures().getTemporaryTextureData(texId);
|
||||
if (d != NULL) {
|
||||
float u0 = (src->x+(IsSecondImage?src->w:0)) / (float)d->w;
|
||||
float u1 = (src->x+(IsSecondImage?2*src->w:src->w)) / (float)d->w;
|
||||
@@ -126,10 +126,10 @@ void OptionButton::updateImage(Options* options) {
|
||||
_secondImage = options->getBooleanValue(m_optId);
|
||||
}
|
||||
|
||||
void OptionButton::mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
||||
void OptionButton::mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum ) {
|
||||
if(buttonNum == MouseAction::ACTION_LEFT) {
|
||||
if(clicked(minecraft, x, y)) {
|
||||
toggle(&minecraft->options);
|
||||
toggle(&minecraft.options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ public:
|
||||
ImageButton(int id, const std::string& msg, const ImageDef& imageDef);
|
||||
void setImageDef(const ImageDef& imageDef, bool setButtonSize);
|
||||
|
||||
void render(Minecraft* minecraft, int xm, int ym);
|
||||
void renderBg(Minecraft* minecraft, int xm, int ym) {}
|
||||
void render(MinecraftClient& minecraft, int xm, int ym);
|
||||
void renderBg(MinecraftClient& minecraft, int xm, int ym) {}
|
||||
|
||||
protected:
|
||||
virtual void setupDefault();
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
protected:
|
||||
bool isSecondImage(bool hovered) { return _secondImage; }
|
||||
|
||||
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
|
||||
virtual void mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum );
|
||||
|
||||
private:
|
||||
OptionId m_optId;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "InventoryPane.hpp"
|
||||
#include "client/gui/Gui.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/player/input/touchscreen/TouchAreaModel.hpp"
|
||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
@@ -12,7 +12,7 @@ namespace Touch {
|
||||
|
||||
static const int By = 6; // Border Frame height
|
||||
|
||||
InventoryPane::InventoryPane( IInventoryPaneCallback* screen, Minecraft* mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize)
|
||||
InventoryPane::InventoryPane( IInventoryPaneCallback* screen, MinecraftClient& mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize)
|
||||
: screen(screen),
|
||||
mc(mc),
|
||||
paneWidth(paneWidth),
|
||||
@@ -62,7 +62,7 @@ void InventoryPane::renderBatch( std::vector<GridItem>& items, float alpha )
|
||||
|
||||
glEnable2(GL_SCISSOR_TEST);
|
||||
GLuint x = (GLuint)(screenScale * bbox.x);
|
||||
GLuint y = mc->height - (GLuint)(screenScale * (bbox.y + bbox.h));
|
||||
GLuint y = mc.getScreenHeight() - (GLuint)(screenScale * (bbox.y + bbox.h));
|
||||
GLuint w = (GLuint)(screenScale * bbox.w);
|
||||
GLuint h = (GLuint)(screenScale * bbox.h);
|
||||
glScissor(x, y, w, h);
|
||||
@@ -75,7 +75,7 @@ void InventoryPane::renderBatch( std::vector<GridItem>& items, float alpha )
|
||||
GridItem& item = items[i];
|
||||
blit(item.xf, item.yf, 200, 46, (float)itemBbox.w, (float)itemBbox.h, 16, 16);
|
||||
}
|
||||
mc->textures->loadAndBindTexture("gui/gui.png");
|
||||
mc.textures().loadAndBindTexture("gui/gui.png");
|
||||
t.endOverrideAndDraw();
|
||||
|
||||
GridItem* marked = NULL;
|
||||
@@ -104,7 +104,7 @@ void InventoryPane::renderBatch( std::vector<GridItem>& items, float alpha )
|
||||
t.noColor();
|
||||
float xx = Gui::floorAlignToScreenPixel(item.xf + BorderPixels + 4);
|
||||
float yy = Gui::floorAlignToScreenPixel(item.yf + BorderPixels + 4);
|
||||
ItemRenderer::renderGuiItem(NULL, mc->textures, citem, xx, yy, 16, 16, false);
|
||||
ItemRenderer::renderGuiItem(NULL, mc.textures(), citem, xx, yy, 16, 16, false);
|
||||
|
||||
if (j == markerIndex && markerShare >= 0)
|
||||
marked = &item, mxx = xx, myy = yy;
|
||||
@@ -123,7 +123,7 @@ void InventoryPane::renderBatch( std::vector<GridItem>& items, float alpha )
|
||||
}
|
||||
|
||||
|
||||
if (!mc->isCreativeMode()) {
|
||||
if (!mc.isCreativeMode()) {
|
||||
const float ikText = Gui::InvGuiScale + Gui::InvGuiScale;
|
||||
const float kText = 0.5f * Gui::GuiScale;
|
||||
t.beginOverride();
|
||||
@@ -138,7 +138,7 @@ void InventoryPane::renderBatch( std::vector<GridItem>& items, float alpha )
|
||||
|
||||
float tx = Gui::floorAlignToScreenPixel(kText * (item.xf + BorderPixels + 3));
|
||||
float ty = Gui::floorAlignToScreenPixel(kText * (item.yf + BorderPixels + 3));
|
||||
mc->gui.renderSlotText(citem, tx, ty, true, true);
|
||||
mc.gui().renderSlotText(citem, tx, ty, true, true);
|
||||
}
|
||||
t.resetScale();
|
||||
glEnable2(GL_BLEND);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "ScrollingPane.hpp"
|
||||
#include "ImageButton.hpp"
|
||||
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
class ItemInstance;
|
||||
class Font;
|
||||
class IArea;
|
||||
@@ -16,7 +16,7 @@ class InventoryPane: public ScrollingPane
|
||||
{
|
||||
typedef ScrollingPane super;
|
||||
public:
|
||||
InventoryPane(IInventoryPaneCallback* screen, Minecraft* mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize);
|
||||
InventoryPane(IInventoryPaneCallback* screen, MinecraftClient& mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize);
|
||||
~InventoryPane();
|
||||
|
||||
void tick();
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
int paneWidth;
|
||||
IArea* _clickArea;
|
||||
IInventoryPaneCallback* screen;
|
||||
Minecraft* mc;
|
||||
MinecraftClient& mc;
|
||||
|
||||
int fillMarginX;
|
||||
int fillMarginY;
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#include "KeyOption.hpp"
|
||||
#include <client/Minecraft.hpp>
|
||||
#include <MinecraftClient.hpp>
|
||||
|
||||
KeyOption::KeyOption(Minecraft* minecraft, OptionId optId)
|
||||
: Touch::TButton((int)optId, Keyboard::getKeyName(minecraft->options.getIntValue(optId))) {}
|
||||
KeyOption::KeyOption(MinecraftClient& minecraft, OptionId optId)
|
||||
: Touch::TButton((int)optId, Keyboard::getKeyName(minecraft.options().getIntValue(optId))) {}
|
||||
|
||||
|
||||
void KeyOption::mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {
|
||||
void KeyOption::mouseClicked(MinecraftClient& minecraft, int x, int y, int buttonNum) {
|
||||
selected = isInside(x, y);
|
||||
msg = (selected)? "..." : Keyboard::getKeyName(minecraft->options.getIntValue((OptionId)id));
|
||||
msg = (selected)? "..." : Keyboard::getKeyName(minecraft.options().getIntValue((OptionId)id));
|
||||
}
|
||||
|
||||
void KeyOption::keyPressed(Minecraft* minecraft, int key) {
|
||||
void KeyOption::keyPressed(MinecraftClient& minecraft, int key) {
|
||||
if (!selected) return;
|
||||
|
||||
if (key != Keyboard::KEY_ESCAPE) {
|
||||
minecraft->options.set((OptionId)id, key);
|
||||
minecraft.options().set((OptionId)id, key);
|
||||
}
|
||||
|
||||
selected = false;
|
||||
msg = Keyboard::getKeyName(minecraft->options.getIntValue((OptionId)id));
|
||||
msg = Keyboard::getKeyName(minecraft.options().getIntValue((OptionId)id));
|
||||
}
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
class KeyOption : public Touch::TButton {
|
||||
public:
|
||||
KeyOption(Minecraft* minecraft, OptionId optId);
|
||||
KeyOption(MinecraftClient& minecraft, OptionId optId);
|
||||
|
||||
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum);
|
||||
virtual void mouseClicked(MinecraftClient& minecraft, int x, int y, int buttonNum);
|
||||
virtual void released(int mx, int my) {}
|
||||
virtual void keyPressed(Minecraft* minecraft, int key);
|
||||
virtual void keyPressed(MinecraftClient& minecraft, int key);
|
||||
protected:
|
||||
bool m_captureMode;
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "LargeImageButton.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "util/Mth.hpp"
|
||||
#include "platform/log.hpp"
|
||||
#include "util/Mth.hpp"
|
||||
@@ -26,14 +26,14 @@ void LargeImageButton::setupDefault() {
|
||||
height = 72;
|
||||
}
|
||||
|
||||
void LargeImageButton::render(Minecraft* minecraft, int xm, int ym) {
|
||||
void LargeImageButton::render(MinecraftClient& minecraft, int xm, int ym) {
|
||||
if (!visible) return;
|
||||
|
||||
Font* font = minecraft->font;
|
||||
Font* font = minecraft.font();
|
||||
|
||||
//minecraft->textures->loadAndBindTexture("gui/gui.png");
|
||||
//minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
bool hovered = active && (minecraft->useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||
bool hovered = active && (minecraft.useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||
|
||||
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
|
||||
//int yImage = getYImage(hovered || selected);
|
||||
@@ -43,7 +43,7 @@ void LargeImageButton::render(Minecraft* minecraft, int xm, int ym) {
|
||||
|
||||
renderBg(minecraft, xm, ym);
|
||||
|
||||
TextureId texId = (_imageDef.name.length() > 0)? minecraft->textures->loadAndBindTexture(_imageDef.name) : Textures::InvalidId;
|
||||
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;
|
||||
@@ -69,7 +69,7 @@ void LargeImageButton::render(Minecraft* minecraft, int xm, int ym) {
|
||||
|
||||
const IntRectangle* src = _imageDef.getSrc();
|
||||
if (src) {
|
||||
const TextureData* d = minecraft->textures->getTemporaryTextureData(texId);
|
||||
const TextureData* d = minecraft.textures().getTemporaryTextureData(texId);
|
||||
if (d != NULL) {
|
||||
float u0 = (src->x+(hovered?src->w:0)) / (float)d->w;
|
||||
float u1 = (src->x+(hovered?2*src->w:src->w)) / (float)d->w;
|
||||
|
||||
@@ -9,7 +9,7 @@ public:
|
||||
LargeImageButton(int id, const std::string& msg);
|
||||
LargeImageButton(int id, const std::string& msg, ImageDef& imageDef);
|
||||
|
||||
void render(Minecraft* minecraft, int xm, int ym);
|
||||
void render(MinecraftClient& minecraft, int xm, int ym);
|
||||
|
||||
private:
|
||||
void setupDefault();
|
||||
|
||||
@@ -36,7 +36,7 @@ NinePatchDescription NinePatchDescription::createSymmetrical( int texWidth, int
|
||||
return patch;
|
||||
}
|
||||
|
||||
NinePatchLayer::NinePatchLayer(const NinePatchDescription& desc, const std::string& imageName, Textures* textures, float w, float h)
|
||||
NinePatchLayer::NinePatchLayer(const NinePatchDescription& desc, const std::string& imageName, Textures& textures, float w, float h)
|
||||
: desc(desc),
|
||||
imageName(imageName),
|
||||
textures(textures),
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "client/renderer/TextureData.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
|
||||
class Tesselator;
|
||||
|
||||
@@ -30,7 +29,7 @@ class NinePatchLayer: public GuiElement
|
||||
{
|
||||
struct CachedQuad;
|
||||
public:
|
||||
NinePatchLayer(const NinePatchDescription& desc, const std::string& imageName, Textures* textures, float w = 32, float h = 32);
|
||||
NinePatchLayer(const NinePatchDescription& desc, const std::string& imageName, Textures& textures, float w = 32, float h = 32);
|
||||
virtual ~NinePatchLayer() {};
|
||||
void setSize(float w, float h);
|
||||
|
||||
@@ -63,12 +62,12 @@ private:
|
||||
|
||||
class NinePatchFactory {
|
||||
public:
|
||||
NinePatchFactory(Textures* textures, const std::string& imageName );
|
||||
NinePatchFactory(Textures& textures, const std::string& imageName );
|
||||
|
||||
NinePatchLayer* createSymmetrical(const IntRectangle& src, int xCutAt, int yCutAt, float w = 32.0f, float h = 32.0f);
|
||||
|
||||
private:
|
||||
Textures* textures;
|
||||
Textures& textures;
|
||||
std::string imageName;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "OptionsGroup.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "ImageButton.hpp"
|
||||
#include "OptionsItem.hpp"
|
||||
#include "Slider.hpp"
|
||||
@@ -14,7 +14,7 @@ OptionsGroup::OptionsGroup( std::string labelID ) {
|
||||
void OptionsGroup::setupPositions() {
|
||||
// First we write the header and then we add the items
|
||||
int curY = y + 18;
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->width = width - 5;
|
||||
|
||||
(*it)->y = curY;
|
||||
@@ -25,17 +25,17 @@ void OptionsGroup::setupPositions() {
|
||||
height = curY;
|
||||
}
|
||||
|
||||
void OptionsGroup::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
void OptionsGroup::render( MinecraftClient& minecraft, int xm, int ym ) {
|
||||
float padX = 10.0f;
|
||||
float padY = 5.0f;
|
||||
|
||||
minecraft->font->draw(label, (float)x + padX, (float)y + padY, 0xffffffff, false);
|
||||
minecraft.font()->draw(label, (float)x + padX, (float)y + padY, 0xffffffff, false);
|
||||
|
||||
super::render(minecraft, xm, ym);
|
||||
}
|
||||
|
||||
OptionsGroup& OptionsGroup::addOptionItem(OptionId optId, Minecraft* minecraft ) {
|
||||
auto option = minecraft->options.getOpt(optId);
|
||||
OptionsGroup& OptionsGroup::addOptionItem(OptionId optId, MinecraftClient& minecraft ) {
|
||||
auto option = minecraft.options().getOpt(optId);
|
||||
|
||||
if (option == nullptr) return *this;
|
||||
|
||||
@@ -51,7 +51,7 @@ OptionsGroup& OptionsGroup::addOptionItem(OptionId optId, Minecraft* minecraft )
|
||||
|
||||
// TODO: wrap this copypaste shit into templates
|
||||
|
||||
void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
||||
void OptionsGroup::createToggle(OptionId optId, MinecraftClient& minecraft ) {
|
||||
ImageDef def;
|
||||
|
||||
def.setSrc(IntRectangle(160, 206, 39, 20));
|
||||
@@ -61,9 +61,9 @@ void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
||||
|
||||
OptionButton* element = new OptionButton(optId);
|
||||
element->setImageDef(def, true);
|
||||
element->updateImage(&minecraft->options);
|
||||
element->updateImage(&minecraft.options);
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
std::string itemLabel = I18n::get(minecraft.options().getOpt(optId)->getStringId());
|
||||
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
|
||||
@@ -71,44 +71,44 @@ void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createProgressSlider(OptionId optId, Minecraft* minecraft ) {
|
||||
void OptionsGroup::createProgressSlider(OptionId optId, MinecraftClient& minecraft ) {
|
||||
Slider* element = new SliderFloat(minecraft, optId);
|
||||
element->width = 100;
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
std::string itemLabel = I18n::get(minecraft.options().getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createStepSlider(OptionId optId, Minecraft* minecraft ) {
|
||||
void OptionsGroup::createStepSlider(OptionId optId, MinecraftClient& minecraft ) {
|
||||
Slider* element = new SliderInt(minecraft, optId);
|
||||
element->width = 100;
|
||||
element->height = 20;
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
std::string itemLabel = I18n::get(minecraft.options().getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createTextbox(OptionId optId, Minecraft* minecraft) {
|
||||
void OptionsGroup::createTextbox(OptionId optId, MinecraftClient& minecraft) {
|
||||
TextBox* element = new TextOption(minecraft, optId);
|
||||
element->width = 100;
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
std::string itemLabel = I18n::get(minecraft.options().getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createKey(OptionId optId, Minecraft* minecraft) {
|
||||
void OptionsGroup::createKey(OptionId optId, MinecraftClient& minecraft) {
|
||||
KeyOption* element = new KeyOption(minecraft, optId);
|
||||
element->width = 50;
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
std::string itemLabel = I18n::get(minecraft.options().getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
|
||||
@@ -8,22 +8,22 @@
|
||||
#include "client/Options.hpp"
|
||||
|
||||
class Font;
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
|
||||
class OptionsGroup: public GuiElementContainer {
|
||||
typedef GuiElementContainer super;
|
||||
public:
|
||||
OptionsGroup(std::string labelID);
|
||||
virtual void setupPositions();
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||
OptionsGroup& addOptionItem(OptionId optId, Minecraft* minecraft);
|
||||
virtual void render(MinecraftClient& minecraft, int xm, int ym);
|
||||
OptionsGroup& addOptionItem(OptionId optId, MinecraftClient& minecraft);
|
||||
protected:
|
||||
|
||||
void createToggle(OptionId optId, Minecraft* minecraft);
|
||||
void createProgressSlider(OptionId optId, Minecraft* minecraft);
|
||||
void createStepSlider(OptionId optId, Minecraft* minecraft);
|
||||
void createTextbox(OptionId optId, Minecraft* minecraft);
|
||||
void createKey(OptionId optId, Minecraft* minecraft);
|
||||
void createToggle(OptionId optId, MinecraftClient& minecraft);
|
||||
void createProgressSlider(OptionId optId, MinecraftClient& minecraft);
|
||||
void createStepSlider(OptionId optId, MinecraftClient& minecraft);
|
||||
void createTextbox(OptionId optId, MinecraftClient& minecraft);
|
||||
void createKey(OptionId optId, MinecraftClient& minecraft);
|
||||
|
||||
std::string label;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "OptionsItem.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "locale/I18n.hpp"
|
||||
#include "util/Mth.hpp"
|
||||
OptionsItem::OptionsItem( OptionId optionId, std::string label, GuiElement* element )
|
||||
@@ -11,7 +11,7 @@ OptionsItem::OptionsItem( OptionId optionId, std::string label, GuiElement* elem
|
||||
|
||||
void OptionsItem::setupPositions() {
|
||||
int currentHeight = 0;
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->x = x + width - (*it)->width - 15;
|
||||
(*it)->y = y + currentHeight;
|
||||
currentHeight += (*it)->height;
|
||||
@@ -19,11 +19,11 @@ void OptionsItem::setupPositions() {
|
||||
height = currentHeight;
|
||||
}
|
||||
|
||||
void OptionsItem::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
void OptionsItem::render( MinecraftClient& minecraft, int xm, int ym ) {
|
||||
int yOffset = (height - 8) / 2;
|
||||
std::string text = m_label;
|
||||
if (m_optionId == OPTIONS_GUI_SCALE) {
|
||||
int value = minecraft->options.getIntValue(OPTIONS_GUI_SCALE);
|
||||
int value = minecraft.options().getIntValue(OPTIONS_GUI_SCALE);
|
||||
std::string scaleText;
|
||||
switch (value) {
|
||||
case 0: scaleText = I18n::get("options.guiScale.auto"); break;
|
||||
@@ -37,6 +37,6 @@ void OptionsItem::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
text += ": " + scaleText;
|
||||
}
|
||||
|
||||
minecraft->font->draw(text, (float)x, (float)y + yOffset, 0x909090, false);
|
||||
minecraft.font()->draw(text, (float)x, (float)y + yOffset, 0x909090, false);
|
||||
super::render(minecraft, xm, ym);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class OptionsItem: public GuiElementContainer
|
||||
typedef GuiElementContainer super;
|
||||
public:
|
||||
OptionsItem(OptionId optionId, std::string label, GuiElement* element);
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||
virtual void render(MinecraftClient& minecraft, int xm, int ym);
|
||||
void setupPositions();
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "RolledSelectionListV.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/gles.hpp"
|
||||
#include "platform/input/Mouse.hpp"
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "client/renderer/Textures.hpp"
|
||||
|
||||
|
||||
RolledSelectionListV::RolledSelectionListV( Minecraft* minecraft_, int width_, int height_, int x0_, int x1_, int y0_, int y1_, int itemHeight_ )
|
||||
RolledSelectionListV::RolledSelectionListV( MinecraftClient& minecraft_, int width_, int height_, int x0_, int x1_, int y0_, int y1_, int itemHeight_ )
|
||||
: minecraft(minecraft_),
|
||||
width(width_),
|
||||
height(height_),
|
||||
@@ -297,7 +297,7 @@ void RolledSelectionListV::render( int xm, int ym, float a )
|
||||
void RolledSelectionListV::renderHoleBackground( /*float x0, float x1,*/ float y0, float y1, int a0, int a1 )
|
||||
{
|
||||
Tesselator& t = Tesselator::instance;
|
||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||
glColor4f2(1.0f, 1, 1, 1);
|
||||
float s = 32;
|
||||
t.begin();
|
||||
@@ -336,7 +336,7 @@ void RolledSelectionListV::renderDirtBackground()
|
||||
float by0 = _renderTopBorder? y0 : 0;
|
||||
float by1 = _renderBottomBorder? y1 : height;
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||
glColor4f2(1.0f, 1, 1, 1);
|
||||
float s = 32;
|
||||
const float uvy = (float)((int) yo);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "client/gui/GuiComponent.hpp"
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
class Tesselator;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class RolledSelectionListV : public GuiComponent
|
||||
static const int DRAG_OUTSIDE = -2;
|
||||
static const int DRAG_NORMAL = 0;
|
||||
public:
|
||||
RolledSelectionListV(Minecraft* minecraft, int width, int height, int x0, int x1, int y0, int y1, int itemHeight);
|
||||
RolledSelectionListV(MinecraftClient& minecraft, int width, int height, int x0, int x1, int y0, int y1, int itemHeight);
|
||||
|
||||
virtual int getItemAtPosition(int x, int y);
|
||||
|
||||
@@ -51,7 +51,7 @@ protected:
|
||||
virtual void onPostRender();
|
||||
void renderDirtBackground();
|
||||
protected:
|
||||
Minecraft* minecraft;
|
||||
MinecraftClient& minecraft;
|
||||
|
||||
float x0;
|
||||
float x1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "ScrolledSelectionList.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/gles.hpp"
|
||||
#include "platform/input/Mouse.hpp"
|
||||
@@ -9,7 +9,7 @@ static int Abs(int d) {
|
||||
return d >= 0? d : -d;
|
||||
}
|
||||
|
||||
ScrolledSelectionList::ScrolledSelectionList( Minecraft* _minecraft, int _width, int _height, int _y0, int _y1, int _itemHeight )
|
||||
ScrolledSelectionList::ScrolledSelectionList( MinecraftClient& _minecraft, int _width, int _height, int _y0, int _y1, int _itemHeight )
|
||||
: minecraft(_minecraft),
|
||||
width(_width),
|
||||
height(_height),
|
||||
@@ -267,7 +267,7 @@ void ScrolledSelectionList::render( int xm, int ym, float a )
|
||||
void ScrolledSelectionList::renderHoleBackground( float y0, float y1, int a0, int a1 )
|
||||
{
|
||||
Tesselator& t = Tesselator::instance;
|
||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||
glColor4f2(1.0f, 1, 1, 1);
|
||||
float s = 32;
|
||||
t.begin();
|
||||
@@ -283,7 +283,7 @@ void ScrolledSelectionList::renderHoleBackground( float y0, float y1, int a0, in
|
||||
void ScrolledSelectionList::renderDirtBackground()
|
||||
{
|
||||
Tesselator& t = Tesselator::instance;
|
||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||
glColor4f2(1.0f, 1, 1, 1);
|
||||
float s = 32;
|
||||
t.begin();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "client/gui/GuiComponent.hpp"
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
class Tesselator;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class ScrolledSelectionList : public GuiComponent
|
||||
static const int DRAG_NORMAL = 0;
|
||||
static const int DRAG_SKIP = 1; // special case to fix android jump bug
|
||||
public:
|
||||
ScrolledSelectionList(Minecraft* _minecraft, int _width, int _height, int _y0, int _y1, int _itemHeight);
|
||||
ScrolledSelectionList(MinecraftClient& _minecraft, int _width, int _height, int _y0, int _y1, int _itemHeight);
|
||||
|
||||
virtual void setRenderSelection(bool _renderSelection);
|
||||
protected:
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
virtual void renderHoleBackground(float y0, float y1, int a0, int a1);
|
||||
void renderDirtBackground();
|
||||
protected:
|
||||
Minecraft* minecraft;
|
||||
MinecraftClient& minecraft;
|
||||
|
||||
float y0;
|
||||
float y1;
|
||||
|
||||
@@ -111,7 +111,7 @@ ScrollingPane::~ScrollingPane() {
|
||||
delete[] selected;
|
||||
}
|
||||
|
||||
//void ScrollingPane::init(Minecraft* mc, int width, int height) {
|
||||
//void ScrollingPane::init(MinecraftClient& mc, int width, int height) {
|
||||
// this->mc = mc;
|
||||
// this->width = width;
|
||||
// this->height = height;
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
ScrollingPane(int flags, const IntRectangle& boundingBox, const IntRectangle& itemRect, int columns, int numItems, float screenScale = 1.0f, const IntRectangle& itemBoundingRect = IntRectangle(0,0,0,0));
|
||||
~ScrollingPane();
|
||||
//void init(Minecraft*, int width, int height);
|
||||
//void init(MinecraftClient&, int width, int height);
|
||||
void tick();
|
||||
void render(int xm, int ym, float alpha);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Slider.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "locale/I18n.hpp"
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
Slider::Slider(OptionId optId) : m_mouseDownOnElement(false), m_optId(optId), m_numSteps(0) {}
|
||||
|
||||
void Slider::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
void Slider::render( MinecraftClient& minecraft, int xm, int ym ) {
|
||||
int xSliderStart = x + 5;
|
||||
int xSliderEnd = x + width - 5;
|
||||
int ySliderStart = y + 6;
|
||||
@@ -28,26 +28,26 @@ void Slider::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
}
|
||||
}
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/touchgui.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/touchgui.png");
|
||||
blit(xSliderStart + (int)(m_percentage * barWidth) - handleSizeX / 2, y, 226, 126, handleSizeX, handleSizeY, handleSizeX, handleSizeY);
|
||||
}
|
||||
|
||||
void Slider::mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
||||
void Slider::mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum ) {
|
||||
if(pointInside(x, y)) {
|
||||
m_mouseDownOnElement = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Slider::mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
||||
void Slider::mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum ) {
|
||||
m_mouseDownOnElement = false;
|
||||
}
|
||||
|
||||
void Slider::tick(Minecraft* minecraft) {
|
||||
if(minecraft->screen != NULL) {
|
||||
void Slider::tick(MinecraftClient& minecraft) {
|
||||
if(minecraft.getScreen()!= NULL) {
|
||||
int xm = Mouse::getX();
|
||||
int ym = Mouse::getY();
|
||||
|
||||
minecraft->screen->toGUICoordinate(xm, ym);
|
||||
minecraft.getScreen()->toGUICoordinate(xm, ym);
|
||||
|
||||
if(m_mouseDownOnElement) {
|
||||
m_percentage = float(xm - x) / float(width);
|
||||
@@ -56,24 +56,24 @@ void Slider::tick(Minecraft* minecraft) {
|
||||
}
|
||||
}
|
||||
|
||||
SliderFloat::SliderFloat(Minecraft* minecraft, OptionId option)
|
||||
: Slider(option), m_option(dynamic_cast<OptionFloat*>(minecraft->options.getOpt(option)))
|
||||
SliderFloat::SliderFloat(MinecraftClient& minecraft, OptionId option)
|
||||
: Slider(option), m_option(dynamic_cast<OptionFloat*>(minecraft.options().getOpt(option)))
|
||||
{
|
||||
m_percentage = Mth::clamp((m_option->get() - m_option->getMin()) / (m_option->getMax() - m_option->getMin()), 0.f, 1.f);
|
||||
}
|
||||
|
||||
SliderInt::SliderInt(Minecraft* minecraft, OptionId option)
|
||||
: Slider(option), m_option(dynamic_cast<OptionInt*>(minecraft->options.getOpt(option)))
|
||||
SliderInt::SliderInt(MinecraftClient& minecraft, OptionId option)
|
||||
: Slider(option), m_option(dynamic_cast<OptionInt*>(minecraft.options().getOpt(option)))
|
||||
{
|
||||
m_numSteps = m_option->getMax() - m_option->getMin() + 1;
|
||||
m_percentage = float(m_option->get() - m_option->getMin()) / (m_numSteps-1);
|
||||
}
|
||||
|
||||
void SliderInt::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
void SliderInt::render( MinecraftClient& minecraft, int xm, int ym ) {
|
||||
Slider::render(minecraft, xm, ym);
|
||||
}
|
||||
|
||||
void SliderInt::mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
||||
void SliderInt::mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum ) {
|
||||
Slider::mouseReleased(minecraft, x, y, buttonNum);
|
||||
|
||||
if (pointInside(x, y)) {
|
||||
@@ -81,14 +81,14 @@ void SliderInt::mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum
|
||||
curStep = Mth::clamp(curStep + m_option->getMin(), m_option->getMin(), m_option->getMax());
|
||||
m_percentage = float(curStep - m_option->getMin()) / (m_numSteps-1);
|
||||
|
||||
minecraft->options.set(m_optId, curStep);
|
||||
minecraft.options().set(m_optId, curStep);
|
||||
}
|
||||
}
|
||||
|
||||
void SliderFloat::mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
||||
void SliderFloat::mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum ) {
|
||||
Slider::mouseReleased(minecraft, x, y, buttonNum);
|
||||
|
||||
if (pointInside(x, y)) {
|
||||
minecraft->options.set(m_optId, m_percentage * (m_option->getMax() - m_option->getMin()) + m_option->getMin());
|
||||
minecraft.options().set(m_optId, m_percentage * (m_option->getMax() - m_option->getMin()) + m_option->getMin());
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@
|
||||
class Slider : public GuiElement {
|
||||
typedef GuiElement super;
|
||||
public:
|
||||
virtual void render( Minecraft* minecraft, int xm, int ym );
|
||||
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
|
||||
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
|
||||
virtual void tick(Minecraft* minecraft);
|
||||
virtual void render( MinecraftClient& minecraft, int xm, int ym );
|
||||
virtual void mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum );
|
||||
virtual void mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum );
|
||||
virtual void tick(MinecraftClient& minecraft);
|
||||
|
||||
protected:
|
||||
Slider(OptionId optId);
|
||||
@@ -24,9 +24,9 @@ protected:
|
||||
|
||||
class SliderFloat : public Slider {
|
||||
public:
|
||||
SliderFloat(Minecraft* minecraft, OptionId option);
|
||||
SliderFloat(MinecraftClient& minecraft, OptionId option);
|
||||
|
||||
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
|
||||
virtual void mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum ) override;
|
||||
|
||||
protected:
|
||||
OptionFloat* m_option;
|
||||
@@ -35,10 +35,10 @@ protected:
|
||||
|
||||
class SliderInt : public Slider {
|
||||
public:
|
||||
SliderInt(Minecraft* minecraft, OptionId option);
|
||||
SliderInt(MinecraftClient& minecraft, OptionId option);
|
||||
|
||||
virtual void render( Minecraft* minecraft, int xm, int ym ) override;
|
||||
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
|
||||
virtual void render( MinecraftClient& minecraft, int xm, int ym ) override;
|
||||
virtual void mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum ) override;
|
||||
|
||||
protected:
|
||||
OptionInt* m_option;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "TextBox.hpp"
|
||||
#include "client/gui/Gui.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "AppPlatform.hpp"
|
||||
#include "platform/input/Mouse.hpp"
|
||||
|
||||
@@ -21,25 +21,25 @@ TextBox::TextBox(int id, int x, int y, int w, int h, const std::string& msg)
|
||||
{
|
||||
}
|
||||
|
||||
void TextBox::setFocus(Minecraft* minecraft) {
|
||||
void TextBox::setFocus(MinecraftClient& minecraft) {
|
||||
if (!focused) {
|
||||
minecraft->platform()->showKeyboard();
|
||||
minecraft.platform()->showKeyboard();
|
||||
focused = true;
|
||||
blinkTicks = 0;
|
||||
blink = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool TextBox::loseFocus(Minecraft* minecraft) {
|
||||
bool TextBox::loseFocus(MinecraftClient& minecraft) {
|
||||
if (focused) {
|
||||
minecraft->platform()->hideKeyboard();
|
||||
minecraft.platform()->hideKeyboard();
|
||||
focused = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TextBox::mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {
|
||||
void TextBox::mouseClicked(MinecraftClient& minecraft, int x, int y, int buttonNum) {
|
||||
if (buttonNum == MouseAction::ACTION_LEFT) {
|
||||
if (pointInside(x, y)) {
|
||||
setFocus(minecraft);
|
||||
@@ -49,19 +49,19 @@ void TextBox::mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {
|
||||
}
|
||||
}
|
||||
|
||||
void TextBox::charPressed(Minecraft* minecraft, char c) {
|
||||
void TextBox::charPressed(MinecraftClient& minecraft, char c) {
|
||||
if (focused && c >= 32 && c < 127 && (int)text.size() < 256) {
|
||||
text.push_back(c);
|
||||
}
|
||||
}
|
||||
|
||||
void TextBox::keyPressed(Minecraft* minecraft, int key) {
|
||||
void TextBox::keyPressed(MinecraftClient& minecraft, int key) {
|
||||
if (focused && key == Keyboard::KEY_BACKSPACE && !text.empty()) {
|
||||
text.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
void TextBox::tick(Minecraft* minecraft) {
|
||||
void TextBox::tick(MinecraftClient& minecraft) {
|
||||
blinkTicks++;
|
||||
if (blinkTicks >= 5) {
|
||||
blink = !blink;
|
||||
@@ -69,7 +69,7 @@ void TextBox::tick(Minecraft* minecraft) {
|
||||
}
|
||||
}
|
||||
|
||||
void TextBox::render(Minecraft* minecraft, int xm, int ym) {
|
||||
void TextBox::render(MinecraftClient& minecraft, int xm, int ym) {
|
||||
// textbox like in beta 1.7.3
|
||||
// change appearance when focused so the user can tell it's active
|
||||
// active background darker gray with a subtle border
|
||||
@@ -81,7 +81,7 @@ void TextBox::render(Minecraft* minecraft, int xm, int ym) {
|
||||
glEnable2(GL_SCISSOR_TEST);
|
||||
glScissor(
|
||||
Gui::GuiScale * (x + 2),
|
||||
minecraft->height - Gui::GuiScale * (y + height - 2),
|
||||
minecraft.getScreenHeight() - Gui::GuiScale * (y + height - 2),
|
||||
Gui::GuiScale * (width - 2),
|
||||
Gui::GuiScale * (height - 2)
|
||||
);
|
||||
@@ -89,12 +89,12 @@ void TextBox::render(Minecraft* minecraft, int xm, int ym) {
|
||||
int _y = y + (height - Font::DefaultLineHeight) / 2;
|
||||
|
||||
if (text.empty() && !focused) {
|
||||
drawString(minecraft->font, hint, x + 2, _y, 0xff5e5e5e);
|
||||
drawString(minecraft.font(), hint, x + 2, _y, 0xff5e5e5e);
|
||||
}
|
||||
|
||||
if (focused && blink) text.push_back('_');
|
||||
|
||||
drawString(minecraft->font, text, x + 2, _y, 0xffffffff);
|
||||
drawString(minecraft.font(), text, x + 2, _y, 0xffffffff);
|
||||
|
||||
if (focused && blink) text.pop_back();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "platform/input/Keyboard.hpp"
|
||||
|
||||
class Font;
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
|
||||
class TextBox: public GuiElement
|
||||
{
|
||||
@@ -18,16 +18,16 @@ public:
|
||||
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);
|
||||
|
||||
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum);
|
||||
virtual void mouseClicked(MinecraftClient& minecraft, int x, int y, int buttonNum);
|
||||
|
||||
virtual void setFocus(Minecraft* minecraft);
|
||||
virtual bool loseFocus(Minecraft* minecraft);
|
||||
virtual void setFocus(MinecraftClient& minecraft);
|
||||
virtual bool loseFocus(MinecraftClient& minecraft);
|
||||
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||
virtual void render(MinecraftClient& minecraft, int xm, int ym);
|
||||
|
||||
virtual void keyPressed(Minecraft* minecraft, int key);
|
||||
virtual void charPressed(Minecraft* minecraft, char c);
|
||||
virtual void tick(Minecraft* minecraft);
|
||||
virtual void keyPressed(MinecraftClient& minecraft, int key);
|
||||
virtual void charPressed(MinecraftClient& minecraft, char c);
|
||||
virtual void tick(MinecraftClient& minecraft);
|
||||
|
||||
public:
|
||||
std::string hint;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#include "TextOption.hpp"
|
||||
#include <client/Minecraft.hpp>
|
||||
|
||||
TextOption::TextOption(Minecraft* minecraft, OptionId optId)
|
||||
: TextBox((int)optId, minecraft->options.getOpt(optId)->getStringId())
|
||||
TextOption::TextOption(MinecraftClient& minecraft, OptionId optId)
|
||||
: TextBox((int)optId, minecraft.options().getOpt(optId)->getStringId())
|
||||
{
|
||||
text = minecraft->options.getStringValue(optId);
|
||||
text = minecraft.options().getStringValue(optId);
|
||||
}
|
||||
|
||||
bool TextOption::loseFocus(Minecraft* minecraft) {
|
||||
bool TextOption::loseFocus(MinecraftClient& minecraft) {
|
||||
if (TextBox::loseFocus(minecraft)) {
|
||||
minecraft->options.set((OptionId)id, text);
|
||||
minecraft.options().set((OptionId)id, text);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
class TextOption : public TextBox {
|
||||
public:
|
||||
TextOption(Minecraft* minecraft, OptionId optId);
|
||||
TextOption(MinecraftClient& minecraft, OptionId optId);
|
||||
|
||||
virtual bool loseFocus(Minecraft* minecraft);
|
||||
virtual bool loseFocus(MinecraftClient& minecraft);
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "ArmorScreen.hpp"
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/gui/components/NinePatch.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||
@@ -73,7 +73,7 @@ ArmorScreen::~ArmorScreen() {
|
||||
void ArmorScreen::init() {
|
||||
super::init();
|
||||
|
||||
player = minecraft->player;
|
||||
player = minecraft.player();
|
||||
|
||||
ImageDef def;
|
||||
def.name = "gui/spritesheet.png";
|
||||
@@ -95,7 +95,7 @@ void ArmorScreen::init() {
|
||||
buttons.push_back(armorButtons[i]);
|
||||
|
||||
// GUI - nine patches
|
||||
NinePatchFactory builder(minecraft->textures, "gui/spritesheet.png");
|
||||
NinePatchFactory builder(minecraft.textures() "gui/spritesheet.png");
|
||||
|
||||
guiBackground = builder.createSymmetrical(IntRectangle(0, 0, 16, 16), 4, 4);
|
||||
guiSlot = builder.createSymmetrical(IntRectangle(0, 32, 8, 8), 3, 3, 20, 20);
|
||||
@@ -200,7 +200,7 @@ void ArmorScreen::render(int xm, int ym, float a) {
|
||||
|
||||
void ArmorScreen::buttonClicked(Button* button) {
|
||||
if (button == &btnClose) {
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.setScreen(NULL);
|
||||
}
|
||||
|
||||
if (button->id >= 0 && button->id <= 3) {
|
||||
@@ -252,8 +252,8 @@ std::vector<const ItemInstance*> ArmorScreen::getItems( const Touch::InventoryPa
|
||||
void ArmorScreen::updateItems() {
|
||||
armorItems.clear();
|
||||
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft->player->inventory->getContainerSize(); ++i) {
|
||||
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft.player()->inventory->getContainerSize(); ++i) {
|
||||
ItemInstance* item = minecraft.player()->inventory->getItem(i);
|
||||
if (ItemInstance::isArmorItem(item))
|
||||
armorItems.push_back(item);
|
||||
}
|
||||
@@ -281,13 +281,13 @@ void ArmorScreen::drawSlotItemAt( Tesselator& t, int slot, const ItemInstance* i
|
||||
guiSlot->draw(t, xx, yy);
|
||||
|
||||
if (item && !item->isNull()) {
|
||||
ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, item, xx + 2, yy, true);
|
||||
ItemRenderer::renderGuiItem(minecraft.font(), minecraft.textures() item, xx + 2, yy, true);
|
||||
glDisable2(GL_TEXTURE_2D);
|
||||
ItemRenderer::renderGuiItemDecorations(item, xx + 2, yy + 3);
|
||||
glEnable2(GL_TEXTURE_2D);
|
||||
//minecraft->gui.renderSlotText(item, xx + 3, yy + 3, true, true);
|
||||
//minecraft.gui().renderSlotText(item, xx + 3, yy + 3, true, true);
|
||||
} else {
|
||||
minecraft->textures->loadAndBindTexture("gui/items.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/items.png");
|
||||
blit(x + 2, y, 15 * 16, slot * 16, 16, 16, 16, 16);
|
||||
}
|
||||
}
|
||||
@@ -297,14 +297,14 @@ void ArmorScreen::takeAndClearSlot( int slot ) {
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
int oldSize = minecraft->player->inventory->getNumEmptySlots();
|
||||
int oldSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||
|
||||
if (!minecraft->player->inventory->add(item))
|
||||
minecraft->player->drop(new ItemInstance(*item), false);
|
||||
if (!minecraft.player()->inventory->add(item))
|
||||
minecraft.player()->drop(new ItemInstance(*item), false);
|
||||
|
||||
player->setArmor(slot, NULL);
|
||||
|
||||
int newSize = minecraft->player->inventory->getNumEmptySlots();
|
||||
int newSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||
setIfNotSet(doRecreatePane, newSize != oldSize);
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ void ArmorScreen::renderPlayer(float xo, float yo) {
|
||||
glRotatef(180, 0, 0, 1);
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
|
||||
Player* player = (Player*) minecraft->player;
|
||||
Player* player = (Player*) minecraft.player();
|
||||
float oybr = player->yBodyRot;
|
||||
float oyr = player->yRot;
|
||||
float oxr = player->xRot;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
|
||||
class BaseContainerMenu;
|
||||
@@ -13,26 +13,23 @@ class BaseContainerScreen: public Screen
|
||||
{
|
||||
typedef Screen super;
|
||||
public:
|
||||
BaseContainerScreen(BaseContainerMenu* menu)
|
||||
: menu(menu)
|
||||
{
|
||||
}
|
||||
BaseContainerScreen(MinecraftClient& mc, BaseContainerMenu* menu) : Screen(mc), menu(menu) {}
|
||||
|
||||
virtual void init() {
|
||||
super::init();
|
||||
minecraft->player->containerMenu = menu;
|
||||
minecraft.player()->containerMenu = menu;
|
||||
}
|
||||
|
||||
virtual void tick() {
|
||||
super::tick();
|
||||
if (!minecraft->player->isAlive() || minecraft->player->removed)
|
||||
minecraft->player->closeContainer();
|
||||
if (!minecraft.player()->isAlive() || minecraft.player()->removed)
|
||||
minecraft.player()->closeContainer();
|
||||
}
|
||||
|
||||
virtual void keyPressed( int eventKey )
|
||||
{
|
||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||
minecraft->player->closeContainer();
|
||||
minecraft.player()->closeContainer();
|
||||
} else {
|
||||
super::keyPressed(eventKey);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,40 @@
|
||||
#include "ChatScreen.hpp"
|
||||
#include "DialogDefinitions.hpp"
|
||||
#include "client/gui/Gui.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include "AppPlatform.hpp"
|
||||
#include "platform/log.hpp"
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
|
||||
|
||||
void ChatScreen::init() {
|
||||
minecraft->platform()->createUserInput(DialogDefinitions::DIALOG_NEW_CHAT_MESSAGE);
|
||||
m_input.x = 2;
|
||||
m_input.width = width - 4;
|
||||
m_input.height = 12;
|
||||
m_input.y = height - m_input.height - 2;
|
||||
|
||||
textBoxes.push_back(&m_input);
|
||||
}
|
||||
|
||||
void ChatScreen::render(int xm, int ym, float a)
|
||||
{
|
||||
int status = minecraft->platform()->getUserInputStatus();
|
||||
if (status > -1) {
|
||||
if (status == 1) {
|
||||
std::vector<std::string> v = minecraft->platform()->getUserInput();
|
||||
if (v.size() && v[0].length() > 0)
|
||||
minecraft->gui.addMessage(v[0]);
|
||||
}
|
||||
void ChatScreen::render(int xm, int ym, float a) {
|
||||
fillGradient(0, 0, width, height, 0x00000000, 0x40000000);
|
||||
m_input.focused = true;
|
||||
|
||||
minecraft->setScreen(NULL);
|
||||
}
|
||||
Screen::render(xm, ym, a);
|
||||
}
|
||||
|
||||
bool ChatScreen::handleBackEvent(bool isDown) {
|
||||
minecraft.setScreen(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChatScreen::keyPressed(int eventKey) {
|
||||
// Was ai code before (we're sorry about it), but now reviewed
|
||||
// and everything is ok
|
||||
|
||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||
return minecraft.setScreen(NULL);
|
||||
}
|
||||
|
||||
if (eventKey == Keyboard::KEY_RETURN) {
|
||||
// execute...
|
||||
}
|
||||
|
||||
return ChatScreen::keyPressed(eventKey);
|
||||
}
|
||||
@@ -1,19 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/gui/components/TextBox.hpp"
|
||||
|
||||
class ChatScreen: public Screen
|
||||
{
|
||||
public:
|
||||
ChatScreen() {}
|
||||
virtual ~ChatScreen() {}
|
||||
ChatScreen();
|
||||
|
||||
void init();
|
||||
|
||||
|
||||
void render(int xm, int ym, float a);
|
||||
|
||||
void buttonClicked(Button* button) {};
|
||||
|
||||
bool handleBackEvent(bool isDown);
|
||||
void keyPressed(int eventKey);
|
||||
private:
|
||||
TextBox m_input;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "touch/TouchStartMenuScreen.hpp"
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/gui/components/NinePatch.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||
@@ -110,7 +110,7 @@ typedef struct FlyingItem {
|
||||
static std::vector<FlyingItem> flyingItems;
|
||||
|
||||
ChestScreen::ChestScreen(Player* player, ChestTileEntity* chest)
|
||||
: super(new ContainerMenu(chest, chest->runningId)), //@huge @attn
|
||||
: super(new ContainerMenu(minecraft, chest, chest->runningId)), //@huge @attn
|
||||
inventoryPane(NULL),
|
||||
chestPane(NULL),
|
||||
btnClose(4, ""),
|
||||
@@ -163,7 +163,7 @@ void ChestScreen::init() {
|
||||
buttons.push_back(&btnClose);
|
||||
|
||||
// GUI - nine patches
|
||||
NinePatchFactory builder(minecraft->textures, "gui/spritesheet.png");
|
||||
NinePatchFactory builder(minecraft.textures() "gui/spritesheet.png");
|
||||
|
||||
guiBackground = builder.createSymmetrical(IntRectangle(0, 0, 16, 16), 4, 4);
|
||||
guiSlot = builder.createSymmetrical(IntRectangle(0, 32, 8, 8), 3, 3);
|
||||
@@ -213,7 +213,7 @@ void ChestScreen::handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, in
|
||||
heldMs = ms;
|
||||
|
||||
FillingContainer* c = (pane == inventoryPane)?
|
||||
upcast<FillingContainer>(minecraft->player->inventory)
|
||||
upcast<FillingContainer>(minecraft.player()->inventory)
|
||||
: upcast<FillingContainer>(chest);
|
||||
|
||||
const int slotIndex = id + c->getNumLinkedSlots();
|
||||
@@ -270,7 +270,7 @@ void ChestScreen::render(int xm, int ym, float a) {
|
||||
|
||||
glEnable2(GL_SCISSOR_TEST);
|
||||
//LOGI("panesBox: %d, %d - %d, %d\n", panesBbox.x, panesBbox.y, panesBbox.w, panesBbox.h);
|
||||
minecraft->gui.setScissorRect(panesBbox);
|
||||
minecraft.gui().setScissorRect(panesBbox);
|
||||
for (unsigned int i = 0; i < flyingItems.size(); ++i) {
|
||||
FlyingItem& fi = flyingItems[i];
|
||||
float since = (now - fi.startTime);
|
||||
@@ -281,8 +281,8 @@ void ChestScreen::render(int xm, int ym, float a) {
|
||||
|
||||
float xx = Mth::lerp(fi.sx, fi.dx, t);
|
||||
float yy = Mth::lerp(fi.sy, fi.dy, t);
|
||||
ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, &fi.item, xx + 7, yy + 8, true);
|
||||
//minecraft->gui.renderSlotText(&fi.item, xx + 3, yy + 3, true, true);
|
||||
ItemRenderer::renderGuiItem(minecraft.font(), minecraft.textures(), &fi.item, xx + 7, yy + 8, true);
|
||||
//minecraft.gui().renderSlotText(&fi.item, xx + 3, yy + 3, true, true);
|
||||
|
||||
flyingToSave.push_back(fi);
|
||||
}
|
||||
@@ -295,12 +295,12 @@ void ChestScreen::render(int xm, int ym, float a) {
|
||||
t.colorABGR(0xffffffff);
|
||||
glDisable2(GL_BLEND);
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/spritesheet.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/spritesheet.png");
|
||||
}
|
||||
|
||||
void ChestScreen::buttonClicked(Button* button) {
|
||||
if (button == &btnClose) {
|
||||
minecraft->player->closeContainer();
|
||||
minecraft.player()->closeContainer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,11 +353,11 @@ bool ChestScreen::handleAddItem(FillingContainer* from, FillingContainer* to, in
|
||||
fi.dy = gTo.yf;
|
||||
flyingItems.push_back(fi);
|
||||
|
||||
if (!fromChest && minecraft->level->isClientSide) {
|
||||
if (!fromChest && minecraft.level->isClientSide) {
|
||||
int j = toIndex;
|
||||
ItemInstance item = items[j]? *items[j] : ItemInstance();
|
||||
ContainerSetSlotPacket p(menu->containerId, j, item);
|
||||
minecraft->raknetInstance->send(p);
|
||||
minecraft.raknetInstance->send(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,7 +366,7 @@ bool ChestScreen::handleAddItem(FillingContainer* from, FillingContainer* to, in
|
||||
if (fromChest) {
|
||||
ItemInstance ins(item->count <= 0? ItemInstance() : *item);
|
||||
ContainerSetSlotPacket p(menu->containerId, slotIndex, ins);
|
||||
minecraft->raknetInstance->send(p);
|
||||
minecraft.raknetInstance->send(p);
|
||||
}
|
||||
if (item->count <= 0)
|
||||
from->clearSlot(slotIndex);
|
||||
@@ -380,8 +380,8 @@ bool ChestScreen::handleAddItem(FillingContainer* from, FillingContainer* to, in
|
||||
bool ChestScreen::addItem(const Touch::InventoryPane* forPane, int itemIndex) {
|
||||
//LOGI("items.size, index: %d, %d\n", inventoryItems.size(), itemIndex);
|
||||
bool l2r = (forPane == inventoryPane);
|
||||
return handleAddItem( l2r? upcast<FillingContainer>(minecraft->player->inventory) : upcast<FillingContainer>(chest),
|
||||
l2r? upcast<FillingContainer>(chest) : upcast<FillingContainer>(minecraft->player->inventory),
|
||||
return handleAddItem( l2r? upcast<FillingContainer>(minecraft.player()->inventory) : upcast<FillingContainer>(chest),
|
||||
l2r? upcast<FillingContainer>(chest) : upcast<FillingContainer>(minecraft.player()->inventory),
|
||||
itemIndex);
|
||||
}
|
||||
|
||||
@@ -398,8 +398,8 @@ bool ChestScreen::renderGameBehind()
|
||||
std::vector<const ItemInstance*> ChestScreen::getItems( const Touch::InventoryPane* forPane )
|
||||
{
|
||||
if (forPane == inventoryPane) {
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE, j = 0; i < minecraft->player->inventory->getContainerSize(); ++i, ++j)
|
||||
inventoryItems[j] = minecraft->player->inventory->getItem(i);
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE, j = 0; i < minecraft.player()->inventory->getContainerSize(); ++i, ++j)
|
||||
inventoryItems[j] = minecraft.player()->inventory->getItem(i);
|
||||
return inventoryItems;
|
||||
}
|
||||
else {
|
||||
@@ -413,8 +413,8 @@ std::vector<const ItemInstance*> ChestScreen::getItems( const Touch::InventoryPa
|
||||
void ChestScreen::setupPane()
|
||||
{
|
||||
inventoryItems.clear();
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft->player->inventory->getContainerSize(); ++i) {
|
||||
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft.player()->inventory->getContainerSize(); ++i) {
|
||||
ItemInstance* item = minecraft.player()->inventory->getItem(i);
|
||||
/*if (!item || item->isNull()) continue;*/
|
||||
inventoryItems.push_back(item);
|
||||
}
|
||||
@@ -439,7 +439,7 @@ void ChestScreen::setupPane()
|
||||
#endif
|
||||
// IntRectangle(0, 0, 100, 100)
|
||||
if (inventoryPane) delete inventoryPane;
|
||||
inventoryPane = new Touch::InventoryPane(this, minecraft, rect, paneWidth, BorderPixels, minecraft->player->inventory->getContainerSize() - Inventory::MAX_SELECTION_SIZE, ItemSize, (int)BorderPixels);
|
||||
inventoryPane = new Touch::InventoryPane(this, minecraft, rect, paneWidth, BorderPixels, minecraft.player()->inventory->getContainerSize() - Inventory::MAX_SELECTION_SIZE, ItemSize, (int)BorderPixels);
|
||||
inventoryPane->fillMarginX = 0;
|
||||
inventoryPane->fillMarginY = 0;
|
||||
guiPaneFrame->setSize((float)rect.w + 2, (float)rect.h + 2);
|
||||
@@ -468,7 +468,7 @@ void ChestScreen::drawSlotItemAt( Tesselator& t, const ItemInstance* item, int x
|
||||
guiSlotMarker->draw(t, xx - 2, yy - 2);
|
||||
|
||||
if (item && !item->isNull()) {
|
||||
ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, item, xx + 7, yy + 8, true);
|
||||
minecraft->gui.renderSlotText(item, xx + 3, yy + 3, true, true);
|
||||
ItemRenderer::renderGuiItem(minecraft.font(), minecraft.textures(), item, xx + 7, yy + 8, true);
|
||||
minecraft.gui().renderSlotText(item, xx + 3, yy + 3, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "ChooseLevelScreen.hpp"
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
|
||||
void ChooseLevelScreen::init() {
|
||||
loadLevelSource();
|
||||
@@ -9,7 +9,7 @@ void ChooseLevelScreen::init() {
|
||||
|
||||
void ChooseLevelScreen::loadLevelSource()
|
||||
{
|
||||
LevelStorageSource* levelSource = minecraft->getLevelSource();
|
||||
LevelStorageSource* levelSource = minecraft.getLevelSource();
|
||||
levelSource->getLevelList(levels);
|
||||
std::sort(levels.begin(), levels.end());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "ConfirmScreen.hpp"
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
|
||||
ConfirmScreen::ConfirmScreen(Screen* parent_, const std::string& title1_, const std::string& title2_, int id_)
|
||||
: parent(parent_),
|
||||
@@ -31,7 +31,7 @@ ConfirmScreen::~ConfirmScreen() {
|
||||
|
||||
void ConfirmScreen::init()
|
||||
{
|
||||
if (/* minecraft->useTouchscreen() */ true) {
|
||||
if (/* minecraft.useTouchscreen() */ true) {
|
||||
yesButton = new Touch::TButton(0, 0, 0, yesButtonText),
|
||||
noButton = new Touch::TButton(1, 0, 0, noButtonText);
|
||||
} else {
|
||||
|
||||
@@ -1,220 +0,0 @@
|
||||
#include "ConsoleScreen.hpp"
|
||||
#include "client/gui/Gui.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "platform/input/Keyboard.hpp"
|
||||
#include "world/level/Level.hpp"
|
||||
#include "network/RakNetInstance.hpp"
|
||||
#include "network/ServerSideNetworkHandler.hpp"
|
||||
#include "network/packet/ChatPacket.hpp"
|
||||
#include "platform/log.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
|
||||
ConsoleScreen::ConsoleScreen()
|
||||
: _input(""),
|
||||
_cursorBlink(0)
|
||||
{
|
||||
}
|
||||
|
||||
void ConsoleScreen::init()
|
||||
{
|
||||
}
|
||||
|
||||
void ConsoleScreen::tick()
|
||||
{
|
||||
_cursorBlink++;
|
||||
}
|
||||
|
||||
bool ConsoleScreen::handleBackEvent(bool /*isDown*/)
|
||||
{
|
||||
minecraft->setScreen(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConsoleScreen::keyPressed(int eventKey)
|
||||
{
|
||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||
minecraft->setScreen(NULL);
|
||||
} else if (eventKey == Keyboard::KEY_RETURN) {
|
||||
execute();
|
||||
} else if (eventKey == Keyboard::KEY_BACKSPACE) {
|
||||
if (!_input.empty())
|
||||
_input.erase(_input.size() - 1, 1);
|
||||
} else {
|
||||
super::keyPressed(eventKey);
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleScreen::charPressed(char inputChar)
|
||||
{
|
||||
if (inputChar >= 32 && inputChar < 127)
|
||||
_input += inputChar;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// execute: run _input as a command, print result, close screen
|
||||
// ---------------------------------------------------------------------------
|
||||
void ConsoleScreen::execute()
|
||||
{
|
||||
if (_input.empty()) {
|
||||
minecraft->setScreen(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_input[0] == '/') {
|
||||
// Command
|
||||
std::string result = processCommand(_input);
|
||||
if (!result.empty())
|
||||
minecraft->gui.addMessage(result);
|
||||
} else {
|
||||
// Chat message: <name> message
|
||||
std::string msg = std::string("<") + minecraft->player->name + "> " + _input;
|
||||
if (minecraft->netCallback && minecraft->raknetInstance->isServer()) {
|
||||
// Hosting a LAN game: displayGameMessage shows locally + broadcasts MessagePacket to clients
|
||||
static_cast<ServerSideNetworkHandler*>(minecraft->netCallback)->displayGameMessage(msg);
|
||||
} else if (minecraft->netCallback) {
|
||||
// Connected client: send ChatPacket to server; server echoes it back as MessagePacket
|
||||
ChatPacket chatPkt(msg);
|
||||
minecraft->raknetInstance->send(chatPkt);
|
||||
} else {
|
||||
// Singleplayer: show locally only
|
||||
minecraft->gui.addMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
minecraft->setScreen(NULL);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// processCommand
|
||||
// ---------------------------------------------------------------------------
|
||||
static std::string trim(const std::string& s) {
|
||||
size_t a = s.find_first_not_of(" \t");
|
||||
if (a == std::string::npos) return "";
|
||||
size_t b = s.find_last_not_of(" \t");
|
||||
return s.substr(a, b - a + 1);
|
||||
}
|
||||
|
||||
std::string ConsoleScreen::processCommand(const std::string& raw)
|
||||
{
|
||||
// strip leading '/'
|
||||
std::string line = raw;
|
||||
if (!line.empty() && line[0] == '/') line = line.substr(1);
|
||||
line = trim(line);
|
||||
|
||||
// tokenise
|
||||
std::vector<std::string> args;
|
||||
{
|
||||
std::istringstream ss(line);
|
||||
std::string tok;
|
||||
while (ss >> tok) args.push_back(tok);
|
||||
}
|
||||
|
||||
if (args.empty()) return "";
|
||||
|
||||
Level* level = minecraft->level;
|
||||
if (!level) return "No level loaded.";
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// /time ...
|
||||
// -----------------------------------------------------------------------
|
||||
if (args[0] == "time") {
|
||||
if (args.size() < 2)
|
||||
return "Usage: /time <add|set|query> ...";
|
||||
|
||||
const std::string& sub = args[1];
|
||||
|
||||
// -- time add <value> -----------------------------------------------
|
||||
if (sub == "add") {
|
||||
if (args.size() < 3) return "Usage: /time add <value>";
|
||||
long delta = std::atol(args[2].c_str());
|
||||
long newTime = level->getTime() + delta;
|
||||
level->setTime(newTime);
|
||||
std::ostringstream out;
|
||||
out << "Set the time to " << (newTime % Level::TICKS_PER_DAY);
|
||||
return out.str();
|
||||
}
|
||||
|
||||
// -- time set <value|day|night|noon|midnight> -----------------------
|
||||
if (sub == "set") {
|
||||
if (args.size() < 3) return "Usage: /time set <value|day|night|noon|midnight>";
|
||||
const std::string& val = args[2];
|
||||
|
||||
long t = -1;
|
||||
if (val == "day") t = 1000;
|
||||
else if (val == "noon") t = 6000;
|
||||
else if (val == "night") t = 13000;
|
||||
else if (val == "midnight") t = 18000;
|
||||
else {
|
||||
// numeric — accept positive integers only
|
||||
bool numeric = true;
|
||||
for (char c : val)
|
||||
if (!std::isdigit((unsigned char)c)) { numeric = false; break; }
|
||||
if (!numeric) return std::string("Unknown value: ") + val;
|
||||
t = std::atol(val.c_str());
|
||||
}
|
||||
|
||||
// Preserve the total day count so only the time-of-day changes
|
||||
long dayCount = level->getTime() / Level::TICKS_PER_DAY;
|
||||
long newTime = dayCount * Level::TICKS_PER_DAY + (t % Level::TICKS_PER_DAY);
|
||||
level->setTime(newTime);
|
||||
std::ostringstream out;
|
||||
out << "Set the time to " << t;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
// -- time query <daytime|gametime|day> ------------------------------
|
||||
if (sub == "query") {
|
||||
if (args.size() < 3) return "Usage: /time query <daytime|gametime|day>";
|
||||
const std::string& what = args[2];
|
||||
|
||||
long total = level->getTime();
|
||||
long daytime = total % Level::TICKS_PER_DAY;
|
||||
long day = total / Level::TICKS_PER_DAY;
|
||||
|
||||
std::ostringstream out;
|
||||
if (what == "daytime") { out << "The time of day is " << daytime; }
|
||||
else if (what == "gametime") { out << "The game time is " << total; }
|
||||
else if (what == "day") { out << "The day is " << day; }
|
||||
else return std::string("Unknown query: ") + what;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
return "Unknown sub-command. Usage: /time <add|set|query> ...";
|
||||
}
|
||||
|
||||
return std::string("Unknown command: /") + args[0];
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// render
|
||||
// ---------------------------------------------------------------------------
|
||||
void ConsoleScreen::render(int /*xm*/, int /*ym*/, float /*a*/)
|
||||
{
|
||||
// Dim the game world slightly
|
||||
fillGradient(0, 0, width, height, 0x00000000, 0x40000000);
|
||||
|
||||
const int boxH = 12;
|
||||
const int boxY = height - boxH - 2;
|
||||
const int boxX0 = 2;
|
||||
const int boxX1 = width - 2;
|
||||
|
||||
// Input box background
|
||||
fill(boxX0, boxY, boxX1, boxY + boxH, 0xc0000000);
|
||||
// Border
|
||||
fill(boxX0, boxY, boxX1, boxY + 1, 0xff808080);
|
||||
fill(boxX0, boxY + boxH - 1, boxX1, boxY + boxH, 0xff808080);
|
||||
fill(boxX0, boxY, boxX0 + 1, boxY + boxH, 0xff808080);
|
||||
fill(boxX1 - 1, boxY, boxX1, boxY + boxH, 0xff808080);
|
||||
|
||||
// Input text + blinking cursor
|
||||
std::string displayed = _input;
|
||||
if ((_cursorBlink / 10) % 2 == 0)
|
||||
displayed += '_';
|
||||
|
||||
// Placeholder hint when empty
|
||||
font->drawShadow(displayed, (float)(boxX0 + 2), (float)(boxY + 2), 0xffffffff);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include <string>
|
||||
|
||||
class ConsoleScreen: public Screen
|
||||
{
|
||||
typedef Screen super;
|
||||
public:
|
||||
ConsoleScreen();
|
||||
virtual ~ConsoleScreen() {}
|
||||
|
||||
void init();
|
||||
void render(int xm, int ym, float a);
|
||||
void tick();
|
||||
|
||||
virtual bool renderGameBehind() { return true; }
|
||||
virtual bool isInGameScreen() { return true; }
|
||||
virtual bool isPauseScreen() { return false; }
|
||||
|
||||
virtual void keyPressed(int eventKey);
|
||||
virtual void charPressed(char inputChar);
|
||||
virtual bool handleBackEvent(bool isDown);
|
||||
|
||||
private:
|
||||
void execute();
|
||||
std::string processCommand(const std::string& cmd);
|
||||
|
||||
std::string _input;
|
||||
int _cursorBlink; // tick counter for cursor blink
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "CreditsScreen.hpp"
|
||||
#include "StartMenuScreen.hpp"
|
||||
#include "OptionsScreen.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "client/gui/components/ImageButton.hpp"
|
||||
#include "platform/input/Mouse.hpp"
|
||||
@@ -67,7 +67,7 @@ void CreditsScreen::tick() {
|
||||
// move text upward
|
||||
_scrollY -= _scrollSpeed;
|
||||
// if text has scrolled off the top, restart
|
||||
float totalHeight = _lines.size() * (minecraft->font->lineHeight + 8);
|
||||
float totalHeight = _lines.size() * (minecraft.font()->lineHeight + 8);
|
||||
if (_scrollY + totalHeight < 0) {
|
||||
_scrollY = height;
|
||||
}
|
||||
@@ -82,9 +82,9 @@ void CreditsScreen::tick() {
|
||||
void CreditsScreen::render(int xm, int ym, float a) {
|
||||
renderBackground();
|
||||
int w = width;
|
||||
Font* font = minecraft->font;
|
||||
Font* font = minecraft.font();
|
||||
float y = _scrollY;
|
||||
const float lineHeight = font->lineHeight + 8;
|
||||
const float lineHeight = font.lineHeight + 8;
|
||||
for (size_t i = 0; i < _lines.size(); ++i) {
|
||||
const std::string& line = _lines[i];
|
||||
// use color-tag-aware drawing, centre by total width
|
||||
@@ -93,7 +93,7 @@ void CreditsScreen::render(int xm, int ym, float a) {
|
||||
// underline hyperlink lines manually
|
||||
if (line.find("http") != std::string::npos || line.find("discord.gg") != std::string::npos) {
|
||||
float x0 = w/2 - lineWidth/2;
|
||||
float y0 = y + font->lineHeight - 1;
|
||||
float y0 = y + font.lineHeight - 1;
|
||||
this->fill(x0, y0, x0 + lineWidth, y0 + 1, 0xffffffff);
|
||||
}
|
||||
y += lineHeight;
|
||||
@@ -104,13 +104,13 @@ void CreditsScreen::render(int xm, int ym, float a) {
|
||||
|
||||
void CreditsScreen::buttonClicked(Button* button) {
|
||||
if (button->id == 1) {
|
||||
minecraft->setScreen(new OptionsScreen());
|
||||
minecraft.setScreen(new OptionsScreen());
|
||||
}
|
||||
}
|
||||
|
||||
void CreditsScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||
// map click to a line in the scrolling text
|
||||
const float lineHeight = minecraft->font->lineHeight + 8;
|
||||
const float lineHeight = minecraft.font()->lineHeight + 8;
|
||||
for (size_t i = 0; i < _lines.size(); ++i) {
|
||||
float lineY = _scrollY + i * lineHeight;
|
||||
if (y >= lineY && y < lineY + lineHeight) {
|
||||
@@ -122,7 +122,7 @@ void CreditsScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||
// extract until space
|
||||
size_t end = line.find(' ', start);
|
||||
std::string url = line.substr(start, (end == std::string::npos) ? std::string::npos : end - start);
|
||||
minecraft->platform()->openURL(url);
|
||||
minecraft.platform()->openURL(url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "DeathScreen.hpp"
|
||||
#include "ScreenChooser.hpp"
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "platform/time.hpp"
|
||||
|
||||
@@ -23,7 +23,7 @@ DeathScreen::~DeathScreen()
|
||||
|
||||
void DeathScreen::init()
|
||||
{
|
||||
if (/* minecraft->useTouchscreen() */ true) {
|
||||
if (/* minecraft.useTouchscreen() */ true) {
|
||||
bRespawn = new Touch::TButton(1, "Respawn!");
|
||||
bTitle = new Touch::TButton(2, "Main menu");
|
||||
} else {
|
||||
@@ -71,13 +71,13 @@ void DeathScreen::buttonClicked( Button* button )
|
||||
|
||||
if (button == bRespawn) {
|
||||
//RespawnPacket packet();
|
||||
//minecraft->raknetInstance->send(packet);
|
||||
//minecraft.raknetInstance->send(packet);
|
||||
|
||||
minecraft->player->respawn();
|
||||
//minecraft->raknetInstance->send();
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.player()->respawn();
|
||||
//minecraft.raknetInstance->send();
|
||||
minecraft.setScreen(NULL);
|
||||
}
|
||||
|
||||
if (button == bTitle)
|
||||
minecraft->leaveGame();
|
||||
minecraft.leaveGame();
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
class DialogDefinitions {
|
||||
public:
|
||||
static const int DIALOG_CREATE_NEW_WORLD = 1;
|
||||
static const int DIALOG_NEW_CHAT_MESSAGE = 2;
|
||||
static const int DIALOG_MAINMENU_OPTIONS = 3;
|
||||
static const int DIALOG_RENAME_MP_WORLD = 4;
|
||||
static const int DIALOG_DEMO_FEATURE_DISABLED = 98;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/gui/Font.hpp"
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include <string>
|
||||
|
||||
class DisconnectionScreen: public Screen
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
}
|
||||
|
||||
void init() {
|
||||
if (/* minecraft->useTouchscreen() */ true)
|
||||
if (/* minecraft.useTouchscreen() */ true)
|
||||
_back = new Touch::TButton(1, "Ok");
|
||||
else
|
||||
_back = new Button(1, "Ok");
|
||||
@@ -37,13 +37,13 @@ public:
|
||||
renderBackground();
|
||||
super::render(xm, ym, a);
|
||||
|
||||
int center = (width - minecraft->font->width(_msg)) / 2;
|
||||
minecraft->font->drawShadow(_msg, (float)center, (float)(height / 2 - 32), 0xffffffff);
|
||||
int center = (width - minecraft.font()->width(_msg)) / 2;
|
||||
minecraft.font()->drawShadow(_msg, (float)center, (float)(height / 2 - 32), 0xffffffff);
|
||||
}
|
||||
|
||||
void buttonClicked(Button* button) {
|
||||
if (button->id == _back->id) {
|
||||
minecraft->leaveGame();
|
||||
minecraft.leaveGame();
|
||||
}
|
||||
}
|
||||
bool isInGameScreen() { return false; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "crafting/PaneCraftingScreen.hpp"
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/gui/components/NinePatch.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||
@@ -115,7 +115,7 @@ void FurnaceScreen::init() {
|
||||
buttons.push_back(&btnClose);
|
||||
|
||||
// GUI - nine patches
|
||||
NinePatchFactory builder(minecraft->textures, "gui/spritesheet.png");
|
||||
NinePatchFactory builder(minecraft.textures() "gui/spritesheet.png");
|
||||
|
||||
guiBackground = builder.createSymmetrical(IntRectangle(0, 0, 16, 16), 4, 4);
|
||||
guiSlot = builder.createSymmetrical(IntRectangle(0, 32, 8, 8), 3, 3);
|
||||
@@ -250,14 +250,14 @@ void FurnaceScreen::render(int xm, int ym, float a) {
|
||||
t.beginOverride();
|
||||
t.colorABGR(0x33ffffff);
|
||||
t.noColor();
|
||||
ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, &burnResult, (float)(btnResult.x + 7), (float)(btnResult.y + 8), true);
|
||||
ItemRenderer::renderGuiItem(minecraft.font(), minecraft.textures(), &burnResult, (float)(btnResult.x + 7), (float)(btnResult.y + 8), true);
|
||||
t.endOverrideAndDraw();
|
||||
glDisable2(GL_BLEND);
|
||||
}
|
||||
minecraft->font->drawWordWrap(currentItemDesc, (float)btnResult.x - 24, (float)(btnResult.y + btnResult.height + 6), descWidth, rgbActive);
|
||||
minecraft.font()->drawWordWrap(currentItemDesc, (float)btnResult.x - 24, (float)(btnResult.y + btnResult.height + 6), descWidth, rgbActive);
|
||||
}
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/spritesheet.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/spritesheet.png");
|
||||
int yy = btnResult.y + 8;
|
||||
int fpx = furnace->getLitProgress(14) + 2;
|
||||
int xx0 = btnIngredient.x + 8;
|
||||
@@ -274,7 +274,7 @@ void FurnaceScreen::buttonClicked(Button* button) {
|
||||
int slot = button->id;
|
||||
|
||||
if (button == &btnClose) {
|
||||
minecraft->player->closeContainer();
|
||||
minecraft.player()->closeContainer();
|
||||
}
|
||||
|
||||
if (slot >= FurnaceTileEntity::SLOT_INGREDIENT
|
||||
@@ -305,8 +305,8 @@ void FurnaceScreen::recheckRecipes()
|
||||
const FurnaceRecipes* recipes = FurnaceRecipes::getInstance();
|
||||
ItemPack ip;
|
||||
// Check for fuel, and items to burn
|
||||
if (minecraft->player && minecraft->player->inventory) {
|
||||
Inventory* inv = (minecraft->player)->inventory;
|
||||
if (minecraft.player() && minecraft.player()->inventory) {
|
||||
Inventory* inv = (minecraft.player())->inventory;
|
||||
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < inv->getContainerSize(); ++i) {
|
||||
if (ItemInstance* item = inv->getItem(i)) {
|
||||
@@ -401,8 +401,8 @@ void FurnaceScreen::updateItems() {
|
||||
|
||||
ItemList all(listFuel.begin(), listFuel.end());
|
||||
all.insert(all.end(), listIngredient.begin(), listIngredient.end());
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft->player->inventory->getContainerSize(); ++i) {
|
||||
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft.player()->inventory->getContainerSize(); ++i) {
|
||||
ItemInstance* item = minecraft.player()->inventory->getItem(i);
|
||||
if (!item) continue;
|
||||
//LOGI("ItemInstance (%p) Id/aux/count: %d, %d, %d\n", item, item->id, item->getAuxValue(), item->count);
|
||||
bool added = false;
|
||||
@@ -481,8 +481,8 @@ void FurnaceScreen::drawSlotItemAt( Tesselator& t, const ItemInstance* item, int
|
||||
guiSlotMarker->draw(t, xx - 2, yy - 2);
|
||||
|
||||
if (item && !item->isNull()) {
|
||||
ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, item, xx + 7, yy + 8, true);
|
||||
minecraft->gui.renderSlotText(item, xx + 3, yy + 3, true, true);
|
||||
ItemRenderer::renderGuiItem(minecraft.font(), minecraft.textures(), item, xx + 7, yy + 8, true);
|
||||
minecraft.gui().renderSlotText(item, xx + 3, yy + 3, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,9 +494,9 @@ ItemInstance FurnaceScreen::moveOver(const ItemInstance* item, int maxCount) {
|
||||
wantedCount = Mth::Min(wantedCount, maxCount);
|
||||
|
||||
ItemInstance removed(item->id, wantedCount, item->getAuxValue());
|
||||
int oldSize = minecraft->player->inventory->getNumEmptySlots();
|
||||
if (minecraft->player->inventory->removeResource(removed)) {
|
||||
int newSize = minecraft->player->inventory->getNumEmptySlots();
|
||||
int oldSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||
if (minecraft.player()->inventory->removeResource(removed)) {
|
||||
int newSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||
setIfNotSet(doRecreatePane, newSize != oldSize);
|
||||
return removed;
|
||||
}
|
||||
@@ -510,24 +510,24 @@ void FurnaceScreen::takeAndClearSlot( int slot )
|
||||
ItemInstance blank;
|
||||
|
||||
furnace->setItem(slot, &blank);
|
||||
if (minecraft->level->isClientSide) {
|
||||
if (minecraft.level->isClientSide) {
|
||||
ContainerSetSlotPacket p(menu->containerId, slot, blank);
|
||||
minecraft->raknetInstance->send(p);
|
||||
minecraft.raknetInstance->send(p);
|
||||
}
|
||||
|
||||
int oldSize = minecraft->player->inventory->getNumEmptySlots();
|
||||
int oldSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||
|
||||
if (!minecraft->player->inventory->add(&oldItem))
|
||||
minecraft->player->drop(new ItemInstance(oldItem), false);
|
||||
if (!minecraft.player()->inventory->add(&oldItem))
|
||||
minecraft.player()->drop(new ItemInstance(oldItem), false);
|
||||
|
||||
int newSize = minecraft->player->inventory->getNumEmptySlots();
|
||||
int newSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||
setIfNotSet(doRecreatePane, newSize != oldSize);
|
||||
}
|
||||
|
||||
bool FurnaceScreen::handleAddItem( int slot, const ItemInstance* item )
|
||||
{
|
||||
ItemInstance* furnaceItem = furnace->getItem(slot);
|
||||
int oldSize = minecraft->player->inventory->getNumEmptySlots();
|
||||
int oldSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||
|
||||
if (item->id == furnaceItem->id) {
|
||||
// If stackable, stack them! Else deny the addition
|
||||
@@ -545,11 +545,11 @@ bool FurnaceScreen::handleAddItem( int slot, const ItemInstance* item )
|
||||
player->containerMenu->setSlot(slot, &moved);
|
||||
}
|
||||
|
||||
if (minecraft->level->isClientSide) {
|
||||
if (minecraft.level->isClientSide) {
|
||||
ContainerSetSlotPacket p(menu->containerId, slot, *furnaceItem);
|
||||
minecraft->raknetInstance->send(p);
|
||||
minecraft.raknetInstance->send(p);
|
||||
}
|
||||
|
||||
int newSize = minecraft->player->inventory->getNumEmptySlots();
|
||||
int newSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||
return (newSize != oldSize);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "InBedScreen.hpp"
|
||||
#include "ScreenChooser.hpp"
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "platform/time.hpp"
|
||||
|
||||
@@ -17,7 +17,7 @@ InBedScreen::~InBedScreen() {
|
||||
}
|
||||
|
||||
void InBedScreen::init() {
|
||||
if (/* minecraft->useTouchscreen() */ true) {
|
||||
if (/* minecraft.useTouchscreen() */ true) {
|
||||
bWakeUp = new Touch::TButton(1, "Leave Bed");
|
||||
} else {
|
||||
bWakeUp = new Button(1, "Leave Bed");
|
||||
@@ -43,7 +43,7 @@ void InBedScreen::render( int xm, int ym, float a ) {
|
||||
|
||||
void InBedScreen::buttonClicked( Button* button ) {
|
||||
if (button == bWakeUp) {
|
||||
minecraft->player->stopSleepInBed(true, true, true);
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.player()->stopSleepInBed(true, true, true);
|
||||
minecraft.setScreen(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "client/renderer/TileRenderer.hpp"
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "client/renderer/gles.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/sound/SoundEngine.hpp"
|
||||
#include "world/entity/player/Inventory.hpp"
|
||||
#include "platform/input/Mouse.hpp"
|
||||
@@ -32,8 +32,8 @@ IngameBlockSelectionScreen::IngameBlockSelectionScreen()
|
||||
|
||||
void IngameBlockSelectionScreen::init()
|
||||
{
|
||||
Inventory* inventory = minecraft->player->inventory;
|
||||
InventoryCols = minecraft->isCreativeMode()? 13 : 9;
|
||||
Inventory* inventory = minecraft.player()->inventory;
|
||||
InventoryCols = minecraft.isCreativeMode()? 13 : 9;
|
||||
InventorySize = inventory->getContainerSize() - Inventory::MAX_SELECTION_SIZE;
|
||||
InventoryRows = 1 + (InventorySize - 1) / InventoryCols;
|
||||
|
||||
@@ -49,7 +49,7 @@ void IngameBlockSelectionScreen::init()
|
||||
}
|
||||
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < InventorySize; i++) {
|
||||
if (selected == minecraft->player->inventory->getItem(i))
|
||||
if (selected == minecraft.player()->inventory->getItem(i))
|
||||
{
|
||||
selectedItem = i - Inventory::MAX_SELECTION_SIZE;
|
||||
break;
|
||||
@@ -58,7 +58,7 @@ void IngameBlockSelectionScreen::init()
|
||||
if (!isAllowed(selectedItem))
|
||||
selectedItem = 0;
|
||||
|
||||
if (!minecraft->isCreativeMode()) {
|
||||
if (!minecraft.isCreativeMode()) {
|
||||
bArmor.width = 42;
|
||||
bArmor.x = 0;
|
||||
bArmor.y = height - bArmor.height;
|
||||
@@ -68,7 +68,7 @@ void IngameBlockSelectionScreen::init()
|
||||
|
||||
void IngameBlockSelectionScreen::removed()
|
||||
{
|
||||
minecraft->gui.inventoryUpdated();
|
||||
minecraft.gui().inventoryUpdated();
|
||||
}
|
||||
|
||||
void IngameBlockSelectionScreen::renderSlots()
|
||||
@@ -86,7 +86,7 @@ void IngameBlockSelectionScreen::renderSlots()
|
||||
//Lighting::turnOn();
|
||||
//glPopMatrix2();
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/gui.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||
for (int r = 0; r < InventoryRows; r++)
|
||||
{
|
||||
int x = getSlotPosX(0) - 3;
|
||||
@@ -146,18 +146,18 @@ int IngameBlockSelectionScreen::getSlotPosY(int slotY) {
|
||||
|
||||
void IngameBlockSelectionScreen::renderSlot(int slot, int x, int y, float a)
|
||||
{
|
||||
ItemInstance* item = minecraft->player->inventory->getItem(slot);
|
||||
ItemInstance* item = minecraft.player()->inventory->getItem(slot);
|
||||
if (!item) return;
|
||||
|
||||
ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, item, (float)x, (float)y, true);
|
||||
ItemRenderer::renderGuiItem(minecraft.font(), minecraft.textures() item, (float)x, (float)y, true);
|
||||
|
||||
if (minecraft->gameMode->isCreativeType()) return;
|
||||
if (minecraft.gameMode->isCreativeType()) return;
|
||||
if (!isAllowed(slot - Inventory::MAX_SELECTION_SIZE)) return;
|
||||
|
||||
glPushMatrix2();
|
||||
glScalef2(Gui::InvGuiScale + Gui::InvGuiScale, Gui::InvGuiScale + Gui::InvGuiScale, 1);
|
||||
const float k = 0.5f * Gui::GuiScale;
|
||||
minecraft->gui.renderSlotText(item, k*x, k*y, true, true);
|
||||
minecraft.gui().renderSlotText(item, k*x, k*y, true, true);
|
||||
glPopMatrix2();
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ void IngameBlockSelectionScreen::keyPressed(int eventKey)
|
||||
|
||||
int tmpSelectedSlot = selectedItem;
|
||||
|
||||
Options& o = minecraft->options;
|
||||
Options& o = minecraft.options();
|
||||
if (eventKey == o.getIntValue(OPTIONS_KEY_LEFT) && selX > 0)
|
||||
{
|
||||
tmpSelectedSlot -= 1;
|
||||
@@ -195,10 +195,10 @@ void IngameBlockSelectionScreen::keyPressed(int eventKey)
|
||||
#ifdef RPI
|
||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_CANCEL)
|
||||
|| eventKey == Keyboard::KEY_ESCAPE)
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.setScreen(NULL);
|
||||
#else
|
||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_CANCEL))
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.setScreen(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ void IngameBlockSelectionScreen::mouseClicked(int x, int y, int buttonNum)
|
||||
if (isAllowed(slot))
|
||||
{
|
||||
selectedItem = slot;
|
||||
//minecraft->soundEngine->playUI("random.click", 1, 1);
|
||||
//minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||
} else {
|
||||
_pendingQuit = !_area.isInside((float)x, (float)y)
|
||||
&& !bArmor.isInside(x, y);
|
||||
@@ -265,7 +265,7 @@ void IngameBlockSelectionScreen::mouseReleased(int x, int y, int buttonNum)
|
||||
selectSlotAndClose();
|
||||
} else {
|
||||
if (_pendingQuit && !_area.isInside((float)x, (float)y))
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.setScreen(NULL);
|
||||
}
|
||||
}
|
||||
if (!_pendingQuit)
|
||||
@@ -274,15 +274,15 @@ void IngameBlockSelectionScreen::mouseReleased(int x, int y, int buttonNum)
|
||||
|
||||
void IngameBlockSelectionScreen::selectSlotAndClose()
|
||||
{
|
||||
Inventory* inventory = minecraft->player->inventory;
|
||||
Inventory* inventory = minecraft.player()->inventory;
|
||||
// Flash the selected gui item
|
||||
//inventory->moveToSelectedSlot(selectedItem + Inventory::MAX_SELECTION_SIZE, true);
|
||||
inventory->moveToSelectionSlot(0, selectedItem + Inventory::MAX_SELECTION_SIZE, true);
|
||||
inventory->selectSlot(0);
|
||||
minecraft->gui.flashSlot(inventory->selected);
|
||||
minecraft.gui().flashSlot(inventory->selected);
|
||||
|
||||
minecraft->soundEngine->playUI("random.click", 1, 1);
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||
minecraft.setScreen(NULL);
|
||||
}
|
||||
|
||||
void IngameBlockSelectionScreen::render( int xm, int ym, float a )
|
||||
@@ -313,7 +313,7 @@ void IngameBlockSelectionScreen::renderDemoOverlay() {
|
||||
|
||||
const int centerX = (getSlotPosX(4) + getSlotPosX(5)) / 2;
|
||||
const int centerY = (getSlotPosY(3) + getSlotPosY(InventoryRows-1)) / 2 + 5;
|
||||
drawCenteredString(minecraft->font, demoVersionString, centerX, centerY, 0xffffffff);
|
||||
drawCenteredString(minecraft.font(), demoVersionString, centerX, centerY, 0xffffffff);
|
||||
#endif /*DEMO_MODE*/
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ bool IngameBlockSelectionScreen::isAllowed(int slot) {
|
||||
return false;
|
||||
|
||||
#ifdef DEMO_MODE
|
||||
return slot < (minecraft->isCreativeMode()? 28 : 27);
|
||||
return slot < (minecraft.isCreativeMode()? 28 : 27);
|
||||
#endif /*DEMO_MODE*/
|
||||
|
||||
return true;
|
||||
@@ -335,7 +335,7 @@ int IngameBlockSelectionScreen::getSlotHeight() {
|
||||
void IngameBlockSelectionScreen::buttonClicked( Button* button )
|
||||
{
|
||||
if (button == &bArmor) {
|
||||
minecraft->setScreen(new ArmorScreen());
|
||||
minecraft.setScreen(new ArmorScreen());
|
||||
}
|
||||
super::buttonClicked(button);
|
||||
}
|
||||
|
||||
@@ -28,21 +28,21 @@ void JoinByIPScreen::buttonClicked(Button* button)
|
||||
{
|
||||
if (button->id == bJoin.id)
|
||||
{
|
||||
minecraft->isLookingForMultiplayer = true;
|
||||
minecraft->netCallback = new ClientSideNetworkHandler(minecraft, minecraft->raknetInstance);
|
||||
minecraft.isLookingForMultiplayer = true;
|
||||
minecraft.netCallback = new ClientSideNetworkHandler(minecraft, minecraft.raknetInstance);
|
||||
|
||||
minecraft->joinMultiplayerFromString(tIP.text);
|
||||
minecraft.joinMultiplayerFromString(tIP.text);
|
||||
{
|
||||
minecraft->options.set(OPTIONS_LAST_IP, tIP.text);
|
||||
minecraft.options().set(OPTIONS_LAST_IP, tIP.text);
|
||||
bJoin.active = false;
|
||||
bBack.active = false;
|
||||
minecraft->setScreen(new ProgressScreen());
|
||||
minecraft.setScreen(new ProgressScreen());
|
||||
}
|
||||
}
|
||||
if (button->id == bBack.id)
|
||||
{
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.cancelLocateMultiplayer();
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ bool JoinByIPScreen::handleBackEvent(bool isDown)
|
||||
{
|
||||
if (!isDown)
|
||||
{
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ void JoinByIPScreen::init()
|
||||
tabButtons.push_back(&bHeader);
|
||||
#endif
|
||||
|
||||
tIP.text = minecraft->options.getStringValue(OPTIONS_LAST_IP);
|
||||
tIP.text = minecraft.options().getStringValue(OPTIONS_LAST_IP);
|
||||
}
|
||||
|
||||
void JoinByIPScreen::setupPositions() {
|
||||
@@ -116,7 +116,7 @@ void JoinByIPScreen::render( int xm, int ym, float a )
|
||||
void JoinByIPScreen::keyPressed(int eventKey)
|
||||
{
|
||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
return;
|
||||
}
|
||||
// let base class handle navigation and text box keys
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/gui/components/ImageButton.hpp"
|
||||
#include "client/gui/components/TextBox.hpp"
|
||||
|
||||
|
||||
@@ -25,20 +25,20 @@ void JoinGameScreen::buttonClicked(Button* button)
|
||||
if (isIndexValid(gamesList->selectedItem))
|
||||
{
|
||||
PingedCompatibleServer selectedServer = gamesList->copiedServerList[gamesList->selectedItem];
|
||||
minecraft->joinMultiplayer(selectedServer);
|
||||
minecraft.joinMultiplayer(selectedServer);
|
||||
{
|
||||
bJoin.active = false;
|
||||
bBack.active = false;
|
||||
minecraft->setScreen(new ProgressScreen());
|
||||
minecraft.setScreen(new ProgressScreen());
|
||||
}
|
||||
}
|
||||
//minecraft->locateMultiplayer();
|
||||
//minecraft->setScreen(new JoinGameScreen());
|
||||
//minecraft.locateMultiplayer();
|
||||
//minecraft.setScreen(new JoinGameScreen());
|
||||
}
|
||||
if (button->id == bBack.id)
|
||||
{
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.cancelLocateMultiplayer();
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ bool JoinGameScreen::handleBackEvent(bool isDown)
|
||||
{
|
||||
if (!isDown)
|
||||
{
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.cancelLocateMultiplayer();
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ bool JoinGameScreen::isIndexValid( int index )
|
||||
|
||||
void JoinGameScreen::tick()
|
||||
{
|
||||
const ServerList& orgServerList = minecraft->raknetInstance->getServerList();
|
||||
const ServerList& orgServerList = minecraft.raknetInstance->getServerList();
|
||||
ServerList serverList;
|
||||
for (unsigned int i = 0; i < orgServerList.size(); ++i)
|
||||
if (orgServerList[i].name.GetLength() > 0)
|
||||
@@ -108,7 +108,7 @@ void JoinGameScreen::init()
|
||||
buttons.push_back(&bJoin);
|
||||
buttons.push_back(&bBack);
|
||||
|
||||
minecraft->raknetInstance->clearServerList();
|
||||
minecraft.raknetInstance->clearServerList();
|
||||
gamesList = new AvailableGamesList(minecraft, width, height);
|
||||
|
||||
#ifdef ANDROID
|
||||
@@ -134,7 +134,7 @@ void JoinGameScreen::setupPositions() {
|
||||
|
||||
void JoinGameScreen::render( int xm, int ym, float a )
|
||||
{
|
||||
bool hasNetwork = minecraft->platform()->isNetworkEnabled(true);
|
||||
bool hasNetwork = minecraft.platform()->isNetworkEnabled(true);
|
||||
#ifdef WIN32
|
||||
hasNetwork = hasNetwork && !GetAsyncKeyState(VK_TAB);
|
||||
#endif
|
||||
@@ -149,18 +149,18 @@ void JoinGameScreen::render( int xm, int ym, float a )
|
||||
#else
|
||||
std::string s = "Scanning for WiFi Games...";
|
||||
#endif
|
||||
drawCenteredString(minecraft->font, s, width / 2, 8, 0xffffffff);
|
||||
drawCenteredString(minecraft.font(), s, width / 2, 8, 0xffffffff);
|
||||
|
||||
const int textWidth = minecraft->font->width(s);
|
||||
const int textWidth = minecraft.font()->width(s);
|
||||
const int spinnerX = width/2 + textWidth / 2 + 6;
|
||||
|
||||
static const char* spinnerTexts[] = {"-", "\\", "|", "/"};
|
||||
int n = ((int)(5.5f * getTimeS()) % 4);
|
||||
drawCenteredString(minecraft->font, spinnerTexts[n], spinnerX, 8, 0xffffffff);
|
||||
drawCenteredString(minecraft.font(), spinnerTexts[n], spinnerX, 8, 0xffffffff);
|
||||
} else {
|
||||
std::string s = "WiFi is disabled";
|
||||
const int yy = height / 2 - 8;
|
||||
drawCenteredString(minecraft->font, s, width / 2, yy, 0xffffffff);
|
||||
drawCenteredString(minecraft.font(), s, width / 2, yy, 0xffffffff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "client/gui/components/ScrolledSelectionList.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "network/RakNetInstance.hpp"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class AvailableGamesList : public ScrolledSelectionList
|
||||
|
||||
public:
|
||||
|
||||
AvailableGamesList(Minecraft* _minecraft, int _width, int _height)
|
||||
AvailableGamesList(MinecraftClient& _minecraft, int _width, int _height)
|
||||
: ScrolledSelectionList(_minecraft, _width, _height, 24, _height - 30, 28)
|
||||
{
|
||||
}
|
||||
@@ -35,8 +35,8 @@ protected:
|
||||
{
|
||||
const PingedCompatibleServer& s = copiedServerList[i];
|
||||
unsigned int color = s.isSpecial? 0xff00b0 : 0xffffa0;
|
||||
drawString(minecraft->font, s.name.C_String(), x, y + 2, color);
|
||||
drawString(minecraft->font, s.address.ToString(false), x, y + 16, 0xffffa0);
|
||||
drawString(minecraft.font(), s.name.C_String(), x, y + 2, color);
|
||||
drawString(minecraft.font(), s.address.ToString(false), x, y + 16, 0xffffa0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "StartMenuScreen.hpp"
|
||||
#include "UsernameScreen.hpp"
|
||||
#include "DialogDefinitions.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "AppPlatform.hpp"
|
||||
#include "CreditsScreen.hpp"
|
||||
|
||||
@@ -34,14 +34,14 @@ OptionsScreen::~OptionsScreen() {
|
||||
btnCredits = NULL;
|
||||
}
|
||||
|
||||
for (std::vector<Touch::TButton*>::iterator it = categoryButtons.begin(); it != categoryButtons.end(); ++it) {
|
||||
for (auto it = categoryButtons.begin(); it != categoryButtons.end(); ++it) {
|
||||
if (*it != NULL) {
|
||||
delete* it;
|
||||
*it = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (std::vector<OptionsGroup*>::iterator it = optionPanes.begin(); it != optionPanes.end(); ++it) {
|
||||
for (auto it = optionPanes.begin(); it != optionPanes.end(); ++it) {
|
||||
if (*it != NULL) {
|
||||
delete* it;
|
||||
*it = NULL;
|
||||
@@ -76,7 +76,7 @@ void OptionsScreen::init() {
|
||||
buttons.push_back(btnClose);
|
||||
buttons.push_back(btnCredits);
|
||||
|
||||
for (std::vector<Touch::TButton*>::iterator it = categoryButtons.begin(); it != categoryButtons.end(); ++it) {
|
||||
for (auto it = categoryButtons.begin(); it != categoryButtons.end(); ++it) {
|
||||
buttons.push_back(*it);
|
||||
tabButtons.push_back(*it);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ void OptionsScreen::setupPositions() {
|
||||
|
||||
int offsetNum = 1;
|
||||
|
||||
for (std::vector<Touch::TButton*>::iterator it = categoryButtons.begin(); it != categoryButtons.end(); ++it) {
|
||||
for (auto it = categoryButtons.begin(); it != categoryButtons.end(); ++it) {
|
||||
|
||||
(*it)->x = 0;
|
||||
(*it)->y = offsetNum * buttonHeight;
|
||||
@@ -114,7 +114,7 @@ void OptionsScreen::setupPositions() {
|
||||
btnCredits->y = height - btnCredits->height;
|
||||
}
|
||||
|
||||
for (std::vector<OptionsGroup*>::iterator it = optionPanes.begin(); it != optionPanes.end(); ++it) {
|
||||
for (auto it = optionPanes.begin(); it != optionPanes.end(); ++it) {
|
||||
|
||||
if (categoryButtons.size() > 0 && categoryButtons[0] != NULL) {
|
||||
|
||||
@@ -133,8 +133,8 @@ void OptionsScreen::setupPositions() {
|
||||
void OptionsScreen::render(int xm, int ym, float a) {
|
||||
renderBackground();
|
||||
|
||||
int xmm = xm * width / minecraft->width;
|
||||
int ymm = ym * height / minecraft->height - 1;
|
||||
int xmm = xm * width / minecraft.getScreenWidth();
|
||||
int ymm = ym * height / minecraft.getScreenHeight() - 1;
|
||||
|
||||
if (currentOptionsGroup != NULL)
|
||||
currentOptionsGroup->render(minecraft, xmm, ymm);
|
||||
@@ -147,11 +147,11 @@ void OptionsScreen::removed() {
|
||||
|
||||
void OptionsScreen::buttonClicked(Button* button) {
|
||||
if (button == btnClose) {
|
||||
minecraft->options.save();
|
||||
if (minecraft->screen != NULL) {
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.options().save();
|
||||
if (minecraft.getScreen()!= NULL) {
|
||||
minecraft.setScreen(NULL);
|
||||
} else {
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
}
|
||||
else if (button->id > 1 && button->id < 7) {
|
||||
@@ -159,14 +159,14 @@ void OptionsScreen::buttonClicked(Button* button) {
|
||||
selectCategory(categoryButton);
|
||||
}
|
||||
else if (button == btnCredits) {
|
||||
minecraft->setScreen(new CreditsScreen());
|
||||
minecraft.setScreen(new CreditsScreen());
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsScreen::selectCategory(int index) {
|
||||
int currentIndex = 0;
|
||||
|
||||
for (std::vector<Touch::TButton*>::iterator it = categoryButtons.begin(); it != categoryButtons.end(); ++it) {
|
||||
for (auto it = categoryButtons.begin(); it != categoryButtons.end(); ++it) {
|
||||
|
||||
if (index == currentIndex)
|
||||
(*it)->selected = true;
|
||||
@@ -246,7 +246,7 @@ void OptionsScreen::keyPressed(int eventKey) {
|
||||
if (currentOptionsGroup != NULL)
|
||||
currentOptionsGroup->keyPressed(minecraft, eventKey);
|
||||
if (eventKey == Keyboard::KEY_ESCAPE)
|
||||
minecraft->options.save();
|
||||
minecraft.options().save();
|
||||
|
||||
super::keyPressed(eventKey);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "PauseScreen.hpp"
|
||||
#include "StartMenuScreen.hpp"
|
||||
#include "client/gui/components/ImageButton.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "util/Mth.hpp"
|
||||
#include "network/RakNetInstance.hpp"
|
||||
#include "network/ServerSideNetworkHandler.hpp"
|
||||
@@ -48,7 +48,7 @@ PauseScreen::~PauseScreen() {
|
||||
}
|
||||
|
||||
void PauseScreen::init() {
|
||||
if (/* minecraft->useTouchscreen() */ true) {
|
||||
if (/* minecraft.useTouchscreen() */ true) {
|
||||
bContinue = new Touch::TButton(1, "Back to game");
|
||||
bOptions = new Touch::TButton(5, "Options");
|
||||
bQuit = new Touch::TButton(2, "Quit to title");
|
||||
@@ -67,9 +67,9 @@ void PauseScreen::init() {
|
||||
buttons.push_back(bContinue);
|
||||
buttons.push_back(bQuit);
|
||||
buttons.push_back(bOptions);
|
||||
// bSound.updateImage(&minecraft->options);
|
||||
bThirdPerson.updateImage(&minecraft->options);
|
||||
bHideGui.updateImage(&minecraft->options);
|
||||
// bSound.updateImage(&minecraft.options);
|
||||
bThirdPerson.updateImage(&minecraft.options);
|
||||
bHideGui.updateImage(&minecraft.options);
|
||||
// buttons.push_back(&bSound);
|
||||
buttons.push_back(&bThirdPerson);
|
||||
//buttons.push_back(&bHideGui);
|
||||
@@ -79,8 +79,8 @@ void PauseScreen::init() {
|
||||
|
||||
#if !defined(APPLE_DEMO_PROMOTION) && !defined(RPI)
|
||||
if (true || !wasBackPaused) {
|
||||
if (minecraft->raknetInstance) {
|
||||
if (minecraft->raknetInstance->isServer()) {
|
||||
if (minecraft.raknetInstance) {
|
||||
if (minecraft.raknetInstance->isServer()) {
|
||||
updateServerVisibilityText();
|
||||
buttons.push_back(bServerVisibility);
|
||||
}
|
||||
@@ -142,7 +142,7 @@ void PauseScreen::tick() {
|
||||
void PauseScreen::render(int xm, int ym, float a) {
|
||||
renderBackground();
|
||||
|
||||
//bool isSaving = !minecraft->level.pauseSave(saveStep++);
|
||||
//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;
|
||||
@@ -158,21 +158,21 @@ void PauseScreen::render(int xm, int ym, float a) {
|
||||
|
||||
void PauseScreen::buttonClicked(Button* button) {
|
||||
if (button->id == bContinue->id) {
|
||||
minecraft->setScreen(NULL);
|
||||
//minecraft->grabMouse();
|
||||
minecraft.setScreen(NULL);
|
||||
//minecraft.grabMouse();
|
||||
}
|
||||
if (button->id == bQuit->id) {
|
||||
minecraft->leaveGame();
|
||||
minecraft.leaveGame();
|
||||
}
|
||||
if (button->id == bQuitAndSaveLocally->id) {
|
||||
minecraft->leaveGame(true);
|
||||
minecraft.leaveGame(true);
|
||||
}
|
||||
if (button->id == bOptions->id) {
|
||||
minecraft->setScreen(new OptionsScreen());
|
||||
minecraft.setScreen(new OptionsScreen());
|
||||
}
|
||||
if (button->id == bServerVisibility->id) {
|
||||
if (minecraft->raknetInstance && minecraft->netCallback && minecraft->raknetInstance->isServer()) {
|
||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) minecraft->netCallback;
|
||||
if (minecraft.raknetInstance && minecraft.netCallback && minecraft.raknetInstance->isServer()) {
|
||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) minecraft.netCallback;
|
||||
bool allows = !ss->allowsIncomingConnections();
|
||||
ss->allowIncomingConnections(allows);
|
||||
|
||||
@@ -181,20 +181,20 @@ void PauseScreen::buttonClicked(Button* button) {
|
||||
}
|
||||
|
||||
if (button->id == OptionButton::ButtonId) {
|
||||
((OptionButton*)button)->toggle(&minecraft->options);
|
||||
((OptionButton*)button)->toggle(&minecraft.options);
|
||||
}
|
||||
|
||||
//if (button->id == bThirdPerson->id) {
|
||||
// minecraft->options.thirdPersonView = !minecraft->options.thirdPersonView;
|
||||
// minecraft.options().thirdPersonView = !minecraft.options().thirdPersonView;
|
||||
//}
|
||||
}
|
||||
|
||||
void PauseScreen::updateServerVisibilityText()
|
||||
{
|
||||
if (!minecraft->raknetInstance || !minecraft->raknetInstance->isServer())
|
||||
if (!minecraft.raknetInstance || !minecraft.raknetInstance->isServer())
|
||||
return;
|
||||
|
||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) minecraft->netCallback;
|
||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) minecraft.netCallback;
|
||||
bServerVisibility->msg = ss->allowsIncomingConnections()?
|
||||
"Server is visible"
|
||||
: "Server is invisible";
|
||||
|
||||
@@ -18,7 +18,7 @@ class PrerenderTilesScreen: public Screen
|
||||
{
|
||||
public:
|
||||
void init() {
|
||||
Player p(minecraft->level, true);
|
||||
Player p(minecraft.level, true);
|
||||
Inventory _inventory(&p, true);
|
||||
Inventory* inventory = &_inventory;
|
||||
|
||||
@@ -93,21 +93,21 @@ public:
|
||||
int y = j/16 * 16;
|
||||
|
||||
//Tesselator::instance.color(0xffffffff);
|
||||
//minecraft->textures->loadAndBindTexture("gui/gui2.png");
|
||||
//minecraft.textures().loadAndBindTexture("gui/gui2.png");
|
||||
//glColor4f2(0.2f, 0.5f, 0.2f, 1);
|
||||
//blit(x, y, 4 + 20 * (i%9), 4, 16, 16, 15, 15);
|
||||
//glColor4f2(1, 1, 1, 1);
|
||||
|
||||
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
|
||||
LOGI("0, %d, %d, %d, 0\n", j, item->id, item->getAuxValue());
|
||||
ItemRenderer::renderGuiItemCorrect(minecraft->font, minecraft->textures, item, x, y);
|
||||
ItemRenderer::renderGuiItemCorrect(minecraft.font(), minecraft.textures() item, x, y);
|
||||
} else if (item->getIcon() >= 0) {
|
||||
LOGI("1, %d, %d, %d, %d\n", j, item->id, item->getAuxValue(), item->getIcon());
|
||||
}
|
||||
++j;
|
||||
}*/
|
||||
int j = 0;
|
||||
for(std::vector<ItemInstance>::iterator i = mItems.begin(); i != mItems.end(); ++i) {
|
||||
for(auto i = mItems.begin(); i != mItems.end(); ++i) {
|
||||
ItemInstance* item = &(*i);
|
||||
|
||||
//LOGI("desc: %d - %s. %d\n", i, item->toString().c_str());
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
int y = j/16 * 16;
|
||||
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
|
||||
LOGI("0, %d, %d, %d, 0\n", j, item->id, item->getAuxValue());
|
||||
ItemRenderer::renderGuiItemCorrect(minecraft->font, minecraft->textures, item, x, y);
|
||||
ItemRenderer::renderGuiItemCorrect(minecraft.font(), minecraft.textures() item, x, y);
|
||||
} else if (item->getIcon() >= 0) {
|
||||
LOGI("1, %d, %d, %d, %d\n", j, item->id, item->getAuxValue(), item->getIcon());
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
if (item->getAuxValue() < 0) return;
|
||||
|
||||
bool found = false;
|
||||
for(std::vector<ItemInstance>::iterator i = mItems.begin(); i != mItems.end(); ++i) {
|
||||
for(auto i = mItems.begin(); i != mItems.end(); ++i) {
|
||||
ItemInstance *jitem = &*i;
|
||||
if(jitem->id != item->id) continue;
|
||||
if(jitem->isStackedByData() && jitem->getAuxValue() != item->getAuxValue()) continue;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "DisconnectionScreen.hpp"
|
||||
#include "client/gui/Gui.hpp"
|
||||
#include "client/gui/Font.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "SharedConstants.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
@@ -14,15 +14,15 @@ ProgressScreen::ProgressScreen()
|
||||
|
||||
void ProgressScreen::render( int xm, int ym, float a )
|
||||
{
|
||||
if (minecraft->isLevelGenerated()) {
|
||||
minecraft->setScreen(NULL);
|
||||
if (minecraft.isLevelGenerated()) {
|
||||
minecraft.setScreen(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
Tesselator& t = Tesselator::instance;
|
||||
renderBackground();
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||
|
||||
const float s = 32;
|
||||
t.begin();
|
||||
@@ -33,7 +33,7 @@ void ProgressScreen::render( int xm, int ym, float a )
|
||||
t.vertexUV(0, 0, 0, 0, 0);
|
||||
t.draw();
|
||||
|
||||
int i = minecraft->progressStagePercentage;
|
||||
int i = minecraft.progressStagePercentage;
|
||||
|
||||
if (i >= 0) {
|
||||
int w = 100;
|
||||
@@ -63,26 +63,26 @@ void ProgressScreen::render( int xm, int ym, float a )
|
||||
glEnable2(GL_BLEND);
|
||||
|
||||
const char* title = "Generating world";
|
||||
minecraft->font->drawShadow(title, (float)((width - minecraft->font->width(title)) / 2), (float)(height / 2 - 4 - 16), 0xffffff);
|
||||
minecraft.font()->drawShadow(title, (float)((width - minecraft.font()->width(title)) / 2), (float)(height / 2 - 4 - 16), 0xffffff);
|
||||
|
||||
const char* status = minecraft->getProgressMessage();
|
||||
const int progressWidth = minecraft->font->width(status);
|
||||
const char* status = minecraft.getProgressMessage();
|
||||
const int progressWidth = minecraft.font()->width(status);
|
||||
const int progressLeft = (width - progressWidth) / 2;
|
||||
const int progressY = height / 2 - 4 + 8;
|
||||
minecraft->font->drawShadow(status, (float)progressLeft, (float)progressY, 0xffffff);
|
||||
minecraft.font()->drawShadow(status, (float)progressLeft, (float)progressY, 0xffffff);
|
||||
|
||||
#if APPLE_DEMO_PROMOTION
|
||||
drawCenteredString(minecraft->font, "This demonstration version", width/2, progressY + 36, 0xffffff);
|
||||
drawCenteredString(minecraft->font, "does not allow saving games", width/2, progressY + 46, 0xffffff);
|
||||
drawCenteredString(minecraft.font(), "This demonstration version", width/2, progressY + 36, 0xffffff);
|
||||
drawCenteredString(minecraft.font(), "does not allow saving games", width/2, progressY + 46, 0xffffff);
|
||||
#endif
|
||||
|
||||
// If we're locating the server, show our famous spinner!
|
||||
bool isLocating = (minecraft->getProgressStatusId() == 0);
|
||||
bool isLocating = (minecraft.getProgressStatusId() == 0);
|
||||
if (isLocating) {
|
||||
const int spinnerX = progressLeft + progressWidth + 6;
|
||||
static const char* spinnerTexts[] = {"-", "\\", "|", "/"};
|
||||
int n = ((int)(5.5f * getTimeS()) % 4);
|
||||
drawCenteredString(minecraft->font, spinnerTexts[n], spinnerX, progressY, 0xffffffff);
|
||||
drawCenteredString(minecraft.font(), spinnerTexts[n], spinnerX, progressY, 0xffffffff);
|
||||
}
|
||||
|
||||
glDisable2(GL_BLEND);
|
||||
@@ -93,7 +93,7 @@ bool ProgressScreen::isInGameScreen() { return false; }
|
||||
|
||||
void ProgressScreen::tick() {
|
||||
// After 10 seconds of not connecting -> write an error message and go back
|
||||
if (++ticks == 10 * SharedConstants::TicksPerSecond && minecraft->getProgressStatusId() == 0) {
|
||||
minecraft->setScreen( new DisconnectionScreen("Could not connect to server. Try again.") );
|
||||
if (++ticks == 10 * SharedConstants::TicksPerSecond && minecraft.getProgressStatusId() == 0) {
|
||||
minecraft.setScreen( new DisconnectionScreen("Could not connect to server. Try again.") );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "touch/TouchJoinGameScreen.hpp"
|
||||
#include "touch/TouchIngameBlockSelectionScreen.hpp"
|
||||
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
|
||||
#include <client/gui/screens/UsernameScreen.hpp>
|
||||
|
||||
@@ -22,7 +22,7 @@ Screen* ScreenChooser::createScreen( ScreenId id )
|
||||
Screen* screen = NULL;
|
||||
|
||||
// :sob:
|
||||
if (/* _mc->useTouchscreen() */ true) {
|
||||
if (/* _mc.useTouchscreen() */ true) {
|
||||
switch (id) {
|
||||
case SCREEN_STARTMENU: screen = new Touch::StartMenuScreen(); break;
|
||||
case SCREEN_SELECTWORLD: screen = new Touch::SelectWorldScreen();break;
|
||||
|
||||
@@ -65,12 +65,12 @@ void WorldSelectionList::renderItem( int i, int x, int y, int h, Tesselator& t )
|
||||
const int TX = centerx - itemWidth / 2 + 5;
|
||||
|
||||
StringVector v = _descriptions[i];
|
||||
drawString(minecraft->font, v[0].c_str(), TX, TY + 0, textColor);
|
||||
drawString(minecraft->font, v[1].c_str(), TX, TY + 10, textColor2);
|
||||
drawString(minecraft->font, v[2].c_str(), TX, TY + 20, textColor2);
|
||||
drawString(minecraft->font, v[3].c_str(), TX, TY + 30, textColor2);
|
||||
drawString(minecraft.font(), v[0].c_str(), TX, TY + 0, textColor);
|
||||
drawString(minecraft.font(), v[1].c_str(), TX, TY + 10, textColor2);
|
||||
drawString(minecraft.font(), v[2].c_str(), TX, TY + 20, textColor2);
|
||||
drawString(minecraft.font(), v[3].c_str(), TX, TY + 30, textColor2);
|
||||
|
||||
minecraft->textures->loadAndBindTexture(_imageNames[i]);
|
||||
minecraft.textures().loadAndBindTexture(_imageNames[i]);
|
||||
t.color(0.3f, 1.0f, 0.2f);
|
||||
|
||||
//float x0 = (float)x;
|
||||
@@ -114,7 +114,7 @@ void WorldSelectionList::commit() {
|
||||
|
||||
std::stringstream ss;
|
||||
ss << level.name << "/preview.png";
|
||||
TextureId id = Textures::InvalidId;//minecraft->textures->loadTexture(ss.str(), false);
|
||||
TextureId id = Textures::InvalidId;//minecraft.textures().loadTexture(ss.str(), false);
|
||||
|
||||
if (id != Textures::InvalidId) {
|
||||
_imageNames.push_back( ss.str() );
|
||||
@@ -124,7 +124,7 @@ void WorldSelectionList::commit() {
|
||||
|
||||
StringVector lines;
|
||||
lines.push_back(level.name);
|
||||
lines.push_back(minecraft->platform()->getDateString(level.lastPlayed));
|
||||
lines.push_back(minecraft.platform()->getDateString(level.lastPlayed));
|
||||
lines.push_back(level.id);
|
||||
lines.push_back(LevelSettings::gameTypeToString(level.gameType));
|
||||
_descriptions.push_back(lines);
|
||||
@@ -247,19 +247,19 @@ void SelectWorldScreen::buttonClicked(Button* button)
|
||||
// open in-game world-creation screen instead of using platform dialog
|
||||
if (!_hasStartedLevel) {
|
||||
std::string name = getUniqueLevelName("world");
|
||||
minecraft->setScreen(new SimpleChooseLevelScreen(name));
|
||||
minecraft.setScreen(new SimpleChooseLevelScreen(name));
|
||||
}
|
||||
}
|
||||
if (button->id == bDelete.id) {
|
||||
if (isIndexValid(worldsList->selectedItem)) {
|
||||
LevelSummary level = worldsList->levels[worldsList->selectedItem];
|
||||
LOGI("level: %s, %s\n", level.id.c_str(), level.name.c_str());
|
||||
minecraft->setScreen( new DeleteWorldScreen(level) );
|
||||
minecraft.setScreen( new DeleteWorldScreen(level) );
|
||||
}
|
||||
}
|
||||
if (button->id == bBack.id) {
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.cancelLocateMultiplayer();
|
||||
minecraft.screenChooser().setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
if (button->id == bWorldView.id) {
|
||||
// Try to "click" the item in the middle
|
||||
@@ -271,8 +271,8 @@ bool SelectWorldScreen::handleBackEvent(bool isDown)
|
||||
{
|
||||
if (!isDown)
|
||||
{
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.cancelLocateMultiplayer();
|
||||
minecraft.screenChooser().setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -291,9 +291,9 @@ void SelectWorldScreen::tick()
|
||||
worldsList->tick();
|
||||
|
||||
if (worldsList->hasPickedLevel) {
|
||||
minecraft->selectLevel(worldsList->pickedLevel.id, worldsList->pickedLevel.name, LevelSettings::None());
|
||||
minecraft->hostMultiplayer();
|
||||
minecraft->setScreen(new ProgressScreen());
|
||||
minecraft.selectLevel(worldsList->pickedLevel.id, worldsList->pickedLevel.name, LevelSettings::None());
|
||||
minecraft.hostMultiplayer();
|
||||
minecraft.setScreen(new ProgressScreen());
|
||||
_hasStartedLevel = true;
|
||||
return;
|
||||
}
|
||||
@@ -379,7 +379,7 @@ void SelectWorldScreen::render( int xm, int ym, float a )
|
||||
//Performance::watches.get("sws-screen").stop();
|
||||
|
||||
//Performance::watches.get("sws-string").start();
|
||||
drawCenteredString(minecraft->font, "Select world", width / 2, 8, 0xffffffff);
|
||||
drawCenteredString(minecraft.font(), "Select world", width / 2, 8, 0xffffffff);
|
||||
//Performance::watches.get("sws-string").stop();
|
||||
|
||||
//Performance::watches.get("sws-full").stop();
|
||||
@@ -388,7 +388,7 @@ void SelectWorldScreen::render( int xm, int ym, float a )
|
||||
|
||||
void SelectWorldScreen::loadLevelSource()
|
||||
{
|
||||
LevelStorageSource* levelSource = minecraft->getLevelSource();
|
||||
LevelStorageSource* levelSource = minecraft.getLevelSource();
|
||||
levelSource->getLevelList(levels);
|
||||
std::sort(levels.begin(), levels.end());
|
||||
|
||||
@@ -438,9 +438,9 @@ void SelectWorldScreen::mouseWheel(int dx, int dy, int xm, int ym)
|
||||
void SelectWorldScreen::keyPressed( int eventKey )
|
||||
{
|
||||
if (bWorldView.selected) {
|
||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_RIGHT))
|
||||
if (eventKey == minecraft.options().getIntValue(OPTIONS_KEY_RIGHT))
|
||||
worldsList->stepLeft();
|
||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_LEFT))
|
||||
if (eventKey == minecraft.options().getIntValue(OPTIONS_KEY_LEFT))
|
||||
worldsList->stepRight();
|
||||
}
|
||||
|
||||
@@ -462,8 +462,8 @@ DeleteWorldScreen::DeleteWorldScreen(const LevelSummary& level)
|
||||
void DeleteWorldScreen::postResult( bool isOk )
|
||||
{
|
||||
if (isOk) {
|
||||
LevelStorageSource* storageSource = minecraft->getLevelSource();
|
||||
LevelStorageSource* storageSource = minecraft.getLevelSource();
|
||||
storageSource->deleteLevel(_level.id);
|
||||
}
|
||||
minecraft->screenChooser.setScreen(SCREEN_SELECTWORLD);
|
||||
minecraft.screenChooser().setScreen(SCREEN_SELECTWORLD);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "ScreenChooser.hpp"
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "client/gui/components/ImageButton.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "world/level/LevelSettings.hpp"
|
||||
#include "platform/time.hpp"
|
||||
#include "platform/input/Keyboard.hpp"
|
||||
@@ -56,7 +56,7 @@ void SimpleChooseLevelScreen::init()
|
||||
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
|
||||
bBack->setImageDef(def, true);
|
||||
}
|
||||
if (/* minecraft->useTouchscreen() */ true) {
|
||||
if (/* minecraft.useTouchscreen() */ true) {
|
||||
bGamemode = new Touch::TButton(1, "Survival mode");
|
||||
bCheats = new Touch::TButton(4, "Cheats: Off");
|
||||
bCreate = new Touch::TButton(3, "Create");
|
||||
@@ -155,11 +155,11 @@ void SimpleChooseLevelScreen::render( int xm, int ym, float a )
|
||||
modeDesc = "Unlimited resources and flying";
|
||||
}
|
||||
if (modeDesc) {
|
||||
drawCenteredString(minecraft->font, modeDesc, width / 2, bGamemode->y + bGamemode->height + 4, 0xffcccccc);
|
||||
drawCenteredString(minecraft.font(), modeDesc, 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);
|
||||
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);
|
||||
glDisable2(GL_BLEND);
|
||||
@@ -231,22 +231,22 @@ void SimpleChooseLevelScreen::buttonClicked( Button* button )
|
||||
}
|
||||
std::string levelId = getUniqueLevelName(tLevelName.text);
|
||||
LevelSettings settings(seed, gamemode, cheatsEnabled);
|
||||
minecraft->selectLevel(levelId, levelId, settings);
|
||||
minecraft->hostMultiplayer();
|
||||
minecraft->setScreen(new ProgressScreen());
|
||||
minecraft.selectLevel(levelId, levelId, settings);
|
||||
minecraft.hostMultiplayer();
|
||||
minecraft.setScreen(new ProgressScreen());
|
||||
hasChosen = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (button == bBack) {
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleChooseLevelScreen::keyPressed(int eventKey)
|
||||
{
|
||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
return;
|
||||
}
|
||||
// let base class handle navigation and text box keys
|
||||
@@ -255,6 +255,6 @@ void SimpleChooseLevelScreen::keyPressed(int eventKey)
|
||||
|
||||
bool SimpleChooseLevelScreen::handleBackEvent(bool isDown) {
|
||||
if (!isDown)
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "client/gui/Font.hpp"
|
||||
#include "client/gui/components/ScrolledSelectionList.hpp"
|
||||
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "AppPlatform.hpp"
|
||||
#include "LicenseCodes.hpp"
|
||||
@@ -38,7 +38,7 @@ void StartMenuScreen::init()
|
||||
{
|
||||
bJoin.active = bHost.active = bOptions.active = true;
|
||||
|
||||
if (minecraft->options.getStringValue(OPTIONS_USERNAME).empty()) {
|
||||
if (minecraft.options().getStringValue(OPTIONS_USERNAME).empty()) {
|
||||
return; // tick() will redirect to UsernameScreen
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void StartMenuScreen::init()
|
||||
// always show base version string, suffix was previously added for Android builds
|
||||
std::string versionString = Common::getGameVersionString();
|
||||
|
||||
std::string _username = minecraft->options.getStringValue(OPTIONS_USERNAME);
|
||||
std::string _username = minecraft.options().getStringValue(OPTIONS_USERNAME);
|
||||
if (_username.empty()) _username = "unknown";
|
||||
|
||||
username = "Username: " + _username;
|
||||
@@ -117,23 +117,23 @@ void StartMenuScreen::buttonClicked(Button* button) {
|
||||
if (button->id == bHost.id)
|
||||
{
|
||||
#if defined(DEMO_MODE) || defined(APPLE_DEMO_PROMOTION)
|
||||
minecraft->setScreen( new SimpleChooseLevelScreen("_DemoLevel") );
|
||||
minecraft.setScreen( new SimpleChooseLevelScreen("_DemoLevel") );
|
||||
#else
|
||||
minecraft->screenChooser.setScreen(SCREEN_SELECTWORLD);
|
||||
minecraft.screenChooser.setScreen(SCREEN_SELECTWORLD);
|
||||
#endif
|
||||
}
|
||||
if (button->id == bJoin.id)
|
||||
{
|
||||
minecraft->locateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_JOINGAME);
|
||||
minecraft.locateMultiplayer();
|
||||
minecraft.screenChooser.setScreen(SCREEN_JOINGAME);
|
||||
}
|
||||
if (button->id == bOptions.id)
|
||||
{
|
||||
minecraft->setScreen(new OptionsScreen());
|
||||
minecraft.setScreen(new OptionsScreen());
|
||||
}
|
||||
if (button == &bQuit)
|
||||
{
|
||||
minecraft->quit();
|
||||
minecraft.quit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,14 +147,14 @@ void StartMenuScreen::render( int xm, int ym, float a )
|
||||
drawString(font, username, 2, 2, 0xffffffff);
|
||||
|
||||
#if defined(RPI)
|
||||
TextureId id = minecraft->textures->loadTexture("gui/pi_title.png");
|
||||
TextureId id = minecraft.textures().loadTexture("gui/pi_title.png");
|
||||
#else
|
||||
TextureId id = minecraft->textures->loadTexture("gui/title.png");
|
||||
TextureId id = minecraft.textures().loadTexture("gui/title.png");
|
||||
#endif
|
||||
const TextureData* data = minecraft->textures->getTemporaryTextureData(id);
|
||||
const TextureData* data = minecraft.textures().getTemporaryTextureData(id);
|
||||
|
||||
if (data) {
|
||||
minecraft->textures->bind(id);
|
||||
minecraft.textures().bind(id);
|
||||
|
||||
const float x = (float)width / 2;
|
||||
const float y = height/16;
|
||||
@@ -175,23 +175,23 @@ void StartMenuScreen::render( int xm, int ym, float a )
|
||||
}
|
||||
|
||||
#if defined(RPI)
|
||||
if (Textures::isTextureIdValid(minecraft->textures->loadAndBindTexture("gui/logo/raknet_high_72.png")))
|
||||
if (Textures::isTextureIdValid(minecraft.textures().loadAndBindTexture("gui/logo/raknet_high_72.png")))
|
||||
blit(0, height - 12, 0, 0, 43, 12, 256, 72+72);
|
||||
#endif
|
||||
|
||||
drawString(font, version, width - font->width(version) - 2, height - 10, 0xffcccccc);//0x666666);
|
||||
drawString(font, version, width - font.width(version) - 2, height - 10, 0xffcccccc);//0x666666);
|
||||
drawString(font, copyright, 2, height - 20, 0xffffff);
|
||||
glEnable2(GL_BLEND);
|
||||
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
if (Textures::isTextureIdValid(minecraft->textures->loadAndBindTexture("gui/logo/github.png")))
|
||||
if (Textures::isTextureIdValid(minecraft.textures().loadAndBindTexture("gui/logo/github.png")))
|
||||
blit(2, height - 10, 0, 0, 8, 8, 256, 256);
|
||||
{
|
||||
std::string txt = "Kolyah35/minecraft-pe-0.6.1";
|
||||
float wtxt = font->width(txt);
|
||||
float wtxt = font.width(txt);
|
||||
Gui::drawColoredString(font, txt, 12, height - 10, 255);
|
||||
// underline link
|
||||
float y0 = height - 10 + font->lineHeight - 1;
|
||||
float y0 = height - 10 + font.lineHeight - 1;
|
||||
this->fill(12, (int)y0, 12 + (int)wtxt, (int)(y0 + 1), 0xffffffff);
|
||||
}
|
||||
|
||||
@@ -201,16 +201,16 @@ void StartMenuScreen::render( int xm, int ym, float a )
|
||||
|
||||
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 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");
|
||||
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();
|
||||
minecraft.quit();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "TextEditScreen.hpp"
|
||||
#include "world/level/tile/entity/SignTileEntity.hpp"
|
||||
#include "AppPlatform.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/renderer/tileentity/TileEntityRenderDispatcher.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
@@ -18,7 +18,7 @@ TextEditScreen::~TextEditScreen() {
|
||||
}
|
||||
void TextEditScreen::init() {
|
||||
super::init();
|
||||
minecraft->platform()->showKeyboard();
|
||||
minecraft.platform()->showKeyboard();
|
||||
isShowingKeyboard = true;
|
||||
ImageDef def;
|
||||
def.name = "gui/spritesheet.png";
|
||||
@@ -41,9 +41,9 @@ void TextEditScreen::setupPositions() {
|
||||
bool TextEditScreen::handleBackEvent( bool isDown ) {
|
||||
sign->setChanged();
|
||||
Packet* signUpdatePacket = sign->getUpdatePacket();
|
||||
minecraft->raknetInstance->send(signUpdatePacket);
|
||||
minecraft->platform()->hideKeyboard();
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.raknetInstance->send(signUpdatePacket);
|
||||
minecraft.platform()->hideKeyboard();
|
||||
minecraft.setScreen(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -59,17 +59,17 @@ void TextEditScreen::render( int xm, int ym, float a ) {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrthof(0.0f, (float)minecraft->width, (float)minecraft->height, 0, -1, 1);
|
||||
glOrthof(0.0f, (float)minecraft.getScreenWidth(), (float)minecraft.getScreenHeight(), 0, -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
minecraft->textures->loadAndBindTexture("item/sign.png");
|
||||
minecraft.textures().loadAndBindTexture("item/sign.png");
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
|
||||
static float minUV[] = {0.03126f, 0.06249f};
|
||||
static float maxUV[] = {0.39063f, 0.4374f};
|
||||
float scale = ((minecraft->height / 2) / 32) * 0.9f;
|
||||
float scale = ((minecraft.getScreenHeight() / 2) / 32) * 0.9f;
|
||||
|
||||
glTranslatef(minecraft->width / 2.0f, 5.0f, 0.0f);
|
||||
glTranslatef(minecraft.getScreenWidth() / 2.0f, 5.0f, 0.0f);
|
||||
glScalef2(scale,scale,1);
|
||||
t.begin(GL_QUADS);
|
||||
t.vertexUV(-32, 0, 0.0f,minUV[0],minUV[1]);
|
||||
@@ -88,13 +88,13 @@ void TextEditScreen::render( int xm, int ym, float a ) {
|
||||
std::string msg = sign->messages[i];
|
||||
if (i == sign->selectedLine && msg.length() < 14) {
|
||||
std::string s = "> " + msg + " <";
|
||||
font->draw(s, -(float)font->width(s) / 2.0f, 10.0f * i, 0xFF000000, false);
|
||||
font.draw(s, -(float)font.width(s) / 2.0f, 10.0f * i, 0xFF000000, false);
|
||||
} else {
|
||||
font->draw(msg, -(float)font->width(msg) / 2.0f, 10.0f * i, 0xFF000000, false);
|
||||
font.draw(msg, -(float)font.width(msg) / 2.0f, 10.0f * i, 0xFF000000, false);
|
||||
}
|
||||
}
|
||||
sign->selectedLine = -1;
|
||||
//font->draw("Hej", minecraft->width / 2, 100, 0xFFFFFFFF, false);
|
||||
//font.draw("Hej", minecraft.getScreenWidth() / 2, 100, 0xFFFFFFFF, false);
|
||||
|
||||
glPopMatrix();
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
@@ -13,10 +13,10 @@ selectedItem(0)
|
||||
|
||||
void UploadPhotoScreen::init()
|
||||
{
|
||||
int currentSelection = minecraft->player->inventory->getSelectedItemId();
|
||||
int currentSelection = minecraft.player()->inventory->getSelectedItemId();
|
||||
for (int i = 0; i < Inventory::INVENTORY_SIZE; i++)
|
||||
{
|
||||
if (currentSelection == minecraft->player->inventory->getSelectionSlotItemId(i + Inventory::SELECTION_SIZE))
|
||||
if (currentSelection == minecraft.player()->inventory->getSelectionSlotItemId(i + Inventory::SELECTION_SIZE))
|
||||
{
|
||||
selectedItem = i;
|
||||
break;
|
||||
@@ -31,7 +31,7 @@ void UploadPhotoScreen::renderSlots()
|
||||
|
||||
blitOffset = -90;
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/gui.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||
for (int r = 0; r < Inventory::INVENTORY_ROWS; r++)
|
||||
{
|
||||
blit(width / 2 - 182 / 2, height - 22 * 3 - 22 * r, 0, 0, 182, 22);
|
||||
@@ -56,7 +56,7 @@ void UploadPhotoScreen::renderSlots()
|
||||
|
||||
void UploadPhotoScreen::renderSlot(int slot, int x, int y, float a)
|
||||
{
|
||||
int itemId = minecraft->player->inventory->getSelectionSlotItemId(slot);
|
||||
int itemId = minecraft.player()->inventory->getSelectionSlotItemId(slot);
|
||||
if (itemId < 0) return;
|
||||
|
||||
const bool fancy = false;
|
||||
@@ -68,7 +68,7 @@ void UploadPhotoScreen::renderSlot(int slot, int x, int y, float a)
|
||||
Tile* tile = Tile::tiles[itemId];
|
||||
if (tile == NULL) return;
|
||||
|
||||
minecraft->textures->loadAndBindTexture("terrain.png");
|
||||
minecraft.textures().loadAndBindTexture("terrain.png");
|
||||
|
||||
int textureId = tile->getTexture(2, 0);
|
||||
blit(x, y, textureId % 16 * 16, textureId / 16 * 16, 16, 16);
|
||||
@@ -82,7 +82,7 @@ void UploadPhotoScreen::keyPressed(int eventKey)
|
||||
int selX = selectedItem % Inventory::SELECTION_SIZE;
|
||||
int selY = selectedItem / Inventory::SELECTION_SIZE;
|
||||
|
||||
Options& o = minecraft->options;
|
||||
Options& o = minecraft.options;
|
||||
if (eventKey == o.keyLeft.key && selX > 0)
|
||||
{
|
||||
selectedItem -= 1;
|
||||
@@ -130,7 +130,7 @@ void UploadPhotoScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||
if (slot >= 0 && slot < Inventory::INVENTORY_SIZE)
|
||||
{
|
||||
selectedItem = slot;
|
||||
//minecraft->soundEngine->playUI("random.click", 1, 1);
|
||||
//minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ void UploadPhotoScreen::mouseReleased(int x, int y, int buttonNum)
|
||||
|
||||
void UploadPhotoScreen::selectSlotAndClose()
|
||||
{
|
||||
Inventory* inventory = minecraft->player->inventory;
|
||||
Inventory* inventory = minecraft.player()->inventory;
|
||||
|
||||
int itemId = inventory->getSelectionSlotItemId(selectedItem + Inventory::SELECTION_SIZE);
|
||||
int i = 0;
|
||||
@@ -170,8 +170,8 @@ void UploadPhotoScreen::selectSlotAndClose()
|
||||
inventory->setSelectionSlotItemId(0, itemId);
|
||||
inventory->selectSlot(0);
|
||||
|
||||
minecraft->soundEngine->playUI("random.click", 1, 1);
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||
minecraft.setScreen(NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "UsernameScreen.hpp"
|
||||
#include "StartMenuScreen.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/gui/Font.hpp"
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "platform/input/Keyboard.hpp"
|
||||
@@ -66,15 +66,15 @@ void UsernameScreen::keyPressed(int eventKey)
|
||||
|
||||
void UsernameScreen::removed()
|
||||
{
|
||||
minecraft->platform()->hideKeyboard();
|
||||
minecraft.platform()->hideKeyboard();
|
||||
}
|
||||
|
||||
void UsernameScreen::buttonClicked(Button* button)
|
||||
{
|
||||
if (button == &_btnDone && !tUsername.text.empty()) {
|
||||
minecraft->options.set(OPTIONS_USERNAME, tUsername.text);
|
||||
minecraft->options.save();
|
||||
minecraft->setScreen(NULL); // goes to StartMenuScreen
|
||||
minecraft.options().set(OPTIONS_USERNAME, tUsername.text);
|
||||
minecraft.options().save();
|
||||
minecraft.setScreen(NULL); // goes to StartMenuScreen
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "client/gui/screens/touch/TouchStartMenuScreen.hpp"
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/gui/components/NinePatch.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||
@@ -37,10 +37,10 @@ public:
|
||||
statePressed(statePressed)
|
||||
{}
|
||||
|
||||
void renderBg(Minecraft* minecraft, int xm, int ym) {
|
||||
void renderBg(MinecraftClient& minecraft, int xm, int ym) {
|
||||
//fill(x+1, y+1, x+w-1, y+h-1, 0xff999999);
|
||||
|
||||
bool hovered = active && (minecraft->useTouchscreen()?
|
||||
bool hovered = active && (minecraft.useTouchscreen()?
|
||||
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||
|
||||
if (hovered || *selectedPtr == this)
|
||||
@@ -103,13 +103,13 @@ void PaneCraftingScreen::init() {
|
||||
btnClose.setImageDef(def, true);
|
||||
btnClose.scaleWhenPressed = false;
|
||||
|
||||
btnCraft.init(minecraft->textures);
|
||||
btnCraft.init(minecraft.textures);
|
||||
|
||||
buttons.push_back(&btnCraft);
|
||||
buttons.push_back(&btnClose);
|
||||
|
||||
// GUI patches
|
||||
NinePatchFactory builder(minecraft->textures, "gui/spritesheet.png");
|
||||
NinePatchFactory builder(minecraft.textures() "gui/spritesheet.png");
|
||||
|
||||
guiBackground = builder.createSymmetrical(IntRectangle(0, 0, 16, 16), 4, 4);
|
||||
guiPaneFrame = builder.createSymmetrical(IntRectangle(0, 20, 8, 8), 1, 2)->setExcluded(1 << 4);
|
||||
@@ -230,7 +230,7 @@ void PaneCraftingScreen::render(int xm, int ym, float a) {
|
||||
CItem::ReqItem& req = currentItem->neededItems[i];
|
||||
reqItem = req.item;
|
||||
if (reqItem.getAuxValue() == -1) reqItem.setAuxValue(0);
|
||||
ItemRenderer::renderGuiItem(NULL, minecraft->textures, &reqItem, xx, yy, 16, 16, true);
|
||||
ItemRenderer::renderGuiItem(NULL, minecraft.textures() &reqItem, xx, yy, 16, 16, true);
|
||||
}
|
||||
t.endOverrideAndDraw();
|
||||
|
||||
@@ -251,17 +251,17 @@ void PaneCraftingScreen::render(int xm, int ym, float a) {
|
||||
|
||||
buf[bufIndex] = 0;
|
||||
if (req.enough())
|
||||
minecraft->font->drawShadow(buf, xx, yy, rgbActive);
|
||||
minecraft.font()->drawShadow(buf, xx, yy, rgbActive);
|
||||
else {
|
||||
minecraft->font->draw(buf, xx+1, yy+1, rgbInactiveShadow);
|
||||
minecraft->font->draw(buf, xx, yy, rgbInactive);
|
||||
minecraft.font()->draw(buf, xx+1, yy+1, rgbInactiveShadow);
|
||||
minecraft.font()->draw(buf, xx, yy, rgbInactive);
|
||||
}
|
||||
}
|
||||
t.resetScale();
|
||||
t.endOverrideAndDraw();
|
||||
|
||||
//minecraft->font->drawWordWrap(currentItemDesc, rightBx + 2, (float)btnCraft.y + btnCraft.h + 6, descFrameWidth-4, rgbActive);
|
||||
minecraft->font->drawWordWrap(currentItemDesc, (float)btnCraft.x, (float)(btnCraft.y + btnCraft.height + 6), (float)btnCraft.width, rgbActive);
|
||||
//minecraft.font()->drawWordWrap(currentItemDesc, rightBx + 2, (float)btnCraft.y + btnCraft.h + 6, descFrameWidth-4, rgbActive);
|
||||
minecraft.font()->drawWordWrap(currentItemDesc, (float)btnCraft.x, (float)(btnCraft.y + btnCraft.height + 6), (float)btnCraft.width, rgbActive);
|
||||
}
|
||||
//glDisable2(GL_ALPHA_TEST);
|
||||
}
|
||||
@@ -271,7 +271,7 @@ void PaneCraftingScreen::buttonClicked(Button* button) {
|
||||
craftSelectedItem();
|
||||
|
||||
if (button == &btnClose)
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.setScreen(NULL);
|
||||
|
||||
// Did we click a category?
|
||||
if (button->id >= 100 && button->id < 200) {
|
||||
@@ -311,8 +311,8 @@ static bool sortCanCraftPredicate(const CItem* a, const CItem* b) {
|
||||
void PaneCraftingScreen::recheckRecipes() {
|
||||
ItemPack ip;
|
||||
|
||||
if (minecraft->player && minecraft->player->inventory) {
|
||||
Inventory* inv = (minecraft->player)->inventory;
|
||||
if (minecraft.player() && minecraft.player()->inventory) {
|
||||
Inventory* inv = (minecraft.player())->inventory;
|
||||
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < inv->getContainerSize(); ++i) {
|
||||
if (ItemInstance* item = inv->getItem(i))
|
||||
@@ -404,8 +404,8 @@ void PaneCraftingScreen::onItemSelected(int buttonIndex, CItem* item) {
|
||||
const int NumCategoryItems = _categories[buttonIndex].size();
|
||||
|
||||
if (pane) delete pane;
|
||||
pane = new ItemPane(this, minecraft->textures, paneRect, NumCategoryItems, height, minecraft->height);
|
||||
pane->f = minecraft->font;
|
||||
pane = new ItemPane(this, minecraft.textures() paneRect, NumCategoryItems, height, minecraft.getScreenHeight());
|
||||
pane->f = minecraft.font();
|
||||
|
||||
currentCategory = buttonIndex;
|
||||
}
|
||||
@@ -422,8 +422,8 @@ void PaneCraftingScreen::clearCategoryItems()
|
||||
void PaneCraftingScreen::keyPressed( int eventKey )
|
||||
{
|
||||
if (eventKey == Keyboard::KEY_ESCAPE || eventKey == Keyboard::KEY_E) {
|
||||
minecraft->setScreen(NULL);
|
||||
//minecraft->grabMouse();
|
||||
minecraft.setScreen(NULL);
|
||||
//minecraft.grabMouse();
|
||||
} else {
|
||||
super::keyPressed(eventKey);
|
||||
}
|
||||
@@ -438,7 +438,7 @@ void PaneCraftingScreen::craftSelectedItem()
|
||||
|
||||
ItemInstance resultItem = currentItem->item;
|
||||
|
||||
if (minecraft->player) {
|
||||
if (minecraft.player()) {
|
||||
// Remove all items required for the recipe and ...
|
||||
for (unsigned int i = 0; i < currentItem->neededItems.size(); ++i) {
|
||||
CItem::ReqItem& req = currentItem->neededItems[i];
|
||||
@@ -451,18 +451,18 @@ void PaneCraftingScreen::craftSelectedItem()
|
||||
if (Tile::sandStone->id == req.item.id
|
||||
&& Recipe::ANY_AUX_VALUE == req.item.getAuxValue()) {
|
||||
toRemove.setAuxValue(0);
|
||||
toRemove.count = minecraft->player->inventory->removeResource(toRemove, true);
|
||||
toRemove.count = minecraft.player()->inventory->removeResource(toRemove, true);
|
||||
toRemove.setAuxValue(Recipe::ANY_AUX_VALUE);
|
||||
}
|
||||
|
||||
if (toRemove.count > 0) {
|
||||
minecraft->player->inventory->removeResource(toRemove);
|
||||
minecraft.player()->inventory->removeResource(toRemove);
|
||||
}
|
||||
}
|
||||
// ... add the new one! (in this order, to fill empty slots better)
|
||||
// if it doesn't fit, throw it on the ground!
|
||||
if (!minecraft->player->inventory->add(&resultItem)) {
|
||||
minecraft->player->drop(new ItemInstance(resultItem), false);
|
||||
if (!minecraft.player()->inventory->add(&resultItem)) {
|
||||
minecraft.player()->drop(new ItemInstance(resultItem), false);
|
||||
}
|
||||
|
||||
recheckRecipes();
|
||||
@@ -541,12 +541,12 @@ IntRectangle CraftButton::getItemPos( int i )
|
||||
return IntRectangle();
|
||||
}
|
||||
|
||||
void CraftButton::renderBg(Minecraft* minecraft, int xm, int ym) {
|
||||
void CraftButton::renderBg(MinecraftClient& minecraft, int xm, int ym) {
|
||||
if (!bg || !bgSelected)
|
||||
return;
|
||||
//fill(x+1, y+1, x+w-1, y+h-1, 0xff999999);
|
||||
|
||||
bool hovered = active && (minecraft->useTouchscreen()?
|
||||
bool hovered = active && (minecraft.useTouchscreen()?
|
||||
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||
|
||||
if (hovered || selected)
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
|
||||
void setNumItems(int i) { numItems = i; }
|
||||
IntRectangle getItemPos(int i);
|
||||
void renderBg(Minecraft* minecraft, int xm, int ym);
|
||||
void renderBg(MinecraftClient& minecraft, int xm, int ym);
|
||||
private:
|
||||
NinePatchLayer* bg;
|
||||
NinePatchLayer* bgSelected;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/sound/SoundEngine.hpp"
|
||||
#include "world/entity/player/Inventory.hpp"
|
||||
#include "platform/input/Mouse.hpp"
|
||||
@@ -69,7 +69,7 @@ IngameBlockSelectionScreen::~IngameBlockSelectionScreen()
|
||||
|
||||
void IngameBlockSelectionScreen::init()
|
||||
{
|
||||
Inventory* inventory = minecraft->player->inventory;
|
||||
Inventory* inventory = minecraft.player()->inventory;
|
||||
|
||||
//const int itemWidth = 2 * BorderPixels +
|
||||
|
||||
@@ -110,7 +110,7 @@ void IngameBlockSelectionScreen::init()
|
||||
|
||||
buttons.push_back(&bHeader);
|
||||
buttons.push_back(&bDone);
|
||||
if (!minecraft->isCreativeMode()) {
|
||||
if (!minecraft.isCreativeMode()) {
|
||||
buttons.push_back(&bCraft);
|
||||
buttons.push_back(&bArmor);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ void IngameBlockSelectionScreen::setupPositions() {
|
||||
bCraft.width = bArmor.width = 48;
|
||||
bArmor.x = bCraft.width;
|
||||
|
||||
if (minecraft->isCreativeMode()) {
|
||||
if (minecraft.isCreativeMode()) {
|
||||
bHeader.x = 0;
|
||||
bHeader.width = width;// - bDone.w;
|
||||
bHeader.xText = width/2; // Center of the screen
|
||||
@@ -134,14 +134,14 @@ void IngameBlockSelectionScreen::setupPositions() {
|
||||
}
|
||||
|
||||
clippingArea.x = 0;
|
||||
clippingArea.w = minecraft->width;
|
||||
clippingArea.w = minecraft.getScreenWidth();
|
||||
clippingArea.y = 0;
|
||||
clippingArea.h = (int)(Gui::GuiScale * 24);
|
||||
}
|
||||
|
||||
void IngameBlockSelectionScreen::removed()
|
||||
{
|
||||
minecraft->gui.inventoryUpdated();
|
||||
minecraft.gui().inventoryUpdated();
|
||||
}
|
||||
|
||||
int IngameBlockSelectionScreen::getSlotPosX(int slotX) {
|
||||
@@ -166,7 +166,7 @@ void IngameBlockSelectionScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||
|
||||
void IngameBlockSelectionScreen::mouseReleased(int x, int y, int buttonNum) {
|
||||
if (_pendingClose && _blockList->_clickArea->isInside((float)x, (float)y))
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.setScreen(NULL);
|
||||
else
|
||||
super::mouseReleased(x, y, buttonNum);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ void IngameBlockSelectionScreen::mouseWheel(int dx, int dy, int xm, int ym)
|
||||
|
||||
bool IngameBlockSelectionScreen::addItem(const InventoryPane* pane, int itemId)
|
||||
{
|
||||
Inventory* inventory = minecraft->player->inventory;
|
||||
Inventory* inventory = minecraft.player()->inventory;
|
||||
itemId += Inventory::MAX_SELECTION_SIZE;
|
||||
|
||||
if (!inventory->getItem(itemId))
|
||||
@@ -201,13 +201,13 @@ bool IngameBlockSelectionScreen::addItem(const InventoryPane* pane, int itemId)
|
||||
|
||||
inventory->selectSlot(0);
|
||||
#ifdef __APPLE__
|
||||
minecraft->soundEngine->playUI("random.pop", 0.3f, 0.3f);//1.0f + 0.2f*(Mth::random()-Mth::random()));
|
||||
minecraft.soundEngine()->playUI("random.pop", 0.3f, 0.3f);//1.0f + 0.2f*(Mth::random()-Mth::random()));
|
||||
#else
|
||||
minecraft->soundEngine->playUI("random.pop2", 1.0f, 0.3f);//1.0f + 0.2f*(Mth::random()-Mth::random()));
|
||||
minecraft.soundEngine()->playUI("random.pop2", 1.0f, 0.3f);//1.0f + 0.2f*(Mth::random()-Mth::random()));
|
||||
#endif
|
||||
|
||||
// Flash the selected gui item
|
||||
minecraft->gui.flashSlot(inventory->selected);
|
||||
minecraft.gui().flashSlot(inventory->selected);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ void IngameBlockSelectionScreen::render( int xm, int ym, float a )
|
||||
// render frame
|
||||
IntRectangle& bbox = _blockList->rect;
|
||||
Tesselator::instance.colorABGR(0xffffffff);
|
||||
minecraft->textures->loadAndBindTexture("gui/itemframe.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/itemframe.png");
|
||||
glEnable2(GL_BLEND);
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -245,31 +245,31 @@ void IngameBlockSelectionScreen::renderDemoOverlay() {
|
||||
|
||||
const int centerX = (getSlotPosX(4) + getSlotPosX(5)) / 2;
|
||||
const int centerY = (getSlotPosY(0) + getSlotPosY(1)) / 2 + 5;
|
||||
drawCenteredString(minecraft->font, demoVersionString, centerX, centerY, 0xffffffff);
|
||||
drawCenteredString(minecraft.font(), demoVersionString, centerX, centerY, 0xffffffff);
|
||||
#endif /*DEMO_MODE*/
|
||||
}
|
||||
|
||||
void IngameBlockSelectionScreen::buttonClicked(Button* button) {
|
||||
if (button->id == bDone.id)
|
||||
minecraft->setScreen(NULL);
|
||||
minecraft.setScreen(NULL);
|
||||
|
||||
if (button->id == bMenu.id)
|
||||
minecraft->screenChooser.setScreen(SCREEN_PAUSE);
|
||||
minecraft.screenChooser.setScreen(SCREEN_PAUSE);
|
||||
|
||||
if (button->id == bCraft.id)
|
||||
minecraft->setScreen(new WorkbenchScreen(Recipe::SIZE_2X2));
|
||||
minecraft.setScreen(new WorkbenchScreen(Recipe::SIZE_2X2));
|
||||
|
||||
if (button == &bArmor)
|
||||
minecraft->setScreen(new ArmorScreen());
|
||||
minecraft.setScreen(new ArmorScreen());
|
||||
}
|
||||
|
||||
bool IngameBlockSelectionScreen::isAllowed( int slot )
|
||||
{
|
||||
if (slot < 0 || slot >= minecraft->player->inventory->getContainerSize())
|
||||
if (slot < 0 || slot >= minecraft.player()->inventory->getContainerSize())
|
||||
return false;
|
||||
|
||||
#ifdef DEMO_MODE
|
||||
if (slot >= (minecraft->isCreativeMode()? 28 : 27)) return false;
|
||||
if (slot >= (minecraft.isCreativeMode()? 28 : 27)) return false;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@@ -283,8 +283,8 @@ bool IngameBlockSelectionScreen::hasClippingArea( IntRectangle& out )
|
||||
std::vector<const ItemInstance*> IngameBlockSelectionScreen::getItems( const InventoryPane* forPane )
|
||||
{
|
||||
std::vector<const ItemInstance*> out;
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft->player->inventory->getContainerSize(); ++i)
|
||||
out.push_back(minecraft->player->inventory->getItem(i));
|
||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft.player()->inventory->getContainerSize(); ++i)
|
||||
out.push_back(minecraft.player()->inventory->getItem(i));
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "client/gui/screens/StartMenuScreen.hpp"
|
||||
#include "client/gui/screens/ProgressScreen.hpp"
|
||||
#include "client/gui/Font.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/renderer/Textures.hpp"
|
||||
|
||||
namespace Touch {
|
||||
@@ -44,16 +44,16 @@ void AvailableGamesList::renderItem( int i, int x, int y, int h, Tesselator& t )
|
||||
glEnable2(GL_TEXTURE_2D);
|
||||
glColor4f2(1,1,1,1);
|
||||
glEnable2(GL_BLEND);
|
||||
minecraft->textures->loadAndBindTexture("gui/badge/minecon140.png");
|
||||
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(), 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);
|
||||
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);
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ void JoinGameScreen::init()
|
||||
buttons.push_back(&bJoinByIp);
|
||||
buttons.push_back(&bHeader);
|
||||
|
||||
minecraft->raknetInstance->clearServerList();
|
||||
minecraft.raknetInstance->clearServerList();
|
||||
gamesList = new AvailableGamesList(minecraft, width, height);
|
||||
|
||||
#ifdef ANDROID
|
||||
@@ -119,25 +119,25 @@ void JoinGameScreen::buttonClicked(Button* button)
|
||||
if (isIndexValid(gamesList->selectedItem))
|
||||
{
|
||||
PingedCompatibleServer selectedServer = gamesList->copiedServerList[gamesList->selectedItem];
|
||||
minecraft->joinMultiplayer(selectedServer);
|
||||
minecraft.joinMultiplayer(selectedServer);
|
||||
{
|
||||
bJoin.active = false;
|
||||
bBack.active = false;
|
||||
minecraft->setScreen(new ProgressScreen());
|
||||
minecraft.setScreen(new ProgressScreen());
|
||||
}
|
||||
}
|
||||
//minecraft->locateMultiplayer();
|
||||
//minecraft->setScreen(new JoinGameScreen());
|
||||
//minecraft.locateMultiplayer();
|
||||
//minecraft.setScreen(new JoinGameScreen());
|
||||
}
|
||||
if(button->id == bJoinByIp.id) {
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_JOINBYIP);
|
||||
minecraft.cancelLocateMultiplayer();
|
||||
minecraft.screenChooser.setScreen(SCREEN_JOINBYIP);
|
||||
}
|
||||
|
||||
if (button->id == bBack.id)
|
||||
{
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.cancelLocateMultiplayer();
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ bool JoinGameScreen::handleBackEvent(bool isDown)
|
||||
{
|
||||
if (!isDown)
|
||||
{
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.cancelLocateMultiplayer();
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ void JoinGameScreen::tick()
|
||||
|
||||
//gamesList->tick();
|
||||
|
||||
const ServerList& orgServerList = minecraft->raknetInstance->getServerList();
|
||||
const ServerList& orgServerList = minecraft.raknetInstance->getServerList();
|
||||
ServerList serverList;
|
||||
for (unsigned int i = 0; i < orgServerList.size(); ++i)
|
||||
if (orgServerList[i].name.GetLength() > 0)
|
||||
@@ -211,7 +211,7 @@ void JoinGameScreen::tick()
|
||||
|
||||
void JoinGameScreen::render( int xm, int ym, float a )
|
||||
{
|
||||
bool hasNetwork = minecraft->platform()->isNetworkEnabled(true);
|
||||
bool hasNetwork = minecraft.platform()->isNetworkEnabled(true);
|
||||
#ifdef WIN32
|
||||
hasNetwork = hasNetwork && !GetAsyncKeyState(VK_TAB);
|
||||
#endif
|
||||
@@ -225,16 +225,16 @@ void JoinGameScreen::render( int xm, int ym, float a )
|
||||
|
||||
if (hasNetwork) {
|
||||
std::string s = "Scanning for WiFi Games...";
|
||||
drawCenteredString(minecraft->font, s, baseX, 8, 0xffffffff);
|
||||
drawCenteredString(minecraft.font(), s, baseX, 8, 0xffffffff);
|
||||
|
||||
const int textWidth = minecraft->font->width(s);
|
||||
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);
|
||||
drawCenteredString(minecraft.font(), spinnerTexts[n], spinnerX, 8, 0xffffffff);
|
||||
} else {
|
||||
drawCenteredString(minecraft->font, "WiFi is disabled", baseX, 8, 0xffffffff);
|
||||
drawCenteredString(minecraft.font(), "WiFi is disabled", baseX, 8, 0xffffffff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "client/gui/components/RolledSelectionListV.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "platform/input/Multitouch.hpp"
|
||||
#include "network/RakNetInstance.hpp"
|
||||
|
||||
@@ -20,7 +20,7 @@ class AvailableGamesList : public RolledSelectionListV
|
||||
friend class JoinGameScreen;
|
||||
|
||||
public:
|
||||
AvailableGamesList(Minecraft* _minecraft, int _width, int _height)
|
||||
AvailableGamesList(MinecraftClient& _minecraft, int _width, int _height)
|
||||
: RolledSelectionListV(_minecraft, _width, _height, 0, _width, 24, _height, 34),
|
||||
selectedItem(-1),
|
||||
startSelected(-1)
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Touch {
|
||||
//
|
||||
// World Selection List
|
||||
//
|
||||
TouchWorldSelectionList::TouchWorldSelectionList( Minecraft* minecraft, int width, int height )
|
||||
TouchWorldSelectionList::TouchWorldSelectionList( MinecraftClient& minecraft, int width, int height )
|
||||
: _height(height),
|
||||
hasPickedLevel(false),
|
||||
pickedIndex(-1),
|
||||
@@ -85,12 +85,12 @@ void TouchWorldSelectionList::renderItem( int i, int x, int y, int h, Tesselator
|
||||
if (i < (int)levels.size()) {
|
||||
// Draw the worlds
|
||||
StringVector v = _descriptions[i];
|
||||
drawString(minecraft->font, v[0].c_str(), TX, TY + 0, textColor);
|
||||
drawString(minecraft->font, v[1].c_str(), TX, TY + 10, textColor2);
|
||||
drawString(minecraft->font, v[2].c_str(), TX, TY + 20, textColor2);
|
||||
drawString(minecraft->font, v[3].c_str(), TX, TY + 30, textColor2);
|
||||
drawString(minecraft.font(), v[0].c_str(), TX, TY + 0, textColor);
|
||||
drawString(minecraft.font(), v[1].c_str(), TX, TY + 10, textColor2);
|
||||
drawString(minecraft.font(), v[2].c_str(), TX, TY + 20, textColor2);
|
||||
drawString(minecraft.font(), v[3].c_str(), TX, TY + 30, textColor2);
|
||||
|
||||
minecraft->textures->loadAndBindTexture(_imageNames[i]);
|
||||
minecraft.textures().loadAndBindTexture(_imageNames[i]);
|
||||
t.color(0.3f, 1.0f, 0.2f);
|
||||
|
||||
//float x0 = (float)x;
|
||||
@@ -106,9 +106,9 @@ void TouchWorldSelectionList::renderItem( int i, int x, int y, int h, Tesselator
|
||||
t.draw();
|
||||
} else {
|
||||
// Draw the "Create new world" icon
|
||||
drawCenteredString(minecraft->font, "Create new", centerx, TY + 12, textColor);
|
||||
drawCenteredString(minecraft.font(), "Create new", centerx, TY + 12, textColor);
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/touchgui.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/touchgui.png");
|
||||
|
||||
const bool selected = _newWorldSelected;
|
||||
|
||||
@@ -164,7 +164,7 @@ void TouchWorldSelectionList::commit() {
|
||||
|
||||
std::stringstream ss;
|
||||
ss << level.name << "/preview.png";
|
||||
TextureId id = Textures::InvalidId;//minecraft->textures->loadTexture(ss.str(), false);
|
||||
TextureId id = Textures::InvalidId;//minecraft.textures().loadTexture(ss.str(), false);
|
||||
|
||||
if (id != Textures::InvalidId) {
|
||||
_imageNames.push_back( ss.str() );
|
||||
@@ -174,7 +174,7 @@ void TouchWorldSelectionList::commit() {
|
||||
|
||||
StringVector lines;
|
||||
lines.push_back(levels[i].name);
|
||||
lines.push_back(minecraft->platform()->getDateString(levels[i].lastPlayed));
|
||||
lines.push_back(minecraft.platform()->getDateString(levels[i].lastPlayed));
|
||||
lines.push_back(levels[i].id);
|
||||
lines.push_back(LevelSettings::gameTypeToString(level.gameType));
|
||||
_descriptions.push_back(lines);
|
||||
@@ -350,19 +350,19 @@ void SelectWorldScreen::buttonClicked(Button* button)
|
||||
if (button->id == bCreate.id) {
|
||||
if (!_hasStartedLevel) {
|
||||
std::string name = getUniqueLevelName("World");
|
||||
minecraft->setScreen(new SimpleChooseLevelScreen(name));
|
||||
minecraft.setScreen(new SimpleChooseLevelScreen(name));
|
||||
}
|
||||
}
|
||||
if (button->id == bDelete.id) {
|
||||
if (isIndexValid(worldsList->selectedItem)) {
|
||||
LevelSummary level = worldsList->levels[worldsList->selectedItem];
|
||||
LOGI("level: %s, %s\n", level.id.c_str(), level.name.c_str());
|
||||
minecraft->setScreen( new TouchDeleteWorldScreen(level) );
|
||||
minecraft.setScreen( new TouchDeleteWorldScreen(level) );
|
||||
}
|
||||
}
|
||||
if (button->id == bBack.id) {
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.cancelLocateMultiplayer();
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
if (button->id == bWorldView.id) {
|
||||
// Try to "click" the item in the middle
|
||||
@@ -374,8 +374,8 @@ bool SelectWorldScreen::handleBackEvent(bool isDown)
|
||||
{
|
||||
if (!isDown)
|
||||
{
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
minecraft.cancelLocateMultiplayer();
|
||||
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -417,19 +417,19 @@ void SelectWorldScreen::tick()
|
||||
std::string levelId = getUniqueLevelName("World");
|
||||
//int seed = Util::hashCode("/r/Minecraft");
|
||||
LevelSettings settings(getEpochTimeS(), GameType::Creative);
|
||||
minecraft->selectLevel(levelId, levelId, settings);
|
||||
minecraft->hostMultiplayer();
|
||||
minecraft->setScreen(new ProgressScreen());
|
||||
minecraft.selectLevel(levelId, levelId, settings);
|
||||
minecraft.hostMultiplayer();
|
||||
minecraft.setScreen(new ProgressScreen());
|
||||
_hasStartedLevel = true;
|
||||
#elif defined(PLATFORM_DESKTOP)
|
||||
std::string name = getUniqueLevelName("World");
|
||||
minecraft->setScreen(new SimpleChooseLevelScreen(name));
|
||||
minecraft.setScreen(new SimpleChooseLevelScreen(name));
|
||||
#else
|
||||
int status = minecraft->platform()->getUserInputStatus();
|
||||
int status = minecraft.platform()->getUserInputStatus();
|
||||
//LOGI("Status is: %d\n", status);
|
||||
if (status > -1) {
|
||||
if (status == 1) {
|
||||
StringVector sv = minecraft->platform()->getUserInput();
|
||||
StringVector sv = minecraft.platform()->getUserInput();
|
||||
|
||||
// Read the level name.
|
||||
// 1) Trim name 2) Remove all bad chars 3) Append '-' chars 'til the name is unique
|
||||
@@ -466,9 +466,9 @@ void SelectWorldScreen::tick()
|
||||
// Start a new level with the given name and seed
|
||||
LOGI("Creating a level with id '%s', name '%s' and seed '%d'\n", levelId.c_str(), levelName.c_str(), seed);
|
||||
LevelSettings settings(seed, isCreative? GameType::Creative : GameType::Survival);
|
||||
minecraft->selectLevel(levelId, levelName, settings);
|
||||
minecraft->hostMultiplayer();
|
||||
minecraft->setScreen(new ProgressScreen());
|
||||
minecraft.selectLevel(levelId, levelName, settings);
|
||||
minecraft.hostMultiplayer();
|
||||
minecraft.setScreen(new ProgressScreen());
|
||||
_hasStartedLevel = true;
|
||||
}
|
||||
_state = _STATE_DEFAULT;
|
||||
@@ -489,11 +489,11 @@ void SelectWorldScreen::tick()
|
||||
if (worldsList->pickedIndex == worldsList->levels.size()) {
|
||||
worldsList->hasPickedLevel = false;
|
||||
std::string name = getUniqueLevelName("World");
|
||||
minecraft->setScreen(new SimpleChooseLevelScreen(name));
|
||||
minecraft.setScreen(new SimpleChooseLevelScreen(name));
|
||||
} else {
|
||||
minecraft->selectLevel(worldsList->pickedLevel.id, worldsList->pickedLevel.name, LevelSettings::None());
|
||||
minecraft->hostMultiplayer();
|
||||
minecraft->setScreen(new ProgressScreen());
|
||||
minecraft.selectLevel(worldsList->pickedLevel.id, worldsList->pickedLevel.name, LevelSettings::None());
|
||||
minecraft.hostMultiplayer();
|
||||
minecraft.setScreen(new ProgressScreen());
|
||||
_hasStartedLevel = true;
|
||||
return;
|
||||
}
|
||||
@@ -533,7 +533,7 @@ void SelectWorldScreen::render( int xm, int ym, float a )
|
||||
Screen::render(xm, ym, a);
|
||||
//Performance::watches.get("sws-screen").stop();
|
||||
|
||||
//minecraft->textures->loadAndBindTexture("gui/selectworld/trash.png");
|
||||
//minecraft.textures().loadAndBindTexture("gui/selectworld/trash.png");
|
||||
|
||||
//Performance::watches.get("sws-string").start();
|
||||
//Performance::watches.get("sws-string").stop();
|
||||
@@ -544,7 +544,7 @@ void SelectWorldScreen::render( int xm, int ym, float a )
|
||||
|
||||
void SelectWorldScreen::loadLevelSource()
|
||||
{
|
||||
LevelStorageSource* levelSource = minecraft->getLevelSource();
|
||||
LevelStorageSource* levelSource = minecraft.getLevelSource();
|
||||
levelSource->getLevelList(levels);
|
||||
std::sort(levels.begin(), levels.end());
|
||||
|
||||
@@ -572,9 +572,9 @@ bool SelectWorldScreen::isInGameScreen() { return true; }
|
||||
void SelectWorldScreen::keyPressed( int eventKey )
|
||||
{
|
||||
if (bWorldView.selected) {
|
||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_LEFT))
|
||||
if (eventKey == minecraft.options().getIntValue(OPTIONS_KEY_LEFT))
|
||||
worldsList->stepLeft();
|
||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_RIGHT))
|
||||
if (eventKey == minecraft.options().getIntValue(OPTIONS_KEY_RIGHT))
|
||||
worldsList->stepRight();
|
||||
}
|
||||
|
||||
@@ -596,10 +596,10 @@ TouchDeleteWorldScreen::TouchDeleteWorldScreen(const LevelSummary& level)
|
||||
void TouchDeleteWorldScreen::postResult( bool isOk )
|
||||
{
|
||||
if (isOk) {
|
||||
LevelStorageSource* storageSource = minecraft->getLevelSource();
|
||||
LevelStorageSource* storageSource = minecraft.getLevelSource();
|
||||
storageSource->deleteLevel(_level.id);
|
||||
}
|
||||
minecraft->screenChooser.setScreen(SCREEN_SELECTWORLD);
|
||||
minecraft.screenChooser.setScreen(SCREEN_SELECTWORLD);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "client/gui/components/ImageButton.hpp"
|
||||
#include "client/gui/components/Button.hpp"
|
||||
#include "client/gui/components/RolledSelectionListH.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "world/level/storage/LevelStorageSource.hpp"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class SelectWorldScreen;
|
||||
class TouchWorldSelectionList : public RolledSelectionListH
|
||||
{
|
||||
public:
|
||||
TouchWorldSelectionList(Minecraft* _minecraft, int _width, int _height);
|
||||
TouchWorldSelectionList(MinecraftClient& _minecraft, int _width, int _height);
|
||||
virtual void tick();
|
||||
void stepLeft();
|
||||
void stepRight();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "client/gui/components/ScrolledSelectionList.hpp"
|
||||
#include "client/gui/components/GuiElement.hpp"
|
||||
|
||||
#include "client/Minecraft.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include "client/renderer/TextureData.hpp"
|
||||
@@ -85,7 +85,7 @@ void StartMenuScreen::init()
|
||||
// always show base version string
|
||||
std::string versionString = Common::getGameVersionString();
|
||||
|
||||
std::string _username = minecraft->options.getStringValue(OPTIONS_USERNAME);
|
||||
std::string _username = minecraft.options().getStringValue(OPTIONS_USERNAME);
|
||||
if (_username.empty()) _username = "unknown";
|
||||
|
||||
username = "Username: " + _username;
|
||||
@@ -127,8 +127,8 @@ void StartMenuScreen::setupPositions() {
|
||||
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;
|
||||
copyrightPosX = width - minecraft.font()->width(copyright) - 1;
|
||||
versionPosX = (width - minecraft.font()->width(version)) / 2;// - minecraft.font()->width(version) - 2;
|
||||
}
|
||||
|
||||
void StartMenuScreen::buttonClicked(::Button* button) {
|
||||
@@ -136,27 +136,27 @@ void StartMenuScreen::buttonClicked(::Button* button) {
|
||||
if (button->id == bHost.id)
|
||||
{
|
||||
#if defined(DEMO_MODE) || defined(APPLE_DEMO_PROMOTION)
|
||||
minecraft->setScreen( new SimpleChooseLevelScreen("_DemoLevel") );
|
||||
minecraft.setScreen( new SimpleChooseLevelScreen("_DemoLevel") );
|
||||
#else
|
||||
minecraft->screenChooser.setScreen(SCREEN_SELECTWORLD);
|
||||
minecraft.screenChooser.setScreen(SCREEN_SELECTWORLD);
|
||||
#endif
|
||||
}
|
||||
if (button->id == bJoin.id)
|
||||
{
|
||||
#ifdef APPLE_DEMO_PROMOTION
|
||||
minecraft->platform()->createUserInput(DialogDefinitions::DIALOG_DEMO_FEATURE_DISABLED);
|
||||
minecraft.platform()->createUserInput(DialogDefinitions::DIALOG_DEMO_FEATURE_DISABLED);
|
||||
#else
|
||||
minecraft->locateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_JOINGAME);
|
||||
minecraft.locateMultiplayer();
|
||||
minecraft.screenChooser.setScreen(SCREEN_JOINGAME);
|
||||
#endif
|
||||
}
|
||||
if (button->id == bOptions.id)
|
||||
{
|
||||
minecraft->setScreen(new OptionsScreen());
|
||||
minecraft.setScreen(new OptionsScreen());
|
||||
}
|
||||
if (button == &bQuit)
|
||||
{
|
||||
minecraft->quit();
|
||||
minecraft.quit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,14 +172,14 @@ void StartMenuScreen::render( int xm, int ym, float a )
|
||||
glEnable2(GL_BLEND);
|
||||
|
||||
#if defined(RPI)
|
||||
TextureId id = minecraft->textures->loadTexture("gui/pi_title.png");
|
||||
TextureId id = minecraft.textures().loadTexture("gui/pi_title.png");
|
||||
#else
|
||||
TextureId id = minecraft->textures->loadTexture("gui/title.png");
|
||||
TextureId id = minecraft.textures().loadTexture("gui/title.png");
|
||||
#endif
|
||||
const TextureData* data = minecraft->textures->getTemporaryTextureData(id);
|
||||
const TextureData* data = minecraft.textures().getTemporaryTextureData(id);
|
||||
|
||||
if (data) {
|
||||
minecraft->textures->bind(id);
|
||||
minecraft.textures().bind(id);
|
||||
|
||||
const float x = (float)width / 2;
|
||||
const float y = 4;
|
||||
@@ -200,7 +200,7 @@ void StartMenuScreen::render( int xm, int ym, float a )
|
||||
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")))
|
||||
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);
|
||||
@@ -212,17 +212,17 @@ void StartMenuScreen::render( int xm, int ym, float a )
|
||||
|
||||
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 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");
|
||||
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();
|
||||
minecraft.quit();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user