Compare commits
11 Commits
0.6.1-alph
...
0c97ceb340
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c97ceb340 | ||
| 65d25748db | |||
| 8a53d3432d | |||
| 5311b134ac | |||
| 310ff754ee | |||
| 416253ebc7 | |||
| 0370944cf6 | |||
| 6c22f3bc25 | |||
| d0f6a9b805 | |||
| d0995643a5 | |||
|
|
f82021117c |
@@ -5,7 +5,10 @@ include(cmake/CPM.cmake)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
||||||
|
endif()
|
||||||
|
|
||||||
CPMAddPackage("gh:madler/zlib@1.3.2")
|
CPMAddPackage("gh:madler/zlib@1.3.2")
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
# MinecraftPE
|
# MinecraftPE
|
||||||
|
> [!Important]
|
||||||
|
> We have a discord server, where you can report bugs or send feedback https://discord.gg/ryZ884DWJf
|
||||||
|
|
||||||
This is leaked source code of Minecraft PE 0.6.1 with my own impovements :sunglasses:
|
This is leaked source code of Minecraft PE 0.6.1 with my own impovements :sunglasses:
|
||||||
|
|
||||||
@@ -8,6 +10,9 @@ First of all I made it build with CMake (w/o VS2012). Also I fixed some compile
|
|||||||
- [x] Add platform GLFW
|
- [x] Add platform GLFW
|
||||||
- [x] Compile for Linux
|
- [x] Compile for Linux
|
||||||
- [ ] Compile for android aarch64
|
- [ ] Compile for android aarch64
|
||||||
|
- [ ] Rewrite platform logic
|
||||||
|
- [x] Fix sound
|
||||||
|
- [ ] Do a server connection gui
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
## CMake
|
## CMake
|
||||||
|
|||||||
@@ -665,7 +665,12 @@ void Minecraft::tickInput() {
|
|||||||
|
|
||||||
if (e.action == MouseAction::ACTION_WHEEL) {
|
if (e.action == MouseAction::ACTION_WHEEL) {
|
||||||
Inventory* v = player->inventory;
|
Inventory* v = player->inventory;
|
||||||
int numSlots = gui.getNumSlots() - 1;
|
|
||||||
|
int numSlots = gui.getNumSlots();
|
||||||
|
#ifndef PLATFORM_DESKTOP
|
||||||
|
numSlots--;
|
||||||
|
#endif
|
||||||
|
|
||||||
int slot = (v->selected - e.dy + numSlots) % numSlots;
|
int slot = (v->selected - e.dy + numSlots) % numSlots;
|
||||||
v->selectSlot(slot);
|
v->selectSlot(slot);
|
||||||
}
|
}
|
||||||
@@ -692,12 +697,12 @@ void Minecraft::tickInput() {
|
|||||||
if (isPressed) {
|
if (isPressed) {
|
||||||
gui.handleKeyPressed(key);
|
gui.handleKeyPressed(key);
|
||||||
|
|
||||||
#if defined(WIN32) || defined(RPI)//|| defined(_DEBUG) || defined(DEBUG)
|
#if defined(WIN32) || defined(RPI) || defined (PLATFORM_DESKTOP)//|| defined(_DEBUG) || defined(DEBUG)
|
||||||
if (key >= '0' && key <= '9') {
|
if (key >= '0' && key <= '9') {
|
||||||
int digit = key - '0';
|
int digit = key - '0';
|
||||||
int slot = digit - 1;
|
int slot = digit - 1;
|
||||||
|
|
||||||
if (slot >= 0 && slot < gui.getNumSlots()-1)
|
if (slot >= 0 && slot < gui.getNumSlots())
|
||||||
player->inventory->selectSlot(slot);
|
player->inventory->selectSlot(slot);
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
@@ -716,21 +721,15 @@ void Minecraft::tickInput() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP) || defined (_WIN32)
|
||||||
if (key == Keyboard::KEY_E) {
|
if (key == Keyboard::KEY_E) {
|
||||||
screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||||
}
|
}
|
||||||
if (!screen && key == Keyboard::KEY_O || key == 250) {
|
if (!screen && key == Keyboard::KEY_O || key == 250) {
|
||||||
releaseMouse();
|
releaseMouse();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if defined(WIN32)
|
|
||||||
if (key == Keyboard::KEY_F) {
|
|
||||||
options.isFlying = !options.isFlying;
|
|
||||||
player->noPhysics = options.isFlying;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key == Keyboard::KEY_T) {
|
if (key == Keyboard::KEY_F5) {
|
||||||
options.thirdPersonView = !options.thirdPersonView;
|
options.thirdPersonView = !options.thirdPersonView;
|
||||||
/*
|
/*
|
||||||
ImprovedNoise noise;
|
ImprovedNoise noise;
|
||||||
@@ -739,6 +738,16 @@ void Minecraft::tickInput() {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change distance
|
||||||
|
if (key == Keyboard::KEY_F)
|
||||||
|
options.viewDistance = (options.viewDistance + 1) % 4;
|
||||||
|
|
||||||
|
#ifdef CHEATS
|
||||||
|
if (key == Keyboard::KEY_J) {
|
||||||
|
options.isFlying = !options.isFlying;
|
||||||
|
player->noPhysics = options.isFlying;
|
||||||
|
}
|
||||||
|
|
||||||
if (key == Keyboard::KEY_O) {
|
if (key == Keyboard::KEY_O) {
|
||||||
useAmbientOcclusion = !useAmbientOcclusion;
|
useAmbientOcclusion = !useAmbientOcclusion;
|
||||||
options.ambientOcclusion = useAmbientOcclusion;
|
options.ambientOcclusion = useAmbientOcclusion;
|
||||||
@@ -831,6 +840,7 @@ void Minecraft::tickInput() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PLATFORM_DESKTOP
|
#ifndef PLATFORM_DESKTOP
|
||||||
if (key == 82)
|
if (key == 82)
|
||||||
@@ -871,13 +881,26 @@ void Minecraft::tickInput() {
|
|||||||
handleBuildAction(&bai);
|
handleBuildAction(&bai);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Mouse::getButtonState(MouseAction::ACTION_LEFT) == 0) {
|
||||||
|
gameMode->stopDestroyBlock();
|
||||||
|
}
|
||||||
|
|
||||||
prevMouseDownLeft = Mouse::isButtonDown(MouseAction::ACTION_LEFT);
|
prevMouseDownLeft = Mouse::isButtonDown(MouseAction::ACTION_LEFT);
|
||||||
|
|
||||||
|
static int buildHoldTicks = 0;
|
||||||
|
|
||||||
// Build and use/interact is on same button
|
// Build and use/interact is on same button
|
||||||
|
// USPESHNO spizheno
|
||||||
if (Mouse::isButtonDown(MouseAction::ACTION_RIGHT)) {
|
if (Mouse::isButtonDown(MouseAction::ACTION_RIGHT)) {
|
||||||
|
if (buildHoldTicks >= 5) buildHoldTicks = 0;
|
||||||
|
|
||||||
|
if (++buildHoldTicks == 1) {
|
||||||
BuildActionIntention bai(BuildActionIntention::BAI_BUILD | BuildActionIntention::BAI_INTERACT);
|
BuildActionIntention bai(BuildActionIntention::BAI_BUILD | BuildActionIntention::BAI_INTERACT);
|
||||||
handleBuildAction(&bai);
|
handleBuildAction(&bai);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
buildHoldTicks = 0;
|
||||||
|
}
|
||||||
|
|
||||||
lastTickTime = getTimeMs();
|
lastTickTime = getTimeMs();
|
||||||
|
|
||||||
@@ -1266,7 +1289,7 @@ void Minecraft::hostMultiplayer(int port) {
|
|||||||
//
|
//
|
||||||
/*static*/
|
/*static*/
|
||||||
|
|
||||||
void* Minecraft::prepareLevel_tspawn(void *p_param)
|
void* Minecraft::prepareLevel_tspawn(void *p_param)
|
||||||
{
|
{
|
||||||
Minecraft* mc = (Minecraft*) p_param;
|
Minecraft* mc = (Minecraft*) p_param;
|
||||||
mc->generateLevel("Currently not used", mc->level);
|
mc->generateLevel("Currently not used", mc->level);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void Options::initDefaultValues() {
|
|||||||
keyBuild = KeyMapping("key.inventory", Keyboard::KEY_E);
|
keyBuild = KeyMapping("key.inventory", Keyboard::KEY_E);
|
||||||
keySneak = KeyMapping("key.sneak", Keyboard::KEY_LSHIFT);
|
keySneak = KeyMapping("key.sneak", Keyboard::KEY_LSHIFT);
|
||||||
#ifndef RPI
|
#ifndef RPI
|
||||||
keyCraft = KeyMapping("key.crafting", Keyboard::KEY_Q);
|
// keyCraft = KeyMapping("key.crafting", Keyboard::KEY_Q);
|
||||||
keyDrop = KeyMapping("key.drop", Keyboard::KEY_Q);
|
keyDrop = KeyMapping("key.drop", Keyboard::KEY_Q);
|
||||||
keyChat = KeyMapping("key.chat", Keyboard::KEY_T);
|
keyChat = KeyMapping("key.chat", Keyboard::KEY_T);
|
||||||
keyFog = KeyMapping("key.fog", Keyboard::KEY_F);
|
keyFog = KeyMapping("key.fog", Keyboard::KEY_F);
|
||||||
@@ -115,10 +115,11 @@ void Options::initDefaultValues() {
|
|||||||
keyMenuCancel.key = 4;
|
keyMenuCancel.key = 4;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PLATFORM_DESKTOP) || defined(RPI)
|
||||||
|
sensitivity *= 0.4f;
|
||||||
|
#endif
|
||||||
#if defined(RPI)
|
#if defined(RPI)
|
||||||
username = "StevePi";
|
username = "StevePi";
|
||||||
sensitivity *= 0.4f;
|
|
||||||
useMouseForDigging = true;
|
useMouseForDigging = true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Gui.h"
|
#include "Gui.h"
|
||||||
#include "Font.h"
|
#include "Font.h"
|
||||||
|
#include "client/Options.h"
|
||||||
#include "screens/IngameBlockSelectionScreen.h"
|
#include "screens/IngameBlockSelectionScreen.h"
|
||||||
#include "../Minecraft.h"
|
#include "../Minecraft.h"
|
||||||
#include "../player/LocalPlayer.h"
|
#include "../player/LocalPlayer.h"
|
||||||
@@ -106,12 +107,6 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
|||||||
|
|
||||||
renderToolBar(a, ySlot, screenWidth);
|
renderToolBar(a, ySlot, screenWidth);
|
||||||
|
|
||||||
|
|
||||||
//font->drawShadow(APP_NAME, 2, 2, 0xffffffff);
|
|
||||||
//font->drawShadow("This is a demo, not the finished product", 2, 10 + 2, 0xffffffff);
|
|
||||||
#ifdef APPLE_DEMO_PROMOTION
|
|
||||||
font->drawShadow("Demo version", 2, 0 + 2, 0xffffffff);
|
|
||||||
#endif /*APPLE_DEMO_PROMOTION*/
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
unsigned int max = 10;
|
unsigned int max = 10;
|
||||||
bool isChatting = false;
|
bool isChatting = false;
|
||||||
@@ -123,9 +118,6 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
|||||||
renderDebugInfo();
|
renderDebugInfo();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// glPopMatrix2();
|
|
||||||
//
|
|
||||||
// glEnable(GL_ALPHA_TEST);
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glEnable2(GL_ALPHA_TEST);
|
glEnable2(GL_ALPHA_TEST);
|
||||||
}
|
}
|
||||||
@@ -188,11 +180,13 @@ void Gui::handleClick(int button, int x, int y) {
|
|||||||
int slot = getSlotIdAt(x, y);
|
int slot = getSlotIdAt(x, y);
|
||||||
if (slot != -1)
|
if (slot != -1)
|
||||||
{
|
{
|
||||||
|
#ifndef PLATFORM_DESKTOP
|
||||||
if (slot == (getNumSlots()-1))
|
if (slot == (getNumSlots()-1))
|
||||||
{
|
{
|
||||||
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
minecraft->player->inventory->selectSlot(slot);
|
minecraft->player->inventory->selectSlot(slot);
|
||||||
itemNameOverlayTime = 0;
|
itemNameOverlayTime = 0;
|
||||||
@@ -220,6 +214,10 @@ void Gui::handleKeyPressed(int key)
|
|||||||
{
|
{
|
||||||
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||||
}
|
}
|
||||||
|
else if (key == minecraft->options.keyDrop.key)
|
||||||
|
{
|
||||||
|
minecraft->player->inventory->dropSlot(minecraft->player->inventory->selected, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::tick() {
|
void Gui::tick() {
|
||||||
@@ -395,6 +393,7 @@ void Gui::onConfigChanged( const Config& c ) {
|
|||||||
//LOGI("x,y: %f, %f\n", xx, yy);
|
//LOGI("x,y: %f, %f\n", xx, yy);
|
||||||
}
|
}
|
||||||
rcFeedbackInner = t.end(true, rcFeedbackInner.vboId);
|
rcFeedbackInner = t.end(true, rcFeedbackInner.vboId);
|
||||||
|
|
||||||
if (c.minecraft->useTouchscreen()) {
|
if (c.minecraft->useTouchscreen()) {
|
||||||
// I'll bump this up to 6.
|
// I'll bump this up to 6.
|
||||||
int num = 6; // without "..." dots
|
int num = 6; // without "..." dots
|
||||||
@@ -452,9 +451,16 @@ void Gui::tickItemDrop()
|
|||||||
// Handle item drop
|
// Handle item drop
|
||||||
static bool isCurrentlyActive = false;
|
static bool isCurrentlyActive = false;
|
||||||
isCurrentlyActive = false;
|
isCurrentlyActive = false;
|
||||||
|
|
||||||
|
int slots = getNumSlots();
|
||||||
|
|
||||||
|
#ifndef PLATFORM_DESKTOP
|
||||||
|
slots--;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (Mouse::isButtonDown(MouseAction::ACTION_LEFT)) {
|
if (Mouse::isButtonDown(MouseAction::ACTION_LEFT)) {
|
||||||
int slot = getSlotIdAt(Mouse::getX(), Mouse::getY());
|
int slot = getSlotIdAt(Mouse::getX(), Mouse::getY());
|
||||||
if (slot >= 0 && slot < getNumSlots()-1) {
|
if (slot >= 0 && slot < slots) {
|
||||||
if (slot != _currentDropSlot) {
|
if (slot != _currentDropSlot) {
|
||||||
_currentDropTicks = 0;
|
_currentDropTicks = 0;
|
||||||
_currentDropSlot = slot;
|
_currentDropSlot = slot;
|
||||||
@@ -756,20 +762,24 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
|||||||
t.beginOverride();
|
t.beginOverride();
|
||||||
|
|
||||||
float x = baseItemX;
|
float x = baseItemX;
|
||||||
for (int i = 0; i < getNumSlots()-1; i++) {
|
|
||||||
|
int slots = getNumSlots();
|
||||||
|
|
||||||
|
// TODO: if using touchscreen
|
||||||
|
|
||||||
|
#ifndef PLATFORM_DESKTOP
|
||||||
|
slots--;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int i = 0; i < slots; i++) {
|
||||||
renderSlot(i, (int)x, ySlot, a);
|
renderSlot(i, (int)x, ySlot, a);
|
||||||
x += 20;
|
x += 20;
|
||||||
}
|
}
|
||||||
_inventoryNeedsUpdate = false;
|
_inventoryNeedsUpdate = false;
|
||||||
//_inventoryRc = t.end(_inventoryRc.vboId);
|
|
||||||
|
|
||||||
//drawArrayVTC(_inventoryRc.vboId, _inventoryRc.vertexCount);
|
#ifndef PLATFORM_DESKTOP
|
||||||
|
|
||||||
//renderSlotWatch.stop();
|
|
||||||
//renderSlotWatch.printEvery(100, "Render slots:");
|
|
||||||
|
|
||||||
//int x = screenWidth / 2 + getNumSlots() * 10 + (getNumSlots()-1) * 20 + 2;
|
|
||||||
blit(screenWidth / 2 + 10 * getNumSlots() - 20 + 4, ySlot + 6, 242, 252, 14, 4, 14, 4);
|
blit(screenWidth / 2 + 10 * getNumSlots() - 20 + 4, ySlot + 6, 242, 252, 14, 4, 14, 4);
|
||||||
|
#endif
|
||||||
|
|
||||||
minecraft->textures->loadAndBindTexture("gui/gui_blocks.png");
|
minecraft->textures->loadAndBindTexture("gui/gui_blocks.png");
|
||||||
t.endOverrideAndDraw();
|
t.endOverrideAndDraw();
|
||||||
@@ -779,7 +789,7 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
|||||||
glDisable2(GL_TEXTURE_2D);
|
glDisable2(GL_TEXTURE_2D);
|
||||||
t.beginOverride();
|
t.beginOverride();
|
||||||
x = baseItemX;
|
x = baseItemX;
|
||||||
for (int i = 0; i < getNumSlots()-1; i++) {
|
for (int i = 0; i < slots; i++) {
|
||||||
ItemRenderer::renderGuiItemDecorations(minecraft->player->inventory->getItem(i), x, (float)ySlot);
|
ItemRenderer::renderGuiItemDecorations(minecraft->player->inventory->getItem(i), x, (float)ySlot);
|
||||||
x += 20;
|
x += 20;
|
||||||
}
|
}
|
||||||
@@ -799,7 +809,7 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
|||||||
t.beginOverride();
|
t.beginOverride();
|
||||||
if (minecraft->gameMode->isSurvivalType()) {
|
if (minecraft->gameMode->isSurvivalType()) {
|
||||||
x = baseItemX;
|
x = baseItemX;
|
||||||
for (int i = 0; i < getNumSlots()-1; i++) {
|
for (int i = 0; i < slots; i++) {
|
||||||
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
||||||
if (item && item->count >= 0)
|
if (item && item->count >= 0)
|
||||||
renderSlotText(item, k*x, k*ySlot + 1, true, true);
|
renderSlotText(item, k*x, k*ySlot + 1, true, true);
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ void Screen::render( int xm, int ym, float a )
|
|||||||
Button* button = buttons[i];
|
Button* button = buttons[i];
|
||||||
button->render(minecraft, xm, ym);
|
button->render(minecraft, xm, ym);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < textBoxes.size(); i++) {
|
||||||
|
TextBox* textbox = textBoxes[i];
|
||||||
|
textbox->render(minecraft, xm, ym);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::init( Minecraft* minecraft, int width, int height )
|
void Screen::init( Minecraft* minecraft, int width, int height )
|
||||||
@@ -157,6 +162,11 @@ void Screen::keyPressed( int eventKey )
|
|||||||
minecraft->setScreen(NULL);
|
minecraft->setScreen(NULL);
|
||||||
//minecraft->grabMouse();
|
//minecraft->grabMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto& textbox : textBoxes) {
|
||||||
|
textbox->handleKey(eventKey);
|
||||||
|
}
|
||||||
|
|
||||||
if (minecraft->useTouchscreen())
|
if (minecraft->useTouchscreen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -181,6 +191,14 @@ void Screen::keyPressed( int eventKey )
|
|||||||
updateTabButtonSelection();
|
updateTabButtonSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Screen::keyboardNewChar(char inputChar) {
|
||||||
|
// yeah im using these modern cpp features in this project :sunglasses:
|
||||||
|
|
||||||
|
for (auto& textbox : textBoxes) {
|
||||||
|
textbox->handleChar(inputChar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Screen::updateTabButtonSelection()
|
void Screen::updateTabButtonSelection()
|
||||||
{
|
{
|
||||||
if (minecraft->useTouchscreen())
|
if (minecraft->useTouchscreen())
|
||||||
@@ -210,6 +228,10 @@ void Screen::mouseClicked( int x, int y, int buttonNum )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto& textbox : textBoxes) {
|
||||||
|
textbox->mouseClicked(minecraft, x, y, buttonNum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::mouseReleased( int x, int y, int buttonNum )
|
void Screen::mouseReleased( int x, int y, int buttonNum )
|
||||||
@@ -253,3 +275,9 @@ void Screen::toGUICoordinate( int& x, int& y ) {
|
|||||||
x = x * width / minecraft->width;
|
x = x * width / minecraft->width;
|
||||||
y = y * height / minecraft->height - 1;
|
y = y * height / minecraft->height - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Screen::tick() {
|
||||||
|
for (auto& textbox : textBoxes) {
|
||||||
|
textbox->tick(minecraft);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
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() {}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ protected:
|
|||||||
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 keyboardNewChar(char inputChar) {}
|
virtual void keyboardNewChar(char inputChar);
|
||||||
public:
|
public:
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
#include "TextBox.h"
|
#include "TextBox.h"
|
||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
#include "../../../AppPlatform.h"
|
#include "../../../AppPlatform.h"
|
||||||
TextBox::TextBox( int id, const std::string& msg )
|
#include "platform/input/Mouse.h"
|
||||||
: id(0), w(0), h(0), x(0), y(0), text(msg), focused(false) {
|
|
||||||
|
|
||||||
}
|
TextBox::TextBox( int id, const std::string& msg )
|
||||||
|
: TextBox(id, 0, 0, msg) {}
|
||||||
|
|
||||||
TextBox::TextBox( int id, int x, int y, const std::string& msg )
|
TextBox::TextBox( int id, int x, int y, const std::string& msg )
|
||||||
: id(id), w(0), h(0), x(x), y(y), text(msg), focused(false) {
|
: TextBox(id, x, y, 24, msg) {}
|
||||||
|
|
||||||
}
|
TextBox::TextBox( int id, int x, int y, int w, const std::string& msg )
|
||||||
|
: GuiElement(true, true, x, y, w, Font::DefaultLineHeight + 4),
|
||||||
TextBox::TextBox( int id, int x, int y, int w, int h, const std::string& msg )
|
id(id), hint(msg), focused(false), blink(false) {}
|
||||||
: id(id), w(w), h(h), x(x), y(y), text(msg) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextBox::setFocus(Minecraft* minecraft) {
|
void TextBox::setFocus(Minecraft* minecraft) {
|
||||||
if(!focused) {
|
if(!focused) {
|
||||||
minecraft->platform()->showKeyboard();
|
minecraft->platform()->showKeyboard();
|
||||||
focused = true;
|
focused = true;
|
||||||
|
|
||||||
|
blinkTicks = 0;
|
||||||
|
blink = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +32,59 @@ bool TextBox::loseFocus(Minecraft* minecraft) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBox::render( Minecraft* minecraft, int xm, int ym ) {
|
void TextBox::mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {
|
||||||
|
if (buttonNum == MouseAction::ACTION_LEFT) {
|
||||||
|
if (pointInside(x, y)) {
|
||||||
|
setFocus(minecraft);
|
||||||
|
} else {
|
||||||
|
loseFocus(minecraft);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextBox::handleChar(char c) {
|
||||||
|
if (focused) {
|
||||||
|
text.push_back(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextBox::handleKey(int key) {
|
||||||
|
if (focused && key == Keyboard::KEY_BACKSPACE && !text.empty()) {
|
||||||
|
text.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextBox::tick(Minecraft* minecraft) {
|
||||||
|
blinkTicks++;
|
||||||
|
|
||||||
|
if (blinkTicks >= 5) {
|
||||||
|
blink = !blink;
|
||||||
|
blinkTicks = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextBox::render( Minecraft* minecraft, int xm, int ym ) {
|
||||||
|
// textbox like in beta 1.7.3
|
||||||
|
fill(x, y, x + width, y + height, 0xffa0a0a0);
|
||||||
|
fill(x + 1, y + 1, x + width - 1, y + height - 1, 0xff000000);
|
||||||
|
|
||||||
|
glEnable2(GL_SCISSOR_TEST);
|
||||||
|
glScissor(
|
||||||
|
Gui::GuiScale * (x + 2),
|
||||||
|
minecraft->height - Gui::GuiScale * (y + height - 2),
|
||||||
|
Gui::GuiScale * (width - 2),
|
||||||
|
Gui::GuiScale * (height - 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (text.empty() && !focused) {
|
||||||
|
drawString(minecraft->font, hint, x + 2, y + 2, 0xff5e5e5e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (focused && blink) text.push_back('_');
|
||||||
|
|
||||||
|
drawString(minecraft->font, text, x + 2, y + 2, 0xffffffff);
|
||||||
|
|
||||||
|
if (focused && blink) text.pop_back();
|
||||||
|
|
||||||
|
glDisable2(GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,31 +4,39 @@
|
|||||||
//package net.minecraft.client.gui;
|
//package net.minecraft.client.gui;
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../GuiComponent.h"
|
#include "GuiElement.h"
|
||||||
#include "../../Options.h"
|
#include "../../Options.h"
|
||||||
|
|
||||||
class Font;
|
class Font;
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
|
|
||||||
class TextBox: public GuiComponent
|
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, const std::string& msg);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
public:
|
virtual void handleKey(int key);
|
||||||
int w, h;
|
virtual void handleChar(char c);
|
||||||
int x, y;
|
virtual void tick(Minecraft* minecraft);
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::string hint;
|
||||||
std::string text;
|
std::string text;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
|
int blinkTicks;
|
||||||
|
|
||||||
bool focused;
|
bool focused;
|
||||||
|
bool blink;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__TextBox_H__*/
|
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__TextBox_H__*/
|
||||||
|
|||||||
@@ -425,13 +425,23 @@ void SelectWorldScreen::render( int xm, int ym, float a )
|
|||||||
//Performance::watches.get("sws-worlds").start();
|
//Performance::watches.get("sws-worlds").start();
|
||||||
|
|
||||||
worldsList->setComponentSelected(bWorldView.selected);
|
worldsList->setComponentSelected(bWorldView.selected);
|
||||||
|
// #ifdef PLATFORM_DESKTOP
|
||||||
|
|
||||||
|
// We should add scrolling with mouse wheel but currently i dont know how to implement it
|
||||||
if (_mouseHasBeenUp)
|
if (_mouseHasBeenUp)
|
||||||
worldsList->render(xm, ym, a);
|
worldsList->render(xm, ym, a);
|
||||||
else {
|
else {
|
||||||
worldsList->render(0, 0, a);
|
worldsList->render(0, 0, a);
|
||||||
_mouseHasBeenUp = !Mouse::getButtonState(MouseAction::ACTION_LEFT);
|
_mouseHasBeenUp = !Mouse::getButtonState(MouseAction::ACTION_LEFT);
|
||||||
}
|
}
|
||||||
|
// #else
|
||||||
|
// if (_mouseHasBeenUp)
|
||||||
|
// worldsList->render(xm, ym, a);
|
||||||
|
// else {
|
||||||
|
// worldsList->render(0, 0, a);
|
||||||
|
// _mouseHasBeenUp = !Mouse::getButtonState(MouseAction::ACTION_LEFT);
|
||||||
|
// }
|
||||||
|
// #endif
|
||||||
|
|
||||||
//Performance::watches.get("sws-worlds").stop();
|
//Performance::watches.get("sws-worlds").stop();
|
||||||
//Performance::watches.get("sws-screen").start();
|
//Performance::watches.get("sws-screen").start();
|
||||||
|
|||||||
@@ -5,52 +5,74 @@
|
|||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
#include "../../../world/level/LevelSettings.h"
|
#include "../../../world/level/LevelSettings.h"
|
||||||
#include "../../../platform/time.h"
|
#include "../../../platform/time.h"
|
||||||
|
#include "client/gamemode/GameMode.h"
|
||||||
|
|
||||||
SimpleChooseLevelScreen::SimpleChooseLevelScreen(const std::string& levelName)
|
SimpleChooseLevelScreen::SimpleChooseLevelScreen(const std::string& levelName)
|
||||||
: bCreative(0),
|
:
|
||||||
bSurvival(0),
|
// bCreative(0),
|
||||||
|
bGamemode(0),
|
||||||
bBack(0),
|
bBack(0),
|
||||||
|
bCreate(0),
|
||||||
levelName(levelName),
|
levelName(levelName),
|
||||||
hasChosen(false)
|
hasChosen(false),
|
||||||
|
gamemode(GameType::Survival),
|
||||||
|
tLevelName(0, "World name"),
|
||||||
|
tSeed(1, "World seed")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleChooseLevelScreen::~SimpleChooseLevelScreen()
|
SimpleChooseLevelScreen::~SimpleChooseLevelScreen()
|
||||||
{
|
{
|
||||||
delete bCreative;
|
// delete bCreative;
|
||||||
delete bSurvival;
|
delete bGamemode;
|
||||||
delete bBack;
|
delete bBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleChooseLevelScreen::init()
|
void SimpleChooseLevelScreen::init()
|
||||||
{
|
{
|
||||||
if (minecraft->useTouchscreen()) {
|
if (minecraft->useTouchscreen()) {
|
||||||
bCreative = new Touch::TButton(1, "Creative mode");
|
// bCreative = new Touch::TButton(1, "Creative mode");
|
||||||
bSurvival = new Touch::TButton(2, "Survival mode");
|
bGamemode = new Touch::TButton(2, "Survival mode");
|
||||||
bBack = new Touch::TButton(3, "Back");
|
bBack = new Touch::TButton(3, "Back");
|
||||||
|
bCreate = new Touch::TButton(4, "Create");
|
||||||
} else {
|
} else {
|
||||||
bCreative = new Button(1, "Creative mode");
|
// bCreative = new Button(1, "Creative mode");
|
||||||
bSurvival = new Button(2, "Survival mode");
|
bGamemode = new Button(2, "Survival mode");
|
||||||
bBack = new Button(3, "Back");
|
bBack = new Button(3, "Back");
|
||||||
|
bCreate = new Button(4, "Create");
|
||||||
}
|
}
|
||||||
buttons.push_back(bCreative);
|
// buttons.push_back(bCreative);
|
||||||
buttons.push_back(bSurvival);
|
buttons.push_back(bGamemode);
|
||||||
buttons.push_back(bBack);
|
buttons.push_back(bBack);
|
||||||
|
buttons.push_back(bCreate);
|
||||||
|
|
||||||
tabButtons.push_back(bCreative);
|
textBoxes.push_back(&tLevelName);
|
||||||
tabButtons.push_back(bSurvival);
|
textBoxes.push_back(&tSeed);
|
||||||
|
|
||||||
|
// tabButtons.push_back(bCreative);
|
||||||
|
tabButtons.push_back(bGamemode);
|
||||||
tabButtons.push_back(bBack);
|
tabButtons.push_back(bBack);
|
||||||
|
tabButtons.push_back(bCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleChooseLevelScreen::setupPositions()
|
void SimpleChooseLevelScreen::setupPositions()
|
||||||
{
|
{
|
||||||
bCreative->width = bSurvival->width = bBack->width = 120;
|
const int padding = 5;
|
||||||
bCreative->x = (width - bCreative->width) / 2;
|
|
||||||
bCreative->y = height/3 - 40;
|
/* bCreative->width = */ bGamemode->width = 120;
|
||||||
bSurvival->x = (width - bSurvival->width) / 2;
|
tLevelName.width = tSeed.width = 120;
|
||||||
bSurvival->y = 2*height/3 - 40;
|
bBack->width = bCreate->width = 60 - padding;
|
||||||
bBack->x = bSurvival->x + bSurvival->width - bBack->width;
|
// bCreative->x = (width - bCreative->width) / 2;
|
||||||
bBack->y = height - 40;
|
// bCreative->y = height/3 - 40;
|
||||||
|
bGamemode->x = (width - bGamemode->width) / 2;
|
||||||
|
bGamemode->y = 2*height/3 - 30;
|
||||||
|
bBack->x = bGamemode->x;
|
||||||
|
bCreate->x = bGamemode->x + bGamemode->width - bCreate->width;
|
||||||
|
bBack->y = bCreate->y = height - 40;
|
||||||
|
|
||||||
|
tLevelName.x = tSeed.x = bGamemode->x;
|
||||||
|
tLevelName.y = 20;
|
||||||
|
tSeed.y = tLevelName.y + 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleChooseLevelScreen::render( int xm, int ym, float a )
|
void SimpleChooseLevelScreen::render( int xm, int ym, float a )
|
||||||
@@ -58,8 +80,20 @@ void SimpleChooseLevelScreen::render( int xm, int ym, float a )
|
|||||||
renderDirtBackground(0);
|
renderDirtBackground(0);
|
||||||
glEnable2(GL_BLEND);
|
glEnable2(GL_BLEND);
|
||||||
|
|
||||||
drawCenteredString(minecraft->font, "Mobs, health and gather resources", width/2, bSurvival->y + bSurvival->height + 4, 0xffcccccc);
|
const char* str = NULL;
|
||||||
drawCenteredString(minecraft->font, "Unlimited resources and flying", width/2, bCreative->y + bCreative->height + 4, 0xffcccccc);
|
|
||||||
|
if (gamemode == GameType::Survival) {
|
||||||
|
str = "Mobs, health and gather resources";
|
||||||
|
} else if (gamemode == GameType::Creative) {
|
||||||
|
str = "Unlimited resources and flying";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str) {
|
||||||
|
drawCenteredString(minecraft->font, str, width/2, bGamemode->y + bGamemode->height + 4, 0xffcccccc);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawString(minecraft->font, "World name:", tLevelName.x, tLevelName.y - Font::DefaultLineHeight - 2, 0xffcccccc);
|
||||||
|
drawString(minecraft->font, "World seed:", tSeed.x, tSeed.y - Font::DefaultLineHeight - 2, 0xffcccccc);
|
||||||
|
|
||||||
Screen::render(xm, ym, a);
|
Screen::render(xm, ym, a);
|
||||||
glDisable2(GL_BLEND);
|
glDisable2(GL_BLEND);
|
||||||
@@ -74,20 +108,33 @@ void SimpleChooseLevelScreen::buttonClicked( Button* button )
|
|||||||
if (hasChosen)
|
if (hasChosen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int gameType;
|
if (button == bGamemode) {
|
||||||
|
gamemode ^= 1;
|
||||||
|
bGamemode->msg = (gamemode == GameType::Survival) ? "Survival mode" : "Creative mode";
|
||||||
|
}
|
||||||
|
|
||||||
if (button == bCreative)
|
if (button == bCreate) {
|
||||||
gameType = GameType::Creative;
|
int seed = getEpochTimeS();
|
||||||
|
|
||||||
if (button == bSurvival)
|
if (!tSeed.text.empty()) {
|
||||||
gameType = GameType::Survival;
|
std::string seedString = Util::stringTrim(tSeed.text);
|
||||||
|
int tmpSeed;
|
||||||
|
// Try to read it as an integer
|
||||||
|
if (sscanf(seedString.c_str(), "%d", &tmpSeed) > 0) {
|
||||||
|
seed = tmpSeed;
|
||||||
|
} // Hash the "seed"
|
||||||
|
else {
|
||||||
|
seed = Util::hashCode(seedString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string levelId = getUniqueLevelName(levelName);
|
std::string levelId = getUniqueLevelName(tLevelName.text);
|
||||||
LevelSettings settings(getEpochTimeS(), gameType);
|
LevelSettings settings(seed, gamemode);
|
||||||
minecraft->selectLevel(levelId, levelId, settings);
|
minecraft->selectLevel(levelId, levelId, settings);
|
||||||
minecraft->hostMultiplayer();
|
minecraft->hostMultiplayer();
|
||||||
minecraft->setScreen(new ProgressScreen());
|
minecraft->setScreen(new ProgressScreen());
|
||||||
hasChosen = true;
|
hasChosen = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimpleChooseLevelScreen::handleBackEvent(bool isDown) {
|
bool SimpleChooseLevelScreen::handleBackEvent(bool isDown) {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__
|
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__
|
||||||
|
|
||||||
#include "ChooseLevelScreen.h"
|
#include "ChooseLevelScreen.h"
|
||||||
|
#include "../components/TextBox.h"
|
||||||
|
|
||||||
class Button;
|
class Button;
|
||||||
|
|
||||||
class SimpleChooseLevelScreen: public ChooseLevelScreen
|
class SimpleChooseLevelScreen: public ChooseLevelScreen
|
||||||
@@ -21,12 +23,18 @@ public:
|
|||||||
bool handleBackEvent(bool isDown);
|
bool handleBackEvent(bool isDown);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Button* bCreative;
|
// Button* bCreative;
|
||||||
Button* bSurvival;
|
Button* bGamemode;
|
||||||
Button* bBack;
|
Button* bBack;
|
||||||
|
Button* bCreate;
|
||||||
bool hasChosen;
|
bool hasChosen;
|
||||||
|
|
||||||
std::string levelName;
|
std::string levelName;
|
||||||
|
|
||||||
|
int gamemode;
|
||||||
|
|
||||||
|
TextBox tLevelName;
|
||||||
|
TextBox tSeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__*/
|
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__DemoChooseLevelScreen_H__*/
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "../../../../world/level/Level.h"
|
#include "../../../../world/level/Level.h"
|
||||||
#include "../../../../world/item/DyePowderItem.h"
|
#include "../../../../world/item/DyePowderItem.h"
|
||||||
#include "../../../../world/item/crafting/Recipe.h"
|
#include "../../../../world/item/crafting/Recipe.h"
|
||||||
|
#include "platform/input/Keyboard.h"
|
||||||
|
|
||||||
static NinePatchLayer* guiPaneFrame = NULL;
|
static NinePatchLayer* guiPaneFrame = NULL;
|
||||||
|
|
||||||
@@ -420,7 +421,7 @@ void PaneCraftingScreen::clearCategoryItems()
|
|||||||
|
|
||||||
void PaneCraftingScreen::keyPressed( int eventKey )
|
void PaneCraftingScreen::keyPressed( int eventKey )
|
||||||
{
|
{
|
||||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
if (eventKey == Keyboard::KEY_ESCAPE || eventKey == Keyboard::KEY_E) {
|
||||||
minecraft->setScreen(NULL);
|
minecraft->setScreen(NULL);
|
||||||
//minecraft->grabMouse();
|
//minecraft->grabMouse();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -22,62 +22,6 @@
|
|||||||
#include "../DialogDefinitions.h"
|
#include "../DialogDefinitions.h"
|
||||||
#include "../SimpleChooseLevelScreen.h"
|
#include "../SimpleChooseLevelScreen.h"
|
||||||
|
|
||||||
//
|
|
||||||
// Buy Button implementation
|
|
||||||
//
|
|
||||||
BuyButton::BuyButton(int id)
|
|
||||||
: super(id, "")
|
|
||||||
{
|
|
||||||
ImageDef def;
|
|
||||||
// Setup the source rectangle
|
|
||||||
def.setSrc(IntRectangle(64, 182, 190, 55));
|
|
||||||
def.width = 75;//rc.w / 3;
|
|
||||||
def.height = 75 * (55.0f / 190.0f);//rc.h / 3;
|
|
||||||
def.name = "gui/gui.png";
|
|
||||||
|
|
||||||
setImageDef(def, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuyButton::render(Minecraft* minecraft, int xm, int ym) {
|
|
||||||
glColor4f2(1, 1, 1, 1);
|
|
||||||
bool hovered = active && (minecraft->useTouchscreen()? (xm >= x && ym >= y && xm < x + width && ym < y + height) : false);
|
|
||||||
renderBg(minecraft, xm, ym);
|
|
||||||
TextureId texId = (_imageDef.name.length() > 0)? minecraft->textures->loadAndBindTexture(_imageDef.name) : Textures::InvalidId;
|
|
||||||
if ( Textures::isTextureIdValid(texId) ) {
|
|
||||||
const ImageDef& d = _imageDef;
|
|
||||||
Tesselator& t = Tesselator::instance;
|
|
||||||
|
|
||||||
t.begin();
|
|
||||||
if (!active) t.color(0xff808080);
|
|
||||||
else if (hovered||selected) t.color(0xffcccccc);
|
|
||||||
//else t.color(0xffe0e0e0);
|
|
||||||
else t.color(0xffffffff);
|
|
||||||
|
|
||||||
float hx = ((float) d.width) * 0.5f;
|
|
||||||
float hy = ((float) d.height) * 0.5f;
|
|
||||||
const float cx = ((float)x+d.x) + hx;
|
|
||||||
const float cy = ((float)y+d.y) + hy;
|
|
||||||
if (hovered) {
|
|
||||||
hx *= 0.95f;
|
|
||||||
hy *= 0.95f;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TextureData* td = minecraft->textures->getTemporaryTextureData(texId);
|
|
||||||
const IntRectangle* src = _imageDef.getSrc();
|
|
||||||
if (td != NULL && src != NULL) {
|
|
||||||
float u0 = (src->x) / (float)td->w;
|
|
||||||
float u1 = (src->x+src->w) / (float)td->w;
|
|
||||||
float v0 = (src->y) / (float)td->h;
|
|
||||||
float v1 = (src->y+src->h) / (float)td->h;
|
|
||||||
t.vertexUV(cx-hx, cy-hy, blitOffset, u0, v0);
|
|
||||||
t.vertexUV(cx-hx, cy+hy, blitOffset, u0, v1);
|
|
||||||
t.vertexUV(cx+hx, cy+hy, blitOffset, u1, v1);
|
|
||||||
t.vertexUV(cx+hx, cy-hy, blitOffset, u1, v0);
|
|
||||||
}
|
|
||||||
t.draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Touch {
|
namespace Touch {
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -88,9 +32,7 @@ namespace Touch {
|
|||||||
StartMenuScreen::StartMenuScreen()
|
StartMenuScreen::StartMenuScreen()
|
||||||
: bHost( 2, "Start Game"),
|
: bHost( 2, "Start Game"),
|
||||||
bJoin( 3, "Join Game"),
|
bJoin( 3, "Join Game"),
|
||||||
bOptions( 4, "Options"),
|
bOptions( 4, "Options")
|
||||||
bBuy( 5),
|
|
||||||
bTest( 9, "Create")
|
|
||||||
{
|
{
|
||||||
ImageDef def;
|
ImageDef def;
|
||||||
bJoin.width = 75;
|
bJoin.width = 75;
|
||||||
@@ -125,11 +67,6 @@ void StartMenuScreen::init()
|
|||||||
tabButtons.push_back(&bJoin);
|
tabButtons.push_back(&bJoin);
|
||||||
tabButtons.push_back(&bOptions);
|
tabButtons.push_back(&bOptions);
|
||||||
|
|
||||||
#ifdef DEMO_MODE
|
|
||||||
buttons.push_back(&bBuy);
|
|
||||||
tabButtons.push_back(&bBuy);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
copyright = "\xffMojang AB";//. Do not distribute!";
|
copyright = "\xffMojang AB";//. Do not distribute!";
|
||||||
|
|
||||||
#ifdef PRE_ANDROID23
|
#ifdef PRE_ANDROID23
|
||||||
@@ -173,20 +110,14 @@ void StartMenuScreen::setupPositions() {
|
|||||||
bJoin.x = 0*buttonWidth + (int)(1*spacing);
|
bJoin.x = 0*buttonWidth + (int)(1*spacing);
|
||||||
bHost.x = 1*buttonWidth + (int)(2*spacing);
|
bHost.x = 1*buttonWidth + (int)(2*spacing);
|
||||||
bOptions.x = 2*buttonWidth + (int)(3*spacing);
|
bOptions.x = 2*buttonWidth + (int)(3*spacing);
|
||||||
//bBuy.y = bOptions.y - bBuy.h - 6;
|
|
||||||
//bBuy.x = bOptions.x + bOptions.w - bBuy.w;
|
|
||||||
|
|
||||||
bBuy.y = height - bBuy.height - 3;
|
|
||||||
bBuy.x = (width - bBuy.width) / 2;
|
|
||||||
|
|
||||||
bTest.x = 4;
|
|
||||||
bTest.y = height - bTest.height - 4;
|
|
||||||
|
|
||||||
copyrightPosX = width - minecraft->font->width(copyright) - 1;
|
copyrightPosX = width - minecraft->font->width(copyright) - 1;
|
||||||
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
|
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuScreen::tick() {
|
void StartMenuScreen::tick() {
|
||||||
|
Screen::tick();
|
||||||
|
|
||||||
_updateLicense();
|
_updateLicense();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,11 +149,6 @@ void StartMenuScreen::buttonClicked(::Button* button) {
|
|||||||
{
|
{
|
||||||
minecraft->setScreen(new OptionsScreen());
|
minecraft->setScreen(new OptionsScreen());
|
||||||
}
|
}
|
||||||
if (button->id == bBuy.id)
|
|
||||||
{
|
|
||||||
minecraft->platform()->buyGame();
|
|
||||||
//minecraft->setScreen(new BuyGameScreen());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartMenuScreen::isInGameScreen() { return false; }
|
bool StartMenuScreen::isInGameScreen() { return false; }
|
||||||
|
|||||||
@@ -3,15 +3,7 @@
|
|||||||
|
|
||||||
#include "../../Screen.h"
|
#include "../../Screen.h"
|
||||||
#include "../../components/LargeImageButton.h"
|
#include "../../components/LargeImageButton.h"
|
||||||
|
#include "../../components/TextBox.h"
|
||||||
|
|
||||||
class BuyButton: public ImageButton {
|
|
||||||
typedef ImageButton super;
|
|
||||||
public:
|
|
||||||
BuyButton(int id);
|
|
||||||
void render(Minecraft* minecraft, int xm, int ym);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
namespace Touch {
|
namespace Touch {
|
||||||
|
|
||||||
@@ -36,8 +28,6 @@ private:
|
|||||||
LargeImageButton bHost;
|
LargeImageButton bHost;
|
||||||
LargeImageButton bJoin;
|
LargeImageButton bJoin;
|
||||||
LargeImageButton bOptions;
|
LargeImageButton bOptions;
|
||||||
TButton bTest;
|
|
||||||
BuyButton bBuy;
|
|
||||||
|
|
||||||
std::string copyright;
|
std::string copyright;
|
||||||
int copyrightPosX;
|
int copyrightPosX;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ void KeyboardInput::tick( Player* player )
|
|||||||
ya *= 0.3f;
|
ya *= 0.3f;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RPI
|
#if defined(RPI) || defined(PLATFORM_DESKTOP)
|
||||||
wantUp = jumping;
|
wantUp = jumping;
|
||||||
wantDown = sneaking;
|
wantDown = sneaking;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public:
|
|||||||
|
|
||||||
void destroy() const {
|
void destroy() const {
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
delete buffer;
|
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,14 +230,11 @@ void SoundEngine::playUI(const std::string& name, float volume, float pitch) {}
|
|||||||
void SoundEngine::play(const std::string& name, float x, float y, float z, float volume, float pitch) {
|
void SoundEngine::play(const std::string& name, float x, float y, float z, float volume, float pitch) {
|
||||||
if ((volume *= options->sound) <= 0) return;
|
if ((volume *= options->sound) <= 0) return;
|
||||||
|
|
||||||
volume = Mth::clamp( volume * _getVolumeMult(x, y, z), 0.0f, 1.0f);
|
volume = Mth::clamp(volume, 0.0f, 1.0f);
|
||||||
if (/*!loaded || */options->sound == 0 || volume <= 0) return;
|
|
||||||
|
|
||||||
SoundDesc sound;
|
SoundDesc sound;
|
||||||
if (sounds.get(name, sound)) {
|
if (sounds.get(name, sound)) {
|
||||||
float dist = SOUND_DISTANCE;
|
soundSystem.playAt(sound, x-_x, y-_y, z-_z, volume, pitch);
|
||||||
if (volume > 1) dist *= volume;
|
|
||||||
soundSystem.playAt(sound, x, y, z, volume, pitch);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SoundEngine::playUI(const std::string& name, float volume, float pitch) {
|
void SoundEngine::playUI(const std::string& name, float volume, float pitch) {
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
#define NET_MINECRAFT_CLIENT_SOUND__SoundEngine_H__
|
#define NET_MINECRAFT_CLIENT_SOUND__SoundEngine_H__
|
||||||
|
|
||||||
//package net.minecraft.client.sound;
|
//package net.minecraft.client.sound;
|
||||||
|
|
||||||
#if defined(ANDROID) && !defined(PRE_ANDROID23)
|
#if defined(ANDROID) && !defined(PRE_ANDROID23)
|
||||||
#include "../../platform/audio/SoundSystemSL.h"
|
#include "../../platform/audio/SoundSystemSL.h"
|
||||||
#elif defined(__APPLE__)
|
#elif (defined(__APPLE__) || defined (PLATFORM_DESKTOP)) && !defined(NO_SOUND)
|
||||||
#include "../../platform/audio/SoundSystemAL.h"
|
#include "../../platform/audio/SoundSystemAL.h"
|
||||||
#else
|
#else
|
||||||
#include "../../platform/audio/SoundSystem.h"
|
#include "../../platform/audio/SoundSystem.h"
|
||||||
@@ -23,7 +22,7 @@ class SoundEngine
|
|||||||
|
|
||||||
#if defined(ANDROID) && !defined(PRE_ANDROID23) && !defined(RPI)
|
#if defined(ANDROID) && !defined(PRE_ANDROID23) && !defined(RPI)
|
||||||
SoundSystemSL soundSystem;
|
SoundSystemSL soundSystem;
|
||||||
#elif defined(__APPLE__)
|
#elif (defined(__APPLE__) || defined (PLATFORM_DESKTOP)) && !defined(NO_SOUND)
|
||||||
SoundSystemAL soundSystem;
|
SoundSystemAL soundSystem;
|
||||||
#else
|
#else
|
||||||
SoundSystem soundSystem;
|
SoundSystem soundSystem;
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#ifndef MAIN_GLFW_H__
|
#ifndef MAIN_GLFW_H__
|
||||||
#define MAIN_GLFW_H__
|
#define MAIN_GLFW_H__
|
||||||
|
|
||||||
|
#include "App.h"
|
||||||
#include "GLFW/glfw3.h"
|
#include "GLFW/glfw3.h"
|
||||||
#include "client/renderer/gles.h"
|
#include "client/renderer/gles.h"
|
||||||
#include "SharedConstants.h"
|
#include "SharedConstants.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include "platform/input/Keyboard.h"
|
||||||
#include "platform/input/Mouse.h"
|
#include "platform/input/Mouse.h"
|
||||||
#include "platform/input/Multitouch.h"
|
#include "platform/input/Multitouch.h"
|
||||||
#include "util/Mth.h"
|
#include "util/Mth.h"
|
||||||
@@ -22,6 +24,7 @@ int transformKey(int glfwkey) {
|
|||||||
case GLFW_KEY_ESCAPE: return Keyboard::KEY_ESCAPE;
|
case GLFW_KEY_ESCAPE: return Keyboard::KEY_ESCAPE;
|
||||||
case GLFW_KEY_BACKSPACE: return Keyboard::KEY_BACKSPACE;
|
case GLFW_KEY_BACKSPACE: return Keyboard::KEY_BACKSPACE;
|
||||||
case GLFW_KEY_LEFT_SHIFT: return Keyboard::KEY_LSHIFT;
|
case GLFW_KEY_LEFT_SHIFT: return Keyboard::KEY_LSHIFT;
|
||||||
|
case GLFW_KEY_ENTER: return Keyboard::KEY_RETURN;
|
||||||
default: return glfwkey;
|
default: return glfwkey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,8 +108,8 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
|
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||||
|
|
||||||
GLFWwindow* window = glfwCreateWindow(appContext.platform->getScreenWidth(), appContext.platform->getScreenHeight(), "main", NULL, NULL);
|
GLFWwindow* window = glfwCreateWindow(appContext.platform->getScreenWidth(), appContext.platform->getScreenHeight(), "main", NULL, NULL);
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ void SoundSystemAL::playAt( const SoundDesc& sound, float x, float y, float z, f
|
|||||||
{
|
{
|
||||||
if (pitch < 0.01f) pitch = 1;
|
if (pitch < 0.01f) pitch = 1;
|
||||||
|
|
||||||
//LOGI("playing sound '%s' with volume/pitch: %f, %f @ %f, %f, %f\n", sound.name.c_str(), volume, pitch, x, y, z);
|
LOGI("playing sound '%s' with volume/pitch: %f, %f @ %f, %f, %f\n", sound.name.c_str(), volume, pitch, x, y, z);
|
||||||
|
|
||||||
ALuint bufferID;
|
ALuint bufferID;
|
||||||
if (!getBufferId(sound, &bufferID)) {
|
if (!getBufferId(sound, &bufferID)) {
|
||||||
@@ -151,7 +151,7 @@ void SoundSystemAL::playAt( const SoundDesc& sound, float x, float y, float z, f
|
|||||||
}
|
}
|
||||||
errIdString = "Get buffer";
|
errIdString = "Get buffer";
|
||||||
checkError();
|
checkError();
|
||||||
//LOGI("playing sound %d - '%s' with volume/pitch: %f, %f @ %f, %f, %f\n", bufferID, sound.name.c_str(), volume, pitch, x, y, z);
|
LOGI("playing sound %d - '%s' with volume/pitch: %f, %f @ %f, %f, %f\n", bufferID, sound.name.c_str(), volume, pitch, x, y, z);
|
||||||
|
|
||||||
int sourceIndex;
|
int sourceIndex;
|
||||||
errIdString = "Get free index";
|
errIdString = "Get free index";
|
||||||
@@ -232,12 +232,12 @@ bool SoundSystemAL::getBufferId(const SoundDesc& sound, ALuint* buf) {
|
|||||||
: (sound.channels==2? AL_FORMAT_STEREO8 : AL_FORMAT_MONO8);
|
: (sound.channels==2? AL_FORMAT_STEREO8 : AL_FORMAT_MONO8);
|
||||||
|
|
||||||
alBufferData(bufferID, format, sound.frames, sound.size, sound.frameRate);
|
alBufferData(bufferID, format, sound.frames, sound.size, sound.frameRate);
|
||||||
//LOGI("Creating %d (%p) from sound: '%s'\n", bufferID, sound.frames, sound.name.c_str());
|
LOGI("Creating %d (%p) from sound: '%s'\n", bufferID, sound.frames, sound.name.c_str());
|
||||||
errIdString = "Buffer data";
|
errIdString = "Buffer data";
|
||||||
//LOGI("Creating buffer with data: %d (%d), %p, %d, %d\n", format, sound.byteWidth, sound.frames, sound.size, sound.frameRate);
|
LOGI("Creating buffer with data: %d (%d), %p, %d, %d\n", format, sound.byteWidth, sound.frames, sound.size, sound.frameRate);
|
||||||
checkError();
|
checkError();
|
||||||
|
|
||||||
//LOGI("Sound ch: %d, fmt: %d, frames: %p, len: %f, fr: %d, sz: %d, numfr: %d\n", sound.channels, format, sound.frames, sound.length(), sound.frameRate, sound.size, sound.numFrames);
|
LOGI("Sound ch: %d, fmt: %d, frames: %p, len: %f, fr: %d, sz: %d, numfr: %d\n", sound.channels, format, sound.frames, sound.length(), sound.frameRate, sound.size, sound.numFrames);
|
||||||
|
|
||||||
|
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ unsigned int splitPacketId, unsigned int splitPacketIndex, unsigned int splitPac
|
|||||||
sprintf(str3,"%5u",reliableMessageNumber);
|
sprintf(str3,"%5u",reliableMessageNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(into, "%s,%s%s,%s,%s,%5u,%s,%u,%"PRINTF_64_BIT_MODIFIER"u,%s,%s,%i,%i,%i,%i,%s,"
|
sprintf(into, "%s,%s%s,%s,%s,%5u,%s,%u,%" PRINTF_64_BIT_MODIFIER "u,%s,%s,%i,%i,%i,%i,%s,"
|
||||||
, localtime
|
, localtime
|
||||||
, prefix
|
, prefix
|
||||||
, dir
|
, dir
|
||||||
@@ -144,7 +144,7 @@ void PacketLogger::OnAck(unsigned int messageNumber, SystemAddress remoteSystemA
|
|||||||
char localtime[128];
|
char localtime[128];
|
||||||
GetLocalTime(localtime);
|
GetLocalTime(localtime);
|
||||||
|
|
||||||
sprintf(str, "%s,Rcv,Ack,%i,,,,%"PRINTF_64_BIT_MODIFIER"u,%s,%s,,,,,,"
|
sprintf(str, "%s,Rcv,Ack,%i,,,,%" PRINTF_64_BIT_MODIFIER "u,%s,%s,,,,,,"
|
||||||
, localtime
|
, localtime
|
||||||
, messageNumber
|
, messageNumber
|
||||||
, (unsigned long long) time
|
, (unsigned long long) time
|
||||||
@@ -164,7 +164,7 @@ void PacketLogger::OnPushBackPacket(const char *data, const BitSize_t bitsUsed,
|
|||||||
char localtime[128];
|
char localtime[128];
|
||||||
GetLocalTime(localtime);
|
GetLocalTime(localtime);
|
||||||
|
|
||||||
sprintf(str, "%s,Lcl,PBP,,,%s,%i,%"PRINTF_64_BIT_MODIFIER"u,%s,%s,,,,,,"
|
sprintf(str, "%s,Lcl,PBP,,,%s,%i,%" PRINTF_64_BIT_MODIFIER "u,%s,%s,,,,,,"
|
||||||
, localtime
|
, localtime
|
||||||
, BaseIDTOString(data[0])
|
, BaseIDTOString(data[0])
|
||||||
, bitsUsed
|
, bitsUsed
|
||||||
@@ -226,7 +226,7 @@ void PacketLogger::WriteMiscellaneous(const char *type, const char *msg)
|
|||||||
char localtime[128];
|
char localtime[128];
|
||||||
GetLocalTime(localtime);
|
GetLocalTime(localtime);
|
||||||
|
|
||||||
sprintf(str, "%s,Lcl,%s,,,,,%"PRINTF_64_BIT_MODIFIER"u,%s,,,,,,,%s"
|
sprintf(str, "%s,Lcl,%s,,,,,%" PRINTF_64_BIT_MODIFIER "u,%s,,,,,,,%s"
|
||||||
, localtime
|
, localtime
|
||||||
, type
|
, type
|
||||||
, (unsigned long long) time
|
, (unsigned long long) time
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ void RAK_DLL_EXPORT RakNet::StatisticsToString( RakNetStatistics *s, char *buffe
|
|||||||
if (verbosityLevel==0)
|
if (verbosityLevel==0)
|
||||||
{
|
{
|
||||||
sprintf(buffer,
|
sprintf(buffer,
|
||||||
"Bytes per second sent %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Bytes per second sent %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Bytes per second received %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Bytes per second received %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Current packetloss %.1f%%\n",
|
"Current packetloss %.1f%%\n",
|
||||||
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_SENT],
|
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_SENT],
|
||||||
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_RECEIVED],
|
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_RECEIVED],
|
||||||
@@ -36,15 +36,15 @@ void RAK_DLL_EXPORT RakNet::StatisticsToString( RakNetStatistics *s, char *buffe
|
|||||||
else if (verbosityLevel==1)
|
else if (verbosityLevel==1)
|
||||||
{
|
{
|
||||||
sprintf(buffer,
|
sprintf(buffer,
|
||||||
"Actual bytes per second sent %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Actual bytes per second sent %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Actual bytes per second received %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Actual bytes per second received %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Message bytes per second pushed %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Message bytes per second pushed %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Total actual bytes sent %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Total actual bytes sent %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Total actual bytes received %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Total actual bytes received %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Total message bytes pushed %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Total message bytes pushed %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Current packetloss %.1f%%\n"
|
"Current packetloss %.1f%%\n"
|
||||||
"Average packetloss %.1f%%\n"
|
"Average packetloss %.1f%%\n"
|
||||||
"Elapsed connection time in seconds %"PRINTF_64_BIT_MODIFIER"u\n",
|
"Elapsed connection time in seconds %" PRINTF_64_BIT_MODIFIER "u\n",
|
||||||
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_SENT],
|
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_SENT],
|
||||||
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_RECEIVED],
|
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_RECEIVED],
|
||||||
(long long unsigned int) s->valueOverLastSecond[USER_MESSAGE_BYTES_PUSHED],
|
(long long unsigned int) s->valueOverLastSecond[USER_MESSAGE_BYTES_PUSHED],
|
||||||
@@ -60,7 +60,7 @@ void RAK_DLL_EXPORT RakNet::StatisticsToString( RakNetStatistics *s, char *buffe
|
|||||||
{
|
{
|
||||||
char buff2[128];
|
char buff2[128];
|
||||||
sprintf(buff2,
|
sprintf(buff2,
|
||||||
"Send capacity %"PRINTF_64_BIT_MODIFIER"u bytes per second (%.0f%%)\n",
|
"Send capacity %" PRINTF_64_BIT_MODIFIER "u bytes per second (%.0f%%)\n",
|
||||||
(long long unsigned int) s->BPSLimitByCongestionControl,
|
(long long unsigned int) s->BPSLimitByCongestionControl,
|
||||||
100.0f * s->valueOverLastSecond[ACTUAL_BYTES_SENT] / s->BPSLimitByCongestionControl
|
100.0f * s->valueOverLastSecond[ACTUAL_BYTES_SENT] / s->BPSLimitByCongestionControl
|
||||||
);
|
);
|
||||||
@@ -70,7 +70,7 @@ void RAK_DLL_EXPORT RakNet::StatisticsToString( RakNetStatistics *s, char *buffe
|
|||||||
{
|
{
|
||||||
char buff2[128];
|
char buff2[128];
|
||||||
sprintf(buff2,
|
sprintf(buff2,
|
||||||
"Send limit %"PRINTF_64_BIT_MODIFIER"u (%.0f%%)\n",
|
"Send limit %" PRINTF_64_BIT_MODIFIER "u (%.0f%%)\n",
|
||||||
(long long unsigned int) s->BPSLimitByOutgoingBandwidthLimit,
|
(long long unsigned int) s->BPSLimitByOutgoingBandwidthLimit,
|
||||||
100.0f * s->valueOverLastSecond[ACTUAL_BYTES_SENT] / s->BPSLimitByOutgoingBandwidthLimit
|
100.0f * s->valueOverLastSecond[ACTUAL_BYTES_SENT] / s->BPSLimitByOutgoingBandwidthLimit
|
||||||
);
|
);
|
||||||
@@ -80,27 +80,27 @@ void RAK_DLL_EXPORT RakNet::StatisticsToString( RakNetStatistics *s, char *buffe
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(buffer,
|
sprintf(buffer,
|
||||||
"Actual bytes per second sent %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Actual bytes per second sent %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Actual bytes per second received %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Actual bytes per second received %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Message bytes per second sent %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Message bytes per second sent %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Message bytes per second resent %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Message bytes per second resent %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Message bytes per second pushed %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Message bytes per second pushed %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Message bytes per second processed %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Message bytes per second processed %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Message bytes per second ignored %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Message bytes per second ignored %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Total bytes sent %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Total bytes sent %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Total bytes received %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Total bytes received %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Total message bytes sent %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Total message bytes sent %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Total message bytes resent %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Total message bytes resent %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Total message bytes pushed %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Total message bytes pushed %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Total message bytes received %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Total message bytes received %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Total message bytes ignored %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Total message bytes ignored %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Messages in send buffer, by priority %i,%i,%i,%i\n"
|
"Messages in send buffer, by priority %i,%i,%i,%i\n"
|
||||||
"Bytes in send buffer, by priority %i,%i,%i,%i\n"
|
"Bytes in send buffer, by priority %i,%i,%i,%i\n"
|
||||||
"Messages in resend buffer %i\n"
|
"Messages in resend buffer %i\n"
|
||||||
"Bytes in resend buffer %"PRINTF_64_BIT_MODIFIER"u\n"
|
"Bytes in resend buffer %" PRINTF_64_BIT_MODIFIER "u\n"
|
||||||
"Current packetloss %.1f%%\n"
|
"Current packetloss %.1f%%\n"
|
||||||
"Average packetloss %.1f%%\n"
|
"Average packetloss %.1f%%\n"
|
||||||
"Elapsed connection time in seconds %"PRINTF_64_BIT_MODIFIER"u\n",
|
"Elapsed connection time in seconds %" PRINTF_64_BIT_MODIFIER "u\n",
|
||||||
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_SENT],
|
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_SENT],
|
||||||
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_RECEIVED],
|
(long long unsigned int) s->valueOverLastSecond[ACTUAL_BYTES_RECEIVED],
|
||||||
(long long unsigned int) s->valueOverLastSecond[USER_MESSAGE_BYTES_SENT],
|
(long long unsigned int) s->valueOverLastSecond[USER_MESSAGE_BYTES_SENT],
|
||||||
@@ -128,7 +128,7 @@ void RAK_DLL_EXPORT RakNet::StatisticsToString( RakNetStatistics *s, char *buffe
|
|||||||
{
|
{
|
||||||
char buff2[128];
|
char buff2[128];
|
||||||
sprintf(buff2,
|
sprintf(buff2,
|
||||||
"Send capacity %"PRINTF_64_BIT_MODIFIER"u bytes per second (%.0f%%)\n",
|
"Send capacity %" PRINTF_64_BIT_MODIFIER "u bytes per second (%.0f%%)\n",
|
||||||
(long long unsigned int) s->BPSLimitByCongestionControl,
|
(long long unsigned int) s->BPSLimitByCongestionControl,
|
||||||
100.0f * s->valueOverLastSecond[ACTUAL_BYTES_SENT] / s->BPSLimitByCongestionControl
|
100.0f * s->valueOverLastSecond[ACTUAL_BYTES_SENT] / s->BPSLimitByCongestionControl
|
||||||
);
|
);
|
||||||
@@ -138,7 +138,7 @@ void RAK_DLL_EXPORT RakNet::StatisticsToString( RakNetStatistics *s, char *buffe
|
|||||||
{
|
{
|
||||||
char buff2[128];
|
char buff2[128];
|
||||||
sprintf(buff2,
|
sprintf(buff2,
|
||||||
"Send limit %"PRINTF_64_BIT_MODIFIER"u (%.0f%%)\n",
|
"Send limit %" PRINTF_64_BIT_MODIFIER "u (%.0f%%)\n",
|
||||||
(long long unsigned int) s->BPSLimitByOutgoingBandwidthLimit,
|
(long long unsigned int) s->BPSLimitByOutgoingBandwidthLimit,
|
||||||
100.0f * s->valueOverLastSecond[ACTUAL_BYTES_SENT] / s->BPSLimitByOutgoingBandwidthLimit
|
100.0f * s->valueOverLastSecond[ACTUAL_BYTES_SENT] / s->BPSLimitByOutgoingBandwidthLimit
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1361,7 +1361,7 @@ bool ReliabilityLayer::HandleSocketReceiveFromConnectedPlayer(
|
|||||||
#ifdef PRINT_TO_FILE_ROT
|
#ifdef PRINT_TO_FILE_ROT
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
fprintf(fp, "Heap push %i, %s, weight=%"PRINTF_64_BIT_MODIFIER"u. OI=%i. waiting on %i. SI=%i.\n", receivedPacketNumber, type, weight, internalPacket->orderingIndex.val, orderedReadIndex[internalPacket->orderingChannel].val, internalPacket->sequencingIndex);
|
fprintf(fp, "Heap push %i, %s, weight=%" PRINTF_64_BIT_MODIFIER "u. OI=%i. waiting on %i. SI=%i.\n", receivedPacketNumber, type, weight, internalPacket->orderingIndex.val, orderedReadIndex[internalPacket->orderingChannel].val, internalPacket->sequencingIndex);
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1248,7 +1248,7 @@ int SocketLayer::SendTo_PC( SOCKET s, const char *data, int length, const System
|
|||||||
#ifdef DEBUG_SENDTO_SPIKES
|
#ifdef DEBUG_SENDTO_SPIKES
|
||||||
RakNetTime end = RakNet::GetTime();
|
RakNetTime end = RakNet::GetTime();
|
||||||
static unsigned int callCount=1;
|
static unsigned int callCount=1;
|
||||||
RAKNET_DEBUG_PRINTF("%i. SendTo_PC, time=%"PRINTF_64_BIT_MODIFIER"u, elapsed=%"PRINTF_64_BIT_MODIFIER"u, length=%i, returned=%i, binaryAddress=%i, port=%i, file=%s, line=%i\n", callCount++, end, end-start, length, len, binaryAddress, port, file, line);
|
RAKNET_DEBUG_PRINTF("%i. SendTo_PC, time=%" PRINTF_64_BIT_MODIFIER "u, elapsed=%" PRINTF_64_BIT_MODIFIER "u, length=%i, returned=%i, binaryAddress=%i, port=%i, file=%s, line=%i\n", callCount++, end, end-start, length, len, binaryAddress, port, file, line);
|
||||||
#endif
|
#endif
|
||||||
if (len<0)
|
if (len<0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user