pragma once everywhere

This commit is contained in:
Kolyah35
2026-03-28 00:00:19 +03:00
parent a45c01d013
commit 7d3257669a
575 changed files with 37222 additions and 38345 deletions

View File

@@ -1,5 +1,4 @@
#ifndef EGLCONFIGPRINTER_H__ #pragma once
#define EGLCONFIGPRINTER_H__
#include <cstdio> #include <cstdio>
#include <string> #include <string>
@@ -122,4 +121,3 @@ public:
} }
}; };
#endif /*EGLCONFIGPRINTER_H__*/

View File

@@ -1,40 +1,39 @@
#ifndef LICENSECODES_H__ #pragma once
#define LICENSECODES_H__
class LicenseCodes
class LicenseCodes {
{ public:
public: // Something's not ready, call again later
// Something's not ready, call again later static const int WAIT_PLATFORM_NOT_READY = -2;
static const int WAIT_PLATFORM_NOT_READY = -2; static const int WAIT_SERVER_NOT_READY = -1;
static const int WAIT_SERVER_NOT_READY = -1;
// License is ok
// License is ok static const int LICENSE_OK = 0;
static const int LICENSE_OK = 0; static const int LICENSE_TRIAL_OK = 1;
static const int LICENSE_TRIAL_OK = 1;
// License is not working in one way or another
// License is not working in one way or another static const int LICENSE_VALIDATION_FAILED = 50;
static const int LICENSE_VALIDATION_FAILED = 50; static const int ITEM_NOT_FOUND = 51;
static const int ITEM_NOT_FOUND = 51; static const int LICENSE_NOT_FOUND = 52;
static const int LICENSE_NOT_FOUND = 52; static const int ERROR_CONTENT_HANDLER = 100;
static const int ERROR_CONTENT_HANDLER = 100; static const int ERROR_ILLEGAL_ARGUMENT = 101;
static const int ERROR_ILLEGAL_ARGUMENT = 101; static const int ERROR_SECURITY = 102;
static const int ERROR_SECURITY = 102; static const int ERROR_INPUT_OUTPUT = 103;
static const int ERROR_INPUT_OUTPUT = 103; static const int ERROR_ILLEGAL_STATE = 104;
static const int ERROR_ILLEGAL_STATE = 104; static const int ERROR_NULL_POINTER = 105;
static const int ERROR_NULL_POINTER = 105; static const int ERROR_GENERAL = 106;
static const int ERROR_GENERAL = 106; static const int ERROR_UNABLE_TO_CONNECT_TO_CDS = 107;
static const int ERROR_UNABLE_TO_CONNECT_TO_CDS = 107;
// The call went wrong so we didn't get a license value at all
// The call went wrong so we didn't get a license value at all static const int ERROR_EXCEPTION = 200;
static const int ERROR_EXCEPTION = 200;
static bool isOk(int i) {
static bool isOk(int i) { return (i == 0) || (i == 1);
return (i == 0) || (i == 1); }
} static bool isReady(int i) {
static bool isReady(int i) { return (i >= 0);
return (i >= 0); }
} };
};
#endif /*LICENSECODES_H__ */
#endif /*LICENSECODES_H__ */

View File

@@ -1,140 +1,138 @@
#ifndef NET_MINECRAFT_CLIENT__Minecraft_H__ #pragma once
#define NET_MINECRAFT_CLIENT__Minecraft_H__
#include "client/Options.h"
#include "client/Options.h" #include "client/Timer.h"
#include "client/Timer.h"
//#include "../network/RakNetInstance.h"
//#include "../network/RakNetInstance.h" #include "world/phys/HitResult.h"
#include "world/phys/HitResult.h"
#include "App.h"
#include "App.h" #include <cstddef>
#include <cstddef>
class Level;
class Level; class LocalPlayer;
class LocalPlayer; class IInputHolder;
class IInputHolder; class Mob;
class Mob; class Player;
class Player; class Entity;
class Entity; class ICreator;
class ICreator; class GameMode;
class GameMode; class CThread;
class CThread; class LevelStorageSource;
class LevelStorageSource; class BuildActionIntention;
class BuildActionIntention; class PerfRenderer;
class PerfRenderer; class LevelSettings;
class LevelSettings; class IRakNetInstance;
class IRakNetInstance; class NetEventCallback;
class NetEventCallback; class CommandServer;
class CommandServer; struct PingedCompatibleServer;
struct PingedCompatibleServer;
class Minecraft: public App {
class Minecraft: public App { public:
public: using App::App;
using App::App; virtual ~Minecraft();
virtual ~Minecraft();
virtual void init();
virtual void init(); virtual void update();
virtual void update(); virtual void restartServer();
virtual void restartServer(); virtual void tick(int nTick, int maxTick);
virtual void tick(int nTick, int maxTick);
virtual bool isOnlineClient();
virtual bool isOnlineClient(); virtual bool isOnline();
virtual bool isOnline();
virtual void setIsCreativeMode(bool isCreative);
virtual void setIsCreativeMode(bool isCreative);
virtual void optionUpdated(OptionId option, bool value);
virtual void optionUpdated(OptionId option, bool value); virtual void optionUpdated(OptionId option, float value);
virtual void optionUpdated(OptionId option, float value); virtual void optionUpdated(OptionId option, int value);
virtual void optionUpdated(OptionId option, int value);
/**
/** * @brief Get public name that will be listed in JoinGame menu
* @brief Get public name that will be listed in JoinGame menu */
*/ virtual std::string getServerName() { return "Unknown"; }
virtual std::string getServerName() { return "Unknown"; }
void toggleDimension() {}
void toggleDimension() {} bool isCreativeMode();
bool isCreativeMode();
virtual void selectLevel(const std::string& levelId, const std::string& levelName, const LevelSettings& settings);
virtual void selectLevel(const std::string& levelId, const std::string& levelName, const LevelSettings& settings); virtual void setLevel(Level* level, const std::string& message = "", Player* forceInsertPlayer = NULL);
virtual void setLevel(Level* level, const std::string& message = "", Player* forceInsertPlayer = NULL);
virtual void onBlockDestroyed(Player* player, int x, int y, int z, int face) {}
virtual void onBlockDestroyed(Player* player, int x, int y, int z, int face) {}
void generateLevel( const std::string& message, Level* level );
void generateLevel( const std::string& message, Level* level ); LevelStorageSource* getLevelSource();
LevelStorageSource* getLevelSource();
virtual void hostMultiplayer(int port=19132);
virtual void hostMultiplayer(int port=19132); Player* respawnPlayer(int playerId);
Player* respawnPlayer(int playerId); void respawnPlayer();
void respawnPlayer(); void resetPlayer(Player* player);
void resetPlayer(Player* player); void doActuallyRespawnPlayer();
void doActuallyRespawnPlayer();
void prepareLevel(const std::string& message);
void prepareLevel(const std::string& message);
int getProgressStatusId();
int getProgressStatusId(); const char* getProgressMessage();
const char* getProgressMessage();
ICreator* getCreator();
ICreator* getCreator();
bool isLevelGenerated();
bool isLevelGenerated();
#ifdef __APPLE__
#ifdef __APPLE__ bool _isSuperFast = false;
bool _isSuperFast = false; bool isSuperFast() { return _isSuperFast; }
bool isSuperFast() { return _isSuperFast; } #endif
#endif
protected:
protected: virtual void _levelGenerated();
virtual void _levelGenerated();
private:
private: static void* prepareLevel_tspawn(void *p_param);
static void* prepareLevel_tspawn(void *p_param); public:
public: Level* level = nullptr;
Level* level = nullptr; CommandServer* _commandServer = nullptr;
CommandServer* _commandServer = nullptr; GameMode* gameMode = nullptr;
GameMode* gameMode = nullptr; IRakNetInstance* raknetInstance = nullptr;
IRakNetInstance* raknetInstance = nullptr; NetEventCallback* netCallback = nullptr;
NetEventCallback* netCallback = nullptr;
int commandPort = 4711;
int commandPort = 4711;
int lastTime = 0;
int lastTime = 0; int lastTickTime = -1;
int lastTickTime = -1; int missTime = 0;
int missTime = 0; int ticks = 0;
int ticks = 0;
CThread* generateLevelThread = nullptr;
CThread* generateLevelThread = nullptr; // static int customDebugId;
// static int customDebugId;
HitResult hitResult;
HitResult hitResult; volatile int progressStagePercentage = 0;
volatile int progressStagePercentage = 0;
// This field is initialized in main()
// This field is initialized in main() // It sets the base path to where worlds can be written (sdcard on android)
// It sets the base path to where worlds can be written (sdcard on android) std::string externalStoragePath;
std::string externalStoragePath; std::string externalCacheStoragePath;
std::string externalCacheStoragePath; protected:
protected: Timer timer{20};
Timer timer{20}; // @note @attn @warn: this is dangerous as fuck!
// @note @attn @warn: this is dangerous as fuck! volatile bool isGeneratingLevel = false;
volatile bool isGeneratingLevel = false; bool _hasSignaledGeneratingLevelFinished = true;
bool _hasSignaledGeneratingLevelFinished = true;
LevelStorageSource* storageSource;
LevelStorageSource* storageSource; bool _running;
bool _running;
protected:
protected: volatile int progressStageStatusId = 0;
volatile int progressStageStatusId = 0; static const char* progressMessages[];
static const char* progressMessages[];
int _licenseId;
int _licenseId;
bool _isCreativeMode;
bool _isCreativeMode; Player* _pendingRemovePlayer; // @attn @todo @fix: remove this shait and fix the respawn behaviour
Player* _pendingRemovePlayer; // @attn @todo @fix: remove this shait and fix the respawn behaviour
// from NinecraftApp
// from NinecraftApp bool _verbose = true;
bool _verbose = true; int _lastTickMs = 0;
int _lastTickMs = 0;
static bool _hasInitedStatics;
static bool _hasInitedStatics; };
};
#endif /*NET_MINECRAFT_CLIENT__Minecraft_H__*/

View File

@@ -1,12 +1,10 @@
#ifndef PERFORMANCE_H__ #pragma once
#define PERFORMANCE_H__
#include "platform/time.h"
#include "platform/time.h"
class Performance
class Performance {
{ public:
public: static StopwatchHandler watches;
static StopwatchHandler watches; };
};
#endif /*PERFORMANCE_H__*/

View File

@@ -1,34 +1,32 @@
#ifndef NET_MINECRAFT_SharedConstants_H__ #pragma once
#define NET_MINECRAFT_SharedConstants_H__
#include <string>
#include <string>
enum LevelGeneratorVersion
enum LevelGeneratorVersion {
{ LGV_ORIGINAL = 0,
LGV_ORIGINAL = 0, };
};
namespace Common {
namespace Common { std::string getGameVersionString(const std::string& versionSuffix = "");
std::string getGameVersionString(const std::string& versionSuffix = ""); }
}
namespace SharedConstants
namespace SharedConstants {
{ // 0.5.0 uses NPv8
// 0.5.0 uses NPv8 // 0.6.0 uses NPv9
// 0.6.0 uses NPv9 const int NetworkProtocolVersion = 9;
const int NetworkProtocolVersion = 9; const int NetworkProtocolLowestSupportedVersion = 9;
const int NetworkProtocolLowestSupportedVersion = 9; const int GameProtocolVersion = 1;
const int GameProtocolVersion = 1; const int GameProtocolLowestSupportedVersion = 1;
const int GameProtocolLowestSupportedVersion = 1;
const int StorageVersion = 3;
const int StorageVersion = 3;
const int MaxChatLength = 100;
const int MaxChatLength = 100;
const int TicksPerSecond = 20;
const int TicksPerSecond = 20;
const int GeneratorVersion = (int)LGV_ORIGINAL;
const int GeneratorVersion = (int)LGV_ORIGINAL; //int FULLBRIGHT_LIGHTVALUE = 15 << 20 | 15 << 4;
//int FULLBRIGHT_LIGHTVALUE = 15 << 20 | 15 << 4; }
}
#endif /*NET_MINECRAFT_SharedConstants_H__*/

View File

@@ -1,48 +1,46 @@
#ifndef CONFIGLISTENER_H__ #pragma once
#define CONFIGLISTENER_H__
#include "PixelCalc.h"
#include "PixelCalc.h" class Minecraft;
class Minecraft; class Options;
class Options;
class Config {
class Config { public:
public: // 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; this->height = height;
this->height = height; this->guiScale = scale;
this->guiScale = scale; this->invGuiScale = 1.0f / scale;
this->invGuiScale = 1.0f / scale; this->guiWidth = (int)(width * invGuiScale);
this->guiWidth = (int)(width * invGuiScale); this->guiHeight = (int)(height * invGuiScale);
this->guiHeight = (int)(height * invGuiScale); }
}
int width;
int width; int height;
int height;
float guiScale;
float guiScale; float invGuiScale;
float invGuiScale; int guiWidth;
int guiWidth; int guiHeight;
int guiHeight;
PixelCalc pixelCalc;
PixelCalc pixelCalc; PixelCalc pixelCalcUi;
PixelCalc pixelCalcUi;
Minecraft* minecraft;
Minecraft* minecraft; Options* options;
Options* options; };
};
Config createConfig(Minecraft* mc);
Config createConfig(Minecraft* mc);
// Interface for Configuration-Changed listener
// Interface for Configuration-Changed listener // This can mean (for instance);
// This can mean (for instance); // - Screen has changed dimensions, or rotation if rotations are enabled
// - Screen has changed dimensions, or rotation if rotations are enabled // - New input device or control mechanism
// - New input device or control mechanism class IConfigListener
class IConfigListener {
{ public:
public: virtual ~IConfigListener() {}
virtual ~IConfigListener() {} virtual void onConfigChanged(const Config& config) = 0;
virtual void onConfigChanged(const Config& config) = 0; };
};
#endif /*CONFIGLISTENER_H__*/

View File

@@ -1,28 +1,26 @@
#ifndef NET_MINECRAFT_CLIENT__MouseHandler_H__ #pragma once
#define NET_MINECRAFT_CLIENT__MouseHandler_H__
//package net.minecraft.client;
//package net.minecraft.client;
class ITurnInput;
class ITurnInput;
class MouseHandler
class MouseHandler {
{ public:
public: MouseHandler(ITurnInput* turnInput);
MouseHandler(ITurnInput* turnInput); MouseHandler();
MouseHandler(); ~MouseHandler();
~MouseHandler();
void setTurnInput(ITurnInput* turnInput);
void setTurnInput(ITurnInput* turnInput);
void grab();
void grab(); void release();
void release();
void poll();
void poll();
float xd, yd;
float xd, yd; private:
private: int toSkip;
int toSkip; ITurnInput* _turnInput;
ITurnInput* _turnInput; };
};
#endif /*NET_MINECRAFT_CLIENT__MouseHandler_H__*/

View File

@@ -1,5 +1,4 @@
#ifndef NET_MINECRAFT_CLIENT__OptionStrings_H__ #pragma once
#define NET_MINECRAFT_CLIENT__OptionStrings_H__
class OptionStrings { class OptionStrings {
public: public:
@@ -33,4 +32,3 @@ public:
}; };
#endif /*NET_MINECRAFT_CLIENT__OptionsStrings_H__*/

View File

@@ -1,166 +1,164 @@
#ifndef NET_MINECRAFT_CLIENT__Options_H__ #pragma once
#define NET_MINECRAFT_CLIENT__Options_H__
#define SOUND_MIN_VALUE 0.0f
#define SOUND_MIN_VALUE 0.0f #define SOUND_MAX_VALUE 1.0f
#define SOUND_MAX_VALUE 1.0f #define MUSIC_MIN_VALUE 0.0f
#define MUSIC_MIN_VALUE 0.0f #define MUSIC_MAX_VALUE 1.0f
#define MUSIC_MAX_VALUE 1.0f #define SENSITIVITY_MIN_VALUE 0.0f
#define SENSITIVITY_MIN_VALUE 0.0f #define SENSITIVITY_MAX_VALUE 1.0f
#define SENSITIVITY_MAX_VALUE 1.0f #define PIXELS_PER_MILLIMETER_MIN_VALUE 3.0f
#define PIXELS_PER_MILLIMETER_MIN_VALUE 3.0f #define PIXELS_PER_MILLIMETER_MAX_VALUE 4.0f
#define PIXELS_PER_MILLIMETER_MAX_VALUE 4.0f
//package net.minecraft.client;
//package net.minecraft.client;
//#include "locale/Language.h"
//#include "locale/Language.h"
#include <string>
#include <string> #include <platform/input/Keyboard.h>
#include <platform/input/Keyboard.h> #include <util/StringUtils.h>
#include <util/StringUtils.h> #include "OptionsFile.h"
#include "OptionsFile.h" #include "Option.h"
#include "Option.h" #include <array>
#include <array>
enum OptionId {
enum OptionId { // General
// General OPTIONS_DIFFICULTY,
OPTIONS_DIFFICULTY, OPTIONS_HIDEGUI,
OPTIONS_HIDEGUI, OPTIONS_THIRD_PERSON_VIEW,
OPTIONS_THIRD_PERSON_VIEW, OPTIONS_GUI_SCALE,
OPTIONS_GUI_SCALE, OPTIONS_DESTROY_VIBRATION,
OPTIONS_DESTROY_VIBRATION, OPTIONS_MUSIC_VOLUME,
OPTIONS_MUSIC_VOLUME, OPTIONS_SOUND_VOLUME,
OPTIONS_SOUND_VOLUME, OPTIONS_SKIN,
OPTIONS_SKIN, OPTIONS_USERNAME,
OPTIONS_USERNAME, OPTIONS_SERVER_VISIBLE,
OPTIONS_SERVER_VISIBLE, OPTIONS_BAR_ON_TOP,
OPTIONS_BAR_ON_TOP, OPTIONS_ALLOW_SPRINT,
OPTIONS_ALLOW_SPRINT, OPTIONS_AUTOJUMP,
OPTIONS_AUTOJUMP,
// Graphics
// Graphics OPTIONS_RENDER_DEBUG,
OPTIONS_RENDER_DEBUG, OPTIONS_SMOOTH_CAMERA,
OPTIONS_SMOOTH_CAMERA, OPTIONS_FIXED_CAMERA,
OPTIONS_FIXED_CAMERA, OPTIONS_VIEW_DISTANCE,
OPTIONS_VIEW_DISTANCE, OPTIONS_VIEW_BOBBING,
OPTIONS_VIEW_BOBBING, OPTIONS_AMBIENT_OCCLUSION,
OPTIONS_AMBIENT_OCCLUSION, OPTIONS_ANAGLYPH_3D,
OPTIONS_ANAGLYPH_3D, OPTIONS_LIMIT_FRAMERATE,
OPTIONS_LIMIT_FRAMERATE, OPTIONS_VSYNC,
OPTIONS_VSYNC, OPTIONS_FANCY_GRAPHICS,
OPTIONS_FANCY_GRAPHICS,
// Cheats / debug
// Cheats / debug OPTIONS_FLY_SPEED,
OPTIONS_FLY_SPEED, OPTIONS_CAMERA_SPEED,
OPTIONS_CAMERA_SPEED, OPTIONS_IS_FLYING,
OPTIONS_IS_FLYING,
// Control
// Control OPTIONS_USE_MOUSE_FOR_DIGGING,
OPTIONS_USE_MOUSE_FOR_DIGGING, OPTIONS_IS_LEFT_HANDED,
OPTIONS_IS_LEFT_HANDED, OPTIONS_IS_JOY_TOUCH_AREA,
OPTIONS_IS_JOY_TOUCH_AREA, OPTIONS_SENSITIVITY,
OPTIONS_SENSITIVITY, OPTIONS_INVERT_Y_MOUSE,
OPTIONS_INVERT_Y_MOUSE, OPTIONS_USE_TOUCHSCREEN,
OPTIONS_USE_TOUCHSCREEN,
OPTIONS_KEY_FORWARD,
OPTIONS_KEY_FORWARD, OPTIONS_KEY_LEFT,
OPTIONS_KEY_LEFT, OPTIONS_KEY_BACK,
OPTIONS_KEY_BACK, OPTIONS_KEY_RIGHT,
OPTIONS_KEY_RIGHT, OPTIONS_KEY_JUMP,
OPTIONS_KEY_JUMP, OPTIONS_KEY_INVENTORY,
OPTIONS_KEY_INVENTORY, OPTIONS_KEY_SNEAK,
OPTIONS_KEY_SNEAK, OPTIONS_KEY_DROP,
OPTIONS_KEY_DROP, OPTIONS_KEY_CHAT,
OPTIONS_KEY_CHAT, OPTIONS_KEY_FOG,
OPTIONS_KEY_FOG, OPTIONS_KEY_USE,
OPTIONS_KEY_USE,
OPTIONS_KEY_MENU_NEXT,
OPTIONS_KEY_MENU_NEXT, OPTIONS_KEY_MENU_PREV,
OPTIONS_KEY_MENU_PREV, OPTIONS_KEY_MENU_OK,
OPTIONS_KEY_MENU_OK, OPTIONS_KEY_MENU_CANCEL,
OPTIONS_KEY_MENU_CANCEL,
OPTIONS_FIRST_LAUNCH,
OPTIONS_FIRST_LAUNCH, OPTIONS_LAST_IP,
OPTIONS_LAST_IP,
OPTIONS_RPI_CURSOR,
OPTIONS_RPI_CURSOR, // Should be last!
// Should be last! OPTIONS_COUNT
OPTIONS_COUNT };
};
class MinecraftClient;
class MinecraftClient; typedef std::vector<std::string> StringVector;
typedef std::vector<std::string> StringVector;
class Options
class Options {
{ public:
public: static bool debugGl;
static bool debugGl;
Options(MinecraftClient& minecraft, const std::string& workingDirectory = "")
Options(MinecraftClient& minecraft, const std::string& workingDirectory = "") : minecraft(minecraft) {
: minecraft(minecraft) { // elements werent initialized so i was getting a garbage pointer and a crash
// elements werent initialized so i was getting a garbage pointer and a crash m_options.fill(nullptr);
m_options.fill(nullptr); initTable();
initTable(); // load() is deferred to init() where path is configured correctly
// load() is deferred to init() where path is configured correctly }
}
void initTable();
void initTable();
int getIntValue(OptionId key) {
int getIntValue(OptionId key) { auto option = opt<OptionInt>(key);
auto option = opt<OptionInt>(key); return (option)? option->get() : 0;
return (option)? option->get() : 0; }
}
std::string getStringValue(OptionId key) {
std::string getStringValue(OptionId key) { auto option = opt<OptionString>(key);
auto option = opt<OptionString>(key); return (option)? option->get() : "";
return (option)? option->get() : ""; }
}
float getProgressValue(OptionId key) {
float getProgressValue(OptionId key) { auto option = opt<OptionFloat>(key);
auto option = opt<OptionFloat>(key); return (option)? option->get() : 0.f;
return (option)? option->get() : 0.f; }
}
bool getBooleanValue(OptionId key) {
bool getBooleanValue(OptionId key) { auto option = opt<OptionBool>(key);
auto option = opt<OptionBool>(key); return (option)? option->get() : false;
return (option)? option->get() : false; }
}
float getProgrssMin(OptionId key) {
float getProgrssMin(OptionId key) { auto option = opt<OptionFloat>(key);
auto option = opt<OptionFloat>(key); return (option)? option->getMin() : 0.f;
return (option)? option->getMin() : 0.f; }
}
float getProgrssMax(OptionId key) {
float getProgrssMax(OptionId key) { auto option = opt<OptionFloat>(key);
auto option = opt<OptionFloat>(key); return (option)? option->getMax() : 0.f;
return (option)? option->getMax() : 0.f; }
}
Option* getOpt(OptionId id) { return m_options[id]; }
Option* getOpt(OptionId id) { return m_options[id]; }
void load();
void load(); void save();
void save(); void set(OptionId key, int value);
void set(OptionId key, int value); void set(OptionId key, float value);
void set(OptionId key, float value); void set(OptionId key, const std::string& value);
void set(OptionId key, const std::string& value); void setOptionsFilePath(const std::string& path);
void setOptionsFilePath(const std::string& path); void toggle(OptionId key);
void toggle(OptionId key);
void notifyOptionUpdate(OptionId key, bool value);
void notifyOptionUpdate(OptionId key, bool value); void notifyOptionUpdate(OptionId key, float value);
void notifyOptionUpdate(OptionId key, float value); void notifyOptionUpdate(OptionId key, int value);
void notifyOptionUpdate(OptionId key, int value); void notifyOptionUpdate(OptionId key, const std::string& value) {}
void notifyOptionUpdate(OptionId key, const std::string& value) {}
private:
private: template<typename T>
template<typename T> T* opt(OptionId key) {
T* opt(OptionId key) { if (m_options[key] == nullptr) return nullptr;
if (m_options[key] == nullptr) return nullptr; return dynamic_cast<T*>(m_options[key]);
return dynamic_cast<T*>(m_options[key]); }
}
std::array<Option*, OPTIONS_COUNT> m_options;
std::array<Option*, OPTIONS_COUNT> m_options; OptionsFile optionsFile;
OptionsFile optionsFile;
MinecraftClient& minecraft;
MinecraftClient& minecraft; };
};
#endif /*NET_MINECRAFT_CLIENT__Options_H__*/

View File

@@ -1,21 +1,19 @@
#ifndef NET_MINECRAFT_CLIENT__OptionsFile_H__ #pragma once
#define NET_MINECRAFT_CLIENT__OptionsFile_H__
//package net.minecraft.client;
//package net.minecraft.client; #include <string>
#include <string> #include <vector>
#include <vector> typedef std::vector<std::string> StringVector;
typedef std::vector<std::string> StringVector; class OptionsFile
class OptionsFile {
{ public:
public: OptionsFile();
OptionsFile(); void save(const StringVector& settings);
void save(const StringVector& settings); StringVector getOptionStrings();
StringVector getOptionStrings(); void setOptionsPath(const std::string& path);
void setOptionsPath(const std::string& path); std::string getOptionsPath() const;
std::string getOptionsPath() const;
private:
private: std::string settingsPath;
std::string settingsPath; };
};
#endif /* NET_MINECRAFT_CLIENT__OptionsFile_H__ */

View File

@@ -1,124 +1,122 @@
#ifndef NET_MINECRAFT_CLIENT__Timer_H__ #pragma once
#define NET_MINECRAFT_CLIENT__Timer_H__
//package net.minecraft.client;
//package net.minecraft.client; #include "../platform/time.h"
#include "../platform/time.h"
class Timer
class Timer {
{ public:
public: Timer(float ticksPerSecond)
Timer(float ticksPerSecond) : ticksPerSecond(ticksPerSecond),
: ticksPerSecond(ticksPerSecond), adjustTime(1.0f),
adjustTime(1.0f), timeScale(1.0f),
timeScale(1.0f), passedTime(0)
passedTime(0) {
{ lastMs = getTimeMs();
lastMs = getTimeMs(); lastMsSysTime = lastMs;
lastMsSysTime = lastMs; lastTime = lastMs / 1000.0f;
lastTime = lastMs / 1000.0f; }
}
void advanceTime() {
void advanceTime() { long nowMs = getTimeMs();
long nowMs = getTimeMs(); long passedMs = nowMs - lastMs;
long passedMs = nowMs - lastMs; long msSysTime = nowMs;//System.nanoTime() / 1000000;
long msSysTime = nowMs;//System.nanoTime() / 1000000;
if (passedMs > 1000) {
if (passedMs > 1000) { long passedMsSysTime = msSysTime - lastMsSysTime;
long passedMsSysTime = msSysTime - lastMsSysTime; if (passedMsSysTime == 0)
if (passedMsSysTime == 0) passedMs = passedMsSysTime = 1;
passedMs = passedMsSysTime = 1;
float adjustTimeT = passedMs / (float) passedMsSysTime;
float adjustTimeT = passedMs / (float) passedMsSysTime; adjustTime += (adjustTimeT - adjustTime) * 0.2f;
adjustTime += (adjustTimeT - adjustTime) * 0.2f;
lastMs = nowMs;
lastMs = nowMs; lastMsSysTime = msSysTime;
lastMsSysTime = msSysTime; }
} if (passedMs < 0) {
if (passedMs < 0) { lastMs = nowMs;
lastMs = nowMs; lastMsSysTime = msSysTime;
lastMsSysTime = msSysTime; }
}
float now = msSysTime / 1000.0f;
float now = msSysTime / 1000.0f; float passedSeconds = (now - lastTime) * adjustTime;
float passedSeconds = (now - lastTime) * adjustTime; lastTime = now;
lastTime = now;
if (passedSeconds < 0) passedSeconds = 0;
if (passedSeconds < 0) passedSeconds = 0; if (passedSeconds > 1) passedSeconds = 1;
if (passedSeconds > 1) passedSeconds = 1; //LOGI("passed s: %f\n", passedSeconds);
//LOGI("passed s: %f\n", passedSeconds);
passedTime += passedSeconds * timeScale * ticksPerSecond;
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) passedTime;
ticks = (int) passedTime; passedTime -= ticks;
passedTime -= ticks; if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE;
if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE; a = passedTime;
a = passedTime; }
}
/**
/** * Advances time the max number of ticks per second.
* Advances time the max number of ticks per second. */
*/ void advanceTimeQuickly() {
void advanceTimeQuickly() {
float passedSeconds = (float) MAX_TICKS_PER_UPDATE / (float) ticksPerSecond;
float passedSeconds = (float) MAX_TICKS_PER_UPDATE / (float) ticksPerSecond;
passedTime += passedSeconds * timeScale * ticksPerSecond;
passedTime += passedSeconds * timeScale * ticksPerSecond; ticks = (int) passedTime;
ticks = (int) passedTime; passedTime -= ticks;
passedTime -= ticks; a = passedTime;
a = passedTime;
lastMs = getTimeMs();//System.currentTimeMillis();
lastMs = getTimeMs();//System.currentTimeMillis(); lastMsSysTime = lastMs;
lastMsSysTime = lastMs; }
}
void skipTime() {
void skipTime() { long nowMs = getTimeMs();//System.currentTimeMillis();
long nowMs = getTimeMs();//System.currentTimeMillis(); long passedMs = nowMs - lastMs;
long passedMs = nowMs - lastMs; long msSysTime = nowMs;//System.nanoTime() / 1000000;
long msSysTime = nowMs;//System.nanoTime() / 1000000;
if (passedMs > 1000) {
if (passedMs > 1000) { long passedMsSysTime = msSysTime - lastMsSysTime;
long passedMsSysTime = msSysTime - lastMsSysTime; if (passedMsSysTime == 0)
if (passedMsSysTime == 0) passedMs = passedMsSysTime = 1;
passedMs = passedMsSysTime = 1;
float adjustTimeT = passedMs / (float) passedMsSysTime;
float adjustTimeT = passedMs / (float) passedMsSysTime; adjustTime += (adjustTimeT - adjustTime) * 0.2f;
adjustTime += (adjustTimeT - adjustTime) * 0.2f;
lastMs = nowMs;
lastMs = nowMs; lastMsSysTime = msSysTime;
lastMsSysTime = msSysTime; }
} if (passedMs < 0) {
if (passedMs < 0) { lastMs = nowMs;
lastMs = nowMs; lastMsSysTime = msSysTime;
lastMsSysTime = msSysTime; }
}
float now = msSysTime / 1000.0f;
float now = msSysTime / 1000.0f; float passedSeconds = (now - lastTime) * adjustTime;
float passedSeconds = (now - lastTime) * adjustTime; lastTime = now;
lastTime = now;
if (passedSeconds < 0) passedSeconds = 0;
if (passedSeconds < 0) passedSeconds = 0; if (passedSeconds > 1) passedSeconds = 1;
if (passedSeconds > 1) passedSeconds = 1;
passedTime += passedSeconds * timeScale * ticksPerSecond;
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) 0;
ticks = (int) 0; if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE;
if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE; passedTime -= ticks;
passedTime -= ticks; }
}
public:
public: float ticksPerSecond;
float ticksPerSecond; int ticks;
int ticks; float a;
float a; float timeScale;
float timeScale; float passedTime;
float passedTime; private:
private: static const int MAX_TICKS_PER_UPDATE = 10;
static const int MAX_TICKS_PER_UPDATE = 10;
float lastTime;
float lastTime; long lastMs;
long lastMs; long lastMsSysTime;
long lastMsSysTime; float adjustTime;
float adjustTime; };
};
#endif /*NET_MINECRAFT_CLIENT__Timer_H__*/

