mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-30 20:13:31 +00:00
server compilable
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
#include "Gui.h"
|
||||
#include "Font.h"
|
||||
#include "MinecraftClient.h"
|
||||
#include "client/Options.h"
|
||||
#include "platform/input/Keyboard.h"
|
||||
#include "screens/IngameBlockSelectionScreen.h"
|
||||
#include "screens/ChatScreen.h"
|
||||
#include "screens/ConsoleScreen.h"
|
||||
#include "../Minecraft.h"
|
||||
#include <Minecraft.h>
|
||||
#include "../player/LocalPlayer.h"
|
||||
#include "../renderer/Tesselator.h"
|
||||
#include "../renderer/TileRenderer.h"
|
||||
@@ -29,39 +30,23 @@
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
#define MAX_MESSAGE_WIDTH 240
|
||||
|
||||
float Gui::InvGuiScale = 1.0f / 3.0f;
|
||||
float Gui::GuiScale = 1.0f / Gui::InvGuiScale;
|
||||
const float Gui::DropTicks = 40.0f;
|
||||
|
||||
//#include <android/log.h>
|
||||
|
||||
Gui::Gui(Minecraft* minecraft)
|
||||
: minecraft(minecraft),
|
||||
tickCount(0),
|
||||
progress(0),
|
||||
overlayMessageTime(0),
|
||||
animateOverlayMessageColor(false),
|
||||
chatScrollOffset(0),
|
||||
tbr(1),
|
||||
_inventoryNeedsUpdate(true),
|
||||
_flashSlotId(-1),
|
||||
_flashSlotStartTime(-1),
|
||||
_slotFont(NULL),
|
||||
_numSlots(4),
|
||||
_currentDropTicks(-1),
|
||||
_currentDropSlot(-1),
|
||||
MAX_MESSAGE_WIDTH(240),
|
||||
itemNameOverlayTime(2),
|
||||
_openInventorySlot(minecraft->useTouchscreen())
|
||||
{
|
||||
// @todo virtual controlConfigurationChanged() when player switches from keyboard to touch for example
|
||||
Gui::Gui(MinecraftClient& minecraft) : minecraft(minecraft), _openInventorySlot(minecraft.useTouchscreen()) {
|
||||
glGenBuffers2(1, &_inventoryRc.vboId);
|
||||
glGenBuffers2(1, &rcFeedbackInner.vboId);
|
||||
glGenBuffers2(1, &rcFeedbackOuter.vboId);
|
||||
//Gui::InvGuiScale = 1.0f / (int) (3 * Minecraft::width / 854);
|
||||
}
|
||||
|
||||
Gui::~Gui()
|
||||
{
|
||||
Gui::~Gui() {
|
||||
if (_slotFont)
|
||||
delete _slotFont;
|
||||
|
||||
@@ -69,17 +54,16 @@ Gui::~Gui()
|
||||
}
|
||||
|
||||
void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
|
||||
if (!minecraft->level || !minecraft->player)
|
||||
if (!minecraft.level || !minecraft.getPlayer())
|
||||
return;
|
||||
|
||||
//minecraft->gameRenderer->setupGuiScreen();
|
||||
Font* font = minecraft->font;
|
||||
Font* font = minecraft.getFont();
|
||||
|
||||
const bool isTouchInterface = minecraft->useTouchscreen();
|
||||
const bool isTouchInterface = minecraft.useTouchscreen();
|
||||
|
||||
const int screenWidth = (int)(minecraft->width * InvGuiScale);
|
||||
const int screenHeight = (int)(minecraft->height * InvGuiScale);
|
||||
const int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||
const int screenHeight = (int)(minecraft.getScreenHeigth() * InvGuiScale);
|
||||
blitOffset = -90;
|
||||
renderProgressIndicator(isTouchInterface, screenWidth, screenHeight, a);
|
||||
|
||||
@@ -91,9 +75,9 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
// F: 3
|
||||
int ySlot = screenHeight - 16 - 3;
|
||||
|
||||
if (!minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
if (minecraft->gameMode->canHurtPlayer()) {
|
||||
minecraft->textures->loadAndBindTexture("gui/icons.png");
|
||||
if (!minecraft.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
if (minecraft.gameMode->canHurtPlayer()) {
|
||||
minecraft.getTextures()->loadAndBindTexture("gui/icons.png");
|
||||
Tesselator& t = Tesselator::instance;
|
||||
t.beginOverride();
|
||||
t.colorABGR(0xffffffff);
|
||||
@@ -103,7 +87,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
}
|
||||
}
|
||||
|
||||
if(minecraft->player->getSleepTimer() > 0) {
|
||||
if(minecraft.getPlayer()->getSleepTimer() > 0) {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
||||
@@ -112,7 +96,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
if (!minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
if (!minecraft.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
renderToolBar(a, ySlot, screenWidth);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "../../util/Random.h"
|
||||
#include "../IConfigListener.h"
|
||||
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
class ItemInstance;
|
||||
class Textures;
|
||||
class Tesselator;
|
||||
@@ -27,7 +27,7 @@ typedef std::vector<GuiMessage> GuiMessageList;
|
||||
class Gui: public GuiComponent, IConfigListener
|
||||
{
|
||||
public:
|
||||
Gui(Minecraft* minecraft);
|
||||
Gui(MinecraftClient& minecraft);
|
||||
~Gui();
|
||||
|
||||
int getSlotIdAt(int x, int y);
|
||||
@@ -90,43 +90,42 @@ private:
|
||||
void tickItemDrop();
|
||||
float cubeSmoothStep(float percentage, float min, float max);
|
||||
public:
|
||||
float progress;
|
||||
float progress = 0.f;
|
||||
std::string selectedName;
|
||||
static float InvGuiScale;
|
||||
static float GuiScale;
|
||||
|
||||
private:
|
||||
int MAX_MESSAGE_WIDTH;
|
||||
//ItemRenderer itemRenderer;
|
||||
GuiMessageList guiMessages;
|
||||
int chatScrollOffset;
|
||||
int chatScrollOffset = 0;
|
||||
Random random;
|
||||
|
||||
Minecraft* minecraft;
|
||||
int tickCount;
|
||||
float itemNameOverlayTime;
|
||||
MinecraftClient& minecraft;
|
||||
int tickCount = 0;
|
||||
float itemNameOverlayTime = 2;
|
||||
std::string overlayMessageString;
|
||||
int overlayMessageTime;
|
||||
bool animateOverlayMessageColor;
|
||||
int overlayMessageTime = 0;
|
||||
bool animateOverlayMessageColor = false;
|
||||
|
||||
float tbr;
|
||||
float tbr = 1.f;
|
||||
|
||||
RenderChunk _inventoryRc;
|
||||
bool _inventoryNeedsUpdate;
|
||||
bool _inventoryNeedsUpdate = true;
|
||||
|
||||
int _flashSlotId;
|
||||
float _flashSlotStartTime;
|
||||
int _flashSlotId = -1;
|
||||
float _flashSlotStartTime = -1;
|
||||
|
||||
Font* _slotFont;
|
||||
int _numSlots;
|
||||
Font* _slotFont = nullptr;
|
||||
int _numSlots = 4;
|
||||
|
||||
RenderChunk rcFeedbackOuter;
|
||||
RenderChunk rcFeedbackInner;
|
||||
|
||||
// For dropping
|
||||
static const float DropTicks;
|
||||
float _currentDropTicks;
|
||||
int _currentDropSlot;
|
||||
float _currentDropTicks = -1;
|
||||
int _currentDropSlot = -1;
|
||||
|
||||
bool _openInventorySlot;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "Screen.h"
|
||||
#include "components/Button.h"
|
||||
#include "components/TextBox.h"
|
||||
#include "../Minecraft.h"
|
||||
#include <Minecraft.h>
|
||||
#include "../renderer/Tesselator.h"
|
||||
#include "../sound/SoundEngine.h"
|
||||
#include "../../platform/input/Keyboard.h"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "RolledSelectionListH.h"
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../renderer/Tesselator.h"
|
||||
#include "../../renderer/gles.h"
|
||||
#include "../../../platform/input/Mouse.h"
|
||||
#include "../../../platform/input/Multitouch.h"
|
||||
#include "../../../util/Mth.h"
|
||||
#include "../../renderer/Textures.h"
|
||||
#include "MinecraftClient.h"
|
||||
|
||||
|
||||
RolledSelectionListH::RolledSelectionListH( Minecraft* minecraft, int width, int height, int x0, int x1, int y0, int y1, int itemWidth )
|
||||
RolledSelectionListH::RolledSelectionListH( MinecraftClient& minecraft, int width, int height, int x0, int x1, int y0, int y1, int itemWidth )
|
||||
: minecraft(minecraft),
|
||||
width(width),
|
||||
height(height),
|
||||
@@ -172,7 +172,7 @@ void RolledSelectionListH::render( int xm, int ym, float a )
|
||||
|
||||
//LOGI("x: %f\n", xo);
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||
glColor4f2(1.0f, 1, 1, 1);
|
||||
float s = 32;
|
||||
t.begin();
|
||||
@@ -280,7 +280,7 @@ void RolledSelectionListH::render( int xm, int ym, float a )
|
||||
void RolledSelectionListH::renderHoleBackground( /*float x0, float x1,*/ float y0, float y1, int a0, int a1 )
|
||||
{
|
||||
Tesselator& t = Tesselator::instance;
|
||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
||||
minecraft.textures().loadAndBindTexture("gui/background.png");
|
||||
glColor4f2(1.0f, 1, 1, 1);
|
||||
float s = 32;
|
||||
t.begin();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListH_H__
|
||||
|
||||
#include "../GuiComponent.h"
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
class Tesselator;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class RolledSelectionListH : public GuiComponent
|
||||
static const int DRAG_OUTSIDE = -2;
|
||||
static const int DRAG_NORMAL = 0;
|
||||
public:
|
||||
RolledSelectionListH(Minecraft* minecraft, int width, int height, int x0, int x1, int y0, int y1, int itemWidth);
|
||||
RolledSelectionListH(MinecraftClient& minecraft, int width, int height, int x0, int x1, int y0, int y1, int itemWidth);
|
||||
|
||||
virtual int getItemAtPosition(int x, int y);
|
||||
|
||||
@@ -45,7 +45,7 @@ protected:
|
||||
virtual void clickedHeader(int headerMouseX, int headerMouseY) {}
|
||||
int getItemAtXPositionRaw(int x);
|
||||
protected:
|
||||
Minecraft* minecraft;
|
||||
MinecraftClient& minecraft;
|
||||
|
||||
float x0;
|
||||
float x1;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
//static NinePatchLayer* guiPaneFrame = NULL;
|
||||
|
||||
static __inline void setIfNotSet(bool& ref, bool condition) {
|
||||
static inline void setIfNotSet(bool& ref, bool condition) {
|
||||
ref = (ref || condition);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "../Gui.h"
|
||||
#include "../../renderer/Textures.h"
|
||||
#include "../../gamemode/GameMode.h"
|
||||
#include <gamemode/GameMode.h>
|
||||
#include "ArmorScreen.h"
|
||||
#include "../components/Button.h"
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
#include "RenameMPLevelScreen.h"
|
||||
#include "StartMenuScreen.h"
|
||||
#include "DialogDefinitions.h"
|
||||
#include "../Gui.h"
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../../AppPlatform.h"
|
||||
#include "../../../platform/log.h"
|
||||
#include "../../../world/level/storage/LevelStorageSource.h"
|
||||
|
||||
|
||||
static char ILLEGAL_FILE_CHARACTERS[] = {
|
||||
'/', '\n', '\r', '\t', '\0', '\f', '`', '?', '*', '\\', '<', '>', '|', '\"', ':'
|
||||
};
|
||||
|
||||
RenameMPLevelScreen::RenameMPLevelScreen( const std::string& levelId )
|
||||
: _levelId(levelId)
|
||||
{
|
||||
}
|
||||
|
||||
void RenameMPLevelScreen::init() {
|
||||
minecraft->platform()->createUserInput(DialogDefinitions::DIALOG_RENAME_MP_WORLD);
|
||||
}
|
||||
|
||||
void RenameMPLevelScreen::render(int xm, int ym, float a)
|
||||
{
|
||||
renderBackground();
|
||||
|
||||
#ifdef WIN32
|
||||
minecraft->getLevelSource()->renameLevel(_levelId, "Save?Level");
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
#else
|
||||
int status = minecraft->platform()->getUserInputStatus();
|
||||
if (status > -1) {
|
||||
if (status == 1) {
|
||||
std::vector<std::string> v = minecraft->platform()->getUserInput();
|
||||
|
||||
if (!v.empty()) {
|
||||
// Read the level name.
|
||||
// 1) Trim name 2) Remove all bad chars -) We don't have to getUniqueLevelName, since renameLevel will do that
|
||||
std::string levelId = v[0];
|
||||
|
||||
for (int i = 0; i < sizeof(ILLEGAL_FILE_CHARACTERS) / sizeof(char); ++i)
|
||||
levelId = Util::stringReplace(levelId, std::string(1, ILLEGAL_FILE_CHARACTERS[i]), "");
|
||||
if ((int)levelId.length() == 0) {
|
||||
levelId = "saved_world";
|
||||
}
|
||||
|
||||
minecraft->getLevelSource()->renameLevel(_levelId, levelId);
|
||||
}
|
||||
}
|
||||
|
||||
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__RenameMPLevelScreen_H__
|
||||
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__RenameMPLevelScreen_H__
|
||||
|
||||
#include "../Screen.h"
|
||||
|
||||
class RenameMPLevelScreen: public Screen
|
||||
{
|
||||
public:
|
||||
RenameMPLevelScreen(const std::string& levelId);
|
||||
|
||||
virtual void init();
|
||||
virtual void render(int xm, int ym, float a);
|
||||
|
||||
private:
|
||||
std::string _levelId;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__RenameMPLevelScreen_H__*/
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ScreenChooser.h"
|
||||
#include "StartMenuScreen.h"
|
||||
#include "MinecraftClient.h"
|
||||
#include "SelectWorldScreen.h"
|
||||
#include "JoinGameScreen.h"
|
||||
#include "PauseScreen.h"
|
||||
@@ -58,6 +59,6 @@ Screen* ScreenChooser::createScreen( ScreenId id )
|
||||
Screen* ScreenChooser::setScreen(ScreenId id)
|
||||
{
|
||||
Screen* screen = createScreen(id);
|
||||
_mc->setScreen(screen);
|
||||
_mc.setScreen(screen);
|
||||
return screen;
|
||||
}
|
||||
|
||||
@@ -14,19 +14,17 @@ enum ScreenId {
|
||||
};
|
||||
|
||||
class Screen;
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
|
||||
class ScreenChooser
|
||||
{
|
||||
public:
|
||||
ScreenChooser(Minecraft* mc)
|
||||
: _mc(mc)
|
||||
{}
|
||||
ScreenChooser(MinecraftClient& mc) : _mc(mc) {}
|
||||
|
||||
Screen* createScreen(ScreenId id);
|
||||
Screen* setScreen(ScreenId id);
|
||||
private:
|
||||
Minecraft* _mc;
|
||||
MinecraftClient& _mc;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ScreenChooser_H__*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "SelectWorldScreen.h"
|
||||
#include "MinecraftClient.h"
|
||||
#include "StartMenuScreen.h"
|
||||
#include "ProgressScreen.h"
|
||||
#include "DialogDefinitions.h"
|
||||
@@ -22,7 +23,7 @@ static float Max(float a, float b) {
|
||||
//
|
||||
// World Selection List
|
||||
//
|
||||
WorldSelectionList::WorldSelectionList( Minecraft* minecraft, int width, int height )
|
||||
WorldSelectionList::WorldSelectionList( MinecraftClient& minecraft, int width, int height )
|
||||
: _height(height),
|
||||
hasPickedLevel(false),
|
||||
currentTick(0),
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#include "../TweenData.h"
|
||||
#include "../components/Button.h"
|
||||
#include "../components/RolledSelectionListH.h"
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../../world/level/storage/LevelStorageSource.h"
|
||||
|
||||
|
||||
class SelectWorldScreen;
|
||||
class MinecraftClient;
|
||||
|
||||
//
|
||||
// Scrolling World selection list
|
||||
@@ -17,7 +17,7 @@ class SelectWorldScreen;
|
||||
class WorldSelectionList : public RolledSelectionListH
|
||||
{
|
||||
public:
|
||||
WorldSelectionList(Minecraft* _minecraft, int _width, int _height);
|
||||
WorldSelectionList(MinecraftClient& _minecraft, int _width, int _height);
|
||||
virtual void tick();
|
||||
void stepLeft();
|
||||
void stepRight();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "../../Screen.h"
|
||||
#include "../../components/ImageButton.h"
|
||||
#include "../../components/InventoryPane.h"
|
||||
#include "../../../gamemode/GameMode.h"
|
||||
#include <gamemode/GameMode.h>
|
||||
#include "../../../renderer/TileRenderer.h"
|
||||
#include "../../../player/LocalPlayer.h"
|
||||
#include "../../../renderer/gles.h"
|
||||
@@ -91,8 +91,7 @@ void IngameBlockSelectionScreen::init()
|
||||
//for (int i = 0; i < inventory->getContainerSize(); ++i)
|
||||
//LOGI("> %d - %s\n", i, inventory->getItem(i)? inventory->getItem(i)->getDescriptionId().c_str() : "<-->\n");
|
||||
|
||||
// Grid indices are 0..N-1 for main inventory only; slots 0..MAX_SELECTION_SIZE-1 are hotbar links.
|
||||
InventorySize = inventory->getContainerSize() - Inventory::MAX_SELECTION_SIZE;
|
||||
InventorySize = inventory->getContainerSize();
|
||||
InventoryRows = 1 + (InventorySize-1) / InventoryColumns;
|
||||
|
||||
//
|
||||
@@ -266,8 +265,7 @@ void IngameBlockSelectionScreen::buttonClicked(Button* button) {
|
||||
|
||||
bool IngameBlockSelectionScreen::isAllowed( int slot )
|
||||
{
|
||||
const int gridCount = minecraft->player->inventory->getContainerSize() - Inventory::MAX_SELECTION_SIZE;
|
||||
if (slot < 0 || slot >= gridCount)
|
||||
if (slot < 0 || slot >= minecraft->player->inventory->getContainerSize())
|
||||
return false;
|
||||
|
||||
#ifdef DEMO_MODE
|
||||
|
||||
Reference in New Issue
Block a user