44 Commits

Author SHA1 Message Date
6bfae5a14e Merge branch 'main' of https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1 2026-03-21 13:43:29 +02:00
4034cf243d FIX: glfw crash when closing the game 2026-03-21 13:43:28 +02:00
b6e7414f04 Merge pull request 'fix msvc build & mingw build' (#10) from evildebugger/minecraft-pe-0.6.1:main into main
Reviewed-on: https://192.168.0.2:3000/Kolyah35/minecraft-pe-0.6.1/pulls/10
2026-03-21 12:48:51 +02:00
66hh
83f3284827 fix msvc build & mingw build
1. Include unified header files using lowercase filenames
2. Change special characters to escape sequences to solve encoding issues
2026-03-21 18:32:09 +08:00
3dab395af3 fix workflow and im done 2026-03-21 02:45:06 +03:00
011c8f7123 fix mingw build 2026-03-21 02:35:04 +03:00
f69c009da9 replace pwd with workspace 2026-03-21 01:38:17 +03:00
b66b4a2dc2 wtf im dumb 2026-03-21 01:35:40 +03:00
7037b2b5f2 create build dir 2026-03-21 01:33:57 +03:00
d54e39b332 -_- 2026-03-21 01:32:47 +03:00
f96ba8bb33 ubuntu 22.04 2026-03-21 01:31:42 +03:00
f0e1980f59 i dont like xwin anymore 2026-03-21 01:31:35 +03:00
52f607b126 Made some changes to the GUI scale slider.
Should be waaaaaaay better now
2026-03-20 23:20:37 +01:00
84a956531c and here 2026-03-21 00:56:21 +03:00
c4f5f22f24 disable module scan 2026-03-21 00:51:35 +03:00
7867aea042 bruh 2026-03-21 00:43:57 +03:00
a90e1463ee maybe try geode msvc sdk 2026-03-21 00:41:19 +03:00
59e820e27f setup ninja 2026-03-21 00:33:59 +03:00
1199f53632 -_- 2026-03-21 00:28:07 +03:00
dc0e2c192b oh i forgot headers 2026-03-21 00:23:56 +03:00
6ef9efa434 maybe ninja? 2026-03-21 00:17:53 +03:00
72e6537dc5 Merge remote-tracking branch 'refs/remotes/origin/main' 2026-03-21 00:15:24 +03:00
0e2e7694d3 oops 2026-03-21 00:12:51 +03:00
45f04ca07b readme fix 2026-03-20 23:08:24 +02:00
42e7a3da90 Merge branch 'main' of https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1 2026-03-20 23:00:36 +02:00
0edee15930 FEAT:Raspberry PI cursor in tweaks 2026-03-20 22:59:52 +02:00
753fdbe701 FIXED: support 64x32 + 64x64 skins with fallback for failed skin URL 2026-03-20 21:47:53 +01:00
ac60559a22 FIXED: Saving works on Android now!
I honestly changed too much stuff trying to pinpoint a fix. I might be stupid.
I have no idea what I did that fixed this.
2026-03-20 21:11:17 +01:00
be6fa57a10 trying to speed up windows build 2026-03-20 23:07:27 +03:00
68f5bc3a0a why zip only files inside data??? 2026-03-20 22:56:00 +03:00
0a24a51663 uuuh 2026-03-20 22:43:49 +03:00
96b17e9c8a tring to pack data with desktop releases 2026-03-20 22:26:26 +03:00
c08c4d270d specify targets for linux 2026-03-20 22:17:20 +03:00
8cd74922bf maybe remove that subdir from path? 2026-03-20 22:10:50 +03:00
b2707cc35d yeah fix shit 2026-03-20 22:03:41 +03:00
1ff91505d8 FIX: ndk and tools caching 2026-03-20 21:57:57 +03:00
b909f3c576 EnumOption 2026-03-20 21:53:10 +03:00
8d1c4f1c4e aaah who did revert my cmake changes 2026-03-20 21:50:45 +03:00
bc5cbe6b73 Merge remote-tracking branch 'refs/remotes/origin/main' 2026-03-20 21:47:46 +03:00
cda2534c1e ADD: pause and chat btn 2026-03-20 21:46:43 +03:00
c54bdfdcff Target SDK lowered for compatibility
Setting it to 36 broke some permission things
Still seems like the game can't write anywhere even with r/w permissions...
2026-03-20 19:07:25 +01:00
d5b2c59ebf FIX: Cmake 2026-03-20 19:14:18 +02:00
5d415dcca1 Merge remote-tracking branch 'refs/remotes/origin/main' 2026-03-20 19:57:24 +03:00
a317bf66af FIX: Increased save time 2026-03-20 19:57:00 +03:00
52 changed files with 506 additions and 262 deletions

17
.github/actions/setup-ninja/action.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: Setup Ninja
description: Sets up Ninja
inputs:
host:
description: 'Host platform: win, mac or linux'
required: true
runs:
using: "composite"
steps:
- name: Setup
shell: bash
run: |
curl -L https://github.com/ninja-build/ninja/releases/latest/download/ninja-${{ inputs.host }}.zip -o ninja.zip
7z x ninja.zip -o"$GITHUB_WORKSPACE/ninja"
echo "$GITHUB_WORKSPACE/ninja" >> $GITHUB_PATH

View File

@@ -19,7 +19,7 @@ permissions:
jobs:
build-windows:
name: Windows Build
runs-on: windows-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
@@ -27,34 +27,51 @@ jobs:
- name: Setup caches
uses: ./.github/actions/setup-cache
with:
host: win
host: linux
target: win
- name: Setup Ninja
uses: ./.github/actions/setup-ninja
with:
host: linux
- name: Download llvm-mingw
run: |
curl -L https://github.com/mstorsjo/llvm-mingw/releases/download/20260311/llvm-mingw-20260311-msvcrt-ubuntu-22.04-x86_64.tar.xz -o llvm-mingw.tar.xz
tar -xf llvm-mingw.tar.xz
mv llvm-mingw-* llvm-mingw
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
shell: powershell
working-directory: ${{github.workspace}}/build
run: cmake $env:GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE
run: |
cmake $GITHUB_WORKSPACE \
-G Ninja \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER=$GITHUB_WORKSPACE/llvm-mingw/bin/x86_64-w64-mingw32-clang \
-DCMAKE_CXX_COMPILER=$GITHUB_WORKSPACE/llvm-mingw/bin/x86_64-w64-mingw32-clang++ \
-DCMAKE_RC_COMPILER=$GITHUB_WORKSPACE/llvm-mingw/bin/x86_64-w64-mingw32-windres \
-DALSOFT_BACKEND_PIPEWIRE=OFF \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Build
working-directory: ${{github.workspace}}/build
shell: powershell
run: cmake --build . --config $env:BUILD_TYPE --target MinecraftPE
run: cmake --build . --config $BUILD_TYPE --target MinecraftPE --parallel
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: mcpe-windows
path: |
${{github.workspace}}/build/${{ env.BUILD_TYPE }}/MinecraftPE.exe
${{github.workspace}}/build/${{ env.BUILD_TYPE }}/glfw3.dll
${{github.workspace}}/build/${{ env.BUILD_TYPE }}/libpng16.dll
${{github.workspace}}/build/${{ env.BUILD_TYPE }}/OpenAL32.dll
${{github.workspace}}/build/${{ env.BUILD_TYPE }}/z.dll
${{github.workspace}}/build/MinecraftPE.exe
${{github.workspace}}/build/glfw3.dll
${{github.workspace}}/build/libpng16.dll
${{github.workspace}}/build/OpenAL32.dll
${{github.workspace}}/build/z.dll
build-linux:
name: Linux Build
@@ -90,7 +107,9 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --build . --config $BUILD_TYPE
run: |
cmake --build . --config $BUILD_TYPE --target MinecraftPE --parallel
cmake --build . --config $BUILD_TYPE --target MinecraftPE-server --parallel
- name: Upload Artifact
uses: actions/upload-artifact@v4
@@ -112,11 +131,10 @@ jobs:
env:
ANDROID_SDK_ROOT: ${{ github.workspace }}/android-sdk
# ANDROID_NDK_PATH: ${{ env.ANDROID_NDK_PATH }}
ANDROID_NDK_PATH: ${{ github.workspace }}/android-ndk-r14b
ANDROID_PLATFORM_API: 36
ANDROID_BUILD_TOOLS_VERSION: 36.0.0
ADB: /bin/true
# JAVA_HOME: ${{ env.JAVA_HOME }}
# build.sh reads MATRIX_ABI to decide which ABI to build when no --abi flag is passed
MATRIX_ABI: ${{ matrix.abi }}
@@ -125,12 +143,14 @@ jobs:
uses: actions/checkout@v4
- name: Cache Android command-line tools
id: cache-android-tools
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/android-sdk/cmdline-tools
path: ${{ env.ANDROID_SDK_ROOT }}
key: android-cmdline-tools-v36
- name: Setup Android command line tools
if: steps.cache-android-tools.outputs.cache-hit != 'true'
run: |
if [ ! -d "$ANDROID_SDK_ROOT/cmdline-tools/latest" ]; then
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
@@ -140,19 +160,21 @@ jobs:
fi
yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" "platform-tools" "platforms;android-${ANDROID_PLATFORM_API}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}"
- name: Cache Android NDK r14b
id: cache-android-ndk
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/android-ndk-r14b
key: android-ndk-r14b
- name: Install Android NDK r14b
if: steps.cache-android-ndk.outputs.cache-hit != 'true'
run: |
if [ ! -d "$GITHUB_WORKSPACE/android-ndk-r14b" ]; then
if [ ! -d "$ANDROID_NDK_PATH" ]; then
curl -L -o ndk.zip "https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip"
unzip -q ndk.zip -d "$GITHUB_WORKSPACE"
fi
echo "ANDROID_NDK_PATH=$GITHUB_WORKSPACE/android-ndk-r14b" >> $GITHUB_ENV
- name: Install system prerequisites
run: |
@@ -214,13 +236,13 @@ jobs:
- name: Zip Windows Artifacts
uses: vimtor/action-zip@v1.2
with:
files: ${{github.workspace}}/data/ mcpe-windows/MinecraftPE.exe mcpe-windows/glfw3.dll mcpe-windows/libpng16.dll mcpe-windows/OpenAL32.dll mcpe-windows/z.dll
files: data mcpe-windows/MinecraftPE.exe mcpe-windows/glfw3.dll mcpe-windows/libpng16.dll mcpe-windows/OpenAL32.dll mcpe-windows/z.dll
dest: minecraftpe-${{ steps.ref.outputs.hash }}-windows.zip
- name: Zip Linux Artifacts
uses: vimtor/action-zip@v1.2
with:
files: ${{github.workspace}}/data/ mcpe-linux/MinecraftPE # ye, you should install libraries by urself :trollface:
files: data mcpe-linux/MinecraftPE
dest: minecraftpe-${{ steps.ref.outputs.hash }}-linux.zip
- name: Zip Linux Server Artifacts