View File

@@ -1,63 +1,61 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__Font_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__Font_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include <string>
#include <string> #include <cctype>
#include <cctype>
#include "../renderer/gles.h"
#include "../renderer/gles.h"
class Textures;
class Textures; class Options;
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();
void draw(const char* str, float x, float y, int color);
void draw(const char* str, float x, float y, int color); void draw(const std::string& str, float x, float y, int color);
void draw(const std::string& str, float x, float y, int color); void draw(const char* str, float x, float y, int color, bool darken);
void draw(const char* str, float x, float y, int color, bool darken); void draw(const std::string& str, float x, float y, int color, bool darken);
void draw(const std::string& str, float x, float y, int color, bool darken); void drawShadow(const std::string& str, float x, float y, int color);
void drawShadow(const std::string& str, float x, float y, int color); void drawShadow(const char* str, float x, float y, int color);
void drawShadow(const char* str, float x, float y, int color); void drawWordWrap(const std::string& str, float x, float y, float w, int col);
void drawWordWrap(const std::string& str, float x, float y, float w, int col);
int width(const std::string& str);
int width(const std::string& str); int height(const std::string& str);
int height(const std::string& str);
static std::string sanitize(const std::string& str);
static std::string sanitize(const std::string& str); private:
private: void buildChar(unsigned char i, float x = 0, float y = 0);
void buildChar(unsigned char i, float x = 0, float y = 0); void drawSlow(const std::string& str, float x, float y, int color, bool darken = false);
void drawSlow(const std::string& str, float x, float y, int color, bool darken = false); void drawSlow(const char* str, float x, float y, int color, bool darken = false);
void drawSlow(const char* str, float x, float y, int color, bool darken = false); public:
public: int fontTexture;
int fontTexture; int lineHeight;
int lineHeight; static const int DefaultLineHeight = 10;
static const int DefaultLineHeight = 10; private:
private: int charWidths[256];
int charWidths[256]; float fcharWidths[256];
float fcharWidths[256]; int listPos;
int listPos;
int index;
int index; int count;
int count; GLuint lists[1024];
GLuint lists[1024];
std::string fontName;
std::string fontName; Textures* _textures;
Textures* _textures;
Options* options;
Options* options;
int _x, _y;
int _x, _y; int _cols;
int _cols; int _rows;
int _rows; unsigned char _charOffset;
unsigned char _charOffset; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI__Font_H__*/

View File

