forked from mirrors/kolyah35-minecraft-pe-0.6.1
some improvements
This commit is contained in:
parent
f0617a5d22
commit
a86d333478
11 changed files with 49 additions and 31 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
build/
|
||||
linux-build/
|
||||
.cache/
|
||||
|
|
@ -3,6 +3,10 @@ project(MinecraftPE)
|
|||
|
||||
include(cmake/CPM.cmake)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-invalid-source-encoding")
|
||||
|
||||
CPMAddPackage("gh:madler/zlib@1.3.2")
|
||||
CPMAddPackage(
|
||||
NAME "libpng"
|
||||
|
|
@ -116,15 +120,33 @@ file(GLOB SOURCES
|
|||
"src/NinecraftApp.cpp"
|
||||
)
|
||||
|
||||
if(NOT DEFINED PLATFORM)
|
||||
set(PLATFORM "PLATFORM_GLFW")
|
||||
endif()
|
||||
|
||||
|
||||
if(PLATFORM STREQUAL "PLATFORM_WIN32")
|
||||
list(APPEND SOURCES "src/AppPlatform_win32.cpp")
|
||||
endif()
|
||||
|
||||
if(PLATFORM STREQUAL "PLATFORM_GLFW")
|
||||
list(APPEND SOURCES "src/AppPlatform_glfw.cpp")
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
${SOURCES}
|
||||
|
||||
#TODO: if PLATFORM=PLATFORM_GLFW
|
||||
"src/AppPlatform_glfw.cpp"
|
||||
|
||||
"glad/src/glad.c"
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(EXTRA_LIBS "ws2_32")
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "_CRT_SECURE_NO_WARNINGS")
|
||||
endif()
|
||||
|
||||
if(PLATFORM STREQUAL "PLATFORM_WIN32" OR PLATFORM STREQUAL "PLATFORM_GLFW")
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLATFORM_DESKTOP")
|
||||
endif()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/glad/include/"
|
||||
"${CMAKE_SOURCE_DIR}/src"
|
||||
|
|
@ -133,14 +155,10 @@ target_include_directories(${PROJECT_NAME} PUBLIC
|
|||
"lib/include"
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" "_CRT_SECURE_NO_WARNINGS" "PLATFORM_GLFW")
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
|
||||
target_link_libraries(${PROJECT_NAME} zlib png_shared alsoft.common OpenAL::OpenAL glfw ${EXTRA_LIBS})
|
||||
|
||||
# TODO: add ws2_32 lib if windows
|
||||
# TODO: fix openal linking for windows
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} zlib png_shared alsoft.common OpenAL glfw)
|
||||
|
||||
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
if (NOT UNIX)
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#define NO_NETWORK
|
||||
#endif
|
||||
|
||||
#if defined(RPI)
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
#define CREATORMODE
|
||||
#endif
|
||||
|
||||
|
|
@ -574,7 +574,7 @@ void Minecraft::tick(int nTick, int maxTick) {
|
|||
#ifndef STANDALONE_SERVER
|
||||
textures->loadAndBindTexture("terrain.png");
|
||||
if (!pause && !(screen && !screen->renderGameBehind())) {
|
||||
#if !defined(RPI)
|
||||
#ifndef PLATFORM_DESKTOP
|
||||
#ifdef __APPLE__
|
||||
if (isSuperFast())
|
||||
#endif
|
||||
|
|
@ -691,7 +691,7 @@ void Minecraft::tickInput() {
|
|||
if (isPressed) {
|
||||
gui.handleKeyPressed(key);
|
||||
|
||||
#if defined(WIN32) || defined(RPI)//|| defined(_DEBUG) || defined(DEBUG)
|
||||
#ifdef PLATFORM_DESKTOP //|| defined(_DEBUG) || defined(DEBUG)
|
||||
if (key >= '0' && key <= '9') {
|
||||
int digit = key - '0';
|
||||
int slot = digit - 1;
|
||||
|
|
@ -714,16 +714,14 @@ void Minecraft::tickInput() {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if defined(RPI)
|
||||
|
||||
if (key == Keyboard::KEY_E) {
|
||||
screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||
}
|
||||
if (!screen && key == Keyboard::KEY_O || key == 250) {
|
||||
releaseMouse();
|
||||
}
|
||||
#endif
|
||||
#if defined(WIN32)
|
||||
|
||||
if (key == Keyboard::KEY_F) {
|
||||
options.isFlying = !options.isFlying;
|
||||
player->noPhysics = options.isFlying;
|
||||
|
|
@ -831,7 +829,7 @@ void Minecraft::tickInput() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(RPI) && !defined(PLATFORM_GLFW)
|
||||
#ifndef PLATFORM_DESKTOP
|
||||
if (key == 82)
|
||||
pauseGame(false);
|
||||
#else
|
||||
|
|
@ -848,7 +846,7 @@ void Minecraft::tickInput() {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef WIN32
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
if (key == Keyboard::KEY_M) {
|
||||
for (int i = 0; i < 5 * SharedConstants::TicksPerSecond; ++i)
|
||||
level->tick();
|
||||
|
|
@ -892,7 +890,7 @@ void Minecraft::tickInput() {
|
|||
|| (buildHandled && bai.isRemove());
|
||||
|
||||
TIMER_POP_PUSH("handlemouse");
|
||||
#if defined(RPI) || defined(PLATFORM_GLFW)
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
handleMouseDown(MouseAction::ACTION_LEFT, isTryingToDestroyBlock);
|
||||
handleMouseClick(buildHandled && bai.isInteract()
|
||||
|| options.useMouseForDigging && Mouse::isButtonDown(MouseAction::ACTION_RIGHT));
|
||||
|
|
@ -1123,7 +1121,7 @@ void Minecraft::releaseMouse()
|
|||
}
|
||||
|
||||
bool Minecraft::useTouchscreen() {
|
||||
#if defined(RPI) || defined(PLATFORM_GLFW)
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
return false;
|
||||
#endif
|
||||
return options.useTouchScreen || !_supportsNonTouchscreen;
|
||||
|
|
@ -1366,7 +1364,7 @@ void Minecraft::_levelGenerated()
|
|||
netCallback->levelGenerated(level);
|
||||
}
|
||||
|
||||
#if defined(WIN32) || defined(RPI)
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
if (_commandServer) {
|
||||
delete _commandServer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ void Options::initDefaultValues() {
|
|||
keyJump = KeyMapping("key.jump", Keyboard::KEY_SPACE);
|
||||
keyBuild = KeyMapping("key.inventory", Keyboard::KEY_E);
|
||||
keySneak = KeyMapping("key.sneak", Keyboard::KEY_LSHIFT);
|
||||
#if defined(RPI) || defined(PLATFORM_GLFW)
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
keyCraft = KeyMapping("key.crafting", Keyboard::KEY_Q);
|
||||
keyDrop = KeyMapping("key.drop", Keyboard::KEY_Q);
|
||||
keyChat = KeyMapping("key.chat", Keyboard::KEY_T);
|
||||
|
|
|
|||
|
|
@ -112,10 +112,10 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
|||
unsigned int max = 10;
|
||||
bool isChatting = false;
|
||||
renderChatMessages(screenHeight, max, isChatting, font);
|
||||
#if !defined(RPI)
|
||||
#ifndef PLATFORM_DESKTOP
|
||||
renderOnSelectItemNameText(screenWidth, font, ySlot);
|
||||
#endif
|
||||
#if defined(RPI)
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
renderDebugInfo();
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ static char ILLEGAL_FILE_CHARACTERS[] = {
|
|||
void SelectWorldScreen::tick()
|
||||
{
|
||||
if (_state == _STATE_CREATEWORLD) {
|
||||
#if defined(RPI)
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
std::string levelId = getUniqueLevelName("world");
|
||||
LevelSettings settings(getEpochTimeS(), GameType::Creative);
|
||||
minecraft->selectLevel(levelId, levelId, settings);
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ static char ILLEGAL_FILE_CHARACTERS[] = {
|
|||
void SelectWorldScreen::tick()
|
||||
{
|
||||
if (_state == _STATE_CREATEWORLD) {
|
||||
#if defined(RPI)
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
std::string levelId = getUniqueLevelName("perf");
|
||||
//int seed = Util::hashCode("/r/Minecraft");
|
||||
LevelSettings settings(getEpochTimeS(), GameType::Creative);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ void KeyboardInput::tick( Player* player )
|
|||
ya *= 0.3f;
|
||||
}
|
||||
|
||||
#if defined(RPI) || defined(PLATFORM_GLFW)
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
wantUp = jumping;
|
||||
wantDown = sneaking;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
/*static*/ int Textures::textureChanges = 0;
|
||||
/*static*/ bool Textures::MIPMAP = false;
|
||||
const TextureId Textures::InvalidId = -1;
|
||||
|
||||
Textures::Textures( Options* options_, AppPlatform* platform_ )
|
||||
: clamp(false),
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ private:
|
|||
public:
|
||||
static bool MIPMAP;
|
||||
static int textureChanges;
|
||||
static const TextureId InvalidId = -1;
|
||||
static const TextureId InvalidId;
|
||||
|
||||
private:
|
||||
TextureMap idMap;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "../Options.h"
|
||||
|
||||
// Android should always run OPENGL_ES
|
||||
#if defined(ANDROID) || defined(__APPLE__) || defined(RPI)
|
||||
#if defined(ANDROID) || defined(__APPLE__) || defined(PLATFORM_DESKTOP)
|
||||
#define OPENGL_ES
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue