mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-04-05 15:03:31 +00:00
Trying to replace pointers with references :v
This commit is contained in:
@@ -142,8 +142,8 @@ void seedMT( unsigned int seed, unsigned int *state, unsigned int *&next, int &l
|
|||||||
// so-- that's why the only change I made is to restrict to odd seeds.
|
// so-- that's why the only change I made is to restrict to odd seeds.
|
||||||
//
|
//
|
||||||
|
|
||||||
register unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
|
unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
|
||||||
register int j;
|
int j;
|
||||||
|
|
||||||
for ( left = 0, *s++ = x, j = N; --j;
|
for ( left = 0, *s++ = x, j = N; --j;
|
||||||
*s++ = ( x *= 69069U ) & 0xFFFFFFFFU )
|
*s++ = ( x *= 69069U ) & 0xFFFFFFFFU )
|
||||||
@@ -154,8 +154,8 @@ void seedMT( unsigned int seed, unsigned int *state, unsigned int *&next, int &l
|
|||||||
|
|
||||||
unsigned int reloadMT( unsigned int *state, unsigned int *&next, int &left )
|
unsigned int reloadMT( unsigned int *state, unsigned int *&next, int &left )
|
||||||
{
|
{
|
||||||
register unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
||||||
register int j;
|
int j;
|
||||||
|
|
||||||
if ( left < -1 )
|
if ( left < -1 )
|
||||||
seedMT( 4357U );
|
seedMT( 4357U );
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ void Minecraft::hostMultiplayer(int port) {
|
|||||||
|
|
||||||
void* Minecraft::prepareLevel_tspawn(void *p_param) {
|
void* Minecraft::prepareLevel_tspawn(void *p_param) {
|
||||||
Minecraft* mc = (Minecraft*) p_param;
|
Minecraft* mc = (Minecraft*) p_param;
|
||||||
mc->generateLevel("Currently not used", mc->level);
|
mc.generateLevel("Currently not used", mc.level);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "Minecraft.hpp"
|
#include "Minecraft.hpp"
|
||||||
#include "client/Options.hpp"
|
#include "client/Options.hpp"
|
||||||
#include "client/gamemode/GameMode.hpp"
|
#include "gamemode/GameMode.hpp"
|
||||||
#include "client/gui/screens/ChatScreen.hpp"
|
#include "client/gui/screens/ChatScreen.hpp"
|
||||||
#include "client/gui/screens/ConsoleScreen.hpp"
|
#include "client/gui/screens/ConsoleScreen.hpp"
|
||||||
#include "client/gui/screens/DeathScreen.hpp"
|
#include "client/gui/screens/DeathScreen.hpp"
|
||||||
@@ -104,7 +104,7 @@ void MinecraftClient::init() {
|
|||||||
|
|
||||||
checkGlError("Init complete");
|
checkGlError("Init complete");
|
||||||
|
|
||||||
screenChooser.setScreen(SCREEN_STARTMENU);
|
m_screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
|
|
||||||
if (options.getBooleanValue(OPTIONS_FIRST_LAUNCH)) {
|
if (options.getBooleanValue(OPTIONS_FIRST_LAUNCH)) {
|
||||||
options.toggle(OPTIONS_FIRST_LAUNCH);
|
options.toggle(OPTIONS_FIRST_LAUNCH);
|
||||||
@@ -321,7 +321,7 @@ void MinecraftClient::onGraphicsReset() {
|
|||||||
|
|
||||||
m_textures.clear();
|
m_textures.clear();
|
||||||
|
|
||||||
font->onGraphicsReset();
|
font.onGraphicsReset();
|
||||||
gui.onGraphicsReset();
|
gui.onGraphicsReset();
|
||||||
|
|
||||||
if (levelRenderer) levelRenderer->onGraphicsReset();
|
if (levelRenderer) levelRenderer->onGraphicsReset();
|
||||||
@@ -532,7 +532,7 @@ void MinecraftClient::tickInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (key == Keyboard::KEY_E) {
|
if (key == Keyboard::KEY_E) {
|
||||||
screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
m_screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getScreen && key == Keyboard::KEY_T && level) {
|
if (!getScreen && key == Keyboard::KEY_T && level) {
|
||||||
@@ -832,7 +832,7 @@ void MinecraftClient::pauseGame(bool isBackPaused) {
|
|||||||
pause = canFreeze;
|
pause = canFreeze;
|
||||||
|
|
||||||
if (getScreen != NULL) return;
|
if (getScreen != NULL) return;
|
||||||
screenChooser.setScreen(isBackPaused? SCREEN_PAUSEPREV : SCREEN_PAUSE);
|
m_screenChooser.setScreen(isBackPaused? SCREEN_PAUSEPREV : SCREEN_PAUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftClient::gameLostFocus() {
|
void MinecraftClient::gameLostFocus() {
|
||||||
@@ -855,7 +855,7 @@ void MinecraftClient::setScreen( Screen* screen ) {
|
|||||||
if (screen != NULL && screen->isErrorScreen())
|
if (screen != NULL && screen->isErrorScreen())
|
||||||
return;
|
return;
|
||||||
if (screen == NULL && level == NULL)
|
if (screen == NULL && level == NULL)
|
||||||
screen = screenChooser.createScreen(SCREEN_STARTMENU);
|
screen = m_screenChooser.createScreen(SCREEN_STARTMENU);
|
||||||
|
|
||||||
if (this->getScreen != NULL) {
|
if (this->getScreen != NULL) {
|
||||||
this->getScreen->removed();
|
this->getScreen->removed();
|
||||||
@@ -1052,7 +1052,7 @@ void MinecraftClient::_levelGenerated() {
|
|||||||
this->cameraTargetPlayer = player;
|
this->cameraTargetPlayer = player;
|
||||||
|
|
||||||
if (player == NULL) {
|
if (player == NULL) {
|
||||||
player = new LocalPlayer(minecraft, level, minecraft.options.getStringValue(OPTIONS_USERNAME), level->dimension->id, isCreativeType());
|
player = new LocalPlayer(minecraft, level, minecraft.options().getStringValue(OPTIONS_USERNAME), level->dimension->id, isCreativeType());
|
||||||
gameMode->initPlayer(player);
|
gameMode->initPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,16 +66,16 @@ public:
|
|||||||
void optionUpdated(OptionId option, float value) override;
|
void optionUpdated(OptionId option, float value) override;
|
||||||
void optionUpdated(OptionId option, int value) override;
|
void optionUpdated(OptionId option, int value) override;
|
||||||
|
|
||||||
LocalPlayer* getPlayer() { return player; }
|
LocalPlayer* player() { return m_player; }
|
||||||
Font* getFont() { return font; }
|
Font* font() { return m_font; }
|
||||||
Textures& textures() { return m_textures; }
|
Textures& textures() { return m_textures; }
|
||||||
Options& options() { return m_options;}
|
Options& options() { return m_options;}
|
||||||
Screen* getScreen() { return m_screen; }
|
Screen* getScreen() { return m_screen; }
|
||||||
Gui& gui() { return m_gui; }
|
Gui& gui() { return m_gui; }
|
||||||
ParticleEngine* getParticleEngine() {return particleEngine; }
|
ParticleEngine* getParticleEngine() {return particleEngine; }
|
||||||
|
|
||||||
int getScreenWidth() { return width; }
|
int getScreenWidth() { return m_width; }
|
||||||
int getScreenHeigth() { return height; }
|
int getScreenHeight() { return m_height; }
|
||||||
|
|
||||||
virtual void hostMultiplayer(int port) override;
|
virtual void hostMultiplayer(int port) override;
|
||||||
|
|
||||||
@@ -92,26 +92,34 @@ public:
|
|||||||
|
|
||||||
void onBlockDestroyed(Player* player, int x, int y, int z, int face) override;
|
void onBlockDestroyed(Player* player, int x, int y, int z, int face) override;
|
||||||
|
|
||||||
|
ScreenChooser& screenChooser() { return m_screenChooser; }
|
||||||
|
|
||||||
|
PixelCalc& pixelCalc() { return m_pixelCalc; }
|
||||||
|
PixelCalc& pixelCalcUi() { return m_pixelCalcUi; }
|
||||||
|
|
||||||
|
IInputHolder* inputHolder() { return m_inputHolder; }
|
||||||
|
SoundEngine* soundEngine() { return m_soundEngine; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _reloadInput();
|
void _reloadInput();
|
||||||
void _levelGenerated() override;
|
void _levelGenerated() override;
|
||||||
|
|
||||||
int width = 1, height = 1;
|
int m_width = 1, m_height = 1;
|
||||||
|
|
||||||
Font* font = nullptr;
|
Font* m_font = nullptr;
|
||||||
// @warn This is unsafe cuz Gui may call some MinecraftClient method while MinecraftClient is not ready
|
// @warn This is unsafe cuz Gui may call some MinecraftClient method while MinecraftClient is not ready
|
||||||
MouseHandler mouseHandler;
|
MouseHandler mouseHandler;
|
||||||
|
|
||||||
LevelRenderer* levelRenderer = nullptr;
|
LevelRenderer* levelRenderer = nullptr;
|
||||||
GameRenderer* gameRenderer = nullptr;
|
GameRenderer* gameRenderer = nullptr;
|
||||||
ParticleEngine* particleEngine = nullptr;
|
ParticleEngine* particleEngine = nullptr;
|
||||||
SoundEngine* soundEngine = nullptr;
|
SoundEngine* m_soundEngine = nullptr;
|
||||||
PerfRenderer* _perfRenderer = nullptr;
|
PerfRenderer* _perfRenderer = nullptr;
|
||||||
|
|
||||||
bool mouseGrabbed = false;
|
bool mouseGrabbed = false;
|
||||||
|
|
||||||
PixelCalc pixelCalc;
|
PixelCalc m_pixelCalc;
|
||||||
PixelCalc pixelCalcUi;
|
PixelCalc m_pixelCalcUi;
|
||||||
|
|
||||||
Screen* m_screen = nullptr;
|
Screen* m_screen = nullptr;
|
||||||
|
|
||||||
@@ -123,9 +131,8 @@ protected:
|
|||||||
|
|
||||||
volatile bool pause = false;
|
volatile bool pause = false;
|
||||||
|
|
||||||
// @todo make static
|
LocalPlayer* m_player = nullptr;
|
||||||
LocalPlayer* player = nullptr;
|
IInputHolder* m_inputHolder = nullptr;
|
||||||
IInputHolder* inputHolder = nullptr;
|
|
||||||
Mob* cameraTargetPlayer = nullptr;
|
Mob* cameraTargetPlayer = nullptr;
|
||||||
|
|
||||||
bool _supportsNonTouchscreen = false;
|
bool _supportsNonTouchscreen = false;
|
||||||
@@ -136,7 +143,7 @@ protected:
|
|||||||
|
|
||||||
Textures m_textures{m_options, *m_platform};
|
Textures m_textures{m_options, *m_platform};
|
||||||
|
|
||||||
ScreenChooser screenChooser{*this};
|
ScreenChooser m_screenChooser{*this};
|
||||||
|
|
||||||
Gui m_gui{*this};
|
Gui m_gui{*this};
|
||||||
};
|
};
|
||||||
@@ -1,16 +1,12 @@
|
|||||||
#include "IConfigListener.hpp"
|
#include "IConfigListener.hpp"
|
||||||
#include "Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#ifndef STANDALONE_SERVER
|
|
||||||
#include "gui/Gui.hpp"
|
#include "gui/Gui.hpp"
|
||||||
#endif /* STANDALONE_SERVER */
|
|
||||||
Config createConfig(Minecraft* mc) {
|
Config::Config(MinecraftClient& mc) : minecraft(mc), options(mc.options()), pixelCalc(mc.pixelCalc()), pixelCalcUi(mc.pixelCalcUi()) {}
|
||||||
Config c;
|
|
||||||
#ifndef STANDALONE_SERVER
|
Config createConfig(MinecraftClient& mc) {
|
||||||
c.setScreenSize(mc->width, mc->height, Gui::GuiScale);
|
Config c(mc);
|
||||||
#endif
|
c.setScreenSize(mc.getScreenWidth(), mc.getScreenHeight(), Gui::GuiScale);
|
||||||
c.pixelCalc = mc->pixelCalc;
|
|
||||||
c.pixelCalcUi = mc->pixelCalcUi;
|
|
||||||
c.minecraft = mc;
|
|
||||||
c.options = &mc->options;
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "PixelCalc.hpp"
|
#include "PixelCalc.hpp"
|
||||||
class Minecraft;
|
|
||||||
|
class MinecraftClient;
|
||||||
class Options;
|
class Options;
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
public:
|
public:
|
||||||
|
Config(MinecraftClient& mc);
|
||||||
|
|
||||||
// Screen dimensions and world-to-screen conversion
|
// Screen dimensions and world-to-screen conversion
|
||||||
void setScreenSize(int width, int height, float scale) {
|
void setScreenSize(int width, int height, float scale) {
|
||||||
this->width = width;
|
this->width = width;
|
||||||
@@ -24,14 +27,14 @@ public:
|
|||||||
int guiWidth;
|
int guiWidth;
|
||||||
int guiHeight;
|
int guiHeight;
|
||||||
|
|
||||||
PixelCalc pixelCalc;
|
PixelCalc& pixelCalc;
|
||||||
PixelCalc pixelCalcUi;
|
PixelCalc& pixelCalcUi;
|
||||||
|
|
||||||
Minecraft* minecraft;
|
MinecraftClient& minecraft;
|
||||||
Options* options;
|
Options& options;
|
||||||
};
|
};
|
||||||
|
|
||||||
Config createConfig(Minecraft* mc);
|
Config createConfig(MinecraftClient& mc);
|
||||||
|
|
||||||
// Interface for Configuration-Changed listener
|
// Interface for Configuration-Changed listener
|
||||||
// This can mean (for instance);
|
// This can mean (for instance);
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ void Options::load() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// if (key == OptionStrings::Controls_UseTouchJoypad) {
|
// if (key == OptionStrings::Controls_UseTouchJoypad) {
|
||||||
// m_options[OPTIONS_IS_JOY_TOUCH_AREA] = readBool(value) && minecraft->useTouchscreen();
|
// m_options[OPTIONS_IS_JOY_TOUCH_AREA] = readBool(value) && minecraft.useTouchscreen();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // Feedback
|
// // Feedback
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "util/Mth.hpp"
|
#include "util/Mth.hpp"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
Font::Font( Options* options, const std::string& name, Textures* textures )
|
Font::Font( Options* options, const std::string& name, Textures& textures )
|
||||||
: options(options),
|
: options(options),
|
||||||
fontTexture(0),
|
fontTexture(0),
|
||||||
fontName(name),
|
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),
|
//: options(options),
|
||||||
// fontTexture(0),
|
// fontTexture(0),
|
||||||
// fontName(name),
|
// fontName(name),
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ class Options;
|
|||||||
class Font
|
class Font
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Font(Options* options, const std::string& name, Textures* textures);
|
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, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset);
|
||||||
|
|
||||||
void init(Options* options);
|
void init(Options* options);
|
||||||
void onGraphicsReset();
|
void onGraphicsReset();
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#include "Gui.hpp"
|
#include "Gui.hpp"
|
||||||
#include "Font.hpp"
|
#include "Font.hpp"
|
||||||
#include "MinecraftClient.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/Options.hpp"
|
#include "client/Options.hpp"
|
||||||
#include "platform/input/Keyboard.hpp"
|
#include "platform/input/Keyboard.hpp"
|
||||||
#include "screens/IngameBlockSelectionScreen.hpp"
|
#include "screens/IngameBlockSelectionScreen.hpp"
|
||||||
#include "screens/ChatScreen.hpp"
|
#include "screens/ChatScreen.hpp"
|
||||||
#include "screens/ConsoleScreen.hpp"
|
|
||||||
#include <Minecraft.hpp>
|
#include <Minecraft.hpp>
|
||||||
#include "client/player/LocalPlayer.hpp"
|
#include "client/player/LocalPlayer.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
@@ -14,10 +13,10 @@
|
|||||||
#include "client/renderer/GameRenderer.hpp"
|
#include "client/renderer/GameRenderer.hpp"
|
||||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||||
#include "client/player/input/IInputHolder.hpp"
|
#include "client/player/input/IInputHolder.hpp"
|
||||||
#include "client/gamemode/GameMode.hpp"
|
#include <gamemode/GameMode.hpp>
|
||||||
#include "client/gamemode/CreativeMode.hpp"
|
#include "gamemode/CreativeMode.hpp"
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
#include "AppConstants.hpp"
|
// #include "AppConstants.hpp"
|
||||||
#include "world/entity/player/Inventory.hpp"
|
#include "world/entity/player/Inventory.hpp"
|
||||||
#include "world/level/material/Material.hpp"
|
#include "world/level/material/Material.hpp"
|
||||||
#include "world/item/Item.hpp"
|
#include "world/item/Item.hpp"
|
||||||
@@ -30,8 +29,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#define MAX_MESSAGE_WIDTH 240
|
|
||||||
|
|
||||||
float Gui::InvGuiScale = 1.0f / 3.0f;
|
float Gui::InvGuiScale = 1.0f / 3.0f;
|
||||||
float Gui::GuiScale = 1.0f / Gui::InvGuiScale;
|
float Gui::GuiScale = 1.0f / Gui::InvGuiScale;
|
||||||
const float Gui::DropTicks = 40.0f;
|
const float Gui::DropTicks = 40.0f;
|
||||||
@@ -54,16 +51,16 @@ Gui::~Gui() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||||
if (!minecraft.level || !minecraft.getPlayer())
|
if (!minecraft.level || !minecraft.player())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//minecraft->gameRenderer->setupGuiScreen();
|
//minecraft.gameRenderer->setupGuiScreen();
|
||||||
Font* font = minecraft.getFont();
|
Font* font = minecraft.font();
|
||||||
|
|
||||||
const bool isTouchInterface = minecraft.useTouchscreen();
|
const bool isTouchInterface = minecraft.useTouchscreen();
|
||||||
|
|
||||||
const int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
const int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||||
const int screenHeight = (int)(minecraft.getScreenHeigth() * InvGuiScale);
|
const int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||||
blitOffset = -90;
|
blitOffset = -90;
|
||||||
renderProgressIndicator(isTouchInterface, screenWidth, screenHeight, a);
|
renderProgressIndicator(isTouchInterface, screenWidth, screenHeight, a);
|
||||||
|
|
||||||
@@ -75,9 +72,9 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
|||||||
// F: 3
|
// F: 3
|
||||||
int ySlot = screenHeight - 16 - 3;
|
int ySlot = screenHeight - 16 - 3;
|
||||||
|
|
||||||
if (!minecraft.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
if (!minecraft.options().getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||||
if (minecraft.gameMode->canHurtPlayer()) {
|
if (minecraft.gameMode->canHurtPlayer()) {
|
||||||
minecraft.getTextures()->loadAndBindTexture("gui/icons.png");
|
minecraft.textures().loadAndBindTexture("gui/icons.png");
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
t.beginOverride();
|
t.beginOverride();
|
||||||
t.colorABGR(0xffffffff);
|
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_DEPTH_TEST);
|
||||||
glDisable(GL_ALPHA_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_ALPHA_TEST);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
if (!minecraft.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
if (!minecraft.options().getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||||
renderToolBar(a, ySlot, screenWidth);
|
renderToolBar(a, ySlot, screenWidth);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
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;
|
unsigned int max = 10;
|
||||||
if (isChatting) {
|
if (isChatting) {
|
||||||
int lineHeight = 9;
|
int lineHeight = 9;
|
||||||
@@ -112,20 +109,17 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
|||||||
} else {
|
} else {
|
||||||
chatScrollOffset = 0;
|
chatScrollOffset = 0;
|
||||||
}
|
}
|
||||||
renderChatMessages(screenHeight, max, isChatting, font);
|
if (font != nullptr) {
|
||||||
#if !defined(RPI)
|
renderChatMessages(screenHeight, max, isChatting, *font);
|
||||||
renderOnSelectItemNameText(screenWidth, font, ySlot);
|
renderOnSelectItemNameText(screenWidth, *font, ySlot);
|
||||||
#endif
|
|
||||||
#if defined(RPI)
|
|
||||||
renderDebugInfo();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (Keyboard::isKeyDown(Keyboard::KEY_TAB)) {
|
if (Keyboard::isKeyDown(Keyboard::KEY_TAB)) {
|
||||||
renderPlayerList(font, screenWidth, screenHeight);
|
renderPlayerList(*font, screenWidth, screenHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minecraft->options.getBooleanValue(OPTIONS_RENDER_DEBUG))
|
if (minecraft.options().getBooleanValue(OPTIONS_RENDER_DEBUG))
|
||||||
renderDebugInfo();
|
renderDebugInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
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 Gui::getSlotIdAt(int x, int y) {
|
||||||
int screenWidth = (int)(minecraft->width * InvGuiScale);
|
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||||
x = (int)(x * InvGuiScale);
|
x = (int)(x * InvGuiScale);
|
||||||
y = (int)(y * InvGuiScale);
|
y = (int)(y * InvGuiScale);
|
||||||
|
|
||||||
@@ -164,24 +158,24 @@ void Gui::flashSlot(int slotId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Gui::getSlotPos(int slot, int& posX, int& posY) {
|
void Gui::getSlotPos(int slot, int& posX, int& posY) {
|
||||||
int screenWidth = (int)(minecraft->width * InvGuiScale);
|
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||||
posX = screenWidth / 2 - getNumSlots() * 10 + slot * 20,
|
posX = screenWidth / 2 - getNumSlots() * 10 + slot * 20,
|
||||||
posY = screenHeight - 22;
|
posY = screenHeight - 22;
|
||||||
}
|
}
|
||||||
|
|
||||||
RectangleArea Gui::getRectangleArea(int extendSide) {
|
RectangleArea Gui::getRectangleArea(int extendSide) {
|
||||||
const int Spacing = 3;
|
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 pHalfWidth = (1.0f + (getNumSlots() * 10 + Spacing)) * Gui::GuiScale;
|
||||||
const float pHeight = (22 + Spacing) * Gui::GuiScale;
|
const float pHeight = (22 + Spacing) * Gui::GuiScale;
|
||||||
|
|
||||||
if (extendSide < 0)
|
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)
|
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) {
|
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);
|
int slot = getSlotIdAt(x, y);
|
||||||
if (slot != -1) {
|
if (slot != -1) {
|
||||||
if (_openInventorySlot && slot == (getNumSlots()-1)) {
|
if (_openInventorySlot && slot == (getNumSlots()-1)) {
|
||||||
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
minecraft.screenChooser().setScreen(SCREEN_BLOCKSELECTION);
|
||||||
} else {
|
} else {
|
||||||
minecraft->player->inventory->selectSlot(slot);
|
minecraft.player()->inventory->selectSlot(slot);
|
||||||
itemNameOverlayTime = 0;
|
itemNameOverlayTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,7 +194,7 @@ void Gui::handleClick(int button, int x, int y) {
|
|||||||
|
|
||||||
void Gui::handleKeyPressed(int key)
|
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) {
|
if (isChatting) {
|
||||||
// Allow scrolling the chat history with the mouse/keyboard when chat is open
|
// Allow scrolling the chat history with the mouse/keyboard when chat is open
|
||||||
if (key == 38) { // VK_UP
|
if (key == 38) { // VK_UP
|
||||||
@@ -211,12 +205,12 @@ void Gui::handleKeyPressed(int key)
|
|||||||
return;
|
return;
|
||||||
} else if (key == 33) { // VK_PRIOR (Page Up)
|
} else if (key == 33) { // VK_PRIOR (Page Up)
|
||||||
// Scroll by a page
|
// Scroll by a page
|
||||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||||
int maxVisible = (screenHeight - 48) / 9;
|
int maxVisible = (screenHeight - 48) / 9;
|
||||||
scrollChat(maxVisible);
|
scrollChat(maxVisible);
|
||||||
return;
|
return;
|
||||||
} else if (key == 34) { // VK_NEXT (Page Down)
|
} 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;
|
int maxVisible = (screenHeight - 48) / 9;
|
||||||
scrollChat(-maxVisible);
|
scrollChat(-maxVisible);
|
||||||
return;
|
return;
|
||||||
@@ -224,30 +218,30 @@ void Gui::handleKeyPressed(int key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (key == Keyboard::KEY_F1) {
|
if (key == Keyboard::KEY_F1) {
|
||||||
minecraft->options.toggle(OPTIONS_HIDEGUI);
|
minecraft.options().toggle(OPTIONS_HIDEGUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == 99)
|
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)
|
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)
|
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)
|
if (delta == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int screenHeight = (int)(minecraft->height * InvGuiScale);
|
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale);
|
||||||
int maxVisible = (screenHeight - 48) / 9;
|
int maxVisible = (screenHeight - 48) / 9;
|
||||||
if (maxVisible <= 0)
|
if (maxVisible <= 0)
|
||||||
return;
|
return;
|
||||||
@@ -277,18 +271,18 @@ void Gui::tick() {
|
|||||||
guiMessages.at(i).ticks++;
|
guiMessages.at(i).ticks++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!minecraft->isCreativeMode())
|
if (!minecraft.isCreativeMode())
|
||||||
tickItemDrop();
|
tickItemDrop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::addMessage(const std::string& _string) {
|
void Gui::addMessage(const std::string& _string) {
|
||||||
if (!minecraft->font)
|
if (!minecraft.font())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string string = _string;
|
std::string string = _string;
|
||||||
while (minecraft->font->width(string) > MAX_MESSAGE_WIDTH) {
|
while (minecraft.font()->width(string) > maxMessageWidth) {
|
||||||
unsigned int i = 1;
|
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++;
|
i++;
|
||||||
}
|
}
|
||||||
addMessage(string.substr(0, i));
|
addMessage(string.substr(0, i));
|
||||||
@@ -338,7 +332,7 @@ void Gui::renderVignette(float br, int w, int h) {
|
|||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
glBlendFunc2(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
glBlendFunc2(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
||||||
glColor4f2(tbr, tbr, tbr, 1);
|
glColor4f2(tbr, tbr, tbr, 1);
|
||||||
minecraft->textures->loadAndBindTexture("misc/vignette.png");
|
minecraft.textures().loadAndBindTexture("misc/vignette.png");
|
||||||
|
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
t.begin();
|
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) {
|
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) {
|
if (!item) {
|
||||||
//LOGW("Warning: item @ Gui::renderSlot is NULL\n");
|
//LOGW("Warning: item @ Gui::renderSlot is NULL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool fancy = true;
|
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 )
|
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);
|
//LOGI("slot: %d - %s\n", slot, buffer);
|
||||||
if (shadow)
|
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
|
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() {
|
void Gui::inventoryUpdated() {
|
||||||
@@ -395,7 +389,7 @@ void Gui::onGraphicsReset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Gui::texturesLoaded( Textures* textures ) {
|
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 ) {
|
void Gui::onConfigChanged( const Config& c ) {
|
||||||
@@ -410,7 +404,7 @@ void Gui::onConfigChanged( const Config& c ) {
|
|||||||
#else
|
#else
|
||||||
const float mm = 50; //20
|
const float mm = 50; //20
|
||||||
#endif
|
#endif
|
||||||
const float maxRadius = minecraft->pixelCalcUi.millimetersToPixels(mm);
|
const float maxRadius = minecraft.pixelCalcUi().millimetersToPixels(mm);
|
||||||
const float radius = Mth::Min(80.0f/2, maxRadius);
|
const float radius = Mth::Min(80.0f/2, maxRadius);
|
||||||
//LOGI("radius, maxradius: %f, %f\n", radius, maxRadius);
|
//LOGI("radius, maxradius: %f, %f\n", radius, maxRadius);
|
||||||
const float radiusInner = radius * 0.95f;
|
const float radiusInner = radius * 0.95f;
|
||||||
@@ -455,10 +449,12 @@ void Gui::onConfigChanged( const Config& c ) {
|
|||||||
}
|
}
|
||||||
rcFeedbackInner = t.end(true, rcFeedbackInner.vboId);
|
rcFeedbackInner = t.end(true, rcFeedbackInner.vboId);
|
||||||
|
|
||||||
if (c.minecraft->useTouchscreen()) {
|
|
||||||
|
|
||||||
|
if (c.minecraft.useTouchscreen()) {
|
||||||
// I'll bump this up to 6.
|
// I'll bump this up to 6.
|
||||||
int num = 6; // without "..." dots
|
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) {
|
while (num < Inventory::MAX_SELECTION_SIZE - 1) {
|
||||||
int x0, x1, y;
|
int x0, x1, y;
|
||||||
getSlotPos(0, x0, y);
|
getSlotPos(0, x0, y);
|
||||||
@@ -477,7 +473,8 @@ void Gui::onConfigChanged( const Config& c ) {
|
|||||||
} else {
|
} else {
|
||||||
_numSlots = Inventory::MAX_SELECTION_SIZE; // Xperia Play
|
_numSlots = Inventory::MAX_SELECTION_SIZE; // Xperia Play
|
||||||
}
|
}
|
||||||
MAX_MESSAGE_WIDTH = c.guiWidth;
|
|
||||||
|
maxMessageWidth = c.guiWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Gui::floorAlignToScreenPixel(float v) {
|
float Gui::floorAlignToScreenPixel(float v) {
|
||||||
@@ -524,8 +521,8 @@ void Gui::tickItemDrop()
|
|||||||
}
|
}
|
||||||
isCurrentlyActive = true;
|
isCurrentlyActive = true;
|
||||||
if ((_currentDropTicks += 1.0f) >= DropTicks) {
|
if ((_currentDropTicks += 1.0f) >= DropTicks) {
|
||||||
minecraft->player->inventory->dropSlot(slot, false);
|
minecraft.player()->inventory->dropSlot(slot, false);
|
||||||
minecraft->level->playSound(minecraft->player, "random.pop", 0.3f, 1);
|
minecraft.level->playSound(minecraft.player(), "random.pop", 0.3f, 1);
|
||||||
isCurrentlyActive = false;
|
isCurrentlyActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -552,7 +549,7 @@ void Gui::postError( int errCode )
|
|||||||
void Gui::setScissorRect( const IntRectangle& bbox )
|
void Gui::setScissorRect( const IntRectangle& bbox )
|
||||||
{
|
{
|
||||||
GLuint x = (GLuint)(GuiScale * bbox.x);
|
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 w = (GLuint)(GuiScale * bbox.w);
|
||||||
GLuint h = (GLuint)(GuiScale * bbox.h);
|
GLuint h = (GLuint)(GuiScale * bbox.h);
|
||||||
glScissor(x, y, w, 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 ) {
|
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 bowEquipped = currentItem != NULL ? currentItem->getItem() == Item::bow : false;
|
||||||
bool itemInUse = currentItem != NULL ? currentItem->getItem() == minecraft->player->getUseItem()->getItem() : false;
|
bool itemInUse = currentItem != NULL ? currentItem->getItem() == minecraft.player()->getUseItem()->getItem() : false;
|
||||||
if ((!isTouchInterface || minecraft->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)
|
if ((!isTouchInterface || minecraft.options().getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)
|
||||||
|| (bowEquipped && itemInUse)) && !minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
|| (bowEquipped && itemInUse)) && !minecraft.options().getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||||
minecraft->textures->loadAndBindTexture("gui/icons.png");
|
minecraft.textures().loadAndBindTexture("gui/icons.png");
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
|
glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
|
||||||
blit(screenWidth/2 - 8, screenHeight/2 - 8, 0, 0, 16, 16);
|
blit(screenWidth/2 - 8, screenHeight/2 - 8, 0, 0, 16, 16);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
} else if(!bowEquipped) {
|
} else if(!bowEquipped) {
|
||||||
const float tprogress = minecraft->gameMode->destroyProgress;
|
const float tprogress = minecraft.gameMode->destroyProgress;
|
||||||
const float alpha = Mth::clamp(minecraft->inputHolder->alpha, 0.0f, 1.0f);
|
const float alpha = Mth::clamp(minecraft.inputHolder()->alpha, 0.0f, 1.0f);
|
||||||
//LOGI("alpha: %f\n", alpha);
|
//LOGI("alpha: %f\n", alpha);
|
||||||
|
|
||||||
if (tprogress <= 0 && minecraft->inputHolder->alpha >= 0) {
|
if (tprogress <= 0 && minecraft.inputHolder()->alpha >= 0) {
|
||||||
glDisable2(GL_TEXTURE_2D);
|
glDisable2(GL_TEXTURE_2D);
|
||||||
glEnable2(GL_BLEND);
|
glEnable2(GL_BLEND);
|
||||||
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
if (minecraft->hitResult.isHit())
|
if (minecraft.hitResult.isHit())
|
||||||
glColor4f2(1, 1, 1, 0.8f * alpha);
|
glColor4f2(1, 1, 1, 0.8f * alpha);
|
||||||
else
|
else
|
||||||
glColor4f2(1, 1, 1, Mth::Min(0.4f, alpha*0.4f));
|
glColor4f2(1, 1, 1, Mth::Min(0.4f, alpha*0.4f));
|
||||||
|
|
||||||
//LOGI("alpha2: %f\n", alpha);
|
//LOGI("alpha2: %f\n", alpha);
|
||||||
const float x = InvGuiScale * minecraft->inputHolder->mousex;
|
const float x = InvGuiScale * minecraft.inputHolder()->mousex;
|
||||||
const float y = InvGuiScale * minecraft->inputHolder->mousey;
|
const float y = InvGuiScale * minecraft.inputHolder()->mousey;
|
||||||
glTranslatef2(x, y, 0);
|
glTranslatef2(x, y, 0);
|
||||||
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24);
|
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24);
|
||||||
glTranslatef2(-x, -y, 0);
|
glTranslatef2(-x, -y, 0);
|
||||||
@@ -599,7 +596,7 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
|
|||||||
glEnable2(GL_TEXTURE_2D);
|
glEnable2(GL_TEXTURE_2D);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
} else if (tprogress > 0) {
|
} 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);
|
const float progress = 0.5f * (oProgress + (tprogress - oProgress) * a);
|
||||||
|
|
||||||
//static Stopwatch w;
|
//static Stopwatch w;
|
||||||
@@ -610,8 +607,8 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
|
|||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
const float x = InvGuiScale * minecraft->inputHolder->mousex;
|
const float x = InvGuiScale * minecraft.inputHolder()->mousex;
|
||||||
const float y = InvGuiScale * minecraft->inputHolder->mousey;
|
const float y = InvGuiScale * minecraft.inputHolder()->mousey;
|
||||||
glPushMatrix2();
|
glPushMatrix2();
|
||||||
glTranslatef2(x, y, 0);
|
glTranslatef2(x, y, 0);
|
||||||
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24);
|
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24);
|
||||||
@@ -632,20 +629,20 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Gui::renderHearts() {
|
void Gui::renderHearts() {
|
||||||
bool blink = (minecraft->player->invulnerableTime / 3) % 2 == 1;
|
bool blink = (minecraft.player()->invulnerableTime / 3) % 2 == 1;
|
||||||
if (minecraft->player->invulnerableTime < 10) blink = false;
|
if (minecraft.player()->invulnerableTime < 10) blink = false;
|
||||||
int h = minecraft->player->health;
|
int h = minecraft.player()->health;
|
||||||
int oh = minecraft->player->lastHealth;
|
int oh = minecraft.player()->lastHealth;
|
||||||
random.setSeed(tickCount * 312871);
|
random.setSeed(tickCount * 312871);
|
||||||
|
|
||||||
int screenWidth = (int)(minecraft->width * InvGuiScale);
|
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||||
int screenHeight = (int)(minecraft->height * 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++) {
|
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;
|
int ip2 = i + i + 1;
|
||||||
|
|
||||||
if (armor > 0) {
|
if (armor > 0) {
|
||||||
@@ -672,14 +669,14 @@ void Gui::renderHearts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Gui::renderBubbles() {
|
void Gui::renderBubbles() {
|
||||||
if (minecraft->player->isUnderLiquid(Material::water)) {
|
if (minecraft.player()->isUnderLiquid(Material::water)) {
|
||||||
int screenWidth = (int)(minecraft->width * InvGuiScale);
|
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||||
int screenHeight = (int)(minecraft->height * 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 yo = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenHeight - 42 : 12;
|
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 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 extra = (int) std::ceil((minecraft.player()->airSupply) * 10.0f / Player::TOTAL_AIR_SUPPLY) - count;
|
||||||
for (int i = 0; i < count + extra; i++) {
|
for (int i = 0; i < count + extra; i++) {
|
||||||
int xo = i * 8 + xx;
|
int xo = i * 8 + xx;
|
||||||
if (i < count) blit(xo, yo, 16, 9 * 2, 9, 9);
|
if (i < count) blit(xo, yo, 16, 9 * 2, 9, 9);
|
||||||
@@ -690,7 +687,7 @@ void Gui::renderBubbles() {
|
|||||||
|
|
||||||
static OffsetPosTranslator posTranslator;
|
static OffsetPosTranslator posTranslator;
|
||||||
void Gui::onLevelGenerated() {
|
void Gui::onLevelGenerated() {
|
||||||
if (Level* level = minecraft->level) {
|
if (Level* level = minecraft.level) {
|
||||||
Pos p = level->getSharedSpawnPos();
|
Pos p = level->getSharedSpawnPos();
|
||||||
posTranslator = OffsetPosTranslator((float)-p.x, (float)-p.y, (float)-p.z);
|
posTranslator = OffsetPosTranslator((float)-p.x, (float)-p.y, (float)-p.z);
|
||||||
}
|
}
|
||||||
@@ -709,8 +706,8 @@ void Gui::renderDebugInfo() {
|
|||||||
fpsLastTime = now;
|
fpsLastTime = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalPlayer* p = minecraft->player;
|
LocalPlayer* p = minecraft.player();
|
||||||
Level* lvl = minecraft->level;
|
Level* lvl = minecraft.level;
|
||||||
|
|
||||||
// Position
|
// Position
|
||||||
float px = p->x, py = p->y - p->heightOffset, pz = p->z;
|
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 LH = (float)Font::DefaultLineHeight; // 10 font-pixels
|
||||||
const float MGN = 2.0f; // left/top margin in font-pixels
|
const float MGN = 2.0f; // left/top margin in font-pixels
|
||||||
const float PAD = 2.0f; // horizontal padding for background
|
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
|
// 1) Draw semi-transparent background boxes behind each line
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
@@ -781,12 +778,12 @@ void Gui::renderDebugInfo() {
|
|||||||
t.endOverrideAndDraw();
|
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
|
// 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
|
// only show the overlay while connected to a multiplayer server
|
||||||
Level* level = minecraft->level;
|
Level* level = minecraft.level;
|
||||||
if (!level) return;
|
if (!level) return;
|
||||||
if (!level->isClientSide) return;
|
if (!level->isClientSide) return;
|
||||||
|
|
||||||
@@ -808,7 +805,7 @@ void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) {
|
|||||||
float maxNameWidth = 0.0f;
|
float maxNameWidth = 0.0f;
|
||||||
// find the longest name so we can size the box accordingly
|
// find the longest name so we can size the box accordingly
|
||||||
for (const std::string& name : playerNames) {
|
for (const std::string& name : playerNames) {
|
||||||
float nameWidth = font->width(name);
|
float nameWidth = font.width(name);
|
||||||
if (nameWidth > maxNameWidth)
|
if (nameWidth > maxNameWidth)
|
||||||
maxNameWidth = nameWidth;
|
maxNameWidth = nameWidth;
|
||||||
}
|
}
|
||||||
@@ -817,7 +814,7 @@ void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) {
|
|||||||
std::ostringstream titleStream;
|
std::ostringstream titleStream;
|
||||||
titleStream << "Players (" << playerNames.size() << ")";
|
titleStream << "Players (" << playerNames.size() << ")";
|
||||||
std::string titleText = titleStream.str();
|
std::string titleText = titleStream.str();
|
||||||
float titleWidth = font->width(titleText);
|
float titleWidth = font.width(titleText);
|
||||||
|
|
||||||
if (titleWidth > maxNameWidth)
|
if (titleWidth > maxNameWidth)
|
||||||
maxNameWidth = titleWidth;
|
maxNameWidth = titleWidth;
|
||||||
@@ -847,21 +844,21 @@ void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) {
|
|||||||
//glScalef2(textScale, textScale, 1);
|
//glScalef2(textScale, textScale, 1);
|
||||||
|
|
||||||
// draw title
|
// draw title
|
||||||
//font->draw(titleText, titleX * invTextScale, titleY * invTextScale, 0xFFFFFFFF);
|
//font.draw(titleText, titleX * invTextScale, titleY * invTextScale, 0xFFFFFFFF);
|
||||||
font->draw(titleText, titleX, titleY, 0xFFFFFFFF);
|
font.draw(titleText, titleX, titleY, 0xFFFFFFFF);
|
||||||
|
|
||||||
// draw player names
|
// draw player names
|
||||||
// we should add ping icons here eventually, but for now just show names
|
// we should add ping icons here eventually, but for now just show names
|
||||||
float currentY = boxTop + padding + lineHeight;
|
float currentY = boxTop + padding + lineHeight;
|
||||||
for (const std::string& name : playerNames) {
|
for (const std::string& name : playerNames) {
|
||||||
font->draw(name, (boxLeft + padding), currentY, 0xFFDDDDDD);
|
font.draw(name, (boxLeft + padding), currentY, 0xFFDDDDDD);
|
||||||
currentY += lineHeight;
|
currentY += lineHeight;
|
||||||
}
|
}
|
||||||
//glPopMatrix2();
|
//glPopMatrix2();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::renderSleepAnimation( const int screenWidth, const int screenHeight ) {
|
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;
|
float amount = (float) timer / (float) Player::SLEEP_DURATION;
|
||||||
if (amount > 1) {
|
if (amount > 1) {
|
||||||
// waking up
|
// waking up
|
||||||
@@ -872,11 +869,11 @@ void Gui::renderSleepAnimation( const int screenWidth, const int screenHeight )
|
|||||||
fill(0, 0, screenWidth, screenHeight, color);
|
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) {
|
if(itemNameOverlayTime < 1.0f) {
|
||||||
ItemInstance* item = minecraft->player->inventory->getSelected();
|
ItemInstance* item = minecraft.player()->inventory->getSelected();
|
||||||
if(item != NULL) {
|
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);
|
float y = float(ySlot - 22);
|
||||||
int alpha = 255;
|
int alpha = 255;
|
||||||
if(itemNameOverlayTime > 0.75) {
|
if(itemNameOverlayTime > 0.75) {
|
||||||
@@ -885,7 +882,7 @@ void Gui::renderOnSelectItemNameText( const int screenWidth, Font* font, int ySl
|
|||||||
alpha = int(percentage * 255);
|
alpha = int(percentage * 255);
|
||||||
}
|
}
|
||||||
if(alpha != 0)
|
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;
|
std::vector<ColorSegment> segs;
|
||||||
parseColorTags(text, segs);
|
parseColorTags(text, segs);
|
||||||
float cx = x;
|
float cx = x;
|
||||||
for (auto &s : segs) {
|
for (auto &s : segs) {
|
||||||
int color = s.color + (alpha << 24);
|
int color = s.color + (alpha << 24);
|
||||||
font->drawShadow(s.text, cx, y, color);
|
font.drawShadow(s.text, cx, y, color);
|
||||||
cx += font->width(s.text);
|
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;
|
std::vector<ColorSegment> segs;
|
||||||
parseColorTags(text, segs);
|
parseColorTags(text, segs);
|
||||||
float w = 0;
|
float w = 0;
|
||||||
for (auto &s : segs) {
|
for (auto &s : segs) {
|
||||||
w += font->width(s.text);
|
w += font.width(s.text);
|
||||||
}
|
}
|
||||||
return w;
|
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) {
|
// if (minecraft.screen instanceof ChatScreen) {
|
||||||
// max = 20;
|
// max = 20;
|
||||||
// isChatting = true;
|
// isChatting = true;
|
||||||
@@ -991,7 +988,7 @@ void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isC
|
|||||||
const float x = 2;
|
const float x = 2;
|
||||||
const float y = (float)(baseY - i * 9);
|
const float y = (float)(baseY - i * 9);
|
||||||
std::string msg = message.message;
|
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);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
// special-case join/leave announcements
|
// 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 ) {
|
void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
||||||
glColor4f2(1, 1, 1, .5);
|
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;
|
int xBase, yBase;
|
||||||
getSlotPos(0, 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);
|
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();
|
t.endOverrideAndDraw();
|
||||||
|
|
||||||
// Render damaged items (@todo: investigate if it's faster by drawing in same batch)
|
// 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();
|
t.beginOverride();
|
||||||
x = baseItemX;
|
x = baseItemX;
|
||||||
for (int i = 0; i < slots; i++) {
|
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;
|
x += 20;
|
||||||
}
|
}
|
||||||
t.endOverrideAndDraw();
|
t.endOverrideAndDraw();
|
||||||
@@ -1094,16 +1091,16 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
|||||||
const float k = 0.5f * GuiScale;
|
const float k = 0.5f * GuiScale;
|
||||||
|
|
||||||
t.beginOverride();
|
t.beginOverride();
|
||||||
if (minecraft->gameMode->isSurvivalType()) {
|
if (minecraft.gameMode->isSurvivalType()) {
|
||||||
x = baseItemX;
|
x = baseItemX;
|
||||||
for (int i = 0; i < slots; i++) {
|
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)
|
if (item && item->count >= 0)
|
||||||
renderSlotText(item, k*x, k*ySlot + 1, true, true);
|
renderSlotText(item, k*x, k*ySlot + 1, true, true);
|
||||||
x += 20;
|
x += 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
minecraft->textures->loadAndBindTexture("font/default8.png");
|
minecraft.textures().loadAndBindTexture("font/default8.png");
|
||||||
t.endOverrideAndDraw();
|
t.endOverrideAndDraw();
|
||||||
|
|
||||||
glPopMatrix2();
|
glPopMatrix2();
|
||||||
|
|||||||
@@ -45,22 +45,22 @@ public:
|
|||||||
|
|
||||||
void renderToolBar( float a, int ySlot, const int screenWidth );
|
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
|
// draw a string containing simple [color]...[/color] tags; color names are matched
|
||||||
// case-insensitively and default to white. alpha is applied to each segment.
|
// case-insensitively and default to white. alpha is applied to each segment.
|
||||||
// draw tagged string (ignores simple [color]…[/color] tags)
|
// draw tagged string (ignores simple [color]…[/color] tags)
|
||||||
static void drawColoredString(Font* font, const std::string& text, float x, float y, int alpha);
|
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 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 renderSleepAnimation( const int screenWidth, const int screenHeight );
|
||||||
|
|
||||||
void renderBubbles();
|
void renderBubbles();
|
||||||
void renderHearts();
|
void renderHearts();
|
||||||
void renderDebugInfo();
|
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 );
|
void renderProgressIndicator( const bool isTouchInterface, const int screenWidth, const int screenHeight, float a );
|
||||||
|
|
||||||
@@ -127,5 +127,7 @@ private:
|
|||||||
int _currentDropSlot = -1;
|
int _currentDropSlot = -1;
|
||||||
|
|
||||||
bool _openInventorySlot;
|
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*/ )
|
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>
|
#include <string>
|
||||||
class Font;
|
class Font;
|
||||||
class Minecraft;
|
|
||||||
|
|
||||||
class GuiComponent
|
class GuiComponent
|
||||||
{
|
{
|
||||||
@@ -12,8 +11,8 @@ public:
|
|||||||
GuiComponent();
|
GuiComponent();
|
||||||
virtual ~GuiComponent();
|
virtual ~GuiComponent();
|
||||||
|
|
||||||
void drawString(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 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(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);
|
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);
|
void fillHorizontalGradient(float x0, float y0, float x1, float y1, int col1, int col2);
|
||||||
|
|
||||||
float blitOffset;
|
float blitOffset;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,15 @@
|
|||||||
#include "platform/input/Keyboard.hpp"
|
#include "platform/input/Keyboard.hpp"
|
||||||
#include "platform/input/Mouse.hpp"
|
#include "platform/input/Mouse.hpp"
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
|
#include <MinecraftClient.hpp>
|
||||||
|
|
||||||
Screen::Screen()
|
Screen::Screen(MinecraftClient& minecraft)
|
||||||
: passEvents(false),
|
: passEvents(false),
|
||||||
clickedButton(NULL),
|
clickedButton(NULL),
|
||||||
tabButtonIndex(0),
|
tabButtonIndex(0),
|
||||||
width(1),
|
width(1),
|
||||||
height(1),
|
height(1),
|
||||||
minecraft(NULL),
|
minecraft(minecraft),
|
||||||
font(NULL)
|
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);
|
//particles = /*new*/ GuiParticles(minecraft);
|
||||||
this->minecraft = minecraft;
|
this->font = minecraft.font();
|
||||||
this->font = minecraft->font;
|
|
||||||
this->width = width;
|
this->width = width;
|
||||||
this->height = height;
|
this->height = height;
|
||||||
init();
|
init();
|
||||||
@@ -80,8 +80,8 @@ void Screen::mouseEvent()
|
|||||||
const MouseAction& e = Mouse::getEvent();
|
const MouseAction& e = Mouse::getEvent();
|
||||||
// forward wheel events to subclasses
|
// forward wheel events to subclasses
|
||||||
if (e.action == MouseAction::ACTION_WHEEL) {
|
if (e.action == MouseAction::ACTION_WHEEL) {
|
||||||
int xm = e.x * width / minecraft->width;
|
int xm = e.x * width / minecraft.getScreenWidth();
|
||||||
int ym = e.y * height / minecraft->height - 1;
|
int ym = e.y * height / minecraft.getScreenHeight() - 1;
|
||||||
mouseWheel(e.dx, e.dy, xm, ym);
|
mouseWheel(e.dx, e.dy, xm, ym);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -90,12 +90,12 @@ void Screen::mouseEvent()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (Mouse::getEventButtonState()) {
|
if (Mouse::getEventButtonState()) {
|
||||||
int xm = e.x * width / minecraft->width;
|
int xm = e.x * width / minecraft.getScreenWidth();
|
||||||
int ym = e.y * height / minecraft->height - 1;
|
int ym = e.y * height / minecraft.getScreenHeight() - 1;
|
||||||
mouseClicked(xm, ym, Mouse::getEventButton());
|
mouseClicked(xm, ym, Mouse::getEventButton());
|
||||||
} else {
|
} else {
|
||||||
int xm = e.x * width / minecraft->width;
|
int xm = e.x * width / minecraft.getScreenWidth();
|
||||||
int ym = e.y * height / minecraft->height - 1;
|
int ym = e.y * height / minecraft.getScreenHeight() - 1;
|
||||||
mouseReleased(xm, ym, Mouse::getEventButton());
|
mouseReleased(xm, ym, Mouse::getEventButton());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ void Screen::keyboardEvent()
|
|||||||
{
|
{
|
||||||
if (Keyboard::getEventKeyState()) {
|
if (Keyboard::getEventKeyState()) {
|
||||||
//if (Keyboard.getEventKey() == Keyboard.KEY_F11) {
|
//if (Keyboard.getEventKey() == Keyboard.KEY_F11) {
|
||||||
// minecraft->toggleFullScreen();
|
// minecraft.toggleFullScreen();
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
keyPressed(Keyboard::getEventKey());
|
keyPressed(Keyboard::getEventKey());
|
||||||
@@ -121,7 +121,7 @@ void Screen::renderBackground()
|
|||||||
|
|
||||||
void Screen::renderBackground( int vo )
|
void Screen::renderBackground( int vo )
|
||||||
{
|
{
|
||||||
if (minecraft->isLevelGenerated()) {
|
if (minecraft.isLevelGenerated()) {
|
||||||
fillGradient(0, 0, width, height, 0xc0101010, 0xd0101010);
|
fillGradient(0, 0, width, height, 0xc0101010, 0xd0101010);
|
||||||
} else {
|
} else {
|
||||||
renderDirtBackground(vo);
|
renderDirtBackground(vo);
|
||||||
@@ -133,7 +133,7 @@ void Screen::renderDirtBackground( int vo )
|
|||||||
//glDisable2(GL_LIGHTING);
|
//glDisable2(GL_LIGHTING);
|
||||||
glDisable2(GL_FOG);
|
glDisable2(GL_FOG);
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||||
glColor4f2(1, 1, 1, 1);
|
glColor4f2(1, 1, 1, 1);
|
||||||
float s = 32;
|
float s = 32;
|
||||||
float fvo = (float) vo;
|
float fvo = (float) vo;
|
||||||
@@ -168,8 +168,8 @@ bool Screen::closeOnPlayerHurt() {
|
|||||||
void Screen::keyPressed( int eventKey )
|
void Screen::keyPressed( int eventKey )
|
||||||
{
|
{
|
||||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
//minecraft->grabMouse();
|
//minecraft.grabMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass key events to any text boxes first
|
// pass key events to any text boxes first
|
||||||
@@ -178,7 +178,7 @@ void Screen::keyPressed( int eventKey )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TABBING
|
#ifdef TABBING
|
||||||
if (minecraft->useTouchscreen())
|
if (minecraft.useTouchscreen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ void Screen::keyPressed( int eventKey )
|
|||||||
if (!tabButtonCount)
|
if (!tabButtonCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Options& o = minecraft->options;
|
Options& o = minecraft.options;
|
||||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_NEXT))
|
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_NEXT))
|
||||||
if (++tabButtonIndex == tabButtonCount) tabButtonIndex = 0;
|
if (++tabButtonIndex == tabButtonCount) tabButtonIndex = 0;
|
||||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_PREV))
|
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)) {
|
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_OK)) {
|
||||||
Button* button = tabButtons[tabButtonIndex];
|
Button* button = tabButtons[tabButtonIndex];
|
||||||
if (button->active) {
|
if (button->active) {
|
||||||
minecraft->soundEngine->playUI("random.click", 1, 1);
|
minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||||
buttonClicked(button);
|
buttonClicked(button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ void Screen::charPressed(char inputChar) {
|
|||||||
void Screen::updateTabButtonSelection()
|
void Screen::updateTabButtonSelection()
|
||||||
{
|
{
|
||||||
#ifdef TABBING
|
#ifdef TABBING
|
||||||
if (minecraft->useTouchscreen())
|
if (minecraft.useTouchscreen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < tabButtons.size(); ++i)
|
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);
|
//LOGI("Hit-test successful: %p\n", button);
|
||||||
clickedButton = button;
|
clickedButton = button;
|
||||||
/*
|
/*
|
||||||
#if !defined(ANDROID) && !defined(__APPLE__) //if (!minecraft->isTouchscreen()) {
|
#if !defined(ANDROID) && !defined(__APPLE__) //if (!minecraft.isTouchscreen()) {
|
||||||
minecraft->soundEngine->playUI("random.click", 1, 1);
|
minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||||
buttonClicked(button);
|
buttonClicked(button);
|
||||||
#endif }
|
#endif }
|
||||||
*/
|
*/
|
||||||
@@ -254,12 +254,12 @@ void Screen::mouseReleased( int x, int y, int buttonNum )
|
|||||||
if (!clickedButton || buttonNum != MouseAction::ACTION_LEFT) return;
|
if (!clickedButton || buttonNum != MouseAction::ACTION_LEFT) return;
|
||||||
|
|
||||||
#if 1
|
#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) {
|
for (unsigned int i = 0; i < buttons.size(); ++i) {
|
||||||
Button* button = buttons[i];
|
Button* button = buttons[i];
|
||||||
if (clickedButton == button && button->clicked(minecraft, x, y)) {
|
if (clickedButton == button && button->clicked(minecraft, x, y)) {
|
||||||
buttonClicked(button);
|
buttonClicked(button);
|
||||||
minecraft->soundEngine->playUI("random.click", 1, 1);
|
minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||||
clickedButton->released(x, y);
|
clickedButton->released(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,13 +279,13 @@ bool Screen::hasClippingArea( IntRectangle& out )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Screen::lostFocus() {
|
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;
|
TextBox* tb = *it;
|
||||||
tb->loseFocus(minecraft);
|
tb->loseFocus(minecraft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::toGUICoordinate( int& x, int& y ) {
|
void Screen::toGUICoordinate( int& x, int& y ) {
|
||||||
x = x * width / minecraft->width;
|
x = x * width / minecraft.getScreenWidth();
|
||||||
y = y * height / minecraft->height - 1;
|
y = y * height / minecraft.getScreenHeight() - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "GuiComponent.hpp"
|
#include "GuiComponent.hpp"
|
||||||
|
|
||||||
class Font;
|
class Font;
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
class Button;
|
class Button;
|
||||||
class TextBox;
|
class TextBox;
|
||||||
struct IntRectangle;
|
struct IntRectangle;
|
||||||
@@ -14,11 +14,11 @@ struct IntRectangle;
|
|||||||
class Screen: public GuiComponent
|
class Screen: public GuiComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Screen();
|
Screen(MinecraftClient& minecraft);
|
||||||
|
|
||||||
virtual void render(int xm, int ym, float a);
|
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();
|
virtual void init();
|
||||||
|
|
||||||
void setSize(int width, int height);
|
void setSize(int width, int height);
|
||||||
@@ -67,7 +67,7 @@ public:
|
|||||||
bool passEvents;
|
bool passEvents;
|
||||||
//GuiParticles* particles;
|
//GuiParticles* particles;
|
||||||
protected:
|
protected:
|
||||||
Minecraft* minecraft;
|
MinecraftClient& minecraft;
|
||||||
std::vector<Button*> buttons;
|
std::vector<Button*> buttons;
|
||||||
std::vector<TextBox*> textBoxes;
|
std::vector<TextBox*> textBoxes;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Button.hpp"
|
#include "Button.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
|
#include <cstddef>
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
|
|
||||||
Button::Button(int id, const std::string& msg)
|
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;
|
if (!visible) return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
minecraft->textures->loadAndBindTexture("gui/gui.png");
|
minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||||
glColor4f2(1, 1, 1, 1);
|
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);
|
//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;
|
_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;
|
return active && mx >= x && my >= y && mx < x + width && my < y + height;
|
||||||
}
|
}
|
||||||
@@ -69,22 +70,27 @@ int Button::getYImage( bool hovered )
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::renderFace(Minecraft* mc, int xm, int ym) {
|
void Button::renderFace(MinecraftClient& mc, int xm, int ym) {
|
||||||
Font* font = mc->font;
|
Font* font = mc.font();
|
||||||
|
|
||||||
|
if (font == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!active) {
|
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 {
|
} else {
|
||||||
if (hovered(mc, xm, ym) || selected) {
|
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 {
|
} 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);
|
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);
|
//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);
|
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) {
|
bool Button::hovered(MinecraftClient& minecraft, int xm , int ym) {
|
||||||
return minecraft->useTouchscreen()? (_currentlyDown && isInside(xm, ym)) : isInside(xm, ym);
|
return minecraft.useTouchscreen()? (_currentlyDown && isInside(xm, ym)) : isInside(xm, ym);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Button::isInside( int xm, int 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));
|
// 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);
|
//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)
|
if (active)
|
||||||
@@ -187,19 +193,22 @@ THeader::THeader( int id, int x, int y, int w, int h, const std::string& msg )
|
|||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void THeader::render( Minecraft* minecraft, int xm, int ym ) {
|
void THeader::render( MinecraftClient& minecraft, int xm, int ym ) {
|
||||||
Font* font = minecraft->font;
|
Font* font = minecraft.font();
|
||||||
renderBg(minecraft, xm, ym);
|
renderBg(minecraft, xm, ym);
|
||||||
|
|
||||||
int xx = x + width/2;
|
int xx = x + width/2;
|
||||||
if (xText != -99999)
|
if (xText != -99999)
|
||||||
xx = xText;
|
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);
|
//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);
|
glColor4f2(1, 1, 1, 1);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "client/Options.hpp"
|
#include "client/Options.hpp"
|
||||||
|
|
||||||
class Font;
|
class Font;
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
|
|
||||||
class Button: public GuiElement
|
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, const std::string& msg);
|
||||||
Button(int id, int x, int y, int w, int h, const std::string& msg);
|
Button(int id, int x, int y, int w, int h, const std::string& msg);
|
||||||
virtual ~Button() {}
|
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 released(int mx, int my);
|
||||||
virtual void setPressed();
|
virtual void setPressed();
|
||||||
|
|
||||||
bool isInside(int xm, int ym);
|
bool isInside(int xm, int ym);
|
||||||
protected:
|
protected:
|
||||||
virtual int getYImage(bool hovered);
|
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);
|
virtual void renderFace(MinecraftClient& minecraft, int xm, int ym);
|
||||||
bool hovered(Minecraft* minecraft, int xm, int ym);
|
bool hovered(MinecraftClient& minecraft, int xm, int ym);
|
||||||
public:
|
public:
|
||||||
std::string msg;
|
std::string msg;
|
||||||
int id;
|
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, const std::string& msg);
|
||||||
TButton(int id, int x, int y, int w, int h, const std::string& msg);
|
TButton(int id, int x, int y, int w, int h, const std::string& msg);
|
||||||
protected:
|
protected:
|
||||||
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
|
virtual void renderBg(MinecraftClient& minecraft, int xm, int ym);
|
||||||
};
|
};
|
||||||
|
|
||||||
// "Header" in Touchscreen mode
|
// "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, const std::string& msg);
|
||||||
THeader(int id, int x, int y, int w, int h, const std::string& msg);
|
THeader(int id, int x, int y, int w, int h, const std::string& msg);
|
||||||
protected:
|
protected:
|
||||||
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
|
virtual void renderBg(MinecraftClient& minecraft, int xm, int ym);
|
||||||
void render( Minecraft* minecraft, int xm, int ym );
|
void render( MinecraftClient& minecraft, int xm, int ym );
|
||||||
public:
|
public:
|
||||||
int xText;
|
int xText;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ public:
|
|||||||
layers.push_back(std::make_pair(e, layerId));
|
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;
|
if (!visible) return;
|
||||||
|
|
||||||
bool isHovered = minecraft->isTouchscreen()?
|
bool isHovered = minecraft.isTouchscreen()?
|
||||||
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height): false;
|
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height): false;
|
||||||
|
|
||||||
int layer = isHovered? LayerSelected : LayerDefault;
|
int layer = isHovered? LayerSelected : LayerDefault;
|
||||||
|
|||||||
@@ -2,21 +2,21 @@
|
|||||||
#include "client/gui/GuiComponent.hpp"
|
#include "client/gui/GuiComponent.hpp"
|
||||||
|
|
||||||
class Tesselator;
|
class Tesselator;
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
|
|
||||||
class GuiElement : public GuiComponent {
|
class GuiElement : public GuiComponent {
|
||||||
public:
|
public:
|
||||||
GuiElement(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
|
GuiElement(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
|
||||||
virtual ~GuiElement() {}
|
virtual ~GuiElement() {}
|
||||||
|
|
||||||
virtual void tick(Minecraft* minecraft) {}
|
virtual void tick(MinecraftClient& minecraft) {}
|
||||||
virtual void render(Minecraft* minecraft, int xm, int ym) { }
|
virtual void render(MinecraftClient& minecraft, int xm, int ym) { }
|
||||||
virtual void setupPositions() {}
|
virtual void setupPositions() {}
|
||||||
|
|
||||||
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {}
|
virtual void mouseClicked(MinecraftClient& minecraft, int x, int y, int buttonNum) {}
|
||||||
virtual void mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum) {}
|
virtual void mouseReleased(MinecraftClient& minecraft, int x, int y, int buttonNum) {}
|
||||||
virtual void keyPressed(Minecraft* minecraft, int key) {}
|
virtual void keyPressed(MinecraftClient& minecraft, int key) {}
|
||||||
virtual void charPressed(Minecraft* minecraft, char key) {}
|
virtual void charPressed(MinecraftClient& minecraft, char key) {}
|
||||||
|
|
||||||
virtual bool pointInside(int x, int y);
|
virtual bool pointInside(int x, int y);
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ GuiElementContainer::~GuiElementContainer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiElementContainer::render( Minecraft* minecraft, int xm, int ym ) {
|
void GuiElementContainer::render( MinecraftClient& minecraft, int xm, int ym ) {
|
||||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||||
(*it)->render(minecraft, xm, ym);
|
(*it)->render(minecraft, xm, ym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiElementContainer::setupPositions() {
|
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();
|
(*it)->setupPositions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,37 +30,37 @@ void GuiElementContainer::addChild( GuiElement* element ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GuiElementContainer::removeChild( 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())
|
if(it != children.end())
|
||||||
children.erase(it);
|
children.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiElementContainer::tick( Minecraft* minecraft ) {
|
void GuiElementContainer::tick( MinecraftClient& minecraft ) {
|
||||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||||
(*it)->tick(minecraft);
|
(*it)->tick(minecraft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiElementContainer::mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
void GuiElementContainer::mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum ) {
|
||||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||||
(*it)->mouseClicked(minecraft, x, y, buttonNum);
|
(*it)->mouseClicked(minecraft, x, y, buttonNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiElementContainer::mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
void GuiElementContainer::mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum ) {
|
||||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||||
(*it)->mouseReleased(minecraft, x, y, buttonNum);
|
(*it)->mouseReleased(minecraft, x, y, buttonNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiElementContainer::keyPressed(Minecraft* minecraft, int key) {
|
void GuiElementContainer::keyPressed(MinecraftClient& minecraft, int key) {
|
||||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||||
(*it)->keyPressed(minecraft, key);
|
(*it)->keyPressed(minecraft, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiElementContainer::charPressed(Minecraft* minecraft, char key) {
|
void GuiElementContainer::charPressed(MinecraftClient& minecraft, char key) {
|
||||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||||
(*it)->charPressed(minecraft, key);
|
(*it)->charPressed(minecraft, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,23 +2,23 @@
|
|||||||
#include "GuiElement.hpp"
|
#include "GuiElement.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
class Tesselator;
|
class Tesselator;
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
|
|
||||||
class GuiElementContainer : public GuiElement {
|
class GuiElementContainer : public GuiElement {
|
||||||
public:
|
public:
|
||||||
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
|
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
|
||||||
virtual ~GuiElementContainer();
|
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 setupPositions();
|
||||||
virtual void addChild(GuiElement* element);
|
virtual void addChild(GuiElement* element);
|
||||||
virtual void removeChild(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 mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum );
|
||||||
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
|
virtual void mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum );
|
||||||
virtual void keyPressed(Minecraft* minecraft, int key);
|
virtual void keyPressed(MinecraftClient& minecraft, int key);
|
||||||
virtual void charPressed(Minecraft* minecraft, char key);
|
virtual void charPressed(MinecraftClient& minecraft, char key);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<GuiElement*> children;
|
std::vector<GuiElement*> children;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "ImageButton.hpp"
|
#include "ImageButton.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "platform/log.hpp"
|
#include "platform/log.hpp"
|
||||||
#include "util/Mth.hpp"
|
#include "util/Mth.hpp"
|
||||||
#include "client/renderer/Textures.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;
|
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);
|
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);
|
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);
|
//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);
|
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) ) {
|
if ( Textures::isTextureIdValid(texId) ) {
|
||||||
const ImageDef& d = _imageDef;
|
const ImageDef& d = _imageDef;
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
@@ -75,7 +75,7 @@ void ImageButton::render(Minecraft* minecraft, int xm, int ym) {
|
|||||||
|
|
||||||
const IntRectangle* src = _imageDef.getSrc();
|
const IntRectangle* src = _imageDef.getSrc();
|
||||||
if (src) {
|
if (src) {
|
||||||
const TextureData* d = minecraft->textures->getTemporaryTextureData(texId);
|
const TextureData* d = minecraft.textures().getTemporaryTextureData(texId);
|
||||||
if (d != NULL) {
|
if (d != NULL) {
|
||||||
float u0 = (src->x+(IsSecondImage?src->w:0)) / (float)d->w;
|
float u0 = (src->x+(IsSecondImage?src->w:0)) / (float)d->w;
|
||||||
float u1 = (src->x+(IsSecondImage?2*src->w:src->w)) / (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);
|
_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(buttonNum == MouseAction::ACTION_LEFT) {
|
||||||
if(clicked(minecraft, x, y)) {
|
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);
|
ImageButton(int id, const std::string& msg, const ImageDef& imageDef);
|
||||||
void setImageDef(const ImageDef& imageDef, bool setButtonSize);
|
void setImageDef(const ImageDef& imageDef, bool setButtonSize);
|
||||||
|
|
||||||
void render(Minecraft* minecraft, int xm, int ym);
|
void render(MinecraftClient& minecraft, int xm, int ym);
|
||||||
void renderBg(Minecraft* minecraft, int xm, int ym) {}
|
void renderBg(MinecraftClient& minecraft, int xm, int ym) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setupDefault();
|
virtual void setupDefault();
|
||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
bool isSecondImage(bool hovered) { return _secondImage; }
|
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:
|
private:
|
||||||
OptionId m_optId;
|
OptionId m_optId;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "InventoryPane.hpp"
|
#include "InventoryPane.hpp"
|
||||||
#include "client/gui/Gui.hpp"
|
#include "client/gui/Gui.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/player/input/touchscreen/TouchAreaModel.hpp"
|
#include "client/player/input/touchscreen/TouchAreaModel.hpp"
|
||||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
@@ -12,7 +12,7 @@ namespace Touch {
|
|||||||
|
|
||||||
static const int By = 6; // Border Frame height
|
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),
|
: screen(screen),
|
||||||
mc(mc),
|
mc(mc),
|
||||||
paneWidth(paneWidth),
|
paneWidth(paneWidth),
|
||||||
@@ -62,7 +62,7 @@ void InventoryPane::renderBatch( std::vector<GridItem>& items, float alpha )
|
|||||||
|
|
||||||
glEnable2(GL_SCISSOR_TEST);
|
glEnable2(GL_SCISSOR_TEST);
|
||||||
GLuint x = (GLuint)(screenScale * bbox.x);
|
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 w = (GLuint)(screenScale * bbox.w);
|
||||||
GLuint h = (GLuint)(screenScale * bbox.h);
|
GLuint h = (GLuint)(screenScale * bbox.h);
|
||||||
glScissor(x, y, w, h);
|
glScissor(x, y, w, h);
|
||||||
@@ -75,7 +75,7 @@ void InventoryPane::renderBatch( std::vector<GridItem>& items, float alpha )
|
|||||||
GridItem& item = items[i];
|
GridItem& item = items[i];
|
||||||
blit(item.xf, item.yf, 200, 46, (float)itemBbox.w, (float)itemBbox.h, 16, 16);
|
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();
|
t.endOverrideAndDraw();
|
||||||
|
|
||||||
GridItem* marked = NULL;
|
GridItem* marked = NULL;
|
||||||
@@ -104,7 +104,7 @@ void InventoryPane::renderBatch( std::vector<GridItem>& items, float alpha )
|
|||||||
t.noColor();
|
t.noColor();
|
||||||
float xx = Gui::floorAlignToScreenPixel(item.xf + BorderPixels + 4);
|
float xx = Gui::floorAlignToScreenPixel(item.xf + BorderPixels + 4);
|
||||||
float yy = Gui::floorAlignToScreenPixel(item.yf + 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)
|
if (j == markerIndex && markerShare >= 0)
|
||||||
marked = &item, mxx = xx, myy = yy;
|
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 ikText = Gui::InvGuiScale + Gui::InvGuiScale;
|
||||||
const float kText = 0.5f * Gui::GuiScale;
|
const float kText = 0.5f * Gui::GuiScale;
|
||||||
t.beginOverride();
|
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 tx = Gui::floorAlignToScreenPixel(kText * (item.xf + BorderPixels + 3));
|
||||||
float ty = Gui::floorAlignToScreenPixel(kText * (item.yf + 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();
|
t.resetScale();
|
||||||
glEnable2(GL_BLEND);
|
glEnable2(GL_BLEND);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "ScrollingPane.hpp"
|
#include "ScrollingPane.hpp"
|
||||||
#include "ImageButton.hpp"
|
#include "ImageButton.hpp"
|
||||||
|
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
class ItemInstance;
|
class ItemInstance;
|
||||||
class Font;
|
class Font;
|
||||||
class IArea;
|
class IArea;
|
||||||
@@ -16,7 +16,7 @@ class InventoryPane: public ScrollingPane
|
|||||||
{
|
{
|
||||||
typedef ScrollingPane super;
|
typedef ScrollingPane super;
|
||||||
public:
|
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();
|
~InventoryPane();
|
||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
@@ -30,7 +30,7 @@ public:
|
|||||||
int paneWidth;
|
int paneWidth;
|
||||||
IArea* _clickArea;
|
IArea* _clickArea;
|
||||||
IInventoryPaneCallback* screen;
|
IInventoryPaneCallback* screen;
|
||||||
Minecraft* mc;
|
MinecraftClient& mc;
|
||||||
|
|
||||||
int fillMarginX;
|
int fillMarginX;
|
||||||
int fillMarginY;
|
int fillMarginY;
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
#include "KeyOption.hpp"
|
#include "KeyOption.hpp"
|
||||||
#include <client/Minecraft.hpp>
|
#include <MinecraftClient.hpp>
|
||||||
|
|
||||||
KeyOption::KeyOption(Minecraft* minecraft, OptionId optId)
|
KeyOption::KeyOption(MinecraftClient& minecraft, OptionId optId)
|
||||||
: Touch::TButton((int)optId, Keyboard::getKeyName(minecraft->options.getIntValue(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);
|
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 (!selected) return;
|
||||||
|
|
||||||
if (key != Keyboard::KEY_ESCAPE) {
|
if (key != Keyboard::KEY_ESCAPE) {
|
||||||
minecraft->options.set((OptionId)id, key);
|
minecraft.options().set((OptionId)id, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
selected = false;
|
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 {
|
class KeyOption : public Touch::TButton {
|
||||||
public:
|
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 released(int mx, int my) {}
|
||||||
virtual void keyPressed(Minecraft* minecraft, int key);
|
virtual void keyPressed(MinecraftClient& minecraft, int key);
|
||||||
protected:
|
protected:
|
||||||
bool m_captureMode;
|
bool m_captureMode;
|
||||||
};
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "LargeImageButton.hpp"
|
#include "LargeImageButton.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "util/Mth.hpp"
|
#include "util/Mth.hpp"
|
||||||
#include "platform/log.hpp"
|
#include "platform/log.hpp"
|
||||||
#include "util/Mth.hpp"
|
#include "util/Mth.hpp"
|
||||||
@@ -26,14 +26,14 @@ void LargeImageButton::setupDefault() {
|
|||||||
height = 72;
|
height = 72;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LargeImageButton::render(Minecraft* minecraft, int xm, int ym) {
|
void LargeImageButton::render(MinecraftClient& minecraft, int xm, int ym) {
|
||||||
if (!visible) return;
|
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);
|
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);
|
//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);
|
//int yImage = getYImage(hovered || selected);
|
||||||
@@ -43,7 +43,7 @@ void LargeImageButton::render(Minecraft* minecraft, int xm, int ym) {
|
|||||||
|
|
||||||
renderBg(minecraft, xm, 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) ) {
|
if ( Textures::isTextureIdValid(texId) ) {
|
||||||
const ImageDef& d = _imageDef;
|
const ImageDef& d = _imageDef;
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
@@ -69,7 +69,7 @@ void LargeImageButton::render(Minecraft* minecraft, int xm, int ym) {
|
|||||||
|
|
||||||
const IntRectangle* src = _imageDef.getSrc();
|
const IntRectangle* src = _imageDef.getSrc();
|
||||||
if (src) {
|
if (src) {
|
||||||
const TextureData* d = minecraft->textures->getTemporaryTextureData(texId);
|
const TextureData* d = minecraft.textures().getTemporaryTextureData(texId);
|
||||||
if (d != NULL) {
|
if (d != NULL) {
|
||||||
float u0 = (src->x+(hovered?src->w:0)) / (float)d->w;
|
float u0 = (src->x+(hovered?src->w:0)) / (float)d->w;
|
||||||
float u1 = (src->x+(hovered?2*src->w:src->w)) / (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);
|
||||||
LargeImageButton(int id, const std::string& msg, ImageDef& imageDef);
|
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:
|
private:
|
||||||
void setupDefault();
|
void setupDefault();
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ NinePatchDescription NinePatchDescription::createSymmetrical( int texWidth, int
|
|||||||
return patch;
|
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),
|
: desc(desc),
|
||||||
imageName(imageName),
|
imageName(imageName),
|
||||||
textures(textures),
|
textures(textures),
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "client/renderer/TextureData.hpp"
|
#include "client/renderer/TextureData.hpp"
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
|
||||||
|
|
||||||
class Tesselator;
|
class Tesselator;
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ class NinePatchLayer: public GuiElement
|
|||||||
{
|
{
|
||||||
struct CachedQuad;
|
struct CachedQuad;
|
||||||
public:
|
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() {};
|
virtual ~NinePatchLayer() {};
|
||||||
void setSize(float w, float h);
|
void setSize(float w, float h);
|
||||||
|
|
||||||
@@ -63,12 +62,12 @@ private:
|
|||||||
|
|
||||||
class NinePatchFactory {
|
class NinePatchFactory {
|
||||||
public:
|
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);
|
NinePatchLayer* createSymmetrical(const IntRectangle& src, int xCutAt, int yCutAt, float w = 32.0f, float h = 32.0f);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Textures* textures;
|
Textures& textures;
|
||||||
std::string imageName;
|
std::string imageName;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "OptionsGroup.hpp"
|
#include "OptionsGroup.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "ImageButton.hpp"
|
#include "ImageButton.hpp"
|
||||||
#include "OptionsItem.hpp"
|
#include "OptionsItem.hpp"
|
||||||
#include "Slider.hpp"
|
#include "Slider.hpp"
|
||||||
@@ -14,7 +14,7 @@ OptionsGroup::OptionsGroup( std::string labelID ) {
|
|||||||
void OptionsGroup::setupPositions() {
|
void OptionsGroup::setupPositions() {
|
||||||
// First we write the header and then we add the items
|
// First we write the header and then we add the items
|
||||||
int curY = y + 18;
|
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)->width = width - 5;
|
||||||
|
|
||||||
(*it)->y = curY;
|
(*it)->y = curY;
|
||||||
@@ -25,17 +25,17 @@ void OptionsGroup::setupPositions() {
|
|||||||
height = curY;
|
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 padX = 10.0f;
|
||||||
float padY = 5.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);
|
super::render(minecraft, xm, ym);
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsGroup& OptionsGroup::addOptionItem(OptionId optId, Minecraft* minecraft ) {
|
OptionsGroup& OptionsGroup::addOptionItem(OptionId optId, MinecraftClient& minecraft ) {
|
||||||
auto option = minecraft->options.getOpt(optId);
|
auto option = minecraft.options().getOpt(optId);
|
||||||
|
|
||||||
if (option == nullptr) return *this;
|
if (option == nullptr) return *this;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ OptionsGroup& OptionsGroup::addOptionItem(OptionId optId, Minecraft* minecraft )
|
|||||||
|
|
||||||
// TODO: wrap this copypaste shit into templates
|
// TODO: wrap this copypaste shit into templates
|
||||||
|
|
||||||
void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
void OptionsGroup::createToggle(OptionId optId, MinecraftClient& minecraft ) {
|
||||||
ImageDef def;
|
ImageDef def;
|
||||||
|
|
||||||
def.setSrc(IntRectangle(160, 206, 39, 20));
|
def.setSrc(IntRectangle(160, 206, 39, 20));
|
||||||
@@ -61,9 +61,9 @@ void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
|||||||
|
|
||||||
OptionButton* element = new OptionButton(optId);
|
OptionButton* element = new OptionButton(optId);
|
||||||
element->setImageDef(def, true);
|
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);
|
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||||
|
|
||||||
@@ -71,44 +71,44 @@ void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
|||||||
setupPositions();
|
setupPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsGroup::createProgressSlider(OptionId optId, Minecraft* minecraft ) {
|
void OptionsGroup::createProgressSlider(OptionId optId, MinecraftClient& minecraft ) {
|
||||||
Slider* element = new SliderFloat(minecraft, optId);
|
Slider* element = new SliderFloat(minecraft, optId);
|
||||||
element->width = 100;
|
element->width = 100;
|
||||||
element->height = 20;
|
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);
|
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||||
addChild(item);
|
addChild(item);
|
||||||
setupPositions();
|
setupPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsGroup::createStepSlider(OptionId optId, Minecraft* minecraft ) {
|
void OptionsGroup::createStepSlider(OptionId optId, MinecraftClient& minecraft ) {
|
||||||
Slider* element = new SliderInt(minecraft, optId);
|
Slider* element = new SliderInt(minecraft, optId);
|
||||||
element->width = 100;
|
element->width = 100;
|
||||||
element->height = 20;
|
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);
|
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||||
addChild(item);
|
addChild(item);
|
||||||
setupPositions();
|
setupPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsGroup::createTextbox(OptionId optId, Minecraft* minecraft) {
|
void OptionsGroup::createTextbox(OptionId optId, MinecraftClient& minecraft) {
|
||||||
TextBox* element = new TextOption(minecraft, optId);
|
TextBox* element = new TextOption(minecraft, optId);
|
||||||
element->width = 100;
|
element->width = 100;
|
||||||
element->height = 20;
|
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);
|
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||||
addChild(item);
|
addChild(item);
|
||||||
setupPositions();
|
setupPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsGroup::createKey(OptionId optId, Minecraft* minecraft) {
|
void OptionsGroup::createKey(OptionId optId, MinecraftClient& minecraft) {
|
||||||
KeyOption* element = new KeyOption(minecraft, optId);
|
KeyOption* element = new KeyOption(minecraft, optId);
|
||||||
element->width = 50;
|
element->width = 50;
|
||||||
element->height = 20;
|
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);
|
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||||
addChild(item);
|
addChild(item);
|
||||||
setupPositions();
|
setupPositions();
|
||||||
|
|||||||
@@ -8,22 +8,22 @@
|
|||||||
#include "client/Options.hpp"
|
#include "client/Options.hpp"
|
||||||
|
|
||||||
class Font;
|
class Font;
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
|
|
||||||
class OptionsGroup: public GuiElementContainer {
|
class OptionsGroup: public GuiElementContainer {
|
||||||
typedef GuiElementContainer super;
|
typedef GuiElementContainer super;
|
||||||
public:
|
public:
|
||||||
OptionsGroup(std::string labelID);
|
OptionsGroup(std::string labelID);
|
||||||
virtual void setupPositions();
|
virtual void setupPositions();
|
||||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
virtual void render(MinecraftClient& minecraft, int xm, int ym);
|
||||||
OptionsGroup& addOptionItem(OptionId optId, Minecraft* minecraft);
|
OptionsGroup& addOptionItem(OptionId optId, MinecraftClient& minecraft);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void createToggle(OptionId optId, Minecraft* minecraft);
|
void createToggle(OptionId optId, MinecraftClient& minecraft);
|
||||||
void createProgressSlider(OptionId optId, Minecraft* minecraft);
|
void createProgressSlider(OptionId optId, MinecraftClient& minecraft);
|
||||||
void createStepSlider(OptionId optId, Minecraft* minecraft);
|
void createStepSlider(OptionId optId, MinecraftClient& minecraft);
|
||||||
void createTextbox(OptionId optId, Minecraft* minecraft);
|
void createTextbox(OptionId optId, MinecraftClient& minecraft);
|
||||||
void createKey(OptionId optId, Minecraft* minecraft);
|
void createKey(OptionId optId, MinecraftClient& minecraft);
|
||||||
|
|
||||||
std::string label;
|
std::string label;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "OptionsItem.hpp"
|
#include "OptionsItem.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "locale/I18n.hpp"
|
#include "locale/I18n.hpp"
|
||||||
#include "util/Mth.hpp"
|
#include "util/Mth.hpp"
|
||||||
OptionsItem::OptionsItem( OptionId optionId, std::string label, GuiElement* element )
|
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() {
|
void OptionsItem::setupPositions() {
|
||||||
int currentHeight = 0;
|
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)->x = x + width - (*it)->width - 15;
|
||||||
(*it)->y = y + currentHeight;
|
(*it)->y = y + currentHeight;
|
||||||
currentHeight += (*it)->height;
|
currentHeight += (*it)->height;
|
||||||
@@ -19,11 +19,11 @@ void OptionsItem::setupPositions() {
|
|||||||
height = currentHeight;
|
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;
|
int yOffset = (height - 8) / 2;
|
||||||
std::string text = m_label;
|
std::string text = m_label;
|
||||||
if (m_optionId == OPTIONS_GUI_SCALE) {
|
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;
|
std::string scaleText;
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0: scaleText = I18n::get("options.guiScale.auto"); break;
|
case 0: scaleText = I18n::get("options.guiScale.auto"); break;
|
||||||
@@ -37,6 +37,6 @@ void OptionsItem::render( Minecraft* minecraft, int xm, int ym ) {
|
|||||||
text += ": " + scaleText;
|
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);
|
super::render(minecraft, xm, ym);
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ class OptionsItem: public GuiElementContainer
|
|||||||
typedef GuiElementContainer super;
|
typedef GuiElementContainer super;
|
||||||
public:
|
public:
|
||||||
OptionsItem(OptionId optionId, std::string label, GuiElement* element);
|
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();
|
void setupPositions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "RolledSelectionListV.hpp"
|
#include "RolledSelectionListV.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/renderer/gles.hpp"
|
#include "client/renderer/gles.hpp"
|
||||||
#include "platform/input/Mouse.hpp"
|
#include "platform/input/Mouse.hpp"
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "client/renderer/Textures.hpp"
|
#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_),
|
: minecraft(minecraft_),
|
||||||
width(width_),
|
width(width_),
|
||||||
height(height_),
|
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 )
|
void RolledSelectionListV::renderHoleBackground( /*float x0, float x1,*/ float y0, float y1, int a0, int a1 )
|
||||||
{
|
{
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||||
glColor4f2(1.0f, 1, 1, 1);
|
glColor4f2(1.0f, 1, 1, 1);
|
||||||
float s = 32;
|
float s = 32;
|
||||||
t.begin();
|
t.begin();
|
||||||
@@ -336,7 +336,7 @@ void RolledSelectionListV::renderDirtBackground()
|
|||||||
float by0 = _renderTopBorder? y0 : 0;
|
float by0 = _renderTopBorder? y0 : 0;
|
||||||
float by1 = _renderBottomBorder? y1 : height;
|
float by1 = _renderBottomBorder? y1 : height;
|
||||||
|
|
||||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||||
glColor4f2(1.0f, 1, 1, 1);
|
glColor4f2(1.0f, 1, 1, 1);
|
||||||
float s = 32;
|
float s = 32;
|
||||||
const float uvy = (float)((int) yo);
|
const float uvy = (float)((int) yo);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "client/gui/GuiComponent.hpp"
|
#include "client/gui/GuiComponent.hpp"
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
class Tesselator;
|
class Tesselator;
|
||||||
|
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ class RolledSelectionListV : public GuiComponent
|
|||||||
static const int DRAG_OUTSIDE = -2;
|
static const int DRAG_OUTSIDE = -2;
|
||||||
static const int DRAG_NORMAL = 0;
|
static const int DRAG_NORMAL = 0;
|
||||||
public:
|
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);
|
virtual int getItemAtPosition(int x, int y);
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ protected:
|
|||||||
virtual void onPostRender();
|
virtual void onPostRender();
|
||||||
void renderDirtBackground();
|
void renderDirtBackground();
|
||||||
protected:
|
protected:
|
||||||
Minecraft* minecraft;
|
MinecraftClient& minecraft;
|
||||||
|
|
||||||
float x0;
|
float x0;
|
||||||
float x1;
|
float x1;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "ScrolledSelectionList.hpp"
|
#include "ScrolledSelectionList.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/renderer/gles.hpp"
|
#include "client/renderer/gles.hpp"
|
||||||
#include "platform/input/Mouse.hpp"
|
#include "platform/input/Mouse.hpp"
|
||||||
@@ -9,7 +9,7 @@ static int Abs(int d) {
|
|||||||
return d >= 0? d : -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),
|
: minecraft(_minecraft),
|
||||||
width(_width),
|
width(_width),
|
||||||
height(_height),
|
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 )
|
void ScrolledSelectionList::renderHoleBackground( float y0, float y1, int a0, int a1 )
|
||||||
{
|
{
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||||
glColor4f2(1.0f, 1, 1, 1);
|
glColor4f2(1.0f, 1, 1, 1);
|
||||||
float s = 32;
|
float s = 32;
|
||||||
t.begin();
|
t.begin();
|
||||||
@@ -283,7 +283,7 @@ void ScrolledSelectionList::renderHoleBackground( float y0, float y1, int a0, in
|
|||||||
void ScrolledSelectionList::renderDirtBackground()
|
void ScrolledSelectionList::renderDirtBackground()
|
||||||
{
|
{
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||||
glColor4f2(1.0f, 1, 1, 1);
|
glColor4f2(1.0f, 1, 1, 1);
|
||||||
float s = 32;
|
float s = 32;
|
||||||
t.begin();
|
t.begin();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "client/gui/GuiComponent.hpp"
|
#include "client/gui/GuiComponent.hpp"
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
class Tesselator;
|
class Tesselator;
|
||||||
|
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ class ScrolledSelectionList : public GuiComponent
|
|||||||
static const int DRAG_NORMAL = 0;
|
static const int DRAG_NORMAL = 0;
|
||||||
static const int DRAG_SKIP = 1; // special case to fix android jump bug
|
static const int DRAG_SKIP = 1; // special case to fix android jump bug
|
||||||
public:
|
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);
|
virtual void setRenderSelection(bool _renderSelection);
|
||||||
protected:
|
protected:
|
||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
virtual void renderHoleBackground(float y0, float y1, int a0, int a1);
|
virtual void renderHoleBackground(float y0, float y1, int a0, int a1);
|
||||||
void renderDirtBackground();
|
void renderDirtBackground();
|
||||||
protected:
|
protected:
|
||||||
Minecraft* minecraft;
|
MinecraftClient& minecraft;
|
||||||
|
|
||||||
float y0;
|
float y0;
|
||||||
float y1;
|
float y1;
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ ScrollingPane::~ScrollingPane() {
|
|||||||
delete[] selected;
|
delete[] selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void ScrollingPane::init(Minecraft* mc, int width, int height) {
|
//void ScrollingPane::init(MinecraftClient& mc, int width, int height) {
|
||||||
// this->mc = mc;
|
// this->mc = mc;
|
||||||
// this->width = width;
|
// this->width = width;
|
||||||
// this->height = height;
|
// 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(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();
|
~ScrollingPane();
|
||||||
//void init(Minecraft*, int width, int height);
|
//void init(MinecraftClient&, int width, int height);
|
||||||
void tick();
|
void tick();
|
||||||
void render(int xm, int ym, float alpha);
|
void render(int xm, int ym, float alpha);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "Slider.hpp"
|
#include "Slider.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
#include "client/gui/Screen.hpp"
|
#include "client/gui/Screen.hpp"
|
||||||
#include "locale/I18n.hpp"
|
#include "locale/I18n.hpp"
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
Slider::Slider(OptionId optId) : m_mouseDownOnElement(false), m_optId(optId), m_numSteps(0) {}
|
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 xSliderStart = x + 5;
|
||||||
int xSliderEnd = x + width - 5;
|
int xSliderEnd = x + width - 5;
|
||||||
int ySliderStart = y + 6;
|
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);
|
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)) {
|
if(pointInside(x, y)) {
|
||||||
m_mouseDownOnElement = true;
|
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;
|
m_mouseDownOnElement = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slider::tick(Minecraft* minecraft) {
|
void Slider::tick(MinecraftClient& minecraft) {
|
||||||
if(minecraft->screen != NULL) {
|
if(minecraft.getScreen()!= NULL) {
|
||||||
int xm = Mouse::getX();
|
int xm = Mouse::getX();
|
||||||
int ym = Mouse::getY();
|
int ym = Mouse::getY();
|
||||||
|
|
||||||
minecraft->screen->toGUICoordinate(xm, ym);
|
minecraft.getScreen()->toGUICoordinate(xm, ym);
|
||||||
|
|
||||||
if(m_mouseDownOnElement) {
|
if(m_mouseDownOnElement) {
|
||||||
m_percentage = float(xm - x) / float(width);
|
m_percentage = float(xm - x) / float(width);
|
||||||
@@ -56,24 +56,24 @@ void Slider::tick(Minecraft* minecraft) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SliderFloat::SliderFloat(Minecraft* minecraft, OptionId option)
|
SliderFloat::SliderFloat(MinecraftClient& minecraft, OptionId option)
|
||||||
: Slider(option), m_option(dynamic_cast<OptionFloat*>(minecraft->options.getOpt(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);
|
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)
|
SliderInt::SliderInt(MinecraftClient& minecraft, OptionId option)
|
||||||
: Slider(option), m_option(dynamic_cast<OptionInt*>(minecraft->options.getOpt(option)))
|
: Slider(option), m_option(dynamic_cast<OptionInt*>(minecraft.options().getOpt(option)))
|
||||||
{
|
{
|
||||||
m_numSteps = m_option->getMax() - m_option->getMin() + 1;
|
m_numSteps = m_option->getMax() - m_option->getMin() + 1;
|
||||||
m_percentage = float(m_option->get() - m_option->getMin()) / (m_numSteps-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);
|
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);
|
Slider::mouseReleased(minecraft, x, y, buttonNum);
|
||||||
|
|
||||||
if (pointInside(x, y)) {
|
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());
|
curStep = Mth::clamp(curStep + m_option->getMin(), m_option->getMin(), m_option->getMax());
|
||||||
m_percentage = float(curStep - m_option->getMin()) / (m_numSteps-1);
|
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);
|
Slider::mouseReleased(minecraft, x, y, buttonNum);
|
||||||
|
|
||||||
if (pointInside(x, y)) {
|
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 {
|
class Slider : public GuiElement {
|
||||||
typedef GuiElement super;
|
typedef GuiElement super;
|
||||||
public:
|
public:
|
||||||
virtual void render( Minecraft* minecraft, int xm, int ym );
|
virtual void render( MinecraftClient& minecraft, int xm, int ym );
|
||||||
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
|
virtual void mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum );
|
||||||
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
|
virtual void mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum );
|
||||||
virtual void tick(Minecraft* minecraft);
|
virtual void tick(MinecraftClient& minecraft);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Slider(OptionId optId);
|
Slider(OptionId optId);
|
||||||
@@ -24,9 +24,9 @@ protected:
|
|||||||
|
|
||||||
class SliderFloat : public Slider {
|
class SliderFloat : public Slider {
|
||||||
public:
|
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:
|
protected:
|
||||||
OptionFloat* m_option;
|
OptionFloat* m_option;
|
||||||
@@ -35,10 +35,10 @@ protected:
|
|||||||
|
|
||||||
class SliderInt : public Slider {
|
class SliderInt : public Slider {
|
||||||
public:
|
public:
|
||||||
SliderInt(Minecraft* minecraft, OptionId option);
|
SliderInt(MinecraftClient& minecraft, OptionId option);
|
||||||
|
|
||||||
virtual void render( Minecraft* minecraft, int xm, int ym ) override;
|
virtual void render( MinecraftClient& minecraft, int xm, int ym ) override;
|
||||||
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:
|
protected:
|
||||||
OptionInt* m_option;
|
OptionInt* m_option;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "TextBox.hpp"
|
#include "TextBox.hpp"
|
||||||
#include "client/gui/Gui.hpp"
|
#include "client/gui/Gui.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "AppPlatform.hpp"
|
#include "AppPlatform.hpp"
|
||||||
#include "platform/input/Mouse.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) {
|
if (!focused) {
|
||||||
minecraft->platform()->showKeyboard();
|
minecraft.platform()->showKeyboard();
|
||||||
focused = true;
|
focused = true;
|
||||||
blinkTicks = 0;
|
blinkTicks = 0;
|
||||||
blink = false;
|
blink = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextBox::loseFocus(Minecraft* minecraft) {
|
bool TextBox::loseFocus(MinecraftClient& minecraft) {
|
||||||
if (focused) {
|
if (focused) {
|
||||||
minecraft->platform()->hideKeyboard();
|
minecraft.platform()->hideKeyboard();
|
||||||
focused = false;
|
focused = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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 (buttonNum == MouseAction::ACTION_LEFT) {
|
||||||
if (pointInside(x, y)) {
|
if (pointInside(x, y)) {
|
||||||
setFocus(minecraft);
|
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) {
|
if (focused && c >= 32 && c < 127 && (int)text.size() < 256) {
|
||||||
text.push_back(c);
|
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()) {
|
if (focused && key == Keyboard::KEY_BACKSPACE && !text.empty()) {
|
||||||
text.pop_back();
|
text.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBox::tick(Minecraft* minecraft) {
|
void TextBox::tick(MinecraftClient& minecraft) {
|
||||||
blinkTicks++;
|
blinkTicks++;
|
||||||
if (blinkTicks >= 5) {
|
if (blinkTicks >= 5) {
|
||||||
blink = !blink;
|
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
|
// textbox like in beta 1.7.3
|
||||||
// change appearance when focused so the user can tell it's active
|
// change appearance when focused so the user can tell it's active
|
||||||
// active background darker gray with a subtle border
|
// 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);
|
glEnable2(GL_SCISSOR_TEST);
|
||||||
glScissor(
|
glScissor(
|
||||||
Gui::GuiScale * (x + 2),
|
Gui::GuiScale * (x + 2),
|
||||||
minecraft->height - Gui::GuiScale * (y + height - 2),
|
minecraft.getScreenHeight() - Gui::GuiScale * (y + height - 2),
|
||||||
Gui::GuiScale * (width - 2),
|
Gui::GuiScale * (width - 2),
|
||||||
Gui::GuiScale * (height - 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;
|
int _y = y + (height - Font::DefaultLineHeight) / 2;
|
||||||
|
|
||||||
if (text.empty() && !focused) {
|
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('_');
|
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();
|
if (focused && blink) text.pop_back();
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "platform/input/Keyboard.hpp"
|
#include "platform/input/Keyboard.hpp"
|
||||||
|
|
||||||
class Font;
|
class Font;
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
|
|
||||||
class TextBox: public GuiElement
|
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, const std::string& msg);
|
||||||
TextBox(int id, int x, int y, int w, int h, const std::string& msg);
|
TextBox(int id, int x, int y, int w, 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 void setFocus(MinecraftClient& minecraft);
|
||||||
virtual bool loseFocus(Minecraft* 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 keyPressed(MinecraftClient& minecraft, int key);
|
||||||
virtual void charPressed(Minecraft* minecraft, char c);
|
virtual void charPressed(MinecraftClient& minecraft, char c);
|
||||||
virtual void tick(Minecraft* minecraft);
|
virtual void tick(MinecraftClient& minecraft);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string hint;
|
std::string hint;
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#include "TextOption.hpp"
|
#include "TextOption.hpp"
|
||||||
#include <client/Minecraft.hpp>
|
#include <client/Minecraft.hpp>
|
||||||
|
|
||||||
TextOption::TextOption(Minecraft* minecraft, OptionId optId)
|
TextOption::TextOption(MinecraftClient& minecraft, OptionId optId)
|
||||||
: TextBox((int)optId, minecraft->options.getOpt(optId)->getStringId())
|
: 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)) {
|
if (TextBox::loseFocus(minecraft)) {
|
||||||
minecraft->options.set((OptionId)id, text);
|
minecraft.options().set((OptionId)id, text);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
class TextOption : public TextBox {
|
class TextOption : public TextBox {
|
||||||
public:
|
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 "ArmorScreen.hpp"
|
||||||
#include "client/gui/Screen.hpp"
|
#include "client/gui/Screen.hpp"
|
||||||
#include "client/gui/components/NinePatch.hpp"
|
#include "client/gui/components/NinePatch.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/player/LocalPlayer.hpp"
|
#include "client/player/LocalPlayer.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||||
@@ -73,7 +73,7 @@ ArmorScreen::~ArmorScreen() {
|
|||||||
void ArmorScreen::init() {
|
void ArmorScreen::init() {
|
||||||
super::init();
|
super::init();
|
||||||
|
|
||||||
player = minecraft->player;
|
player = minecraft.player();
|
||||||
|
|
||||||
ImageDef def;
|
ImageDef def;
|
||||||
def.name = "gui/spritesheet.png";
|
def.name = "gui/spritesheet.png";
|
||||||
@@ -95,7 +95,7 @@ void ArmorScreen::init() {
|
|||||||
buttons.push_back(armorButtons[i]);
|
buttons.push_back(armorButtons[i]);
|
||||||
|
|
||||||
// GUI - nine patches
|
// 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);
|
guiBackground = builder.createSymmetrical(IntRectangle(0, 0, 16, 16), 4, 4);
|
||||||
guiSlot = builder.createSymmetrical(IntRectangle(0, 32, 8, 8), 3, 3, 20, 20);
|
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) {
|
void ArmorScreen::buttonClicked(Button* button) {
|
||||||
if (button == &btnClose) {
|
if (button == &btnClose) {
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button->id >= 0 && button->id <= 3) {
|
if (button->id >= 0 && button->id <= 3) {
|
||||||
@@ -252,8 +252,8 @@ std::vector<const ItemInstance*> ArmorScreen::getItems( const Touch::InventoryPa
|
|||||||
void ArmorScreen::updateItems() {
|
void ArmorScreen::updateItems() {
|
||||||
armorItems.clear();
|
armorItems.clear();
|
||||||
|
|
||||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft->player->inventory->getContainerSize(); ++i) {
|
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft.player()->inventory->getContainerSize(); ++i) {
|
||||||
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
ItemInstance* item = minecraft.player()->inventory->getItem(i);
|
||||||
if (ItemInstance::isArmorItem(item))
|
if (ItemInstance::isArmorItem(item))
|
||||||
armorItems.push_back(item);
|
armorItems.push_back(item);
|
||||||
}
|
}
|
||||||
@@ -281,13 +281,13 @@ void ArmorScreen::drawSlotItemAt( Tesselator& t, int slot, const ItemInstance* i
|
|||||||
guiSlot->draw(t, xx, yy);
|
guiSlot->draw(t, xx, yy);
|
||||||
|
|
||||||
if (item && !item->isNull()) {
|
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);
|
glDisable2(GL_TEXTURE_2D);
|
||||||
ItemRenderer::renderGuiItemDecorations(item, xx + 2, yy + 3);
|
ItemRenderer::renderGuiItemDecorations(item, xx + 2, yy + 3);
|
||||||
glEnable2(GL_TEXTURE_2D);
|
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 {
|
} 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);
|
blit(x + 2, y, 15 * 16, slot * 16, 16, 16, 16, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,14 +297,14 @@ void ArmorScreen::takeAndClearSlot( int slot ) {
|
|||||||
if (!item)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int oldSize = minecraft->player->inventory->getNumEmptySlots();
|
int oldSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||||
|
|
||||||
if (!minecraft->player->inventory->add(item))
|
if (!minecraft.player()->inventory->add(item))
|
||||||
minecraft->player->drop(new ItemInstance(*item), false);
|
minecraft.player()->drop(new ItemInstance(*item), false);
|
||||||
|
|
||||||
player->setArmor(slot, NULL);
|
player->setArmor(slot, NULL);
|
||||||
|
|
||||||
int newSize = minecraft->player->inventory->getNumEmptySlots();
|
int newSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||||
setIfNotSet(doRecreatePane, newSize != oldSize);
|
setIfNotSet(doRecreatePane, newSize != oldSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ void ArmorScreen::renderPlayer(float xo, float yo) {
|
|||||||
glRotatef(180, 0, 0, 1);
|
glRotatef(180, 0, 0, 1);
|
||||||
//glDisable(GL_DEPTH_TEST);
|
//glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
Player* player = (Player*) minecraft->player;
|
Player* player = (Player*) minecraft.player();
|
||||||
float oybr = player->yBodyRot;
|
float oybr = player->yBodyRot;
|
||||||
float oyr = player->yRot;
|
float oyr = player->yRot;
|
||||||
float oxr = player->xRot;
|
float oxr = player->xRot;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "client/gui/Screen.hpp"
|
#include "client/gui/Screen.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/player/LocalPlayer.hpp"
|
#include "client/player/LocalPlayer.hpp"
|
||||||
|
|
||||||
class BaseContainerMenu;
|
class BaseContainerMenu;
|
||||||
@@ -13,26 +13,23 @@ class BaseContainerScreen: public Screen
|
|||||||
{
|
{
|
||||||
typedef Screen super;
|
typedef Screen super;
|
||||||
public:
|
public:
|
||||||
BaseContainerScreen(BaseContainerMenu* menu)
|
BaseContainerScreen(MinecraftClient& mc, BaseContainerMenu* menu) : Screen(mc), menu(menu) {}
|
||||||
: menu(menu)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void init() {
|
virtual void init() {
|
||||||
super::init();
|
super::init();
|
||||||
minecraft->player->containerMenu = menu;
|
minecraft.player()->containerMenu = menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void tick() {
|
virtual void tick() {
|
||||||
super::tick();
|
super::tick();
|
||||||
if (!minecraft->player->isAlive() || minecraft->player->removed)
|
if (!minecraft.player()->isAlive() || minecraft.player()->removed)
|
||||||
minecraft->player->closeContainer();
|
minecraft.player()->closeContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void keyPressed( int eventKey )
|
virtual void keyPressed( int eventKey )
|
||||||
{
|
{
|
||||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||||
minecraft->player->closeContainer();
|
minecraft.player()->closeContainer();
|
||||||
} else {
|
} else {
|
||||||
super::keyPressed(eventKey);
|
super::keyPressed(eventKey);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,40 @@
|
|||||||
#include "ChatScreen.hpp"
|
#include "ChatScreen.hpp"
|
||||||
#include "DialogDefinitions.hpp"
|
#include "client/gui/Screen.hpp"
|
||||||
#include "client/gui/Gui.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/Minecraft.hpp"
|
|
||||||
#include "AppPlatform.hpp"
|
|
||||||
#include "platform/log.hpp"
|
|
||||||
|
|
||||||
void ChatScreen::init() {
|
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)
|
void ChatScreen::render(int xm, int ym, float a) {
|
||||||
{
|
fillGradient(0, 0, width, height, 0x00000000, 0x40000000);
|
||||||
int status = minecraft->platform()->getUserInputStatus();
|
m_input.focused = true;
|
||||||
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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
#pragma once
|
||||||
|
|
||||||
#include "client/gui/Screen.hpp"
|
#include "client/gui/Screen.hpp"
|
||||||
|
#include "client/gui/components/TextBox.hpp"
|
||||||
|
|
||||||
class ChatScreen: public Screen
|
class ChatScreen: public Screen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ChatScreen() {}
|
ChatScreen();
|
||||||
virtual ~ChatScreen() {}
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void render(int xm, int ym, float a);
|
void render(int xm, int ym, float a);
|
||||||
|
|
||||||
void buttonClicked(Button* button) {};
|
void buttonClicked(Button* button) {};
|
||||||
|
|
||||||
|
bool handleBackEvent(bool isDown);
|
||||||
|
void keyPressed(int eventKey);
|
||||||
private:
|
private:
|
||||||
|
TextBox m_input;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "touch/TouchStartMenuScreen.hpp"
|
#include "touch/TouchStartMenuScreen.hpp"
|
||||||
#include "client/gui/Screen.hpp"
|
#include "client/gui/Screen.hpp"
|
||||||
#include "client/gui/components/NinePatch.hpp"
|
#include "client/gui/components/NinePatch.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/player/LocalPlayer.hpp"
|
#include "client/player/LocalPlayer.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||||
@@ -110,7 +110,7 @@ typedef struct FlyingItem {
|
|||||||
static std::vector<FlyingItem> flyingItems;
|
static std::vector<FlyingItem> flyingItems;
|
||||||
|
|
||||||
ChestScreen::ChestScreen(Player* player, ChestTileEntity* chest)
|
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),
|
inventoryPane(NULL),
|
||||||
chestPane(NULL),
|
chestPane(NULL),
|
||||||
btnClose(4, ""),
|
btnClose(4, ""),
|
||||||
@@ -163,7 +163,7 @@ void ChestScreen::init() {
|
|||||||
buttons.push_back(&btnClose);
|
buttons.push_back(&btnClose);
|
||||||
|
|
||||||
// GUI - nine patches
|
// 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);
|
guiBackground = builder.createSymmetrical(IntRectangle(0, 0, 16, 16), 4, 4);
|
||||||
guiSlot = builder.createSymmetrical(IntRectangle(0, 32, 8, 8), 3, 3);
|
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;
|
heldMs = ms;
|
||||||
|
|
||||||
FillingContainer* c = (pane == inventoryPane)?
|
FillingContainer* c = (pane == inventoryPane)?
|
||||||
upcast<FillingContainer>(minecraft->player->inventory)
|
upcast<FillingContainer>(minecraft.player()->inventory)
|
||||||
: upcast<FillingContainer>(chest);
|
: upcast<FillingContainer>(chest);
|
||||||
|
|
||||||
const int slotIndex = id + c->getNumLinkedSlots();
|
const int slotIndex = id + c->getNumLinkedSlots();
|
||||||
@@ -270,7 +270,7 @@ void ChestScreen::render(int xm, int ym, float a) {
|
|||||||
|
|
||||||
glEnable2(GL_SCISSOR_TEST);
|
glEnable2(GL_SCISSOR_TEST);
|
||||||
//LOGI("panesBox: %d, %d - %d, %d\n", panesBbox.x, panesBbox.y, panesBbox.w, panesBbox.h);
|
//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) {
|
for (unsigned int i = 0; i < flyingItems.size(); ++i) {
|
||||||
FlyingItem& fi = flyingItems[i];
|
FlyingItem& fi = flyingItems[i];
|
||||||
float since = (now - fi.startTime);
|
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 xx = Mth::lerp(fi.sx, fi.dx, t);
|
||||||
float yy = Mth::lerp(fi.sy, fi.dy, t);
|
float yy = Mth::lerp(fi.sy, fi.dy, t);
|
||||||
ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, &fi.item, xx + 7, yy + 8, 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);
|
//minecraft.gui().renderSlotText(&fi.item, xx + 3, yy + 3, true, true);
|
||||||
|
|
||||||
flyingToSave.push_back(fi);
|
flyingToSave.push_back(fi);
|
||||||
}
|
}
|
||||||
@@ -295,12 +295,12 @@ void ChestScreen::render(int xm, int ym, float a) {
|
|||||||
t.colorABGR(0xffffffff);
|
t.colorABGR(0xffffffff);
|
||||||
glDisable2(GL_BLEND);
|
glDisable2(GL_BLEND);
|
||||||
|
|
||||||
minecraft->textures->loadAndBindTexture("gui/spritesheet.png");
|
minecraft.textures().loadAndBindTexture("gui/spritesheet.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChestScreen::buttonClicked(Button* button) {
|
void ChestScreen::buttonClicked(Button* button) {
|
||||||
if (button == &btnClose) {
|
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;
|
fi.dy = gTo.yf;
|
||||||
flyingItems.push_back(fi);
|
flyingItems.push_back(fi);
|
||||||
|
|
||||||
if (!fromChest && minecraft->level->isClientSide) {
|
if (!fromChest && minecraft.level->isClientSide) {
|
||||||
int j = toIndex;
|
int j = toIndex;
|
||||||
ItemInstance item = items[j]? *items[j] : ItemInstance();
|
ItemInstance item = items[j]? *items[j] : ItemInstance();
|
||||||
ContainerSetSlotPacket p(menu->containerId, j, item);
|
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) {
|
if (fromChest) {
|
||||||
ItemInstance ins(item->count <= 0? ItemInstance() : *item);
|
ItemInstance ins(item->count <= 0? ItemInstance() : *item);
|
||||||
ContainerSetSlotPacket p(menu->containerId, slotIndex, ins);
|
ContainerSetSlotPacket p(menu->containerId, slotIndex, ins);
|
||||||
minecraft->raknetInstance->send(p);
|
minecraft.raknetInstance->send(p);
|
||||||
}
|
}
|
||||||
if (item->count <= 0)
|
if (item->count <= 0)
|
||||||
from->clearSlot(slotIndex);
|
from->clearSlot(slotIndex);
|
||||||
@@ -380,8 +380,8 @@ bool ChestScreen::handleAddItem(FillingContainer* from, FillingContainer* to, in
|
|||||||
bool ChestScreen::addItem(const Touch::InventoryPane* forPane, int itemIndex) {
|
bool ChestScreen::addItem(const Touch::InventoryPane* forPane, int itemIndex) {
|
||||||
//LOGI("items.size, index: %d, %d\n", inventoryItems.size(), itemIndex);
|
//LOGI("items.size, index: %d, %d\n", inventoryItems.size(), itemIndex);
|
||||||
bool l2r = (forPane == inventoryPane);
|
bool l2r = (forPane == inventoryPane);
|
||||||
return handleAddItem( l2r? upcast<FillingContainer>(minecraft->player->inventory) : upcast<FillingContainer>(chest),
|
return handleAddItem( l2r? upcast<FillingContainer>(minecraft.player()->inventory) : upcast<FillingContainer>(chest),
|
||||||
l2r? upcast<FillingContainer>(chest) : upcast<FillingContainer>(minecraft->player->inventory),
|
l2r? upcast<FillingContainer>(chest) : upcast<FillingContainer>(minecraft.player()->inventory),
|
||||||
itemIndex);
|
itemIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,8 +398,8 @@ bool ChestScreen::renderGameBehind()
|
|||||||
std::vector<const ItemInstance*> ChestScreen::getItems( const Touch::InventoryPane* forPane )
|
std::vector<const ItemInstance*> ChestScreen::getItems( const Touch::InventoryPane* forPane )
|
||||||
{
|
{
|
||||||
if (forPane == inventoryPane) {
|
if (forPane == inventoryPane) {
|
||||||
for (int i = Inventory::MAX_SELECTION_SIZE, j = 0; i < minecraft->player->inventory->getContainerSize(); ++i, ++j)
|
for (int i = Inventory::MAX_SELECTION_SIZE, j = 0; i < minecraft.player()->inventory->getContainerSize(); ++i, ++j)
|
||||||
inventoryItems[j] = minecraft->player->inventory->getItem(i);
|
inventoryItems[j] = minecraft.player()->inventory->getItem(i);
|
||||||
return inventoryItems;
|
return inventoryItems;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -413,8 +413,8 @@ std::vector<const ItemInstance*> ChestScreen::getItems( const Touch::InventoryPa
|
|||||||
void ChestScreen::setupPane()
|
void ChestScreen::setupPane()
|
||||||
{
|
{
|
||||||
inventoryItems.clear();
|
inventoryItems.clear();
|
||||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft->player->inventory->getContainerSize(); ++i) {
|
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft.player()->inventory->getContainerSize(); ++i) {
|
||||||
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
ItemInstance* item = minecraft.player()->inventory->getItem(i);
|
||||||
/*if (!item || item->isNull()) continue;*/
|
/*if (!item || item->isNull()) continue;*/
|
||||||
inventoryItems.push_back(item);
|
inventoryItems.push_back(item);
|
||||||
}
|
}
|
||||||
@@ -439,7 +439,7 @@ void ChestScreen::setupPane()
|
|||||||
#endif
|
#endif
|
||||||
// IntRectangle(0, 0, 100, 100)
|
// IntRectangle(0, 0, 100, 100)
|
||||||
if (inventoryPane) delete inventoryPane;
|
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->fillMarginX = 0;
|
||||||
inventoryPane->fillMarginY = 0;
|
inventoryPane->fillMarginY = 0;
|
||||||
guiPaneFrame->setSize((float)rect.w + 2, (float)rect.h + 2);
|
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);
|
guiSlotMarker->draw(t, xx - 2, yy - 2);
|
||||||
|
|
||||||
if (item && !item->isNull()) {
|
if (item && !item->isNull()) {
|
||||||
ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, item, xx + 7, yy + 8, true);
|
ItemRenderer::renderGuiItem(minecraft.font(), minecraft.textures(), item, xx + 7, yy + 8, true);
|
||||||
minecraft->gui.renderSlotText(item, xx + 3, yy + 3, true, true);
|
minecraft.gui().renderSlotText(item, xx + 3, yy + 3, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "ChooseLevelScreen.hpp"
|
#include "ChooseLevelScreen.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
|
|
||||||
void ChooseLevelScreen::init() {
|
void ChooseLevelScreen::init() {
|
||||||
loadLevelSource();
|
loadLevelSource();
|
||||||
@@ -9,7 +9,7 @@ void ChooseLevelScreen::init() {
|
|||||||
|
|
||||||
void ChooseLevelScreen::loadLevelSource()
|
void ChooseLevelScreen::loadLevelSource()
|
||||||
{
|
{
|
||||||
LevelStorageSource* levelSource = minecraft->getLevelSource();
|
LevelStorageSource* levelSource = minecraft.getLevelSource();
|
||||||
levelSource->getLevelList(levels);
|
levelSource->getLevelList(levels);
|
||||||
std::sort(levels.begin(), levels.end());
|
std::sort(levels.begin(), levels.end());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "ConfirmScreen.hpp"
|
#include "ConfirmScreen.hpp"
|
||||||
#include "client/gui/components/Button.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_)
|
ConfirmScreen::ConfirmScreen(Screen* parent_, const std::string& title1_, const std::string& title2_, int id_)
|
||||||
: parent(parent_),
|
: parent(parent_),
|
||||||
@@ -31,7 +31,7 @@ ConfirmScreen::~ConfirmScreen() {
|
|||||||
|
|
||||||
void ConfirmScreen::init()
|
void ConfirmScreen::init()
|
||||||
{
|
{
|
||||||
if (/* minecraft->useTouchscreen() */ true) {
|
if (/* minecraft.useTouchscreen() */ true) {
|
||||||
yesButton = new Touch::TButton(0, 0, 0, yesButtonText),
|
yesButton = new Touch::TButton(0, 0, 0, yesButtonText),
|
||||||
noButton = new Touch::TButton(1, 0, 0, noButtonText);
|
noButton = new Touch::TButton(1, 0, 0, noButtonText);
|
||||||
} else {
|
} 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 "CreditsScreen.hpp"
|
||||||
#include "StartMenuScreen.hpp"
|
#include "StartMenuScreen.hpp"
|
||||||
#include "OptionsScreen.hpp"
|
#include "OptionsScreen.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/gui/components/Button.hpp"
|
#include "client/gui/components/Button.hpp"
|
||||||
#include "client/gui/components/ImageButton.hpp"
|
#include "client/gui/components/ImageButton.hpp"
|
||||||
#include "platform/input/Mouse.hpp"
|
#include "platform/input/Mouse.hpp"
|
||||||
@@ -67,7 +67,7 @@ void CreditsScreen::tick() {
|
|||||||
// move text upward
|
// move text upward
|
||||||
_scrollY -= _scrollSpeed;
|
_scrollY -= _scrollSpeed;
|
||||||
// if text has scrolled off the top, restart
|
// 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) {
|
if (_scrollY + totalHeight < 0) {
|
||||||
_scrollY = height;
|
_scrollY = height;
|
||||||
}
|
}
|
||||||
@@ -82,9 +82,9 @@ void CreditsScreen::tick() {
|
|||||||
void CreditsScreen::render(int xm, int ym, float a) {
|
void CreditsScreen::render(int xm, int ym, float a) {
|
||||||
renderBackground();
|
renderBackground();
|
||||||
int w = width;
|
int w = width;
|
||||||
Font* font = minecraft->font;
|
Font* font = minecraft.font();
|
||||||
float y = _scrollY;
|
float y = _scrollY;
|
||||||
const float lineHeight = font->lineHeight + 8;
|
const float lineHeight = font.lineHeight + 8;
|
||||||
for (size_t i = 0; i < _lines.size(); ++i) {
|
for (size_t i = 0; i < _lines.size(); ++i) {
|
||||||
const std::string& line = _lines[i];
|
const std::string& line = _lines[i];
|
||||||
// use color-tag-aware drawing, centre by total width
|
// 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
|
// underline hyperlink lines manually
|
||||||
if (line.find("http") != std::string::npos || line.find("discord.gg") != std::string::npos) {
|
if (line.find("http") != std::string::npos || line.find("discord.gg") != std::string::npos) {
|
||||||
float x0 = w/2 - lineWidth/2;
|
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);
|
this->fill(x0, y0, x0 + lineWidth, y0 + 1, 0xffffffff);
|
||||||
}
|
}
|
||||||
y += lineHeight;
|
y += lineHeight;
|
||||||
@@ -104,13 +104,13 @@ void CreditsScreen::render(int xm, int ym, float a) {
|
|||||||
|
|
||||||
void CreditsScreen::buttonClicked(Button* button) {
|
void CreditsScreen::buttonClicked(Button* button) {
|
||||||
if (button->id == 1) {
|
if (button->id == 1) {
|
||||||
minecraft->setScreen(new OptionsScreen());
|
minecraft.setScreen(new OptionsScreen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreditsScreen::mouseClicked(int x, int y, int buttonNum) {
|
void CreditsScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||||
// map click to a line in the scrolling text
|
// 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) {
|
for (size_t i = 0; i < _lines.size(); ++i) {
|
||||||
float lineY = _scrollY + i * lineHeight;
|
float lineY = _scrollY + i * lineHeight;
|
||||||
if (y >= lineY && y < lineY + lineHeight) {
|
if (y >= lineY && y < lineY + lineHeight) {
|
||||||
@@ -122,7 +122,7 @@ void CreditsScreen::mouseClicked(int x, int y, int buttonNum) {
|
|||||||
// extract until space
|
// extract until space
|
||||||
size_t end = line.find(' ', start);
|
size_t end = line.find(' ', start);
|
||||||
std::string url = line.substr(start, (end == std::string::npos) ? std::string::npos : end - 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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "DeathScreen.hpp"
|
#include "DeathScreen.hpp"
|
||||||
#include "ScreenChooser.hpp"
|
#include "ScreenChooser.hpp"
|
||||||
#include "client/gui/components/Button.hpp"
|
#include "client/gui/components/Button.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/player/LocalPlayer.hpp"
|
#include "client/player/LocalPlayer.hpp"
|
||||||
#include "platform/time.hpp"
|
#include "platform/time.hpp"
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ DeathScreen::~DeathScreen()
|
|||||||
|
|
||||||
void DeathScreen::init()
|
void DeathScreen::init()
|
||||||
{
|
{
|
||||||
if (/* minecraft->useTouchscreen() */ true) {
|
if (/* minecraft.useTouchscreen() */ true) {
|
||||||
bRespawn = new Touch::TButton(1, "Respawn!");
|
bRespawn = new Touch::TButton(1, "Respawn!");
|
||||||
bTitle = new Touch::TButton(2, "Main menu");
|
bTitle = new Touch::TButton(2, "Main menu");
|
||||||
} else {
|
} else {
|
||||||
@@ -71,13 +71,13 @@ void DeathScreen::buttonClicked( Button* button )
|
|||||||
|
|
||||||
if (button == bRespawn) {
|
if (button == bRespawn) {
|
||||||
//RespawnPacket packet();
|
//RespawnPacket packet();
|
||||||
//minecraft->raknetInstance->send(packet);
|
//minecraft.raknetInstance->send(packet);
|
||||||
|
|
||||||
minecraft->player->respawn();
|
minecraft.player()->respawn();
|
||||||
//minecraft->raknetInstance->send();
|
//minecraft.raknetInstance->send();
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button == bTitle)
|
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/Screen.hpp"
|
||||||
#include "client/gui/Font.hpp"
|
#include "client/gui/Font.hpp"
|
||||||
#include "client/gui/components/Button.hpp"
|
#include "client/gui/components/Button.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class DisconnectionScreen: public Screen
|
class DisconnectionScreen: public Screen
|
||||||
@@ -20,7 +20,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
if (/* minecraft->useTouchscreen() */ true)
|
if (/* minecraft.useTouchscreen() */ true)
|
||||||
_back = new Touch::TButton(1, "Ok");
|
_back = new Touch::TButton(1, "Ok");
|
||||||
else
|
else
|
||||||
_back = new Button(1, "Ok");
|
_back = new Button(1, "Ok");
|
||||||
@@ -37,13 +37,13 @@ public:
|
|||||||
renderBackground();
|
renderBackground();
|
||||||
super::render(xm, ym, a);
|
super::render(xm, ym, a);
|
||||||
|
|
||||||
int center = (width - minecraft->font->width(_msg)) / 2;
|
int center = (width - minecraft.font()->width(_msg)) / 2;
|
||||||
minecraft->font->drawShadow(_msg, (float)center, (float)(height / 2 - 32), 0xffffffff);
|
minecraft.font()->drawShadow(_msg, (float)center, (float)(height / 2 - 32), 0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
void buttonClicked(Button* button) {
|
void buttonClicked(Button* button) {
|
||||||
if (button->id == _back->id) {
|
if (button->id == _back->id) {
|
||||||
minecraft->leaveGame();
|
minecraft.leaveGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool isInGameScreen() { return false; }
|
bool isInGameScreen() { return false; }
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "crafting/PaneCraftingScreen.hpp"
|
#include "crafting/PaneCraftingScreen.hpp"
|
||||||
#include "client/gui/Screen.hpp"
|
#include "client/gui/Screen.hpp"
|
||||||
#include "client/gui/components/NinePatch.hpp"
|
#include "client/gui/components/NinePatch.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/player/LocalPlayer.hpp"
|
#include "client/player/LocalPlayer.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||||
@@ -115,7 +115,7 @@ void FurnaceScreen::init() {
|
|||||||
buttons.push_back(&btnClose);
|
buttons.push_back(&btnClose);
|
||||||
|
|
||||||
// GUI - nine patches
|
// 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);
|
guiBackground = builder.createSymmetrical(IntRectangle(0, 0, 16, 16), 4, 4);
|
||||||
guiSlot = builder.createSymmetrical(IntRectangle(0, 32, 8, 8), 3, 3);
|
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.beginOverride();
|
||||||
t.colorABGR(0x33ffffff);
|
t.colorABGR(0x33ffffff);
|
||||||
t.noColor();
|
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();
|
t.endOverrideAndDraw();
|
||||||
glDisable2(GL_BLEND);
|
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 yy = btnResult.y + 8;
|
||||||
int fpx = furnace->getLitProgress(14) + 2;
|
int fpx = furnace->getLitProgress(14) + 2;
|
||||||
int xx0 = btnIngredient.x + 8;
|
int xx0 = btnIngredient.x + 8;
|
||||||
@@ -274,7 +274,7 @@ void FurnaceScreen::buttonClicked(Button* button) {
|
|||||||
int slot = button->id;
|
int slot = button->id;
|
||||||
|
|
||||||
if (button == &btnClose) {
|
if (button == &btnClose) {
|
||||||
minecraft->player->closeContainer();
|
minecraft.player()->closeContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot >= FurnaceTileEntity::SLOT_INGREDIENT
|
if (slot >= FurnaceTileEntity::SLOT_INGREDIENT
|
||||||
@@ -305,8 +305,8 @@ void FurnaceScreen::recheckRecipes()
|
|||||||
const FurnaceRecipes* recipes = FurnaceRecipes::getInstance();
|
const FurnaceRecipes* recipes = FurnaceRecipes::getInstance();
|
||||||
ItemPack ip;
|
ItemPack ip;
|
||||||
// Check for fuel, and items to burn
|
// Check for fuel, and items to burn
|
||||||
if (minecraft->player && minecraft->player->inventory) {
|
if (minecraft.player() && minecraft.player()->inventory) {
|
||||||
Inventory* inv = (minecraft->player)->inventory;
|
Inventory* inv = (minecraft.player())->inventory;
|
||||||
|
|
||||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < inv->getContainerSize(); ++i) {
|
for (int i = Inventory::MAX_SELECTION_SIZE; i < inv->getContainerSize(); ++i) {
|
||||||
if (ItemInstance* item = inv->getItem(i)) {
|
if (ItemInstance* item = inv->getItem(i)) {
|
||||||
@@ -401,8 +401,8 @@ void FurnaceScreen::updateItems() {
|
|||||||
|
|
||||||
ItemList all(listFuel.begin(), listFuel.end());
|
ItemList all(listFuel.begin(), listFuel.end());
|
||||||
all.insert(all.end(), listIngredient.begin(), listIngredient.end());
|
all.insert(all.end(), listIngredient.begin(), listIngredient.end());
|
||||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft->player->inventory->getContainerSize(); ++i) {
|
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft.player()->inventory->getContainerSize(); ++i) {
|
||||||
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
ItemInstance* item = minecraft.player()->inventory->getItem(i);
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
//LOGI("ItemInstance (%p) Id/aux/count: %d, %d, %d\n", item, item->id, item->getAuxValue(), item->count);
|
//LOGI("ItemInstance (%p) Id/aux/count: %d, %d, %d\n", item, item->id, item->getAuxValue(), item->count);
|
||||||
bool added = false;
|
bool added = false;
|
||||||
@@ -481,8 +481,8 @@ void FurnaceScreen::drawSlotItemAt( Tesselator& t, const ItemInstance* item, int
|
|||||||
guiSlotMarker->draw(t, xx - 2, yy - 2);
|
guiSlotMarker->draw(t, xx - 2, yy - 2);
|
||||||
|
|
||||||
if (item && !item->isNull()) {
|
if (item && !item->isNull()) {
|
||||||
ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, item, xx + 7, yy + 8, true);
|
ItemRenderer::renderGuiItem(minecraft.font(), minecraft.textures(), item, xx + 7, yy + 8, true);
|
||||||
minecraft->gui.renderSlotText(item, xx + 3, yy + 3, true, 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);
|
wantedCount = Mth::Min(wantedCount, maxCount);
|
||||||
|
|
||||||
ItemInstance removed(item->id, wantedCount, item->getAuxValue());
|
ItemInstance removed(item->id, wantedCount, item->getAuxValue());
|
||||||
int oldSize = minecraft->player->inventory->getNumEmptySlots();
|
int oldSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||||
if (minecraft->player->inventory->removeResource(removed)) {
|
if (minecraft.player()->inventory->removeResource(removed)) {
|
||||||
int newSize = minecraft->player->inventory->getNumEmptySlots();
|
int newSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||||
setIfNotSet(doRecreatePane, newSize != oldSize);
|
setIfNotSet(doRecreatePane, newSize != oldSize);
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
@@ -510,24 +510,24 @@ void FurnaceScreen::takeAndClearSlot( int slot )
|
|||||||
ItemInstance blank;
|
ItemInstance blank;
|
||||||
|
|
||||||
furnace->setItem(slot, &blank);
|
furnace->setItem(slot, &blank);
|
||||||
if (minecraft->level->isClientSide) {
|
if (minecraft.level->isClientSide) {
|
||||||
ContainerSetSlotPacket p(menu->containerId, slot, blank);
|
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))
|
if (!minecraft.player()->inventory->add(&oldItem))
|
||||||
minecraft->player->drop(new ItemInstance(oldItem), false);
|
minecraft.player()->drop(new ItemInstance(oldItem), false);
|
||||||
|
|
||||||
int newSize = minecraft->player->inventory->getNumEmptySlots();
|
int newSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||||
setIfNotSet(doRecreatePane, newSize != oldSize);
|
setIfNotSet(doRecreatePane, newSize != oldSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FurnaceScreen::handleAddItem( int slot, const ItemInstance* item )
|
bool FurnaceScreen::handleAddItem( int slot, const ItemInstance* item )
|
||||||
{
|
{
|
||||||
ItemInstance* furnaceItem = furnace->getItem(slot);
|
ItemInstance* furnaceItem = furnace->getItem(slot);
|
||||||
int oldSize = minecraft->player->inventory->getNumEmptySlots();
|
int oldSize = minecraft.player()->inventory->getNumEmptySlots();
|
||||||
|
|
||||||
if (item->id == furnaceItem->id) {
|
if (item->id == furnaceItem->id) {
|
||||||
// If stackable, stack them! Else deny the addition
|
// 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);
|
player->containerMenu->setSlot(slot, &moved);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minecraft->level->isClientSide) {
|
if (minecraft.level->isClientSide) {
|
||||||
ContainerSetSlotPacket p(menu->containerId, slot, *furnaceItem);
|
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);
|
return (newSize != oldSize);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "InBedScreen.hpp"
|
#include "InBedScreen.hpp"
|
||||||
#include "ScreenChooser.hpp"
|
#include "ScreenChooser.hpp"
|
||||||
#include "client/gui/components/Button.hpp"
|
#include "client/gui/components/Button.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/player/LocalPlayer.hpp"
|
#include "client/player/LocalPlayer.hpp"
|
||||||
#include "platform/time.hpp"
|
#include "platform/time.hpp"
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ InBedScreen::~InBedScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InBedScreen::init() {
|
void InBedScreen::init() {
|
||||||
if (/* minecraft->useTouchscreen() */ true) {
|
if (/* minecraft.useTouchscreen() */ true) {
|
||||||
bWakeUp = new Touch::TButton(1, "Leave Bed");
|
bWakeUp = new Touch::TButton(1, "Leave Bed");
|
||||||
} else {
|
} else {
|
||||||
bWakeUp = new Button(1, "Leave Bed");
|
bWakeUp = new Button(1, "Leave Bed");
|
||||||
@@ -43,7 +43,7 @@ void InBedScreen::render( int xm, int ym, float a ) {
|
|||||||
|
|
||||||
void InBedScreen::buttonClicked( Button* button ) {
|
void InBedScreen::buttonClicked( Button* button ) {
|
||||||
if (button == bWakeUp) {
|
if (button == bWakeUp) {
|
||||||
minecraft->player->stopSleepInBed(true, true, true);
|
minecraft.player()->stopSleepInBed(true, true, true);
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "client/renderer/TileRenderer.hpp"
|
#include "client/renderer/TileRenderer.hpp"
|
||||||
#include "client/player/LocalPlayer.hpp"
|
#include "client/player/LocalPlayer.hpp"
|
||||||
#include "client/renderer/gles.hpp"
|
#include "client/renderer/gles.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/sound/SoundEngine.hpp"
|
#include "client/sound/SoundEngine.hpp"
|
||||||
#include "world/entity/player/Inventory.hpp"
|
#include "world/entity/player/Inventory.hpp"
|
||||||
#include "platform/input/Mouse.hpp"
|
#include "platform/input/Mouse.hpp"
|
||||||
@@ -32,8 +32,8 @@ IngameBlockSelectionScreen::IngameBlockSelectionScreen()
|
|||||||
|
|
||||||
void IngameBlockSelectionScreen::init()
|
void IngameBlockSelectionScreen::init()
|
||||||
{
|
{
|
||||||
Inventory* inventory = minecraft->player->inventory;
|
Inventory* inventory = minecraft.player()->inventory;
|
||||||
InventoryCols = minecraft->isCreativeMode()? 13 : 9;
|
InventoryCols = minecraft.isCreativeMode()? 13 : 9;
|
||||||
InventorySize = inventory->getContainerSize() - Inventory::MAX_SELECTION_SIZE;
|
InventorySize = inventory->getContainerSize() - Inventory::MAX_SELECTION_SIZE;
|
||||||
InventoryRows = 1 + (InventorySize - 1) / InventoryCols;
|
InventoryRows = 1 + (InventorySize - 1) / InventoryCols;
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ void IngameBlockSelectionScreen::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < InventorySize; i++) {
|
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;
|
selectedItem = i - Inventory::MAX_SELECTION_SIZE;
|
||||||
break;
|
break;
|
||||||
@@ -58,7 +58,7 @@ void IngameBlockSelectionScreen::init()
|
|||||||
if (!isAllowed(selectedItem))
|
if (!isAllowed(selectedItem))
|
||||||
selectedItem = 0;
|
selectedItem = 0;
|
||||||
|
|
||||||
if (!minecraft->isCreativeMode()) {
|
if (!minecraft.isCreativeMode()) {
|
||||||
bArmor.width = 42;
|
bArmor.width = 42;
|
||||||
bArmor.x = 0;
|
bArmor.x = 0;
|
||||||
bArmor.y = height - bArmor.height;
|
bArmor.y = height - bArmor.height;
|
||||||
@@ -68,7 +68,7 @@ void IngameBlockSelectionScreen::init()
|
|||||||
|
|
||||||
void IngameBlockSelectionScreen::removed()
|
void IngameBlockSelectionScreen::removed()
|
||||||
{
|
{
|
||||||
minecraft->gui.inventoryUpdated();
|
minecraft.gui().inventoryUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IngameBlockSelectionScreen::renderSlots()
|
void IngameBlockSelectionScreen::renderSlots()
|
||||||
@@ -86,7 +86,7 @@ void IngameBlockSelectionScreen::renderSlots()
|
|||||||
//Lighting::turnOn();
|
//Lighting::turnOn();
|
||||||
//glPopMatrix2();
|
//glPopMatrix2();
|
||||||
|
|
||||||
minecraft->textures->loadAndBindTexture("gui/gui.png");
|
minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||||
for (int r = 0; r < InventoryRows; r++)
|
for (int r = 0; r < InventoryRows; r++)
|
||||||
{
|
{
|
||||||
int x = getSlotPosX(0) - 3;
|
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)
|
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;
|
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;
|
if (!isAllowed(slot - Inventory::MAX_SELECTION_SIZE)) return;
|
||||||
|
|
||||||
glPushMatrix2();
|
glPushMatrix2();
|
||||||
glScalef2(Gui::InvGuiScale + Gui::InvGuiScale, Gui::InvGuiScale + Gui::InvGuiScale, 1);
|
glScalef2(Gui::InvGuiScale + Gui::InvGuiScale, Gui::InvGuiScale + Gui::InvGuiScale, 1);
|
||||||
const float k = 0.5f * Gui::GuiScale;
|
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();
|
glPopMatrix2();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ void IngameBlockSelectionScreen::keyPressed(int eventKey)
|
|||||||
|
|
||||||
int tmpSelectedSlot = selectedItem;
|
int tmpSelectedSlot = selectedItem;
|
||||||
|
|
||||||
Options& o = minecraft->options;
|
Options& o = minecraft.options();
|
||||||
if (eventKey == o.getIntValue(OPTIONS_KEY_LEFT) && selX > 0)
|
if (eventKey == o.getIntValue(OPTIONS_KEY_LEFT) && selX > 0)
|
||||||
{
|
{
|
||||||
tmpSelectedSlot -= 1;
|
tmpSelectedSlot -= 1;
|
||||||
@@ -195,10 +195,10 @@ void IngameBlockSelectionScreen::keyPressed(int eventKey)
|
|||||||
#ifdef RPI
|
#ifdef RPI
|
||||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_CANCEL)
|
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_CANCEL)
|
||||||
|| eventKey == Keyboard::KEY_ESCAPE)
|
|| eventKey == Keyboard::KEY_ESCAPE)
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
#else
|
#else
|
||||||
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_CANCEL))
|
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_CANCEL))
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ void IngameBlockSelectionScreen::mouseClicked(int x, int y, int buttonNum)
|
|||||||
if (isAllowed(slot))
|
if (isAllowed(slot))
|
||||||
{
|
{
|
||||||
selectedItem = slot;
|
selectedItem = slot;
|
||||||
//minecraft->soundEngine->playUI("random.click", 1, 1);
|
//minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||||
} else {
|
} else {
|
||||||
_pendingQuit = !_area.isInside((float)x, (float)y)
|
_pendingQuit = !_area.isInside((float)x, (float)y)
|
||||||
&& !bArmor.isInside(x, y);
|
&& !bArmor.isInside(x, y);
|
||||||
@@ -265,7 +265,7 @@ void IngameBlockSelectionScreen::mouseReleased(int x, int y, int buttonNum)
|
|||||||
selectSlotAndClose();
|
selectSlotAndClose();
|
||||||
} else {
|
} else {
|
||||||
if (_pendingQuit && !_area.isInside((float)x, (float)y))
|
if (_pendingQuit && !_area.isInside((float)x, (float)y))
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_pendingQuit)
|
if (!_pendingQuit)
|
||||||
@@ -274,15 +274,15 @@ void IngameBlockSelectionScreen::mouseReleased(int x, int y, int buttonNum)
|
|||||||
|
|
||||||
void IngameBlockSelectionScreen::selectSlotAndClose()
|
void IngameBlockSelectionScreen::selectSlotAndClose()
|
||||||
{
|
{
|
||||||
Inventory* inventory = minecraft->player->inventory;
|
Inventory* inventory = minecraft.player()->inventory;
|
||||||
// Flash the selected gui item
|
// Flash the selected gui item
|
||||||
//inventory->moveToSelectedSlot(selectedItem + Inventory::MAX_SELECTION_SIZE, true);
|
//inventory->moveToSelectedSlot(selectedItem + Inventory::MAX_SELECTION_SIZE, true);
|
||||||
inventory->moveToSelectionSlot(0, selectedItem + Inventory::MAX_SELECTION_SIZE, true);
|
inventory->moveToSelectionSlot(0, selectedItem + Inventory::MAX_SELECTION_SIZE, true);
|
||||||
inventory->selectSlot(0);
|
inventory->selectSlot(0);
|
||||||
minecraft->gui.flashSlot(inventory->selected);
|
minecraft.gui().flashSlot(inventory->selected);
|
||||||
|
|
||||||
minecraft->soundEngine->playUI("random.click", 1, 1);
|
minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IngameBlockSelectionScreen::render( int xm, int ym, float a )
|
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 centerX = (getSlotPosX(4) + getSlotPosX(5)) / 2;
|
||||||
const int centerY = (getSlotPosY(3) + getSlotPosY(InventoryRows-1)) / 2 + 5;
|
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*/
|
#endif /*DEMO_MODE*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ bool IngameBlockSelectionScreen::isAllowed(int slot) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef DEMO_MODE
|
#ifdef DEMO_MODE
|
||||||
return slot < (minecraft->isCreativeMode()? 28 : 27);
|
return slot < (minecraft.isCreativeMode()? 28 : 27);
|
||||||
#endif /*DEMO_MODE*/
|
#endif /*DEMO_MODE*/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -335,7 +335,7 @@ int IngameBlockSelectionScreen::getSlotHeight() {
|
|||||||
void IngameBlockSelectionScreen::buttonClicked( Button* button )
|
void IngameBlockSelectionScreen::buttonClicked( Button* button )
|
||||||
{
|
{
|
||||||
if (button == &bArmor) {
|
if (button == &bArmor) {
|
||||||
minecraft->setScreen(new ArmorScreen());
|
minecraft.setScreen(new ArmorScreen());
|
||||||
}
|
}
|
||||||
super::buttonClicked(button);
|
super::buttonClicked(button);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,21 +28,21 @@ void JoinByIPScreen::buttonClicked(Button* button)
|
|||||||
{
|
{
|
||||||
if (button->id == bJoin.id)
|
if (button->id == bJoin.id)
|
||||||
{
|
{
|
||||||
minecraft->isLookingForMultiplayer = true;
|
minecraft.isLookingForMultiplayer = true;
|
||||||
minecraft->netCallback = new ClientSideNetworkHandler(minecraft, minecraft->raknetInstance);
|
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;
|
bJoin.active = false;
|
||||||
bBack.active = false;
|
bBack.active = false;
|
||||||
minecraft->setScreen(new ProgressScreen());
|
minecraft.setScreen(new ProgressScreen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (button->id == bBack.id)
|
if (button->id == bBack.id)
|
||||||
{
|
{
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft.cancelLocateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ bool JoinByIPScreen::handleBackEvent(bool isDown)
|
|||||||
{
|
{
|
||||||
if (!isDown)
|
if (!isDown)
|
||||||
{
|
{
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ void JoinByIPScreen::init()
|
|||||||
tabButtons.push_back(&bHeader);
|
tabButtons.push_back(&bHeader);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tIP.text = minecraft->options.getStringValue(OPTIONS_LAST_IP);
|
tIP.text = minecraft.options().getStringValue(OPTIONS_LAST_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoinByIPScreen::setupPositions() {
|
void JoinByIPScreen::setupPositions() {
|
||||||
@@ -116,7 +116,7 @@ void JoinByIPScreen::render( int xm, int ym, float a )
|
|||||||
void JoinByIPScreen::keyPressed(int eventKey)
|
void JoinByIPScreen::keyPressed(int eventKey)
|
||||||
{
|
{
|
||||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// let base class handle navigation and text box keys
|
// let base class handle navigation and text box keys
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "client/gui/Screen.hpp"
|
#include "client/gui/Screen.hpp"
|
||||||
#include "client/gui/components/Button.hpp"
|
#include "client/gui/components/Button.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/gui/components/ImageButton.hpp"
|
#include "client/gui/components/ImageButton.hpp"
|
||||||
#include "client/gui/components/TextBox.hpp"
|
#include "client/gui/components/TextBox.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -25,20 +25,20 @@ void JoinGameScreen::buttonClicked(Button* button)
|
|||||||
if (isIndexValid(gamesList->selectedItem))
|
if (isIndexValid(gamesList->selectedItem))
|
||||||
{
|
{
|
||||||
PingedCompatibleServer selectedServer = gamesList->copiedServerList[gamesList->selectedItem];
|
PingedCompatibleServer selectedServer = gamesList->copiedServerList[gamesList->selectedItem];
|
||||||
minecraft->joinMultiplayer(selectedServer);
|
minecraft.joinMultiplayer(selectedServer);
|
||||||
{
|
{
|
||||||
bJoin.active = false;
|
bJoin.active = false;
|
||||||
bBack.active = false;
|
bBack.active = false;
|
||||||
minecraft->setScreen(new ProgressScreen());
|
minecraft.setScreen(new ProgressScreen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//minecraft->locateMultiplayer();
|
//minecraft.locateMultiplayer();
|
||||||
//minecraft->setScreen(new JoinGameScreen());
|
//minecraft.setScreen(new JoinGameScreen());
|
||||||
}
|
}
|
||||||
if (button->id == bBack.id)
|
if (button->id == bBack.id)
|
||||||
{
|
{
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft.cancelLocateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +46,8 @@ bool JoinGameScreen::handleBackEvent(bool isDown)
|
|||||||
{
|
{
|
||||||
if (!isDown)
|
if (!isDown)
|
||||||
{
|
{
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft.cancelLocateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ bool JoinGameScreen::isIndexValid( int index )
|
|||||||
|
|
||||||
void JoinGameScreen::tick()
|
void JoinGameScreen::tick()
|
||||||
{
|
{
|
||||||
const ServerList& orgServerList = minecraft->raknetInstance->getServerList();
|
const ServerList& orgServerList = minecraft.raknetInstance->getServerList();
|
||||||
ServerList serverList;
|
ServerList serverList;
|
||||||
for (unsigned int i = 0; i < orgServerList.size(); ++i)
|
for (unsigned int i = 0; i < orgServerList.size(); ++i)
|
||||||
if (orgServerList[i].name.GetLength() > 0)
|
if (orgServerList[i].name.GetLength() > 0)
|
||||||
@@ -108,7 +108,7 @@ void JoinGameScreen::init()
|
|||||||
buttons.push_back(&bJoin);
|
buttons.push_back(&bJoin);
|
||||||
buttons.push_back(&bBack);
|
buttons.push_back(&bBack);
|
||||||
|
|
||||||
minecraft->raknetInstance->clearServerList();
|
minecraft.raknetInstance->clearServerList();
|
||||||
gamesList = new AvailableGamesList(minecraft, width, height);
|
gamesList = new AvailableGamesList(minecraft, width, height);
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
@@ -134,7 +134,7 @@ void JoinGameScreen::setupPositions() {
|
|||||||
|
|
||||||
void JoinGameScreen::render( int xm, int ym, float a )
|
void JoinGameScreen::render( int xm, int ym, float a )
|
||||||
{
|
{
|
||||||
bool hasNetwork = minecraft->platform()->isNetworkEnabled(true);
|
bool hasNetwork = minecraft.platform()->isNetworkEnabled(true);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
hasNetwork = hasNetwork && !GetAsyncKeyState(VK_TAB);
|
hasNetwork = hasNetwork && !GetAsyncKeyState(VK_TAB);
|
||||||
#endif
|
#endif
|
||||||
@@ -149,18 +149,18 @@ void JoinGameScreen::render( int xm, int ym, float a )
|
|||||||
#else
|
#else
|
||||||
std::string s = "Scanning for WiFi Games...";
|
std::string s = "Scanning for WiFi Games...";
|
||||||
#endif
|
#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;
|
const int spinnerX = width/2 + textWidth / 2 + 6;
|
||||||
|
|
||||||
static const char* spinnerTexts[] = {"-", "\\", "|", "/"};
|
static const char* spinnerTexts[] = {"-", "\\", "|", "/"};
|
||||||
int n = ((int)(5.5f * getTimeS()) % 4);
|
int n = ((int)(5.5f * getTimeS()) % 4);
|
||||||
drawCenteredString(minecraft->font, spinnerTexts[n], spinnerX, 8, 0xffffffff);
|
drawCenteredString(minecraft.font(), spinnerTexts[n], spinnerX, 8, 0xffffffff);
|
||||||
} else {
|
} else {
|
||||||
std::string s = "WiFi is disabled";
|
std::string s = "WiFi is disabled";
|
||||||
const int yy = height / 2 - 8;
|
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/Screen.hpp"
|
||||||
#include "client/gui/components/Button.hpp"
|
#include "client/gui/components/Button.hpp"
|
||||||
#include "client/gui/components/ScrolledSelectionList.hpp"
|
#include "client/gui/components/ScrolledSelectionList.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "network/RakNetInstance.hpp"
|
#include "network/RakNetInstance.hpp"
|
||||||
|
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ class AvailableGamesList : public ScrolledSelectionList
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AvailableGamesList(Minecraft* _minecraft, int _width, int _height)
|
AvailableGamesList(MinecraftClient& _minecraft, int _width, int _height)
|
||||||
: ScrolledSelectionList(_minecraft, _width, _height, 24, _height - 30, 28)
|
: ScrolledSelectionList(_minecraft, _width, _height, 24, _height - 30, 28)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -35,8 +35,8 @@ protected:
|
|||||||
{
|
{
|
||||||
const PingedCompatibleServer& s = copiedServerList[i];
|
const PingedCompatibleServer& s = copiedServerList[i];
|
||||||
unsigned int color = s.isSpecial? 0xff00b0 : 0xffffa0;
|
unsigned int color = s.isSpecial? 0xff00b0 : 0xffffa0;
|
||||||
drawString(minecraft->font, s.name.C_String(), x, y + 2, color);
|
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.address.ToString(false), x, y + 16, 0xffffa0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "StartMenuScreen.hpp"
|
#include "StartMenuScreen.hpp"
|
||||||
#include "UsernameScreen.hpp"
|
#include "UsernameScreen.hpp"
|
||||||
#include "DialogDefinitions.hpp"
|
#include "DialogDefinitions.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "AppPlatform.hpp"
|
#include "AppPlatform.hpp"
|
||||||
#include "CreditsScreen.hpp"
|
#include "CreditsScreen.hpp"
|
||||||
|
|
||||||
@@ -34,14 +34,14 @@ OptionsScreen::~OptionsScreen() {
|
|||||||
btnCredits = NULL;
|
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) {
|
if (*it != NULL) {
|
||||||
delete* it;
|
delete* it;
|
||||||
*it = NULL;
|
*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) {
|
if (*it != NULL) {
|
||||||
delete* it;
|
delete* it;
|
||||||
*it = NULL;
|
*it = NULL;
|
||||||
@@ -76,7 +76,7 @@ void OptionsScreen::init() {
|
|||||||
buttons.push_back(btnClose);
|
buttons.push_back(btnClose);
|
||||||
buttons.push_back(btnCredits);
|
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);
|
buttons.push_back(*it);
|
||||||
tabButtons.push_back(*it);
|
tabButtons.push_back(*it);
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ void OptionsScreen::setupPositions() {
|
|||||||
|
|
||||||
int offsetNum = 1;
|
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)->x = 0;
|
||||||
(*it)->y = offsetNum * buttonHeight;
|
(*it)->y = offsetNum * buttonHeight;
|
||||||
@@ -114,7 +114,7 @@ void OptionsScreen::setupPositions() {
|
|||||||
btnCredits->y = height - btnCredits->height;
|
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) {
|
if (categoryButtons.size() > 0 && categoryButtons[0] != NULL) {
|
||||||
|
|
||||||
@@ -133,8 +133,8 @@ void OptionsScreen::setupPositions() {
|
|||||||
void OptionsScreen::render(int xm, int ym, float a) {
|
void OptionsScreen::render(int xm, int ym, float a) {
|
||||||
renderBackground();
|
renderBackground();
|
||||||
|
|
||||||
int xmm = xm * width / minecraft->width;
|
int xmm = xm * width / minecraft.getScreenWidth();
|
||||||
int ymm = ym * height / minecraft->height - 1;
|
int ymm = ym * height / minecraft.getScreenHeight() - 1;
|
||||||
|
|
||||||
if (currentOptionsGroup != NULL)
|
if (currentOptionsGroup != NULL)
|
||||||
currentOptionsGroup->render(minecraft, xmm, ymm);
|
currentOptionsGroup->render(minecraft, xmm, ymm);
|
||||||
@@ -147,11 +147,11 @@ void OptionsScreen::removed() {
|
|||||||
|
|
||||||
void OptionsScreen::buttonClicked(Button* button) {
|
void OptionsScreen::buttonClicked(Button* button) {
|
||||||
if (button == btnClose) {
|
if (button == btnClose) {
|
||||||
minecraft->options.save();
|
minecraft.options().save();
|
||||||
if (minecraft->screen != NULL) {
|
if (minecraft.getScreen()!= NULL) {
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
} else {
|
} else {
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (button->id > 1 && button->id < 7) {
|
else if (button->id > 1 && button->id < 7) {
|
||||||
@@ -159,14 +159,14 @@ void OptionsScreen::buttonClicked(Button* button) {
|
|||||||
selectCategory(categoryButton);
|
selectCategory(categoryButton);
|
||||||
}
|
}
|
||||||
else if (button == btnCredits) {
|
else if (button == btnCredits) {
|
||||||
minecraft->setScreen(new CreditsScreen());
|
minecraft.setScreen(new CreditsScreen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsScreen::selectCategory(int index) {
|
void OptionsScreen::selectCategory(int index) {
|
||||||
int currentIndex = 0;
|
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)
|
if (index == currentIndex)
|
||||||
(*it)->selected = true;
|
(*it)->selected = true;
|
||||||
@@ -246,7 +246,7 @@ void OptionsScreen::keyPressed(int eventKey) {
|
|||||||
if (currentOptionsGroup != NULL)
|
if (currentOptionsGroup != NULL)
|
||||||
currentOptionsGroup->keyPressed(minecraft, eventKey);
|
currentOptionsGroup->keyPressed(minecraft, eventKey);
|
||||||
if (eventKey == Keyboard::KEY_ESCAPE)
|
if (eventKey == Keyboard::KEY_ESCAPE)
|
||||||
minecraft->options.save();
|
minecraft.options().save();
|
||||||
|
|
||||||
super::keyPressed(eventKey);
|
super::keyPressed(eventKey);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "PauseScreen.hpp"
|
#include "PauseScreen.hpp"
|
||||||
#include "StartMenuScreen.hpp"
|
#include "StartMenuScreen.hpp"
|
||||||
#include "client/gui/components/ImageButton.hpp"
|
#include "client/gui/components/ImageButton.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "util/Mth.hpp"
|
#include "util/Mth.hpp"
|
||||||
#include "network/RakNetInstance.hpp"
|
#include "network/RakNetInstance.hpp"
|
||||||
#include "network/ServerSideNetworkHandler.hpp"
|
#include "network/ServerSideNetworkHandler.hpp"
|
||||||
@@ -48,7 +48,7 @@ PauseScreen::~PauseScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PauseScreen::init() {
|
void PauseScreen::init() {
|
||||||
if (/* minecraft->useTouchscreen() */ true) {
|
if (/* minecraft.useTouchscreen() */ true) {
|
||||||
bContinue = new Touch::TButton(1, "Back to game");
|
bContinue = new Touch::TButton(1, "Back to game");
|
||||||
bOptions = new Touch::TButton(5, "Options");
|
bOptions = new Touch::TButton(5, "Options");
|
||||||
bQuit = new Touch::TButton(2, "Quit to title");
|
bQuit = new Touch::TButton(2, "Quit to title");
|
||||||
@@ -67,9 +67,9 @@ void PauseScreen::init() {
|
|||||||
buttons.push_back(bContinue);
|
buttons.push_back(bContinue);
|
||||||
buttons.push_back(bQuit);
|
buttons.push_back(bQuit);
|
||||||
buttons.push_back(bOptions);
|
buttons.push_back(bOptions);
|
||||||
// bSound.updateImage(&minecraft->options);
|
// bSound.updateImage(&minecraft.options);
|
||||||
bThirdPerson.updateImage(&minecraft->options);
|
bThirdPerson.updateImage(&minecraft.options);
|
||||||
bHideGui.updateImage(&minecraft->options);
|
bHideGui.updateImage(&minecraft.options);
|
||||||
// buttons.push_back(&bSound);
|
// buttons.push_back(&bSound);
|
||||||
buttons.push_back(&bThirdPerson);
|
buttons.push_back(&bThirdPerson);
|
||||||
//buttons.push_back(&bHideGui);
|
//buttons.push_back(&bHideGui);
|
||||||
@@ -79,8 +79,8 @@ void PauseScreen::init() {
|
|||||||
|
|
||||||
#if !defined(APPLE_DEMO_PROMOTION) && !defined(RPI)
|
#if !defined(APPLE_DEMO_PROMOTION) && !defined(RPI)
|
||||||
if (true || !wasBackPaused) {
|
if (true || !wasBackPaused) {
|
||||||
if (minecraft->raknetInstance) {
|
if (minecraft.raknetInstance) {
|
||||||
if (minecraft->raknetInstance->isServer()) {
|
if (minecraft.raknetInstance->isServer()) {
|
||||||
updateServerVisibilityText();
|
updateServerVisibilityText();
|
||||||
buttons.push_back(bServerVisibility);
|
buttons.push_back(bServerVisibility);
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ void PauseScreen::tick() {
|
|||||||
void PauseScreen::render(int xm, int ym, float a) {
|
void PauseScreen::render(int xm, int ym, float a) {
|
||||||
renderBackground();
|
renderBackground();
|
||||||
|
|
||||||
//bool isSaving = !minecraft->level.pauseSave(saveStep++);
|
//bool isSaving = !minecraft.level.pauseSave(saveStep++);
|
||||||
//if (isSaving || visibleTime < 20) {
|
//if (isSaving || visibleTime < 20) {
|
||||||
// float col = ((visibleTime % 10) + a) / 10.0f;
|
// float col = ((visibleTime % 10) + a) / 10.0f;
|
||||||
// col = Mth::sin(col * Mth::PI * 2) * 0.2f + 0.8f;
|
// 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) {
|
void PauseScreen::buttonClicked(Button* button) {
|
||||||
if (button->id == bContinue->id) {
|
if (button->id == bContinue->id) {
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
//minecraft->grabMouse();
|
//minecraft.grabMouse();
|
||||||
}
|
}
|
||||||
if (button->id == bQuit->id) {
|
if (button->id == bQuit->id) {
|
||||||
minecraft->leaveGame();
|
minecraft.leaveGame();
|
||||||
}
|
}
|
||||||
if (button->id == bQuitAndSaveLocally->id) {
|
if (button->id == bQuitAndSaveLocally->id) {
|
||||||
minecraft->leaveGame(true);
|
minecraft.leaveGame(true);
|
||||||
}
|
}
|
||||||
if (button->id == bOptions->id) {
|
if (button->id == bOptions->id) {
|
||||||
minecraft->setScreen(new OptionsScreen());
|
minecraft.setScreen(new OptionsScreen());
|
||||||
}
|
}
|
||||||
if (button->id == bServerVisibility->id) {
|
if (button->id == bServerVisibility->id) {
|
||||||
if (minecraft->raknetInstance && minecraft->netCallback && minecraft->raknetInstance->isServer()) {
|
if (minecraft.raknetInstance && minecraft.netCallback && minecraft.raknetInstance->isServer()) {
|
||||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) minecraft->netCallback;
|
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) minecraft.netCallback;
|
||||||
bool allows = !ss->allowsIncomingConnections();
|
bool allows = !ss->allowsIncomingConnections();
|
||||||
ss->allowIncomingConnections(allows);
|
ss->allowIncomingConnections(allows);
|
||||||
|
|
||||||
@@ -181,20 +181,20 @@ void PauseScreen::buttonClicked(Button* button) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (button->id == OptionButton::ButtonId) {
|
if (button->id == OptionButton::ButtonId) {
|
||||||
((OptionButton*)button)->toggle(&minecraft->options);
|
((OptionButton*)button)->toggle(&minecraft.options);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (button->id == bThirdPerson->id) {
|
//if (button->id == bThirdPerson->id) {
|
||||||
// minecraft->options.thirdPersonView = !minecraft->options.thirdPersonView;
|
// minecraft.options().thirdPersonView = !minecraft.options().thirdPersonView;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PauseScreen::updateServerVisibilityText()
|
void PauseScreen::updateServerVisibilityText()
|
||||||
{
|
{
|
||||||
if (!minecraft->raknetInstance || !minecraft->raknetInstance->isServer())
|
if (!minecraft.raknetInstance || !minecraft.raknetInstance->isServer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) minecraft->netCallback;
|
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) minecraft.netCallback;
|
||||||
bServerVisibility->msg = ss->allowsIncomingConnections()?
|
bServerVisibility->msg = ss->allowsIncomingConnections()?
|
||||||
"Server is visible"
|
"Server is visible"
|
||||||
: "Server is invisible";
|
: "Server is invisible";
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class PrerenderTilesScreen: public Screen
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void init() {
|
void init() {
|
||||||
Player p(minecraft->level, true);
|
Player p(minecraft.level, true);
|
||||||
Inventory _inventory(&p, true);
|
Inventory _inventory(&p, true);
|
||||||
Inventory* inventory = &_inventory;
|
Inventory* inventory = &_inventory;
|
||||||
|
|
||||||
@@ -93,21 +93,21 @@ public:
|
|||||||
int y = j/16 * 16;
|
int y = j/16 * 16;
|
||||||
|
|
||||||
//Tesselator::instance.color(0xffffffff);
|
//Tesselator::instance.color(0xffffffff);
|
||||||
//minecraft->textures->loadAndBindTexture("gui/gui2.png");
|
//minecraft.textures().loadAndBindTexture("gui/gui2.png");
|
||||||
//glColor4f2(0.2f, 0.5f, 0.2f, 1);
|
//glColor4f2(0.2f, 0.5f, 0.2f, 1);
|
||||||
//blit(x, y, 4 + 20 * (i%9), 4, 16, 16, 15, 15);
|
//blit(x, y, 4 + 20 * (i%9), 4, 16, 16, 15, 15);
|
||||||
//glColor4f2(1, 1, 1, 1);
|
//glColor4f2(1, 1, 1, 1);
|
||||||
|
|
||||||
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
|
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
|
||||||
LOGI("0, %d, %d, %d, 0\n", j, item->id, item->getAuxValue());
|
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) {
|
} else if (item->getIcon() >= 0) {
|
||||||
LOGI("1, %d, %d, %d, %d\n", j, item->id, item->getAuxValue(), item->getIcon());
|
LOGI("1, %d, %d, %d, %d\n", j, item->id, item->getAuxValue(), item->getIcon());
|
||||||
}
|
}
|
||||||
++j;
|
++j;
|
||||||
}*/
|
}*/
|
||||||
int j = 0;
|
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);
|
ItemInstance* item = &(*i);
|
||||||
|
|
||||||
//LOGI("desc: %d - %s. %d\n", i, item->toString().c_str());
|
//LOGI("desc: %d - %s. %d\n", i, item->toString().c_str());
|
||||||
@@ -116,7 +116,7 @@ public:
|
|||||||
int y = j/16 * 16;
|
int y = j/16 * 16;
|
||||||
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
|
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
|
||||||
LOGI("0, %d, %d, %d, 0\n", j, item->id, item->getAuxValue());
|
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) {
|
} else if (item->getIcon() >= 0) {
|
||||||
LOGI("1, %d, %d, %d, %d\n", j, item->id, item->getAuxValue(), item->getIcon());
|
LOGI("1, %d, %d, %d, %d\n", j, item->id, item->getAuxValue(), item->getIcon());
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ public:
|
|||||||
if (item->getAuxValue() < 0) return;
|
if (item->getAuxValue() < 0) return;
|
||||||
|
|
||||||
bool found = false;
|
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;
|
ItemInstance *jitem = &*i;
|
||||||
if(jitem->id != item->id) continue;
|
if(jitem->id != item->id) continue;
|
||||||
if(jitem->isStackedByData() && jitem->getAuxValue() != item->getAuxValue()) continue;
|
if(jitem->isStackedByData() && jitem->getAuxValue() != item->getAuxValue()) continue;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "DisconnectionScreen.hpp"
|
#include "DisconnectionScreen.hpp"
|
||||||
#include "client/gui/Gui.hpp"
|
#include "client/gui/Gui.hpp"
|
||||||
#include "client/gui/Font.hpp"
|
#include "client/gui/Font.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "SharedConstants.hpp"
|
#include "SharedConstants.hpp"
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
@@ -14,15 +14,15 @@ ProgressScreen::ProgressScreen()
|
|||||||
|
|
||||||
void ProgressScreen::render( int xm, int ym, float a )
|
void ProgressScreen::render( int xm, int ym, float a )
|
||||||
{
|
{
|
||||||
if (minecraft->isLevelGenerated()) {
|
if (minecraft.isLevelGenerated()) {
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
renderBackground();
|
renderBackground();
|
||||||
|
|
||||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||||
|
|
||||||
const float s = 32;
|
const float s = 32;
|
||||||
t.begin();
|
t.begin();
|
||||||
@@ -33,7 +33,7 @@ void ProgressScreen::render( int xm, int ym, float a )
|
|||||||
t.vertexUV(0, 0, 0, 0, 0);
|
t.vertexUV(0, 0, 0, 0, 0);
|
||||||
t.draw();
|
t.draw();
|
||||||
|
|
||||||
int i = minecraft->progressStagePercentage;
|
int i = minecraft.progressStagePercentage;
|
||||||
|
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
int w = 100;
|
int w = 100;
|
||||||
@@ -63,26 +63,26 @@ void ProgressScreen::render( int xm, int ym, float a )
|
|||||||
glEnable2(GL_BLEND);
|
glEnable2(GL_BLEND);
|
||||||
|
|
||||||
const char* title = "Generating world";
|
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 char* status = minecraft.getProgressMessage();
|
||||||
const int progressWidth = minecraft->font->width(status);
|
const int progressWidth = minecraft.font()->width(status);
|
||||||
const int progressLeft = (width - progressWidth) / 2;
|
const int progressLeft = (width - progressWidth) / 2;
|
||||||
const int progressY = height / 2 - 4 + 8;
|
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
|
#if APPLE_DEMO_PROMOTION
|
||||||
drawCenteredString(minecraft->font, "This demonstration version", width/2, progressY + 36, 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);
|
drawCenteredString(minecraft.font(), "does not allow saving games", width/2, progressY + 46, 0xffffff);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// If we're locating the server, show our famous spinner!
|
// If we're locating the server, show our famous spinner!
|
||||||
bool isLocating = (minecraft->getProgressStatusId() == 0);
|
bool isLocating = (minecraft.getProgressStatusId() == 0);
|
||||||
if (isLocating) {
|
if (isLocating) {
|
||||||
const int spinnerX = progressLeft + progressWidth + 6;
|
const int spinnerX = progressLeft + progressWidth + 6;
|
||||||
static const char* spinnerTexts[] = {"-", "\\", "|", "/"};
|
static const char* spinnerTexts[] = {"-", "\\", "|", "/"};
|
||||||
int n = ((int)(5.5f * getTimeS()) % 4);
|
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);
|
glDisable2(GL_BLEND);
|
||||||
@@ -93,7 +93,7 @@ bool ProgressScreen::isInGameScreen() { return false; }
|
|||||||
|
|
||||||
void ProgressScreen::tick() {
|
void ProgressScreen::tick() {
|
||||||
// After 10 seconds of not connecting -> write an error message and go back
|
// After 10 seconds of not connecting -> write an error message and go back
|
||||||
if (++ticks == 10 * SharedConstants::TicksPerSecond && minecraft->getProgressStatusId() == 0) {
|
if (++ticks == 10 * SharedConstants::TicksPerSecond && minecraft.getProgressStatusId() == 0) {
|
||||||
minecraft->setScreen( new DisconnectionScreen("Could not connect to server. Try again.") );
|
minecraft.setScreen( new DisconnectionScreen("Could not connect to server. Try again.") );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "touch/TouchJoinGameScreen.hpp"
|
#include "touch/TouchJoinGameScreen.hpp"
|
||||||
#include "touch/TouchIngameBlockSelectionScreen.hpp"
|
#include "touch/TouchIngameBlockSelectionScreen.hpp"
|
||||||
|
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
|
|
||||||
#include <client/gui/screens/UsernameScreen.hpp>
|
#include <client/gui/screens/UsernameScreen.hpp>
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ Screen* ScreenChooser::createScreen( ScreenId id )
|
|||||||
Screen* screen = NULL;
|
Screen* screen = NULL;
|
||||||
|
|
||||||
// :sob:
|
// :sob:
|
||||||
if (/* _mc->useTouchscreen() */ true) {
|
if (/* _mc.useTouchscreen() */ true) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case SCREEN_STARTMENU: screen = new Touch::StartMenuScreen(); break;
|
case SCREEN_STARTMENU: screen = new Touch::StartMenuScreen(); break;
|
||||||
case SCREEN_SELECTWORLD: screen = new Touch::SelectWorldScreen();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;
|
const int TX = centerx - itemWidth / 2 + 5;
|
||||||
|
|
||||||
StringVector v = _descriptions[i];
|
StringVector v = _descriptions[i];
|
||||||
drawString(minecraft->font, v[0].c_str(), TX, TY + 0, textColor);
|
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[1].c_str(), TX, TY + 10, textColor2);
|
||||||
drawString(minecraft->font, v[2].c_str(), TX, TY + 20, 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[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);
|
t.color(0.3f, 1.0f, 0.2f);
|
||||||
|
|
||||||
//float x0 = (float)x;
|
//float x0 = (float)x;
|
||||||
@@ -114,7 +114,7 @@ void WorldSelectionList::commit() {
|
|||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << level.name << "/preview.png";
|
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) {
|
if (id != Textures::InvalidId) {
|
||||||
_imageNames.push_back( ss.str() );
|
_imageNames.push_back( ss.str() );
|
||||||
@@ -124,7 +124,7 @@ void WorldSelectionList::commit() {
|
|||||||
|
|
||||||
StringVector lines;
|
StringVector lines;
|
||||||
lines.push_back(level.name);
|
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(level.id);
|
||||||
lines.push_back(LevelSettings::gameTypeToString(level.gameType));
|
lines.push_back(LevelSettings::gameTypeToString(level.gameType));
|
||||||
_descriptions.push_back(lines);
|
_descriptions.push_back(lines);
|
||||||
@@ -247,19 +247,19 @@ void SelectWorldScreen::buttonClicked(Button* button)
|
|||||||
// open in-game world-creation screen instead of using platform dialog
|
// open in-game world-creation screen instead of using platform dialog
|
||||||
if (!_hasStartedLevel) {
|
if (!_hasStartedLevel) {
|
||||||
std::string name = getUniqueLevelName("world");
|
std::string name = getUniqueLevelName("world");
|
||||||
minecraft->setScreen(new SimpleChooseLevelScreen(name));
|
minecraft.setScreen(new SimpleChooseLevelScreen(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (button->id == bDelete.id) {
|
if (button->id == bDelete.id) {
|
||||||
if (isIndexValid(worldsList->selectedItem)) {
|
if (isIndexValid(worldsList->selectedItem)) {
|
||||||
LevelSummary level = worldsList->levels[worldsList->selectedItem];
|
LevelSummary level = worldsList->levels[worldsList->selectedItem];
|
||||||
LOGI("level: %s, %s\n", level.id.c_str(), level.name.c_str());
|
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) {
|
if (button->id == bBack.id) {
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft.cancelLocateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser().setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
if (button->id == bWorldView.id) {
|
if (button->id == bWorldView.id) {
|
||||||
// Try to "click" the item in the middle
|
// Try to "click" the item in the middle
|
||||||
@@ -271,8 +271,8 @@ bool SelectWorldScreen::handleBackEvent(bool isDown)
|
|||||||
{
|
{
|
||||||
if (!isDown)
|
if (!isDown)
|
||||||
{
|
{
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft.cancelLocateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser().setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -291,9 +291,9 @@ void SelectWorldScreen::tick()
|
|||||||
worldsList->tick();
|
worldsList->tick();
|
||||||
|
|
||||||
if (worldsList->hasPickedLevel) {
|
if (worldsList->hasPickedLevel) {
|
||||||
minecraft->selectLevel(worldsList->pickedLevel.id, worldsList->pickedLevel.name, LevelSettings::None());
|
minecraft.selectLevel(worldsList->pickedLevel.id, worldsList->pickedLevel.name, LevelSettings::None());
|
||||||
minecraft->hostMultiplayer();
|
minecraft.hostMultiplayer();
|
||||||
minecraft->setScreen(new ProgressScreen());
|
minecraft.setScreen(new ProgressScreen());
|
||||||
_hasStartedLevel = true;
|
_hasStartedLevel = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -379,7 +379,7 @@ void SelectWorldScreen::render( int xm, int ym, float a )
|
|||||||
//Performance::watches.get("sws-screen").stop();
|
//Performance::watches.get("sws-screen").stop();
|
||||||
|
|
||||||
//Performance::watches.get("sws-string").start();
|
//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-string").stop();
|
||||||
|
|
||||||
//Performance::watches.get("sws-full").stop();
|
//Performance::watches.get("sws-full").stop();
|
||||||
@@ -388,7 +388,7 @@ void SelectWorldScreen::render( int xm, int ym, float a )
|
|||||||
|
|
||||||
void SelectWorldScreen::loadLevelSource()
|
void SelectWorldScreen::loadLevelSource()
|
||||||
{
|
{
|
||||||
LevelStorageSource* levelSource = minecraft->getLevelSource();
|
LevelStorageSource* levelSource = minecraft.getLevelSource();
|
||||||
levelSource->getLevelList(levels);
|
levelSource->getLevelList(levels);
|
||||||
std::sort(levels.begin(), levels.end());
|
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 )
|
void SelectWorldScreen::keyPressed( int eventKey )
|
||||||
{
|
{
|
||||||
if (bWorldView.selected) {
|
if (bWorldView.selected) {
|
||||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_RIGHT))
|
if (eventKey == minecraft.options().getIntValue(OPTIONS_KEY_RIGHT))
|
||||||
worldsList->stepLeft();
|
worldsList->stepLeft();
|
||||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_LEFT))
|
if (eventKey == minecraft.options().getIntValue(OPTIONS_KEY_LEFT))
|
||||||
worldsList->stepRight();
|
worldsList->stepRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,8 +462,8 @@ DeleteWorldScreen::DeleteWorldScreen(const LevelSummary& level)
|
|||||||
void DeleteWorldScreen::postResult( bool isOk )
|
void DeleteWorldScreen::postResult( bool isOk )
|
||||||
{
|
{
|
||||||
if (isOk) {
|
if (isOk) {
|
||||||
LevelStorageSource* storageSource = minecraft->getLevelSource();
|
LevelStorageSource* storageSource = minecraft.getLevelSource();
|
||||||
storageSource->deleteLevel(_level.id);
|
storageSource->deleteLevel(_level.id);
|
||||||
}
|
}
|
||||||
minecraft->screenChooser.setScreen(SCREEN_SELECTWORLD);
|
minecraft.screenChooser().setScreen(SCREEN_SELECTWORLD);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "ScreenChooser.hpp"
|
#include "ScreenChooser.hpp"
|
||||||
#include "client/gui/components/Button.hpp"
|
#include "client/gui/components/Button.hpp"
|
||||||
#include "client/gui/components/ImageButton.hpp"
|
#include "client/gui/components/ImageButton.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "world/level/LevelSettings.hpp"
|
#include "world/level/LevelSettings.hpp"
|
||||||
#include "platform/time.hpp"
|
#include "platform/time.hpp"
|
||||||
#include "platform/input/Keyboard.hpp"
|
#include "platform/input/Keyboard.hpp"
|
||||||
@@ -56,7 +56,7 @@ void SimpleChooseLevelScreen::init()
|
|||||||
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
|
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
|
||||||
bBack->setImageDef(def, true);
|
bBack->setImageDef(def, true);
|
||||||
}
|
}
|
||||||
if (/* minecraft->useTouchscreen() */ true) {
|
if (/* minecraft.useTouchscreen() */ true) {
|
||||||
bGamemode = new Touch::TButton(1, "Survival mode");
|
bGamemode = new Touch::TButton(1, "Survival mode");
|
||||||
bCheats = new Touch::TButton(4, "Cheats: Off");
|
bCheats = new Touch::TButton(4, "Cheats: Off");
|
||||||
bCreate = new Touch::TButton(3, "Create");
|
bCreate = new Touch::TButton(3, "Create");
|
||||||
@@ -155,11 +155,11 @@ void SimpleChooseLevelScreen::render( int xm, int ym, float a )
|
|||||||
modeDesc = "Unlimited resources and flying";
|
modeDesc = "Unlimited resources and flying";
|
||||||
}
|
}
|
||||||
if (modeDesc) {
|
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 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 seed:", tSeed.x, tSeed.y - Font::DefaultLineHeight - 2, 0xffcccccc);
|
||||||
|
|
||||||
Screen::render(xm, ym, a);
|
Screen::render(xm, ym, a);
|
||||||
glDisable2(GL_BLEND);
|
glDisable2(GL_BLEND);
|
||||||
@@ -231,22 +231,22 @@ void SimpleChooseLevelScreen::buttonClicked( Button* button )
|
|||||||
}
|
}
|
||||||
std::string levelId = getUniqueLevelName(tLevelName.text);
|
std::string levelId = getUniqueLevelName(tLevelName.text);
|
||||||
LevelSettings settings(seed, gamemode, cheatsEnabled);
|
LevelSettings settings(seed, gamemode, cheatsEnabled);
|
||||||
minecraft->selectLevel(levelId, levelId, settings);
|
minecraft.selectLevel(levelId, levelId, settings);
|
||||||
minecraft->hostMultiplayer();
|
minecraft.hostMultiplayer();
|
||||||
minecraft->setScreen(new ProgressScreen());
|
minecraft.setScreen(new ProgressScreen());
|
||||||
hasChosen = true;
|
hasChosen = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button == bBack) {
|
if (button == bBack) {
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleChooseLevelScreen::keyPressed(int eventKey)
|
void SimpleChooseLevelScreen::keyPressed(int eventKey)
|
||||||
{
|
{
|
||||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// let base class handle navigation and text box keys
|
// let base class handle navigation and text box keys
|
||||||
@@ -255,6 +255,6 @@ void SimpleChooseLevelScreen::keyPressed(int eventKey)
|
|||||||
|
|
||||||
bool SimpleChooseLevelScreen::handleBackEvent(bool isDown) {
|
bool SimpleChooseLevelScreen::handleBackEvent(bool isDown) {
|
||||||
if (!isDown)
|
if (!isDown)
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "client/gui/Font.hpp"
|
#include "client/gui/Font.hpp"
|
||||||
#include "client/gui/components/ScrolledSelectionList.hpp"
|
#include "client/gui/components/ScrolledSelectionList.hpp"
|
||||||
|
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "AppPlatform.hpp"
|
#include "AppPlatform.hpp"
|
||||||
#include "LicenseCodes.hpp"
|
#include "LicenseCodes.hpp"
|
||||||
@@ -38,7 +38,7 @@ void StartMenuScreen::init()
|
|||||||
{
|
{
|
||||||
bJoin.active = bHost.active = bOptions.active = true;
|
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
|
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
|
// always show base version string, suffix was previously added for Android builds
|
||||||
std::string versionString = Common::getGameVersionString();
|
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";
|
if (_username.empty()) _username = "unknown";
|
||||||
|
|
||||||
username = "Username: " + _username;
|
username = "Username: " + _username;
|
||||||
@@ -117,23 +117,23 @@ void StartMenuScreen::buttonClicked(Button* button) {
|
|||||||
if (button->id == bHost.id)
|
if (button->id == bHost.id)
|
||||||
{
|
{
|
||||||
#if defined(DEMO_MODE) || defined(APPLE_DEMO_PROMOTION)
|
#if defined(DEMO_MODE) || defined(APPLE_DEMO_PROMOTION)
|
||||||
minecraft->setScreen( new SimpleChooseLevelScreen("_DemoLevel") );
|
minecraft.setScreen( new SimpleChooseLevelScreen("_DemoLevel") );
|
||||||
#else
|
#else
|
||||||
minecraft->screenChooser.setScreen(SCREEN_SELECTWORLD);
|
minecraft.screenChooser.setScreen(SCREEN_SELECTWORLD);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (button->id == bJoin.id)
|
if (button->id == bJoin.id)
|
||||||
{
|
{
|
||||||
minecraft->locateMultiplayer();
|
minecraft.locateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_JOINGAME);
|
minecraft.screenChooser.setScreen(SCREEN_JOINGAME);
|
||||||
}
|
}
|
||||||
if (button->id == bOptions.id)
|
if (button->id == bOptions.id)
|
||||||
{
|
{
|
||||||
minecraft->setScreen(new OptionsScreen());
|
minecraft.setScreen(new OptionsScreen());
|
||||||
}
|
}
|
||||||
if (button == &bQuit)
|
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);
|
drawString(font, username, 2, 2, 0xffffffff);
|
||||||
|
|
||||||
#if defined(RPI)
|
#if defined(RPI)
|
||||||
TextureId id = minecraft->textures->loadTexture("gui/pi_title.png");
|
TextureId id = minecraft.textures().loadTexture("gui/pi_title.png");
|
||||||
#else
|
#else
|
||||||
TextureId id = minecraft->textures->loadTexture("gui/title.png");
|
TextureId id = minecraft.textures().loadTexture("gui/title.png");
|
||||||
#endif
|
#endif
|
||||||
const TextureData* data = minecraft->textures->getTemporaryTextureData(id);
|
const TextureData* data = minecraft.textures().getTemporaryTextureData(id);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
minecraft->textures->bind(id);
|
minecraft.textures().bind(id);
|
||||||
|
|
||||||
const float x = (float)width / 2;
|
const float x = (float)width / 2;
|
||||||
const float y = height/16;
|
const float y = height/16;
|
||||||
@@ -175,23 +175,23 @@ void StartMenuScreen::render( int xm, int ym, float a )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(RPI)
|
#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);
|
blit(0, height - 12, 0, 0, 43, 12, 256, 72+72);
|
||||||
#endif
|
#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);
|
drawString(font, copyright, 2, height - 20, 0xffffff);
|
||||||
glEnable2(GL_BLEND);
|
glEnable2(GL_BLEND);
|
||||||
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glColor4f2(1, 1, 1, 1);
|
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);
|
blit(2, height - 10, 0, 0, 8, 8, 256, 256);
|
||||||
{
|
{
|
||||||
std::string txt = "Kolyah35/minecraft-pe-0.6.1";
|
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);
|
Gui::drawColoredString(font, txt, 12, height - 10, 255);
|
||||||
// underline link
|
// 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);
|
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) {
|
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||||
const int logoX = 2;
|
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 logoY = height - 10;
|
||||||
const int logoH = 10;
|
const int logoH = 10;
|
||||||
if (x >= logoX && x <= logoX + logoW && y >= logoY && y <= logoY + logoH)
|
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
|
else
|
||||||
Screen::mouseClicked(x, y, buttonNum);
|
Screen::mouseClicked(x, y, buttonNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartMenuScreen::handleBackEvent( bool isDown ) {
|
bool StartMenuScreen::handleBackEvent( bool isDown ) {
|
||||||
minecraft->quit();
|
minecraft.quit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "TextEditScreen.hpp"
|
#include "TextEditScreen.hpp"
|
||||||
#include "world/level/tile/entity/SignTileEntity.hpp"
|
#include "world/level/tile/entity/SignTileEntity.hpp"
|
||||||
#include "AppPlatform.hpp"
|
#include "AppPlatform.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/renderer/tileentity/TileEntityRenderDispatcher.hpp"
|
#include "client/renderer/tileentity/TileEntityRenderDispatcher.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
@@ -18,7 +18,7 @@ TextEditScreen::~TextEditScreen() {
|
|||||||
}
|
}
|
||||||
void TextEditScreen::init() {
|
void TextEditScreen::init() {
|
||||||
super::init();
|
super::init();
|
||||||
minecraft->platform()->showKeyboard();
|
minecraft.platform()->showKeyboard();
|
||||||
isShowingKeyboard = true;
|
isShowingKeyboard = true;
|
||||||
ImageDef def;
|
ImageDef def;
|
||||||
def.name = "gui/spritesheet.png";
|
def.name = "gui/spritesheet.png";
|
||||||
@@ -41,9 +41,9 @@ void TextEditScreen::setupPositions() {
|
|||||||
bool TextEditScreen::handleBackEvent( bool isDown ) {
|
bool TextEditScreen::handleBackEvent( bool isDown ) {
|
||||||
sign->setChanged();
|
sign->setChanged();
|
||||||
Packet* signUpdatePacket = sign->getUpdatePacket();
|
Packet* signUpdatePacket = sign->getUpdatePacket();
|
||||||
minecraft->raknetInstance->send(signUpdatePacket);
|
minecraft.raknetInstance->send(signUpdatePacket);
|
||||||
minecraft->platform()->hideKeyboard();
|
minecraft.platform()->hideKeyboard();
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,17 +59,17 @@ void TextEditScreen::render( int xm, int ym, float a ) {
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
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);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
minecraft->textures->loadAndBindTexture("item/sign.png");
|
minecraft.textures().loadAndBindTexture("item/sign.png");
|
||||||
glColor4f2(1, 1, 1, 1);
|
glColor4f2(1, 1, 1, 1);
|
||||||
|
|
||||||
static float minUV[] = {0.03126f, 0.06249f};
|
static float minUV[] = {0.03126f, 0.06249f};
|
||||||
static float maxUV[] = {0.39063f, 0.4374f};
|
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);
|
glScalef2(scale,scale,1);
|
||||||
t.begin(GL_QUADS);
|
t.begin(GL_QUADS);
|
||||||
t.vertexUV(-32, 0, 0.0f,minUV[0],minUV[1]);
|
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];
|
std::string msg = sign->messages[i];
|
||||||
if (i == sign->selectedLine && msg.length() < 14) {
|
if (i == sign->selectedLine && msg.length() < 14) {
|
||||||
std::string s = "> " + msg + " <";
|
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 {
|
} 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;
|
sign->selectedLine = -1;
|
||||||
//font->draw("Hej", minecraft->width / 2, 100, 0xFFFFFFFF, false);
|
//font.draw("Hej", minecraft.getScreenWidth() / 2, 100, 0xFFFFFFFF, false);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ selectedItem(0)
|
|||||||
|
|
||||||
void UploadPhotoScreen::init()
|
void UploadPhotoScreen::init()
|
||||||
{
|
{
|
||||||
int currentSelection = minecraft->player->inventory->getSelectedItemId();
|
int currentSelection = minecraft.player()->inventory->getSelectedItemId();
|
||||||
for (int i = 0; i < Inventory::INVENTORY_SIZE; i++)
|
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;
|
selectedItem = i;
|
||||||
break;
|
break;
|
||||||
@@ -31,7 +31,7 @@ void UploadPhotoScreen::renderSlots()
|
|||||||
|
|
||||||
blitOffset = -90;
|
blitOffset = -90;
|
||||||
|
|
||||||
minecraft->textures->loadAndBindTexture("gui/gui.png");
|
minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||||
for (int r = 0; r < Inventory::INVENTORY_ROWS; r++)
|
for (int r = 0; r < Inventory::INVENTORY_ROWS; r++)
|
||||||
{
|
{
|
||||||
blit(width / 2 - 182 / 2, height - 22 * 3 - 22 * r, 0, 0, 182, 22);
|
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)
|
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;
|
if (itemId < 0) return;
|
||||||
|
|
||||||
const bool fancy = false;
|
const bool fancy = false;
|
||||||
@@ -68,7 +68,7 @@ void UploadPhotoScreen::renderSlot(int slot, int x, int y, float a)
|
|||||||
Tile* tile = Tile::tiles[itemId];
|
Tile* tile = Tile::tiles[itemId];
|
||||||
if (tile == NULL) return;
|
if (tile == NULL) return;
|
||||||
|
|
||||||
minecraft->textures->loadAndBindTexture("terrain.png");
|
minecraft.textures().loadAndBindTexture("terrain.png");
|
||||||
|
|
||||||
int textureId = tile->getTexture(2, 0);
|
int textureId = tile->getTexture(2, 0);
|
||||||
blit(x, y, textureId % 16 * 16, textureId / 16 * 16, 16, 16);
|
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 selX = selectedItem % Inventory::SELECTION_SIZE;
|
||||||
int selY = 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)
|
if (eventKey == o.keyLeft.key && selX > 0)
|
||||||
{
|
{
|
||||||
selectedItem -= 1;
|
selectedItem -= 1;
|
||||||
@@ -130,7 +130,7 @@ void UploadPhotoScreen::mouseClicked(int x, int y, int buttonNum) {
|
|||||||
if (slot >= 0 && slot < Inventory::INVENTORY_SIZE)
|
if (slot >= 0 && slot < Inventory::INVENTORY_SIZE)
|
||||||
{
|
{
|
||||||
selectedItem = slot;
|
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()
|
void UploadPhotoScreen::selectSlotAndClose()
|
||||||
{
|
{
|
||||||
Inventory* inventory = minecraft->player->inventory;
|
Inventory* inventory = minecraft.player()->inventory;
|
||||||
|
|
||||||
int itemId = inventory->getSelectionSlotItemId(selectedItem + Inventory::SELECTION_SIZE);
|
int itemId = inventory->getSelectionSlotItemId(selectedItem + Inventory::SELECTION_SIZE);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -170,8 +170,8 @@ void UploadPhotoScreen::selectSlotAndClose()
|
|||||||
inventory->setSelectionSlotItemId(0, itemId);
|
inventory->setSelectionSlotItemId(0, itemId);
|
||||||
inventory->selectSlot(0);
|
inventory->selectSlot(0);
|
||||||
|
|
||||||
minecraft->soundEngine->playUI("random.click", 1, 1);
|
minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "UsernameScreen.hpp"
|
#include "UsernameScreen.hpp"
|
||||||
#include "StartMenuScreen.hpp"
|
#include "StartMenuScreen.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/gui/Font.hpp"
|
#include "client/gui/Font.hpp"
|
||||||
#include "client/gui/components/Button.hpp"
|
#include "client/gui/components/Button.hpp"
|
||||||
#include "platform/input/Keyboard.hpp"
|
#include "platform/input/Keyboard.hpp"
|
||||||
@@ -66,15 +66,15 @@ void UsernameScreen::keyPressed(int eventKey)
|
|||||||
|
|
||||||
void UsernameScreen::removed()
|
void UsernameScreen::removed()
|
||||||
{
|
{
|
||||||
minecraft->platform()->hideKeyboard();
|
minecraft.platform()->hideKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsernameScreen::buttonClicked(Button* button)
|
void UsernameScreen::buttonClicked(Button* button)
|
||||||
{
|
{
|
||||||
if (button == &_btnDone && !tUsername.text.empty()) {
|
if (button == &_btnDone && !tUsername.text.empty()) {
|
||||||
minecraft->options.set(OPTIONS_USERNAME, tUsername.text);
|
minecraft.options().set(OPTIONS_USERNAME, tUsername.text);
|
||||||
minecraft->options.save();
|
minecraft.options().save();
|
||||||
minecraft->setScreen(NULL); // goes to StartMenuScreen
|
minecraft.setScreen(NULL); // goes to StartMenuScreen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "client/gui/screens/touch/TouchStartMenuScreen.hpp"
|
#include "client/gui/screens/touch/TouchStartMenuScreen.hpp"
|
||||||
#include "client/gui/Screen.hpp"
|
#include "client/gui/Screen.hpp"
|
||||||
#include "client/gui/components/NinePatch.hpp"
|
#include "client/gui/components/NinePatch.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/player/LocalPlayer.hpp"
|
#include "client/player/LocalPlayer.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||||
@@ -37,10 +37,10 @@ public:
|
|||||||
statePressed(statePressed)
|
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);
|
//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));
|
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||||
|
|
||||||
if (hovered || *selectedPtr == this)
|
if (hovered || *selectedPtr == this)
|
||||||
@@ -103,13 +103,13 @@ void PaneCraftingScreen::init() {
|
|||||||
btnClose.setImageDef(def, true);
|
btnClose.setImageDef(def, true);
|
||||||
btnClose.scaleWhenPressed = false;
|
btnClose.scaleWhenPressed = false;
|
||||||
|
|
||||||
btnCraft.init(minecraft->textures);
|
btnCraft.init(minecraft.textures);
|
||||||
|
|
||||||
buttons.push_back(&btnCraft);
|
buttons.push_back(&btnCraft);
|
||||||
buttons.push_back(&btnClose);
|
buttons.push_back(&btnClose);
|
||||||
|
|
||||||
// GUI patches
|
// 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);
|
guiBackground = builder.createSymmetrical(IntRectangle(0, 0, 16, 16), 4, 4);
|
||||||
guiPaneFrame = builder.createSymmetrical(IntRectangle(0, 20, 8, 8), 1, 2)->setExcluded(1 << 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];
|
CItem::ReqItem& req = currentItem->neededItems[i];
|
||||||
reqItem = req.item;
|
reqItem = req.item;
|
||||||
if (reqItem.getAuxValue() == -1) reqItem.setAuxValue(0);
|
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();
|
t.endOverrideAndDraw();
|
||||||
|
|
||||||
@@ -251,17 +251,17 @@ void PaneCraftingScreen::render(int xm, int ym, float a) {
|
|||||||
|
|
||||||
buf[bufIndex] = 0;
|
buf[bufIndex] = 0;
|
||||||
if (req.enough())
|
if (req.enough())
|
||||||
minecraft->font->drawShadow(buf, xx, yy, rgbActive);
|
minecraft.font()->drawShadow(buf, xx, yy, rgbActive);
|
||||||
else {
|
else {
|
||||||
minecraft->font->draw(buf, xx+1, yy+1, rgbInactiveShadow);
|
minecraft.font()->draw(buf, xx+1, yy+1, rgbInactiveShadow);
|
||||||
minecraft->font->draw(buf, xx, yy, rgbInactive);
|
minecraft.font()->draw(buf, xx, yy, rgbInactive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.resetScale();
|
t.resetScale();
|
||||||
t.endOverrideAndDraw();
|
t.endOverrideAndDraw();
|
||||||
|
|
||||||
//minecraft->font->drawWordWrap(currentItemDesc, rightBx + 2, (float)btnCraft.y + btnCraft.h + 6, descFrameWidth-4, 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);
|
minecraft.font()->drawWordWrap(currentItemDesc, (float)btnCraft.x, (float)(btnCraft.y + btnCraft.height + 6), (float)btnCraft.width, rgbActive);
|
||||||
}
|
}
|
||||||
//glDisable2(GL_ALPHA_TEST);
|
//glDisable2(GL_ALPHA_TEST);
|
||||||
}
|
}
|
||||||
@@ -271,7 +271,7 @@ void PaneCraftingScreen::buttonClicked(Button* button) {
|
|||||||
craftSelectedItem();
|
craftSelectedItem();
|
||||||
|
|
||||||
if (button == &btnClose)
|
if (button == &btnClose)
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
|
|
||||||
// Did we click a category?
|
// Did we click a category?
|
||||||
if (button->id >= 100 && button->id < 200) {
|
if (button->id >= 100 && button->id < 200) {
|
||||||
@@ -311,8 +311,8 @@ static bool sortCanCraftPredicate(const CItem* a, const CItem* b) {
|
|||||||
void PaneCraftingScreen::recheckRecipes() {
|
void PaneCraftingScreen::recheckRecipes() {
|
||||||
ItemPack ip;
|
ItemPack ip;
|
||||||
|
|
||||||
if (minecraft->player && minecraft->player->inventory) {
|
if (minecraft.player() && minecraft.player()->inventory) {
|
||||||
Inventory* inv = (minecraft->player)->inventory;
|
Inventory* inv = (minecraft.player())->inventory;
|
||||||
|
|
||||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < inv->getContainerSize(); ++i) {
|
for (int i = Inventory::MAX_SELECTION_SIZE; i < inv->getContainerSize(); ++i) {
|
||||||
if (ItemInstance* item = inv->getItem(i))
|
if (ItemInstance* item = inv->getItem(i))
|
||||||
@@ -404,8 +404,8 @@ void PaneCraftingScreen::onItemSelected(int buttonIndex, CItem* item) {
|
|||||||
const int NumCategoryItems = _categories[buttonIndex].size();
|
const int NumCategoryItems = _categories[buttonIndex].size();
|
||||||
|
|
||||||
if (pane) delete pane;
|
if (pane) delete pane;
|
||||||
pane = new ItemPane(this, minecraft->textures, paneRect, NumCategoryItems, height, minecraft->height);
|
pane = new ItemPane(this, minecraft.textures() paneRect, NumCategoryItems, height, minecraft.getScreenHeight());
|
||||||
pane->f = minecraft->font;
|
pane->f = minecraft.font();
|
||||||
|
|
||||||
currentCategory = buttonIndex;
|
currentCategory = buttonIndex;
|
||||||
}
|
}
|
||||||
@@ -422,8 +422,8 @@ void PaneCraftingScreen::clearCategoryItems()
|
|||||||
void PaneCraftingScreen::keyPressed( int eventKey )
|
void PaneCraftingScreen::keyPressed( int eventKey )
|
||||||
{
|
{
|
||||||
if (eventKey == Keyboard::KEY_ESCAPE || eventKey == Keyboard::KEY_E) {
|
if (eventKey == Keyboard::KEY_ESCAPE || eventKey == Keyboard::KEY_E) {
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
//minecraft->grabMouse();
|
//minecraft.grabMouse();
|
||||||
} else {
|
} else {
|
||||||
super::keyPressed(eventKey);
|
super::keyPressed(eventKey);
|
||||||
}
|
}
|
||||||
@@ -438,7 +438,7 @@ void PaneCraftingScreen::craftSelectedItem()
|
|||||||
|
|
||||||
ItemInstance resultItem = currentItem->item;
|
ItemInstance resultItem = currentItem->item;
|
||||||
|
|
||||||
if (minecraft->player) {
|
if (minecraft.player()) {
|
||||||
// Remove all items required for the recipe and ...
|
// Remove all items required for the recipe and ...
|
||||||
for (unsigned int i = 0; i < currentItem->neededItems.size(); ++i) {
|
for (unsigned int i = 0; i < currentItem->neededItems.size(); ++i) {
|
||||||
CItem::ReqItem& req = currentItem->neededItems[i];
|
CItem::ReqItem& req = currentItem->neededItems[i];
|
||||||
@@ -451,18 +451,18 @@ void PaneCraftingScreen::craftSelectedItem()
|
|||||||
if (Tile::sandStone->id == req.item.id
|
if (Tile::sandStone->id == req.item.id
|
||||||
&& Recipe::ANY_AUX_VALUE == req.item.getAuxValue()) {
|
&& Recipe::ANY_AUX_VALUE == req.item.getAuxValue()) {
|
||||||
toRemove.setAuxValue(0);
|
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);
|
toRemove.setAuxValue(Recipe::ANY_AUX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toRemove.count > 0) {
|
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)
|
// ... add the new one! (in this order, to fill empty slots better)
|
||||||
// if it doesn't fit, throw it on the ground!
|
// if it doesn't fit, throw it on the ground!
|
||||||
if (!minecraft->player->inventory->add(&resultItem)) {
|
if (!minecraft.player()->inventory->add(&resultItem)) {
|
||||||
minecraft->player->drop(new ItemInstance(resultItem), false);
|
minecraft.player()->drop(new ItemInstance(resultItem), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
recheckRecipes();
|
recheckRecipes();
|
||||||
@@ -541,12 +541,12 @@ IntRectangle CraftButton::getItemPos( int i )
|
|||||||
return IntRectangle();
|
return IntRectangle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CraftButton::renderBg(Minecraft* minecraft, int xm, int ym) {
|
void CraftButton::renderBg(MinecraftClient& minecraft, int xm, int ym) {
|
||||||
if (!bg || !bgSelected)
|
if (!bg || !bgSelected)
|
||||||
return;
|
return;
|
||||||
//fill(x+1, y+1, x+w-1, y+h-1, 0xff999999);
|
//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));
|
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||||
|
|
||||||
if (hovered || selected)
|
if (hovered || selected)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
void setNumItems(int i) { numItems = i; }
|
void setNumItems(int i) { numItems = i; }
|
||||||
IntRectangle getItemPos(int i);
|
IntRectangle getItemPos(int i);
|
||||||
void renderBg(Minecraft* minecraft, int xm, int ym);
|
void renderBg(MinecraftClient& minecraft, int xm, int ym);
|
||||||
private:
|
private:
|
||||||
NinePatchLayer* bg;
|
NinePatchLayer* bg;
|
||||||
NinePatchLayer* bgSelected;
|
NinePatchLayer* bgSelected;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/sound/SoundEngine.hpp"
|
#include "client/sound/SoundEngine.hpp"
|
||||||
#include "world/entity/player/Inventory.hpp"
|
#include "world/entity/player/Inventory.hpp"
|
||||||
#include "platform/input/Mouse.hpp"
|
#include "platform/input/Mouse.hpp"
|
||||||
@@ -69,7 +69,7 @@ IngameBlockSelectionScreen::~IngameBlockSelectionScreen()
|
|||||||
|
|
||||||
void IngameBlockSelectionScreen::init()
|
void IngameBlockSelectionScreen::init()
|
||||||
{
|
{
|
||||||
Inventory* inventory = minecraft->player->inventory;
|
Inventory* inventory = minecraft.player()->inventory;
|
||||||
|
|
||||||
//const int itemWidth = 2 * BorderPixels +
|
//const int itemWidth = 2 * BorderPixels +
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ void IngameBlockSelectionScreen::init()
|
|||||||
|
|
||||||
buttons.push_back(&bHeader);
|
buttons.push_back(&bHeader);
|
||||||
buttons.push_back(&bDone);
|
buttons.push_back(&bDone);
|
||||||
if (!minecraft->isCreativeMode()) {
|
if (!minecraft.isCreativeMode()) {
|
||||||
buttons.push_back(&bCraft);
|
buttons.push_back(&bCraft);
|
||||||
buttons.push_back(&bArmor);
|
buttons.push_back(&bArmor);
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ void IngameBlockSelectionScreen::setupPositions() {
|
|||||||
bCraft.width = bArmor.width = 48;
|
bCraft.width = bArmor.width = 48;
|
||||||
bArmor.x = bCraft.width;
|
bArmor.x = bCraft.width;
|
||||||
|
|
||||||
if (minecraft->isCreativeMode()) {
|
if (minecraft.isCreativeMode()) {
|
||||||
bHeader.x = 0;
|
bHeader.x = 0;
|
||||||
bHeader.width = width;// - bDone.w;
|
bHeader.width = width;// - bDone.w;
|
||||||
bHeader.xText = width/2; // Center of the screen
|
bHeader.xText = width/2; // Center of the screen
|
||||||
@@ -134,14 +134,14 @@ void IngameBlockSelectionScreen::setupPositions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clippingArea.x = 0;
|
clippingArea.x = 0;
|
||||||
clippingArea.w = minecraft->width;
|
clippingArea.w = minecraft.getScreenWidth();
|
||||||
clippingArea.y = 0;
|
clippingArea.y = 0;
|
||||||
clippingArea.h = (int)(Gui::GuiScale * 24);
|
clippingArea.h = (int)(Gui::GuiScale * 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IngameBlockSelectionScreen::removed()
|
void IngameBlockSelectionScreen::removed()
|
||||||
{
|
{
|
||||||
minecraft->gui.inventoryUpdated();
|
minecraft.gui().inventoryUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
int IngameBlockSelectionScreen::getSlotPosX(int slotX) {
|
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) {
|
void IngameBlockSelectionScreen::mouseReleased(int x, int y, int buttonNum) {
|
||||||
if (_pendingClose && _blockList->_clickArea->isInside((float)x, (float)y))
|
if (_pendingClose && _blockList->_clickArea->isInside((float)x, (float)y))
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
else
|
else
|
||||||
super::mouseReleased(x, y, buttonNum);
|
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)
|
bool IngameBlockSelectionScreen::addItem(const InventoryPane* pane, int itemId)
|
||||||
{
|
{
|
||||||
Inventory* inventory = minecraft->player->inventory;
|
Inventory* inventory = minecraft.player()->inventory;
|
||||||
itemId += Inventory::MAX_SELECTION_SIZE;
|
itemId += Inventory::MAX_SELECTION_SIZE;
|
||||||
|
|
||||||
if (!inventory->getItem(itemId))
|
if (!inventory->getItem(itemId))
|
||||||
@@ -201,13 +201,13 @@ bool IngameBlockSelectionScreen::addItem(const InventoryPane* pane, int itemId)
|
|||||||
|
|
||||||
inventory->selectSlot(0);
|
inventory->selectSlot(0);
|
||||||
#ifdef __APPLE__
|
#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
|
#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
|
#endif
|
||||||
|
|
||||||
// Flash the selected gui item
|
// Flash the selected gui item
|
||||||
minecraft->gui.flashSlot(inventory->selected);
|
minecraft.gui().flashSlot(inventory->selected);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ void IngameBlockSelectionScreen::render( int xm, int ym, float a )
|
|||||||
// render frame
|
// render frame
|
||||||
IntRectangle& bbox = _blockList->rect;
|
IntRectangle& bbox = _blockList->rect;
|
||||||
Tesselator::instance.colorABGR(0xffffffff);
|
Tesselator::instance.colorABGR(0xffffffff);
|
||||||
minecraft->textures->loadAndBindTexture("gui/itemframe.png");
|
minecraft.textures().loadAndBindTexture("gui/itemframe.png");
|
||||||
glEnable2(GL_BLEND);
|
glEnable2(GL_BLEND);
|
||||||
glColor4f2(1, 1, 1, 1);
|
glColor4f2(1, 1, 1, 1);
|
||||||
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
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 centerX = (getSlotPosX(4) + getSlotPosX(5)) / 2;
|
||||||
const int centerY = (getSlotPosY(0) + getSlotPosY(1)) / 2 + 5;
|
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*/
|
#endif /*DEMO_MODE*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void IngameBlockSelectionScreen::buttonClicked(Button* button) {
|
void IngameBlockSelectionScreen::buttonClicked(Button* button) {
|
||||||
if (button->id == bDone.id)
|
if (button->id == bDone.id)
|
||||||
minecraft->setScreen(NULL);
|
minecraft.setScreen(NULL);
|
||||||
|
|
||||||
if (button->id == bMenu.id)
|
if (button->id == bMenu.id)
|
||||||
minecraft->screenChooser.setScreen(SCREEN_PAUSE);
|
minecraft.screenChooser.setScreen(SCREEN_PAUSE);
|
||||||
|
|
||||||
if (button->id == bCraft.id)
|
if (button->id == bCraft.id)
|
||||||
minecraft->setScreen(new WorkbenchScreen(Recipe::SIZE_2X2));
|
minecraft.setScreen(new WorkbenchScreen(Recipe::SIZE_2X2));
|
||||||
|
|
||||||
if (button == &bArmor)
|
if (button == &bArmor)
|
||||||
minecraft->setScreen(new ArmorScreen());
|
minecraft.setScreen(new ArmorScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IngameBlockSelectionScreen::isAllowed( int slot )
|
bool IngameBlockSelectionScreen::isAllowed( int slot )
|
||||||
{
|
{
|
||||||
if (slot < 0 || slot >= minecraft->player->inventory->getContainerSize())
|
if (slot < 0 || slot >= minecraft.player()->inventory->getContainerSize())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef DEMO_MODE
|
#ifdef DEMO_MODE
|
||||||
if (slot >= (minecraft->isCreativeMode()? 28 : 27)) return false;
|
if (slot >= (minecraft.isCreativeMode()? 28 : 27)) return false;
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -283,8 +283,8 @@ bool IngameBlockSelectionScreen::hasClippingArea( IntRectangle& out )
|
|||||||
std::vector<const ItemInstance*> IngameBlockSelectionScreen::getItems( const InventoryPane* forPane )
|
std::vector<const ItemInstance*> IngameBlockSelectionScreen::getItems( const InventoryPane* forPane )
|
||||||
{
|
{
|
||||||
std::vector<const ItemInstance*> out;
|
std::vector<const ItemInstance*> out;
|
||||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft->player->inventory->getContainerSize(); ++i)
|
for (int i = Inventory::MAX_SELECTION_SIZE; i < minecraft.player()->inventory->getContainerSize(); ++i)
|
||||||
out.push_back(minecraft->player->inventory->getItem(i));
|
out.push_back(minecraft.player()->inventory->getItem(i));
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "client/gui/screens/StartMenuScreen.hpp"
|
#include "client/gui/screens/StartMenuScreen.hpp"
|
||||||
#include "client/gui/screens/ProgressScreen.hpp"
|
#include "client/gui/screens/ProgressScreen.hpp"
|
||||||
#include "client/gui/Font.hpp"
|
#include "client/gui/Font.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
|
|
||||||
namespace Touch {
|
namespace Touch {
|
||||||
@@ -44,16 +44,16 @@ void AvailableGamesList::renderItem( int i, int x, int y, int h, Tesselator& t )
|
|||||||
glEnable2(GL_TEXTURE_2D);
|
glEnable2(GL_TEXTURE_2D);
|
||||||
glColor4f2(1,1,1,1);
|
glColor4f2(1,1,1,1);
|
||||||
glEnable2(GL_BLEND);
|
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);
|
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.name.C_String(), xx1, y + 4 + 2, color);
|
||||||
drawString(minecraft->font, s.address.ToString(false), xx2, y + 18, color2);
|
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].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].address.ToString(false), (int)x0 + 24, y + 18, color);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ void JoinGameScreen::init()
|
|||||||
buttons.push_back(&bJoinByIp);
|
buttons.push_back(&bJoinByIp);
|
||||||
buttons.push_back(&bHeader);
|
buttons.push_back(&bHeader);
|
||||||
|
|
||||||
minecraft->raknetInstance->clearServerList();
|
minecraft.raknetInstance->clearServerList();
|
||||||
gamesList = new AvailableGamesList(minecraft, width, height);
|
gamesList = new AvailableGamesList(minecraft, width, height);
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
@@ -119,25 +119,25 @@ void JoinGameScreen::buttonClicked(Button* button)
|
|||||||
if (isIndexValid(gamesList->selectedItem))
|
if (isIndexValid(gamesList->selectedItem))
|
||||||
{
|
{
|
||||||
PingedCompatibleServer selectedServer = gamesList->copiedServerList[gamesList->selectedItem];
|
PingedCompatibleServer selectedServer = gamesList->copiedServerList[gamesList->selectedItem];
|
||||||
minecraft->joinMultiplayer(selectedServer);
|
minecraft.joinMultiplayer(selectedServer);
|
||||||
{
|
{
|
||||||
bJoin.active = false;
|
bJoin.active = false;
|
||||||
bBack.active = false;
|
bBack.active = false;
|
||||||
minecraft->setScreen(new ProgressScreen());
|
minecraft.setScreen(new ProgressScreen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//minecraft->locateMultiplayer();
|
//minecraft.locateMultiplayer();
|
||||||
//minecraft->setScreen(new JoinGameScreen());
|
//minecraft.setScreen(new JoinGameScreen());
|
||||||
}
|
}
|
||||||
if(button->id == bJoinByIp.id) {
|
if(button->id == bJoinByIp.id) {
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft.cancelLocateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_JOINBYIP);
|
minecraft.screenChooser.setScreen(SCREEN_JOINBYIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button->id == bBack.id)
|
if (button->id == bBack.id)
|
||||||
{
|
{
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft.cancelLocateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,8 +145,8 @@ bool JoinGameScreen::handleBackEvent(bool isDown)
|
|||||||
{
|
{
|
||||||
if (!isDown)
|
if (!isDown)
|
||||||
{
|
{
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft.cancelLocateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ void JoinGameScreen::tick()
|
|||||||
|
|
||||||
//gamesList->tick();
|
//gamesList->tick();
|
||||||
|
|
||||||
const ServerList& orgServerList = minecraft->raknetInstance->getServerList();
|
const ServerList& orgServerList = minecraft.raknetInstance->getServerList();
|
||||||
ServerList serverList;
|
ServerList serverList;
|
||||||
for (unsigned int i = 0; i < orgServerList.size(); ++i)
|
for (unsigned int i = 0; i < orgServerList.size(); ++i)
|
||||||
if (orgServerList[i].name.GetLength() > 0)
|
if (orgServerList[i].name.GetLength() > 0)
|
||||||
@@ -211,7 +211,7 @@ void JoinGameScreen::tick()
|
|||||||
|
|
||||||
void JoinGameScreen::render( int xm, int ym, float a )
|
void JoinGameScreen::render( int xm, int ym, float a )
|
||||||
{
|
{
|
||||||
bool hasNetwork = minecraft->platform()->isNetworkEnabled(true);
|
bool hasNetwork = minecraft.platform()->isNetworkEnabled(true);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
hasNetwork = hasNetwork && !GetAsyncKeyState(VK_TAB);
|
hasNetwork = hasNetwork && !GetAsyncKeyState(VK_TAB);
|
||||||
#endif
|
#endif
|
||||||
@@ -225,16 +225,16 @@ void JoinGameScreen::render( int xm, int ym, float a )
|
|||||||
|
|
||||||
if (hasNetwork) {
|
if (hasNetwork) {
|
||||||
std::string s = "Scanning for WiFi Games...";
|
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;
|
const int spinnerX = baseX + textWidth / 2 + 6;
|
||||||
|
|
||||||
static const char* spinnerTexts[] = {"-", "\\", "|", "/"};
|
static const char* spinnerTexts[] = {"-", "\\", "|", "/"};
|
||||||
int n = ((int)(5.5f * getTimeS()) % 4);
|
int n = ((int)(5.5f * getTimeS()) % 4);
|
||||||
drawCenteredString(minecraft->font, spinnerTexts[n], spinnerX, 8, 0xffffffff);
|
drawCenteredString(minecraft.font(), spinnerTexts[n], spinnerX, 8, 0xffffffff);
|
||||||
} else {
|
} 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/Screen.hpp"
|
||||||
#include "client/gui/components/Button.hpp"
|
#include "client/gui/components/Button.hpp"
|
||||||
#include "client/gui/components/RolledSelectionListV.hpp"
|
#include "client/gui/components/RolledSelectionListV.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "platform/input/Multitouch.hpp"
|
#include "platform/input/Multitouch.hpp"
|
||||||
#include "network/RakNetInstance.hpp"
|
#include "network/RakNetInstance.hpp"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ class AvailableGamesList : public RolledSelectionListV
|
|||||||
friend class JoinGameScreen;
|
friend class JoinGameScreen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AvailableGamesList(Minecraft* _minecraft, int _width, int _height)
|
AvailableGamesList(MinecraftClient& _minecraft, int _width, int _height)
|
||||||
: RolledSelectionListV(_minecraft, _width, _height, 0, _width, 24, _height, 34),
|
: RolledSelectionListV(_minecraft, _width, _height, 0, _width, 24, _height, 34),
|
||||||
selectedItem(-1),
|
selectedItem(-1),
|
||||||
startSelected(-1)
|
startSelected(-1)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Touch {
|
|||||||
//
|
//
|
||||||
// World Selection List
|
// World Selection List
|
||||||
//
|
//
|
||||||
TouchWorldSelectionList::TouchWorldSelectionList( Minecraft* minecraft, int width, int height )
|
TouchWorldSelectionList::TouchWorldSelectionList( MinecraftClient& minecraft, int width, int height )
|
||||||
: _height(height),
|
: _height(height),
|
||||||
hasPickedLevel(false),
|
hasPickedLevel(false),
|
||||||
pickedIndex(-1),
|
pickedIndex(-1),
|
||||||
@@ -85,12 +85,12 @@ void TouchWorldSelectionList::renderItem( int i, int x, int y, int h, Tesselator
|
|||||||
if (i < (int)levels.size()) {
|
if (i < (int)levels.size()) {
|
||||||
// Draw the worlds
|
// Draw the worlds
|
||||||
StringVector v = _descriptions[i];
|
StringVector v = _descriptions[i];
|
||||||
drawString(minecraft->font, v[0].c_str(), TX, TY + 0, textColor);
|
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[1].c_str(), TX, TY + 10, textColor2);
|
||||||
drawString(minecraft->font, v[2].c_str(), TX, TY + 20, 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[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);
|
t.color(0.3f, 1.0f, 0.2f);
|
||||||
|
|
||||||
//float x0 = (float)x;
|
//float x0 = (float)x;
|
||||||
@@ -106,9 +106,9 @@ void TouchWorldSelectionList::renderItem( int i, int x, int y, int h, Tesselator
|
|||||||
t.draw();
|
t.draw();
|
||||||
} else {
|
} else {
|
||||||
// Draw the "Create new world" icon
|
// 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;
|
const bool selected = _newWorldSelected;
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ void TouchWorldSelectionList::commit() {
|
|||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << level.name << "/preview.png";
|
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) {
|
if (id != Textures::InvalidId) {
|
||||||
_imageNames.push_back( ss.str() );
|
_imageNames.push_back( ss.str() );
|
||||||
@@ -174,7 +174,7 @@ void TouchWorldSelectionList::commit() {
|
|||||||
|
|
||||||
StringVector lines;
|
StringVector lines;
|
||||||
lines.push_back(levels[i].name);
|
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(levels[i].id);
|
||||||
lines.push_back(LevelSettings::gameTypeToString(level.gameType));
|
lines.push_back(LevelSettings::gameTypeToString(level.gameType));
|
||||||
_descriptions.push_back(lines);
|
_descriptions.push_back(lines);
|
||||||
@@ -350,19 +350,19 @@ void SelectWorldScreen::buttonClicked(Button* button)
|
|||||||
if (button->id == bCreate.id) {
|
if (button->id == bCreate.id) {
|
||||||
if (!_hasStartedLevel) {
|
if (!_hasStartedLevel) {
|
||||||
std::string name = getUniqueLevelName("World");
|
std::string name = getUniqueLevelName("World");
|
||||||
minecraft->setScreen(new SimpleChooseLevelScreen(name));
|
minecraft.setScreen(new SimpleChooseLevelScreen(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (button->id == bDelete.id) {
|
if (button->id == bDelete.id) {
|
||||||
if (isIndexValid(worldsList->selectedItem)) {
|
if (isIndexValid(worldsList->selectedItem)) {
|
||||||
LevelSummary level = worldsList->levels[worldsList->selectedItem];
|
LevelSummary level = worldsList->levels[worldsList->selectedItem];
|
||||||
LOGI("level: %s, %s\n", level.id.c_str(), level.name.c_str());
|
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) {
|
if (button->id == bBack.id) {
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft.cancelLocateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
if (button->id == bWorldView.id) {
|
if (button->id == bWorldView.id) {
|
||||||
// Try to "click" the item in the middle
|
// Try to "click" the item in the middle
|
||||||
@@ -374,8 +374,8 @@ bool SelectWorldScreen::handleBackEvent(bool isDown)
|
|||||||
{
|
{
|
||||||
if (!isDown)
|
if (!isDown)
|
||||||
{
|
{
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft.cancelLocateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
minecraft.screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -417,19 +417,19 @@ void SelectWorldScreen::tick()
|
|||||||
std::string levelId = getUniqueLevelName("World");
|
std::string levelId = getUniqueLevelName("World");
|
||||||
//int seed = Util::hashCode("/r/Minecraft");
|
//int seed = Util::hashCode("/r/Minecraft");
|
||||||
LevelSettings settings(getEpochTimeS(), GameType::Creative);
|
LevelSettings settings(getEpochTimeS(), GameType::Creative);
|
||||||
minecraft->selectLevel(levelId, levelId, settings);
|
minecraft.selectLevel(levelId, levelId, settings);
|
||||||
minecraft->hostMultiplayer();
|
minecraft.hostMultiplayer();
|
||||||
minecraft->setScreen(new ProgressScreen());
|
minecraft.setScreen(new ProgressScreen());
|
||||||
_hasStartedLevel = true;
|
_hasStartedLevel = true;
|
||||||
#elif defined(PLATFORM_DESKTOP)
|
#elif defined(PLATFORM_DESKTOP)
|
||||||
std::string name = getUniqueLevelName("World");
|
std::string name = getUniqueLevelName("World");
|
||||||
minecraft->setScreen(new SimpleChooseLevelScreen(name));
|
minecraft.setScreen(new SimpleChooseLevelScreen(name));
|
||||||
#else
|
#else
|
||||||
int status = minecraft->platform()->getUserInputStatus();
|
int status = minecraft.platform()->getUserInputStatus();
|
||||||
//LOGI("Status is: %d\n", status);
|
//LOGI("Status is: %d\n", status);
|
||||||
if (status > -1) {
|
if (status > -1) {
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
StringVector sv = minecraft->platform()->getUserInput();
|
StringVector sv = minecraft.platform()->getUserInput();
|
||||||
|
|
||||||
// Read the level name.
|
// Read the level name.
|
||||||
// 1) Trim name 2) Remove all bad chars 3) Append '-' chars 'til the name is unique
|
// 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
|
// 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);
|
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);
|
LevelSettings settings(seed, isCreative? GameType::Creative : GameType::Survival);
|
||||||
minecraft->selectLevel(levelId, levelName, settings);
|
minecraft.selectLevel(levelId, levelName, settings);
|
||||||
minecraft->hostMultiplayer();
|
minecraft.hostMultiplayer();
|
||||||
minecraft->setScreen(new ProgressScreen());
|
minecraft.setScreen(new ProgressScreen());
|
||||||
_hasStartedLevel = true;
|
_hasStartedLevel = true;
|
||||||
}
|
}
|
||||||
_state = _STATE_DEFAULT;
|
_state = _STATE_DEFAULT;
|
||||||
@@ -489,11 +489,11 @@ void SelectWorldScreen::tick()
|
|||||||
if (worldsList->pickedIndex == worldsList->levels.size()) {
|
if (worldsList->pickedIndex == worldsList->levels.size()) {
|
||||||
worldsList->hasPickedLevel = false;
|
worldsList->hasPickedLevel = false;
|
||||||
std::string name = getUniqueLevelName("World");
|
std::string name = getUniqueLevelName("World");
|
||||||
minecraft->setScreen(new SimpleChooseLevelScreen(name));
|
minecraft.setScreen(new SimpleChooseLevelScreen(name));
|
||||||
} else {
|
} else {
|
||||||
minecraft->selectLevel(worldsList->pickedLevel.id, worldsList->pickedLevel.name, LevelSettings::None());
|
minecraft.selectLevel(worldsList->pickedLevel.id, worldsList->pickedLevel.name, LevelSettings::None());
|
||||||
minecraft->hostMultiplayer();
|
minecraft.hostMultiplayer();
|
||||||
minecraft->setScreen(new ProgressScreen());
|
minecraft.setScreen(new ProgressScreen());
|
||||||
_hasStartedLevel = true;
|
_hasStartedLevel = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -533,7 +533,7 @@ void SelectWorldScreen::render( int xm, int ym, float a )
|
|||||||
Screen::render(xm, ym, a);
|
Screen::render(xm, ym, a);
|
||||||
//Performance::watches.get("sws-screen").stop();
|
//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").start();
|
||||||
//Performance::watches.get("sws-string").stop();
|
//Performance::watches.get("sws-string").stop();
|
||||||
@@ -544,7 +544,7 @@ void SelectWorldScreen::render( int xm, int ym, float a )
|
|||||||
|
|
||||||
void SelectWorldScreen::loadLevelSource()
|
void SelectWorldScreen::loadLevelSource()
|
||||||
{
|
{
|
||||||
LevelStorageSource* levelSource = minecraft->getLevelSource();
|
LevelStorageSource* levelSource = minecraft.getLevelSource();
|
||||||
levelSource->getLevelList(levels);
|
levelSource->getLevelList(levels);
|
||||||
std::sort(levels.begin(), levels.end());
|
std::sort(levels.begin(), levels.end());
|
||||||
|
|
||||||
@@ -572,9 +572,9 @@ bool SelectWorldScreen::isInGameScreen() { return true; }
|
|||||||
void SelectWorldScreen::keyPressed( int eventKey )
|
void SelectWorldScreen::keyPressed( int eventKey )
|
||||||
{
|
{
|
||||||
if (bWorldView.selected) {
|
if (bWorldView.selected) {
|
||||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_LEFT))
|
if (eventKey == minecraft.options().getIntValue(OPTIONS_KEY_LEFT))
|
||||||
worldsList->stepLeft();
|
worldsList->stepLeft();
|
||||||
if (eventKey == minecraft->options.getIntValue(OPTIONS_KEY_RIGHT))
|
if (eventKey == minecraft.options().getIntValue(OPTIONS_KEY_RIGHT))
|
||||||
worldsList->stepRight();
|
worldsList->stepRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,10 +596,10 @@ TouchDeleteWorldScreen::TouchDeleteWorldScreen(const LevelSummary& level)
|
|||||||
void TouchDeleteWorldScreen::postResult( bool isOk )
|
void TouchDeleteWorldScreen::postResult( bool isOk )
|
||||||
{
|
{
|
||||||
if (isOk) {
|
if (isOk) {
|
||||||
LevelStorageSource* storageSource = minecraft->getLevelSource();
|
LevelStorageSource* storageSource = minecraft.getLevelSource();
|
||||||
storageSource->deleteLevel(_level.id);
|
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/ImageButton.hpp"
|
||||||
#include "client/gui/components/Button.hpp"
|
#include "client/gui/components/Button.hpp"
|
||||||
#include "client/gui/components/RolledSelectionListH.hpp"
|
#include "client/gui/components/RolledSelectionListH.hpp"
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "world/level/storage/LevelStorageSource.hpp"
|
#include "world/level/storage/LevelStorageSource.hpp"
|
||||||
|
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ class SelectWorldScreen;
|
|||||||
class TouchWorldSelectionList : public RolledSelectionListH
|
class TouchWorldSelectionList : public RolledSelectionListH
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TouchWorldSelectionList(Minecraft* _minecraft, int _width, int _height);
|
TouchWorldSelectionList(MinecraftClient& _minecraft, int _width, int _height);
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
void stepLeft();
|
void stepLeft();
|
||||||
void stepRight();
|
void stepRight();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "client/gui/components/ScrolledSelectionList.hpp"
|
#include "client/gui/components/ScrolledSelectionList.hpp"
|
||||||
#include "client/gui/components/GuiElement.hpp"
|
#include "client/gui/components/GuiElement.hpp"
|
||||||
|
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
#include "client/renderer/TextureData.hpp"
|
#include "client/renderer/TextureData.hpp"
|
||||||
@@ -85,7 +85,7 @@ void StartMenuScreen::init()
|
|||||||
// always show base version string
|
// always show base version string
|
||||||
std::string versionString = Common::getGameVersionString();
|
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";
|
if (_username.empty()) _username = "unknown";
|
||||||
|
|
||||||
username = "Username: " + _username;
|
username = "Username: " + _username;
|
||||||
@@ -127,8 +127,8 @@ void StartMenuScreen::setupPositions() {
|
|||||||
bQuit.x = width - bQuit.width;
|
bQuit.x = width - bQuit.width;
|
||||||
bQuit.y = 0;
|
bQuit.y = 0;
|
||||||
|
|
||||||
copyrightPosX = width - minecraft->font->width(copyright) - 1;
|
copyrightPosX = width - minecraft.font()->width(copyright) - 1;
|
||||||
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
|
versionPosX = (width - minecraft.font()->width(version)) / 2;// - minecraft.font()->width(version) - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuScreen::buttonClicked(::Button* button) {
|
void StartMenuScreen::buttonClicked(::Button* button) {
|
||||||
@@ -136,27 +136,27 @@ void StartMenuScreen::buttonClicked(::Button* button) {
|
|||||||
if (button->id == bHost.id)
|
if (button->id == bHost.id)
|
||||||
{
|
{
|
||||||
#if defined(DEMO_MODE) || defined(APPLE_DEMO_PROMOTION)
|
#if defined(DEMO_MODE) || defined(APPLE_DEMO_PROMOTION)
|
||||||
minecraft->setScreen( new SimpleChooseLevelScreen("_DemoLevel") );
|
minecraft.setScreen( new SimpleChooseLevelScreen("_DemoLevel") );
|
||||||
#else
|
#else
|
||||||
minecraft->screenChooser.setScreen(SCREEN_SELECTWORLD);
|
minecraft.screenChooser.setScreen(SCREEN_SELECTWORLD);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (button->id == bJoin.id)
|
if (button->id == bJoin.id)
|
||||||
{
|
{
|
||||||
#ifdef APPLE_DEMO_PROMOTION
|
#ifdef APPLE_DEMO_PROMOTION
|
||||||
minecraft->platform()->createUserInput(DialogDefinitions::DIALOG_DEMO_FEATURE_DISABLED);
|
minecraft.platform()->createUserInput(DialogDefinitions::DIALOG_DEMO_FEATURE_DISABLED);
|
||||||
#else
|
#else
|
||||||
minecraft->locateMultiplayer();
|
minecraft.locateMultiplayer();
|
||||||
minecraft->screenChooser.setScreen(SCREEN_JOINGAME);
|
minecraft.screenChooser.setScreen(SCREEN_JOINGAME);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (button->id == bOptions.id)
|
if (button->id == bOptions.id)
|
||||||
{
|
{
|
||||||
minecraft->setScreen(new OptionsScreen());
|
minecraft.setScreen(new OptionsScreen());
|
||||||
}
|
}
|
||||||
if (button == &bQuit)
|
if (button == &bQuit)
|
||||||
{
|
{
|
||||||
minecraft->quit();
|
minecraft.quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,14 +172,14 @@ void StartMenuScreen::render( int xm, int ym, float a )
|
|||||||
glEnable2(GL_BLEND);
|
glEnable2(GL_BLEND);
|
||||||
|
|
||||||
#if defined(RPI)
|
#if defined(RPI)
|
||||||
TextureId id = minecraft->textures->loadTexture("gui/pi_title.png");
|
TextureId id = minecraft.textures().loadTexture("gui/pi_title.png");
|
||||||
#else
|
#else
|
||||||
TextureId id = minecraft->textures->loadTexture("gui/title.png");
|
TextureId id = minecraft.textures().loadTexture("gui/title.png");
|
||||||
#endif
|
#endif
|
||||||
const TextureData* data = minecraft->textures->getTemporaryTextureData(id);
|
const TextureData* data = minecraft.textures().getTemporaryTextureData(id);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
minecraft->textures->bind(id);
|
minecraft.textures().bind(id);
|
||||||
|
|
||||||
const float x = (float)width / 2;
|
const float x = (float)width / 2;
|
||||||
const float y = 4;
|
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, version, versionPosX, (int)(y+h)+2, /*50,*/ 0xffcccccc);//0x666666);
|
||||||
drawString(font, copyright, copyrightPosX, height - 10, 0xffffff);
|
drawString(font, copyright, copyrightPosX, height - 10, 0xffffff);
|
||||||
glColor4f2(1, 1, 1, 1);
|
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);
|
blit(2, height - 10, 0, 0, 8, 8, 256, 256);
|
||||||
drawString(font, "Kolyah35/minecraft-pe-0.6.1", 12, height - 10, 0xffcccccc);
|
drawString(font, "Kolyah35/minecraft-pe-0.6.1", 12, height - 10, 0xffcccccc);
|
||||||
//patch->draw(t, 0, 20);
|
//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) {
|
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||||
const int logoX = 2;
|
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 logoY = height - 10;
|
||||||
const int logoH = 10;
|
const int logoH = 10;
|
||||||
if (x >= logoX && x <= logoX + logoW && y >= logoY && y <= logoY + logoH)
|
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
|
else
|
||||||
Screen::mouseClicked(x, y, buttonNum);
|
Screen::mouseClicked(x, y, buttonNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartMenuScreen::handleBackEvent( bool isDown ) {
|
bool StartMenuScreen::handleBackEvent( bool isDown ) {
|
||||||
minecraft->quit();
|
minecraft.quit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,17 +54,17 @@ public:
|
|||||||
updateSkyDarken();
|
updateSkyDarken();
|
||||||
|
|
||||||
for (int i = 0; i < 10 && !reEntries.empty(); i++) {
|
for (int i = 0; i < 10 && !reEntries.empty(); i++) {
|
||||||
EntitySet::iterator it = reEntries.begin();
|
auto it = reEntries.begin();
|
||||||
Entity* e = *it;//reEntries.iterator().next();
|
Entity* e = *it;//reEntries.iterator().next();
|
||||||
reEntries.erase(it);
|
reEntries.erase(it);
|
||||||
|
|
||||||
//if (!entities.contains(e)) addEntity(e);
|
//if (!entities.contains(e)) addEntity(e);
|
||||||
EntityList::iterator jt = std::find(entities.begin(), entities.end(), e);
|
auto jt = std::find(entities.begin(), entities.end(), e);
|
||||||
if (jt == entities.end())
|
if (jt == entities.end())
|
||||||
addEntity(e);
|
addEntity(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ResetInfoList::iterator it = updatesToReset.begin(); it != updatesToReset.end();) {
|
for (auto it = updatesToReset.begin(); it != updatesToReset.end();) {
|
||||||
ResetInfo& r = *it;
|
ResetInfo& r = *it;
|
||||||
if (--r.ticks == 0) {
|
if (--r.ticks == 0) {
|
||||||
super::setTileAndDataNoUpdate(r.x, r.y, r.z, r.tile, r.data);
|
super::setTileAndDataNoUpdate(r.x, r.y, r.z, r.tile, r.data);
|
||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clearResetRegion(int x0, int y0, int z0, int x1, int y1, int z1) {
|
void clearResetRegion(int x0, int y0, int z0, int x1, int y1, int z1) {
|
||||||
for (ResetInfoList::iterator it = updatesToReset.begin(); it != updatesToReset.end();) {
|
for (auto it = updatesToReset.begin(); it != updatesToReset.end();) {
|
||||||
ResetInfo& r = *it;
|
ResetInfo& r = *it;
|
||||||
if (r.x >= x0 && r.y >= y0 && r.z >= z0 && r.x <= x1 && r.y <= y1 && r.z <= z1) {
|
if (r.x >= x0 && r.y >= y0 && r.z >= z0 && r.x <= x1 && r.y <= y1 && r.z <= z1) {
|
||||||
it = updatesToReset.erase(it);
|
it = updatesToReset.erase(it);
|
||||||
@@ -141,7 +141,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity* removeEntity(int id) {
|
Entity* removeEntity(int id) {
|
||||||
EntityIdMap::iterator it = entitiesById.find(id);
|
auto it = entitiesById.find(id);
|
||||||
if (it != entitiesById.end()) {
|
if (it != entitiesById.end()) {
|
||||||
Entity* e = it->second;
|
Entity* e = it->second;
|
||||||
entitiesById.erase(it);
|
entitiesById.erase(it);
|
||||||
@@ -208,7 +208,7 @@ protected:
|
|||||||
|
|
||||||
void entityAdded(Entity* e) {
|
void entityAdded(Entity* e) {
|
||||||
super::entityAdded(e);
|
super::entityAdded(e);
|
||||||
EntitySet::iterator it = reEntries.find(e);
|
auto it = reEntries.find(e);
|
||||||
if (it != reEntries.end()) {
|
if (it != reEntries.end()) {
|
||||||
reEntries.erase(it);
|
reEntries.erase(it);
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ protected:
|
|||||||
|
|
||||||
void entityRemoved(Entity* e) {
|
void entityRemoved(Entity* e) {
|
||||||
super::entityRemoved(e);
|
super::entityRemoved(e);
|
||||||
EntitySet::iterator it = forced.find(e);
|
auto it = forced.find(e);
|
||||||
if (it != forced.end()) {
|
if (it != forced.end()) {
|
||||||
if (e->isAlive()) {
|
if (e->isAlive()) {
|
||||||
reEntries.insert(e);
|
reEntries.insert(e);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "world/level/Level.hpp"
|
#include "world/level/Level.hpp"
|
||||||
#include "NinecraftApp.hpp"
|
#include "NinecraftApp.hpp"
|
||||||
|
|
||||||
ParticleEngine::ParticleEngine(Level* level, Textures* textures)
|
ParticleEngine::ParticleEngine(Level* level, Textures& textures)
|
||||||
: level(level),
|
: level(level),
|
||||||
textures(textures)
|
textures(textures)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
|
|
||||||
static const int TEXTURE_COUNT = 4;
|
static const int TEXTURE_COUNT = 4;
|
||||||
|
|
||||||
ParticleEngine(Level* level, Textures* textures);
|
ParticleEngine(Level* level, Textures& textures);
|
||||||
~ParticleEngine();
|
~ParticleEngine();
|
||||||
|
|
||||||
void add(Particle* p);
|
void add(Particle* p);
|
||||||
|
|||||||
@@ -552,8 +552,8 @@ void LocalPlayer::closeContainer() {
|
|||||||
|
|
||||||
//@Override
|
//@Override
|
||||||
void LocalPlayer::move(float xa, float ya, float za) {
|
void LocalPlayer::move(float xa, float ya, float za) {
|
||||||
//@note: why is this == minecraft.player needed?
|
//@note: why is this == minecraft.player() needed?
|
||||||
if (this == minecraft.getPlayer() && minecraft.options().getBooleanValue(OPTIONS_IS_FLYING)) {
|
if (this == minecraft.player() && minecraft.options().getBooleanValue(OPTIONS_IS_FLYING)) {
|
||||||
noPhysics = true;
|
noPhysics = true;
|
||||||
float tmp = walkDist; // update
|
float tmp = walkDist; // update
|
||||||
calculateFlight((float) xa, (float) ya, (float) za);
|
calculateFlight((float) xa, (float) ya, (float) za);
|
||||||
@@ -666,9 +666,9 @@ void LocalPlayer::hurtTo( int newHealth )
|
|||||||
lastHealth = health;
|
lastHealth = health;
|
||||||
invulnerableTime = invulnerableDuration;
|
invulnerableTime = invulnerableDuration;
|
||||||
|
|
||||||
minecraft.getPlayer()->bypassArmor = true;
|
minecraft.player()->bypassArmor = true;
|
||||||
actuallyHurt(dmg);
|
actuallyHurt(dmg);
|
||||||
minecraft.getPlayer()->bypassArmor = false;
|
minecraft.player()->bypassArmor = false;
|
||||||
|
|
||||||
hurtTime = hurtDuration = 10;
|
hurtTime = hurtDuration = 10;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ public:
|
|||||||
void displayClientMessage(const std::string& messageId);
|
void displayClientMessage(const std::string& messageId);
|
||||||
|
|
||||||
void awardStat(Stat* stat, int count) {
|
void awardStat(Stat* stat, int count) {
|
||||||
//minecraft->stats.award(stat, count);
|
//minecraft.stats.award(stat, count);
|
||||||
//minecraft->achievementPopup.popup("Achievement get!", stat.name);
|
//minecraft.achievementPopup.popup("Achievement get!", stat.name);
|
||||||
}
|
}
|
||||||
void causeFallDamage( float distance );
|
void causeFallDamage( float distance );
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "client/IConfigListener.hpp"
|
#include "client/IConfigListener.hpp"
|
||||||
class Player;
|
class Player;
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
|
|
||||||
class IMoveInput
|
class IMoveInput
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ public:
|
|||||||
static const int MODE_OFFSET = 1;
|
static const int MODE_OFFSET = 1;
|
||||||
static const int MODE_DELTA = 2;
|
static const int MODE_DELTA = 2;
|
||||||
|
|
||||||
UnifiedTurnBuild(int turnMode, int width, int height, float maxMovementDelta, float sensitivity, IInputHolder* holder, Minecraft* minecraft)
|
UnifiedTurnBuild(int turnMode, int width, int height, float maxMovementDelta, float sensitivity, IInputHolder* holder, MinecraftClient& minecraft)
|
||||||
: mode(turnMode),
|
: mode(turnMode),
|
||||||
_holder(holder),
|
_holder(holder),
|
||||||
_options(&minecraft->options),
|
_options(&minecraft.options),
|
||||||
cxO(0), cyO(0),
|
cxO(0), cyO(0),
|
||||||
wasActive(false),
|
wasActive(false),
|
||||||
_totalMoveDelta(0),
|
_totalMoveDelta(0),
|
||||||
@@ -90,12 +90,12 @@ public:
|
|||||||
virtual void onConfigChanged(const Config& c) {
|
virtual void onConfigChanged(const Config& c) {
|
||||||
if (false && _options->getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)) {
|
if (false && _options->getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)) {
|
||||||
int touchWidth = c.width - (int)inventoryArea._x1;
|
int touchWidth = c.width - (int)inventoryArea._x1;
|
||||||
if (touchWidth > (int)c.minecraft->pixelCalc.millimetersToPixels(60))
|
if (touchWidth > (int)c.minecraft.pixelCalc.millimetersToPixels(60))
|
||||||
touchWidth = (int)c.minecraft->pixelCalc.millimetersToPixels(60);
|
touchWidth = (int)c.minecraft.pixelCalc.millimetersToPixels(60);
|
||||||
|
|
||||||
int touchHeight = (int)(c.height * 0.4f);
|
int touchHeight = (int)(c.height * 0.4f);
|
||||||
if (touchHeight > (int)c.minecraft->pixelCalc.millimetersToPixels(40))
|
if (touchHeight > (int)c.minecraft.pixelCalc.millimetersToPixels(40))
|
||||||
touchHeight = (int)c.minecraft->pixelCalc.millimetersToPixels(40);
|
touchHeight = (int)c.minecraft.pixelCalc.millimetersToPixels(40);
|
||||||
|
|
||||||
joyTouchArea._x0 = (float)(c.width - touchWidth);
|
joyTouchArea._x0 = (float)(c.width - touchWidth);
|
||||||
joyTouchArea._y0 = (float)(c.height - touchHeight);
|
joyTouchArea._y0 = (float)(c.height - touchHeight);
|
||||||
@@ -403,7 +403,7 @@ private:
|
|||||||
Options* _options;
|
Options* _options;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning( disable : 4355 ) // 'this' pointer in initialization list which is perfectly legal
|
#pragma warning( disable : 4355 ) // 'this' pointer in initialization list which is perfectly legal
|
||||||
@@ -412,10 +412,10 @@ class Minecraft;
|
|||||||
class TouchInputHolder: public IInputHolder
|
class TouchInputHolder: public IInputHolder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TouchInputHolder(Minecraft* mc, Options* options)
|
TouchInputHolder(MinecraftClient& mc, Options* options)
|
||||||
: _mc(mc),
|
: _mc(mc),
|
||||||
_move(mc, options),
|
_move(mc, options),
|
||||||
_turnBuild(UnifiedTurnBuild::MODE_DELTA, mc->width, mc->height, (float)MovementLimit, 1, this, mc)
|
_turnBuild(UnifiedTurnBuild::MODE_DELTA, mc.getScreenWidth(), mc.getScreenHeight(), (float)MovementLimit, 1, this, mc)
|
||||||
{
|
{
|
||||||
onConfigChanged(createConfig(mc));
|
onConfigChanged(createConfig(mc));
|
||||||
}
|
}
|
||||||
@@ -426,7 +426,7 @@ public:
|
|||||||
_move.onConfigChanged(c);
|
_move.onConfigChanged(c);
|
||||||
_turnBuild.moveArea = _move.getRectangleArea();
|
_turnBuild.moveArea = _move.getRectangleArea();
|
||||||
_turnBuild.pauseArea = _move.getPauseRectangleArea();
|
_turnBuild.pauseArea = _move.getPauseRectangleArea();
|
||||||
_turnBuild.inventoryArea = _mc->gui.getRectangleArea( _mc->options.getBooleanValue(OPTIONS_IS_LEFT_HANDED)? 1 : -1 );
|
_turnBuild.inventoryArea = _mc.gui().getRectangleArea( _mc.options.getBooleanValue(OPTIONS_IS_LEFT_HANDED)? 1 : -1 );
|
||||||
_turnBuild.setSensitivity(c.options->getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)? 1.8f : 1.0f);
|
_turnBuild.setSensitivity(c.options->getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)? 1.8f : 1.0f);
|
||||||
((ITurnInput*)&_turnBuild)->onConfigChanged(c);
|
((ITurnInput*)&_turnBuild)->onConfigChanged(c);
|
||||||
}
|
}
|
||||||
@@ -462,7 +462,7 @@ private:
|
|||||||
TouchscreenInput_TestFps _move;
|
TouchscreenInput_TestFps _move;
|
||||||
UnifiedTurnBuild _turnBuild;
|
UnifiedTurnBuild _turnBuild;
|
||||||
|
|
||||||
Minecraft* _mc;
|
MinecraftClient& _mc;
|
||||||
|
|
||||||
static const int MovementLimit = 200; // per update
|
static const int MovementLimit = 200; // per update
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "client/renderer/Tesselator.hpp"
|
#include "client/renderer/Tesselator.hpp"
|
||||||
#include "world/entity/player/Player.hpp"
|
#include "world/entity/player/Player.hpp"
|
||||||
|
|
||||||
#include "client/Minecraft.hpp"
|
#include <MinecraftClient.hpp>
|
||||||
#include "platform/log.hpp"
|
#include "platform/log.hpp"
|
||||||
#include "client/renderer/Textures.hpp"
|
#include "client/renderer/Textures.hpp"
|
||||||
#include "client/sound/SoundEngine.hpp"
|
#include "client/sound/SoundEngine.hpp"
|
||||||
@@ -64,7 +64,7 @@ static void Transformed(int n, float* x, float* y, float* dx, float* dy, float x
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
TouchscreenInput_TestFps::TouchscreenInput_TestFps( Minecraft* mc, Options* options )
|
TouchscreenInput_TestFps::TouchscreenInput_TestFps( MinecraftClient& mc, Options* options )
|
||||||
: _minecraft(mc),
|
: _minecraft(mc),
|
||||||
_options(options),
|
_options(options),
|
||||||
_northJump(false),
|
_northJump(false),
|
||||||
@@ -129,7 +129,7 @@ void TouchscreenInput_TestFps::onConfigChanged(const Config& c) {
|
|||||||
float Bh = Bw;//0.15f;
|
float Bh = Bw;//0.15f;
|
||||||
|
|
||||||
// If too large (like playing on Tablet)
|
// If too large (like playing on Tablet)
|
||||||
PixelCalc& pc = _minecraft->pixelCalc;
|
PixelCalc& pc = _minecraft.pixelCalc;
|
||||||
if (pc.pixelsToMillimeters(Bw) > 200) { //14
|
if (pc.pixelsToMillimeters(Bw) > 200) { //14
|
||||||
Bw = Bh = pc.millimetersToPixels(200); //14
|
Bw = Bh = pc.millimetersToPixels(200); //14
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ void TouchscreenInput_TestFps::onConfigChanged(const Config& c) {
|
|||||||
xx = BaseX + 2 * Bw; yy = BaseY + Bh;
|
xx = BaseX + 2 * Bw; yy = BaseY + Bh;
|
||||||
_model.addArea(AREA_DPAD_E, aRight = new RectangleArea(xx, yy, xx+Bw, yy+Bh));
|
_model.addArea(AREA_DPAD_E, aRight = new RectangleArea(xx, yy, xx+Bw, yy+Bh));
|
||||||
|
|
||||||
float maxPixels = _minecraft->pixelCalc.millimetersToPixels(10);
|
float maxPixels = _minecraft.pixelCalc.millimetersToPixels(10);
|
||||||
// float btnSize = Mth::Min(18 * Gui::GuiScale, maxPixels);
|
// float btnSize = Mth::Min(18 * Gui::GuiScale, maxPixels);
|
||||||
float btnSize = pc.millimetersToPixels(18 * Gui::GuiScale);
|
float btnSize = pc.millimetersToPixels(18 * Gui::GuiScale);
|
||||||
_model.addArea(AREA_PAUSE, aPause = new RectangleArea(w - 4 - btnSize, 4, w - 4, 4 + btnSize));
|
_model.addArea(AREA_PAUSE, aPause = new RectangleArea(w - 4 - btnSize, 4, w - 4, 4 + btnSize));
|
||||||
@@ -312,15 +312,15 @@ void TouchscreenInput_TestFps::tick( Player* player )
|
|||||||
}
|
}
|
||||||
else if (areaId == AREA_PAUSE) {
|
else if (areaId == AREA_PAUSE) {
|
||||||
if (Multitouch::isReleased(p)) {
|
if (Multitouch::isReleased(p)) {
|
||||||
_minecraft->soundEngine->playUI("random.click", 1, 1);
|
_minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||||
_minecraft->screenChooser.setScreen(SCREEN_PAUSE);
|
_minecraft.screenChooser.setScreen(SCREEN_PAUSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (areaId == AREA_CHAT) {
|
else if (areaId == AREA_CHAT) {
|
||||||
if (Multitouch::isReleased(p)) {
|
if (Multitouch::isReleased(p)) {
|
||||||
_minecraft->soundEngine->playUI("random.click", 1, 1);
|
_minecraft.soundEngine()->playUI("random.click", 1, 1);
|
||||||
_minecraft->screenChooser.setScreen(SCREEN_CONSOLE);
|
_minecraft.screenChooser.setScreen(SCREEN_CONSOLE);
|
||||||
_minecraft->platform()->showKeyboard();
|
_minecraft.platform()->showKeyboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,7 +409,7 @@ void TouchscreenInput_TestFps::render( float a ) {
|
|||||||
|
|
||||||
glEnable2(GL_BLEND);
|
glEnable2(GL_BLEND);
|
||||||
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
_minecraft->textures->loadAndBindTexture("gui/gui.png");
|
_minecraft.textures().loadAndBindTexture("gui/gui.png");
|
||||||
|
|
||||||
//glDisable2(GL_TEXTURE_2D);
|
//glDisable2(GL_TEXTURE_2D);
|
||||||
|
|
||||||
@@ -506,7 +506,7 @@ void TouchscreenInput_TestFps::rebuild() {
|
|||||||
drawRectangleArea(t, aJump, imageU + imageSize * 4, imageV, (float)imageSize);
|
drawRectangleArea(t, aJump, imageU + imageSize * 4, imageV, (float)imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_minecraft->screen) {
|
if (!_minecraft.screen) {
|
||||||
t.colorABGR(0xFFFFFFFF);
|
t.colorABGR(0xFFFFFFFF);
|
||||||
// if (isButtonDown(AREA_PAUSE)) t.colorABGR(cPressedPause);
|
// if (isButtonDown(AREA_PAUSE)) t.colorABGR(cPressedPause);
|
||||||
// else t.colorABGR(cReleasedPause);
|
// else t.colorABGR(cReleasedPause);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
class Options;
|
class Options;
|
||||||
class Player;
|
class Player;
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
class PolygonArea;
|
class PolygonArea;
|
||||||
|
|
||||||
// @todo: extract a separate MoveInput (-> merge XperiaPlayInput)
|
// @todo: extract a separate MoveInput (-> merge XperiaPlayInput)
|
||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
static const int KEY_CRAFT = 6;
|
static const int KEY_CRAFT = 6;
|
||||||
static const int NumKeys = 7;
|
static const int NumKeys = 7;
|
||||||
|
|
||||||
TouchscreenInput_TestFps(Minecraft* mc, Options* options);
|
TouchscreenInput_TestFps(MinecraftClient& mc, Options* options);
|
||||||
~TouchscreenInput_TestFps();
|
~TouchscreenInput_TestFps();
|
||||||
|
|
||||||
void onConfigChanged(const Config& c);
|
void onConfigChanged(const Config& c);
|
||||||
@@ -53,7 +53,7 @@ private:
|
|||||||
bool _northJump;
|
bool _northJump;
|
||||||
bool _renderFlightImage;
|
bool _renderFlightImage;
|
||||||
TouchAreaModel _model;
|
TouchAreaModel _model;
|
||||||
Minecraft* _minecraft;
|
MinecraftClient& _minecraft;
|
||||||
|
|
||||||
RectangleArea* aLeft;
|
RectangleArea* aLeft;
|
||||||
RectangleArea* aRight;
|
RectangleArea* aRight;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "culling/FrustumCuller.hpp"
|
#include "culling/FrustumCuller.hpp"
|
||||||
#include "entity/EntityRenderDispatcher.hpp"
|
#include "entity/EntityRenderDispatcher.hpp"
|
||||||
#include <Minecraft.hpp>
|
#include <Minecraft.hpp>
|
||||||
#include "client/gamemode/GameMode.hpp"
|
#include "gamemode/GameMode.hpp"
|
||||||
#include "client/particle/ParticleEngine.hpp"
|
#include "client/particle/ParticleEngine.hpp"
|
||||||
#include "client/player/LocalPlayer.hpp"
|
#include "client/player/LocalPlayer.hpp"
|
||||||
#include "client/gui/Screen.hpp"
|
#include "client/gui/Screen.hpp"
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
static int _shTicks = -1;
|
static int _shTicks = -1;
|
||||||
|
|
||||||
GameRenderer::GameRenderer( Minecraft* mc )
|
GameRenderer::GameRenderer( MinecraftClient& mc )
|
||||||
: mc(mc),
|
: mc(mc),
|
||||||
renderDistance(0),
|
renderDistance(0),
|
||||||
_tick(0),
|
_tick(0),
|
||||||
@@ -61,17 +61,17 @@ GameRenderer::GameRenderer( Minecraft* mc )
|
|||||||
|
|
||||||
EntityRenderDispatcher* e = EntityRenderDispatcher::getInstance();
|
EntityRenderDispatcher* e = EntityRenderDispatcher::getInstance();
|
||||||
e->itemInHandRenderer = itemInHandRenderer;
|
e->itemInHandRenderer = itemInHandRenderer;
|
||||||
e->textures = mc->textures;
|
e->textures = mc.textures;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameRenderer::~GameRenderer() {
|
GameRenderer::~GameRenderer() {
|
||||||
delete itemInHandRenderer;
|
delete itemInHandRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderCursor(float x, float y, Minecraft* minecraft) {
|
void renderCursor(float x, float y, MinecraftClient& minecraft) {
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
|
|
||||||
minecraft->textures->loadAndBindTexture("gui/cursor.png");
|
minecraft.textures().loadAndBindTexture("gui/cursor.png");
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
const float s = 32;
|
const float s = 32;
|
||||||
@@ -90,9 +90,9 @@ void renderCursor(float x, float y, Minecraft* minecraft) {
|
|||||||
|
|
||||||
/*private*/
|
/*private*/
|
||||||
void GameRenderer::setupCamera(float a, int eye) {
|
void GameRenderer::setupCamera(float a, int eye) {
|
||||||
renderDistance = (float) (16 * 16 >> (mc->options.getIntValue(OPTIONS_VIEW_DISTANCE)));
|
renderDistance = (float) (16 * 16 >> (mc.options.getIntValue(OPTIONS_VIEW_DISTANCE)));
|
||||||
#if defined(ANDROID)
|
#if defined(ANDROID)
|
||||||
if (mc->isPowerVR() && mc->options.getIntValue(OPTIONS_VIEW_DISTANCE) <= 2)
|
if (mc.isPowerVR() && mc.options.getIntValue(OPTIONS_VIEW_DISTANCE) <= 2)
|
||||||
renderDistance *= 0.8f;
|
renderDistance *= 0.8f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -100,21 +100,21 @@ void GameRenderer::setupCamera(float a, int eye) {
|
|||||||
glLoadIdentity2();
|
glLoadIdentity2();
|
||||||
|
|
||||||
float stereoScale = 0.07f;
|
float stereoScale = 0.07f;
|
||||||
if (mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) glTranslatef2(-(eye * 2 - 1) * stereoScale, 0, 0);
|
if (mc.options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) glTranslatef2(-(eye * 2 - 1) * stereoScale, 0, 0);
|
||||||
if (zoom != 1) {
|
if (zoom != 1) {
|
||||||
glTranslatef2((float) zoom_x, (float) -zoom_y, 0);
|
glTranslatef2((float) zoom_x, (float) -zoom_y, 0);
|
||||||
glScalef2(zoom, zoom, 1);
|
glScalef2(zoom, zoom, 1);
|
||||||
gluPerspective(_setupCameraFov = getFov(a, true), mc->width / (float) mc->height, 0.05f, renderDistance);
|
gluPerspective(_setupCameraFov = getFov(a, true), mc.getScreenWidth() / (float) mc.getScreenHeight(), 0.05f, renderDistance);
|
||||||
} else {
|
} else {
|
||||||
gluPerspective(_setupCameraFov = getFov(a, true), mc->width / (float) mc->height, 0.05f, renderDistance);
|
gluPerspective(_setupCameraFov = getFov(a, true), mc.getScreenWidth() / (float) mc.getScreenHeight(), 0.05f, renderDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity2();
|
glLoadIdentity2();
|
||||||
if (mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) glTranslatef2((eye * 2 - 1) * 0.10f, 0, 0);
|
if (mc.options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) glTranslatef2((eye * 2 - 1) * 0.10f, 0, 0);
|
||||||
|
|
||||||
bobHurt(a);
|
bobHurt(a);
|
||||||
if (mc->options.getBooleanValue(OPTIONS_VIEW_BOBBING)) bobView(a);
|
if (mc.options.getBooleanValue(OPTIONS_VIEW_BOBBING)) bobView(a);
|
||||||
|
|
||||||
moveCameraToPlayer(a);
|
moveCameraToPlayer(a);
|
||||||
}
|
}
|
||||||
@@ -124,14 +124,14 @@ extern int _t_keepPic;
|
|||||||
/*public*/
|
/*public*/
|
||||||
void GameRenderer::render(float a) {
|
void GameRenderer::render(float a) {
|
||||||
TIMER_PUSH("mouse");
|
TIMER_PUSH("mouse");
|
||||||
if (mc->player && mc->mouseGrabbed) {
|
if (mc.player && mc.mouseGrabbed) {
|
||||||
mc->mouseHandler.poll();
|
mc.mouseHandler.poll();
|
||||||
//printf("Controller.x,y : %f,%f\n", Controller::getX(0), Controller::getY(0));
|
//printf("Controller.x,y : %f,%f\n", Controller::getX(0), Controller::getY(0));
|
||||||
|
|
||||||
float ss = mc->options.getProgressValue(OPTIONS_SENSITIVITY) * 0.6f + 0.2f;
|
float ss = mc.options.getProgressValue(OPTIONS_SENSITIVITY) * 0.6f + 0.2f;
|
||||||
float sens = (ss * ss * ss) * 8;
|
float sens = (ss * ss * ss) * 8;
|
||||||
float xo = mc->mouseHandler.xd * sens * 4.f;
|
float xo = mc.mouseHandler.xd * sens * 4.f;
|
||||||
float yo = mc->mouseHandler.yd * sens * 4.f;
|
float yo = mc.mouseHandler.yd * sens * 4.f;
|
||||||
|
|
||||||
const float now = _tick + a;
|
const float now = _tick + a;
|
||||||
float deltaT = now - _lastTickT;
|
float deltaT = now - _lastTickT;
|
||||||
@@ -142,19 +142,19 @@ void GameRenderer::render(float a) {
|
|||||||
_rotY += yo;
|
_rotY += yo;
|
||||||
|
|
||||||
int yAxis = -1;
|
int yAxis = -1;
|
||||||
if (mc->options.getBooleanValue(OPTIONS_INVERT_Y_MOUSE)) yAxis = 1;
|
if (mc.options.getBooleanValue(OPTIONS_INVERT_Y_MOUSE)) yAxis = 1;
|
||||||
|
|
||||||
bool screenCovering = mc->screen && !mc->screen->passEvents;
|
bool screenCovering = mc.screen && !mc.screen->passEvents;
|
||||||
if (!screenCovering)
|
if (!screenCovering)
|
||||||
{
|
{
|
||||||
mc->player->turn(deltaT * _rotXlast, deltaT * _rotYlast * yAxis);
|
mc.player->turn(deltaT * _rotXlast, deltaT * _rotYlast * yAxis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int xMouse = (int)(Mouse::getX() * Gui::InvGuiScale);
|
int xMouse = (int)(Mouse::getX() * Gui::InvGuiScale);
|
||||||
int yMouse = (int)(Mouse::getY() * Gui::InvGuiScale);
|
int yMouse = (int)(Mouse::getY() * Gui::InvGuiScale);
|
||||||
|
|
||||||
if (mc->useTouchscreen()) {
|
if (mc.useTouchscreen()) {
|
||||||
const int pid = Multitouch::getFirstActivePointerIdExThisUpdate();
|
const int pid = Multitouch::getFirstActivePointerIdExThisUpdate();
|
||||||
if (pid >= 0) {
|
if (pid >= 0) {
|
||||||
xMouse = (int)(Multitouch::getX(pid) * Gui::InvGuiScale);
|
xMouse = (int)(Multitouch::getX(pid) * Gui::InvGuiScale);
|
||||||
@@ -169,29 +169,29 @@ void GameRenderer::render(float a) {
|
|||||||
bool hasClearedColorBuffer = false;
|
bool hasClearedColorBuffer = false;
|
||||||
bool hasSetupGuiScreen = false;
|
bool hasSetupGuiScreen = false;
|
||||||
useScreenScissor = false;
|
useScreenScissor = false;
|
||||||
if (mc->isLevelGenerated()) {
|
if (mc.isLevelGenerated()) {
|
||||||
|
|
||||||
TIMER_PUSH("level");
|
TIMER_PUSH("level");
|
||||||
if (_t_keepPic < 0) {
|
if (_t_keepPic < 0) {
|
||||||
if (!(mc->screen && !mc->screen->renderGameBehind())) {
|
if (!(mc.screen && !mc.screen->renderGameBehind())) {
|
||||||
|
|
||||||
if (mc->screen && mc->screen->hasClippingArea(screenScissorArea))
|
if (mc.screen && mc.screen->hasClippingArea(screenScissorArea))
|
||||||
useScreenScissor = true;
|
useScreenScissor = true;
|
||||||
|
|
||||||
renderLevel(a);
|
renderLevel(a);
|
||||||
hasClearedColorBuffer = true;
|
hasClearedColorBuffer = true;
|
||||||
|
|
||||||
if (!mc->options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
if (!mc.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||||
TIMER_POP_PUSH("gui");
|
TIMER_POP_PUSH("gui");
|
||||||
setupGuiScreen(false);
|
setupGuiScreen(false);
|
||||||
hasSetupGuiScreen = true;
|
hasSetupGuiScreen = true;
|
||||||
mc->gui.render(a, mc->screen != NULL, xMouse, yMouse);
|
mc.gui().render(a, mc.screen != NULL, xMouse, yMouse);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
TIMER_POP();
|
TIMER_POP();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
glViewport(0, 0, mc->width, mc->height);
|
glViewport(0, 0, mc.getScreenWidth(), mc.getScreenHeight());
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity2();
|
glLoadIdentity2();
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
@@ -204,23 +204,23 @@ void GameRenderer::render(float a) {
|
|||||||
if (!hasSetupGuiScreen)
|
if (!hasSetupGuiScreen)
|
||||||
setupGuiScreen(!hasClearedColorBuffer);
|
setupGuiScreen(!hasClearedColorBuffer);
|
||||||
|
|
||||||
if (mc->player && mc->screen == NULL) {
|
if (mc.player && mc.screen == NULL) {
|
||||||
if (mc->inputHolder) mc->inputHolder->render(a);
|
if (mc.inputHolder) mc.inputHolder->render(a);
|
||||||
if (mc->player->input) mc->player->input->render(a);
|
if (mc.player->input) mc.player->input->render(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc->screen != NULL) {
|
if (mc.screen != NULL) {
|
||||||
if (useScreenScissor)
|
if (useScreenScissor)
|
||||||
glDisable2(GL_SCISSOR_TEST);
|
glDisable2(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
mc->screen->render(xMouse, yMouse, a);
|
mc.screen->render(xMouse, yMouse, a);
|
||||||
|
|
||||||
mc->platform()->hideCursor(!mc->options.getBooleanValue(OPTIONS_RPI_CURSOR));
|
mc.platform()->hideCursor(!mc.options.getBooleanValue(OPTIONS_RPI_CURSOR));
|
||||||
if (mc->options.getBooleanValue(OPTIONS_RPI_CURSOR))
|
if (mc.options.getBooleanValue(OPTIONS_RPI_CURSOR))
|
||||||
renderCursor(xMouse, yMouse, mc);
|
renderCursor(xMouse, yMouse, mc);
|
||||||
|
|
||||||
// Screen might have been removed, so check it again
|
// Screen might have been removed, so check it again
|
||||||
if (mc->screen && !mc->screen->isInGameScreen())
|
if (mc.screen && !mc.screen->isInGameScreen())
|
||||||
sleepMs(15);
|
sleepMs(15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,10 +228,10 @@ void GameRenderer::render(float a) {
|
|||||||
/*public*/
|
/*public*/
|
||||||
void GameRenderer::renderLevel(float a) {
|
void GameRenderer::renderLevel(float a) {
|
||||||
|
|
||||||
if (mc->cameraTargetPlayer == NULL) {
|
if (mc.cameraTargetPlayer == NULL) {
|
||||||
if (mc->player)
|
if (mc.player)
|
||||||
{
|
{
|
||||||
mc->cameraTargetPlayer = mc->player;
|
mc.cameraTargetPlayer = mc.player;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -242,21 +242,21 @@ void GameRenderer::renderLevel(float a) {
|
|||||||
TIMER_PUSH("pick");
|
TIMER_PUSH("pick");
|
||||||
pick(a);
|
pick(a);
|
||||||
|
|
||||||
Mob* cameraEntity = mc->cameraTargetPlayer;
|
Mob* cameraEntity = mc.cameraTargetPlayer;
|
||||||
LevelRenderer* levelRenderer = mc->levelRenderer;
|
LevelRenderer* levelRenderer = mc.levelRenderer;
|
||||||
ParticleEngine* particleEngine = mc->particleEngine;
|
ParticleEngine* particleEngine = mc.particleEngine;
|
||||||
float xOff = cameraEntity->xOld + (cameraEntity->x - cameraEntity->xOld) * a;
|
float xOff = cameraEntity->xOld + (cameraEntity->x - cameraEntity->xOld) * a;
|
||||||
float yOff = cameraEntity->yOld + (cameraEntity->y - cameraEntity->yOld) * a;
|
float yOff = cameraEntity->yOld + (cameraEntity->y - cameraEntity->yOld) * a;
|
||||||
float zOff = cameraEntity->zOld + (cameraEntity->z - cameraEntity->zOld) * a;
|
float zOff = cameraEntity->zOld + (cameraEntity->z - cameraEntity->zOld) * a;
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
if (mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) {
|
if (mc.options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) {
|
||||||
if (i == 0) glColorMask(false, true, true, false);
|
if (i == 0) glColorMask(false, true, true, false);
|
||||||
else glColorMask(true, false, false, false);
|
else glColorMask(true, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMER_POP_PUSH("clear");
|
TIMER_POP_PUSH("clear");
|
||||||
glViewport(0, 0, mc->width, mc->height);
|
glViewport(0, 0, mc.getScreenWidth(), mc.getScreenHeight());
|
||||||
setupClearColor(a);
|
setupClearColor(a);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
@@ -272,7 +272,7 @@ void GameRenderer::renderLevel(float a) {
|
|||||||
screenScissorArea.w, screenScissorArea.h);
|
screenScissorArea.w, screenScissorArea.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mc->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS)) {
|
if(mc.options.getBooleanValue(OPTIONS_FANCY_GRAPHICS)) {
|
||||||
setupFog(-1);
|
setupFog(-1);
|
||||||
TIMER_POP_PUSH("sky");
|
TIMER_POP_PUSH("sky");
|
||||||
glFogf(GL_FOG_START, renderDistance * 0.2f);
|
glFogf(GL_FOG_START, renderDistance * 0.2f);
|
||||||
@@ -284,7 +284,7 @@ void GameRenderer::renderLevel(float a) {
|
|||||||
glEnable2(GL_FOG);
|
glEnable2(GL_FOG);
|
||||||
setupFog(1);
|
setupFog(1);
|
||||||
|
|
||||||
if (mc->options.getBooleanValue(OPTIONS_AMBIENT_OCCLUSION)) {
|
if (mc.options.getBooleanValue(OPTIONS_AMBIENT_OCCLUSION)) {
|
||||||
glShadeModel2(GL_SMOOTH);
|
glShadeModel2(GL_SMOOTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,17 +293,17 @@ void GameRenderer::renderLevel(float a) {
|
|||||||
frustum.prepare(xOff, yOff, zOff);
|
frustum.prepare(xOff, yOff, zOff);
|
||||||
|
|
||||||
TIMER_POP_PUSH("culling");
|
TIMER_POP_PUSH("culling");
|
||||||
mc->levelRenderer->cull(&frustum, a);
|
mc.levelRenderer->cull(&frustum, a);
|
||||||
mc->levelRenderer->updateDirtyChunks(cameraEntity, false);
|
mc.levelRenderer->updateDirtyChunks(cameraEntity, false);
|
||||||
|
|
||||||
if(mc->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS)) {
|
if(mc.options.getBooleanValue(OPTIONS_FANCY_GRAPHICS)) {
|
||||||
prepareAndRenderClouds(levelRenderer, a);
|
prepareAndRenderClouds(levelRenderer, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
setupFog(0);
|
setupFog(0);
|
||||||
glEnable2(GL_FOG);
|
glEnable2(GL_FOG);
|
||||||
|
|
||||||
mc->textures->loadAndBindTexture("terrain.png");
|
mc.textures().loadAndBindTexture("terrain.png");
|
||||||
glDisable2(GL_ALPHA_TEST);
|
glDisable2(GL_ALPHA_TEST);
|
||||||
glDisable2(GL_BLEND);
|
glDisable2(GL_BLEND);
|
||||||
glEnable2(GL_CULL_FACE);
|
glEnable2(GL_CULL_FACE);
|
||||||
@@ -316,7 +316,7 @@ void GameRenderer::renderLevel(float a) {
|
|||||||
|
|
||||||
glShadeModel2(GL_FLAT);
|
glShadeModel2(GL_FLAT);
|
||||||
TIMER_POP_PUSH("entities");
|
TIMER_POP_PUSH("entities");
|
||||||
mc->levelRenderer->renderEntities(cameraEntity->getPos(a), &frustum, a);
|
mc.levelRenderer->renderEntities(cameraEntity->getPos(a), &frustum, a);
|
||||||
// setupFog(0);
|
// setupFog(0);
|
||||||
TIMER_POP_PUSH("particles");
|
TIMER_POP_PUSH("particles");
|
||||||
particleEngine->render(cameraEntity, a);
|
particleEngine->render(cameraEntity, a);
|
||||||
@@ -328,12 +328,12 @@ void GameRenderer::renderLevel(float a) {
|
|||||||
glDisable2(GL_CULL_FACE);
|
glDisable2(GL_CULL_FACE);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glDisable2(GL_ALPHA_TEST);
|
glDisable2(GL_ALPHA_TEST);
|
||||||
mc->textures->loadAndBindTexture("terrain.png");
|
mc.textures().loadAndBindTexture("terrain.png");
|
||||||
//if (mc->options.fancyGraphics) {
|
//if (mc.options.fancyGraphics) {
|
||||||
// glColorMask(false, false, false, false);
|
// glColorMask(false, false, false, false);
|
||||||
// int visibleWaterChunks = levelRenderer->render(cameraEntity, 1, a);
|
// int visibleWaterChunks = levelRenderer->render(cameraEntity, 1, a);
|
||||||
// glColorMask(true, true, true, true);
|
// glColorMask(true, true, true, true);
|
||||||
// if (mc->options.anaglyph3d) {
|
// if (mc.options.anaglyph3d) {
|
||||||
// if (i == 0) glColorMask(false, true, true, false);
|
// if (i == 0) glColorMask(false, true, true, false);
|
||||||
// else glColorMask(true, false, false, false);
|
// else glColorMask(true, false, false, false);
|
||||||
// }
|
// }
|
||||||
@@ -357,13 +357,13 @@ void GameRenderer::renderLevel(float a) {
|
|||||||
glEnable2(GL_ALPHA_TEST);
|
glEnable2(GL_ALPHA_TEST);
|
||||||
|
|
||||||
if (/*!Minecraft::FLYBY_MODE &&*/ zoom == 1 && cameraEntity->isPlayer()) {
|
if (/*!Minecraft::FLYBY_MODE &&*/ zoom == 1 && cameraEntity->isPlayer()) {
|
||||||
if (mc->hitResult.isHit() && !cameraEntity->isUnderLiquid(Material::water)) {
|
if (mc.hitResult.isHit() && !cameraEntity->isUnderLiquid(Material::water)) {
|
||||||
TIMER_POP_PUSH("select");
|
TIMER_POP_PUSH("select");
|
||||||
Player* player = (Player*) cameraEntity;
|
Player* player = (Player*) cameraEntity;
|
||||||
// if (mc->useTouchscreen()) {
|
// if (mc.useTouchscreen()) {
|
||||||
levelRenderer->renderHitSelect(player, mc->hitResult, 0, NULL, a); //player.inventory->getSelected(), a);
|
levelRenderer->renderHitSelect(player, mc.hitResult, 0, NULL, a); //player.inventory->getSelected(), a);
|
||||||
// }
|
// }
|
||||||
levelRenderer->renderHit(player, mc->hitResult, 0, NULL, a);//player->inventory.getSelected(), a);
|
levelRenderer->renderHit(player, mc.hitResult, 0, NULL, a);//player->inventory.getSelected(), a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,13 +375,13 @@ void GameRenderer::renderLevel(float a) {
|
|||||||
// glDisable2(GL_FOG);
|
// glDisable2(GL_FOG);
|
||||||
setupFog(1);
|
setupFog(1);
|
||||||
|
|
||||||
if (zoom == 1 && !mc->options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
if (zoom == 1 && !mc.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||||
TIMER_POP_PUSH("hand");
|
TIMER_POP_PUSH("hand");
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
renderItemInHand(a, i);
|
renderItemInHand(a, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) {
|
if (!mc.options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) {
|
||||||
TIMER_POP();
|
TIMER_POP();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -391,16 +391,16 @@ void GameRenderer::renderLevel(float a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameRenderer::tickFov() {
|
void GameRenderer::tickFov() {
|
||||||
if (mc->cameraTargetPlayer != mc->player)
|
if (mc.cameraTargetPlayer != mc.player)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
oFov = fov;
|
oFov = fov;
|
||||||
fov += (mc->player->getFieldOfViewModifier() - fov) * 0.5f;
|
fov += (mc.player->getFieldOfViewModifier() - fov) * 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private*/
|
/*private*/
|
||||||
float GameRenderer::getFov(float a, bool applyEffects) {
|
float GameRenderer::getFov(float a, bool applyEffects) {
|
||||||
Mob* player = mc->cameraTargetPlayer;
|
Mob* player = mc.cameraTargetPlayer;
|
||||||
float fov = 70;
|
float fov = 70;
|
||||||
|
|
||||||
if (applyEffects)
|
if (applyEffects)
|
||||||
@@ -417,7 +417,7 @@ float GameRenderer::getFov(float a, bool applyEffects) {
|
|||||||
|
|
||||||
/*private*/
|
/*private*/
|
||||||
void GameRenderer::moveCameraToPlayer(float a) {
|
void GameRenderer::moveCameraToPlayer(float a) {
|
||||||
Entity* player = mc->cameraTargetPlayer;
|
Entity* player = mc.cameraTargetPlayer;
|
||||||
|
|
||||||
float heightOffset = player->heightOffset - 1.62f;
|
float heightOffset = player->heightOffset - 1.62f;
|
||||||
|
|
||||||
@@ -433,10 +433,10 @@ void GameRenderer::moveCameraToPlayer(float a) {
|
|||||||
if(player->isPlayer() && ((Player*)player)->isSleeping()) {
|
if(player->isPlayer() && ((Player*)player)->isSleeping()) {
|
||||||
heightOffset += 1.0;
|
heightOffset += 1.0;
|
||||||
glTranslatef(0.0f, 0.3f, 0);
|
glTranslatef(0.0f, 0.3f, 0);
|
||||||
if (!mc->options.getBooleanValue(OPTIONS_FIXED_CAMERA)) {
|
if (!mc.options.getBooleanValue(OPTIONS_FIXED_CAMERA)) {
|
||||||
int t = mc->level->getTile(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
int t = mc.level->getTile(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
||||||
if (t == Tile::bed->id) {
|
if (t == Tile::bed->id) {
|
||||||
int data = mc->level->getData(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
int data = mc.level->getData(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
||||||
|
|
||||||
int direction = data & 3;
|
int direction = data & 3;
|
||||||
glRotatef(float(direction * 90), 0, 1, 0);
|
glRotatef(float(direction * 90), 0, 1, 0);
|
||||||
@@ -444,10 +444,10 @@ void GameRenderer::moveCameraToPlayer(float a) {
|
|||||||
glRotatef(player->yRotO + (player->yRot - player->yRotO) * a + 180, 0, -1, 0);
|
glRotatef(player->yRotO + (player->yRot - player->yRotO) * a + 180, 0, -1, 0);
|
||||||
glRotatef(player->xRotO + (player->xRot - player->xRotO) * a, -1, 0, 0);
|
glRotatef(player->xRotO + (player->xRot - player->xRotO) * a, -1, 0, 0);
|
||||||
}
|
}
|
||||||
} else if (mc->options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW)/* || (player->isPlayer() && !player->isAlive())*/) {
|
} else if (mc.options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW)/* || (player->isPlayer() && !player->isAlive())*/) {
|
||||||
float cameraDist = thirdDistanceO + (thirdDistance - thirdDistanceO) * a;
|
float cameraDist = thirdDistanceO + (thirdDistance - thirdDistanceO) * a;
|
||||||
|
|
||||||
if (mc->options.getBooleanValue(OPTIONS_FIXED_CAMERA)) {
|
if (mc.options.getBooleanValue(OPTIONS_FIXED_CAMERA)) {
|
||||||
|
|
||||||
float rotationY = thirdRotationO + (thirdRotation - thirdRotationO) * a;
|
float rotationY = thirdRotationO + (thirdRotation - thirdRotationO) * a;
|
||||||
float xRot = thirdTiltO + (thirdTilt - thirdTiltO) * a;
|
float xRot = thirdTiltO + (thirdTilt - thirdTiltO) * a;
|
||||||
@@ -471,7 +471,7 @@ void GameRenderer::moveCameraToPlayer(float a) {
|
|||||||
yo *= 0.1f;
|
yo *= 0.1f;
|
||||||
zo *= 0.1f;
|
zo *= 0.1f;
|
||||||
|
|
||||||
HitResult hr = mc->level->clip(Vec3(x + xo, y + yo, z + zo), Vec3(x - xd + xo + zo, y - yd + yo, z - zd + zo)); // newTemp
|
HitResult hr = mc.level->clip(Vec3(x + xo, y + yo, z + zo), Vec3(x - xd + xo + zo, y - yd + yo, z - zd + zo)); // newTemp
|
||||||
if (hr.type != NO_HIT) {
|
if (hr.type != NO_HIT) {
|
||||||
float dist = hr.pos.distanceTo(Vec3(x, y, z)); // newTemp
|
float dist = hr.pos.distanceTo(Vec3(x, y, z)); // newTemp
|
||||||
if (dist < cameraDist) cameraDist = dist;
|
if (dist < cameraDist) cameraDist = dist;
|
||||||
@@ -490,7 +490,7 @@ void GameRenderer::moveCameraToPlayer(float a) {
|
|||||||
glTranslatef2(0, 0, -0.1f);
|
glTranslatef2(0, 0, -0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mc->options.getBooleanValue(OPTIONS_FIXED_CAMERA)) {
|
if (!mc.options.getBooleanValue(OPTIONS_FIXED_CAMERA)) {
|
||||||
glRotatef2(player->xRotO + (player->xRot - player->xRotO) * a, 1.0f, 0.0f, 0.0f);
|
glRotatef2(player->xRotO + (player->xRot - player->xRotO) * a, 1.0f, 0.0f, 0.0f);
|
||||||
glRotatef2(player->yRotO + (player->yRot - player->yRotO) * a + 180, 0, 1, 0);
|
glRotatef2(player->yRotO + (player->yRot - player->yRotO) * a + 180, 0, 1, 0);
|
||||||
//if (_t_keepPic > 0)
|
//if (_t_keepPic > 0)
|
||||||
@@ -500,7 +500,7 @@ void GameRenderer::moveCameraToPlayer(float a) {
|
|||||||
|
|
||||||
/*private*/
|
/*private*/
|
||||||
void GameRenderer::bobHurt(float a) {
|
void GameRenderer::bobHurt(float a) {
|
||||||
Mob* player = mc->cameraTargetPlayer;
|
Mob* player = mc.cameraTargetPlayer;
|
||||||
|
|
||||||
float hurt = player->hurtTime - a;
|
float hurt = player->hurtTime - a;
|
||||||
|
|
||||||
@@ -523,11 +523,11 @@ void GameRenderer::bobHurt(float a) {
|
|||||||
|
|
||||||
/*private*/
|
/*private*/
|
||||||
void GameRenderer::bobView(float a) {
|
void GameRenderer::bobView(float a) {
|
||||||
//if (mc->options.thirdPersonView) return;
|
//if (mc.options.thirdPersonView) return;
|
||||||
if (!(mc->cameraTargetPlayer->isPlayer())) {
|
if (!(mc.cameraTargetPlayer->isPlayer())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player* player = (Player*) mc->cameraTargetPlayer;
|
Player* player = (Player*) mc.cameraTargetPlayer;
|
||||||
|
|
||||||
float wda = player->walkDist - player->walkDistO;
|
float wda = player->walkDist - player->walkDistO;
|
||||||
float b = -(player->walkDist + wda * a);
|
float b = -(player->walkDist + wda * a);
|
||||||
@@ -541,7 +541,7 @@ void GameRenderer::bobView(float a) {
|
|||||||
|
|
||||||
/*private*/
|
/*private*/
|
||||||
void GameRenderer::setupFog(int i) {
|
void GameRenderer::setupFog(int i) {
|
||||||
Mob* player = mc->cameraTargetPlayer;
|
Mob* player = mc.cameraTargetPlayer;
|
||||||
float fogBuffer[4] = {fr, fg, fb, 1};
|
float fogBuffer[4] = {fr, fg, fb, 1};
|
||||||
|
|
||||||
glFogfv(GL_FOG_COLOR, (GLfloat*)fogBuffer);
|
glFogfv(GL_FOG_COLOR, (GLfloat*)fogBuffer);
|
||||||
@@ -555,7 +555,7 @@ void GameRenderer::setupFog(int i) {
|
|||||||
// float gg = 0.4f;
|
// float gg = 0.4f;
|
||||||
// float bb = 0.9f;
|
// float bb = 0.9f;
|
||||||
//
|
//
|
||||||
// if (mc->options.anaglyph3d) {
|
// if (mc.options.anaglyph3d) {
|
||||||
// float rrr = (rr * 30 + gg * 59 + bb * 11) / 100;
|
// float rrr = (rr * 30 + gg * 59 + bb * 11) / 100;
|
||||||
// float ggg = (rr * 30 + gg * 70) / (100);
|
// float ggg = (rr * 30 + gg * 70) / (100);
|
||||||
// float bbb = (rr * 30 + bb * 70) / (100);
|
// float bbb = (rr * 30 + bb * 70) / (100);
|
||||||
@@ -571,7 +571,7 @@ void GameRenderer::setupFog(int i) {
|
|||||||
// float gg = 0.3f;
|
// float gg = 0.3f;
|
||||||
// float bb = 0.3f;
|
// float bb = 0.3f;
|
||||||
//
|
//
|
||||||
// if (mc->options.anaglyph3d) {
|
// if (mc.options.anaglyph3d) {
|
||||||
// float rrr = (rr * 30 + gg * 59 + bb * 11) / 100;
|
// float rrr = (rr * 30 + gg * 59 + bb * 11) / 100;
|
||||||
// float ggg = (rr * 30 + gg * 70) / (100);
|
// float ggg = (rr * 30 + gg * 70) / (100);
|
||||||
// float bbb = (rr * 30 + bb * 70) / (100);
|
// float bbb = (rr * 30 + bb * 70) / (100);
|
||||||
@@ -589,7 +589,7 @@ void GameRenderer::setupFog(int i) {
|
|||||||
glFogf(GL_FOG_END, renderDistance * 1.0f);
|
glFogf(GL_FOG_END, renderDistance * 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc->level->dimension->foggy) {
|
if (mc.level->dimension->foggy) {
|
||||||
glFogf(GL_FOG_START, 0);
|
glFogf(GL_FOG_START, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -599,27 +599,27 @@ void GameRenderer::setupFog(int i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameRenderer::updateAllChunks() {
|
void GameRenderer::updateAllChunks() {
|
||||||
mc->levelRenderer->updateDirtyChunks(mc->cameraTargetPlayer, true);
|
mc.levelRenderer->updateDirtyChunks(mc.cameraTargetPlayer, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameRenderer::updateFreeformPickDirection(float a, Vec3& outDir) {
|
bool GameRenderer::updateFreeformPickDirection(float a, Vec3& outDir) {
|
||||||
|
|
||||||
if (!mc->inputHolder->allowPicking()) {
|
if (!mc.inputHolder->allowPicking()) {
|
||||||
_shTicks = 1;
|
_shTicks = 1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 c = mc->cameraTargetPlayer->getPos(a);
|
Vec3 c = mc.cameraTargetPlayer->getPos(a);
|
||||||
|
|
||||||
bool firstPerson = !mc->options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW);
|
bool firstPerson = !mc.options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW);
|
||||||
const float PickingDistance = firstPerson? 6.0f : 12.0f;
|
const float PickingDistance = firstPerson? 6.0f : 12.0f;
|
||||||
|
|
||||||
_shTicks = -1;
|
_shTicks = -1;
|
||||||
|
|
||||||
int vp[4] = {0, 0, mc->width, mc->height};
|
int vp[4] = {0, 0, mc.getScreenWidth(), mc.getScreenHeight()};
|
||||||
float pt[3];
|
float pt[3];
|
||||||
float x = mc->inputHolder->mousex;
|
float x = mc.inputHolder->mousex;
|
||||||
float y = mc->height - mc->inputHolder->mousey;
|
float y = mc.getScreenHeight() - mc.inputHolder->mousey;
|
||||||
|
|
||||||
//sw.start();
|
//sw.start();
|
||||||
|
|
||||||
@@ -637,42 +637,42 @@ bool GameRenderer::updateFreeformPickDirection(float a, Vec3& outDir) {
|
|||||||
//sw.stop();
|
//sw.stop();
|
||||||
//sw.printEvery(30, "unproject ");
|
//sw.printEvery(30, "unproject ");
|
||||||
|
|
||||||
const HitResult& hit = mc->hitResult = mc->level->clip(p0, p1, false);
|
const HitResult& hit = mc.hitResult = mc.level->clip(p0, p1, false);
|
||||||
|
|
||||||
// If in 3rd person view - verify that the hit target is within range
|
// If in 3rd person view - verify that the hit target is within range
|
||||||
if (!firstPerson && hit.isHit()) {
|
if (!firstPerson && hit.isHit()) {
|
||||||
const float MaxSqrDist = PickingDistance*PickingDistance;
|
const float MaxSqrDist = PickingDistance*PickingDistance;
|
||||||
if (mc->cameraTargetPlayer->distanceToSqr((float)hit.x, (float)hit.y, (float)hit.z) > MaxSqrDist)
|
if (mc.cameraTargetPlayer->distanceToSqr((float)hit.x, (float)hit.y, (float)hit.z) > MaxSqrDist)
|
||||||
mc->hitResult.type = NO_HIT;
|
mc.hitResult.type = NO_HIT;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public*/
|
/*public*/
|
||||||
void GameRenderer::pick(float a) {
|
void GameRenderer::pick(float a) {
|
||||||
if (mc->level == NULL) return;
|
if (mc.level == NULL) return;
|
||||||
if (mc->cameraTargetPlayer == NULL) return;
|
if (mc.cameraTargetPlayer == NULL) return;
|
||||||
if (!mc->cameraTargetPlayer->isAlive()) return;
|
if (!mc.cameraTargetPlayer->isAlive()) return;
|
||||||
|
|
||||||
float range = mc->gameMode->getPickRange();
|
float range = mc.gameMode->getPickRange();
|
||||||
bool isPicking = true;
|
bool isPicking = true;
|
||||||
|
|
||||||
bool freeform = mc->useTouchscreen(); //&& !mc->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA);
|
bool freeform = mc.useTouchscreen(); //&& !mc.options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA);
|
||||||
|
|
||||||
if (freeform) {
|
if (freeform) {
|
||||||
isPicking = updateFreeformPickDirection(a, pickDirection);
|
isPicking = updateFreeformPickDirection(a, pickDirection);
|
||||||
} else {
|
} else {
|
||||||
mc->hitResult = mc->cameraTargetPlayer->pick(range, a);
|
mc.hitResult = mc.cameraTargetPlayer->pick(range, a);
|
||||||
pickDirection = mc->cameraTargetPlayer->getViewVector(a);
|
pickDirection = mc.cameraTargetPlayer->getViewVector(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 from = mc->cameraTargetPlayer->getPos(a);
|
Vec3 from = mc.cameraTargetPlayer->getPos(a);
|
||||||
float dist = range;
|
float dist = range;
|
||||||
if (mc->hitResult.isHit()) {
|
if (mc.hitResult.isHit()) {
|
||||||
dist = mc->hitResult.pos.distanceTo(from);
|
dist = mc.hitResult.pos.distanceTo(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc->gameMode->isCreativeType()) {
|
if (mc.gameMode->isCreativeType()) {
|
||||||
/*dist =*/ range = 12;
|
/*dist =*/ range = 12;
|
||||||
} else {
|
} else {
|
||||||
if (dist > 3) dist = 3;
|
if (dist > 3) dist = 3;
|
||||||
@@ -681,12 +681,12 @@ void GameRenderer::pick(float a) {
|
|||||||
|
|
||||||
Vec3 pv = (pickDirection * range);
|
Vec3 pv = (pickDirection * range);
|
||||||
Vec3 to = from + pv;
|
Vec3 to = from + pv;
|
||||||
mc->cameraTargetPlayer->aimDirection = pickDirection;
|
mc.cameraTargetPlayer->aimDirection = pickDirection;
|
||||||
|
|
||||||
Entity* hovered = NULL;
|
Entity* hovered = NULL;
|
||||||
const float g = 1;
|
const float g = 1;
|
||||||
AABB aabb = mc->cameraTargetPlayer->bb.expand(pv.x, pv.y, pv.z).grow(g, g, g);
|
AABB aabb = mc.cameraTargetPlayer->bb.expand(pv.x, pv.y, pv.z).grow(g, g, g);
|
||||||
EntityList& objects = mc->level->getEntities(mc->cameraTargetPlayer, aabb);
|
EntityList& objects = mc.level->getEntities(mc.cameraTargetPlayer, aabb);
|
||||||
float nearest = 0;
|
float nearest = 0;
|
||||||
for (unsigned int i = 0; i < objects.size(); i++) {
|
for (unsigned int i = 0; i < objects.size(); i++) {
|
||||||
Entity* e = objects[i];
|
Entity* e = objects[i];
|
||||||
@@ -714,26 +714,26 @@ void GameRenderer::pick(float a) {
|
|||||||
|
|
||||||
if (hovered != NULL) {
|
if (hovered != NULL) {
|
||||||
if(nearest < dist) {
|
if(nearest < dist) {
|
||||||
mc->hitResult = HitResult(hovered);
|
mc.hitResult = HitResult(hovered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isPicking && !mc->hitResult.isHit()) {
|
else if (isPicking && !mc.hitResult.isHit()) {
|
||||||
// if we don't have a hit result, attempt to hit the edge of the block we are standing on
|
// if we don't have a hit result, attempt to hit the edge of the block we are standing on
|
||||||
// (this is an pocket edition simplification to help building floors)
|
// (this is an pocket edition simplification to help building floors)
|
||||||
//LOGI("hovered : %d (%f)\n", mc->hitResult.type, viewVec.y);
|
//LOGI("hovered : %d (%f)\n", mc.hitResult.type, viewVec.y);
|
||||||
if (pickDirection.y < -.7f) {
|
if (pickDirection.y < -.7f) {
|
||||||
// looking down by more than roughly 45 degrees, fetch a hit to the block standing on
|
// looking down by more than roughly 45 degrees, fetch a hit to the block standing on
|
||||||
Vec3 to = from.add(0, -2.0f, 0);
|
Vec3 to = from.add(0, -2.0f, 0);
|
||||||
|
|
||||||
HitResult downHitResult = mc->level->clip(from, to);
|
HitResult downHitResult = mc.level->clip(from, to);
|
||||||
if (downHitResult.isHit()) {
|
if (downHitResult.isHit()) {
|
||||||
mc->hitResult = downHitResult;
|
mc.hitResult = downHitResult;
|
||||||
mc->hitResult.indirectHit = true;
|
mc.hitResult.indirectHit = true;
|
||||||
// change face (not up)
|
// change face (not up)
|
||||||
if (std::abs(pickDirection.x) > std::abs(pickDirection.z)) {
|
if (std::abs(pickDirection.x) > std::abs(pickDirection.z)) {
|
||||||
mc->hitResult.f = (pickDirection.x < 0)? 4 : 5;
|
mc.hitResult.f = (pickDirection.x < 0)? 4 : 5;
|
||||||
} else {
|
} else {
|
||||||
mc->hitResult.f = (pickDirection.z < 0)? 2 : 3;
|
mc.hitResult.f = (pickDirection.z < 0)? 2 : 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -743,13 +743,13 @@ void GameRenderer::pick(float a) {
|
|||||||
void GameRenderer::tick(int nTick, int maxTick) {
|
void GameRenderer::tick(int nTick, int maxTick) {
|
||||||
--_t_keepPic;
|
--_t_keepPic;
|
||||||
|
|
||||||
if (!mc->player)
|
if (!mc.player)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (--_shTicks == 0)
|
if (--_shTicks == 0)
|
||||||
mc->hitResult.type = NO_HIT;
|
mc.hitResult.type = NO_HIT;
|
||||||
|
|
||||||
//_rotXlast = _rotX;
|
//_rotXlast = _rotX;
|
||||||
//_rotYlast = _rotY;
|
//_rotYlast = _rotY;
|
||||||
@@ -775,35 +775,35 @@ void GameRenderer::tick(int nTick, int maxTick) {
|
|||||||
fovOffsetO = fovOffset;
|
fovOffsetO = fovOffset;
|
||||||
cameraRollO = cameraRoll;
|
cameraRollO = cameraRoll;
|
||||||
|
|
||||||
if (mc->cameraTargetPlayer == NULL) {
|
if (mc.cameraTargetPlayer == NULL) {
|
||||||
mc->cameraTargetPlayer = mc->player;
|
mc.cameraTargetPlayer = mc.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
tickFov();
|
tickFov();
|
||||||
|
|
||||||
float brr = mc->level->getBrightness( Mth::floor(mc->cameraTargetPlayer->x),
|
float brr = mc.level->getBrightness( Mth::floor(mc.cameraTargetPlayer->x),
|
||||||
Mth::floor(mc->cameraTargetPlayer->y),
|
Mth::floor(mc.cameraTargetPlayer->y),
|
||||||
Mth::floor(mc->cameraTargetPlayer->z));
|
Mth::floor(mc.cameraTargetPlayer->z));
|
||||||
|
|
||||||
float whiteness = (3 - mc->options.getIntValue(OPTIONS_VIEW_DISTANCE)) / 3.0f;
|
float whiteness = (3 - mc.options.getIntValue(OPTIONS_VIEW_DISTANCE)) / 3.0f;
|
||||||
float fogBrT = brr * (1 - whiteness) + whiteness;
|
float fogBrT = brr * (1 - whiteness) + whiteness;
|
||||||
fogBr += (fogBrT - fogBr) * 0.1f;
|
fogBr += (fogBrT - fogBr) * 0.1f;
|
||||||
|
|
||||||
_tick++;
|
_tick++;
|
||||||
|
|
||||||
itemInHandRenderer->tick();
|
itemInHandRenderer->tick();
|
||||||
// if (mc->isRaining) tickRain();
|
// if (mc.isRaining) tickRain();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private*/
|
/*private*/
|
||||||
void GameRenderer::setupClearColor(float a) {
|
void GameRenderer::setupClearColor(float a) {
|
||||||
Level* level = mc->level;
|
Level* level = mc.level;
|
||||||
Mob* player = mc->cameraTargetPlayer;
|
Mob* player = mc.cameraTargetPlayer;
|
||||||
|
|
||||||
float whiteness = 1.0f / (4 - mc->options.getIntValue(OPTIONS_VIEW_DISTANCE));
|
float whiteness = 1.0f / (4 - mc.options.getIntValue(OPTIONS_VIEW_DISTANCE));
|
||||||
whiteness = 1 - (float) pow(whiteness, 0.25f);
|
whiteness = 1 - (float) pow(whiteness, 0.25f);
|
||||||
|
|
||||||
Vec3 skyColor = level->getSkyColor(mc->cameraTargetPlayer, a);
|
Vec3 skyColor = level->getSkyColor(mc.cameraTargetPlayer, a);
|
||||||
float sr = (float) skyColor.x;
|
float sr = (float) skyColor.x;
|
||||||
float sg = (float) skyColor.y;
|
float sg = (float) skyColor.y;
|
||||||
float sb = (float) skyColor.z;
|
float sb = (float) skyColor.z;
|
||||||
@@ -832,7 +832,7 @@ void GameRenderer::setupClearColor(float a) {
|
|||||||
fg *= brr;
|
fg *= brr;
|
||||||
fb *= brr;
|
fb *= brr;
|
||||||
|
|
||||||
if (mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) {
|
if (mc.options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) {
|
||||||
float frr = (fr * 30 + fg * 59 + fb * 11) / 100;
|
float frr = (fr * 30 + fg * 59 + fb * 11) / 100;
|
||||||
float fgg = (fr * 30 + fg * 70) / (100);
|
float fgg = (fr * 30 + fg * 70) / (100);
|
||||||
float fbb = (fr * 30 + fb * 70) / (100);
|
float fbb = (fr * 30 + fb * 70) / (100);
|
||||||
@@ -859,8 +859,8 @@ void GameRenderer::unZoomRegion()
|
|||||||
|
|
||||||
void GameRenderer::setupGuiScreen( bool clearColorBuffer )
|
void GameRenderer::setupGuiScreen( bool clearColorBuffer )
|
||||||
{
|
{
|
||||||
int screenWidth = (int)(mc->width * Gui::InvGuiScale);
|
int screenWidth = (int)(mc.getScreenWidth() * Gui::InvGuiScale);
|
||||||
int screenHeight = (int)(mc->height * Gui::InvGuiScale);
|
int screenHeight = (int)(mc.getScreenHeight() * Gui::InvGuiScale);
|
||||||
|
|
||||||
// Setup GUI render mode
|
// Setup GUI render mode
|
||||||
GLbitfield clearBits = clearColorBuffer?
|
GLbitfield clearBits = clearColorBuffer?
|
||||||
@@ -878,19 +878,19 @@ void GameRenderer::setupGuiScreen( bool clearColorBuffer )
|
|||||||
/*private*/
|
/*private*/
|
||||||
void GameRenderer::renderItemInHand(float a, int eye) {
|
void GameRenderer::renderItemInHand(float a, int eye) {
|
||||||
glLoadIdentity2();
|
glLoadIdentity2();
|
||||||
if (mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) glTranslatef2((eye * 2 - 1) * 0.10f, 0, 0);
|
if (mc.options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) glTranslatef2((eye * 2 - 1) * 0.10f, 0, 0);
|
||||||
|
|
||||||
glPushMatrix2();
|
glPushMatrix2();
|
||||||
bobHurt(a);
|
bobHurt(a);
|
||||||
if (mc->options.getBooleanValue(OPTIONS_VIEW_BOBBING)) bobView(a);
|
if (mc.options.getBooleanValue(OPTIONS_VIEW_BOBBING)) bobView(a);
|
||||||
|
|
||||||
if (!mc->options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW) && (mc->cameraTargetPlayer->isPlayer() && !((Player*)mc->cameraTargetPlayer)->isSleeping())) {
|
if (!mc.options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW) && (mc.cameraTargetPlayer->isPlayer() && !((Player*)mc.cameraTargetPlayer)->isSleeping())) {
|
||||||
if (!mc->options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
if (!mc.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||||
float fov = getFov(a, false);
|
float fov = getFov(a, false);
|
||||||
if (fov != _setupCameraFov) {
|
if (fov != _setupCameraFov) {
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(fov, mc->width / (float) mc->height, 0.05f, renderDistance);
|
gluPerspective(fov, mc.getScreenWidth() / (float) mc.getScreenHeight(), 0.05f, renderDistance);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
}
|
}
|
||||||
itemInHandRenderer->render(a);
|
itemInHandRenderer->render(a);
|
||||||
@@ -898,11 +898,11 @@ void GameRenderer::renderItemInHand(float a, int eye) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
glPopMatrix2();
|
glPopMatrix2();
|
||||||
if (!mc->options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW) && (mc->cameraTargetPlayer->isPlayer() && !((Player*)mc->cameraTargetPlayer)->isSleeping())) {
|
if (!mc.options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW) && (mc.cameraTargetPlayer->isPlayer() && !((Player*)mc.cameraTargetPlayer)->isSleeping())) {
|
||||||
itemInHandRenderer->renderScreenEffect(a);
|
itemInHandRenderer->renderScreenEffect(a);
|
||||||
bobHurt(a);
|
bobHurt(a);
|
||||||
}
|
}
|
||||||
if (mc->options.getBooleanValue(OPTIONS_VIEW_BOBBING)) bobView(a);
|
if (mc.options.getBooleanValue(OPTIONS_VIEW_BOBBING)) bobView(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameRenderer::onGraphicsReset()
|
void GameRenderer::onGraphicsReset()
|
||||||
@@ -926,12 +926,12 @@ void GameRenderer::saveMatrices()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameRenderer::prepareAndRenderClouds( LevelRenderer* levelRenderer, float a ) {
|
void GameRenderer::prepareAndRenderClouds( LevelRenderer* levelRenderer, float a ) {
|
||||||
//if(mc->options.isCloudsOn()) {
|
//if(mc.options.isCloudsOn()) {
|
||||||
TIMER_PUSH("clouds");
|
TIMER_PUSH("clouds");
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPushMatrix2();
|
glPushMatrix2();
|
||||||
glLoadIdentity2();
|
glLoadIdentity2();
|
||||||
gluPerspective(_setupCameraFov = getFov(a, true), mc->width / (float) mc->height, 2, renderDistance * 512);
|
gluPerspective(_setupCameraFov = getFov(a, true), mc.getScreenWidth() / (float) mc.getScreenHeight(), 2, renderDistance * 512);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix2();
|
glPushMatrix2();
|
||||||
setupFog(0);
|
setupFog(0);
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
#include "world/phys/Vec3.hpp"
|
#include "world/phys/Vec3.hpp"
|
||||||
#include "client/gui/components/ImageButton.hpp"
|
#include "client/gui/components/ImageButton.hpp"
|
||||||
|
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
class Entity;
|
class Entity;
|
||||||
class ItemInHandRenderer;
|
class ItemInHandRenderer;
|
||||||
class LevelRenderer;
|
class LevelRenderer;
|
||||||
class GameRenderer
|
class GameRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GameRenderer(Minecraft* mc_);
|
GameRenderer(MinecraftClient& mc_);
|
||||||
~GameRenderer();
|
~GameRenderer();
|
||||||
|
|
||||||
void pick(float a);
|
void pick(float a);
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
ItemInHandRenderer* itemInHandRenderer;
|
ItemInHandRenderer* itemInHandRenderer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Minecraft* mc;
|
MinecraftClient& mc;
|
||||||
|
|
||||||
float renderDistance;
|
float renderDistance;
|
||||||
int _tick;
|
int _tick;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
//static StopwatchHandler handler;
|
//static StopwatchHandler handler;
|
||||||
|
|
||||||
ItemInHandRenderer::ItemInHandRenderer( Minecraft* mc )
|
ItemInHandRenderer::ItemInHandRenderer( MinecraftClient& mc )
|
||||||
: mc(mc),
|
: mc(mc),
|
||||||
lastSlot(-1),
|
lastSlot(-1),
|
||||||
height(0),
|
height(0),
|
||||||
@@ -51,7 +51,7 @@ void ItemInHandRenderer::tick()
|
|||||||
oHeight = height;
|
oHeight = height;
|
||||||
item.id = 0;
|
item.id = 0;
|
||||||
|
|
||||||
ItemInstance* itemInHand = mc->player->inventory->getSelected();
|
ItemInstance* itemInHand = mc.player->inventory->getSelected();
|
||||||
if (itemInHand && itemInHand->count > 0) {
|
if (itemInHand && itemInHand->count > 0) {
|
||||||
item.id = itemInHand->id;
|
item.id = itemInHand->id;
|
||||||
item.setAuxValue(itemInHand->getAuxValue());
|
item.setAuxValue(itemInHand->getAuxValue());
|
||||||
@@ -122,10 +122,10 @@ void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
|||||||
|
|
||||||
if (item->id < 256) {
|
if (item->id < 256) {
|
||||||
renderObject.texture = "terrain.png";
|
renderObject.texture = "terrain.png";
|
||||||
//mc->textures->loadAndBindTexture("terrain.png");
|
//mc.textures().loadAndBindTexture("terrain.png");
|
||||||
} else {
|
} else {
|
||||||
renderObject.texture = "gui/items.png";
|
renderObject.texture = "gui/items.png";
|
||||||
//mc->textures->loadAndBindTexture("gui/items.png");
|
//mc.textures().loadAndBindTexture("gui/items.png");
|
||||||
}
|
}
|
||||||
// glDisable2(GL_LIGHTING);
|
// glDisable2(GL_LIGHTING);
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
@@ -217,7 +217,7 @@ void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
|||||||
glRotatef2(45 + 290, 0, 0, 1);
|
glRotatef2(45 + 290, 0, 0, 1);
|
||||||
glTranslatef2(-15 / 16.0f, -1 / 16.0f, 0);
|
glTranslatef2(-15 / 16.0f, -1 / 16.0f, 0);
|
||||||
}
|
}
|
||||||
mc->textures->loadAndBindTexture(renderObject.texture);
|
mc.textures().loadAndBindTexture(renderObject.texture);
|
||||||
|
|
||||||
drawArrayVT_NoState(renderObject.chunk.vboId, renderObject.chunk.vertexCount);
|
drawArrayVT_NoState(renderObject.chunk.vboId, renderObject.chunk.vertexCount);
|
||||||
if (renderObject.isFlat)
|
if (renderObject.isFlat)
|
||||||
@@ -235,7 +235,7 @@ void ItemInHandRenderer::render( float a )
|
|||||||
//w.start();
|
//w.start();
|
||||||
|
|
||||||
float h = oHeight + (height - oHeight) * a;
|
float h = oHeight + (height - oHeight) * a;
|
||||||
Player* player = mc->player;
|
Player* player = mc.player;
|
||||||
// if (selectedTile==NULL) return;
|
// if (selectedTile==NULL) return;
|
||||||
|
|
||||||
glPushMatrix2();
|
glPushMatrix2();
|
||||||
@@ -243,7 +243,7 @@ void ItemInHandRenderer::render( float a )
|
|||||||
glRotatef2(player->yRotO + (player->yRot - player->yRotO) * a, 0, 1, 0);
|
glRotatef2(player->yRotO + (player->yRot - player->yRotO) * a, 0, 1, 0);
|
||||||
glPopMatrix2();
|
glPopMatrix2();
|
||||||
|
|
||||||
float br = mc->level->getBrightness(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
float br = mc.level->getBrightness(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
||||||
|
|
||||||
ItemInstance* item;// = selectedItem;
|
ItemInstance* item;// = selectedItem;
|
||||||
//if (player.fishing != NULL) {
|
//if (player.fishing != NULL) {
|
||||||
@@ -354,7 +354,7 @@ void ItemInHandRenderer::render( float a )
|
|||||||
glRotatef2(-swing3 * 20, 0, 0, 1);
|
glRotatef2(-swing3 * 20, 0, 0, 1);
|
||||||
// glRotatef2(-swing2 * 80, 1, 0, 0);
|
// glRotatef2(-swing2 * 80, 1, 0, 0);
|
||||||
|
|
||||||
mc->textures->loadAndBindTexture(player->getTexture());
|
mc.textures().loadAndBindTexture(player->getTexture());
|
||||||
glTranslatef2(-1.0f, +3.6f, +3.5f);
|
glTranslatef2(-1.0f, +3.6f, +3.5f);
|
||||||
glRotatef2(120, 0, 0, 1);
|
glRotatef2(120, 0, 0, 1);
|
||||||
glRotatef2(180 + 20, 1, 0, 0);
|
glRotatef2(180 + 20, 1, 0, 0);
|
||||||
@@ -362,7 +362,7 @@ void ItemInHandRenderer::render( float a )
|
|||||||
glScalef2(1.5f / 24.0f * 16, 1.5f / 24.0f * 16, 1.5f / 24.0f * 16);
|
glScalef2(1.5f / 24.0f * 16, 1.5f / 24.0f * 16, 1.5f / 24.0f * 16);
|
||||||
glTranslatef2(5.6f, 0, 0);
|
glTranslatef2(5.6f, 0, 0);
|
||||||
|
|
||||||
EntityRenderer* er = EntityRenderDispatcher::getInstance()->getRenderer(mc->player);
|
EntityRenderer* er = EntityRenderDispatcher::getInstance()->getRenderer(mc.player);
|
||||||
HumanoidMobRenderer* playerRenderer = (HumanoidMobRenderer*) er;
|
HumanoidMobRenderer* playerRenderer = (HumanoidMobRenderer*) er;
|
||||||
float ss = 1;
|
float ss = 1;
|
||||||
glScalef2(ss, ss, ss);
|
glScalef2(ss, ss, ss);
|
||||||
@@ -377,26 +377,26 @@ void ItemInHandRenderer::render( float a )
|
|||||||
void ItemInHandRenderer::renderScreenEffect( float a )
|
void ItemInHandRenderer::renderScreenEffect( float a )
|
||||||
{
|
{
|
||||||
glDisable2(GL_ALPHA_TEST);
|
glDisable2(GL_ALPHA_TEST);
|
||||||
if (mc->player->isOnFire()) {
|
if (mc.player->isOnFire()) {
|
||||||
mc->textures->loadAndBindTexture("terrain.png");
|
mc.textures().loadAndBindTexture("terrain.png");
|
||||||
renderFire(a);
|
renderFire(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc->player->isInWall()) // Inside a tile
|
if (mc.player->isInWall()) // Inside a tile
|
||||||
{
|
{
|
||||||
int x = Mth::floor(mc->player->x);
|
int x = Mth::floor(mc.player->x);
|
||||||
int y = Mth::floor(mc->player->y);
|
int y = Mth::floor(mc.player->y);
|
||||||
int z = Mth::floor(mc->player->z);
|
int z = Mth::floor(mc.player->z);
|
||||||
|
|
||||||
mc->textures->loadAndBindTexture("terrain.png");
|
mc.textures().loadAndBindTexture("terrain.png");
|
||||||
int tile = mc->level->getTile(x, y, z);
|
int tile = mc.level->getTile(x, y, z);
|
||||||
if (Tile::tiles[tile] != NULL) {
|
if (Tile::tiles[tile] != NULL) {
|
||||||
renderTex(a, Tile::tiles[tile]->getTexture(2));
|
renderTex(a, Tile::tiles[tile]->getTexture(2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (mc->player->isUnderLiquid(Material::water)) {
|
// if (mc.player->isUnderLiquid(Material::water)) {
|
||||||
//mc->textures->loadAndBindTexture("misc/water.png");
|
//mc.textures().loadAndBindTexture("misc/water.png");
|
||||||
// renderWater(a);
|
// renderWater(a);
|
||||||
// }
|
// }
|
||||||
glEnable2(GL_ALPHA_TEST);
|
glEnable2(GL_ALPHA_TEST);
|
||||||
@@ -416,7 +416,7 @@ void ItemInHandRenderer::renderTex( float a, int tex )
|
|||||||
{
|
{
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
|
|
||||||
float br;// = mc->player->getBrightness(a);
|
float br;// = mc.player->getBrightness(a);
|
||||||
br = 0.1f;
|
br = 0.1f;
|
||||||
glColor4f2(br, br, br, 0.5f);
|
glColor4f2(br, br, br, 0.5f);
|
||||||
|
|
||||||
@@ -450,7 +450,7 @@ void ItemInHandRenderer::renderWater( float a )
|
|||||||
{
|
{
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
|
|
||||||
float br = mc->player->getBrightness(a);
|
float br = mc.player->getBrightness(a);
|
||||||
glColor4f2(br, br, br, 0.5f);
|
glColor4f2(br, br, br, 0.5f);
|
||||||
glEnable2(GL_BLEND);
|
glEnable2(GL_BLEND);
|
||||||
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
@@ -465,8 +465,8 @@ void ItemInHandRenderer::renderWater( float a )
|
|||||||
float y1 = +1;
|
float y1 = +1;
|
||||||
float z0 = -0.5f;
|
float z0 = -0.5f;
|
||||||
|
|
||||||
float uo = -mc->player->yRot / 64.0f;
|
float uo = -mc.player->yRot / 64.0f;
|
||||||
float vo = +mc->player->xRot / 64.0f;
|
float vo = +mc.player->xRot / 64.0f;
|
||||||
|
|
||||||
t.begin();
|
t.begin();
|
||||||
t.vertexUV(x0, y0, z0, size + uo, size + vo);
|
t.vertexUV(x0, y0, z0, size + uo, size + vo);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "client/renderer/RenderChunk.hpp"
|
#include "client/renderer/RenderChunk.hpp"
|
||||||
#include "world/item/ItemInstance.hpp"
|
#include "world/item/ItemInstance.hpp"
|
||||||
|
|
||||||
class Minecraft;
|
class MinecraftClient;
|
||||||
|
|
||||||
typedef struct RenderCall {
|
typedef struct RenderCall {
|
||||||
int itemId;
|
int itemId;
|
||||||
@@ -19,7 +19,7 @@ typedef struct RenderCall {
|
|||||||
class ItemInHandRenderer
|
class ItemInHandRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ItemInHandRenderer(Minecraft* mc);
|
ItemInHandRenderer(MinecraftClient& mc);
|
||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ private:
|
|||||||
int lastSlot;
|
int lastSlot;
|
||||||
ItemInstance item;
|
ItemInstance item;
|
||||||
|
|
||||||
Minecraft* mc;
|
MinecraftClient& mc;
|
||||||
//ItemInstance* selectedItem;
|
//ItemInstance* selectedItem;
|
||||||
float height;
|
float height;
|
||||||
float oHeight;
|
float oHeight;
|
||||||
|
|||||||
@@ -31,9 +31,9 @@
|
|||||||
/* static */ const int LevelRenderer::CHUNK_SIZE = 16;
|
/* static */ const int LevelRenderer::CHUNK_SIZE = 16;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LevelRenderer::LevelRenderer( Minecraft* mc)
|
LevelRenderer::LevelRenderer( MinecraftClient& mc)
|
||||||
: mc(mc),
|
: mc(mc),
|
||||||
textures(mc->textures),
|
textures(mc.textures()),
|
||||||
level(NULL),
|
level(NULL),
|
||||||
cullStep(0),
|
cullStep(0),
|
||||||
|
|
||||||
@@ -149,16 +149,16 @@ void LevelRenderer::allChanged()
|
|||||||
{
|
{
|
||||||
deleteChunks();
|
deleteChunks();
|
||||||
|
|
||||||
bool fancy = mc->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS);
|
bool fancy = mc.options.getBooleanValue(OPTIONS_FANCY_GRAPHICS);
|
||||||
|
|
||||||
Tile::leaves->setFancy(fancy);
|
Tile::leaves->setFancy(fancy);
|
||||||
Tile::leaves_carried->setFancy(fancy);
|
Tile::leaves_carried->setFancy(fancy);
|
||||||
lastViewDistance = mc->options.getIntValue(OPTIONS_VIEW_DISTANCE);
|
lastViewDistance = mc.options.getIntValue(OPTIONS_VIEW_DISTANCE);
|
||||||
|
|
||||||
int dist = (512 >> 3) << (3 - lastViewDistance);
|
int dist = (512 >> 3) << (3 - lastViewDistance);
|
||||||
if (lastViewDistance <= 2 && mc->isPowerVR())
|
if (lastViewDistance <= 2 && mc.isPowerVR())
|
||||||
dist = (int)((float)dist * 0.8f);
|
dist = (int)((float)dist * 0.8f);
|
||||||
LOGI("last: %d, power: %d\n", lastViewDistance, mc->isPowerVR());
|
LOGI("last: %d, power: %d\n", lastViewDistance, mc.isPowerVR());
|
||||||
|
|
||||||
#if defined(RPI)
|
#if defined(RPI)
|
||||||
dist *= 0.6f;
|
dist *= 0.6f;
|
||||||
@@ -214,7 +214,7 @@ void LevelRenderer::allChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (level != NULL) {
|
if (level != NULL) {
|
||||||
Entity* player = mc->cameraTargetPlayer;
|
Entity* player = mc.cameraTargetPlayer;
|
||||||
if (player != NULL) {
|
if (player != NULL) {
|
||||||
this->resortChunks(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
this->resortChunks(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
||||||
DistanceChunkSorter distanceSorter(player);
|
DistanceChunkSorter distanceSorter(player);
|
||||||
@@ -297,7 +297,7 @@ void LevelRenderer::resortChunks( int xc, int yc, int zc )
|
|||||||
|
|
||||||
int LevelRenderer::render( Mob* player, int layer, float alpha )
|
int LevelRenderer::render( Mob* player, int layer, float alpha )
|
||||||
{
|
{
|
||||||
if (mc->options.getIntValue(OPTIONS_VIEW_DISTANCE) != lastViewDistance) {
|
if (mc.options.getIntValue(OPTIONS_VIEW_DISTANCE) != lastViewDistance) {
|
||||||
allChanged();
|
allChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +336,7 @@ int LevelRenderer::render( Mob* player, int layer, float alpha )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (occlusionCheck && !mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D) && layer == 0) {
|
if (occlusionCheck && !mc.options.getBooleanValue(OPTIONS_ANAGLYPH_3D) && layer == 0) {
|
||||||
int from = 0;
|
int from = 0;
|
||||||
int to = 16;
|
int to = 16;
|
||||||
//checkQueryResults(from, to);
|
//checkQueryResults(from, to);
|
||||||
@@ -439,7 +439,7 @@ void LevelRenderer::renderDebug(const AABB& b, float a) const {
|
|||||||
t.begin();
|
t.begin();
|
||||||
t.color(255, 255, 255, 255);
|
t.color(255, 255, 255, 255);
|
||||||
|
|
||||||
t.offset(((Mob*)mc->player)->getPos(a).negated());
|
t.offset(((Mob*)mc.player)->getPos(a).negated());
|
||||||
|
|
||||||
// up
|
// up
|
||||||
t.vertexUV(x0, y0, z1, u0, v1);
|
t.vertexUV(x0, y0, z1, u0, v1);
|
||||||
@@ -495,7 +495,7 @@ void LevelRenderer::render(const AABB& b) const
|
|||||||
//t.begin();
|
//t.begin();
|
||||||
t.color(255, 255, 255, 255);
|
t.color(255, 255, 255, 255);
|
||||||
|
|
||||||
t.offset(((Mob*)mc->player)->getPos(0).negated());
|
t.offset(((Mob*)mc.player)->getPos(0).negated());
|
||||||
|
|
||||||
t.begin(GL_LINE_STRIP);
|
t.begin(GL_LINE_STRIP);
|
||||||
t.vertex(b.x0, b.y0, b.z0);
|
t.vertex(b.x0, b.y0, b.z0);
|
||||||
@@ -558,7 +558,7 @@ int LevelRenderer::renderChunks( int from, int to, int layer, float alpha )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Mob* player = mc->cameraTargetPlayer;
|
Mob* player = mc.cameraTargetPlayer;
|
||||||
float xOff = player->xOld + (player->x - player->xOld) * alpha;
|
float xOff = player->xOld + (player->x - player->xOld) * alpha;
|
||||||
float yOff = player->yOld + (player->y - player->yOld) * alpha;
|
float yOff = player->yOld + (player->y - player->yOld) * alpha;
|
||||||
float zOff = player->zOld + (player->z - player->zOld) * alpha;
|
float zOff = player->zOld + (player->z - player->zOld) * alpha;
|
||||||
@@ -917,14 +917,14 @@ void LevelRenderer::renderEntities(Vec3 cam, Culler* culler, float a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TIMER_PUSH("prepare");
|
TIMER_PUSH("prepare");
|
||||||
TileEntityRenderDispatcher::getInstance()->prepare(level, textures, mc->font, mc->cameraTargetPlayer, a);
|
TileEntityRenderDispatcher::getInstance()->prepare(level, textures, mc.getFont(), mc.cameraTargetPlayer, a);
|
||||||
EntityRenderDispatcher::getInstance()->prepare(level, mc->font, mc->cameraTargetPlayer, &mc->options, a);
|
EntityRenderDispatcher::getInstance()->prepare(level, mc.getFont(), mc.cameraTargetPlayer, &mc.options, a);
|
||||||
|
|
||||||
totalEntities = 0;
|
totalEntities = 0;
|
||||||
renderedEntities = 0;
|
renderedEntities = 0;
|
||||||
culledEntities = 0;
|
culledEntities = 0;
|
||||||
|
|
||||||
Entity* player = mc->cameraTargetPlayer;
|
Entity* player = mc.cameraTargetPlayer;
|
||||||
EntityRenderDispatcher::xOff = TileEntityRenderDispatcher::xOff = (player->xOld + (player->x - player->xOld) * a);
|
EntityRenderDispatcher::xOff = TileEntityRenderDispatcher::xOff = (player->xOld + (player->x - player->xOld) * a);
|
||||||
EntityRenderDispatcher::yOff = TileEntityRenderDispatcher::yOff = (player->yOld + (player->y - player->yOld) * a);
|
EntityRenderDispatcher::yOff = TileEntityRenderDispatcher::yOff = (player->yOld + (player->y - player->yOld) * a);
|
||||||
EntityRenderDispatcher::zOff = TileEntityRenderDispatcher::zOff = (player->zOld + (player->z - player->zOld) * a);
|
EntityRenderDispatcher::zOff = TileEntityRenderDispatcher::zOff = (player->zOld + (player->z - player->zOld) * a);
|
||||||
@@ -940,12 +940,12 @@ void LevelRenderer::renderEntities(Vec3 cam, Culler* culler, float a) {
|
|||||||
for (int i = 0; i < totalEntities; i++) {
|
for (int i = 0; i < totalEntities; i++) {
|
||||||
Entity* entity = entities[i];
|
Entity* entity = entities[i];
|
||||||
|
|
||||||
bool thirdPerson = mc->options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW);
|
bool thirdPerson = mc.options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW);
|
||||||
|
|
||||||
if (entity->shouldRender(cam) && culler->isVisible(entity->bb))
|
if (entity->shouldRender(cam) && culler->isVisible(entity->bb))
|
||||||
{
|
{
|
||||||
if (entity == mc->cameraTargetPlayer && thirdPerson == 0 && mc->cameraTargetPlayer->isPlayer() && !((Player*)mc->cameraTargetPlayer)->isSleeping()) continue;
|
if (entity == mc.cameraTargetPlayer && thirdPerson == 0 && mc.cameraTargetPlayer->isPlayer() && !((Player*)mc.cameraTargetPlayer)->isSleeping()) continue;
|
||||||
if (entity == mc->cameraTargetPlayer && !thirdPerson)
|
if (entity == mc.cameraTargetPlayer && !thirdPerson)
|
||||||
continue;
|
continue;
|
||||||
if (!level->hasChunkAt(Mth::floor(entity->x), Mth::floor(entity->y), Mth::floor(entity->z)))
|
if (!level->hasChunkAt(Mth::floor(entity->x), Mth::floor(entity->y), Mth::floor(entity->z)))
|
||||||
continue;
|
continue;
|
||||||
@@ -992,15 +992,15 @@ std::string LevelRenderer::gatherStats1() {
|
|||||||
// IntBuffer resultBuffer = MemoryTracker.createIntBuffer(64);
|
// IntBuffer resultBuffer = MemoryTracker.createIntBuffer(64);
|
||||||
|
|
||||||
void LevelRenderer::renderSky(float alpha) {
|
void LevelRenderer::renderSky(float alpha) {
|
||||||
if (mc->level->dimension->foggy) return;
|
if (mc.level->dimension->foggy) return;
|
||||||
|
|
||||||
glDisable2(GL_TEXTURE_2D);
|
glDisable2(GL_TEXTURE_2D);
|
||||||
Vec3 sc = level->getSkyColor(mc->cameraTargetPlayer, alpha);
|
Vec3 sc = level->getSkyColor(mc.cameraTargetPlayer, alpha);
|
||||||
float sr = (float) sc.x;
|
float sr = (float) sc.x;
|
||||||
float sg = (float) sc.y;
|
float sg = (float) sc.y;
|
||||||
float sb = (float) sc.z;// + 0.5f;
|
float sb = (float) sc.z;// + 0.5f;
|
||||||
|
|
||||||
if (mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) {
|
if (mc.options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) {
|
||||||
float srr = (sr * 30.0f + sg * 59.0f + sb * 11.0f) / 100.0f;
|
float srr = (sr * 30.0f + sg * 59.0f + sb * 11.0f) / 100.0f;
|
||||||
float sgg = (sr * 30.0f + sg * 70.0f) / (100.0f);
|
float sgg = (sr * 30.0f + sg * 70.0f) / (100.0f);
|
||||||
float sbb = (sr * 30.0f + sb * 70.0f) / (100.0f);
|
float sbb = (sr * 30.0f + sb * 70.0f) / (100.0f);
|
||||||
@@ -1023,10 +1023,10 @@ void LevelRenderer::renderSky(float alpha) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LevelRenderer::renderClouds( float alpha ) {
|
void LevelRenderer::renderClouds( float alpha ) {
|
||||||
//if (!mc->level->dimension->isNaturalDimension()) return;
|
//if (!mc.level->dimension->isNaturalDimension()) return;
|
||||||
glEnable2(GL_TEXTURE_2D);
|
glEnable2(GL_TEXTURE_2D);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
float yOffs = (float) (mc->player->yOld + (mc->player->y - mc->player->yOld) * alpha);
|
float yOffs = (float) (mc.player->yOld + (mc.player->y - mc.player->yOld) * alpha);
|
||||||
int s = 32;
|
int s = 32;
|
||||||
int d = 256 / s;
|
int d = 256 / s;
|
||||||
Tesselator& t = Tesselator::instance;
|
Tesselator& t = Tesselator::instance;
|
||||||
@@ -1045,14 +1045,14 @@ void LevelRenderer::renderClouds( float alpha ) {
|
|||||||
float scale = 1 / 2048.0f;
|
float scale = 1 / 2048.0f;
|
||||||
|
|
||||||
float time = (ticks + alpha);
|
float time = (ticks + alpha);
|
||||||
float xo = mc->player->xo + (mc->player->x - mc->player->xo) * alpha + time * 0.03f;
|
float xo = mc.player->xo + (mc.player->x - mc.player->xo) * alpha + time * 0.03f;
|
||||||
float zo = mc->player->zo + (mc->player->z - mc->player->zo) * alpha;
|
float zo = mc.player->zo + (mc.player->z - mc.player->zo) * alpha;
|
||||||
int xOffs = Mth::floor(xo / 2048);
|
int xOffs = Mth::floor(xo / 2048);
|
||||||
int zOffs = Mth::floor(zo / 2048);
|
int zOffs = Mth::floor(zo / 2048);
|
||||||
xo -= xOffs * 2048;
|
xo -= xOffs * 2048;
|
||||||
zo -= zOffs * 2048;
|
zo -= zOffs * 2048;
|
||||||
|
|
||||||
float yy = /*level.dimension.getCloudHeight()*/ 128 - yOffs + 0.33f;//mc->player->y + 1;
|
float yy = /*level.dimension.getCloudHeight()*/ 128 - yOffs + 0.33f;//mc.player->y + 1;
|
||||||
float uo = (float) (xo * scale);
|
float uo = (float) (xo * scale);
|
||||||
float vo = (float) (zo * scale);
|
float vo = (float) (zo * scale);
|
||||||
t.begin();
|
t.begin();
|
||||||
@@ -1077,16 +1077,16 @@ void LevelRenderer::playSound(const std::string& name, float x, float y, float z
|
|||||||
float dd = 16;
|
float dd = 16;
|
||||||
|
|
||||||
if (volume > 1) dd *= volume;
|
if (volume > 1) dd *= volume;
|
||||||
if (mc->cameraTargetPlayer->distanceToSqr(x, y, z) < dd * dd) {
|
if (mc.cameraTargetPlayer->distanceToSqr(x, y, z) < dd * dd) {
|
||||||
mc->soundEngine->play(name, x, y, z, volume, pitch);
|
mc.soundEngine->play(name, x, y, z, volume, pitch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelRenderer::addParticle(const std::string& name, float x, float y, float z, float xa, float ya, float za, int data) {
|
void LevelRenderer::addParticle(const std::string& name, float x, float y, float z, float xa, float ya, float za, int data) {
|
||||||
|
|
||||||
float xd = mc->cameraTargetPlayer->x - x;
|
float xd = mc.cameraTargetPlayer->x - x;
|
||||||
float yd = mc->cameraTargetPlayer->y - y;
|
float yd = mc.cameraTargetPlayer->y - y;
|
||||||
float zd = mc->cameraTargetPlayer->z - z;
|
float zd = mc.cameraTargetPlayer->z - z;
|
||||||
float distanceSquared = xd * xd + yd * yd + zd * zd;
|
float distanceSquared = xd * xd + yd * yd + zd * zd;
|
||||||
|
|
||||||
//Particle* p = NULL;
|
//Particle* p = NULL;
|
||||||
@@ -1095,7 +1095,7 @@ void LevelRenderer::addParticle(const std::string& name, float x, float y, float
|
|||||||
|
|
||||||
//if (p) {
|
//if (p) {
|
||||||
// if (distanceSquared < 32 * 32) {
|
// if (distanceSquared < 32 * 32) {
|
||||||
// mc->particleEngine->add(p);
|
// mc.particleEngine->add(p);
|
||||||
// } else { delete p; }
|
// } else { delete p; }
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
@@ -1106,21 +1106,21 @@ void LevelRenderer::addParticle(const std::string& name, float x, float y, float
|
|||||||
//static Stopwatch sw;
|
//static Stopwatch sw;
|
||||||
//sw.start();
|
//sw.start();
|
||||||
|
|
||||||
if (name == "bubble") mc->particleEngine->add(new BubbleParticle(level, x, y, z, xa, ya, za));
|
if (name == "bubble") mc.particleEngine->add(new BubbleParticle(level, x, y, z, xa, ya, za));
|
||||||
else if (name == "crit") mc->particleEngine->add(new CritParticle2(level, x, y, z, xa, ya, za));
|
else if (name == "crit") mc.particleEngine->add(new CritParticle2(level, x, y, z, xa, ya, za));
|
||||||
else if (name == "smoke") mc->particleEngine->add(new SmokeParticle(level, x, y, z, xa, ya, za));
|
else if (name == "smoke") mc.particleEngine->add(new SmokeParticle(level, x, y, z, xa, ya, za));
|
||||||
//else if (name == "note") mc->particleEngine->add(new NoteParticle(level, x, y, z, xa, ya, za));
|
//else if (name == "note") mc.particleEngine->add(new NoteParticle(level, x, y, z, xa, ya, za));
|
||||||
else if (name == "explode") mc->particleEngine->add(new ExplodeParticle(level, x, y, z, xa, ya, za));
|
else if (name == "explode") mc.particleEngine->add(new ExplodeParticle(level, x, y, z, xa, ya, za));
|
||||||
else if (name == "flame") mc->particleEngine->add(new FlameParticle(level, x, y, z, xa, ya, za));
|
else if (name == "flame") mc.particleEngine->add(new FlameParticle(level, x, y, z, xa, ya, za));
|
||||||
else if (name == "lava") mc->particleEngine->add(new LavaParticle(level, x, y, z));
|
else if (name == "lava") mc.particleEngine->add(new LavaParticle(level, x, y, z));
|
||||||
//else if (name == "splash") mc->particleEngine->add(new SplashParticle(level, x, y, z, xa, ya, za));
|
//else if (name == "splash") mc.particleEngine->add(new SplashParticle(level, x, y, z, xa, ya, za));
|
||||||
else if (name == "largesmoke") mc->particleEngine->add(new SmokeParticle(level, x, y, z, xa, ya, za, 2.5f));
|
else if (name == "largesmoke") mc.particleEngine->add(new SmokeParticle(level, x, y, z, xa, ya, za, 2.5f));
|
||||||
else if (name == "reddust") mc->particleEngine->add(new RedDustParticle(level, x, y, z, xa, ya, za));
|
else if (name == "reddust") mc.particleEngine->add(new RedDustParticle(level, x, y, z, xa, ya, za));
|
||||||
else if (name == "iconcrack") mc->particleEngine->add(new BreakingItemParticle(level, x, y, z, xa, ya, za, Item::items[data]));
|
else if (name == "iconcrack") mc.particleEngine->add(new BreakingItemParticle(level, x, y, z, xa, ya, za, Item::items[data]));
|
||||||
else if (name == "snowballpoof") mc->particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::snowBall));
|
else if (name == "snowballpoof") mc.particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::snowBall));
|
||||||
//else if (name == "snowballpoof") mc->particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::snowBall));
|
//else if (name == "snowballpoof") mc.particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::snowBall));
|
||||||
//else if (name == "slime") mc->particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::slimeBall));
|
//else if (name == "slime") mc.particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::slimeBall));
|
||||||
//else if (name == "heart") mc->particleEngine->add(new HeartParticle(level, x, y, z, xa, ya, za));
|
//else if (name == "heart") mc.particleEngine->add(new HeartParticle(level, x, y, z, xa, ya, za));
|
||||||
|
|
||||||
//sw.stop();
|
//sw.stop();
|
||||||
//sw.printEvery(50, "add-particle-string");
|
//sw.printEvery(50, "add-particle-string");
|
||||||
@@ -1128,9 +1128,9 @@ void LevelRenderer::addParticle(const std::string& name, float x, float y, float
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
void LevelRenderer::addParticle(ParticleType::Id name, float x, float y, float z, float xa, float ya, float za, int data) {
|
void LevelRenderer::addParticle(ParticleType::Id name, float x, float y, float z, float xa, float ya, float za, int data) {
|
||||||
float xd = mc->cameraTargetPlayer->x - x;
|
float xd = mc.cameraTargetPlayer->x - x;
|
||||||
float yd = mc->cameraTargetPlayer->y - y;
|
float yd = mc.cameraTargetPlayer->y - y;
|
||||||
float zd = mc->cameraTargetPlayer->z - z;
|
float zd = mc.cameraTargetPlayer->z - z;
|
||||||
|
|
||||||
const float particleDistance = 16;
|
const float particleDistance = 16;
|
||||||
if (xd * xd + yd * yd + zd * zd > particleDistance * particleDistance) return;
|
if (xd * xd + yd * yd + zd * zd > particleDistance * particleDistance) return;
|
||||||
@@ -1140,15 +1140,15 @@ void LevelRenderer::addParticle(ParticleType::Id name, float x, float y, float z
|
|||||||
|
|
||||||
//Particle* p = NULL;
|
//Particle* p = NULL;
|
||||||
|
|
||||||
if (name == ParticleType::bubble) mc->particleEngine->add( new BubbleParticle(level, x, y, z, xa, ya, za) );
|
if (name == ParticleType::bubble) mc.particleEngine->add( new BubbleParticle(level, x, y, z, xa, ya, za) );
|
||||||
else if (name == ParticleType::crit) mc->particleEngine->add(new CritParticle2(level, x, y, z, xa, ya, za) );
|
else if (name == ParticleType::crit) mc.particleEngine->add(new CritParticle2(level, x, y, z, xa, ya, za) );
|
||||||
else if (name == ParticleType::smoke) mc->particleEngine->add(new SmokeParticle(level, x, y, z, xa, ya, za) );
|
else if (name == ParticleType::smoke) mc.particleEngine->add(new SmokeParticle(level, x, y, z, xa, ya, za) );
|
||||||
else if (name == ParticleType::explode) mc->particleEngine->add( new ExplodeParticle(level, x, y, z, xa, ya, za) );
|
else if (name == ParticleType::explode) mc.particleEngine->add( new ExplodeParticle(level, x, y, z, xa, ya, za) );
|
||||||
else if (name == ParticleType::flame) mc->particleEngine->add( new FlameParticle(level, x, y, z, xa, ya, za) );
|
else if (name == ParticleType::flame) mc.particleEngine->add( new FlameParticle(level, x, y, z, xa, ya, za) );
|
||||||
else if (name == ParticleType::lava) mc->particleEngine->add( new LavaParticle(level, x, y, z) );
|
else if (name == ParticleType::lava) mc.particleEngine->add( new LavaParticle(level, x, y, z) );
|
||||||
else if (name == ParticleType::largesmoke) mc->particleEngine->add( new SmokeParticle(level, x, y, z, xa, ya, za, 2.5f) );
|
else if (name == ParticleType::largesmoke) mc.particleEngine->add( new SmokeParticle(level, x, y, z, xa, ya, za, 2.5f) );
|
||||||
else if (name == ParticleType::reddust) mc->particleEngine->add( new RedDustParticle(level, x, y, z, xa, ya, za) );
|
else if (name == ParticleType::reddust) mc.particleEngine->add( new RedDustParticle(level, x, y, z, xa, ya, za) );
|
||||||
else if (name == ParticleType::iconcrack) mc->particleEngine->add( new BreakingItemParticle(level, x, y, z, xa, ya, za, Item::items[data]) );
|
else if (name == ParticleType::iconcrack) mc.particleEngine->add( new BreakingItemParticle(level, x, y, z, xa, ya, za, Item::items[data]) );
|
||||||
|
|
||||||
//switch (name) {
|
//switch (name) {
|
||||||
// case ParticleType::bubble: p = new BubbleParticle(level, x, y, z, xa, ya, za); break;
|
// case ParticleType::bubble: p = new BubbleParticle(level, x, y, z, xa, ya, za); break;
|
||||||
@@ -1170,7 +1170,7 @@ void LevelRenderer::addParticle(ParticleType::Id name, float x, float y, float z
|
|||||||
// break;
|
// break;
|
||||||
//}
|
//}
|
||||||
//if (p) {
|
//if (p) {
|
||||||
// mc->particleEngine->add(p);
|
// mc.particleEngine->add(p);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//sw.stop();
|
//sw.stop();
|
||||||
@@ -1261,29 +1261,29 @@ int _t_keepPic = -1;
|
|||||||
void LevelRenderer::takePicture( TripodCamera* cam, Entity* entity )
|
void LevelRenderer::takePicture( TripodCamera* cam, Entity* entity )
|
||||||
{
|
{
|
||||||
// Push old values
|
// Push old values
|
||||||
Mob* oldCameraEntity = mc->cameraTargetPlayer;
|
Mob* oldCameraEntity = mc.cameraTargetPlayer;
|
||||||
bool hideGui = mc->options.getBooleanValue(OPTIONS_HIDEGUI);
|
bool hideGui = mc.options.getBooleanValue(OPTIONS_HIDEGUI);
|
||||||
bool thirdPerson = mc->options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW);
|
bool thirdPerson = mc.options.getBooleanValue(OPTIONS_THIRD_PERSON_VIEW);
|
||||||
|
|
||||||
// @huge @attn: This is highly illegal, super temp!
|
// @huge @attn: This is highly illegal, super temp!
|
||||||
mc->cameraTargetPlayer = (Mob*)cam;
|
mc.cameraTargetPlayer = (Mob*)cam;
|
||||||
mc->options.set(OPTIONS_HIDEGUI, true);
|
mc.options.set(OPTIONS_HIDEGUI, true);
|
||||||
mc->options.set(OPTIONS_THIRD_PERSON_VIEW, false);
|
mc.options.set(OPTIONS_THIRD_PERSON_VIEW, false);
|
||||||
|
|
||||||
mc->gameRenderer->renderLevel(0);
|
mc.gameRenderer->renderLevel(0);
|
||||||
|
|
||||||
// Pop values back
|
// Pop values back
|
||||||
mc->cameraTargetPlayer = oldCameraEntity;
|
mc.cameraTargetPlayer = oldCameraEntity;
|
||||||
mc->options.set(OPTIONS_HIDEGUI, hideGui);
|
mc.options.set(OPTIONS_HIDEGUI, hideGui);
|
||||||
mc->options.set(OPTIONS_THIRD_PERSON_VIEW, thirdPerson);
|
mc.options.set(OPTIONS_THIRD_PERSON_VIEW, thirdPerson);
|
||||||
|
|
||||||
_t_keepPic = -1;
|
_t_keepPic = -1;
|
||||||
|
|
||||||
// Save image
|
// Save image
|
||||||
static char filename[256];
|
static char filename[256];
|
||||||
sprintf(filename, "%s/games/com.mojang/img_%.4d.jpg", mc->externalStoragePath.c_str(), getTimeMs());
|
sprintf(filename, "%s/games/com.mojang/img_%.4d.jpg", mc.externalStoragePath.c_str(), getTimeMs());
|
||||||
|
|
||||||
mc->platform()->saveScreenshot(filename, mc->width, mc->height);
|
mc.platform()->saveScreenshot(filename, mc.getScreenWidth(), mc.getScreenHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelRenderer::levelEvent(Player* player, int type, int x, int y, int z, int data) {
|
void LevelRenderer::levelEvent(Player* player, int type, int x, int y, int z, int data) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user