@@ -1,133 +1,131 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__Gui_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__Gui_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include "GuiComponent.h"
#include "GuiComponent.h" #include "Font.h"
#include "Font.h" #include "../player/input/touchscreen/TouchAreaModel.h"
#include "../player/input/touchscreen/TouchAreaModel.h" #include "../renderer/RenderChunk.h"
#include "../renderer/RenderChunk.h" #include "../../util/Random.h"
#include "../../util/Random.h" #include "../IConfigListener.h"
#include "../IConfigListener.h"
class MinecraftClient;
class MinecraftClient; class ItemInstance;
class ItemInstance; class Textures;
class Textures; class Tesselator;
class Tesselator; struct IntRectangle;
struct IntRectangle;
struct GuiMessage
struct GuiMessage {
{ std::string message;
std::string message; int ticks;
int ticks; };
};
typedef std::vector<GuiMessage> GuiMessageList;
typedef std::vector<GuiMessage> GuiMessageList;
class Gui: public GuiComponent, IConfigListener
class Gui: public GuiComponent, IConfigListener {
{ public:
public: Gui(MinecraftClient& minecraft);
Gui(MinecraftClient& minecraft); ~Gui();
~Gui();
int getSlotIdAt(int x, int y);
int getSlotIdAt(int x, int y); void flashSlot(int slotId);
void flashSlot(int slotId); bool isInside(int x, int y);
bool isInside(int x, int y); RectangleArea getRectangleArea(int extendSide);
RectangleArea getRectangleArea(int extendSide); void getSlotPos(int slot, int& posX, int& posY);
void getSlotPos(int slot, int& posX, int& posY); int getNumSlots();
int getNumSlots();
void handleClick(int button, int x, int y);
void handleClick(int button, int x, int y); void handleKeyPressed( int key );
void handleKeyPressed( int key ); void scrollChat(int delta);
void scrollChat(int delta);
void tick();
void tick(); void render(float a, bool mouseFree, int xMouse, int yMouse);
void render(float a, bool mouseFree, int xMouse, int yMouse);
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 );
void addMessage(const std::string& string);
void addMessage(const std::string& string); void clearMessages();
void clearMessages(); void postError(int errCode);
void postError(int errCode);
void onGraphicsReset();
void onGraphicsReset(); void inventoryUpdated();
void inventoryUpdated();
void setNowPlaying(const std::string& string);
void setNowPlaying(const std::string& string); void displayClientMessage(const std::string& messageId);
void displayClientMessage(const std::string& messageId); void renderSlotText(const ItemInstance* item, float x, float y, bool hasFinite, bool shadow);
void renderSlotText(const ItemInstance* item, float x, float y, bool hasFinite, bool shadow); void texturesLoaded( Textures* textures );
void texturesLoaded( Textures* textures );
void onConfigChanged(const Config& config);
void onConfigChanged(const Config& config); void onLevelGenerated();
void onLevelGenerated();
void setScissorRect(const IntRectangle& rect);
void setScissorRect(const IntRectangle& rect);
static float floorAlignToScreenPixel(float);
static float floorAlignToScreenPixel(float); static int itemCountItoa(char* buf, int count);
static int itemCountItoa(char* buf, int count); private:
private: void renderVignette(float br, int w, int h);
void renderVignette(float br, int w, int h); void renderSlot(int slot, int x, int y, float a);
void renderSlot(int slot, int x, int y, float a); void tickItemDrop();
void tickItemDrop(); float cubeSmoothStep(float percentage, float min, float max);
float cubeSmoothStep(float percentage, float min, float max); public:
public: float progress = 0.f;
float progress = 0.f; std::string selectedName;
std::string selectedName; static float InvGuiScale;
static float InvGuiScale; static float GuiScale;
static float GuiScale;
private:
private: //ItemRenderer itemRenderer;
//ItemRenderer itemRenderer; GuiMessageList guiMessages;
GuiMessageList guiMessages; int chatScrollOffset = 0;
int chatScrollOffset = 0; Random random;
Random random;
MinecraftClient& minecraft;
MinecraftClient& minecraft; int tickCount = 0;
int tickCount = 0; float itemNameOverlayTime = 2;
float itemNameOverlayTime = 2; std::string overlayMessageString;
std::string overlayMessageString; int overlayMessageTime = 0;
int overlayMessageTime = 0; bool animateOverlayMessageColor = false;
bool animateOverlayMessageColor = false;
float tbr = 1.f;
float tbr = 1.f;
RenderChunk _inventoryRc;
RenderChunk _inventoryRc; bool _inventoryNeedsUpdate = true;
bool _inventoryNeedsUpdate = true;
int _flashSlotId = -1;
int _flashSlotId = -1; float _flashSlotStartTime = -1;
float _flashSlotStartTime = -1;
Font* _slotFont = nullptr;
Font* _slotFont = nullptr; int _numSlots = 4;
int _numSlots = 4;
RenderChunk rcFeedbackOuter;
RenderChunk rcFeedbackOuter; RenderChunk rcFeedbackInner;
RenderChunk rcFeedbackInner;
// For dropping
// For dropping static const float DropTicks;
static const float DropTicks; float _currentDropTicks = -1;
float _currentDropTicks = -1; int _currentDropSlot = -1;
int _currentDropSlot = -1;
bool _openInventorySlot;
bool _openInventorySlot; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI__Gui_H__*/

View File

@@ -1,34 +1,32 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include <string>
#include <string> class Font;
class Font; class Minecraft;
class Minecraft;
class GuiComponent
class GuiComponent {
{ public:
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);
protected:
protected: void fill(int x0, int y0, int x1, int y1, int col);
void fill(int x0, int y0, int x1, int y1, int col); void fill(float x0, float y0, float x1, float y1, int col);
void fill(float x0, float y0, float x1, float y1, int col); void fillGradient(int x0, int y0, int x1, int y1, int col1, int col2);
void fillGradient(int x0, int y0, int x1, int y1, int col1, int col2); void fillGradient(float x0, float y0, float x1, float y1, int col1, int col2);
void fillGradient(float x0, float y0, float x1, float y1, int col1, int col2); void fillHorizontalGradient(int x0, int y0, int x1, int y1, int col1, int col2);
void fillHorizontalGradient(int x0, int y0, int x1, int y1, int col1, int col2); 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;
};
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__*/

View File

@@ -1,83 +1,81 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__Screen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__Screen_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include <vector>
#include <vector> #include "GuiComponent.h"
#include "GuiComponent.h"
class Font;
class Font; class Minecraft;
class Minecraft; class Button;
class Button; class TextBox;
class TextBox; struct IntRectangle;
struct IntRectangle;
class Screen: public GuiComponent
class Screen: public GuiComponent {
{ public:
public: Screen();
Screen();
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(Minecraft* minecraft, int width, int height); virtual void init();
virtual void init();
void setSize(int width, int height);
void setSize(int width, int height); virtual void setupPositions() {};
virtual void setupPositions() {};
virtual void updateEvents();
virtual void updateEvents(); virtual void mouseEvent();
virtual void mouseEvent(); virtual void keyboardEvent();
virtual void keyboardEvent(); virtual void keyboardTextEvent();
virtual void keyboardTextEvent(); virtual bool handleBackEvent(bool isDown);
virtual bool handleBackEvent(bool isDown);
virtual void tick() {}
virtual void tick() {}
virtual void removed() {}
virtual void removed() {}
virtual void renderBackground();
virtual void renderBackground(); virtual void renderBackground(int vo);
virtual void renderBackground(int vo); virtual void renderDirtBackground(int vo);
virtual void renderDirtBackground(int vo); // query
// query virtual bool renderGameBehind();
virtual bool renderGameBehind(); virtual bool hasClippingArea(IntRectangle& out);
virtual bool hasClippingArea(IntRectangle& out);
virtual bool isPauseScreen();
virtual bool isPauseScreen(); virtual bool isErrorScreen();
virtual bool isErrorScreen(); virtual bool isInGameScreen();
virtual bool isInGameScreen(); virtual bool closeOnPlayerHurt();
virtual bool closeOnPlayerHurt();
virtual void confirmResult(bool result, int id) {}
virtual void confirmResult(bool result, int id) {} virtual void lostFocus();
virtual void lostFocus(); virtual void toGUICoordinate(int& x, int& y);
virtual void toGUICoordinate(int& x, int& y); protected:
protected: void updateTabButtonSelection();
void updateTabButtonSelection();
virtual void buttonClicked(Button* button) {}
virtual void buttonClicked(Button* button) {} virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseClicked(int x, int y, int buttonNum); virtual void mouseReleased(int x, int y, int buttonNum);
virtual void mouseReleased(int x, int y, int buttonNum);
// mouse wheel movement (dx/dy are wheel deltas, xm/ym are GUI coords)
// mouse wheel movement (dx/dy are wheel deltas, xm/ym are GUI coords) virtual void mouseWheel(int dx, int dy, int xm, int ym) {}
virtual void mouseWheel(int dx, int dy, int xm, int ym) {}
virtual void keyPressed(int eventKey);
virtual void keyPressed(int eventKey); virtual void charPressed(char inputChar);
virtual void charPressed(char inputChar); public:
public: int width;
int width; int height;
int height; bool passEvents;
bool passEvents; //GuiParticles* particles;
//GuiParticles* particles; protected:
protected: Minecraft* minecraft;
Minecraft* minecraft; std::vector<Button*> buttons;
std::vector<Button*> buttons; std::vector<TextBox*> textBoxes;
std::vector<TextBox*> textBoxes;
std::vector<Button*> tabButtons;
std::vector<Button*> tabButtons; int tabButtonIndex;
int tabButtonIndex;
Font* font;
Font* font; private:
private: Button* clickedButton;
Button* clickedButton; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI__Screen_H__*/

View File

@@ -1,11 +1,9 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__TweenData_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__TweenData_H__
typedef struct TweenData {
typedef struct TweenData { float cur;
float cur; float dur;
float dur; float start;
float start; float stop;
float stop; } TweenData;
} TweenData;
#endif /*NET_MINECRAFT_CLIENT_GUI__TweenData_H__*/

View File

@@ -1,80 +1,78 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include <string>
#include <string> #include "GuiElement.h"
#include "GuiElement.h" #include "../../Options.h"
#include "../../Options.h"
class Font;
class Font; class Minecraft;
class Minecraft;
class Button: public GuiElement
class Button: public GuiElement {
{ public:
public: Button(int id, const std::string& msg);
Button(int id, const std::string& msg); 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(Minecraft* minecraft, int xm, int ym);
virtual bool clicked(Minecraft* minecraft, int mx, int my);
virtual bool clicked(Minecraft* 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(Minecraft* minecraft, int xm, int ym);
virtual void renderFace(Minecraft* minecraft, int xm, int ym);
virtual void renderFace(Minecraft* minecraft, int xm, int ym); bool hovered(Minecraft* minecraft, int xm, int ym);
bool hovered(Minecraft* minecraft, int xm, int ym); public:
public: std::string msg;
std::string msg; int id;
int id;
bool selected;
bool selected; protected:
protected: bool _currentlyDown;
bool _currentlyDown; };
};
// @note: A bit backwards, but this is a button that
// @note: A bit backwards, but this is a button that // only reacts to clicks, but isn't rendered.
// only reacts to clicks, but isn't rendered. class BlankButton: public Button
class BlankButton: public Button {
{ typedef Button super;
typedef Button super; public:
public: BlankButton(int id);
BlankButton(int id); BlankButton(int id, int x, int y, int w, int h);
BlankButton(int id, int x, int y, int w, int h); };
};
namespace Touch {
namespace Touch { class TButton: public Button
class TButton: public Button {
{ typedef Button super;
typedef Button super; public:
public: TButton(int id, const std::string& msg);
TButton(int id, const std::string& msg); 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(Minecraft* minecraft, int xm, int ym); };
};
// "Header" in Touchscreen mode
// "Header" in Touchscreen mode class THeader: public Button {
class THeader: public Button { typedef Button super;
typedef Button super; public:
public: THeader(int id, const std::string& msg);
THeader(int id, const std::string& msg); 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(Minecraft* minecraft, int xm, int ym); void render( Minecraft* minecraft, int xm, int ym );
void render( Minecraft* minecraft, int xm, int ym ); public:
public: int xText;
int xText; };
}; }
}
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__*/

View File

@@ -1,55 +1,53 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__GButton_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__GButton_H__ #include "Button.h"
#include "Button.h"
class GButton: public Button {
class GButton: public Button { typedef Button super;
typedef Button super; public:
public: static const int LayerDefault = 1;
static const int LayerDefault = 1; static const int LayerSelected = 2;
static const int LayerSelected = 2; static const int LayerMax = 4;
static const int LayerMax = 4;
GButton(int id)
GButton(int id) : super(id, "")
: super(id, "") {}
{} ~GButton() {
~GButton() { for (unsigned int i = 0; i < layers.size(); ++i) {
for (unsigned int i = 0; i < layers.size(); ++i) { delete layers[i].first;
delete layers[i].first; }
} }
}
void addElement(int layerId, GuiElement* e) {
void addElement(int layerId, GuiElement* e) { if (!e || layerId < 0 || layerId >= LayerMax) {
if (!e || layerId < 0 || layerId >= LayerMax) { LOGE("Error @ GButton::element : Trying to add element %p at layer: %d\n", e, layerId);
LOGE("Error @ GButton::element : Trying to add element %p at layer: %d\n", e, layerId); return;
return; }
} 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( Minecraft* 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; if (layer < 0) return;
if (layer < 0) return;
Tesselator& t = Tesselator::instance;
Tesselator& t = Tesselator::instance; t.addOffset((float)x, (float)y, 0);
t.addOffset((float)x, (float)y, 0);
for (unsigned int i = 0; i < layers.size(); ++i) {
for (unsigned int i = 0; i < layers.size(); ++i) { if ((layers[i].second & layer) != 0)
if ((layers[i].second & layer) != 0) layers[i].first->render(minecraft, 0, 0);
layers[i].first->render(minecraft, 0, 0); }
}
t.addOffset((float)-x, (float)-y, 0);
t.addOffset((float)-x, (float)-y, 0); }
}
private:
private: std::vector<std::pair<GuiElement*, int> > layers;
std::vector<std::pair<GuiElement*, int> > layers; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GButton_H__*/

View File

@@ -1,34 +1,32 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__GuiElement_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__GuiElement_H__ #include "../GuiComponent.h"
#include "../GuiComponent.h"
class Tesselator;
class Tesselator; class Minecraft;
class Minecraft;
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(Minecraft* minecraft) {} virtual void render(Minecraft* minecraft, int xm, int ym) { }
virtual void render(Minecraft* 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(Minecraft* minecraft, int x, int y, int buttonNum) {} virtual void mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum) {}
virtual void mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum) {} virtual void keyPressed(Minecraft* minecraft, int key) {}
virtual void keyPressed(Minecraft* minecraft, int key) {} virtual void charPressed(Minecraft* minecraft, char key) {}
virtual void charPressed(Minecraft* minecraft, char key) {}
virtual bool pointInside(int x, int y);
virtual bool pointInside(int x, int y);
void setVisible(bool visible);
void setVisible(bool visible);
bool active;
bool active; bool visible;
bool visible; int x;
int x; int y;
int y; int width;
int width; int height;
int height; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiElement_H__*/

View File

@@ -1,28 +1,26 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__GuiElementContainer_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__GuiElementContainer_H__ #include "GuiElement.h"
#include "GuiElement.h" #include <vector>
#include <vector> class Tesselator;
class Tesselator; class Minecraft;
class Minecraft;
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(Minecraft* 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( Minecraft* minecraft );
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum ); virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ); virtual void keyPressed(Minecraft* minecraft, int key);
virtual void keyPressed(Minecraft* minecraft, int key); virtual void charPressed(Minecraft* minecraft, char key);
virtual void charPressed(Minecraft* minecraft, char key);
protected:
protected: std::vector<GuiElement*> children;
std::vector<GuiElement*> children; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiElementContainer_H__*/

View File

@@ -1,97 +1,95 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ImageButton_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ImageButton_H__
#include "Button.h"
#include "Button.h"
typedef struct IntRectangle {
typedef struct IntRectangle { IntRectangle()
IntRectangle() : x(0),
: x(0), y(0),
y(0), w(1),
w(1), h(1)
h(1) {}
{} IntRectangle(int x, int y, int w, int h)
IntRectangle(int x, int y, int w, int h) : x(x),
: x(x), y(y),
y(y), w(w),
w(w), h(h)
h(h) {}
{}
int x, y;
int x, y; int w, h;
int w, h; } IntRectangle;
} IntRectangle;
typedef struct ImageDef {
typedef struct ImageDef { ImageDef()
ImageDef() : hasSrc(false),
: hasSrc(false), x(0),
x(0), y(0),
y(0), width(16),
width(16), height(16)
height(16) {}
{}
std::string name;
std::string name; int x;
int x; int y;
int y; float width;
float width; float height;
float height;
ImageDef& setSrc(const IntRectangle& srcRect) {
ImageDef& setSrc(const IntRectangle& srcRect) { hasSrc = true;
hasSrc = true; src = srcRect;
src = srcRect; return *this;
return *this; }
} IntRectangle* getSrc() {
IntRectangle* getSrc() { return hasSrc? &src : NULL;
return hasSrc? &src : NULL; }
} protected:
protected: IntRectangle src;
IntRectangle src; bool hasSrc;
bool hasSrc; } ImageDef;
} ImageDef;
class ImageButton: public Button
class ImageButton: public Button {
{ typedef Button super;
typedef Button super; public:
public: ImageButton(int id, const std::string& msg);
ImageButton(int id, const std::string& msg); 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(Minecraft* minecraft, int xm, int ym); void renderBg(Minecraft* minecraft, int xm, int ym) {}
void renderBg(Minecraft* minecraft, int xm, int ym) {}
protected:
protected: virtual void setupDefault();
virtual void setupDefault(); virtual bool isSecondImage(bool hovered) { return hovered; }
virtual bool isSecondImage(bool hovered) { return hovered; }
ImageDef _imageDef;
ImageDef _imageDef; public:
public: bool scaleWhenPressed;
bool scaleWhenPressed; };
};
//
// // A toggleable Button
// A toggleable Button //
// class OptionButton: public ImageButton
class OptionButton: public ImageButton {
{ typedef ImageButton super;
typedef ImageButton super; public:
public: OptionButton(OptionId optId);
OptionButton(OptionId optId);
void toggle(Options* options);
void toggle(Options* options); void updateImage(Options* options);
void updateImage(Options* options);
static const int ButtonId = 9999999;
static const int ButtonId = 9999999; 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( Minecraft* minecraft, int x, int y, int buttonNum );
private:
private: OptionId m_optId;
OptionId m_optId; bool _secondImage;
bool _secondImage; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ImageButton_H__*/

View File

@@ -1,62 +1,60 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__InventoryPane_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__InventoryPane_H__
#include "ScrollingPane.h"
#include "ScrollingPane.h" #include "ImageButton.h"
#include "ImageButton.h"
class Minecraft;
class Minecraft; class ItemInstance;
class ItemInstance; class Font;
class Font; class IArea;
class IArea;
namespace Touch {
namespace Touch {
class IInventoryPaneCallback;
class IInventoryPaneCallback;
class InventoryPane: public ScrollingPane
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, Minecraft* mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize); ~InventoryPane();
~InventoryPane();
void tick();
void tick(); void renderBatch( std::vector<GridItem>& item, float alpha );
void renderBatch( std::vector<GridItem>& item, float alpha ); bool onSelect( int gridId, bool selected );
bool onSelect( int gridId, bool selected ); void drawScrollBar( ScrollBar& hScroll );
void drawScrollBar( ScrollBar& hScroll );
void setRenderDecorations(bool value);
void setRenderDecorations(bool value);
IntRectangle rect;
IntRectangle rect; int paneWidth;
int paneWidth; IArea* _clickArea;
IArea* _clickArea; IInventoryPaneCallback* screen;
IInventoryPaneCallback* screen; Minecraft* mc;
Minecraft* mc;
int fillMarginX;
int fillMarginX; int fillMarginY;
int fillMarginY;
int markerType;
int markerType; int markerIndex;
int markerIndex; float markerShare;
float markerShare; private:
private: int lastItemIndex;
int lastItemIndex; int lastItemTicks;
int lastItemTicks; int BorderPixels;
int BorderPixels; bool renderDecorations;
bool renderDecorations;
IntRectangle bg;
IntRectangle bg; };
};
class IInventoryPaneCallback
class IInventoryPaneCallback {
{ public:
public: virtual ~IInventoryPaneCallback() {}
virtual ~IInventoryPaneCallback() {} virtual bool addItem(const InventoryPane* forPane, int index) = 0;
virtual bool addItem(const InventoryPane* forPane, int index) = 0; virtual bool isAllowed( int slot ) = 0;
virtual bool isAllowed( int slot ) = 0; virtual std::vector<const ItemInstance*> getItems(const InventoryPane* forPane) = 0;
virtual std::vector<const ItemInstance*> getItems(const InventoryPane* forPane) = 0; };
};
}
}
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__InventoryPane_H__*/

View File

@@ -1,95 +1,93 @@
#ifndef ITEMPANE_H__ #pragma once
#define ITEMPANE_H__
#include <string>
#include <string> #include <vector>
#include <vector> #include "ScrollingPane.h"
#include "ScrollingPane.h" #include "../../../world/item/ItemInstance.h"
#include "../../../world/item/ItemInstance.h"
class Font;
class Font; class Textures;
class Textures; class NinePatchLayer;
class NinePatchLayer; class Recipe;
class Recipe; class ItemPane;
class ItemPane;
class CItem
class CItem {
{ public:
public: CItem(const ItemInstance& ins, Recipe* recipe, const std::string& text)
CItem(const ItemInstance& ins, Recipe* recipe, const std::string& text) : item(ins),
: item(ins), recipe(recipe),
recipe(recipe), text(text),
text(text), sortText(text),
sortText(text), //maxBuildCount(0),
//maxBuildCount(0), numBuilt(0),
numBuilt(0), inventoryCount(0),
inventoryCount(0), _canCraft(false)
_canCraft(false) {
{ }
}
typedef struct ReqItem {
typedef struct ReqItem { ReqItem() {}
ReqItem() {} ReqItem(const ItemInstance& needItem, int has)
ReqItem(const ItemInstance& needItem, int has) : item(needItem), has(has) {}
: item(needItem), has(has) {} ItemInstance item;
ItemInstance item; int has;
int has; bool enough() { return has >= item.count; }
bool enough() { return has >= item.count; } } ReqItem;
} ReqItem;
bool canCraft() {
bool canCraft() { return _canCraft;// || maxBuildCount > 0;
return _canCraft;// || maxBuildCount > 0; }
} void setCanCraft(bool status) {
void setCanCraft(bool status) { _canCraft = status;
_canCraft = status; }
}
ItemInstance item;
ItemInstance item; Recipe* recipe;
Recipe* recipe; std::string text;
std::string text; std::string sortText;
std::string sortText; //int maxBuildCount;
//int maxBuildCount; int numBuilt;
int numBuilt; int inventoryCount;
int inventoryCount; std::vector<ReqItem> neededItems;
std::vector<ReqItem> neededItems; private:
private: bool _canCraft;
bool _canCraft; };
};
class IItemPaneCallback
class IItemPaneCallback {
{ public:
public: virtual ~IItemPaneCallback() {}
virtual ~IItemPaneCallback() {} virtual void onItemSelected(const ItemPane* forPane, int index) = 0;
virtual void onItemSelected(const ItemPane* forPane, int index) = 0; virtual const std::vector<CItem*>& getItems(const ItemPane* forPane) = 0;
virtual const std::vector<CItem*>& getItems(const ItemPane* forPane) = 0; };
};
class ItemPane: public ScrollingPane
class ItemPane: public ScrollingPane {
{ typedef ScrollingPane super;
typedef ScrollingPane super; public:
public: ItemPane( IItemPaneCallback* screen,
ItemPane( IItemPaneCallback* screen, Textures* textures,
Textures* textures, const IntRectangle& rect,
const IntRectangle& rect, int numItems,
int numItems, int guiHeight,
int guiHeight, int physicalScreenHeight,
int physicalScreenHeight, bool isVertical = true);
bool isVertical = true); ~ItemPane();
~ItemPane();
void renderBatch( std::vector<GridItem>& item, float alpha );
void renderBatch( std::vector<GridItem>& item, float alpha ); bool onSelect( int gridId, bool selected );
bool onSelect( int gridId, bool selected ); void drawScrollBar( ScrollBar& hScroll );
void drawScrollBar( ScrollBar& hScroll ); //void setSize()
//void setSize()
Font* f;
Font* f; Textures* textures;
Textures* textures; IItemPaneCallback* screen;
IItemPaneCallback* screen;
int physicalScreenHeight; // Needed for glScissor
int physicalScreenHeight; // Needed for glScissor bool isVertical;
bool isVertical;
NinePatchLayer* guiSlotItem;
NinePatchLayer* guiSlotItem; NinePatchLayer* guiSlotItemSelected;
NinePatchLayer* guiSlotItemSelected; };
};
#endif /*ITEMPANE_H__*/

View File

@@ -1,21 +1,19 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__LargeImageButton_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__LargeImageButton_H__
#include "ImageButton.h"
#include "ImageButton.h"
class LargeImageButton: public ImageButton
class LargeImageButton: public ImageButton {
{ typedef ImageButton super;
typedef ImageButton super; public:
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(Minecraft* minecraft, int xm, int ym);
private:
private: void setupDefault();
void setupDefault();
float _buttonScale;
float _buttonScale; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__LargeImageButton_H__*/

View File

@@ -1,78 +1,76 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__NinePatch_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__NinePatch_H__
#include "ImageButton.h"
#include "ImageButton.h" #include "../../renderer/TextureData.h"
#include "../../renderer/TextureData.h" #include "../../renderer/Textures.h"
#include "../../renderer/Textures.h" #include "../../renderer/Tesselator.h"
#include "../../renderer/Tesselator.h" #include "../../Minecraft.h"
#include "../../Minecraft.h"
class Tesselator;
class Tesselator;
class NinePatchDescription {
class NinePatchDescription { public:
public: NinePatchDescription& transformUVForImage(const TextureData& d);
NinePatchDescription& transformUVForImage(const TextureData& d); NinePatchDescription& transformUVForImageSize(int w, int h);
NinePatchDescription& transformUVForImageSize(int w, int h);
float u0, u1, u2, u3;
float u0, u1, u2, u3; float v0, v1, v2, v3;
float v0, v1, v2, v3; float w, e, n, s;
float w, e, n, s;
static NinePatchDescription createSymmetrical(int texWidth, int texHeight, const IntRectangle& src, int xCutAt, int yCutAt);
static NinePatchDescription createSymmetrical(int texWidth, int texHeight, const IntRectangle& src, int xCutAt, int yCutAt); private:
private: NinePatchDescription( float x, float y, float x1, float x2, float x3, float y1, float y2, float y3,
NinePatchDescription( float x, float y, float x1, float x2, float x3, float y1, float y2, float y3, float w, float e, float n, float s);
float w, float e, float n, float s);
int imgW;
int imgW; int imgH;
int imgH; };
};
class NinePatchLayer: public GuiElement
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);
void draw(Tesselator& t, float x, float y);
void draw(Tesselator& t, float x, float y);
NinePatchLayer* exclude(int excludeId);
NinePatchLayer* exclude(int excludeId); NinePatchLayer* setExcluded(int exludeBits);
NinePatchLayer* setExcluded(int exludeBits);
float getWidth() { return w; }
float getWidth() { return w; } float getHeight() { return h; }
float getHeight() { return h; }
private:
private: void buildQuad(int qid);
void buildQuad(int qid); void getPatchInfo(int xc, int yc, float& x0, float& x1, float& y0, float& y1);
void getPatchInfo(int xc, int yc, float& x0, float& x1, float& y0, float& y1);
void d(Tesselator& t, const CachedQuad& q);
void d(Tesselator& t, const CachedQuad& q);
float w, h;
float w, h; NinePatchDescription desc;
NinePatchDescription desc; std::string imageName;
std::string imageName; Textures* textures;
Textures* textures; int excluded;
int excluded;
typedef struct CachedQuad {
typedef struct CachedQuad { float x0, x1, y0, y1, z;
float x0, x1, y0, y1, z; float u0, u1, v0, v1;
float u0, u1, v0, v1; } CachedQuad;
} CachedQuad; CachedQuad quads[9];
CachedQuad quads[9]; };
};
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; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI__NinePatch_H__*/

View File

@@ -1,32 +1,30 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include <string>
#include <string> #include "GuiElementContainer.h"
#include "GuiElementContainer.h" #include "ScrollingPane.h"
#include "ScrollingPane.h" #include "../../Options.h"
#include "../../Options.h"
class Font;
class Font; class Minecraft;
class Minecraft;
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(Minecraft* minecraft, int xm, int ym); OptionsGroup& addOptionItem(OptionId optId, Minecraft* minecraft);
OptionsGroup& addOptionItem(OptionId optId, Minecraft* minecraft); protected:
protected:
void createToggle(OptionId optId, Minecraft* minecraft);
void createToggle(OptionId optId, Minecraft* minecraft); void createProgressSlider(OptionId optId, Minecraft* minecraft);
void createProgressSlider(OptionId optId, Minecraft* minecraft); void createStepSlider(OptionId optId, Minecraft* minecraft);
void createStepSlider(OptionId optId, Minecraft* minecraft); void createTextbox(OptionId optId, Minecraft* minecraft);
void createTextbox(OptionId optId, Minecraft* minecraft); void createKey(OptionId optId, Minecraft* minecraft);
void createKey(OptionId optId, Minecraft* minecraft);
std::string label;
std::string label; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__*/

View File

@@ -1,27 +1,25 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsItem_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsItem_H__
#include <string>
#include <string> #include <vector>
#include <vector> #include "GuiElementContainer.h"
#include "GuiElementContainer.h" #include "../../../world/item/ItemInstance.h"
#include "../../../world/item/ItemInstance.h" #include "../../../client/Options.h"
#include "../../../client/Options.h" class Font;
class Font; class Textures;
class Textures; class NinePatchLayer;
class NinePatchLayer; class ItemPane;
class ItemPane;
class OptionsItem: public GuiElementContainer
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(Minecraft* minecraft, int xm, int ym); void setupPositions();
void setupPositions();
private:
private: OptionId m_optionId;
OptionId m_optionId; std::string m_label;
std::string m_label; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsItem_H__*/

View File

@@ -1,82 +1,80 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListH_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListH_H__
#include "../GuiComponent.h"
#include "../GuiComponent.h" class MinecraftClient;
class MinecraftClient; class Tesselator;
class Tesselator;
class RolledSelectionListH : public GuiComponent
class RolledSelectionListH : public GuiComponent {
{ static const int NO_DRAG = -1;
static const int NO_DRAG = -1; 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: RolledSelectionListH(MinecraftClient& 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);
virtual int getItemAtPosition(int x, int y);
virtual bool capXPosition();
virtual bool capXPosition();
virtual void tick();
virtual void tick(); virtual void render(int xm, int ym, float a);
virtual void render(int xm, int ym, float a); virtual void renderHoleBackground(/*float x0, float x1,*/ float y0, float y1, int a0, int a1);
virtual void renderHoleBackground(/*float x0, float x1,*/ float y0, float y1, int a0, int a1); virtual void setRenderSelection(bool _renderSelection);
virtual void setRenderSelection(bool _renderSelection); virtual void setComponentSelected(bool selected);
virtual void setComponentSelected(bool selected); protected:
protected: void setRenderHeader(bool _renderHeader, int _headerHeight);
void setRenderHeader(bool _renderHeader, int _headerHeight);
virtual int getNumberOfItems() = 0;
virtual int getNumberOfItems() = 0;
virtual void selectStart(int item, int localX, int localY) {}
virtual void selectStart(int item, int localX, int localY) {} virtual void selectCancel() {}
virtual void selectCancel() {} virtual void selectItem(int item, bool doubleClick) = 0;
virtual void selectItem(int item, bool doubleClick) = 0; virtual bool isSelectedItem(int item) = 0;
virtual bool isSelectedItem(int item) = 0;
virtual int getMaxPosition();
virtual int getMaxPosition(); virtual float getPos(float alpha);
virtual float getPos(float alpha); virtual void touched();
virtual void touched();
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0;
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0; virtual void renderHeader(int x, int y, Tesselator& t) {}
virtual void renderHeader(int x, int y, Tesselator& t) {} virtual void renderBackground() = 0;
virtual void renderBackground() = 0; virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {} int getItemAtXPositionRaw(int x);
int getItemAtXPositionRaw(int x); protected:
protected: MinecraftClient& minecraft;
MinecraftClient& minecraft;
float x0;
float x0; float x1;
float x1; int itemWidth;
int itemWidth; int width;
int width; int height;
int height; //private:
//private: float y0;
float y0; float y1;
float y1;
int dragState;
int dragState; float xDrag;
float xDrag; float xo;
float xo; float xoo;
float xoo; float xInertia;
float xInertia; float _xinertia;
float _xinertia;
int selectionX;
int selectionX; bool renderSelection;
bool renderSelection; bool _componentSelected;
bool _componentSelected;
bool _renderTopBorder;
bool _renderTopBorder; bool _renderBottomBorder;
bool _renderBottomBorder;
private:
private: int headerWidth;
int headerWidth; bool doRenderHeader;
bool doRenderHeader; long lastSelectionTime;
long lastSelectionTime; int lastSelection;
int lastSelection;
float _lastxoo;
float _lastxoo; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListH_H__*/

View File

@@ -1,94 +1,92 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListV_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListV_H__
#include "../GuiComponent.h"
#include "../GuiComponent.h" class Minecraft;
class Minecraft; class Tesselator;
class Tesselator;
class RolledSelectionListV : public GuiComponent
class RolledSelectionListV : public GuiComponent {
{ static const int NO_DRAG = -1;
static const int NO_DRAG = -1; 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(Minecraft* 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);
virtual bool capYPosition();
virtual bool capYPosition();
virtual void tick();
virtual void tick(); virtual void render(int xm, int ym, float a);
virtual void render(int xm, int ym, float a); virtual void renderHoleBackground(/*float x0, float x1,*/ float y0, float y1, int a0, int a1);
virtual void renderHoleBackground(/*float x0, float x1,*/ float y0, float y1, int a0, int a1); virtual void setRenderSelection(bool _renderSelection);
virtual void setRenderSelection(bool _renderSelection); virtual void setComponentSelected(bool selected);
virtual void setComponentSelected(bool selected); protected:
protected: void setRenderHeader(bool _renderHeader, int _headerHeight);
void setRenderHeader(bool _renderHeader, int _headerHeight);
virtual int getNumberOfItems() = 0;
virtual int getNumberOfItems() = 0;
virtual void selectStart(int item) {}
virtual void selectStart(int item) {} virtual void selectCancel() {}
virtual void selectCancel() {} virtual void selectItem(int item, bool doubleClick) = 0;
virtual void selectItem(int item, bool doubleClick) = 0; virtual bool isSelectedItem(int item) = 0;
virtual bool isSelectedItem(int item) = 0;
virtual int getMaxPosition();
virtual int getMaxPosition(); virtual float getPos(float alpha);
virtual float getPos(float alpha); virtual void touched();
virtual void touched();
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0;
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0; virtual void renderHeader(int x, int y, Tesselator& t) {}
virtual void renderHeader(int x, int y, Tesselator& t) {} virtual void renderBackground() = 0;
virtual void renderBackground() = 0; virtual void renderForeground() {}
virtual void renderForeground() {} virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {} virtual int convertSelection(int item, int xm, int ym) { return item; }
virtual int convertSelection(int item, int xm, int ym) { return item; }
int getItemAtYPositionRaw(int y);
int getItemAtYPositionRaw(int y); void evaluate(int xm, int ym);
void evaluate(int xm, int ym); virtual void onPreRender();
virtual void onPreRender(); virtual void onPostRender();
virtual void onPostRender(); void renderDirtBackground();
void renderDirtBackground(); protected:
protected: Minecraft* minecraft;
Minecraft* minecraft;
float x0;
float x0; float x1;
float x1; int itemHeight;
int itemHeight; int width;
int width; int height;
int height; //private:
//private: float y0;
float y0; float y1;
float y1;
int dragState;
int dragState; float yDrag;
float yDrag; float yo;
float yo; float yoo;
float yoo; float yInertia;
float yInertia; float _yinertia;
float _yinertia;
int selectionY;
int selectionY; bool renderSelection;
bool renderSelection; bool _componentSelected;
bool _componentSelected;
bool _renderDirtBackground;
bool _renderDirtBackground; bool _renderTopBorder;
bool _renderTopBorder; bool _renderBottomBorder;
bool _renderBottomBorder;
int _lastxm;
int _lastxm; int _lastym;
int _lastym; private:
private: int headerHeight;
int headerHeight; bool doRenderHeader;
bool doRenderHeader; long lastSelectionTime;
long lastSelectionTime; int lastSelection;
int lastSelection;
float _lastyoo;
float _lastyoo;
float _stickPixels;
float _stickPixels; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__RolledSelectionListV_H__*/

View File

@@ -1,69 +1,67 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrolledSelectionList_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrolledSelectionList_H__
#include "../GuiComponent.h"
#include "../GuiComponent.h" class Minecraft;
class Minecraft; class Tesselator;
class Tesselator;
class ScrolledSelectionList : public GuiComponent
class ScrolledSelectionList : public GuiComponent {
{ static const int NO_DRAG = -1;
static const int NO_DRAG = -1; static const int DRAG_OUTSIDE = -2;
static const int DRAG_OUTSIDE = -2; 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(Minecraft* _minecraft, int _width, int _height, int _y0, int _y1, int _itemHeight);
virtual void setRenderSelection(bool _renderSelection);
virtual void setRenderSelection(bool _renderSelection); protected:
protected: void setRenderHeader(bool _renderHeader, int _headerHeight);
void setRenderHeader(bool _renderHeader, int _headerHeight);
virtual int getNumberOfItems() = 0;
virtual int getNumberOfItems() = 0;
virtual void selectItem(int item, bool doubleClick) = 0;
virtual void selectItem(int item, bool doubleClick) = 0; virtual bool isSelectedItem(int item) = 0;
virtual bool isSelectedItem(int item) = 0;
virtual int getMaxPosition();
virtual int getMaxPosition();
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0;
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) = 0; virtual void renderHeader(int x, int y, Tesselator& t) {}
virtual void renderHeader(int x, int y, Tesselator& t) {} virtual void renderBackground() = 0;
virtual void renderBackground() = 0; virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void renderDecorations(int mouseX, int mouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {}
virtual void clickedHeader(int headerMouseX, int headerMouseY) {} public:
public: virtual int getItemAtPosition(int x, int y);
virtual int getItemAtPosition(int x, int y);
virtual void capYPosition();
virtual void capYPosition();
virtual void render(int xm, int ym, float a);
virtual void render(int xm, int ym, float a); 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;
Minecraft* minecraft;
float y0;
float y0; float y1;
float y1; int itemHeight;
int itemHeight; private:
private: int width;
int width; int height;
int height; float x1;
float x1; float x0;
float x0;
int ignoreY; // new attempt to fix android jump bug
int ignoreY; // new attempt to fix android jump bug int dragState;
int dragState; float yDrag;
float yDrag; float yo;
float yo; float yInertia;
float yInertia;
int selectionY;
int selectionY; long lastSelectionTime;
long lastSelectionTime;
bool renderSelection;
bool renderSelection; bool doRenderHeader;
bool doRenderHeader; int headerHeight;
int headerHeight; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrolledSelectionList_H__*/

View File

@@ -1,203 +1,201 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrollingPane_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrollingPane_H__
#include "../GuiComponent.h"
#include "../GuiComponent.h" #include "ImageButton.h"
#include "ImageButton.h" #include "../../player/input/touchscreen/TouchAreaModel.h"
#include "../../player/input/touchscreen/TouchAreaModel.h" #include "../../../world/phys/Vec3.h"
#include "../../../world/phys/Vec3.h" #include "../../Timer.h"
#include "../../Timer.h"
enum ScrollingPaneFlags {
enum ScrollingPaneFlags { SF_LockX = 1 << 0,
SF_LockX = 1 << 0, SF_LockY = 1 << 1,
SF_LockY = 1 << 1, SF_WrapX = 1 << 2,
SF_WrapX = 1 << 2, SF_WrapY = 1 << 3,
SF_WrapY = 1 << 3, SF_HardLimits = 1 << 4,
SF_HardLimits = 1 << 4, SF_MultiSelect = 1 << 5,
SF_MultiSelect = 1 << 5, //SF_Snap = 1 << 6,
//SF_Snap = 1 << 6, //SF_CustomSnap = 1 << 7,
//SF_CustomSnap = 1 << 7, //SF_Scissor = 1 << 8,
//SF_Scissor = 1 << 8, SF_ShowScrollbar= 1 << 9,
SF_ShowScrollbar= 1 << 9, SF_NoHoldSelect = 1 << 10
SF_NoHoldSelect = 1 << 10 };
};
typedef struct ScrollBar {
typedef struct ScrollBar { ScrollBar()
ScrollBar() : alpha(0),
: alpha(0), fading(-1)
fading(-1) {}
{} float x;
float x; float y;
float y; float w;
float w; float h;
float h; //bool visible;
//bool visible; float alpha;
float alpha; int fading;
int fading; } ScrollBar;
} ScrollBar;
class ScrollingPane: public GuiComponent {
class ScrollingPane: public GuiComponent { public:
public: typedef struct GridItem {
typedef struct GridItem { int id;
int id; int x, y;
int x, y; // The GUI coordinates comes in (xf, yf)
// The GUI coordinates comes in (xf, yf) float xf, yf;
float xf, yf; bool selected;
bool selected; } GridItem;
} GridItem;
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(Minecraft*, int width, int height); void tick();
void tick(); void render(int xm, int ym, float alpha);
void render(int xm, int ym, float alpha);
// scroll the content by the given amount (dx horizontal, dy vertical)
// scroll the content by the given amount (dx horizontal, dy vertical) // positive values move content downward/rightward
// positive values move content downward/rightward void scrollBy(float dx, float dy);
void scrollBy(float dx, float dy);
bool getGridItemFor_slow(int itemIndex, GridItem& out);
bool getGridItemFor_slow(int itemIndex, GridItem& out);
void setSelected(int id, bool selected);
void setSelected(int id, bool selected);
// This function is called with all visible GridItems. The base
// This function is called with all visible GridItems. The base // implementation just dispatches each item to renderItem in y,x order
// implementation just dispatches each item to renderItem in y,x order virtual void renderBatch(std::vector<GridItem>& items, float alpha);
virtual void renderBatch(std::vector<GridItem>& items, float alpha); virtual void renderItem(GridItem& item, float alpha);
virtual void renderItem(GridItem& item, float alpha);
//void render(int xx, int yy);
//void render(int xx, int yy); bool queryHoldTime(int* gridId, int* heldMs);
bool queryHoldTime(int* gridId, int* heldMs);
protected:
protected: GridItem getItemForPos(float x, float y, bool isScreenPos);
GridItem getItemForPos(float x, float y, bool isScreenPos); void handleUserInput();
void handleUserInput(); void addDeltaPos(float x, float y, float dt, int z);
void addDeltaPos(float x, float y, float dt, int z);
void translate(float xo, float yo);
void translate(float xo, float yo);
int flags;
int flags;
int columns;
int columns; int rows;
int rows; int numItems;
int numItems;
int px, py;
int px, py; float fpx, fpy;
float fpx, fpy;
float screenScale;
float screenScale; float invScreenScale;
float invScreenScale; //bool hasItemBounding;
//bool hasItemBounding;
IntRectangle bbox;
IntRectangle bbox; IntRectangle itemRect;
IntRectangle itemRect; IntRectangle itemBbox;
IntRectangle itemBbox; RectangleArea area;
RectangleArea area; RectangleArea bboxArea;
RectangleArea bboxArea;
// Dragging info
// Dragging info std::vector<float> dragDeltas;
std::vector<float> dragDeltas; int dragState;
int dragState; Vec3 dragBeginPos;
Vec3 dragBeginPos; Vec3 dragBeginScreenPos;
Vec3 dragBeginScreenPos; int dragTicks;
int dragTicks; float dragLastDeltaTimeStamp;
float dragLastDeltaTimeStamp; Vec3 dragLastPos;
Vec3 dragLastPos;
float dx, dy;
float dx, dy; float friction;
float friction;
float dstx, dsty;
float dstx, dsty;
// Rewrite
// Rewrite bool dragging; //!
bool dragging; //! bool decelerating;
bool decelerating; bool tracking; //!
bool tracking; //!
bool pagingEnabled; //!
bool pagingEnabled; //!
Vec3 _contentOffset; //!
Vec3 _contentOffset; //! Vec3 _contentOffsetBeforeDeceleration; //*
Vec3 _contentOffsetBeforeDeceleration; //*
int lastEventTime; //<
int lastEventTime; //<
Vec3 decelerationVelocity; //*
Vec3 decelerationVelocity; //* Vec3 minDecelerationPoint; //*
Vec3 minDecelerationPoint; //* Vec3 maxDecelerationPoint; //*
Vec3 maxDecelerationPoint; //*
float penetrationDeceleration; //<
float penetrationDeceleration; //< float penetrationAcceleration; //<
float penetrationAcceleration; //<
Vec3 minPoint; //*
Vec3 minPoint; //* Vec3 startPosition; //*
Vec3 startPosition; //* Vec3 startTouchPosition; //*
Vec3 startTouchPosition; //* Vec3 startTimePosition; //*
Vec3 startTimePosition; //*
bool wasDeceleratingWhenTouchesBegan; //*
bool wasDeceleratingWhenTouchesBegan; //* bool firstDrag; //<
bool firstDrag; //<
float startTime; //<
float startTime; //< //float startTime
//float startTime
IntRectangle size;
IntRectangle size; int lastFrame;
int lastFrame;
bool _scrollEnabled; //!
bool _scrollEnabled; //! bool touchesHaveMoved; //*
bool touchesHaveMoved; //*
virtual void didEndDragging() {}
virtual void didEndDragging() {} virtual void didEndDecelerating() {}
virtual void didEndDecelerating() {} virtual void willBeginDecelerating() {}
virtual void willBeginDecelerating() {} virtual void willBeginDragging() {}
virtual void willBeginDragging() {}
int te_moved,
int te_moved, te_ended,
te_ended, te_highlight;
te_highlight; int highlightTimer;
int highlightTimer; int highlightStarted;
int highlightStarted; GridItem highlightItem;
GridItem highlightItem;
bool* selected;
bool* selected; int selectedId;
int selectedId;
ScrollBar vScroll, hScroll;
ScrollBar vScroll, hScroll;
IntRectangle adjustedContentSize;
IntRectangle adjustedContentSize; void touchesBegan(float x, float y, int t);
void touchesBegan(float x, float y, int t); void touchesMoved(float x, float y, int t);
void touchesMoved(float x, float y, int t); void touchesEnded(float x, float y, int t);
void touchesEnded(float x, float y, int t); void touchesCancelled(float x, float y, int t);
void touchesCancelled(float x, float y, int t); void beginTracking(float x, float y, int t);
void beginTracking(float x, float y, int t); void onHoldItem();
void onHoldItem();
void _onSelect( int id );
void _onSelect( int id ); virtual bool onSelect(int gridId, bool selected);
virtual bool onSelect(int gridId, bool selected);
Vec3& contentOffset();
Vec3& contentOffset();
void startDecelerationAnimation(bool force);
void startDecelerationAnimation(bool force); void stopDecelerationAnimation();
void stopDecelerationAnimation(); void stepThroughDecelerationAnimation(bool f);
void stepThroughDecelerationAnimation(bool f);
void setContentOffset(float x, float y);
void setContentOffset(float x, float y); void setContentOffset(Vec3 a);
void setContentOffset(Vec3 a); void setContentOffsetWithAnimation(Vec3 b, bool doScroll);
void setContentOffsetWithAnimation(Vec3 b, bool doScroll); void snapContentOffsetToBounds(bool snap); //*
void snapContentOffsetToBounds(bool snap); //* void adjustContentSize();
void adjustContentSize(); //TouchAreaModel _areaModel;
//TouchAreaModel _areaModel;
bool isAllSet(int flag) { return (flags & flag) == flag; }
bool isAllSet(int flag) { return (flags & flag) == flag; } bool isSet(int flag) { return (flags & flag) != 0; }
bool isSet(int flag) { return (flags & flag) != 0; } bool isNotSet(int flag) { return !isSet(flag); }
bool isNotSet(int flag) { return !isSet(flag); }
void updateHorizontalScrollIndicator();
void updateHorizontalScrollIndicator(); void updateVerticalScrollIndicator();
void updateVerticalScrollIndicator(); void hideScrollIndicators(); //*
void hideScrollIndicators(); //* void updateScrollFade( ScrollBar& vScroll );
void updateScrollFade( ScrollBar& vScroll ); private:
private: Timer _timer;
Timer _timer; bool _doStepTimer;
bool _doStepTimer; bool _wasDown;
bool _wasDown; float _lx;
float _lx; float _ly;
float _ly; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ScrollingPane_H__*/

View File

@@ -1,48 +1,46 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Slider_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Slider_H__
#include "GuiElement.h"
#include "GuiElement.h" #include "../../../client/Options.h"
#include "../../../client/Options.h" #include <client/Option.h>
#include <client/Option.h>
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( Minecraft* minecraft, int xm, int ym ); virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum ); virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ); virtual void tick(Minecraft* minecraft);
virtual void tick(Minecraft* minecraft);
protected:
protected: Slider(OptionId optId);
Slider(OptionId optId);
OptionId m_optId;
OptionId m_optId;
bool m_mouseDownOnElement;
bool m_mouseDownOnElement; float m_percentage;
float m_percentage; int m_numSteps;
int m_numSteps; };
};
class SliderFloat : public Slider {
class SliderFloat : public Slider { public:
public: SliderFloat(Minecraft* minecraft, OptionId option);
SliderFloat(Minecraft* minecraft, OptionId option);
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
protected:
protected: OptionFloat* m_option;
OptionFloat* m_option; };
};
class SliderInt : public Slider {
class SliderInt : public Slider { public:
public: SliderInt(Minecraft* minecraft, OptionId option);
SliderInt(Minecraft* minecraft, OptionId option);
virtual void render( Minecraft* minecraft, int xm, int ym ) override;
virtual void render( Minecraft* minecraft, int xm, int ym ) override; virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
protected:
protected: OptionInt* m_option;
OptionInt* m_option; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Slider_H__*/

View File

@@ -1,44 +1,42 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__TextBox_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__TextBox_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include <string>
#include <string> #include "GuiElement.h"
#include "GuiElement.h" #include "../../Options.h"
#include "../../Options.h" #include "../../../platform/input/Mouse.h"
#include "../../../platform/input/Mouse.h" #include "../../../platform/input/Keyboard.h"
#include "../../../platform/input/Keyboard.h"
class Font;
class Font; class Minecraft;
class Minecraft;
class TextBox: public GuiElement
class TextBox: public GuiElement {
{ public:
public: TextBox(int id, const std::string& msg);
TextBox(int id, const std::string& msg); TextBox(int id, int x, int y, const std::string& msg);
TextBox(int id, int x, int y, const std::string& msg); TextBox(int id, int x, int y, int w, int h, const std::string& msg);
TextBox(int id, int x, int y, int w, int h, const std::string& msg);
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum);
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum);
virtual void setFocus(Minecraft* minecraft);
virtual void setFocus(Minecraft* minecraft); virtual bool loseFocus(Minecraft* minecraft);
virtual bool loseFocus(Minecraft* minecraft);
virtual void render(Minecraft* minecraft, int xm, int ym);
virtual void render(Minecraft* minecraft, int xm, int ym);
virtual void keyPressed(Minecraft* minecraft, int key);
virtual void keyPressed(Minecraft* minecraft, int key); virtual void charPressed(Minecraft* minecraft, char c);
virtual void charPressed(Minecraft* minecraft, char c); virtual void tick(Minecraft* minecraft);
virtual void tick(Minecraft* minecraft);
public:
public: std::string hint;
std::string hint; std::string text;
std::string text; int id;
int id;
int blinkTicks;
int blinkTicks;
bool focused;
bool focused; bool blink;
bool blink; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__TextBox_H__*/

View File

@@ -1,79 +1,77 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ArmorScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ArmorScreen_H__
#include "BaseContainerScreen.h"
#include "BaseContainerScreen.h"
#include "../components/InventoryPane.h"
#include "../components/InventoryPane.h" #include "../components/Button.h"
#include "../components/Button.h"
class Font;
class Font; class CItem;
class CItem; class Textures;
class Textures; class NinePatchLayer;
class NinePatchLayer; class Tesselator;
class Tesselator;
class ArmorScreen: public Screen,
class ArmorScreen: public Screen, public Touch::IInventoryPaneCallback
public Touch::IInventoryPaneCallback {
{ typedef Screen super;
typedef Screen super; typedef std::vector<CItem*> ItemList;
typedef std::vector<CItem*> ItemList;
static const int NUM_ARMORBUTTONS = 4;
static const int NUM_ARMORBUTTONS = 4; public:
public: ArmorScreen();
ArmorScreen(); ~ArmorScreen();
~ArmorScreen();
void init();
void init(); void setupPositions();
void setupPositions();
void tick();
void tick(); void render(int xm, int ym, float a);
void render(int xm, int ym, float a); bool renderGameBehind();
bool renderGameBehind(); void buttonClicked(Button* button);
void buttonClicked(Button* button);
// IInventoryPaneCallback
// IInventoryPaneCallback bool addItem(const Touch::InventoryPane* pane, int itemId);
bool addItem(const Touch::InventoryPane* pane, int itemId); bool isAllowed( int slot );
bool isAllowed( int slot ); std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane );
std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane ); private:
private: void renderPlayer(float xo, float yo);
void renderPlayer(float xo, float yo);
void setupInventoryPane();
void setupInventoryPane(); void updateItems();
void updateItems();
void drawSlotItemAt(Tesselator& t, int slot, const ItemInstance* item, int x, int y);
void drawSlotItemAt(Tesselator& t, int slot, const ItemInstance* item, int x, int y); ItemInstance moveOver(const ItemInstance* item, int maxCount);
ItemInstance moveOver(const ItemInstance* item, int maxCount); void takeAndClearSlot( int slot );
void takeAndClearSlot( int slot ); void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a);
void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a); bool canMoveToSlot(int slot, const ItemInstance* item);
bool canMoveToSlot(int slot, const ItemInstance* item); ItemList _items;
ItemList _items;
std::string currentItemDesc;
std::string currentItemDesc; ItemInstance burnResult;
ItemInstance burnResult; float descWidth;
float descWidth; ImageButton btnClose;
ImageButton btnClose;
BlankButton btnArmor0;
BlankButton btnArmor0; BlankButton btnArmor1;
BlankButton btnArmor1; BlankButton btnArmor2;
BlankButton btnArmor2; BlankButton btnArmor3;
BlankButton btnArmor3; BlankButton* armorButtons[4];
BlankButton* armorButtons[4];
Touch::THeader bHeader;
Touch::THeader bHeader;
Touch::InventoryPane* inventoryPane;
Touch::InventoryPane* inventoryPane; IntRectangle inventoryPaneRect;
IntRectangle inventoryPaneRect; IntRectangle guiPlayerBgRect;
IntRectangle guiPlayerBgRect;
std::vector<const ItemInstance*> armorItems;
std::vector<const ItemInstance*> armorItems; bool doRecreatePane;
bool doRecreatePane;
// GUI elements such as 9-Patches
// GUI elements such as 9-Patches NinePatchLayer* guiBackground;
NinePatchLayer* guiBackground; NinePatchLayer* guiSlot;
NinePatchLayer* guiSlot; NinePatchLayer* guiPaneFrame;
NinePatchLayer* guiPaneFrame; NinePatchLayer* guiPlayerBg;
NinePatchLayer* guiPlayerBg; Player* player;
Player* player; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ArmorScreen_H__*/

View File

@@ -1,50 +1,48 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__BaseContainerScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__BaseContainerScreen_H__
//package net.minecraft.client.gui.screens;
//package net.minecraft.client.gui.screens;
#include <vector>
#include <vector> #include "../Screen.h"
#include "../Screen.h" #include "../../Minecraft.h"
#include "../../Minecraft.h" #include "../../player/LocalPlayer.h"
#include "../../player/LocalPlayer.h"
class BaseContainerMenu;
class BaseContainerMenu;
class BaseContainerScreen: public Screen
class BaseContainerScreen: public Screen {
{ typedef Screen super;
typedef Screen super; public:
public: BaseContainerScreen(BaseContainerMenu* menu)
BaseContainerScreen(BaseContainerMenu* menu) : 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); }
} }
}
virtual bool closeOnPlayerHurt() {
virtual bool closeOnPlayerHurt() { return true;
return true; }
}
protected:
protected: BaseContainerMenu* menu;
BaseContainerMenu* menu; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI__BaseContainerScreen_H__*/

View File

@@ -1,21 +1,19 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ChatScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ChatScreen_H__
#include "../Screen.h"
#include "../Screen.h"
class ChatScreen: public Screen
class ChatScreen: public Screen {
{ public:
public: ChatScreen() {}
ChatScreen() {} virtual ~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) {};
private:
private: };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ChatScreen_H__*/

View File

@@ -1,72 +1,70 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ChestScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ChestScreen_H__
#include "BaseContainerScreen.h"
#include "BaseContainerScreen.h"
#include "../components/InventoryPane.h"
#include "../components/InventoryPane.h" #include "../components/Button.h"
#include "../components/Button.h"
class Font;
class Font; class CItem;
class CItem; class Textures;
class Textures; class NinePatchLayer;
class NinePatchLayer; class FillingContainer;
class FillingContainer; class ChestTileEntity;
class ChestTileEntity; class Tesselator;
class Tesselator;
class ChestScreen: public BaseContainerScreen,
class ChestScreen: public BaseContainerScreen, public Touch::IInventoryPaneCallback
public Touch::IInventoryPaneCallback {
{ typedef BaseContainerScreen super;
typedef BaseContainerScreen super; typedef std::vector<CItem*> ItemList;
typedef std::vector<CItem*> ItemList; friend class ItemPane;
friend class ItemPane; public:
public: ChestScreen(Player* player, ChestTileEntity* chest);
ChestScreen(Player* player, ChestTileEntity* chest); ~ChestScreen();
~ChestScreen();
void init();
void init(); void setupPositions();
void setupPositions();
void tick();
void tick(); void render(int xm, int ym, float a);
void render(int xm, int ym, float a); bool renderGameBehind();
bool renderGameBehind(); void buttonClicked(Button* button);
void buttonClicked(Button* button);
// IInventoryPaneCallback
// IInventoryPaneCallback bool addItem(const Touch::InventoryPane* pane, int itemId);
bool addItem(const Touch::InventoryPane* pane, int itemId); bool isAllowed( int slot );
bool isAllowed( int slot ); std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane );
std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane ); //const ItemList& getItems(const ItemPane* forPane);
//const ItemList& getItems(const ItemPane* forPane); private:
private: void setupPane();
void setupPane();
void drawSlotItemAt(Tesselator& t, const ItemInstance* item, int x, int y, bool selected);
void drawSlotItemAt(Tesselator& t, const ItemInstance* item, int x, int y, bool selected); bool handleAddItem(FillingContainer* from, FillingContainer* to, int itemIndex);
bool handleAddItem(FillingContainer* from, FillingContainer* to, int itemIndex); void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a);
void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a);
std::string currentItemDesc;
std::string currentItemDesc; ImageButton btnClose;
ImageButton btnClose; Touch::THeader bHeader;
Touch::THeader bHeader; Touch::THeader bHeaderChest;
Touch::THeader bHeaderChest;
Touch::InventoryPane* inventoryPane;
Touch::InventoryPane* inventoryPane; Touch::InventoryPane* chestPane;
Touch::InventoryPane* chestPane; IntRectangle panesBbox;
IntRectangle panesBbox;
std::vector<const ItemInstance*> inventoryItems;
std::vector<const ItemInstance*> inventoryItems; std::vector<const ItemInstance*> chestItems;
std::vector<const ItemInstance*> chestItems; bool doRecreatePane;
bool doRecreatePane;
int selectedSlot;
int selectedSlot;
// GUI elements such as 9-Patches
// GUI elements such as 9-Patches NinePatchLayer* guiBackground;
NinePatchLayer* guiBackground; NinePatchLayer* guiSlot;
NinePatchLayer* guiSlot; NinePatchLayer* guiSlotMarked;
NinePatchLayer* guiSlotMarked; NinePatchLayer* guiSlotMarker;
NinePatchLayer* guiSlotMarker; NinePatchLayer* guiPaneFrame;
NinePatchLayer* guiPaneFrame; Player* player;
Player* player; ChestTileEntity* chest;
ChestTileEntity* chest; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ChestScreen_H__*/

View File

@@ -1,21 +1,19 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ChooseLevelScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ChooseLevelScreen_H__
#include "../Screen.h"
#include "../Screen.h" #include "../../../world/level/storage/LevelStorageSource.h"
#include "../../../world/level/storage/LevelStorageSource.h"
class ChooseLevelScreen: public Screen
class ChooseLevelScreen: public Screen {
{ public:
public: void init();
void init();
protected:
protected: std::string getUniqueLevelName(const std::string& level);
std::string getUniqueLevelName(const std::string& level);
private:
private: void loadLevelSource();
void loadLevelSource();
LevelSummaryList levels;
LevelSummaryList levels; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ChooseLevelScreen_H__*/

View File

@@ -1,40 +1,38 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ConfirmScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ConfirmScreen_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include "../Screen.h"
#include "../Screen.h" #include <string>
#include <string>
class ConfirmScreen: public Screen
class ConfirmScreen: public Screen {
{ typedef Screen super;
typedef Screen super; public:
public: ConfirmScreen(Screen* parent_, const std::string& title1_, const std::string& title2_, int id_);
ConfirmScreen(Screen* parent_, const std::string& title1_, const std::string& title2_, int id_); ConfirmScreen(Screen* parent_, const std::string& title1_, const std::string& title2_, const std::string& yesButton, const std::string& noButton, int id_);
ConfirmScreen(Screen* parent_, const std::string& title1_, const std::string& title2_, const std::string& yesButton, const std::string& noButton, int id_); ~ConfirmScreen();
~ConfirmScreen();
void init();
void init(); void setupPositions();
void setupPositions();
bool handleBackEvent(bool isDown);
bool handleBackEvent(bool isDown); void render(int xm, int ym, float a);
void render(int xm, int ym, float a); protected:
protected: void buttonClicked(Button* button);
void buttonClicked(Button* button);
virtual void postResult(bool isOk);
virtual void postResult(bool isOk);
Screen* parent;
Screen* parent; int id;
int id; private:
private: std::string title1;
std::string title1; std::string title2;
std::string title2;
std::string yesButtonText;
std::string yesButtonText; std::string noButtonText;
std::string noButtonText;
Button* yesButton; // 0
Button* yesButton; // 0 Button* noButton; // 1
Button* noButton; // 1 };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ConfirmScreen_H__*/

View File

@@ -1,5 +1,4 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ConsoleScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ConsoleScreen_H__
#include "../Screen.h" #include "../Screen.h"
#include <string> #include <string>
@@ -31,4 +30,3 @@ private:
int _cursorBlink; // tick counter for cursor blink int _cursorBlink; // tick counter for cursor blink
}; };
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ConsoleScreen_H__*/

View File

@@ -1,5 +1,4 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__CreditsScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__CreditsScreen_H__
#include "../Screen.h" #include "../Screen.h"
#include "../components/Button.h" #include "../components/Button.h"
@@ -29,4 +28,3 @@ private:
float _scrollSpeed; float _scrollSpeed;
}; };
#endif /* NET_MINECRAFT_CLIENT_GUI_SCREENS__CreditsScreen_H__ */

View File

@@ -1,30 +1,28 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__DeathScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DeathScreen_H__
#include "../Screen.h"
#include "../Screen.h" class Button;
class Button;
class DeathScreen: public Screen
class DeathScreen: public Screen {
{ public:
public: DeathScreen();
DeathScreen();
virtual ~DeathScreen();
virtual ~DeathScreen();
void init();
void init();
void setupPositions();
void setupPositions();
void tick();
void tick(); void render(int xm, int ym, float a);
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
void buttonClicked(Button* button);
private:
private: Button* bRespawn;
Button* bRespawn; Button* bTitle;
Button* bTitle; bool _hasChosen;
bool _hasChosen; int _tick;
int _tick; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__DeathScreen_H__*/

View File

@@ -1,13 +1,11 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__DialogDefinitions_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DialogDefinitions_H__
class DialogDefinitions {
class DialogDefinitions { public:
public: static const int DIALOG_CREATE_NEW_WORLD = 1;
static const int DIALOG_CREATE_NEW_WORLD = 1; static const int DIALOG_NEW_CHAT_MESSAGE = 2;
static const int DIALOG_NEW_CHAT_MESSAGE = 2; static const int DIALOG_MAINMENU_OPTIONS = 3;
static const int DIALOG_MAINMENU_OPTIONS = 3; static const int DIALOG_RENAME_MP_WORLD = 4;
static const int DIALOG_RENAME_MP_WORLD = 4; static const int DIALOG_DEMO_FEATURE_DISABLED = 98;
static const int DIALOG_DEMO_FEATURE_DISABLED = 98; };
};
#endif /*#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__DialogDefinitions_H__*/

View File

@@ -1,57 +1,55 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__DisconnectionScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DisconnectionScreen_H__
#include "../Screen.h"
#include "../Screen.h" #include "../Font.h"
#include "../Font.h" #include "../components/Button.h"
#include "../components/Button.h" #include "../../Minecraft.h"
#include "../../Minecraft.h" #include <string>
#include <string>
class DisconnectionScreen: public Screen
class DisconnectionScreen: public Screen {
{ typedef Screen super;
typedef Screen super; public:
public: DisconnectionScreen(const std::string& msg)
DisconnectionScreen(const std::string& msg) : _msg(msg),
: _msg(msg), _back(NULL)
_back(NULL) {}
{}
~DisconnectionScreen() {
~DisconnectionScreen() { delete _back;
delete _back; }
}
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");
buttons.push_back(_back);
buttons.push_back(_back); tabButtons.push_back(_back);
tabButtons.push_back(_back);
_back->width = 128;
_back->width = 128; _back->x = (width - _back->width) / 2;
_back->x = (width - _back->width) / 2; _back->y = height / 2;
_back->y = height / 2; }
}
void render( int xm, int ym, float a ) {
void render( int xm, int ym, float a ) { 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; }
private:
private: std::string _msg;
std::string _msg; Button* _back;
Button* _back; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__DisconnectionScreen_H__*/

View File

@@ -1,84 +1,82 @@
#ifndef _FURNACESCREEN_H__ #pragma once
#define _FURNACESCREEN_H__
#include "BaseContainerScreen.h"
#include "BaseContainerScreen.h"
#include "../components/InventoryPane.h"
#include "../components/InventoryPane.h" #include "../components/Button.h"
#include "../components/Button.h"
class Font;
class Font; class CItem;
class CItem; class Textures;
class Textures; class NinePatchLayer;
class NinePatchLayer; class Tesselator;
class Tesselator;
class FurnaceScreen: public BaseContainerScreen,
class FurnaceScreen: public BaseContainerScreen, public Touch::IInventoryPaneCallback
public Touch::IInventoryPaneCallback {
{ typedef BaseContainerScreen super;
typedef BaseContainerScreen super; typedef std::vector<CItem*> ItemList;
typedef std::vector<CItem*> ItemList; public:
public: FurnaceScreen(Player* player, FurnaceTileEntity* furnace);
FurnaceScreen(Player* player, FurnaceTileEntity* furnace); ~FurnaceScreen();
~FurnaceScreen();
void init();
void init(); void setupPositions();
void setupPositions();
void tick();
void tick(); void render(int xm, int ym, float a);
void render(int xm, int ym, float a); bool renderGameBehind();
bool renderGameBehind(); void buttonClicked(Button* button);
void buttonClicked(Button* button);
// IInventoryPaneCallback
// IInventoryPaneCallback bool addItem(const Touch::InventoryPane* pane, int itemId);
bool addItem(const Touch::InventoryPane* pane, int itemId); bool isAllowed( int slot );
bool isAllowed( int slot ); std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane );
std::vector<const ItemInstance*> getItems( const Touch::InventoryPane* forPane ); private:
private: //void addItem(Recipe* recipe);
//void addItem(Recipe* recipe); void recheckRecipes();
void recheckRecipes();
void clearItems();
void clearItems(); void updateResult(const ItemInstance* item);
void updateResult(const ItemInstance* item); void setupInventoryPane();
void setupInventoryPane(); void updateItems();
void updateItems();
void drawSlotItemAt(Tesselator& t, const ItemInstance* item, int x, int y, bool selected);
void drawSlotItemAt(Tesselator& t, const ItemInstance* item, int x, int y, bool selected); ItemInstance moveOver(const ItemInstance* item, int maxCount);
ItemInstance moveOver(const ItemInstance* item, int maxCount); void takeAndClearSlot( int slot );
void takeAndClearSlot( int slot ); bool handleAddItem( int slot, const ItemInstance* item );
bool handleAddItem( int slot, const ItemInstance* item ); void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a);
void handleRenderPane(Touch::InventoryPane* pane, Tesselator& t, int xm, int ym, float a); bool canMoveToFurnace(int inventorySlot, const ItemInstance* item);
bool canMoveToFurnace(int inventorySlot, const ItemInstance* item); ItemList _items;
ItemList _items;
std::string currentItemDesc;
std::string currentItemDesc; ItemInstance burnResult;
ItemInstance burnResult; float descWidth;
float descWidth; ImageButton btnClose;
ImageButton btnClose; BlankButton btnIngredient;
BlankButton btnIngredient; BlankButton btnFuel;
BlankButton btnFuel; BlankButton btnResult;
BlankButton btnResult; Touch::THeader bHeader;
Touch::THeader bHeader;
Touch::InventoryPane* inventoryPane;
Touch::InventoryPane* inventoryPane; IntRectangle inventoryPaneRect;
IntRectangle inventoryPaneRect;
ItemList listFuel;
ItemList listFuel; ItemList listIngredient;
ItemList listIngredient; std::vector<int> inventorySlots;
std::vector<int> inventorySlots; std::vector<const ItemInstance*> inventoryItems;
std::vector<const ItemInstance*> inventoryItems; bool doRecreatePane;
bool doRecreatePane;
int selectedSlot;
int selectedSlot; int lastBurnTypeId;
int lastBurnTypeId;
// GUI elements such as 9-Patches
// GUI elements such as 9-Patches NinePatchLayer* guiBackground;
NinePatchLayer* guiBackground; NinePatchLayer* guiSlot;
NinePatchLayer* guiSlot; NinePatchLayer* guiSlotMarked;
NinePatchLayer* guiSlotMarked; NinePatchLayer* guiSlotMarker;
NinePatchLayer* guiSlotMarker; NinePatchLayer* guiPaneFrame;
NinePatchLayer* guiPaneFrame; Player* player;
Player* player; FurnaceTileEntity* furnace;
FurnaceTileEntity* furnace; };
};
#endif /*_FURNACESCREEN_H__*/

View File

@@ -1,26 +1,24 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__InBedScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__InBedScreen_H__
#include "../Screen.h"
#include "../Screen.h" class Button;
class Button;
class InBedScreen: public Screen
class InBedScreen: public Screen {
{ public:
public: InBedScreen();
InBedScreen();
virtual ~InBedScreen();
virtual ~InBedScreen();
void init();
void init();
void setupPositions();
void setupPositions();
void render(int xm, int ym, float a);
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
void buttonClicked(Button* button);
private:
private: Button* bWakeUp;
Button* bWakeUp; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__InBedScreen_H__*/

View File

@@ -1,59 +1,57 @@
#ifndef _MINECRAFT_INGAMEBLOCKSELECTIONSCREEN_H_ #pragma once
#define _MINECRAFT_INGAMEBLOCKSELECTIONSCREEN_H_
#include "../Screen.h"
#include "../Screen.h" #include "../../player/input/touchscreen/TouchAreaModel.h"
#include "../../player/input/touchscreen/TouchAreaModel.h" #include "../components/Button.h"
#include "../components/Button.h"
class IngameBlockSelectionScreen : public Screen
class IngameBlockSelectionScreen : public Screen {
{ typedef Screen super;
typedef Screen super; public:
public: IngameBlockSelectionScreen();
IngameBlockSelectionScreen(); virtual ~IngameBlockSelectionScreen() {}
virtual ~IngameBlockSelectionScreen() {}
virtual void init() override;
virtual void init() override; virtual void removed() override;
virtual void removed() override;
void render(int xm, int ym, float a) override;
void render(int xm, int ym, float a) override;
protected:
protected: virtual void mouseClicked(int x, int y, int buttonNum) override;
virtual void mouseClicked(int x, int y, int buttonNum) override; virtual void mouseReleased(int x, int y, int buttonNum) override;
virtual void mouseReleased(int x, int y, int buttonNum) override;
virtual void buttonClicked(Button* button) override;
virtual void buttonClicked(Button* button) override;
// wheel input for creative inventory scrolling
// wheel input for creative inventory scrolling virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
virtual void keyPressed(int eventKey) override;
virtual void keyPressed(int eventKey) override; private:
private: void renderSlots();
void renderSlots(); void renderSlot(int slot, int x, int y, float a);
void renderSlot(int slot, int x, int y, float a); void renderDemoOverlay();
void renderDemoOverlay();
int getSelectedSlot(int x, int y);
int getSelectedSlot(int x, int y); void selectSlotAndClose();
void selectSlotAndClose();
//int getLinearSlotId(int x, int y);
//int getLinearSlotId(int x, int y); int getSlotPosX(int slotX);
int getSlotPosX(int slotX); int getSlotPosY(int slotY);
int getSlotPosY(int slotY);
int getSlotHeight();
int getSlotHeight();
bool isAllowed(int slot);
bool isAllowed(int slot);
private:
private: int InventoryCols;
int InventoryCols; int InventoryRows;
int InventoryRows; int InventorySize;
int InventorySize;
int selectedItem;
int selectedItem; bool _pendingQuit;
bool _pendingQuit;
Button bArmor;
Button bArmor;
RectangleArea _area;
RectangleArea _area; };
};
#endif

View File

@@ -1,70 +1,68 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__JoinGameScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__JoinGameScreen_H__
#include "../Screen.h"
#include "../Screen.h" #include "../components/Button.h"
#include "../components/Button.h" #include "../components/ScrolledSelectionList.h"
#include "../components/ScrolledSelectionList.h" #include "../../Minecraft.h"
#include "../../Minecraft.h" #include "../../../network/RakNetInstance.h"
#include "../../../network/RakNetInstance.h"
class JoinGameScreen;
class JoinGameScreen;
class AvailableGamesList : public ScrolledSelectionList
class AvailableGamesList : public ScrolledSelectionList {
{ int selectedItem;
int selectedItem; ServerList copiedServerList;
ServerList copiedServerList;
friend class JoinGameScreen;
friend class JoinGameScreen;
public:
public:
AvailableGamesList(Minecraft* _minecraft, int _width, int _height)
AvailableGamesList(Minecraft* _minecraft, int _width, int _height) : ScrolledSelectionList(_minecraft, _width, _height, 24, _height - 30, 28)
: ScrolledSelectionList(_minecraft, _width, _height, 24, _height - 30, 28) {
{ }
}
protected:
protected:
virtual int getNumberOfItems() { return (int)copiedServerList.size(); }
virtual int getNumberOfItems() { return (int)copiedServerList.size(); }
virtual void selectItem(int item, bool doubleClick) { selectedItem = item; }
virtual void selectItem(int item, bool doubleClick) { selectedItem = item; } virtual bool isSelectedItem(int item) { return item == selectedItem; }
virtual bool isSelectedItem(int item) { return item == selectedItem; }
virtual void renderBackground() {}
virtual void renderBackground() {} virtual void renderItem(int i, int x, int y, int h, Tesselator& t)
virtual void renderItem(int i, int x, int y, int h, Tesselator& t) {
{ 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); }
} };
};
class JoinGameScreen: public Screen
class JoinGameScreen: public Screen {
{ public:
public: JoinGameScreen();
JoinGameScreen(); virtual ~JoinGameScreen();
virtual ~JoinGameScreen();
void init();
void init(); void setupPositions();
void setupPositions();
virtual bool handleBackEvent(bool isDown);
virtual bool handleBackEvent(bool isDown);
virtual bool isIndexValid(int index);
virtual bool isIndexValid(int index);
virtual void tick();
virtual void tick();
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 isInGameScreen();
bool isInGameScreen(); private:
private: Button bJoin;
Button bJoin; Button bBack;
Button bBack; AvailableGamesList* gamesList;
AvailableGamesList* gamesList; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__JoinGameScreen_H__*/

View File

@@ -1,49 +1,47 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__OptionsScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__OptionsScreen_H__
#include "../Screen.h"
#include "../Screen.h" #include "../components/Button.h"
#include "../components/Button.h" #include "../components/OptionsGroup.h"
#include "../components/OptionsGroup.h"
class ImageButton;
class ImageButton; class OptionsPane;
class OptionsPane;
class OptionsScreen: public Screen
class OptionsScreen: public Screen {
{ typedef Screen super;
typedef Screen super;
void init();
void init(); void generateOptionScreens();
void generateOptionScreens();
public:
public: OptionsScreen();
OptionsScreen(); ~OptionsScreen();
~OptionsScreen();
void setupPositions();
void setupPositions(); void buttonClicked(Button* button);
void buttonClicked(Button* button); void render(int xm, int ym, float a);
void render(int xm, int ym, float a); void removed();
void removed(); void selectCategory(int index);
void selectCategory(int index);
virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseClicked(int x, int y, int buttonNum); virtual void mouseReleased(int x, int y, int buttonNum);
virtual void mouseReleased(int x, int y, int buttonNum); virtual void keyPressed(int eventKey);
virtual void keyPressed(int eventKey); virtual void charPressed(char inputChar);
virtual void charPressed(char inputChar);
virtual void tick();
virtual void tick();
private:
private: Touch::THeader* bHeader;
Touch::THeader* bHeader; ImageButton* btnClose;
ImageButton* btnClose;
Button* btnCredits; // <-- ADD THIS
Button* btnCredits; // <-- ADD THIS
std::vector<Touch::TButton*> categoryButtons;
std::vector<Touch::TButton*> categoryButtons; std::vector<OptionsGroup*> optionPanes;
std::vector<OptionsGroup*> optionPanes;
OptionsGroup* currentOptionsGroup;
OptionsGroup* currentOptionsGroup;
int selectedCategory;
int selectedCategory; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__OptionsScreen_H__*/

View File

@@ -1,45 +1,43 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__PauseScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI__PauseScreen_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include "../Screen.h"
#include "../Screen.h" #include "../components/ImageButton.h"
#include "../components/ImageButton.h"
class Button;
class Button;
class PauseScreen: public Screen
class PauseScreen: public Screen {
{ typedef Screen super;
typedef Screen super; public:
public: PauseScreen(bool wasBackPaused);
PauseScreen(bool wasBackPaused); ~PauseScreen();
~PauseScreen();
void init();
void init(); void setupPositions();
void setupPositions();
void tick();
void tick(); void render(int xm, int ym, float a);
void render(int xm, int ym, float a); protected:
protected: void buttonClicked(Button* button);
void buttonClicked(Button* button); private:
private: void updateServerVisibilityText();
void updateServerVisibilityText();
int saveStep;
int saveStep; int visibleTime;
int visibleTime; bool wasBackPaused;
bool wasBackPaused;
Button* bContinue;
Button* bContinue; Button* bQuit;
Button* bQuit; Button* bQuitAndSaveLocally;
Button* bQuitAndSaveLocally; Button* bServerVisibility;
Button* bServerVisibility; Button* bOptions;
Button* bOptions;
// Button* bThirdPerson;
// Button* bThirdPerson;
// OptionButton bSound;
// OptionButton bSound; OptionButton bThirdPerson;
OptionButton bThirdPerson; OptionButton bHideGui;
OptionButton bHideGui; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI__PauseScreen_H__*/

View File

@@ -1,162 +1,160 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__PrerenderTilesScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__PrerenderTilesScreen_H__
#include "../Screen.h"
#include "../Screen.h"
#include "../../renderer/GameRenderer.h"
#include "../../renderer/GameRenderer.h" #include "../../renderer/entity/ItemRenderer.h"
#include "../../renderer/entity/ItemRenderer.h" #include "../../../world/item/ItemInstance.h"
#include "../../../world/item/ItemInstance.h" #include "../../../world/level/tile/Tile.h"
#include "../../../world/level/tile/Tile.h"
#include "../../../world/entity/player/Inventory.h"
#include "../../../world/entity/player/Inventory.h" #include "../../renderer/Tesselator.h"
#include "../../renderer/Tesselator.h" #include "../../../world/item/crafting/Recipes.h"
#include "../../../world/item/crafting/Recipes.h" #include "../../../world/item/crafting/FurnaceRecipes.h"
#include "../../../world/item/crafting/FurnaceRecipes.h" #include "../../../world/level/tile/LeafTile.h"
#include "../../../world/level/tile/LeafTile.h" #include "../../renderer/TileRenderer.h"
#include "../../renderer/TileRenderer.h"
class PrerenderTilesScreen: public Screen
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;
// Copy over the inventory items
// Copy over the inventory items for (int i = Inventory::MAX_SELECTION_SIZE; i < inventory->getContainerSize(); ++i)
for (int i = Inventory::MAX_SELECTION_SIZE; i < inventory->getContainerSize(); ++i) addItem(inventory->getItem(i));
addItem(inventory->getItem(i));
// Fill the inventory with all the recipe items we don't already have: furnace
// Fill the inventory with all the recipe items we don't already have: furnace const FurnaceRecipes::Map& furnaceRecipes = FurnaceRecipes::getInstance()->getRecipes();
const FurnaceRecipes::Map& furnaceRecipes = FurnaceRecipes::getInstance()->getRecipes(); for (FurnaceRecipes::Map::const_iterator cit = furnaceRecipes.begin(); cit != furnaceRecipes.end(); ++cit) {
for (FurnaceRecipes::Map::const_iterator cit = furnaceRecipes.begin(); cit != furnaceRecipes.end(); ++cit) { ItemInstance ingredient(cit->first, 1, 0);
ItemInstance ingredient(cit->first, 1, 0); addItem(&ingredient);
addItem(&ingredient); ItemInstance result = cit->second;
ItemInstance result = cit->second; addItem(&result);
addItem(&result); }
}
// Fill the inventory with all the recipe items we don't already have: crafting
// Fill the inventory with all the recipe items we don't already have: crafting const RecipeList& recipes = Recipes::getInstance()->getRecipes();
const RecipeList& recipes = Recipes::getInstance()->getRecipes(); for (unsigned int i = 0; i < recipes.size(); ++i) {
for (unsigned int i = 0; i < recipes.size(); ++i) {
std::vector<ItemInstance> items;
std::vector<ItemInstance> items; std::vector<ItemInstance> required = recipes[i]->getItemPack().getItemInstances();
std::vector<ItemInstance> required = recipes[i]->getItemPack().getItemInstances(); items.push_back(recipes[i]->getResultItem());
items.push_back(recipes[i]->getResultItem()); items.insert(items.end(), required.begin(), required.end());
items.insert(items.end(), required.begin(), required.end());
for (unsigned int i = 0; i < items.size(); ++i) {
for (unsigned int i = 0; i < items.size(); ++i) { ItemInstance& item = items[i];
ItemInstance& item = items[i]; addItem(&item);
addItem(&item); }
} }
}
// Manually added stuff
// Manually added stuff // Example: the one that's spawned from tiles when destroyed
// Example: the one that's spawned from tiles when destroyed int items[] = {
int items[] = { Tile::sapling->id, LeafTile::BIRCH_LEAF,
Tile::sapling->id, LeafTile::BIRCH_LEAF, Tile::sapling->id, LeafTile::EVERGREEN_LEAF,
Tile::sapling->id, LeafTile::EVERGREEN_LEAF, Tile::sapling->id, LeafTile::NORMAL_LEAF,
Tile::sapling->id, LeafTile::NORMAL_LEAF, Tile::dirt->id, 0,
Tile::dirt->id, 0, Tile::reeds->id, 0,
Tile::reeds->id, 0, Tile::gravel->id, 0,
Tile::gravel->id, 0, Item::apple->id, 0,
Item::apple->id, 0, Tile::grass_carried->id, 0,
Tile::grass_carried->id, 0, Tile::web->id, 0,
Tile::web->id, 0, Item::sign->id, 0,
Item::sign->id, 0, };
}; for (int i = 0; i < sizeof(items)/sizeof(int); i += 2) {
for (int i = 0; i < sizeof(items)/sizeof(int); i += 2) { ItemInstance item(items[i], 1, items[i+1]);
ItemInstance item(items[i], 1, items[i+1]); addItem(&item);
addItem(&item); }
} }
}
void render( int xm, int ym, float a ) {
void render( int xm, int ym, float a ) { static Stopwatch w;
static Stopwatch w; w.start();
w.start();
glDisable2(GL_DEPTH_TEST);
glDisable2(GL_DEPTH_TEST); fill(0, 0, width, height, 0xffff00ff);
fill(0, 0, width, height, 0xffff00ff); //fill(0, 0, width, height, 0xff333333);
//fill(0, 0, width, height, 0xff333333); glColor4f2(1, 1, 1, 1);
glColor4f2(1, 1, 1, 1); glEnable2(GL_BLEND);
glEnable2(GL_BLEND);
LOGI("--------------------\n");
LOGI("--------------------\n"); /*int j = 0;
/*int j = 0; for (int i = Inventory::MAX_SELECTION_SIZE; i < inventory->getContainerSize(); ++i) {
for (int i = Inventory::MAX_SELECTION_SIZE; i < inventory->getContainerSize(); ++i) {
ItemInstance* item = inventory->getItem(i);
ItemInstance* item = inventory->getItem(i); if (!item) continue;
if (!item) continue;
//LOGI("desc: %d - %s. %d\n", i, item->toString().c_str());
//LOGI("desc: %d - %s. %d\n", i, item->toString().c_str());
int x = j%16 * 16;
int x = j%16 * 16; 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(std::vector<ItemInstance>::iterator 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());
int x = j%16 * 16;
int x = j%16 * 16; 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()); }
} j++;
j++; }
} //@todo: blit out something famous here
//@todo: blit out something famous here
//glRotatef2(-180, 1, 0, 0);
//glRotatef2(-180, 1, 0, 0); glEnable2(GL_DEPTH_TEST);
glEnable2(GL_DEPTH_TEST); glDisable2(GL_BLEND);
glDisable2(GL_BLEND);
w.stop();
w.stop(); w.printEvery(100, "render-blocksel");
w.printEvery(100, "render-blocksel"); }
} void removed(){}
void removed(){}
void addItem(ItemInstance* item) {
void addItem(ItemInstance* item) { if(item == NULL)
if(item == NULL) return;
return; 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(std::vector<ItemInstance>::iterator 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;
found = true;
found = true; break;
break; }
}
if (!found) {
if (!found) { LOGI("Adding item: %s\n", item->getDescriptionId().c_str());
LOGI("Adding item: %s\n", item->getDescriptionId().c_str()); mItems.push_back(*item);
mItems.push_back(*item); }
} }
}
private:
private: std::vector<ItemInstance> mItems;
std::vector<ItemInstance> mItems; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__PrerenderTilesScreen_H__*/

View File

@@ -1,21 +1,19 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ProgressScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ProgressScreen_H__
#include "../Screen.h"
#include "../Screen.h"
class ProgressScreen: public Screen
class ProgressScreen: public Screen {
{ public:
public: ProgressScreen();
ProgressScreen();
void render(int xm, int ym, float a);
void render(int xm, int ym, float a); bool isInGameScreen();
bool isInGameScreen();
virtual void keyPressed(int eventKey) {}
virtual void keyPressed(int eventKey) {}
void tick();
void tick(); private:
private: int ticks;
int ticks; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ProgressScreen_H__*/

View File

@@ -1,30 +1,28 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__ScreenChooser_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__ScreenChooser_H__
enum ScreenId {
enum ScreenId { SCREEN_NONE,
SCREEN_NONE, SCREEN_STARTMENU,
SCREEN_STARTMENU, SCREEN_JOINGAME,
SCREEN_JOINGAME, SCREEN_PAUSE,
SCREEN_PAUSE, SCREEN_PAUSEPREV,
SCREEN_PAUSEPREV, SCREEN_SELECTWORLD,
SCREEN_SELECTWORLD, SCREEN_BLOCKSELECTION,
SCREEN_BLOCKSELECTION, SCREEN_JOINBYIP,
SCREEN_JOINBYIP, SCREEN_CONSOLE
SCREEN_CONSOLE };
};
class Screen;
class Screen; class MinecraftClient;
class MinecraftClient;
class ScreenChooser
class ScreenChooser {
{ public:
public: ScreenChooser(MinecraftClient& mc) : _mc(mc) {}
ScreenChooser(MinecraftClient& mc) : _mc(mc) {}
Screen* createScreen(ScreenId id);
Screen* createScreen(ScreenId id); Screen* setScreen(ScreenId id);
Screen* setScreen(ScreenId id); private:
private: MinecraftClient& _mc;
MinecraftClient& _mc; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__ScreenChooser_H__*/

View File

@@ -1,112 +1,110 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__SelectWorldScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__SelectWorldScreen_H__
#include "../Screen.h"
#include "../Screen.h" #include "../TweenData.h"
#include "../TweenData.h" #include "../components/Button.h"
#include "../components/Button.h" #include "../components/RolledSelectionListH.h"
#include "../components/RolledSelectionListH.h" #include "../../../world/level/storage/LevelStorageSource.h"
#include "../../../world/level/storage/LevelStorageSource.h"
class SelectWorldScreen;
class SelectWorldScreen; class MinecraftClient;
class MinecraftClient;
//
// // Scrolling World selection list
// Scrolling World selection list //
// class WorldSelectionList : public RolledSelectionListH
class WorldSelectionList : public RolledSelectionListH {
{ public:
public: WorldSelectionList(MinecraftClient& _minecraft, int _width, int _height);
WorldSelectionList(MinecraftClient& _minecraft, int _width, int _height); virtual void tick();
virtual void tick(); void stepLeft();
void stepLeft(); void stepRight();
void stepRight();
void commit();
void commit(); protected:
protected: virtual int getNumberOfItems();
virtual int getNumberOfItems(); virtual void selectItem(int item, bool doubleClick);
virtual void selectItem(int item, bool doubleClick); virtual bool isSelectedItem(int item);
virtual bool isSelectedItem(int item);
virtual void renderBackground() {}
virtual void renderBackground() {} virtual void renderItem(int i, int x, int y, int h, Tesselator& t);
virtual void renderItem(int i, int x, int y, int h, Tesselator& t); virtual float getPos(float alpha);
virtual float getPos(float alpha); virtual void touched() { mode = 0; }
virtual void touched() { mode = 0; } virtual bool capXPosition();
virtual bool capXPosition(); private:
private: TweenData td;
TweenData td; void tweenInited();
void tweenInited();
int selectedItem;
int selectedItem; int _height;
int _height; LevelSummaryList levels;
LevelSummaryList levels; std::vector<StringVector> _descriptions;
std::vector<StringVector> _descriptions; StringVector _imageNames;
StringVector _imageNames;
bool hasPickedLevel;
bool hasPickedLevel; LevelSummary pickedLevel;
LevelSummary pickedLevel;
int stoppedTick;
int stoppedTick; int currentTick;
int currentTick; float accRatio;
float accRatio; int mode;
int mode;
friend class SelectWorldScreen;
friend class SelectWorldScreen; };
};
//
// // Delete World screen
// Delete World screen //
// #include "ConfirmScreen.h"
#include "ConfirmScreen.h" class DeleteWorldScreen: public ConfirmScreen
class DeleteWorldScreen: public ConfirmScreen {
{ public:
public: DeleteWorldScreen(const LevelSummary& levelId);
DeleteWorldScreen(const LevelSummary& levelId); protected:
protected: virtual void postResult(bool isOk);
virtual void postResult(bool isOk); private:
private: LevelSummary _level;
LevelSummary _level; };
};
//
// // Select world screen
// Select world screen //
// class SelectWorldScreen: public Screen
class SelectWorldScreen: public Screen {
{ public:
public: SelectWorldScreen();
SelectWorldScreen(); virtual ~SelectWorldScreen();
virtual ~SelectWorldScreen();
virtual void init();
virtual void init(); virtual void setupPositions();
virtual void setupPositions(); virtual void tick();
virtual void tick();
virtual bool isIndexValid(int index);
virtual bool isIndexValid(int index); virtual bool handleBackEvent(bool isDown);
virtual bool handleBackEvent(bool isDown); virtual void buttonClicked(Button* button);
virtual void buttonClicked(Button* button); virtual void keyPressed(int eventKey);
virtual void keyPressed(int eventKey);
void render(int xm, int ym, float a);
void render(int xm, int ym, float a);
// mouse wheel scroll (new in desktop implementation)
// mouse wheel scroll (new in desktop implementation) virtual void mouseWheel(int dx, int dy, int xm, int ym);
virtual void mouseWheel(int dx, int dy, int xm, int ym);
bool isInGameScreen();
bool isInGameScreen(); private:
private: void loadLevelSource();
void loadLevelSource(); std::string getUniqueLevelName(const std::string& level);
std::string getUniqueLevelName(const std::string& level);
Button bDelete;
Button bDelete; Button bCreate;
Button bCreate; Button bBack;
Button bBack; Button bWorldView;
Button bWorldView; WorldSelectionList* worldsList;
WorldSelectionList* worldsList; LevelSummaryList levels;
LevelSummaryList levels;
bool _mouseHasBeenUp;
bool _mouseHasBeenUp; bool _hasStartedLevel;
bool _hasStartedLevel; //LevelStorageSource* levels;
//LevelStorageSource* levels; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__SelectWorldScreen_H__*/

View File

@@ -1,44 +1,42 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__
#include "ChooseLevelScreen.h"
#include "ChooseLevelScreen.h" #include "../components/TextBox.h"
#include "../components/TextBox.h" #include "../components/Button.h" // for Touch::THeader
#include "../components/Button.h" // for Touch::THeader class Button;
class Button; class ImageButton;
class ImageButton;
class SimpleChooseLevelScreen: public ChooseLevelScreen
class SimpleChooseLevelScreen: public ChooseLevelScreen {
{ public:
public: SimpleChooseLevelScreen(const std::string& levelName);
SimpleChooseLevelScreen(const std::string& levelName);
virtual ~SimpleChooseLevelScreen();
virtual ~SimpleChooseLevelScreen();
void init();
void init(); void setupPositions();
void setupPositions(); void tick();
void tick();
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);
bool handleBackEvent(bool isDown); virtual void keyPressed(int eventKey);
virtual void keyPressed(int eventKey); virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseClicked(int x, int y, int buttonNum);
private:
private: Touch::THeader* bHeader;
Touch::THeader* bHeader; Button* bGamemode;
Button* bGamemode; Button* bCheats;
Button* bCheats; ImageButton* bBack;
ImageButton* bBack; Button* bCreate;
Button* bCreate; bool hasChosen;
bool hasChosen;
std::string levelName;
std::string levelName; int gamemode;
int gamemode; bool cheatsEnabled;
bool cheatsEnabled;
TextBox tLevelName;
TextBox tLevelName; TextBox tSeed;
TextBox tSeed; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__*/

View File

@@ -1,40 +1,38 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__StartMenuScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__StartMenuScreen_H__
#include "../Screen.h"
#include "../Screen.h" #include "../components/Button.h"
#include "../components/Button.h" #include "../components/ImageButton.h"
#include "../components/ImageButton.h"
class StartMenuScreen: public Screen
class StartMenuScreen: public Screen {
{ public:
public: StartMenuScreen();
StartMenuScreen(); virtual ~StartMenuScreen();
virtual ~StartMenuScreen();
void init();
void init(); void setupPositions();
void setupPositions();
void tick();
void tick(); void render(int xm, int ym, float a);
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
void buttonClicked(Button* button); virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseClicked(int x, int y, int buttonNum); bool handleBackEvent(bool isDown);
bool handleBackEvent(bool isDown); bool isInGameScreen();
bool isInGameScreen(); private:
private:
Button bHost;
Button bHost; Button bJoin;
Button bJoin; Button bOptions;
Button bOptions; ImageButton bQuit; // X button in top-right corner
ImageButton bQuit; // X button in top-right corner
std::string copyright;
std::string copyright; int copyrightPosX;
int copyrightPosX;
std::string version;
std::string version; int versionPosX;
int versionPosX;
std::string username;
std::string username; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__StartMenuScreen_H__*/

View File

@@ -1,35 +1,33 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__TextEditScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__TextEditScreen_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include "../Screen.h"
#include "../Screen.h" #include <string>
#include <string> #include "../components/ImageButton.h"
#include "../components/ImageButton.h" class SignTileEntity;
class SignTileEntity; class Button;
class Button; class TextEditScreen: public Screen
class TextEditScreen: public Screen {
{ typedef Screen super;
typedef Screen super; public:
public: TextEditScreen(SignTileEntity* signEntity);
TextEditScreen(SignTileEntity* signEntity); ~TextEditScreen();
~TextEditScreen(); void init();
void init(); void tick();
void tick(); bool handleBackEvent(bool isDown);
bool handleBackEvent(bool isDown); void render(int xm, int ym, float a);
void render(int xm, int ym, float a); virtual void lostFocus();
virtual void lostFocus(); virtual void keyPressed(int eventKey);
virtual void keyPressed(int eventKey); virtual void charPressed(char inputChar);
virtual void charPressed(char inputChar); void setupPositions();
void setupPositions(); void buttonClicked(Button* button);
void buttonClicked(Button* button); protected:
protected: bool isShowingKeyboard;
bool isShowingKeyboard; SignTileEntity* sign;
SignTileEntity* sign; int frame;
int frame; int line;
int line; private:
private: ImageButton btnClose;
ImageButton btnClose; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__TextEditScreen_H__*/

View File

@@ -1,36 +1,34 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__UploadPhotoScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__UploadPhotoScreen_H__
#include "Screen.h"
#include "Screen.h"
class UploadPhotoScreen : public Screen
class UploadPhotoScreen : public Screen {
{ public:
public:
UploadPhotoScreen();
UploadPhotoScreen(); virtual ~UploadPhotoScreen() {}
virtual ~UploadPhotoScreen() {}
virtual void init();
virtual void init();
void render(int xm, int ym, float a) {
void render(int xm, int ym, float a) { Screen::render(xm, ym, a);
Screen::render(xm, ym, a); }
}
protected:
protected:
virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseClicked(int x, int y, int buttonNum); virtual void mouseReleased(int x, int y, int buttonNum);
virtual void mouseReleased(int x, int y, int buttonNum); virtual void keyPressed(int eventKey);
virtual void keyPressed(int eventKey);
private:
private:
int selectedItem;
int selectedItem;
void renderSlots();
void renderSlots(); void renderSlot(int slot, int x, int y, float a);
void renderSlot(int slot, int x, int y, float a);
int getSelectedSlot(int x, int y);
int getSelectedSlot(int x, int y); void selectSlotAndClose();
void selectSlotAndClose(); };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__UploadPhotoScreen_H__*/

View File

@@ -1,5 +1,4 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__UsernameScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__UsernameScreen_H__
#include "../Screen.h" #include "../Screen.h"
#include "../components/Button.h" #include "../components/Button.h"
@@ -34,4 +33,3 @@ private:
int _cursorBlink; int _cursorBlink;
}; };
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__UsernameScreen_H__*/

View File

@@ -1,10 +1,8 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_CraftingFilters_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_CraftingFilters_H__
class ItemInstance;
class ItemInstance;
namespace CraftingFilters {
namespace CraftingFilters { bool isStonecutterItem(const ItemInstance& item);
bool isStonecutterItem(const ItemInstance& item); }
}
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_CraftingFilters_H__*/

View File

@@ -1,106 +1,104 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_PaneCraftingScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_PaneCraftingScreen_H__
#include "../../Screen.h"
#include "../../Screen.h" #include "../../../../world/item/crafting/Recipes.h"
#include "../../../../world/item/crafting/Recipes.h" #include "../../../../world/item/ItemInstance.h"
#include "../../../../world/item/ItemInstance.h"
#include "../../components/ScrollingPane.h"
#include "../../components/ScrollingPane.h" #include "../../components/ImageButton.h"
#include "../../components/ImageButton.h" #include "../../components/ItemPane.h"
#include "../../components/ItemPane.h"
class Font;
class Font; class CItem;
class CItem; class Textures;
class Textures; class NinePatchLayer;
class NinePatchLayer;
class CraftButton: public ImageButton
class CraftButton: public ImageButton {
{ typedef ImageButton super;
typedef ImageButton super; public:
public: CraftButton(int id);
CraftButton(int id); ~CraftButton();
~CraftButton();
void init(Textures*);
void init(Textures*); void setSize(float w, float h);
void setSize(float w, float h);
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(Minecraft* minecraft, int xm, int ym); private:
private: NinePatchLayer* bg;
NinePatchLayer* bg; NinePatchLayer* bgSelected;
NinePatchLayer* bgSelected; int numItems;
int numItems; };
};
class PaneCraftingScreen: public Screen,
class PaneCraftingScreen: public Screen, public IItemPaneCallback
public IItemPaneCallback {
{ typedef Screen super;
typedef Screen super; typedef std::vector<CItem*> ItemList;
typedef std::vector<CItem*> ItemList; public:
public: PaneCraftingScreen(int craftingSize);
PaneCraftingScreen(int craftingSize); ~PaneCraftingScreen();
~PaneCraftingScreen();
void init();
void init(); void setupPositions();
void setupPositions();
void tick();
void tick(); void render(int xm, int ym, float a);
void render(int xm, int ym, float a); bool renderGameBehind();
bool renderGameBehind(); bool closeOnPlayerHurt();
bool closeOnPlayerHurt(); void buttonClicked(Button* button);
void buttonClicked(Button* button); void keyPressed( int eventKey );
void keyPressed( int eventKey );
// IItemPaneCallback
// IItemPaneCallback void onItemSelected(const ItemPane* forPane, int itemIndexInCurrentCategory);
void onItemSelected(const ItemPane* forPane, int itemIndexInCurrentCategory); const std::vector<CItem*>& getItems(const ItemPane* forPane);
const std::vector<CItem*>& getItems(const ItemPane* forPane); protected:
protected: void setSingleCategoryAndIcon(int categoryBitmask, int categoryIcon);
void setSingleCategoryAndIcon(int categoryBitmask, int categoryIcon); private:
private: /// Filter out non craftable recipes.
/// Filter out non craftable recipes. /// The default implementation calls bool filterRecipe(r) for every
/// The default implementation calls bool filterRecipe(r) for every /// Recipe r and keeps the ones that returned true.
/// Recipe r and keeps the ones that returned true. /// A crafting size filter has already been applied.
/// A crafting size filter has already been applied. virtual void filterRecipes(RecipeList& recipes);
virtual void filterRecipes(RecipeList& recipes); virtual bool filterRecipe(const Recipe& recipe) = 0;
virtual bool filterRecipe(const Recipe& recipe) = 0;
void initCategories();
void initCategories();
void addItem(Recipe* recipe);
void addItem(Recipe* recipe); void recheckRecipes();
void recheckRecipes(); void onItemSelected(int buttonIndex, CItem* item);
void onItemSelected(int buttonIndex, CItem* item); void clearCategoryItems();
void clearCategoryItems();
void craftSelectedItem();
void craftSelectedItem(); std::vector<ImageButton*> _categoryButtons;
std::vector<ImageButton*> _categoryButtons;
ItemList _items;
ItemList _items; std::vector<ItemList> _categories;
std::vector<ItemList> _categories;
int currentCategory;
int currentCategory; CItem* currentItem;
CItem* currentItem; std::string currentItemDesc;
std::string currentItemDesc; std::vector<Button*> currentCategoryButtons;
std::vector<Button*> currentCategoryButtons; ImageButton btnClose;
ImageButton btnClose; CraftButton btnCraft;
CraftButton btnCraft;
int craftingSize;
int craftingSize;
ItemPane* pane;
ItemPane* pane; IntRectangle paneRect;
IntRectangle paneRect; //int paneX;
//int paneX; //int paneW;
//int paneW;
int numCategories;
int numCategories; std::vector<int> categoryBitmasks;
std::vector<int> categoryBitmasks; std::vector<int> categoryIcons;
std::vector<int> categoryIcons; ImageButton* selectedCategoryButton;
ImageButton* selectedCategoryButton;
// GUI elements such as 9-Patches
// GUI elements such as 9-Patches NinePatchLayer* guiBackground;
NinePatchLayer* guiBackground; NinePatchLayer* guiSlotCategory;
NinePatchLayer* guiSlotCategory; NinePatchLayer* guiSlotCategorySelected;
NinePatchLayer* guiSlotCategorySelected; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_PaneCraftingScreen_H__*/

View File

@@ -1,17 +1,15 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_StonecutterScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_StonecutterScreen_H__
#include "PaneCraftingScreen.h"
#include "PaneCraftingScreen.h"
class StonecutterScreen: public PaneCraftingScreen
class StonecutterScreen: public PaneCraftingScreen {
{ typedef PaneCraftingScreen super;
typedef PaneCraftingScreen super; public:
public: StonecutterScreen();
StonecutterScreen(); ~StonecutterScreen();
~StonecutterScreen();
private:
private: bool filterRecipe(const Recipe& r);
bool filterRecipe(const Recipe& r); };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_StonecutterScreen_H__*/

View File

@@ -1,17 +1,15 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_WorkbenchScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_WorkbenchScreen_H__
#include "PaneCraftingScreen.h"
#include "PaneCraftingScreen.h"
class WorkbenchScreen: public PaneCraftingScreen
class WorkbenchScreen: public PaneCraftingScreen {
{ typedef PaneCraftingScreen super;
typedef PaneCraftingScreen super; public:
public: WorkbenchScreen(int craftingSize);
WorkbenchScreen(int craftingSize); ~WorkbenchScreen();
~WorkbenchScreen();
private:
private: bool filterRecipe(const Recipe& r);
bool filterRecipe(const Recipe& r); };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_CRAFT_WorkbenchScreen_H__*/

View File

@@ -1,73 +1,71 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchIngameBlockSelectionScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchIngameBlockSelectionScreen_H__
#include "../../Screen.h"
#include "../../Screen.h" #include "../../components/InventoryPane.h"
#include "../../components/InventoryPane.h" #include "../../components/Button.h"
#include "../../components/Button.h" #include "../../components/ScrollingPane.h"
#include "../../components/ScrollingPane.h" #include "../../components/ItemPane.h"
#include "../../components/ItemPane.h" #include "../../TweenData.h"
#include "../../TweenData.h" #include "../../../player/input/touchscreen/TouchAreaModel.h"
#include "../../../player/input/touchscreen/TouchAreaModel.h" #include "../../../../AppPlatform.h"
#include "../../../../AppPlatform.h"
namespace Touch {
namespace Touch {
class IngameBlockSelectionScreen : public Screen,
class IngameBlockSelectionScreen : public Screen, public IInventoryPaneCallback
public IInventoryPaneCallback {
{ typedef Screen super;
typedef Screen super;
public:
public: IngameBlockSelectionScreen();
IngameBlockSelectionScreen(); virtual ~IngameBlockSelectionScreen();
virtual ~IngameBlockSelectionScreen();
virtual void init() override;
virtual void init() override; virtual void setupPositions() override;
virtual void setupPositions() override; virtual void removed() override;
virtual void removed() override;
void tick() override;
void tick() override; void render(int xm, int ym, float a) override;
void render(int xm, int ym, float a) override;
bool hasClippingArea(IntRectangle& out) override;
bool hasClippingArea(IntRectangle& out) override;
// IInventoryPaneCallback
// IInventoryPaneCallback bool addItem(const InventoryPane* pane, int itemId) override;
bool addItem(const InventoryPane* pane, int itemId) override; bool isAllowed(int slot) override;
bool isAllowed(int slot) override; std::vector<const ItemInstance*> getItems(const InventoryPane* forPane) override;
std::vector<const ItemInstance*> getItems(const InventoryPane* forPane) override;
void buttonClicked(Button* button) override;
void buttonClicked(Button* button) override; protected:
protected: virtual void mouseClicked(int x, int y, int buttonNum) override;
virtual void mouseClicked(int x, int y, int buttonNum) override; virtual void mouseReleased(int x, int y, int buttonNum) override;
virtual void mouseReleased(int x, int y, int buttonNum) override;
// also support wheel scrolling
// also support wheel scrolling virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
virtual void mouseWheel(int dx, int dy, int xm, int ym) override; private:
private: void renderDemoOverlay();
void renderDemoOverlay();
//int getLinearSlotId(int x, int y);
//int getLinearSlotId(int x, int y); int getSlotPosX(int slotX);
int getSlotPosX(int slotX); int getSlotPosY(int slotY);
int getSlotPosY(int slotY); int getSlotHeight();
int getSlotHeight();
private:
private: int selectedItem;
int selectedItem; bool _pendingClose;
bool _pendingClose; InventoryPane* _blockList;
InventoryPane* _blockList;
THeader bHeader;
THeader bHeader; ImageButton bDone;
ImageButton bDone; TButton bCraft;
TButton bCraft; TButton bArmor;
TButton bArmor; TButton bMenu;
TButton bMenu;
IntRectangle clippingArea;
IntRectangle clippingArea;
int InventoryRows;
int InventoryRows; int InventorySize;
int InventorySize; int InventoryColumns;
int InventoryColumns; };
};
}
}
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchIngameBlockSelectionScreen_H__*/

View File

@@ -1,74 +1,72 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchJoinGameScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchJoinGameScreen_H__
#include "../../Screen.h"
#include "../../Screen.h" #include "../../components/Button.h"
#include "../../components/Button.h" #include "../../components/RolledSelectionListV.h"
#include "../../components/RolledSelectionListV.h" #include "../../../Minecraft.h"
#include "../../../Minecraft.h" #include "../../../../platform/input/Multitouch.h"
#include "../../../../platform/input/Multitouch.h" #include "../../../../network/RakNetInstance.h"
#include "../../../../network/RakNetInstance.h"
namespace Touch {
namespace Touch {
class JoinGameScreen;
class JoinGameScreen;
class AvailableGamesList : public RolledSelectionListV
class AvailableGamesList : public RolledSelectionListV {
{ int startSelected;
int startSelected; int selectedItem;
int selectedItem; ServerList copiedServerList;
ServerList copiedServerList;
friend class JoinGameScreen;
friend class JoinGameScreen;
public:
public: AvailableGamesList(Minecraft* _minecraft, int _width, int _height)
AvailableGamesList(Minecraft* _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) {
{ }
}
protected:
protected:
virtual int getNumberOfItems() { return (int)copiedServerList.size(); }
virtual int getNumberOfItems() { return (int)copiedServerList.size(); }
virtual void selectCancel();
virtual void selectCancel(); virtual void selectStart(int item);
virtual void selectStart(int item); virtual void selectItem(int item, bool doubleClick);
virtual void selectItem(int item, bool doubleClick);
virtual bool isSelectedItem(int item) { return item == selectedItem; }
virtual bool isSelectedItem(int item) { return item == selectedItem; }
virtual void renderBackground() {}
virtual void renderBackground() {} virtual void renderItem(int i, int x, int y, int h, Tesselator& t);
virtual void renderItem(int i, int x, int y, int h, Tesselator& t); };
};
class JoinGameScreen: public Screen
class JoinGameScreen: public Screen {
{ public:
public: JoinGameScreen();
JoinGameScreen(); virtual ~JoinGameScreen();
virtual ~JoinGameScreen();
void init();
void init(); void setupPositions();
void setupPositions();
virtual bool handleBackEvent(bool isDown);
virtual bool handleBackEvent(bool isDown);
virtual bool isIndexValid(int index);
virtual bool isIndexValid(int index);
virtual void tick();
virtual void tick(); 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 isInGameScreen();
bool isInGameScreen(); private:
private: Button bJoin;
Button bJoin; TButton bBack;
TButton bBack; TButton bJoinByIp;
TButton bJoinByIp; THeader bHeader;
THeader bHeader; AvailableGamesList* gamesList;
AvailableGamesList* gamesList; };
};
};
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchJoinGameScreen_H__*/

View File

@@ -1,122 +1,120 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchSelectWorldScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchSelectWorldScreen_H__
#include "../ConfirmScreen.h"
#include "../ConfirmScreen.h" #include "../../Screen.h"
#include "../../Screen.h" #include "../../TweenData.h"
#include "../../TweenData.h" #include "../../components/ImageButton.h"
#include "../../components/ImageButton.h" #include "../../components/Button.h"
#include "../../components/Button.h" #include "../../components/RolledSelectionListH.h"
#include "../../components/RolledSelectionListH.h" #include "../../../Minecraft.h"
#include "../../../Minecraft.h" #include "../../../../world/level/storage/LevelStorageSource.h"
#include "../../../../world/level/storage/LevelStorageSource.h"
namespace Touch {
namespace Touch {
class SelectWorldScreen;
class SelectWorldScreen;
//
// // Scrolling World selection list
// Scrolling World selection list //
// class TouchWorldSelectionList : public RolledSelectionListH
class TouchWorldSelectionList : public RolledSelectionListH {
{ public:
public: TouchWorldSelectionList(Minecraft* _minecraft, int _width, int _height);
TouchWorldSelectionList(Minecraft* _minecraft, int _width, int _height); virtual void tick();
virtual void tick(); void stepLeft();
void stepLeft(); void stepRight();
void stepRight();
void commit();
void commit(); protected:
protected: virtual int getNumberOfItems();
virtual int getNumberOfItems(); virtual void selectItem(int item, bool doubleClick);
virtual void selectItem(int item, bool doubleClick); virtual bool isSelectedItem(int item);
virtual bool isSelectedItem(int item);
virtual void renderBackground() {}
virtual void renderBackground() {} virtual void renderItem(int i, int x, int y, int h, Tesselator& t);
virtual void renderItem(int i, int x, int y, int h, Tesselator& t); virtual float getPos(float alpha);
virtual float getPos(float alpha); virtual void touched() { mode = 0; }
virtual void touched() { mode = 0; } virtual bool capXPosition();
virtual bool capXPosition();
virtual void selectStart(int item, int localX, int localY);
virtual void selectStart(int item, int localX, int localY); virtual void selectCancel();
virtual void selectCancel(); private:
private: TweenData td;
TweenData td; void tweenInited();
void tweenInited();
int selectedItem;
int selectedItem; bool _newWorldSelected; // Is the PLUS button pressed?
bool _newWorldSelected; // Is the PLUS button pressed? int _height;
int _height; LevelSummaryList levels;
LevelSummaryList levels; std::vector<StringVector> _descriptions;
std::vector<StringVector> _descriptions; StringVector _imageNames;
StringVector _imageNames;
bool hasPickedLevel;
bool hasPickedLevel; LevelSummary pickedLevel;
LevelSummary pickedLevel; int pickedIndex;
int pickedIndex;
int stoppedTick;
int stoppedTick; int currentTick;
int currentTick; float accRatio;
float accRatio; int mode;
int mode;
friend class SelectWorldScreen;
friend class SelectWorldScreen; };
};
//
// // Delete World screen
// Delete World screen //
// class TouchDeleteWorldScreen: public ConfirmScreen
class TouchDeleteWorldScreen: public ConfirmScreen {
{ public:
public: TouchDeleteWorldScreen(const LevelSummary& levelId);
TouchDeleteWorldScreen(const LevelSummary& levelId); protected:
protected: virtual void postResult(bool isOk);
virtual void postResult(bool isOk); private:
private: LevelSummary _level;
LevelSummary _level; };
};
//
// // Select world screen
// Select world screen //
// class SelectWorldScreen: public Screen
class SelectWorldScreen: public Screen {
{ public:
public: SelectWorldScreen();
SelectWorldScreen(); virtual ~SelectWorldScreen();
virtual ~SelectWorldScreen();
virtual void init() override;
virtual void init() override; virtual void setupPositions() override;
virtual void setupPositions() override;
virtual void tick() override;
virtual void tick() override; virtual void render(int xm, int ym, float a) override;
virtual void render(int xm, int ym, float a) override;
virtual bool isIndexValid(int index);
virtual bool isIndexValid(int index); virtual bool handleBackEvent(bool isDown) override;
virtual bool handleBackEvent(bool isDown) override; virtual void buttonClicked(Button* button) override;
virtual void buttonClicked(Button* button) override; virtual void keyPressed(int eventKey) override;
virtual void keyPressed(int eventKey) override;
// support for mouse wheel when desktop code uses touch variant
// support for mouse wheel when desktop code uses touch variant virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
bool isInGameScreen() override;
bool isInGameScreen() override; private:
private: void loadLevelSource();
void loadLevelSource(); std::string getUniqueLevelName(const std::string& level);
std::string getUniqueLevelName(const std::string& level);
ImageButton bDelete;
ImageButton bDelete; TButton bCreate;
TButton bCreate; THeader bHeader;
THeader bHeader; TButton bBack;
TButton bBack; Button bWorldView;
Button bWorldView; TouchWorldSelectionList* worldsList;
TouchWorldSelectionList* worldsList; LevelSummaryList levels;
LevelSummaryList levels;
bool _mouseHasBeenUp;
bool _mouseHasBeenUp; bool _hasStartedLevel;
bool _hasStartedLevel; //LevelStorageSource* levels;
//LevelStorageSource* levels; };
}; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchSelectWorldScreen_H__*/

View File

@@ -1,43 +1,41 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchStartMenuScreen_H__ #pragma once
#define NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchStartMenuScreen_H__
#include "../../Screen.h"
#include "../../Screen.h" #include "../../components/LargeImageButton.h"
#include "../../components/LargeImageButton.h" #include "../../components/ImageButton.h"
#include "../../components/ImageButton.h" #include "../../components/TextBox.h"
#include "../../components/TextBox.h"
namespace Touch {
namespace Touch {
class StartMenuScreen: public Screen
class StartMenuScreen: public Screen {
{ public:
public: StartMenuScreen();
StartMenuScreen(); virtual ~StartMenuScreen();
virtual ~StartMenuScreen();
void init();
void init(); void setupPositions();
void setupPositions();
void render(int xm, int ym, float a);
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
void buttonClicked(Button* button); virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseClicked(int x, int y, int buttonNum); bool handleBackEvent(bool isDown);
bool handleBackEvent(bool isDown); bool isInGameScreen();
bool isInGameScreen(); private:
private:
LargeImageButton bHost;
LargeImageButton bHost; LargeImageButton bJoin;
LargeImageButton bJoin; LargeImageButton bOptions;
LargeImageButton bOptions; ImageButton bQuit; // X close icon
ImageButton bQuit; // X close icon
std::string copyright;
std::string copyright; int copyrightPosX;
int copyrightPosX;
std::string version;
std::string version; int versionPosX;
int versionPosX;
std::string username;
std::string username; };
}; };
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS_TOUCH__TouchStartMenuScreen_H__*/

View File

@@ -1,52 +1,50 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__ChestModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__ChestModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "Model.h"
#include "Model.h" #include "geom/ModelPart.h"
#include "geom/ModelPart.h"
class ChestModel: public Model
class ChestModel: public Model {
{ public:
public: ChestModel()
ChestModel() : lid(0, 0),
: lid(0, 0), lock(0, 0),
lock(0, 0), bottom(0, 0)
bottom(0, 0) {
{ lid.setModel(this);
lid.setModel(this); lid.setTexSize(64, 64);
lid.setTexSize(64, 64); lid.addBox(0.0f, -5, -14, 14, 5, 14, 0);
lid.addBox(0.0f, -5, -14, 14, 5, 14, 0); lid.x = 1;
lid.x = 1; lid.y = 7;
lid.y = 7; lid.z = 15;
lid.z = 15;
lock.setModel(this);
lock.setModel(this); lock.setTexSize(64, 64);
lock.setTexSize(64, 64); lock.addBox(-1, -2, -15, 2, 4, 1, 0);
lock.addBox(-1, -2, -15, 2, 4, 1, 0); lock.x = 8;
lock.x = 8; lock.y = 7;
lock.y = 7; lock.z = 15;
lock.z = 15;
bottom.setModel(this);
bottom.setModel(this); bottom.setTexSize(64, 64);
bottom.setTexSize(64, 64); bottom.addBox(0.0f, 0, 0, 14, 10, 14, 0);
bottom.addBox(0.0f, 0, 0, 14, 10, 14, 0); bottom.x = 1;
bottom.x = 1; bottom.y = 6;
bottom.y = 6; bottom.z = 1;
bottom.z = 1; }
}
void render() {
void render() { lock.xRot = lid.xRot;
lock.xRot = lid.xRot;
lid.render(1 / 16.0f);
lid.render(1 / 16.0f); lock.render(1 / 16.0f);
lock.render(1 / 16.0f); bottom.render(1 / 16.0f);
bottom.render(1 / 16.0f); }
}
ModelPart lid;
ModelPart lid; ModelPart bottom;
ModelPart bottom; ModelPart lock;
ModelPart lock; };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__ChestModel_H__*/

View File

@@ -1,23 +1,21 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__ChickenModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__ChickenModel_H__
#include "Model.h"
#include "Model.h" #include "geom/ModelPart.h"
#include "geom/ModelPart.h"
class Entity;
class Entity;
class ChickenModel: public Model
class ChickenModel: public Model {
{ typedef Model super;
typedef Model super; public:
public: ModelPart head, hair, body, leg0, leg1, wing0, wing1, beak, redThing;
ModelPart head, hair, body, leg0, leg1, wing0, wing1, beak, redThing;
ChickenModel();
ChickenModel();
/*@Override*/
/*@Override*/ void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale);
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale); };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__ChickenModel_H__*/

View File

@@ -1,15 +1,13 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__CowModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__CowModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
#include "QuadrupedModel.h"
class CowModel: public QuadrupedModel
class CowModel: public QuadrupedModel {
{ typedef QuadrupedModel super;
typedef QuadrupedModel super; public:
public: CowModel();
CowModel(); };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__CowModel_H__*/

View File

@@ -1,82 +1,80 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__CreeperModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__CreeperModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "Model.h"
#include "Model.h"
#include "geom/ModelPart.h"
#include "geom/ModelPart.h" #include "../../world/entity/Entity.h"
#include "../../world/entity/Entity.h"
class CreeperModel: public Model
class CreeperModel: public Model {
{ typedef Model super;
typedef Model super; public:
public: ModelPart head, /*hair,*/ body, leg0, leg1, leg2, leg3;
ModelPart head, /*hair,*/ body, leg0, leg1, leg2, leg3;
CreeperModel(float g = 0)
CreeperModel(float g = 0) : head(0, 0),
: head(0, 0), //hair(32, 0),
//hair(32, 0), body(16, 16),
body(16, 16), leg0(0, 16),
leg0(0, 16), leg1(0, 16),
leg1(0, 16), leg2(0, 16),
leg2(0, 16), leg3(0, 16)
leg3(0, 16) {
{ float yo = 4;
float yo = 4;
head.setModel(this);
head.setModel(this); //hair.setModel(this);
//hair.setModel(this); body.setModel(this);
body.setModel(this); leg0.setModel(this);
leg0.setModel(this); leg1.setModel(this);
leg1.setModel(this); leg2.setModel(this);
leg2.setModel(this); leg3.setModel(this);
leg3.setModel(this);
head.addBox(-4, -8, -4, 8, 8, 8, g); // Head
head.addBox(-4, -8, -4, 8, 8, 8, g); // Head head.setPos(0, yo, 0);
head.setPos(0, yo, 0);
// hair.addBox(-4, -8, -4, 8, 8, 8, g + 0.5f); // Head
// hair.addBox(-4, -8, -4, 8, 8, 8, g + 0.5f); // Head // hair.setPos(0, yo, 0);
// hair.setPos(0, yo, 0);
body.addBox(-4, 0, -2, 8, 12, 4, g); // Body
body.addBox(-4, 0, -2, 8, 12, 4, g); // Body body.setPos(0, yo, 0);
body.setPos(0, yo, 0);
leg0.addBox(-2, 0, -2, 4, 6, 4, g); // Leg0
leg0.addBox(-2, 0, -2, 4, 6, 4, g); // Leg0 leg0.setPos(-2, 12 + yo, 4);
leg0.setPos(-2, 12 + yo, 4);
leg1.addBox(-2, 0, -2, 4, 6, 4, g); // Leg1
leg1.addBox(-2, 0, -2, 4, 6, 4, g); // Leg1 leg1.setPos(2, 12 + yo, 4);
leg1.setPos(2, 12 + yo, 4);
leg2.addBox(-2, 0, -2, 4, 6, 4, g); // Leg2
leg2.addBox(-2, 0, -2, 4, 6, 4, g); // Leg2 leg2.setPos(-2, 12 + yo, -4);
leg2.setPos(-2, 12 + yo, -4);
leg3.addBox(-2, 0, -2, 4, 6, 4, g); // Leg3
leg3.addBox(-2, 0, -2, 4, 6, 4, g); // Leg3 leg3.setPos(2, 12 + yo, -4);
leg3.setPos(2, 12 + yo, -4); }
}
/*@Override*/
/*@Override*/ void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale) {
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale) { setupAnim(time, r, bob, yRot, xRot, scale);
setupAnim(time, r, bob, yRot, xRot, scale);
head.render(scale);
head.render(scale); body.render(scale);
body.render(scale); leg0.render(scale);
leg0.render(scale); leg1.render(scale);
leg1.render(scale); leg2.render(scale);
leg2.render(scale); leg3.render(scale);
leg3.render(scale); }
}
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) { head.yRot = yRot / (float) (180 / Mth::PI);
head.yRot = yRot / (float) (180 / Mth::PI); head.xRot = xRot / (float) (180 / Mth::PI);
head.xRot = xRot / (float) (180 / Mth::PI);
const float pend = (Mth::cos(time * 0.6662f) * 1.4f) * r;
const float pend = (Mth::cos(time * 0.6662f) * 1.4f) * r; leg0.xRot = pend;
leg0.xRot = pend; leg1.xRot = -pend;
leg1.xRot = -pend; leg2.xRot = -pend;
leg2.xRot = -pend; leg3.xRot = pend;
leg3.xRot = pend; }
} };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__CreeperModel_H__*/

View File

@@ -1,28 +1,26 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__HumanoidModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__HumanoidModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "Model.h"
#include "Model.h" #include "geom/ModelPart.h"
#include "geom/ModelPart.h" class ItemInstance;
class ItemInstance; class HumanoidModel: public Model
class HumanoidModel: public Model {
{ public:
public: HumanoidModel(float g = 0, float yOffset = 0, int texW = 64, int texH = 32);
HumanoidModel(float g = 0, float yOffset = 0, int texW = 64, int texH = 32);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
void render(HumanoidModel* model, float scale);
void render(HumanoidModel* model, float scale); void render(Entity* e, float time, float r, float bob, float yRot, float xRot, float scale);
void render(Entity* e, float time, float r, float bob, float yRot, float xRot, float scale); void renderHorrible(float time, float r, float bob, float yRot, float xRot, float scale);
void renderHorrible(float time, float r, float bob, float yRot, float xRot, float scale); void onGraphicsReset();
void onGraphicsReset();
ModelPart head, hair, body, arm0, arm1, leg0, leg1;//, ear;
ModelPart head, hair, body, arm0, arm1, leg0, leg1;//, ear; bool holdingLeftHand;
bool holdingLeftHand; bool holdingRightHand;
bool holdingRightHand; bool sneaking;
bool sneaking; bool bowAndArrow;
bool bowAndArrow; };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__HumanoidModel_H__*/

View File

@@ -1,48 +1,46 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__Model_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__Model_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include <vector>
#include <vector> #include "geom/ModelPart.h"
#include "geom/ModelPart.h"
class Mob;
class Mob; class Entity;
class Entity;
class Model
class Model {
{ protected:
protected: Model()
Model() : riding(false),
: riding(false), attackTime(0),
attackTime(0), texWidth(64),
texWidth(64), texHeight(32),
texHeight(32), young(true)
young(true) {}
{}
public:
public: virtual ~Model() {}
virtual ~Model() {}
virtual void onGraphicsReset() {
virtual void onGraphicsReset() { for (unsigned int i = 0; i < cubes.size(); ++i)
for (unsigned int i = 0; i < cubes.size(); ++i) cubes[i]->onGraphicsReset();
cubes[i]->onGraphicsReset(); }
}
virtual void render(Entity* e, float time, float r, float bob, float yRot, float xRot, float scale) {}
virtual void render(Entity* e, float time, float r, float bob, float yRot, float xRot, float scale) {} virtual void renderHorrible(float time, float r, float bob, float yRot, float xRot, float scale) {}
virtual void renderHorrible(float time, float r, float bob, float yRot, float xRot, float scale) {} virtual void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {}
virtual void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {} virtual void prepareMobModel(Mob* mob, float time, float r, float a) {}
virtual void prepareMobModel(Mob* mob, float time, float r, float a) {}
float attackTime;
float attackTime; bool riding;
bool riding;
int texWidth;
int texWidth; int texHeight;
int texHeight;
std::vector<ModelPart*> cubes;
std::vector<ModelPart*> cubes; bool young;
bool young; private:
private: //Map<String, TexOffs> mappedTexOffs = new HashMap<String, TexOffs>();
//Map<String, TexOffs> mappedTexOffs = new HashMap<String, TexOffs>(); };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__Model_H__*/

View File

@@ -1,17 +1,15 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__ModelInclude_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__ModelInclude_H__
#include "HumanoidModel.h"
#include "HumanoidModel.h"
#include "ChickenModel.h"
#include "ChickenModel.h" #include "CowModel.h"
#include "CowModel.h" #include "PigModel.h"
#include "PigModel.h" #include "SheepModel.h"
#include "SheepModel.h" #include "SheepFurModel.h"
#include "SheepFurModel.h"
#include "ZombieModel.h"
#include "ZombieModel.h" #include "SkeletonModel.h"
#include "SkeletonModel.h"
#include "SignModel.h"
#include "SignModel.h"
#endif /*NET_MINECRAFT_CLIENT_MODEL__ModelInclude_H__*/

View File

@@ -1,15 +1,13 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__PigModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__PigModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
#include "QuadrupedModel.h"
class PigModel: public QuadrupedModel
class PigModel: public QuadrupedModel {
{ typedef QuadrupedModel super;
typedef QuadrupedModel super; public:
public: PigModel(float g = 0);
PigModel(float g = 0); };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__PigModel_H__*/

View File

@@ -1,28 +1,26 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__QuadrupedModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__QuadrupedModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "Model.h"
#include "Model.h" #include "geom/ModelPart.h"
#include "geom/ModelPart.h"
class Entity;
class Entity;
class QuadrupedModel: public Model
class QuadrupedModel: public Model {
{ public:
public: QuadrupedModel(int legSize, float g);
QuadrupedModel(int legSize, float g);
//@Override
//@Override void render(QuadrupedModel* model, float scale);
void render(QuadrupedModel* model, float scale); void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale);
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
ModelPart head, hair, body, leg0, leg1, leg2, leg3;
ModelPart head, hair, body, leg0, leg1, leg2, leg3; protected:
protected: float yHeadOffs;
float yHeadOffs; float zHeadOffs;
float zHeadOffs; };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__QuadrupedModel_H__*/

View File

@@ -1,24 +1,22 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__SheepFurModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__SheepFurModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
#include "QuadrupedModel.h"
class SheepFurModel: public QuadrupedModel
class SheepFurModel: public QuadrupedModel {
{ typedef QuadrupedModel super;
typedef QuadrupedModel super;
public:
public: SheepFurModel();
SheepFurModel();
/*@Override*/
/*@Override*/ void prepareMobModel(Mob* mob, float time, float r, float a);
void prepareMobModel(Mob* mob, float time, float r, float a);
/*@Override*/
/*@Override*/ void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale); private:
private: float headXRot;
float headXRot; };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__SheepFurModel_H__*/

View File

@@ -1,23 +1,21 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__SheepModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__SheepModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "QuadrupedModel.h"
#include "QuadrupedModel.h"
class SheepModel: public QuadrupedModel
class SheepModel: public QuadrupedModel {
{ typedef QuadrupedModel super;
typedef QuadrupedModel super; public:
public: SheepModel();
SheepModel();
/*@Override*/
/*@Override*/ void prepareMobModel(Mob* mob, float time, float r, float a);
void prepareMobModel(Mob* mob, float time, float r, float a);
/*@Override*/
/*@Override*/ void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale);
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale); private:
private: float headXRot;
float headXRot; };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__SheepModel_H__*/

View File

@@ -1,32 +1,30 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__SignModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__SignModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "Model.h"
#include "Model.h" #include "geom/ModelPart.h"
#include "geom/ModelPart.h"
class SignModel: public Model
class SignModel: public Model {
{ public:
public: SignModel()
SignModel() : cube(0, 0),
: cube(0, 0), cube2(0, 14)
cube2(0, 14) {
{ cube.addBox(-12, -14, -1, 24, 12, 2, 0);
cube.addBox(-12, -14, -1, 24, 12, 2, 0); cube2.addBox(-1, -2, -1, 2, 14, 2, 0);
cube2.addBox(-1, -2, -1, 2, 14, 2, 0);
cube.setModel(this);
cube.setModel(this); cube2.setModel(this);
cube2.setModel(this); }
}
void render() {
void render() { cube.render(1 / 16.0f);
cube.render(1 / 16.0f); cube2.render(1 / 16.0f);
cube2.render(1 / 16.0f); }
}
ModelPart cube;
ModelPart cube; ModelPart cube2;
ModelPart cube2; };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__SignModel_H__*/

View File

@@ -1,46 +1,44 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__SkeletonModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__SkeletonModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "ZombieModel.h"
#include "ZombieModel.h" #include "geom/ModelPart.h"
#include "geom/ModelPart.h"
class SkeletonModel: public ZombieModel
class SkeletonModel: public ZombieModel {
{ typedef ZombieModel super;
typedef ZombieModel super; public:
public: SkeletonModel()
SkeletonModel() {
{ float g = 0;
float g = 0;
arm0 = ModelPart(24 + 16, 16);
arm0 = ModelPart(24 + 16, 16); arm0.setModel(this);
arm0.setModel(this); arm0.addBox(-1, -2, -1, 2, 12, 2, g); // Arm0
arm0.addBox(-1, -2, -1, 2, 12, 2, g); // Arm0 arm0.setPos(-5, 2, 0);
arm0.setPos(-5, 2, 0);
arm1 = ModelPart(24 + 16, 16);
arm1 = ModelPart(24 + 16, 16); arm1.setModel(this);
arm1.setModel(this); arm1.mirror = true;
arm1.mirror = true; arm1.addBox(-1, -2, -1, 2, 12, 2, g); // Arm1
arm1.addBox(-1, -2, -1, 2, 12, 2, g); // Arm1 arm1.setPos(5, 2, 0);
arm1.setPos(5, 2, 0);
leg0 = ModelPart(0, 16);
leg0 = ModelPart(0, 16); leg0.setModel(this);
leg0.setModel(this); leg0.addBox(-1, 0, -1, 2, 12, 2, g); // Leg0
leg0.addBox(-1, 0, -1, 2, 12, 2, g); // Leg0 leg0.setPos(-2, 12, 0);
leg0.setPos(-2, 12, 0);
leg1 = ModelPart(0, 16);
leg1 = ModelPart(0, 16); leg1.setModel(this);
leg1.setModel(this); leg1.mirror = true;
leg1.mirror = true; leg1.addBox(-1, 0, -1, 2, 12, 2, g); // Leg1
leg1.addBox(-1, 0, -1, 2, 12, 2, g); // Leg1 leg1.setPos(2, 12, 0);
leg1.setPos(2, 12, 0); }
}
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) { bowAndArrow = true;
bowAndArrow = true; super::setupAnim(time, r, bob, yRot, xRot, scale);
super::setupAnim(time, r, bob, yRot, xRot, scale); }
} };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__SkeletonModel_H__*/

View File

@@ -1,168 +1,166 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__SpiderModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__SpiderModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "Model.h"
#include "Model.h"
#include "geom/ModelPart.h"
#include "geom/ModelPart.h" #include "../../world/entity/Entity.h"
#include "../../world/entity/Entity.h" #include "../../util/Mth.h"
#include "../../util/Mth.h"
class SpiderModel: public Model
class SpiderModel: public Model {
{ typedef Model super;
typedef Model super; public:
public: ModelPart head, body0, body1, leg0, leg1, leg2, leg3, leg4, leg5, leg6, leg7;
ModelPart head, body0, body1, leg0, leg1, leg2, leg3, leg4, leg5, leg6, leg7;
SpiderModel()
SpiderModel() : head(32, 4),
: head(32, 4), body0(0, 0),
body0(0, 0), body1(0, 12),
body1(0, 12), leg0(18, 0),
leg0(18, 0), leg1(18, 0),
leg1(18, 0), leg2(18, 0),
leg2(18, 0), leg3(18, 0),
leg3(18, 0), leg4(18, 0),
leg4(18, 0), leg5(18, 0),
leg5(18, 0), leg6(18, 0),
leg6(18, 0), leg7(18, 0)
leg7(18, 0) {
{ float g = 0;
float g = 0;
head.setModel(this);
head.setModel(this); body0.setModel(this);
body0.setModel(this); body0.setModel(this);
body0.setModel(this); leg0.setModel(this);
leg0.setModel(this); leg1.setModel(this);
leg1.setModel(this); leg2.setModel(this);
leg2.setModel(this); leg3.setModel(this);
leg3.setModel(this); leg4.setModel(this);
leg4.setModel(this); leg5.setModel(this);
leg5.setModel(this); leg6.setModel(this);
leg6.setModel(this); leg7.setModel(this);
leg7.setModel(this);
float yo = 18 + 6 - 9;
float yo = 18 + 6 - 9;
head.addBox(-4, -4, -8, 8, 8, 8, g); // Head
head.addBox(-4, -4, -8, 8, 8, 8, g); // Head head.setPos(0, 0 + yo, -3);
head.setPos(0, 0 + yo, -3);
body0.addBox(-3, -3, -3, 6, 6, 6, g); // Body
body0.addBox(-3, -3, -3, 6, 6, 6, g); // Body body0.setPos(0, yo, 0);
body0.setPos(0, yo, 0);
body1.addBox(-5, -4, -6, 10, 8, 12, g); // Body
body1.addBox(-5, -4, -6, 10, 8, 12, g); // Body body1.setPos(0, 0 + yo, 3 + 6);
body1.setPos(0, 0 + yo, 3 + 6);
leg0.addBox(-15, -1, -1, 16, 2, 2, g); // Leg0
leg0.addBox(-15, -1, -1, 16, 2, 2, g); // Leg0 leg0.setPos(-4, 0 + yo, 2);
leg0.setPos(-4, 0 + yo, 2);
leg1.addBox(-1, -1, -1, 16, 2, 2, g); // Leg1
leg1.addBox(-1, -1, -1, 16, 2, 2, g); // Leg1 leg1.setPos(4, 0 + yo, 2);
leg1.setPos(4, 0 + yo, 2);
leg2.addBox(-15, -1, -1, 16, 2, 2, g); // Leg2
leg2.addBox(-15, -1, -1, 16, 2, 2, g); // Leg2 leg2.setPos(-4, 0 + yo, 1);
leg2.setPos(-4, 0 + yo, 1);
leg3.addBox(-1, -1, -1, 16, 2, 2, g); // Leg3
leg3.addBox(-1, -1, -1, 16, 2, 2, g); // Leg3 leg3.setPos(4, 0 + yo, 1);
leg3.setPos(4, 0 + yo, 1);
leg4.addBox(-15, -1, -1, 16, 2, 2, g); // Leg0
leg4.addBox(-15, -1, -1, 16, 2, 2, g); // Leg0 leg4.setPos(-4, 0 + yo, 0);
leg4.setPos(-4, 0 + yo, 0);
leg5.addBox(-1, -1, -1, 16, 2, 2, g); // Leg1
leg5.addBox(-1, -1, -1, 16, 2, 2, g); // Leg1 leg5.setPos(4, 0 + yo, 0);
leg5.setPos(4, 0 + yo, 0);
leg6.addBox(-15, -1, -1, 16, 2, 2, g); // Leg2
leg6.addBox(-15, -1, -1, 16, 2, 2, g); // Leg2 leg6.setPos(-4, 0 + yo, -1);
leg6.setPos(-4, 0 + yo, -1);
leg7.addBox(-1, -1, -1, 16, 2, 2, g); // Leg3
leg7.addBox(-1, -1, -1, 16, 2, 2, g); // Leg3 leg7.setPos(4, 0 + yo, -1);
leg7.setPos(4, 0 + yo, -1); }
}
/*@Override*/
/*@Override*/ void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale) {
void render(Entity* entity, float time, float r, float bob, float yRot, float xRot, float scale) { setupAnim(time, r, bob, yRot, xRot, scale);
setupAnim(time, r, bob, yRot, xRot, scale);
head.render(scale);
head.render(scale); body0.render(scale);
body0.render(scale); body1.render(scale);
body1.render(scale); leg0.render(scale);
leg0.render(scale); leg1.render(scale);
leg1.render(scale); leg2.render(scale);
leg2.render(scale); leg3.render(scale);
leg3.render(scale); leg4.render(scale);
leg4.render(scale); leg5.render(scale);
leg5.render(scale); leg6.render(scale);
leg6.render(scale); leg7.render(scale);
leg7.render(scale); }
}
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) { head.yRot = yRot / (float) (180 / Mth::PI);
head.yRot = yRot / (float) (180 / Mth::PI); head.xRot = xRot / (float) (180 / Mth::PI);
head.xRot = xRot / (float) (180 / Mth::PI);
const float sr = (float) Mth::PI / 4.0f;
const float sr = (float) Mth::PI / 4.0f; leg0.zRot = -sr;
leg0.zRot = -sr; leg1.zRot = sr;
leg1.zRot = sr;
leg2.zRot = -sr * 0.74f;
leg2.zRot = -sr * 0.74f; leg3.zRot = sr * 0.74f;
leg3.zRot = sr * 0.74f;
leg4.zRot = -sr * 0.74f;
leg4.zRot = -sr * 0.74f; leg5.zRot = sr * 0.74f;
leg5.zRot = sr * 0.74f;
leg6.zRot = -sr;
leg6.zRot = -sr; leg7.zRot = sr;
leg7.zRot = sr;
//float ro = -(float) Mth::PI / 2.0f * 0;
//float ro = -(float) Mth::PI / 2.0f * 0; const float ur = (float) Mth::PI / 8.0f;
const float ur = (float) Mth::PI / 8.0f; const float ur2 = sr;
const float ur2 = sr;
leg0.yRot = ur2;
leg0.yRot = ur2; leg1.yRot = -ur2;
leg1.yRot = -ur2; leg2.yRot = ur;
leg2.yRot = ur; leg3.yRot = -ur;
leg3.yRot = -ur; leg4.yRot = -ur;
leg4.yRot = -ur; leg5.yRot = +ur;
leg5.yRot = +ur; leg6.yRot = -ur2;
leg6.yRot = -ur2; leg7.yRot = +ur2;
leg7.yRot = +ur2;
//static Stopwatch w;
//static Stopwatch w; //w.start();
//w.start();
float c0 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 0 / 4.0f) * 0.4f) * r;
float c0 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 0 / 4.0f) * 0.4f) * r; float c1 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 2 / 4.0f) * 0.4f) * r;
float c1 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 2 / 4.0f) * 0.4f) * r; float c2 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 1 / 4.0f) * 0.4f) * r;
float c2 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 1 / 4.0f) * 0.4f) * r; float c3 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 3 / 4.0f) * 0.4f) * r;
float c3 = -((float) Mth::cos(time * 0.6662f * 2 + Mth::PI * 2 * 3 / 4.0f) * 0.4f) * r;
//LOGI("spider: %f, %f, %f, %f\n", c0, c1, c2, c3);
//LOGI("spider: %f, %f, %f, %f\n", c0, c1, c2, c3);
float s0 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 0 / 4.0f) * 0.4f) * r;
float s0 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 0 / 4.0f) * 0.4f) * r; float s1 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 2 / 4.0f) * 0.4f) * r;
float s1 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 2 / 4.0f) * 0.4f) * r; float s2 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 1 / 4.0f) * 0.4f) * r;
float s2 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 1 / 4.0f) * 0.4f) * r; float s3 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 3 / 4.0f) * 0.4f) * r;
float s3 = std::abs((float) Mth::sin(time * 0.6662f + Mth::PI * 2 * 3 / 4.0f) * 0.4f) * r;
//w.stop();
//w.stop(); //w.printEvery(100);
//w.printEvery(100);
//LOGI("spiddy: %f, %f, %f, %f\n", s0, s1, s2, s3);
//LOGI("spiddy: %f, %f, %f, %f\n", s0, s1, s2, s3);
leg0.yRot += c0;
leg0.yRot += c0; leg1.yRot -= c0;
leg1.yRot -= c0; leg2.yRot += c1;
leg2.yRot += c1; leg3.yRot -= c1;
leg3.yRot -= c1; leg4.yRot += c2;
leg4.yRot += c2; leg5.yRot -= c2;
leg5.yRot -= c2; leg6.yRot += c3;
leg6.yRot += c3; leg7.yRot -= c3;
leg7.yRot -= c3;
leg0.zRot += s0;
leg0.zRot += s0; leg1.zRot -= s0;
leg1.zRot -= s0; leg2.zRot += s1;
leg2.zRot += s1; leg3.zRot -= s1;
leg3.zRot -= s1; leg4.zRot += s2;
leg4.zRot += s2; leg5.zRot -= s2;
leg5.zRot -= s2; leg6.zRot += s3;
leg6.zRot += s3; leg7.zRot -= s3;
leg7.zRot -= s3; }
} };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__SpiderModel_H__*/