2
.gitignore vendored
View File

@@ -9,8 +9,6 @@ CMakeFiles/
CMakeCache.txt
cmake_install.cmake
Makefile
*.cmake
!cmake/CPM.cmake
# Compiled object files
*.o

View File

@@ -6,22 +6,44 @@ include(cmake/CPM.cmake)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_POLICY_VERSION_MINIMUM 3.10)
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()
include(cmake/EnumOption.cmake)
if(EMSCRIPTEN)
# When configuring web builds with "emcmake cmake -B build -S .", set PLATFORM to Web by default
set(PLATFORM Web CACHE STRING "Platform to build for.")
endif()
enum_option(PLATFORM "Desktop;Web" "Platform to build for.")
find_package(Threads REQUIRED)
find_package(OpenSSL)
if(EMSCRIPTEN)
set(AL_LIBTYPE "STATIC")
else()
set(AL_LIBTYPE "SHARED")
if (${PLATFORM} STREQUAL "Desktop")
set(PLATFORM_CPP "PLATFORM_DESKTOP")
if (WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
include_directories(misc/windows)
set(EXTRA_LIBS ws2_32 winhttp)
elseif(UNIX)
find_library(pthread NAMES pthread)
set(EXTRA_LIBS pthread m)
endif()
elseif (${PLATFORM} STREQUAL "Web")
set(PLATFORM_CPP "PLATFORM_WEB")
set(EXTRA_LIBS "idbfs.js")
endif()
# I totally shocked
if(EMSCRIPTEN)
if(${PLATFORM} MATCHES "Web")
set(PNG_LIB png)
set(AL_LIBTYPE "STATIC")
add_library(zlib INTERFACE IMPORTED)
set_target_properties(zlib PROPERTIES
@@ -39,6 +61,7 @@ if(EMSCRIPTEN)
)
else()
set(PNG_LIB png_shared)
set(AL_LIBTYPE "SHARED")
CPMAddPackage(
NAME "zlib"
@@ -78,6 +101,7 @@ CPMAddPackage(
"ALSOFT_TESTS OFF"
"ALSOFT_UTILS OFF"
"LIBTYPE ${AL_LIBTYPE}"
"ALSOFT_ENABLE_MODULES OFF"
)
# TODO: Clear this paths with *
@@ -259,49 +283,32 @@ file(GLOB CLIENT_SOURCES
"src/SharedConstants.cpp"
"src/main.cpp"
"src/NinecraftApp.cpp"
"src/AppPlatform_glfw.cpp"
"src/main.cpp"
)
if(NOT DEFINED PLATFORM)
set(PLATFORM "PLATFORM_GLFW")
endif()
if(PLATFORM STREQUAL "PLATFORM_WIN32")
list(APPEND CLIENT_SOURCES "src/AppPlatform_win32.cpp" "glad/src/glad.c")
endif()
if(PLATFORM STREQUAL "PLATFORM_GLFW")
list(APPEND CLIENT_SOURCES "src/AppPlatform_glfw.cpp" "glad/src/glad.c")
endif()
if(EMSCRIPTEN)
list(APPEND CLIENT_SOURCES "glad/src/glad.c")
if (${PLATFORM} STREQUAL "Desktop")
list(APPEND CLIENT_SOURCES glad/src/glad.c)
endif()
# Server
if(UNIX)
add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES})
add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES})
target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER")
target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER")
target_include_directories("${PROJECT_NAME}-server" PUBLIC
"${CMAKE_SOURCE_DIR}/src/"
"project/lib_projects/raknet/jni/RaknetSources"
)
target_include_directories("${PROJECT_NAME}-server" PUBLIC
"${CMAKE_SOURCE_DIR}/src/"
"project/lib_projects/raknet/jni/RaknetSources"
)
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT})
endif()
add_executable(${PROJECT_NAME} ${CLIENT_SOURCES})
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_compile_definitions(${PROJECT_NAME} PUBLIC ${PLATFORM_CPP})
target_include_directories(${PROJECT_NAME} PUBLIC
"${CMAKE_SOURCE_DIR}/glad/include/"
@@ -311,7 +318,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
"lib/include"
)
if(EMSCRIPTEN)
if(${PLATFORM} MATCHES "Web")
set(CMAKE_CXX_STANDARD 11)
# uuuh i hate it
set(EM_FLAGS "-pthread -sUSE_PTHREADS=1 -sSHARED_MEMORY=1")
@@ -352,12 +359,11 @@ if(EMSCRIPTEN)
endif()
target_compile_definitions(${PROJECT_NAME} PUBLIC "__EMSCRIPTEN__" "NO_SOUND" "NO_NETWORK")
set(EXTRA_LIBS "idbfs.js")
endif()
# Client
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
target_link_libraries(${PROJECT_NAME} zlib ${PNG_LIB} alsoft.common OpenAL::OpenAL glfw ${EXTRA_LIBS})
target_link_libraries(${PROJECT_NAME} zlib ${PNG_LIB} OpenAL::OpenAL glfw ${EXTRA_LIBS})
if (OpenSSL_FOUND)
target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
@@ -373,7 +379,7 @@ if (NOT UNIX)
)
endif()
if(NOT EMSCRIPTEN)
if(NOT ${PLATFORM} MATCHES "Web")
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
@@ -385,4 +391,7 @@ else()
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/misc/web/index.html" $<TARGET_FILE_DIR:${PROJECT_NAME}>
)
endif()
endif()
message(STATUS "Compiling with the flags:")
message(STATUS " PLATFORM=" ${PLATFORM_CPP})