View File

@@ -1,37 +1,35 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__ZombieModel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__ZombieModel_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "HumanoidModel.h"
#include "HumanoidModel.h"
class ZombieModel: public HumanoidModel
class ZombieModel: public HumanoidModel {
{ typedef HumanoidModel super;
typedef HumanoidModel super; public:
public: void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) {
void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) { super::setupAnim(time, r, bob, yRot, xRot, scale);
super::setupAnim(time, r, bob, yRot, xRot, scale); if(!holdingLeftHand && !holdingRightHand) {
if(!holdingLeftHand && !holdingRightHand) { float attack2 = (float) Mth::sin(attackTime * Mth::PI);
float attack2 = (float) Mth::sin(attackTime * Mth::PI); float attack = (float) Mth::sin((1 - (1 - attackTime) * (1 - attackTime)) * Mth::PI);
float attack = (float) Mth::sin((1 - (1 - attackTime) * (1 - attackTime)) * Mth::PI); arm0.zRot = 0;// -attack;
arm0.zRot = 0;// -attack; arm1.zRot = 0;// +attack;
arm1.zRot = 0;// +attack; arm0.yRot = -(0.1f - attack2 * 0.6f);
arm0.yRot = -(0.1f - attack2 * 0.6f); arm1.yRot = +(0.1f - attack2 * 0.6f);
arm1.yRot = +(0.1f - attack2 * 0.6f); arm0.xRot = -Mth::PI / 2.0f;
arm0.xRot = -Mth::PI / 2.0f; arm1.xRot = -Mth::PI / 2.0f;
arm1.xRot = -Mth::PI / 2.0f; arm0.xRot -= attack2 * 1.2f - attack * 0.4f;
arm0.xRot -= attack2 * 1.2f - attack * 0.4f; arm1.xRot -= attack2 * 1.2f - attack * 0.4f;
arm1.xRot -= attack2 * 1.2f - attack * 0.4f;
// body.yRot = attack;
// body.yRot = attack; const float zBob = Mth::cos(bob * 0.09f) * 0.05f + 0.05f;
const float zBob = Mth::cos(bob * 0.09f) * 0.05f + 0.05f; const float xBob = Mth::sin(bob * 0.067f) * 0.05f;
const float xBob = Mth::sin(bob * 0.067f) * 0.05f; arm0.zRot += zBob;
arm0.zRot += zBob; arm1.zRot -= zBob;
arm1.zRot -= zBob; arm0.xRot += xBob;
arm0.xRot += xBob; arm1.xRot -= xBob;
arm1.xRot -= xBob; }
} }
} };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__ZombieModel_H__*/

View File

@@ -1,29 +1,27 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL_GEOM__Cube_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL_GEOM__Cube_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include <string>
#include <string> #include "Polygon.h"
#include "Polygon.h"
class Tesselator;
class Tesselator; class ModelPart;
class ModelPart;
class Cube
class Cube {
{ public:
public: Cube(ModelPart* modelPart, int xTexOffs, int yTexOffs, float x0, float y0, float z0, int w, int h, int d, float g);
Cube(ModelPart* modelPart, int xTexOffs, int yTexOffs, float x0, float y0, float z0, int w, int h, int d, float g);
void compile(Tesselator& t, float scale);
void compile(Tesselator& t, float scale); Cube* setId(const std::string& id);
Cube* setId(const std::string& id); private:
private:
VertexPT vertices[8];
VertexPT vertices[8]; PolygonQuad polygons[6];
PolygonQuad polygons[6]; std::string id;
std::string id; const float x0, y0, z0, x1, y1, z1;
const float x0, y0, z0, x1, y1, z1;
friend class ModelPart;
friend class ModelPart; };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL_GEOM__Cube_H__*/

View File

@@ -1,74 +1,72 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL_GEOM__ModelPart_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL_GEOM__ModelPart_H__
#include "../../renderer/gles.h"
#include "../../renderer/gles.h"
class Model;
class Model; class Cube;
class Cube;
class ModelPart
class ModelPart {
{ public:
public: ModelPart(const std::string& id);
ModelPart(const std::string& id); ModelPart(int xTexOffs = 0, int yTexOffs = 0);
ModelPart(int xTexOffs = 0, int yTexOffs = 0); ModelPart(Model* model, int xTexOffs = 0, int yTexOffs = 0);
ModelPart(Model* model, int xTexOffs = 0, int yTexOffs = 0); ~ModelPart();
~ModelPart();
void _init();
void _init(); void clear();//const ModelPart& rhs);
void clear();//const ModelPart& rhs); ModelPart& operator=(const ModelPart& rhs);
ModelPart& operator=(const ModelPart& rhs);
void setModel(Model* model);
void setModel(Model* model);
void setPos( float x, float y, float z );
void setPos( float x, float y, float z ); void translateTo( float scale );
void translateTo( float scale );
ModelPart& setTexSize(int xs, int ys);
ModelPart& setTexSize(int xs, int ys); ModelPart& texOffs(int xTexOffs, int yTexOffs);
ModelPart& texOffs(int xTexOffs, int yTexOffs);
void mimic(const ModelPart* o);
void mimic(const ModelPart* o);
// Render normally
// Render normally void render( float scale );
void render( float scale ); void renderRollable( float scale );
void renderRollable( float scale ); void draw();
void draw(); // Bad, immediate version... //@fix @todo: remove this
// Bad, immediate version... //@fix @todo: remove this void renderHorrible(float scale);
void renderHorrible(float scale); void drawSlow( float scale );
void drawSlow( float scale );
void onGraphicsReset() { compiled = false; }
void onGraphicsReset() { compiled = false; } void compile( float scale );
void compile( float scale );
void addChild(ModelPart* child);
void addChild(ModelPart* child); ModelPart& addBox(const std::string& id, float x0, float y0, float z0, int w, int h, int d);
ModelPart& addBox(const std::string& id, float x0, float y0, float z0, int w, int h, int d); ModelPart& addBox(float x0, float y0, float z0, int w, int h, int d);
ModelPart& addBox(float x0, float y0, float z0, int w, int h, int d); void addBox(float x0, float y0, float z0, int w, int h, int d, float g);
void addBox(float x0, float y0, float z0, int w, int h, int d, float g); void addTexBox(float x0, float y0, float z0, int w, int h, int d, int tex);
void addTexBox(float x0, float y0, float z0, int w, int h, int d, int tex);
float x, y, z;
float x, y, z; float xRot, yRot, zRot;
float xRot, yRot, zRot;
bool mirror;
bool mirror; bool visible;
bool visible;
std::vector<Cube*> cubes;
std::vector<Cube*> cubes; std::vector<ModelPart*> children;
std::vector<ModelPart*> children;
std::string id;
std::string id;
float xTexSize;
float xTexSize; float yTexSize;
float yTexSize;
private:
private: int xTexOffs, yTexOffs;
int xTexOffs, yTexOffs;
bool neverRender;
bool neverRender;
bool compiled;
bool compiled; int list;
int list; GLuint vboId;
GLuint vboId;
Model* model;
Model* model; };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL_GEOM__ModelPart_H__*/

View File

@@ -1,29 +1,27 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__Polygon_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__Polygon_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model; #include "Vertex.h"
#include "Vertex.h"
class Tesselator;
class Tesselator;
class PolygonQuad
class PolygonQuad {
{ public:
public: PolygonQuad() {}
PolygonQuad() {} PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*);
PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*); PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*, int u0, int v0, int u1, int v1, float texW = 64.0f, float texH = 32.0f);
PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*, int u0, int v0, int u1, int v1, float texW = 64.0f, float texH = 32.0f); PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*, float u0, float v0, float u1, float v1);
PolygonQuad(VertexPT*,VertexPT*,VertexPT*,VertexPT*, float u0, float v0, float u1, float v1);
void mirror();
void mirror(); void render(Tesselator& t, float scale, int vboId = -1);
void render(Tesselator& t, float scale, int vboId = -1); PolygonQuad* flipNormal();
PolygonQuad* flipNormal();
VertexPT vertices[4];
VertexPT vertices[4]; //int vertexCount;
//int vertexCount;
private:
private: static const int VERTEX_COUNT = 4;
static const int VERTEX_COUNT = 4; bool _flipNormal;
bool _flipNormal; };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__Polygon_H__*/