View File

@@ -113,7 +113,7 @@ cmake --build .
$HOME/Android/Sdk/cmdline-tools/bin/sdkmanager
```
> [!NOTE]
> [!Note]
> `sdkmanager` expects the SDK to include a `cmdline-tools/latest/` folder.
> If you only have `cmdline-tools/bin`, create the required layout:
>
@@ -134,7 +134,7 @@ cmake --build .
sdkmanager --install "platform-tools" "platforms;android-35" "build-tools;35.0.0"
```
> [!NOTE]
> [!Note]
> if you want build.sh to always find the SDK,
> Set ANDROID_SDK_ROOT in your shell config (~/.bashrc / ~/.profile / ~/.config/fish/config.fish), for example:
>
@@ -162,14 +162,14 @@ cmake --build .
7. Extract the archive to `/home/username/`, so that the final directory path is `/home/username/android-ndk-r14b/`
> [!WARNING]
> [!Warning]
> Make sure you dont end up with a nested folder like `/home/username/android-ndk-r14b/android-ndk-r14b/`.
8. Re run `build.sh`
## Web
1. Download and install **emsdk**: https://emscripten.org/docs/getting_started/downloads.html
> [!NOTE]
> [!Note]
> On arch linux you can use AUR:
> `yay -Sy emsdk`
@@ -179,7 +179,7 @@ cmake --build .
cmake .. -B . -G Ninja "-DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
cmake --build . --target MinecraftPE
```
> [!NOTE]
> [!Note]
> If you are using VSCode with CMake plugin, you can add Emscripten kit
> 1. Press Ctrl + Shift + P
> 2. Type `CMake: Edit User-Local CMake Kits` and hit Enter

9
cmake/EnumOption.cmake Normal file
View File

@@ -0,0 +1,9 @@
macro(enum_option var values description)
set(${var}_VALUES ${values})
list(GET ${var}_VALUES 0 default)
set(${var} "${default}" CACHE STRING "${description}")
set_property(CACHE ${var} PROPERTY STRINGS ${${var}_VALUES})
if (NOT ";${${var}_VALUES};" MATCHES ";${${var}};")
message(FATAL_ERROR "Unknown value ${${var}}. Only -D${var}=${${var}_VALUES} allowed.")
endif()
endmacro()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -152,6 +152,7 @@ options.group.graphics=Graphics
options.group.tweaks=Tweaks
options.allowSprint=Allow sprint
options.barOnTop=HUD above inventory
options.rpiCursor=Show Raspberry PI cursor
options.autojump=Auto Jump
options.thirdperson=Third Person
options.servervisible=Server Visible
@@ -181,9 +182,10 @@ options.graphics.fast=Fast
options.guiScale=GUI Scale
options.guiScale.auto=Auto
options.guiScale.small=Small
options.guiScale.normal=Normal
options.guiScale.medium=Medium
options.guiScale.large=Large
options.guiScale.larger=Larger
options.guiScale.largest=Largest
options.advancedOpengl=Advanced OpenGL
options.renderClouds=Clouds
options.farWarning1=A 64 bit Java installation is recommended

View File

@@ -7,7 +7,7 @@
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="36" />
android:targetSdkVersion="30" />
<!-- uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true"/ -->

View File

@@ -168,9 +168,10 @@ options.graphics.fast=Fast
options.guiScale=GUI Scale
options.guiScale.auto=Auto
options.guiScale.small=Small
options.guiScale.normal=Normal
options.guiScale.medium=Medium
options.guiScale.large=Large
options.guiScale.larger=Larger
options.guiScale.largest=Largest
options.advancedOpengl=Advanced OpenGL
options.renderClouds=Clouds
options.farWarning1=A 64 bit Java installation is recommended

View File

@@ -6,7 +6,7 @@
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="36"/>
android:targetSdkVersion="30"/>
<uses-feature
android:name="android.hardware.touchscreen.multitouch"

View File

@@ -168,8 +168,10 @@ options.graphics.fast=Fast
options.guiScale=GUI Scale
options.guiScale.auto=Auto
options.guiScale.small=Small
options.guiScale.normal=Normal
options.guiScale.medium=Medium
options.guiScale.large=Large
options.guiScale.larger=Larger
options.guiScale.largest=Largest
options.advancedOpengl=Advanced OpenGL
options.renderClouds=Clouds
options.farWarning1=A 64 bit Java installation is recommended

View File

@@ -59,6 +59,7 @@ public class MainActivity extends Activity {
private static final int PERMISSION_REQUEST_CODE = 123;
private GLView _glView;
private boolean _nativeInitialized = false;
public float invScale = 1.0f;// / 1.5f;
private int _screenWidth = 0;
private int _screenHeight = 0;
@@ -77,63 +78,48 @@ public class MainActivity extends Activity {
_screenWidth = Math.max(_dm.widthPixels, _dm.heightPixels);
_screenHeight = Math.min(_dm.widthPixels, _dm.heightPixels);
nativeOnCreate(_screenWidth, _screenHeight);
_glView = new GLView(getApplication(), this);
//_glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
_glView.setEGLConfigChooser(true);
//_glView
// _glView.setEGLConfigChooser(
// new GLSurfaceView.EGLConfigChooser() {
//
// @Override
// public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
// // TODO Auto-generated method stub
//
// // Specify a configuration for our opengl session
// // and grab the first configuration that matches is
// int[] configSpec = {
// EGL10.EGL_DEPTH_SIZE, 24,
// EGL10.EGL_NONE
// };
// EGLConfig[] configs = new EGLConfig[1];
// int[] num_config = new int[1];
// egl.eglChooseConfig(display, configSpec, configs, 1, num_config);
// EGLConfig config = configs[0];
// return config;
//
// //return null;
// }
// } );
_glView.commit();
setContentView(_glView);
_soundPlayer = new SoundPlayer(this, AudioManager.STREAM_MUSIC);
setContentView(_glView);
_soundPlayer = new SoundPlayer(this, AudioManager.STREAM_MUSIC);
// request dangerous permissions at runtime if necessary
checkAndRequestPermissions();
initNative();
}
private void checkAndRequestPermissions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
boolean needRequest = false;
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
needRequest = true;
}
if (checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
needRequest = true;
}
if (needRequest) {
requestPermissions(new String[] {
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
android.Manifest.permission.READ_EXTERNAL_STORAGE
}, PERMISSION_REQUEST_CODE);
}
private void initNative() {
if (_nativeInitialized) {
return;
}
_nativeInitialized = true;
nativeOnCreate(_screenWidth, _screenHeight);
}
// request dangerous permissions at runtime if necessary
private boolean checkAndRequestPermissions() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return true;
}
boolean writeGranted = checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
boolean readGranted = checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
if (writeGranted && readGranted) {
return true;
}
requestPermissions(new String[] {
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
android.Manifest.permission.READ_EXTERNAL_STORAGE
}, PERMISSION_REQUEST_CODE);
return false;
}
@Override
@@ -146,8 +132,18 @@ public class MainActivity extends Activity {
break;
}
}
if (!granted) {
// user denied; you might want to warn or close the app
if (granted) {
initNative();
} else {
// We can still run using app-specific external files in scoped-storage,
// so allow startup while warning the user.
initNative();
new AlertDialog.Builder(this)
.setTitle("Storage permission recommended")
.setMessage("MinecraftPE can still run with app-private storage, but public external save/load may require permission.")
.setPositiveButton("OK", null)
.setCancelable(true)
.show();
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);

View File

@@ -1,8 +1,8 @@
#if defined(X360__)
#elif defined (_WIN32)
#include <WinSock2.h>
#include <winsock2.h>
#include <windows.h>
#include <Ws2tcpip.h>
#include <ws2tcpip.h>
// Must always include Winsock2.h before windows.h
// or else:

View File

@@ -74,6 +74,8 @@ public:
virtual TextureData loadTextureFromMemory(const unsigned char* data, size_t size) { return TextureData(); }
virtual void playSound(const std::string& fn, float volume, float pitch) {}
virtual void hideCursor(bool hide) {}
virtual void showDialog(int dialogId) {}
virtual void createUserInput() {}

View File

@@ -73,50 +73,20 @@ public:
: filename_;
std::ifstream source(filename.c_str(), std::ios::binary);
if (source) {
png_structp pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!pngPtr)
return out;
png_infop infoPtr = png_create_info_struct(pngPtr);
if (!infoPtr) {
png_destroy_read_struct(&pngPtr, NULL, NULL);
return out;
}
// Hack to get around the broken libpng for windows
png_set_read_fn(pngPtr,(void*)&source, png_funcReadFile);
png_read_info(pngPtr, infoPtr);
// Set up the texdata properties
out.w = png_get_image_width(pngPtr, infoPtr);
out.h = png_get_image_height(pngPtr, infoPtr);
png_bytep* rowPtrs = new png_bytep[out.h];
out.data = new unsigned char[4 * out.w * out.h];
out.memoryHandledExternally = false;
int rowStrideBytes = 4 * out.w;
for (int i = 0; i < out.h; i++) {
rowPtrs[i] = (png_bytep)&out.data[i*rowStrideBytes];
}
png_read_image(pngPtr, rowPtrs);
// Teardown and return
png_destroy_read_struct(&pngPtr, &infoPtr,(png_infopp)0);
delete[] (png_bytep)rowPtrs;
source.close();
return out;
}
else
{
if (!source) {
LOGI("Couldn't find file: %s\n", filename.c_str());
return out;
}
std::vector<unsigned char> fileData((std::istreambuf_iterator<char>(source)), std::istreambuf_iterator<char>());
source.close();
if (fileData.empty()) {
LOGI("Couldn't read file: %s\n", filename.c_str());
return out;
}
return loadTextureFromMemory(fileData.data(), fileData.size());
}
TextureData loadTextureFromMemory(const unsigned char* data, size_t size) override {
@@ -139,6 +109,11 @@ public:
virtual bool supportsTouchscreen() override { return true; }
virtual void hideCursor(bool hide) override {
int isHide = hide ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN;
glfwSetInputMode(window, GLFW_CURSOR, isHide);
}
virtual void openURL(const std::string& url) override {
#ifdef _WIN32
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);

View File

@@ -99,6 +99,9 @@ void NinecraftApp::init()
I18n::loadLanguage(platform(), "en_US");
#endif
if (!externalStoragePath.empty()) {
options.setOptionsFilePath(externalStoragePath);
}
Minecraft::init();
#if !defined(DEMO_MODE) && !defined(APPLE_DEMO_PROMOTION) && !defined(NO_STORAGE)

View File

@@ -1143,6 +1143,8 @@ void Minecraft::init()
checkGlError("Init complete");
#endif
options.load();
setIsCreativeMode(false); // false means it's Survival Mode
reloadOptions();
}
@@ -1158,12 +1160,13 @@ void Minecraft::setSize(int w, int h) {
// determine gui scale, optionally overriding auto
if (guiScale != 0) {
// manual selection: 1->small, 2->normal, 3->large, 4->larger
// manual selection: 1->small, 2->medium, 3->large, 4->larger, 5->largest
switch (guiScale) {
case 1: Gui::GuiScale = 2.0f; break;
case 2: Gui::GuiScale = 3.0f; break;
case 3: Gui::GuiScale = 4.0f; break;
case 4: Gui::GuiScale = 5.0f; break; // bigger than large
case 4: Gui::GuiScale = 5.0f; break;
case 5: Gui::GuiScale = 6.0f; break;
default: Gui::GuiScale = 1.0f; break; // auto
}
} else {

View File

@@ -5,7 +5,7 @@
#include <SDL/SDL.h>
#endif
#ifdef PLATFORM_GLFW
#ifdef PLATFORM_DESKTOP
#include <GLFW/glfw3.h>
#endif
@@ -34,7 +34,7 @@ void MouseHandler::grab() {
SDL_ShowCursor(0);
#endif
#ifdef PLATFORM_GLFW
#ifdef PLATFORM_DESKTOP
glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
#endif
}
@@ -46,7 +46,7 @@ void MouseHandler::release() {
SDL_ShowCursor(1);
#endif
#ifdef PLATFORM_GLFW
#ifdef PLATFORM_DESKTOP
glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
#endif
}

View File

@@ -20,6 +20,7 @@ OptionBool fixedCamera("fixedCamera", false);
OptionBool isFlying("isflying", false);
OptionBool barOnTop("barOnTop", false);
OptionBool allowSprint("allowSprint", true);
OptionBool rpiCursor("rpiCursor", false);
OptionBool autoJump("autoJump", true);
@@ -158,6 +159,7 @@ void Options::initTable() {
m_options[OPTIONS_BAR_ON_TOP] = &barOnTop;
m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint;
m_options[OPTIONS_RPI_CURSOR] = &rpiCursor;
m_options[OPTIONS_AUTOJUMP] = &autoJump;
m_options[OPTIONS_LAST_IP] = &lastIp;
@@ -283,6 +285,10 @@ void Options::save() {
optionsFile.save(stringVec);
}
void Options::setOptionsFilePath(const std::string& path) {
optionsFile.setOptionsPath(path + "/options.txt");
}
void Options::notifyOptionUpdate(OptionId key, bool value) {
minecraft->optionUpdated(key, value);
}

View File

@@ -83,6 +83,7 @@ enum OptionId {
OPTIONS_FIRST_LAUNCH,
OPTIONS_LAST_IP,
OPTIONS_RPI_CURSOR,
// Should be last!
OPTIONS_COUNT
};
@@ -100,15 +101,10 @@ public:
// elements werent initialized so i was getting a garbage pointer and a crash
m_options.fill(nullptr);
initTable();
load();
// load() is deferred to init() where path is configured correctly
}
void initTable();
void set(OptionId key, int value);
void set(OptionId key, float value);
void set(OptionId key, const std::string& value);
void toggle(OptionId key);
void initTable();
int getIntValue(OptionId key) {
auto option = opt<OptionInt>(key);
@@ -144,6 +140,11 @@ public:
void load();
void save();
void set(OptionId key, int value);
void set(OptionId key, float value);
void set(OptionId key, const std::string& value);
void setOptionsFilePath(const std::string& path);
void toggle(OptionId key);
void notifyOptionUpdate(OptionId key, bool value);
void notifyOptionUpdate(OptionId key, float value);

View File

@@ -4,6 +4,13 @@
#include <errno.h>
#include <platform/log.h>
#if defined(_WIN32)
#include <direct.h>
#else
#include <sys/stat.h>
#include <sys/types.h>
#endif
OptionsFile::OptionsFile() {
#ifdef __APPLE__
settingsPath = "./Documents/options.txt";
@@ -14,18 +21,54 @@ OptionsFile::OptionsFile() {
#endif
}
void OptionsFile::save(const StringVector& settings) {
FILE* pFile = fopen(settingsPath.c_str(), "w");
if(pFile != NULL) {
for(StringVector::const_iterator it = settings.begin(); it != settings.end(); ++it) {
fprintf(pFile, "%s\n", it->c_str());
}
fclose(pFile);
} else {
LOGI("OptionsFile::save failed to open '%s' for writing: %s", settingsPath.c_str(), strerror(errno));
}
void OptionsFile::setOptionsPath(const std::string& path) {
settingsPath = path;
}
std::string OptionsFile::getOptionsPath() const {
return settingsPath;
}
void OptionsFile::save(const StringVector& settings) {
FILE* pFile = fopen(settingsPath.c_str(), "w");
if (!pFile && errno == ENOENT) {
std::string dir = settingsPath;
size_t fpos = dir.find_last_of("/\\");
if (fpos != std::string::npos) {
dir.resize(fpos);
std::string toCreate;
for (size_t i = 0; i <= dir.size(); ++i) {
if (i == dir.size() || dir[i] == '/' || dir[i] == '\\') {
if (!toCreate.empty()) {
#if defined(_WIN32)
_mkdir(toCreate.c_str());
#else
mkdir(toCreate.c_str(), 0755);
#endif
}
}
if (i < dir.size())
toCreate.push_back(dir[i]);
}
}
pFile = fopen(settingsPath.c_str(), "w");
}
if (!pFile) {
LOGI("OptionsFile::save failed: %s", strerror(errno));
return;
}
for (const auto& s : settings) {
fprintf(pFile, "%s\n", s.c_str());
}
fclose(pFile);
}
StringVector OptionsFile::getOptionStrings() {
StringVector returnVector;
FILE* pFile = fopen(settingsPath.c_str(), "r");
@@ -46,7 +89,8 @@ StringVector OptionsFile::getOptionStrings() {
}
fclose(pFile);
} else {
LOGI("OptionsFile::getOptionStrings failed to open '%s' for reading: %s", settingsPath.c_str(), strerror(errno));
if (errno != ENOENT)
LOGI("OptionsFile::getOptionStrings failed to open '%s' for reading: %s", settingsPath.c_str(), strerror(errno));
}
return returnVector;
}

View File

@@ -11,7 +11,9 @@ public:
OptionsFile();
void save(const StringVector& settings);
StringVector getOptionStrings();
void setOptionsPath(const std::string& path);
std::string getOptionsPath() const;
private:
std::string settingsPath;
};

View File

@@ -186,7 +186,7 @@ void Font::draw( const std::string& str, float x, float y, int color, bool darke
glPushMatrix2();
glTranslatef2((GLfloat)x, (GLfloat)y, 0.0f);
for (unsigned int i = 0; i < str.length(); i++) {
while (str.length() > i + 1 && str[i] == '§') {
while (str.length() > i + 1 && str[i] == '\xa7') {
int cc = hex.find((char)tolower(str[i + 1]));
if (cc < 0 || cc > 15) cc = 15;
lists[index++] = listPos + 256 + cc + (darken ? 16 : 0);
@@ -235,7 +235,7 @@ int Font::width( const std::string& str )
int len = 0;
for (unsigned int i = 0; i < str.length(); i++) {
if (str[i] == '§') {
if (str[i] == '\xa7') {
i++;
} else {
//int ch = SharedConstants.acceptableLetters.indexOf(str.charAt(i));
@@ -274,7 +274,7 @@ std::string Font::sanitize( const std::string& str )
int j = 0;
for (unsigned int i = 0; i < str.length(); i++) {
if (str[i] == '§') {
if (str[i] == '\xa7') {
i++;
//} else if (SharedConstants.acceptableLetters.indexOf(str.charAt(i)) >= 0) {
} else {

View File

@@ -65,7 +65,7 @@ void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
OptionsItem* item = new OptionsItem(itemLabel, element);
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
addChild(item);
setupPositions();
@@ -77,7 +77,7 @@ void OptionsGroup::createProgressSlider(OptionId optId, Minecraft* minecraft ) {
element->height = 20;
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
OptionsItem* item = new OptionsItem(itemLabel, element);
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
addChild(item);
setupPositions();
}
@@ -87,7 +87,7 @@ void OptionsGroup::createStepSlider(OptionId optId, Minecraft* minecraft ) {
element->width = 100;
element->height = 20;
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
OptionsItem* item = new OptionsItem(itemLabel, element);
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
addChild(item);
setupPositions();
}
@@ -98,7 +98,7 @@ void OptionsGroup::createTextbox(OptionId optId, Minecraft* minecraft) {
element->height = 20;
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
OptionsItem* item = new OptionsItem(itemLabel, element);
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
addChild(item);
setupPositions();
}
@@ -109,7 +109,7 @@ void OptionsGroup::createKey(OptionId optId, Minecraft* minecraft) {
element->height = 20;
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
OptionsItem* item = new OptionsItem(itemLabel, element);
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
addChild(item);
setupPositions();
}

View File

@@ -1,9 +1,11 @@
#include "OptionsItem.h"
#include "../../Minecraft.h"
#include "../../../locale/I18n.h"
#include "../../../util/Mth.h"
OptionsItem::OptionsItem( std::string label, GuiElement* element )
OptionsItem::OptionsItem( OptionId optionId, std::string label, GuiElement* element )
: GuiElementContainer(false, true, 0, 0, 24, 12),
label(label) {
m_optionId(optionId),
m_label(label) {
addChild(element);
}
@@ -19,6 +21,22 @@ void OptionsItem::setupPositions() {
void OptionsItem::render( Minecraft* minecraft, int xm, int ym ) {
int yOffset = (height - 8) / 2;
minecraft->font->draw(label, (float)x, (float)y + yOffset, 0x909090, false);
std::string text = m_label;
if (m_optionId == OPTIONS_GUI_SCALE) {
int value = minecraft->options.getIntValue(OPTIONS_GUI_SCALE);
std::string scaleText;
switch (value) {
case 0: scaleText = I18n::get("options.guiScale.auto"); break;
case 1: scaleText = I18n::get("options.guiScale.small"); break;
case 2: scaleText = I18n::get("options.guiScale.medium"); break;
case 3: scaleText = I18n::get("options.guiScale.large"); break;
case 4: scaleText = I18n::get("options.guiScale.larger"); break;
case 5: scaleText = I18n::get("options.guiScale.largest"); break;
default: scaleText = I18n::get("options.guiScale.auto"); break;
}
text += ": " + scaleText;
}
minecraft->font->draw(text, (float)x, (float)y + yOffset, 0x909090, false);
super::render(minecraft, xm, ym);
}

View File

@@ -15,12 +15,13 @@ class OptionsItem: public GuiElementContainer
{
typedef GuiElementContainer super;
public:
OptionsItem(std::string label, GuiElement* element);
OptionsItem(OptionId optionId, std::string label, GuiElement* element);
virtual void render(Minecraft* minecraft, int xm, int ym);
void setupPositions();
private:
std::string label;
OptionId m_optionId;
std::string m_label;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsItem_H__*/

View File

@@ -2,6 +2,7 @@
#include "../../Minecraft.h"
#include "../../renderer/Textures.h"
#include "../Screen.h"
#include "../../../locale/I18n.h"
#include "../../../util/Mth.h"
#include <algorithm>
#include <assert.h>
@@ -21,7 +22,7 @@ void Slider::render( Minecraft* minecraft, int xm, int ym ) {
if (m_numSteps > 2) {
int stepDistance = barWidth / (m_numSteps-1);
for(int a = 0; a <= m_numSteps; ++a) {
for(int a = 0; a < m_numSteps; ++a) {
int renderSliderStepPosX = xSliderStart + a * stepDistance + 1;
fill(renderSliderStepPosX - 1, ySliderStart - 2, renderSliderStepPosX + 1, ySliderEnd + 2, 0xff606060);
}
@@ -64,15 +65,20 @@ SliderFloat::SliderFloat(Minecraft* minecraft, OptionId option)
SliderInt::SliderInt(Minecraft* minecraft, OptionId option)
: Slider(option), m_option(dynamic_cast<OptionInt*>(minecraft->options.getOpt(option)))
{
m_numSteps = m_option->getMax() - m_option->getMin();
m_numSteps = m_option->getMax() - m_option->getMin() + 1;
m_percentage = float(m_option->get() - m_option->getMin()) / (m_numSteps-1);
}
void SliderInt::render( Minecraft* minecraft, int xm, int ym ) {
Slider::render(minecraft, xm, ym);
}
void SliderInt::mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) {
Slider::mouseReleased(minecraft, x, y, buttonNum);
if (pointInside(x, y)) {
int curStep = Mth::floor(m_percentage * (m_numSteps-1));
int curStep = int(m_percentage * (m_numSteps-1) + 0.5f);
curStep = Mth::clamp(curStep + m_option->getMin(), m_option->getMin(), m_option->getMax());
m_percentage = float(curStep - m_option->getMin()) / (m_numSteps-1);
minecraft->options.set(m_optId, curStep);

View File

@@ -38,6 +38,7 @@ class SliderInt : public Slider {
public:
SliderInt(Minecraft* minecraft, OptionId option);
virtual void render( Minecraft* minecraft, int xm, int ym ) override;
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
protected:

View File

@@ -216,8 +216,5 @@ void ConsoleScreen::render(int /*xm*/, int /*ym*/, float /*a*/)
displayed += '_';
// Placeholder hint when empty
if (_input.empty() && (_cursorBlink / 10) % 2 != 0)
font->drawShadow("Type a message or /command", (float)(boxX0 + 2), (float)(boxY + 2), 0xff606060);
else
font->drawShadow(displayed, (float)(boxX0 + 2), (float)(boxY + 2), 0xffffffff);
font->drawShadow(displayed, (float)(boxX0 + 2), (float)(boxY + 2), 0xffffffff);
}

View File

@@ -225,7 +225,8 @@ void OptionsScreen::generateOptionScreens() {
.addOptionItem(OPTIONS_AMBIENT_OCCLUSION, minecraft);
optionPanes[4]->addOptionItem(OPTIONS_ALLOW_SPRINT, minecraft)
.addOptionItem(OPTIONS_BAR_ON_TOP, minecraft);
.addOptionItem(OPTIONS_BAR_ON_TOP, minecraft)
.addOptionItem(OPTIONS_RPI_CURSOR, minecraft);
}
void OptionsScreen::mouseClicked(int x, int y, int buttonNum) {

View File

@@ -4,6 +4,7 @@
#include "JoinGameScreen.h"
#include "PauseScreen.h"
#include "RenameMPLevelScreen.h"
#include "ConsoleScreen.h"
#include "IngameBlockSelectionScreen.h"
#include "JoinByIPScreen.h"
#include "touch/TouchStartMenuScreen.h"
@@ -19,6 +20,7 @@ Screen* ScreenChooser::createScreen( ScreenId id )
{
Screen* screen = NULL;
// :sob:
if (_mc->useTouchscreen()) {
switch (id) {
case SCREEN_STARTMENU: screen = new Touch::StartMenuScreen(); break;
@@ -28,6 +30,7 @@ Screen* ScreenChooser::createScreen( ScreenId id )
case SCREEN_PAUSEPREV: screen = new PauseScreen(true); break;
case SCREEN_BLOCKSELECTION: screen = new Touch::IngameBlockSelectionScreen(); break;
case SCREEN_JOINBYIP: screen = new JoinByIPScreen(); break;
case SCREEN_CONSOLE: screen = new ConsoleScreen(); break;
case SCREEN_NONE:
default:
// Do nothing
@@ -42,7 +45,7 @@ Screen* ScreenChooser::createScreen( ScreenId id )
case SCREEN_PAUSEPREV: screen = new PauseScreen(true); break;
case SCREEN_BLOCKSELECTION: screen = new IngameBlockSelectionScreen(); break;
case SCREEN_JOINBYIP: screen = new JoinByIPScreen(); break;
case SCREEN_CONSOLE: screen = new ConsoleScreen(); break;
case SCREEN_NONE:
default:
// Do nothing

View File

@@ -9,7 +9,8 @@ enum ScreenId {
SCREEN_PAUSEPREV,
SCREEN_SELECTWORLD,
SCREEN_BLOCKSELECTION,
SCREEN_JOINBYIP
SCREEN_JOINBYIP,
SCREEN_CONSOLE
};
class Screen;

View File

@@ -28,6 +28,7 @@
#if defined(_WIN32)
#include <direct.h>
#include <sys/stat.h>
#else
#include <sys/stat.h>
#include <sys/types.h>
@@ -187,6 +188,33 @@ static bool ensureDirectoryExists(const std::string& path) {
return _mkdir(path.c_str()) == 0 || errno == EEXIST;
#else
struct stat st;
if (stat(path.c_str(), &st) == 0 && S_ISDIR(st.st_mode))
return true;
std::string subPath;
size_t i = 0;
while (i < path.length()) {
i = path.find_first_of("/\\", i);
if (i == std::string::npos) {
subPath = path;
} else {
subPath = path.substr(0, i);
}
if (!subPath.empty()) {
if (stat(subPath.c_str(), &st) != 0) {
if (mkdir(subPath.c_str(), 0755) != 0 && errno != EEXIST)
return false;
} else if (!S_ISDIR(st.st_mode)) {
return false;
}
}
if (i == std::string::npos)
break;
i += 1;
}
if (stat(path.c_str(), &st) == 0 && S_ISDIR(st.st_mode))
return true;
return mkdir(path.c_str(), 0755) == 0 || errno == EEXIST;
@@ -236,7 +264,8 @@ static void* fetchSkinForPlayer(void* param) {
std::vector<unsigned char> skinData;
if (!HttpClient::download(skinUrl, skinData) || skinData.empty()) {
LOGW("[Skin] download failed for %s\n", skinUrl.c_str());
return NULL;
player->setTextureName("mob/char.png");
return NULL;
}
// Save to cache

View File

@@ -426,9 +426,7 @@ public:
virtual void onConfigChanged(const Config& c) {
_move.onConfigChanged(c);
_turnBuild.moveArea = _move.getRectangleArea();
#ifdef __APPLE__
_turnBuild.pauseArea = _move.getPauseRectangleArea();
#endif
_turnBuild.inventoryArea = _mc->gui.getRectangleArea( _mc->options.getBooleanValue(OPTIONS_IS_LEFT_HANDED)? 1 : -1 );
_turnBuild.setSensitivity(c.options->getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)? 1.8f : 1.0f);
((ITurnInput*)&_turnBuild)->onConfigChanged(c);

View File

@@ -9,7 +9,10 @@
#include "../../../../platform/log.h"
#include "../../../renderer/Textures.h"
#include "../../../sound/SoundEngine.h"
#include "client/gui/screens/ScreenChooser.h"
// ARGHHHHHH WHY NOT FUCKING ENUM
static const int AREA_DPAD_FIRST = 100;
static const int AREA_DPAD_N = 100;
static const int AREA_DPAD_S = 101;
@@ -17,6 +20,7 @@ static const int AREA_DPAD_W = 102;
static const int AREA_DPAD_E = 103;
static const int AREA_DPAD_C = 104;
static const int AREA_PAUSE = 105;
static const int AREA_CHAT = 106;
static int cPressed = 0;
static int cReleased = 0;
@@ -158,14 +162,11 @@ void TouchscreenInput_TestFps::onConfigChanged(const Config& c) {
xx = BaseX + 2 * Bw; yy = BaseY + Bh;
_model.addArea(AREA_DPAD_E, aRight = new RectangleArea(xx, yy, xx+Bw, yy+Bh));
#ifdef __APPLE__
float maxPixels = _minecraft->pixelCalc.millimetersToPixels(10);
float btnSize = Mth::Min(18 * Gui::GuiScale, maxPixels);
_model.addArea(AREA_PAUSE, aPause = new RectangleArea(w - 4 - btnSize,
4,
w - 4,
4 + btnSize));
#endif /* __APPLE__ */
// float btnSize = Mth::Min(18 * Gui::GuiScale, maxPixels);
float btnSize = pc.millimetersToPixels(50);
_model.addArea(AREA_PAUSE, aPause = new RectangleArea(w - 4 - btnSize, 4, w - 4, 4 + btnSize));
_model.addArea(AREA_CHAT, aChat = new RectangleArea(w - 8 - btnSize * 2, 4, w - 8 - btnSize, 4 + btnSize));
//rebuild();
}
@@ -309,14 +310,19 @@ void TouchscreenInput_TestFps::tick( Player* player )
setButton = true;
xa -= 1;
}
#ifdef __APPLE__
else if (areaId == AREA_PAUSE) {
if (Multitouch::isReleased(p)) {
_minecraft->soundEngine->playUI("random.click", 1, 1);
_minecraft->screenChooser.setScreen(SCREEN_PAUSE);
}
}
#endif /*__APPLE__*/
else if (areaId == AREA_CHAT) {
if (Multitouch::isReleased(p)) {
_minecraft->soundEngine->playUI("random.click", 1, 1);
_minecraft->screenChooser.setScreen(SCREEN_CONSOLE);
}
}
_buttons[areaId - AREA_DPAD_FIRST] = setButton;
}
@@ -499,15 +505,14 @@ void TouchscreenInput_TestFps::rebuild() {
drawRectangleArea(t, aJump, imageU + imageSize * 4, imageV, (float)imageSize);
}
#ifdef __APPLE__
if (!_minecraft->screen) {
if (isButtonDown(AREA_PAUSE)) t.colorABGR(cPressedPause);
else t.colorABGR(cReleasedPause);
t.colorABGR(0xFFFFFFFF);
// if (isButtonDown(AREA_PAUSE)) t.colorABGR(cPressedPause);
// else t.colorABGR(cReleasedPause);
drawRectangleArea(t, aPause, 200, 64, 18.0f);
drawRectangleArea(t, aChat, 200, 82, 18.0f);
}
#endif /*__APPLE__*/
//t.end(true, _bufferId);
//return;

View File

@@ -61,6 +61,7 @@ private:
RectangleArea* aUp;
RectangleArea* aDown;
RectangleArea* aPause;
RectangleArea* aChat;
//RectangleArea* aUpJump;
RectangleArea* aJump;
RectangleArea* aUpLeft;

View File

@@ -1,4 +1,5 @@
#include "GameRenderer.h"
#include "client/Options.h"
#include "gles.h"
#include "../../util/PerfTimer.h"
@@ -214,12 +215,14 @@ void GameRenderer::render(float a) {
glDisable2(GL_SCISSOR_TEST);
mc->screen->render(xMouse, yMouse, a);
#ifdef RPI
mc->platform()->hideCursor(!mc->options.getBooleanValue(OPTIONS_RPI_CURSOR));
if (mc->options.getBooleanValue(OPTIONS_RPI_CURSOR))
renderCursor(xMouse, yMouse, mc);
#endif
// Screen might have been removed, so check it again
if (mc->screen && !mc->screen->isInGameScreen())
sleepMs(15);
// Screen might have been removed, so check it again
if (mc->screen && !mc->screen->isInGameScreen())
sleepMs(15);
}
}

View File

@@ -19,12 +19,13 @@ public:
protected:
void additionalRendering(Mob* mob, float a);
private:
HumanoidModel* humanoidModel;
// Last rotation values for cape smoothing (reduces jitter)
float lastCapeXRot;
float lastCapeZRot;
private:
// i guess ill keep this just in case seomthing breaks
};
#endif /*NET_MINECRAFT_CLIENT_RENDERER_ENTITY__HumanoidMobRenderer_H__*/

View File

@@ -43,8 +43,8 @@ public:
protected:
void setArmor(Model* armor);
Model* getArmor();
Model* model; // allows derived renderers to swap models dynamically for skin formats
private:
Model* model;
Model* armor;
};

View File

@@ -1,5 +1,6 @@
#include "PlayerRenderer.h"
#include "EntityRenderDispatcher.h"
#include "../Textures.h"
#include "../../../world/entity/player/Player.h"
#include "../../../world/level/Level.h"
#include "../../../world/item/ArmorItem.h"
@@ -14,12 +15,22 @@ static const std::string armorFilenames[10] = {
PlayerRenderer::PlayerRenderer( HumanoidModel* humanoidModel, float shadow )
: super(humanoidModel, shadow),
playerModel64(humanoidModel),
playerModel32(new HumanoidModel(0, 0, 64, 32)),
armorParts1(new HumanoidModel(1.0f, 0, 64, 64)),
armorParts2(new HumanoidModel(0.5f, 0, 64, 64))
{
// default to legacy skin path until we know the exact texture size
model = playerModel32;
humanoidModel = playerModel32;
}
PlayerRenderer::~PlayerRenderer() {
// prevent MobRenderer destructor from deleting model pointers we manage manually
model = nullptr;
delete playerModel32;
delete playerModel64;
delete armorParts1;
delete armorParts2;
}
@@ -43,6 +54,15 @@ void PlayerRenderer::setupRotations( Entity* mob, float bob, float bodyRot, floa
super::setupRotations(mob, bob, bodyRot, a);
}
bool PlayerRenderer::isModernPlayerSkin(Mob* mob) {
const std::string texName = mob->getTexture();
TextureId texId = entityRenderDispatcher->textures->loadTexture(texName);
if (!Textures::isTextureIdValid(texId))
return false;
const TextureData* texData = entityRenderDispatcher->textures->getTemporaryTextureData(texId);
return texData && texData->w == 64 && texData->h == 64;
}
void PlayerRenderer::renderName( Mob* mob, float x, float y, float z ){
//@todo: figure out how to handle HideGUI
if (mob != entityRenderDispatcher->cameraEntity && mob->level->adventureSettings.showNameTags) {
@@ -50,6 +70,20 @@ void PlayerRenderer::renderName( Mob* mob, float x, float y, float z ){
}
}
void PlayerRenderer::render(Entity* mob_, float x, float y, float z, float rot, float a) {
Mob* mob = (Mob*) mob_;
HumanoidModel* desired = isModernPlayerSkin(mob) ? playerModel64 : playerModel32;
if (model != desired || humanoidModel != desired) {
model = desired;
humanoidModel = desired;
}
// LOGI("[PlayerRenderer] %s: skin=%s, modelTex=%dx%d, desired=%s\n",
// ((Player*)mob)->name.c_str(), mob->getTexture().c_str(),
// humanoidModel->texWidth, humanoidModel->texHeight,
// (desired == playerModel64 ? "64" : "32"));
HumanoidMobRenderer::render(mob_, x, y, z, rot, a);
}
int PlayerRenderer::prepareArmor(Mob* mob, int layer, float a) {
Player* player = (Player*) mob;
@@ -80,8 +114,11 @@ int PlayerRenderer::prepareArmor(Mob* mob, int layer, float a) {
}
void PlayerRenderer::onGraphicsReset() {
super::onGraphicsReset();
if (playerModel32) playerModel32->onGraphicsReset();
if (playerModel64) playerModel64->onGraphicsReset();
if (armorParts1) armorParts1->onGraphicsReset();
if (armorParts2) armorParts2->onGraphicsReset();
super::onGraphicsReset();
}

View File

@@ -11,6 +11,8 @@ public:
~PlayerRenderer();
virtual int prepareArmor(Mob* mob, int layer, float a);
bool isModernPlayerSkin(Mob* mob);
virtual void render(Entity* mob, float x, float y, float z, float rot, float a);
virtual void setupPosition(Entity* mob, float x, float y, float z);
virtual void setupRotations(Entity* mob, float bob, float bodyRot, float a);
@@ -18,6 +20,8 @@ public:
virtual void renderName(Mob* mob, float x, float y, float z);
virtual void onGraphicsReset();
private:
HumanoidModel* playerModel32;
HumanoidModel* playerModel64;
HumanoidModel* armorParts1;
HumanoidModel* armorParts2;
};

View File

@@ -31,7 +31,7 @@
// #else
// // Uglyness to fix redeclaration issues
// #ifdef WIN32
// #include <WinSock2.h>
// #include <winsock2.h>
// #include <Windows.h>
// #endif
// #include <gl/glew.h>

View File

@@ -22,12 +22,12 @@
#include "NinecraftApp.h"
#define MAIN_CLASS NinecraftApp
#ifdef PLATFORM_WINDOWS
#include "main_win32.h"
#endif
// #ifdef PLATFORM_WINDOWS
// #include "main_win32.h"
// #endif
#ifdef PLATFORM_GLFW
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
#include "main_glfw.h"
#endif

View File

@@ -25,12 +25,33 @@ static void setupExternalPath(struct android_app* state, MAIN_CLASS* app)
{
LOGI("Environment exists");
}
jclass clazz = env->FindClass("android/os/Environment");
jmethodID method = env->GetStaticMethodID(clazz, "getExternalStorageDirectory", "()Ljava/io/File;");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
// try appspecific external directory first
jobject activity = state->activity->clazz;
jclass activityClass = env->GetObjectClass(activity);
jmethodID getExternalFilesDir = env->GetMethodID(activityClass, "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;");
jobject file = NULL;
if (getExternalFilesDir != NULL) {
file = env->CallObjectMethod(activity, getExternalFilesDir, NULL);
}
if (file == NULL) {
// Fallback to the legacy shared storage directory
jclass clazz = env->FindClass("android/os/Environment");
jmethodID method = env->GetStaticMethodID(clazz, "getExternalStorageDirectory", "()Ljava/io/File;");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
}
file = env->CallStaticObjectMethod(clazz, method);
}
if (!file) {
LOGI("Failed to get external storage file object, using current working dir");
app->externalStoragePath = ".";
app->externalCacheStoragePath = ".";
return;
}
jobject file = env->CallStaticObjectMethod(clazz, method);
jclass fileClass = env->GetObjectClass(file);
jmethodID fileMethod = env->GetMethodID(fileClass, "getAbsolutePath", "()Ljava/lang/String;");
@@ -38,7 +59,7 @@ static void setupExternalPath(struct android_app* state, MAIN_CLASS* app)
const char* str = env->GetStringUTFChars((jstring) pathString, NULL);
app->externalStoragePath = str;
app->externalCacheStoragePath = str;
app->externalCacheStoragePath = str;
LOGI("%s", str);
// ensure the process working directory is set to a writable location

View File

@@ -30,12 +30,33 @@ static void setupExternalPath(JNIEnv* env, MAIN_CLASS* app)
{
LOGI("Environment exists");
}
jclass clazz = env->FindClass("android/os/Environment");
jmethodID method = env->GetStaticMethodID(clazz, "getExternalStorageDirectory", "()Ljava/io/File;");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
// try appspecific external directory first
jobject activity = g_pActivity;
jclass activityClass = env->GetObjectClass(activity);
jmethodID getExternalFilesDir = env->GetMethodID(activityClass, "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;");
jobject file = NULL;
if (getExternalFilesDir != NULL) {
file = env->CallObjectMethod(activity, getExternalFilesDir, NULL);
}
if (file == NULL) {
// Fallback to the legacy shared storage directory
jclass clazz = env->FindClass("android/os/Environment");
jmethodID method = env->GetStaticMethodID(clazz, "getExternalStorageDirectory", "()Ljava/io/File;");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
}
file = env->CallStaticObjectMethod(clazz, method);
}
if (!file) {
LOGI("Failed to get external storage file object, using current working dir");
app->externalStoragePath = ".";
app->externalCacheStoragePath = ".";
return;
}
jobject file = env->CallStaticObjectMethod(clazz, method);
jclass fileClass = env->GetObjectClass(file);
jmethodID fileMethod = env->GetMethodID(fileClass, "getAbsolutePath", "()Ljava/lang/String;");
@@ -43,7 +64,7 @@ static void setupExternalPath(JNIEnv* env, MAIN_CLASS* app)
const char* str = env->GetStringUTFChars((jstring) pathString, NULL);
app->externalStoragePath = str;
app->externalCacheStoragePath = str;
app->externalCacheStoragePath = str;
LOGI("%s", str);
// same fix as the native entry point: make sure cwd is writable

View File

@@ -166,7 +166,7 @@ int main(void) {
AppPlatform_glfw* platform = (AppPlatform_glfw*)appContext.platform;
platform->window = glfwCreateWindow(appContext.platform->getScreenWidth(), appContext.platform->getScreenHeight(), "main", NULL, NULL);
platform->window = glfwCreateWindow(appContext.platform->getScreenWidth(), appContext.platform->getScreenHeight(), "Minecraft PE 0.6.1", NULL, NULL);
if (platform->window == NULL) {
return 1;
@@ -205,16 +205,16 @@ int main(void) {
delete app;
appContext.platform->finish();
delete appContext.platform;
#ifndef STANDALONE_SERVER
// Exit.
glfwDestroyWindow(platform->window);
glfwTerminate();
#endif
appContext.platform->finish();
delete appContext.platform;
return 0;
}

View File

@@ -14,7 +14,7 @@
#include <windows.h>
#include <windowsx.h>
#include <WinSock2.h>
#include <winsock2.h>
#include <process.h>
#include "SharedConstants.h"

View File

@@ -5,7 +5,7 @@
#include <vector>
#ifdef WIN32
#include <WinSock2.h>
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>

View File

@@ -140,7 +140,9 @@ RakNet::TimeUS GetTimeUS_Windows( void )
#if _MSC_VER >= 1400 && defined (_M_X64)
GetProcessAffinityMask(mProc, (PDWORD_PTR)&mProcMask, (PDWORD_PTR)&mSysMask);
#else
#ifndef __MINGW32__
GetProcessAffinityMask(mProc, &mProcMask, &mSysMask);
#endif
#endif
mThread = GetCurrentThread();

View File

@@ -1,8 +1,8 @@
#if defined(X360__)
#elif defined (_WIN32)
#include <WinSock2.h>
#include <winsock2.h>
#include <windows.h>
#include <Ws2tcpip.h>
#include <ws2tcpip.h>
// Must always include Winsock2.h before windows.h
// or else:

View File

@@ -7,6 +7,7 @@
#include "../chunk/LevelChunk.h"
#include "../Level.h"
#include "../LevelConstants.h"
#include "platform/log.h"
#include "../tile/TreeTile.h"
#include "../../entity/EntityFactory.h"
#include "../../../nbt/NbtIo.h"
@@ -289,8 +290,9 @@ bool ExternalFileLevelStorage::readPlayerData(const std::string& filename, Level
void ExternalFileLevelStorage::tick()
{
tickCount++;
if ((tickCount % 50) == 0 && level)
{
if ((tickCount % 1000) == 0 && level) {
LOGI("Saving level...\n");
// look for chunks that needs to be saved
for (int z = 0; z < CHUNK_CACHE_WIDTH; z++)
{