View File

@@ -1,40 +1,38 @@
#ifndef NET_MINECRAFT_CLIENT_MODEL__Vertex_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MODEL__Vertex_H__
//package net.minecraft.client.model;
//package net.minecraft.client.model;
#include "../../../world/phys/Vec3.h"
#include "../../../world/phys/Vec3.h"
class VertexPT
class VertexPT {
{ public:
public: Vec3 pos;
Vec3 pos;
float u, v;
float u, v;
VertexPT() {}
VertexPT() {}
VertexPT(float x, float y, float z, float u_, float v_)
VertexPT(float x, float y, float z, float u_, float v_) : pos(x, y, z),
: pos(x, y, z), u(u_),
u(u_), v(v_)
v(v_) {}
{}
VertexPT remap(float u, float v) {
VertexPT remap(float u, float v) { return VertexPT(*this, u, v);
return VertexPT(*this, u, v); }
}
VertexPT(const VertexPT& vertex, float u_, float v_) {
VertexPT(const VertexPT& vertex, float u_, float v_) { pos = vertex.pos;
pos = vertex.pos; u = u_;
u = u_; v = v_;
v = v_; }
}
VertexPT(const Vec3& pos_, float u_, float v_) {
VertexPT(const Vec3& pos_, float u_, float v_) { pos = pos_;
pos = pos_; u = u_;
u = u_; v = v_;
v = v_; }
} };
};
#endif /*NET_MINECRAFT_CLIENT_MODEL__Vertex_H__*/

View File

@@ -1,265 +1,263 @@
#ifndef NET_MINECRAFT_CLIENT_MULTIPLAYER__MultiPlayerLevel_H__ #pragma once
#define NET_MINECRAFT_CLIENT_MULTIPLAYER__MultiPlayerLevel_H__
#include "../../world/Pos.h"
#include "../../world/Pos.h" #include "../../world/level/Level.h"
#include "../../world/level/Level.h" //#include "../../network/packet/DisconnectPacket.h"
//#include "../../network/packet/DisconnectPacket.h" #include "../../world/entity/Entity.h"
#include "../../world/entity/Entity.h" #include "../../world/level/chunk/ChunkSource.h"
#include "../../world/level/chunk/ChunkSource.h" #include "../../world/level/dimension/Dimension.h"
#include "../../world/level/dimension/Dimension.h" //#include "../../world/level/storage/MockedLevelStorage.h"
//#include "../../world/level/storage/MockedLevelStorage.h"
#include <set>
#include <set> #include <map>
#include <map> #include <list>
#include <list>
class MultiPlayerLevel: public Level
class MultiPlayerLevel: public Level {
{ typedef Level super;
typedef Level super; typedef std::map<int, Entity*> EntityIdMap;
typedef std::map<int, Entity*> EntityIdMap; typedef std::set<Entity*> EntitySet;
typedef std::set<Entity*> EntitySet;
static const int TICKS_BEFORE_RESET = SharedConstants::TicksPerSecond * 4;
static const int TICKS_BEFORE_RESET = SharedConstants::TicksPerSecond * 4;
class ResetInfo {
class ResetInfo { public:
public: int x, y, z, ticks, tile, data;
int x, y, z, ticks, tile, data;
ResetInfo(int x, int y, int z, int tile, int data)
ResetInfo(int x, int y, int z, int tile, int data) : x(x),
: x(x), y(y),
y(y), z(z),
z(z), ticks(TICKS_BEFORE_RESET),
ticks(TICKS_BEFORE_RESET), tile(tile),
tile(tile), data(data)
data(data) {}
{} };
}; typedef std::list<ResetInfo> ResetInfoList;
typedef std::list<ResetInfo> ResetInfoList;
public:
public: MultiPlayerLevel(LevelStorage* levelStorage, const std::string& levelName, const LevelSettings& settings, int levelVersion)
MultiPlayerLevel(LevelStorage* levelStorage, const std::string& levelName, const LevelSettings& settings, int levelVersion) : super(levelStorage, levelName, settings, levelVersion)
: super(levelStorage, levelName, settings, levelVersion) {
{ //super(new MockedLevelStorage(), "MpServer", Dimension.getNew(dimension), levelSettings);
//super(new MockedLevelStorage(), "MpServer", Dimension.getNew(dimension), levelSettings); //this->difficulty = difficulty;
//this->difficulty = difficulty; //setSpawnPos(new Pos(8, 64, 8));
//setSpawnPos(new Pos(8, 64, 8)); //this.savedDataStorage = connection.savedDataStorage;
//this.savedDataStorage = connection.savedDataStorage; }
}
//@todo: destructor (to <delete> Entities)
//@todo: destructor (to <delete> Entities)
void tick() {
void tick() { if (adventureSettings.doTickTime) {
if (adventureSettings.doTickTime) { setTime(getTime() + 1);
setTime(getTime() + 1); }
} 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();
EntitySet::iterator 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);
EntityList::iterator 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 (ResetInfoList::iterator 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); super::sendTileUpdated(r.x, r.y, r.z);
super::sendTileUpdated(r.x, r.y, r.z); it = updatesToReset.erase(it);
it = updatesToReset.erase(it); } else
} else ++it;
++it; }
} }
}
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 (ResetInfoList::iterator 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); } else
} else ++it;
++it; }
} }
}
void validateSpawn() {
void validateSpawn() { setSpawnPos(Pos(8, 64, 8));
setSpawnPos(Pos(8, 64, 8)); }
}
void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay) {
void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay) { }
}
bool tickPendingTicks(bool force) {
bool tickPendingTicks(bool force) { return false;
return false; }
}
//@todo
//@todo //void setChunkVisible(int x, int z, bool visible) {
//void setChunkVisible(int x, int z, bool visible) { // if (visible) chunkCache.create(x, z);
// if (visible) chunkCache.create(x, z); // else chunkCache.drop(x, z);
// else chunkCache.drop(x, z); // if (!visible) {
// if (!visible) { // this->setTilesDirty(x * 16, 0, z * 16, x * 16 + 15, depth, z * 16 + 15);
// this->setTilesDirty(x * 16, 0, z * 16, x * 16 + 15, depth, z * 16 + 15); // }
// } //}
//}
bool addEntity(Entity* e) {
bool addEntity(Entity* e) { bool ok = super::addEntity(e);
bool ok = super::addEntity(e); forced.insert(e);
forced.insert(e);
if (!ok) {
if (!ok) { reEntries.insert(e);
reEntries.insert(e); }
}
return ok;
return ok; }
}
void removeEntity(Entity* e) {
void removeEntity(Entity* e) { super::removeEntity(e);
super::removeEntity(e); forced.erase(e);
forced.erase(e); }
}
void putEntity(int id, Entity* e) {
void putEntity(int id, Entity* e) { Entity* old = getEntity(id);
Entity* old = getEntity(id); if (old != NULL) {
if (old != NULL) { removeEntity(old);
removeEntity(old); }
}
forced.insert(e);
forced.insert(e); e->entityId = id;
e->entityId = id; if (!addEntity(e)) {
if (!addEntity(e)) { reEntries.insert(e);
reEntries.insert(e); }
} entitiesById.insert(std::make_pair(id, e));
entitiesById.insert(std::make_pair(id, e)); }
}
Entity* getEntity(int id) {
Entity* getEntity(int id) { EntityIdMap::const_iterator cit = entitiesById.find(id);
EntityIdMap::const_iterator cit = entitiesById.find(id); return cit != entitiesById.end()? cit->second : NULL;
return cit != entitiesById.end()? cit->second : NULL; }
}
Entity* removeEntity(int id) {
Entity* removeEntity(int id) { EntityIdMap::iterator it = entitiesById.find(id);
EntityIdMap::iterator 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); removeEntity(e);
removeEntity(e); return it->second;
return it->second; }
} return NULL;
return NULL; }
}
bool setDataNoUpdate(int x, int y, int z, int data) {
bool setDataNoUpdate(int x, int y, int z, int data) { int t = getTile(x, y, z);
int t = getTile(x, y, z); int d = getData(x, y, z);
int d = getData(x, y, z); if (super::setDataNoUpdate(x, y, z, data)) {
if (super::setDataNoUpdate(x, y, z, data)) { updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d));
updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d)); return true;
return true; }
} return false;
return false; }
}
bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data) {
bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data) { int t = getTile(x, y, z);
int t = getTile(x, y, z); int d = getData(x, y, z);
int d = getData(x, y, z); if (super::setTileAndDataNoUpdate(x, y, z, tile, data)) {
if (super::setTileAndDataNoUpdate(x, y, z, tile, data)) { updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d));
updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d)); return true;
return true; }
} return false;
return false; }
}
bool setTileNoUpdate(int x, int y, int z, int tile) {
bool setTileNoUpdate(int x, int y, int z, int tile) { int t = getTile(x, y, z);
int t = getTile(x, y, z); int d = getData(x, y, z);
int d = getData(x, y, z); if (super::setTileNoUpdate(x, y, z, tile)) {
if (super::setTileNoUpdate(x, y, z, tile)) { updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d));
updatesToReset.push_back(/*new*/ ResetInfo(x, y, z, t, d)); return true;
return true; }
} return false;
return false; }
}
bool doSetTileAndData(int x, int y, int z, int tile, int data) {
bool doSetTileAndData(int x, int y, int z, int tile, int data) { clearResetRegion(x, y, z, x, y, z);
clearResetRegion(x, y, z, x, y, z); if (super::setTileAndDataNoUpdate(x, y, z, tile, data)) {
if (super::setTileAndDataNoUpdate(x, y, z, tile, data)) { // if (setTile(x, y, z, tile)) {
// if (setTile(x, y, z, tile)) { // setData(x, y, z, data);
// setData(x, y, z, data); tileUpdated(x, y, z, tile);
tileUpdated(x, y, z, tile); return true;
return true; }
} return false;
return false; }
}
void disconnect() {
void disconnect() { //connection.sendAndDisconnect(/*new*/ DisconnectPacket("Quitting"));
//connection.sendAndDisconnect(/*new*/ DisconnectPacket("Quitting")); }
}
protected:
protected: void tickTiles() {
void tickTiles() { }
} /*@Override*/
/*@Override*/ ChunkSource* createChunkSource() {
ChunkSource* createChunkSource() { //chunkCache = /*new*/ MultiPlayerChunkCache(this);
//chunkCache = /*new*/ MultiPlayerChunkCache(this); //return chunkCache;
//return chunkCache; return NULL;
return NULL; }
}
void entityAdded(Entity* e) {
void entityAdded(Entity* e) { super::entityAdded(e);
super::entityAdded(e); EntitySet::iterator it = reEntries.find(e);
EntitySet::iterator it = reEntries.find(e); if (it != reEntries.end()) {
if (it != reEntries.end()) { reEntries.erase(it);
reEntries.erase(it); }
} }
}
void entityRemoved(Entity* e) {
void entityRemoved(Entity* e) { super::entityRemoved(e);
super::entityRemoved(e); EntitySet::iterator it = forced.find(e);
EntitySet::iterator it = forced.find(e); if (it != forced.end()) {
if (it != forced.end()) { if (e->isAlive()) {
if (e->isAlive()) { reEntries.insert(e);
reEntries.insert(e); } else {
} else { forced.erase(it);
forced.erase(it); }
} }
} }
}
// void tickWeather() {
// void tickWeather() { // if (dimension.hasCeiling) return;
// if (dimension.hasCeiling) return; //
// // if (lightningTime > 0) {
// if (lightningTime > 0) { // lightningTime--;
// lightningTime--; // }
// } //
// // oRainLevel = rainLevel;
// oRainLevel = rainLevel; // if (levelData.isRaining()) {
// if (levelData.isRaining()) { // rainLevel += 0.01;
// rainLevel += 0.01; // } else {
// } else { // rainLevel -= 0.01;
// rainLevel -= 0.01; // }
// } // if (rainLevel < 0) rainLevel = 0;
// if (rainLevel < 0) rainLevel = 0; // if (rainLevel > 1) rainLevel = 1;
// if (rainLevel > 1) rainLevel = 1; //
// // oThunderLevel = thunderLevel;
// oThunderLevel = thunderLevel; // if (levelData.isThundering()) {
// if (levelData.isThundering()) { // thunderLevel += 0.01;
// thunderLevel += 0.01; // } else {
// } else { // thunderLevel -= 0.01;
// thunderLevel -= 0.01; // }
// } // if (thunderLevel < 0) thunderLevel = 0;
// if (thunderLevel < 0) thunderLevel = 0; // if (thunderLevel > 1) thunderLevel = 1;
// if (thunderLevel > 1) thunderLevel = 1; // }
// } private:
private: ResetInfoList updatesToReset;
ResetInfoList updatesToReset; //ClientConnection connection;
//ClientConnection connection; //MultiPlayerChunkCache chunkCache;
//MultiPlayerChunkCache chunkCache;
EntityIdMap entitiesById;
EntityIdMap entitiesById; EntitySet forced;
EntitySet forced; EntitySet reEntries;
EntitySet reEntries; };
};
#endif /*NET_MINECRAFT_CLIENT_MULTIPLAYER__MultiPlayerLevel_H__*/

View File

@@ -1,66 +1,64 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__BreakingItemParticle_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__BreakingItemParticle_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "Particle.h"
#include "Particle.h" #include "../renderer/Tesselator.h"
#include "../renderer/Tesselator.h" #include "../../world/item/Item.h"
#include "../../world/item/Item.h" #include "../../world/level/Level.h"
#include "../../world/level/Level.h" #include "../../world/level/tile/Tile.h"
#include "../../world/level/tile/Tile.h"
class BreakingItemParticle: public Particle
class BreakingItemParticle: public Particle {
{ typedef Particle super;
typedef Particle super; public:
public: BreakingItemParticle(Level* level, float x, float y, float z, Item* item)
BreakingItemParticle(Level* level, float x, float y, float z, Item* item) : super(level, x, y, z, 0, 0, 0)
: super(level, x, y, z, 0, 0, 0) {
{ _init(item);
_init(item); }
}
BreakingItemParticle(Level* level, float x, float y, float z, float xa, float ya, float za, Item* item)
BreakingItemParticle(Level* level, float x, float y, float z, float xa, float ya, float za, Item* item) : super(level, x, y, z, 0, 0, 0)
: super(level, x, y, z, 0, 0, 0) {
{ _init(item);
_init(item);
xd *= 0.1f;
xd *= 0.1f; yd *= 0.1f;
yd *= 0.1f; zd *= 0.1f;
zd *= 0.1f; xd += xa;
xd += xa; yd += ya;
yd += ya; zd += za;
zd += za; }
}
void _init(Item* item) {
void _init(Item* item) { tex = item->getIcon(0);
tex = item->getIcon(0); rCol = gCol = bCol = 1.0f;
rCol = gCol = bCol = 1.0f; gravity = Tile::snow->gravity;
gravity = Tile::snow->gravity; size /= 2;
size /= 2; }
}
int getParticleTexture() {
int getParticleTexture() { return ParticleEngine::ITEM_TEXTURE;
return ParticleEngine::ITEM_TEXTURE; }
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) { float u0 = (tex % 16 + uo / 4.0f) / 16.0f;
float u0 = (tex % 16 + uo / 4.0f) / 16.0f; float u1 = u0 + 0.999f / 16.0f / 4;
float u1 = u0 + 0.999f / 16.0f / 4; float v0 = (tex / 16 + vo / 4.0f) / 16.0f;
float v0 = (tex / 16 + vo / 4.0f) / 16.0f; float v1 = v0 + 0.999f / 16.0f / 4;
float v1 = v0 + 0.999f / 16.0f / 4; float r = 0.1f * size;
float r = 0.1f * size;
float x = (float) (xo + (this->x - xo) * a - xOff);
float x = (float) (xo + (this->x - xo) * a - xOff); float y = (float) (yo + (this->y - yo) * a - yOff);
float y = (float) (yo + (this->y - yo) * a - yOff); float z = (float) (zo + (this->z - zo) * a - zOff);
float z = (float) (zo + (this->z - zo) * a - zOff); float br = getBrightness(a);
float br = getBrightness(a); t.color(br * rCol, br * gCol, br * bCol);
t.color(br * rCol, br * gCol, br * bCol);
t.vertexUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u0, v1);
t.vertexUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u0, v1); t.vertexUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u0, v0);
t.vertexUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u0, v0); t.vertexUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u1, v0);
t.vertexUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u1, v0); t.vertexUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u1, v1);
t.vertexUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u1, v1); }
} };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__BreakingItemParticle_H__*/

View File

@@ -1,51 +1,49 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__BubbleParticle_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__BubbleParticle_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "../../util/Mth.h"
#include "../../util/Mth.h" #include "../../world/level/Level.h"
#include "../../world/level/Level.h" #include "../../world/level/material/Material.h"
#include "../../world/level/material/Material.h" #include "Particle.h"
#include "Particle.h"
class BubbleParticle: public Particle
class BubbleParticle: public Particle {
{ typedef Particle super;
typedef Particle super;
public:
public: BubbleParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
BubbleParticle(Level* level, float x, float y, float z, float xa, float ya, float za) : super(level, x, y, z, xa, ya, za)
: super(level, x, y, z, xa, ya, za) {
{ rCol = 1.0f;
rCol = 1.0f; gCol = 1.0f;
gCol = 1.0f; bCol = 1.0f;
bCol = 1.0f; tex = 32;
tex = 32; this->setSize(0.02f, 0.02f);
this->setSize(0.02f, 0.02f);
size = size*(sharedRandom.nextFloat()*0.6f+0.2f);
size = size*(sharedRandom.nextFloat()*0.6f+0.2f);
xd = xa*0.2f+(float)(Mth::random()*2-1)*0.02f;
xd = xa*0.2f+(float)(Mth::random()*2-1)*0.02f; yd = ya*0.2f+(float)(Mth::random()*2-1)*0.02f;
yd = ya*0.2f+(float)(Mth::random()*2-1)*0.02f; zd = za*0.2f+(float)(Mth::random()*2-1)*0.02f;
zd = za*0.2f+(float)(Mth::random()*2-1)*0.02f;
lifetime = (int) (8 / (Mth::random() * 0.8 + 0.2));
lifetime = (int) (8 / (Mth::random() * 0.8 + 0.2)); }
}
void tick() {
void tick() { xo = x;
xo = x; yo = y;
yo = y; zo = z;
zo = z;
yd += 0.002f;
yd += 0.002f; move(xd, yd, zd);
move(xd, yd, zd); xd *= 0.85f;
xd *= 0.85f; yd *= 0.85f;
yd *= 0.85f; zd *= 0.85f;
zd *= 0.85f;
if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) != Material::water) remove();
if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) != Material::water) remove();
if (lifetime-- <= 0) remove();
if (lifetime-- <= 0) remove(); }
} };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__BubbleParticle_H__*/

View File

@@ -1,74 +1,72 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__CritParticle2_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__CritParticle2_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "Particle.h"
#include "Particle.h" #include "../../util/Mth.h"
#include "../../util/Mth.h" #include "../../world/level/Level.h"
#include "../../world/level/Level.h" #include "../../world/level/material/Material.h"
#include "../../world/level/material/Material.h"
class CritParticle2: public Particle
class CritParticle2: public Particle {
{ typedef Particle super;
typedef Particle super; public:
public: CritParticle2(Level* level, float x, float y, float z, float xa, float ya, float za, float scale = 1.0f)
CritParticle2(Level* level, float x, float y, float z, float xa, float ya, float za, float scale = 1.0f) : super(level, x, y, z, 0, 0, 0),
: super(level, x, y, z, 0, 0, 0), visible(true)
visible(true) {
{ xd *= 0.1f;
xd *= 0.1f; yd *= 0.1f;
yd *= 0.1f; zd *= 0.1f;
zd *= 0.1f; xd += xa * 0.4f;
xd += xa * 0.4f; yd += ya * 0.4f;
yd += ya * 0.4f; zd += za * 0.4f;
zd += za * 0.4f;
rCol = gCol = bCol = (float) (Mth::random() * 0.3f + 0.6f);
rCol = gCol = bCol = (float) (Mth::random() * 0.3f + 0.6f); size *= 0.75f;
size *= 0.75f; size *= scale;
size *= scale; oSize = size;
oSize = size;
lifetime = (int)(6 / (Mth::random() * 0.8f + 0.6f) * scale);
lifetime = (int)(6 / (Mth::random() * 0.8f + 0.6f) * scale); noPhysics = false;
noPhysics = false;
tex = 16 * 4 + 1;
tex = 16 * 4 + 1; tick();
tick(); }
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) { if (!visible) return;
if (!visible) return; float l = ((age + a) / lifetime) * 32;
float l = ((age + a) / lifetime) * 32; if (l < 0) l = 0;
if (l < 0) l = 0; if (l > 1) l = 1;
if (l > 1) l = 1;
size = oSize * l;
size = oSize * l; super::render(t, a, xa, ya, za, xa2, za2);
super::render(t, a, xa, ya, za, xa2, za2); }
}
void tick() {
void tick() { xo = x;
xo = x; yo = y;
yo = y; zo = z;
zo = z;
if (age++ >= lifetime) remove();
if (age++ >= lifetime) remove();
move(xd, yd, zd);
move(xd, yd, zd); gCol *= 0.96f;
gCol *= 0.96f; bCol *= 0.9f;
bCol *= 0.9f;
xd *= 0.70f;
xd *= 0.70f; yd *= 0.70f;
yd *= 0.70f; zd *= 0.70f;
zd *= 0.70f; yd -= 0.02f;
yd -= 0.02f;
if (onGround) {
if (onGround) { xd *= 0.7f;
xd *= 0.7f; zd *= 0.7f;
zd *= 0.7f; }
} }
} protected:
protected: bool visible;
bool visible; float oSize;
float oSize; };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__CritParticle2_H__*/

View File

@@ -1,51 +1,49 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__ExplodeParticle_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__ExplodeParticle_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "Particle.h"
#include "Particle.h" #include "../renderer/Tesselator.h"
#include "../renderer/Tesselator.h" #include "../../world/level/Level.h"
#include "../../world/level/Level.h"
class ExplodeParticle: public Particle
class ExplodeParticle: public Particle {
{ typedef Particle super;
typedef Particle super; public:
public: ExplodeParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
ExplodeParticle(Level* level, float x, float y, float z, float xa, float ya, float za) : super(level, x, y, z, xa, ya, za)
: super(level, x, y, z, xa, ya, za) {
{ xd = xa + (Mth::random()*2.0f-1.0f) * 0.05f;
xd = xa + (Mth::random()*2.0f-1.0f) * 0.05f; yd = ya + (Mth::random()*2.0f-1.0f) * 0.05f;
yd = ya + (Mth::random()*2.0f-1.0f) * 0.05f; zd = za + (Mth::random()*2.0f-1.0f) * 0.05f;
zd = za + (Mth::random()*2.0f-1.0f) * 0.05f;
rCol = gCol = bCol = sharedRandom.nextFloat() * 0.3f + 0.7f;
rCol = gCol = bCol = sharedRandom.nextFloat() * 0.3f + 0.7f; size = sharedRandom.nextFloat() * sharedRandom.nextFloat() * 6.0f + 1.0f;
size = sharedRandom.nextFloat() * sharedRandom.nextFloat() * 6.0f + 1.0f;
lifetime = (int)(16.0f/(sharedRandom.nextFloat() * 0.8f + 0.2f)) + 2;
lifetime = (int)(16.0f/(sharedRandom.nextFloat() * 0.8f + 0.2f)) + 2; // noPhysics = true;
// noPhysics = true; }
}
void tick()
void tick() {
{ xo = x;
xo = x; yo = y;
yo = y; zo = z;
zo = z;
if (age++ >= lifetime) remove();
if (age++ >= lifetime) remove();
tex = 7 - age * 8 / lifetime;
tex = 7 - age * 8 / lifetime;
yd += 0.004f;
yd += 0.004f; move(xd, yd, zd);
move(xd, yd, zd); xd *= 0.90f;
xd *= 0.90f; yd *= 0.90f;
yd *= 0.90f; zd *= 0.90f;
zd *= 0.90f;
if (onGround) {
if (onGround) { xd *= 0.7f;
xd *= 0.7f; zd *= 0.7f;
zd *= 0.7f; }
} }
} };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__ExplodeParticle_H__*/

View File

@@ -1,73 +1,71 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__FlameParticle_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__FlameParticle_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "Particle.h"
#include "Particle.h" #include "../renderer/Tesselator.h"
#include "../renderer/Tesselator.h" #include "../../world/level/Level.h"
#include "../../world/level/Level.h"
class FlameParticle: public Particle
class FlameParticle: public Particle {
{ typedef Particle super;
typedef Particle super; float oSize;
float oSize; public:
public: FlameParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
FlameParticle(Level* level, float x, float y, float z, float xa, float ya, float za) : super(level, x, y, z, xa, ya, za)
: super(level, x, y, z, xa, ya, za) {
{ xd = xd * 0.01f + xa;
xd = xd * 0.01f + xa; yd = yd * 0.01f + ya;
yd = yd * 0.01f + ya; zd = zd * 0.01f + za;
zd = zd * 0.01f + za; x += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f;
x += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f; y += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f;
y += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f; z += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f;
z += (sharedRandom.nextFloat()-sharedRandom.nextFloat()) * 0.05f;
//printf("xd, yd, zd: %f, %f, %f\n", xd, yd, zd);
//printf("xd, yd, zd: %f, %f, %f\n", xd, yd, zd);
oSize = size;
oSize = size; rCol = gCol = bCol = 1.0f;
rCol = gCol = bCol = 1.0f;
lifetime = (int)(8.0f/(Mth::random()*0.8f+0.2f))+4;
lifetime = (int)(8.0f/(Mth::random()*0.8f+0.2f))+4; noPhysics = true;
noPhysics = true; tex = 48;
tex = 48; }
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) { float s = (age + a) / (float) lifetime;
float s = (age + a) / (float) lifetime; size = oSize * (1 - s*s*0.5f);
size = oSize * (1 - s*s*0.5f); super::render(t, a, xa, ya, za, xa2, za2);
super::render(t, a, xa, ya, za, xa2, za2); }
}
float getBrightness(float a) {
float getBrightness(float a) { return 1.0f;
return 1.0f; /*
/* float l = (age+a)/lifetime;
float l = (age+a)/lifetime; if (l<0) l = 0;
if (l<0) l = 0; if (l>1) l = 1;
if (l>1) l = 1; float br = super::getBrightness(a);
float br = super::getBrightness(a);
return br*l+(1-l);
return br*l+(1-l); */
*/ }
}
void tick()
void tick() {
{ xo = x;
xo = x; yo = y;
yo = y; zo = z;
zo = z;
if (age++ >= lifetime) remove();
if (age++ >= lifetime) remove();
move(xd, yd, zd);
move(xd, yd, zd); xd *= 0.96f;
xd *= 0.96f; yd *= 0.96f;
yd *= 0.96f; zd *= 0.96f;
zd *= 0.96f;
if (onGround)
if (onGround) {
{ xd *= 0.7f;
xd *= 0.7f; zd *= 0.7f;
zd *= 0.7f; }
} }
} };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__FlameParticle_H__*/

View File

@@ -1,72 +1,70 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionParticle_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionParticle_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../renderer/Tesselator.h" #include "../renderer/Textures.h"
#include "../renderer/Textures.h" #include "../../world/level/Level.h"
#include "../../world/level/Level.h"
class HugeExplosionParticle: public Particle
class HugeExplosionParticle: public Particle {
{ typedef Particle super;
typedef Particle super; public:
public: HugeExplosionParticle(Textures* textures, Level* level, float x, float y, float z, float xa, float ya, float za)
HugeExplosionParticle(Textures* textures, Level* level, float x, float y, float z, float xa, float ya, float za) : super(level, x, y, z, 0, 0, 0),
: super(level, x, y, z, 0, 0, 0), life(0),
life(0), lifeTime(6 + sharedRandom.nextInt(4)),
lifeTime(6 + sharedRandom.nextInt(4)), textures(textures),
textures(textures), size(1 - xa * 0.5f)
size(1 - xa * 0.5f) {
{ rCol = gCol = bCol = sharedRandom.nextFloat() * 0.6f + 0.4f;
rCol = gCol = bCol = sharedRandom.nextFloat() * 0.6f + 0.4f; }
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) { int tex = (int) ((life + a) * 15 / lifeTime);
int tex = (int) ((life + a) * 15 / lifeTime); if (tex > 15) return;
if (tex > 15) return; textures->loadAndBindTexture("misc/explosion.png");
textures->loadAndBindTexture("misc/explosion.png");
float u0 = (tex % 4) / 4.0f;
float u0 = (tex % 4) / 4.0f; float u1 = u0 + 0.999f / 4.0f;
float u1 = u0 + 0.999f / 4.0f; float v0 = (tex / 4) / 4.0f;
float v0 = (tex / 4) / 4.0f; float v1 = v0 + 0.999f / 4.0f;
float v1 = v0 + 0.999f / 4.0f;
// xa2 = 0;
// xa2 = 0; // za2 = 1;
// za2 = 1;
float r = size + size;
float r = size + size;
float x = xo + (this->x - xo) * a - xOff;
float x = xo + (this->x - xo) * a - xOff; float y = yo + (this->y - yo) * a - yOff;
float y = yo + (this->y - yo) * a - yOff; float z = zo + (this->z - zo) * a - zOff;
float z = zo + (this->z - zo) * a - zOff; const float xar = xa * r, yar = ya * r, zar = za * r;
const float xar = xa * r, yar = ya * r, zar = za * r; const float xa2r = xa2 * r, za2r = za2 * r;
const float xa2r = xa2 * r, za2r = za2 * r; t.begin();
t.begin(); t.color(rCol, gCol, bCol, 1.0f);
t.color(rCol, gCol, bCol, 1.0f); t.vertexUV(x - xar - xa2r, y - yar, z - zar - za2r, u1, v1);
t.vertexUV(x - xar - xa2r, y - yar, z - zar - za2r, u1, v1); t.vertexUV(x - xar + xa2r, y + yar, z - zar + za2r, u1, v0);
t.vertexUV(x - xar + xa2r, y + yar, z - zar + za2r, u1, v0); t.vertexUV(x + xar + xa2r, y + yar, z + zar + za2r, u0, v0);
t.vertexUV(x + xar + xa2r, y + yar, z + zar + za2r, u0, v0); t.vertexUV(x + xar - xa2r, y - yar, z + zar - za2r, u0, v1);
t.vertexUV(x + xar - xa2r, y - yar, z + zar - za2r, u0, v1); t.draw();
t.draw(); //glPolygonOffset(0, 0.0f);
//glPolygonOffset(0, 0.0f); }
}
void tick() {
void tick() { xo = x;
xo = x; yo = y;
yo = y; zo = z;
zo = z; life++;
life++; if (life == lifeTime) remove();
if (life == lifeTime) remove(); }
}
int getParticleTexture() {
int getParticleTexture() { return ParticleEngine::ENTITY_PARTICLE_TEXTURE;
return ParticleEngine::ENTITY_PARTICLE_TEXTURE; }
} private:
private: int life;
int life; int lifeTime;
int lifeTime; float size;
float size; Textures* textures;
Textures* textures; };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionParticle_H__*/

View File

@@ -1,40 +1,38 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionSeedParticle_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionSeedParticle_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "Particle.h"
#include "Particle.h"
class HugeExplosionSeedParticle: public Particle
class HugeExplosionSeedParticle: public Particle {
{ typedef Particle super;
typedef Particle super; public:
public: HugeExplosionSeedParticle(Level* level, float x, float y, float z, float xa, float ya, float za)
HugeExplosionSeedParticle(Level* level, float x, float y, float z, float xa, float ya, float za) : super(level, x, y, z, 0, 0, 0),
: super(level, x, y, z, 0, 0, 0), life(0),
life(0), lifeTime(8)
lifeTime(8) {
{ }
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {}
void tick() {
void tick() { for (int i = 0; i < 6; i++) {
for (int i = 0; i < 6; i++) { float xx = x + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4;
float xx = x + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4; float yy = y + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4;
float yy = y + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4; float zz = z + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4;
float zz = z + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 4; level->addParticle(PARTICLETYPE(largeexplode), xx, yy, zz, life / (float) lifeTime, 0, 0);
level->addParticle(PARTICLETYPE(largeexplode), xx, yy, zz, life / (float) lifeTime, 0, 0); }
} life++;
life++; if (life == lifeTime) remove();
if (life == lifeTime) remove(); }
}
int getParticleTexture() {
int getParticleTexture() { return ParticleEngine::TERRAIN_TEXTURE;
return ParticleEngine::TERRAIN_TEXTURE; }
} private:
private: int life;
int life; int lifeTime;
int lifeTime; };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__HugeExplosionSeedParticle_H__*/

View File

@@ -1,63 +1,61 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__LavaParticle_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__LavaParticle_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../renderer/Tesselator.h" #include "../../world/level/Level.h"
#include "../../world/level/Level.h"
class LavaParticle: public Particle
class LavaParticle: public Particle {
{ typedef Particle super;
typedef Particle super; float oSize;
float oSize; public:
public: LavaParticle(Level* level, float x, float y, float z)
LavaParticle(Level* level, float x, float y, float z) : super(level, x, y, z, 0, 0, 0)
: super(level, x, y, z, 0, 0, 0) {
{ xd *= 0.8f;
xd *= 0.8f; yd *= 0.8f;
yd *= 0.8f; zd *= 0.8f;
zd *= 0.8f; yd = sharedRandom.nextFloat() * 0.4f + 0.05f;
yd = sharedRandom.nextFloat() * 0.4f + 0.05f;
rCol = gCol = bCol = 1;
rCol = gCol = bCol = 1; size *= (sharedRandom.nextFloat() * 2 + 0.2f);
size *= (sharedRandom.nextFloat() * 2 + 0.2f); oSize = size;
oSize = size;
lifetime = (int) (16 / (Mth::random() * 0.8 + 0.2));
lifetime = (int) (16 / (Mth::random() * 0.8 + 0.2)); noPhysics = false;
noPhysics = false; tex = 49;
tex = 49; }
}
float getBrightness(float a) {
float getBrightness(float a) { return 1;
return 1; }
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) { float s = (age + a) / (float) lifetime;
float s = (age + a) / (float) lifetime; size = oSize * (1 - s*s);
size = oSize * (1 - s*s); super::render(t, a, xa, ya, za, xa2, za2);
super::render(t, a, xa, ya, za, xa2, za2); }
}
void tick() {
void tick() { xo = x;
xo = x; yo = y;
yo = y; zo = z;
zo = z;
if (age++ >= lifetime) remove();
if (age++ >= lifetime) remove(); float odds = age / (float) lifetime;
float odds = age / (float) lifetime; if (sharedRandom.nextFloat() > odds) level->addParticle(PARTICLETYPE(smoke), x, y, z, xd, yd, zd);
if (sharedRandom.nextFloat() > odds) level->addParticle(PARTICLETYPE(smoke), x, y, z, xd, yd, zd);
yd -= 0.03f;
yd -= 0.03f; move(xd, yd, zd);
move(xd, yd, zd); xd *= 0.999f;
xd *= 0.999f; yd *= 0.999f;
yd *= 0.999f; zd *= 0.999f;
zd *= 0.999f;
if (onGround) {
if (onGround) { xd *= 0.7f;
xd *= 0.7f; zd *= 0.7f;
zd *= 0.7f; }
} }
} };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__LavaParticle_H__*/

View File

@@ -1,46 +1,44 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__Particle_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__Particle_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../renderer/Tesselator.h" #include "../../world/entity/Entity.h"
#include "../../world/entity/Entity.h" #include "../../world/level/Level.h"
#include "../../world/level/Level.h" #include "ParticleEngine.h"
#include "ParticleEngine.h"
class CompoundTag;
class CompoundTag;
class Particle: public Entity {
class Particle: public Entity { typedef Entity super;
typedef Entity super;
public:
public: static float xOff, yOff, zOff;
static float xOff, yOff, zOff;
Particle(Level* level, float x, float y, float z, float xa, float ya, float za);
Particle(Level* level, float x, float y, float z, float xa, float ya, float za);
virtual ~Particle() {}
virtual ~Particle() {}
Particle* setPower(float power);
Particle* setPower(float power); Particle* scale(float scale);
Particle* scale(float scale);
virtual void tick();
virtual void tick(); virtual void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2);
virtual void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2);
virtual int getParticleTexture();
virtual int getParticleTexture();
virtual void addAdditonalSaveData(CompoundTag* entityTag) {}
virtual void addAdditonalSaveData(CompoundTag* entityTag) {} virtual void readAdditionalSaveData(CompoundTag* tag) {}
virtual void readAdditionalSaveData(CompoundTag* tag) {}
virtual int getEntityTypeId() const { return 0; }
virtual int getEntityTypeId() const { return 0; }
protected:
protected: int tex;
int tex; float uo, vo;
float uo, vo; int age;
int age; int lifetime;
int lifetime; float size;
float size; float gravity;
float gravity; float rCol, gCol, bCol;
float rCol, gCol, bCol; };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__Particle_H__*/

View File

@@ -1,54 +1,52 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__ParticleEngine_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__ParticleEngine_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include <vector>
#include <vector> #include "../../world/entity/Entity.h"
#include "../../world/entity/Entity.h" #include "../../world/level/tile/Tile.h"
#include "../../world/level/tile/Tile.h" #include "../renderer/gles.h"
#include "../renderer/gles.h"
class Textures;
class Textures; class Level;
class Level; class Particle;
class Particle; typedef std::vector<Particle*> ParticleList;
typedef std::vector<Particle*> ParticleList;
class ParticleEngine
class ParticleEngine {
{ public:
public: static const int MISC_TEXTURE = 0;
static const int MISC_TEXTURE = 0; static const int TERRAIN_TEXTURE = 1;
static const int TERRAIN_TEXTURE = 1; static const int ITEM_TEXTURE = 2;
static const int ITEM_TEXTURE = 2; static const int ENTITY_PARTICLE_TEXTURE = 3;
static const int ENTITY_PARTICLE_TEXTURE = 3;
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); void destroy(int x, int y, int z);
void destroy(int x, int y, int z);
void tick();
void tick(); void render(Entity* player, float a);
void render(Entity* player, float a); void renderLit(Entity* player, float a);
void renderLit(Entity* player, float a);
void setLevel(Level* level);
void setLevel(Level* level);
void crack(int x, int y, int z, int face);
void crack(int x, int y, int z, int face);
std::string countParticles();
std::string countParticles();
protected:
protected: void clear();
void clear();
Level* level;
Level* level; GLuint textureIds[4];
GLuint textureIds[4];
private:
private: ParticleList particles[4];
ParticleList particles[4]; Textures* textures;
Textures* textures; Random random;
Random random; };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__ParticleEngine_H__*/

View File

@@ -1,17 +1,15 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__ParticleInclude_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__ParticleInclude_H__
#include "Particle.h"
#include "Particle.h"
#include "BubbleParticle.h"
#include "BubbleParticle.h" #include "CritParticle2.h"
#include "CritParticle2.h" #include "ExplodeParticle.h"
#include "ExplodeParticle.h" #include "FlameParticle.h"
#include "FlameParticle.h" #include "LavaParticle.h"
#include "LavaParticle.h" #include "RedDustParticle.h"
#include "RedDustParticle.h" #include "SmokeParticle.h"
#include "SmokeParticle.h" #include "TerrainParticle.h"
#include "TerrainParticle.h" #include "HugeExplosionSeedParticle.h"
#include "HugeExplosionSeedParticle.h" #include "HugeExplosionParticle.h"
#include "HugeExplosionParticle.h"
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__ParticleInclude_H__*/

View File

@@ -1,73 +1,71 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__RedDustParticle_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__RedDustParticle_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "../renderer/Tesselator.h"
#include "../renderer/Tesselator.h" #include "../../world/level/Level.h"
#include "../../world/level/Level.h"
class RedDustParticle: public Particle
class RedDustParticle: public Particle {
{ typedef Particle super;
typedef Particle super; public:
public: float oSize;
float oSize;
RedDustParticle(Level* level, float x, float y, float z, float rCol, float gCol, float bCol, float scale = 1.0f)
RedDustParticle(Level* level, float x, float y, float z, float rCol, float gCol, float bCol, float scale = 1.0f) : super(level, x, y, z, 0, 0, 0)
: super(level, x, y, z, 0, 0, 0) {
{ xd *= 0.1f;
xd *= 0.1f; yd *= 0.1f;
yd *= 0.1f; zd *= 0.1f;
zd *= 0.1f;
if (rCol == 0) {
if (rCol == 0) { rCol = 1;
rCol = 1; }
} float brr = (float) Mth::random() * 0.4f + 0.6f;
float brr = (float) Mth::random() * 0.4f + 0.6f; this->rCol = ((float) (Mth::random() * 0.2f) + 0.8f) * rCol * brr;
this->rCol = ((float) (Mth::random() * 0.2f) + 0.8f) * rCol * brr; this->gCol = ((float) (Mth::random() * 0.2f) + 0.8f) * gCol * brr;
this->gCol = ((float) (Mth::random() * 0.2f) + 0.8f) * gCol * brr; this->bCol = ((float) (Mth::random() * 0.2f) + 0.8f) * bCol * brr;
this->bCol = ((float) (Mth::random() * 0.2f) + 0.8f) * bCol * brr; size *= 0.75f;
size *= 0.75f; size *= scale;
size *= scale; oSize = size;
oSize = size;
lifetime = (int) (8 / (Mth::random() * 0.8 + 0.2));
lifetime = (int) (8 / (Mth::random() * 0.8 + 0.2)); lifetime = (int)(lifetime * scale);
lifetime = (int)(lifetime * scale); noPhysics = false;
noPhysics = false; }
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) { float l = ((age + a) / lifetime) * 32;
float l = ((age + a) / lifetime) * 32; if (l < 0) l = 0;
if (l < 0) l = 0; if (l > 1) l = 1;
if (l > 1) l = 1;
size = oSize * l;
size = oSize * l; super::render(t, a, xa, ya, za, xa2, za2);
super::render(t, a, xa, ya, za, xa2, za2); }
}
void tick() {
void tick() { xo = x;
xo = x; yo = y;
yo = y; zo = z;
zo = z;
if (age++ >= lifetime) remove();
if (age++ >= lifetime) remove();
tex = 7 - age * 8 / lifetime;
tex = 7 - age * 8 / lifetime;
move(xd, yd, zd);
move(xd, yd, zd); if (y == yo) {
if (y == yo) { xd *= 1.1f;
xd *= 1.1f; zd *= 1.1f;
zd *= 1.1f; }
} xd *= 0.96f;
xd *= 0.96f; yd *= 0.96f;
yd *= 0.96f; zd *= 0.96f;
zd *= 0.96f;
if (onGround) {
if (onGround) { xd *= 0.7f;
xd *= 0.7f; zd *= 0.7f;
zd *= 0.7f; }
} }
} };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__RedDustParticle_H__*/

View File

@@ -1,69 +1,67 @@
#ifndef NET_MINECRAFT_CLIENT_PARTICLE__SmokeParticle_H__ #pragma once
#define NET_MINECRAFT_CLIENT_PARTICLE__SmokeParticle_H__
//package net.minecraft.client.particle;
//package net.minecraft.client.particle;
#include "Particle.h"
#include "Particle.h"
class SmokeParticle: public Particle
class SmokeParticle: public Particle {
{ typedef Particle super;
typedef Particle super;
public:
public: float oSize;
float oSize;
SmokeParticle(Level* level, float x, float y, float z, float xa, float ya, float za, float scale = 1.0f)
SmokeParticle(Level* level, float x, float y, float z, float xa, float ya, float za, float scale = 1.0f) : super(level, x, y, z, 0, 0, 0)
: super(level, x, y, z, 0, 0, 0) {
{ xd *= 0.1f;
xd *= 0.1f; yd *= 0.1f;
yd *= 0.1f; zd *= 0.1f;
zd *= 0.1f; xd += xa;
xd += xa; yd += ya;
yd += ya; zd += za;
zd += za;
rCol = gCol = bCol = (float) (Mth::random() * 0.5f);
rCol = gCol = bCol = (float) (Mth::random() * 0.5f); size *= 0.75f;
size *= 0.75f; size *= scale;
size *= scale; oSize = size;
oSize = size;
lifetime = (int) (scale * 8.0f / (Mth::random() * 0.8f + 0.2f));
lifetime = (int) (scale * 8.0f / (Mth::random() * 0.8f + 0.2f)); noPhysics = false;
noPhysics = false; }
}
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) {
void render(Tesselator& t, float a, float xa, float ya, float za, float xa2, float za2) { float l = ((age + a) / lifetime) * 32;
float l = ((age + a) / lifetime) * 32; if (l < 0) l = 0;
if (l < 0) l = 0; if (l > 1) l = 1;
if (l > 1) l = 1;
size = oSize * l;
size = oSize * l; super::render(t, a, xa, ya, za, xa2, za2);
super::render(t, a, xa, ya, za, xa2, za2); }
}
void tick() {
void tick() { xo = x;
xo = x; yo = y;
yo = y; zo = z;
zo = z;
if (age++ >= lifetime) remove();
if (age++ >= lifetime) remove();
tex = 7 - age * 8 / lifetime;
tex = 7 - age * 8 / lifetime;
yd += 0.004f;
yd += 0.004f; move(xd, yd, zd);
move(xd, yd, zd); if (y == yo) {
if (y == yo) { xd *= 1.1f;
xd *= 1.1f; zd *= 1.1f;
zd *= 1.1f; }
} xd *= 0.96f;
xd *= 0.96f; yd *= 0.96f;
yd *= 0.96f; zd *= 0.96f;
zd *= 0.96f;
if (onGround) {
if (onGround) { xd *= 0.7f;
xd *= 0.7f; zd *= 0.7f;
zd *= 0.7f; }
} }
} };
};
#endif /*NET_MINECRAFT_CLIENT_PARTICLE__SmokeParticle_H__*/

Some files were not shown because too many files have changed in this diff Show More