Compare commits
42 Commits
5d415dcca1
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 6bfae5a14e | |||
| 4034cf243d | |||
| b6e7414f04 | |||
|
|
83f3284827 | ||
|
|
3dab395af3 | ||
|
|
011c8f7123 | ||
|
|
f69c009da9 | ||
|
|
b66b4a2dc2 | ||
|
|
7037b2b5f2 | ||
|
|
d54e39b332 | ||
|
|
f96ba8bb33 | ||
|
|
f0e1980f59 | ||
| 52f607b126 | |||
|
|
84a956531c | ||
|
|
c4f5f22f24 | ||
|
|
7867aea042 | ||
|
|
a90e1463ee | ||
|
|
59e820e27f | ||
|
|
1199f53632 | ||
|
|
dc0e2c192b | ||
|
|
6ef9efa434 | ||
|
|
72e6537dc5 | ||
|
|
0e2e7694d3 | ||
| 45f04ca07b | |||
| 42e7a3da90 | |||
| 0edee15930 | |||
| 753fdbe701 | |||
| ac60559a22 | |||
|
|
be6fa57a10 | ||
|
|
68f5bc3a0a | ||
|
|
0a24a51663 | ||
|
|
96b17e9c8a | ||
|
|
c08c4d270d | ||
|
|
8cd74922bf | ||
|
|
b2707cc35d | ||
|
|
1ff91505d8 | ||
|
|
b909f3c576 | ||
|
|
8d1c4f1c4e | ||
|
|
bc5cbe6b73 | ||
|
|
cda2534c1e | ||
| c54bdfdcff | |||
| d5b2c59ebf |
17
.github/actions/setup-ninja/action.yml
vendored
Normal file
17
.github/actions/setup-ninja/action.yml
vendored
Normal 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
|
||||||
60
.github/workflows/build.yml
vendored
60
.github/workflows/build.yml
vendored
@@ -19,7 +19,7 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
build-windows:
|
build-windows:
|
||||||
name: Windows Build
|
name: Windows Build
|
||||||
runs-on: windows-latest
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -27,34 +27,51 @@ jobs:
|
|||||||
- name: Setup caches
|
- name: Setup caches
|
||||||
uses: ./.github/actions/setup-cache
|
uses: ./.github/actions/setup-cache
|
||||||
with:
|
with:
|
||||||
host: win
|
host: linux
|
||||||
target: win
|
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
|
- name: Create Build Environment
|
||||||
# Some projects don't allow in-source building, so create a separate build directory
|
# 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
|
# We'll use this as our working directory for all subsequent commands
|
||||||
run: cmake -E make_directory ${{github.workspace}}/build
|
run: cmake -E make_directory ${{github.workspace}}/build
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
shell: powershell
|
|
||||||
working-directory: ${{github.workspace}}/build
|
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
|
- name: Build
|
||||||
working-directory: ${{github.workspace}}/build
|
working-directory: ${{github.workspace}}/build
|
||||||
shell: powershell
|
run: cmake --build . --config $BUILD_TYPE --target MinecraftPE --parallel
|
||||||
run: cmake --build . --config $env:BUILD_TYPE --target MinecraftPE
|
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: mcpe-windows
|
name: mcpe-windows
|
||||||
path: |
|
path: |
|
||||||
${{github.workspace}}/build/${{ env.BUILD_TYPE }}/MinecraftPE.exe
|
${{github.workspace}}/build/MinecraftPE.exe
|
||||||
${{github.workspace}}/build/${{ env.BUILD_TYPE }}/glfw3.dll
|
${{github.workspace}}/build/glfw3.dll
|
||||||
${{github.workspace}}/build/${{ env.BUILD_TYPE }}/libpng16.dll
|
${{github.workspace}}/build/libpng16.dll
|
||||||
${{github.workspace}}/build/${{ env.BUILD_TYPE }}/OpenAL32.dll
|
${{github.workspace}}/build/OpenAL32.dll
|
||||||
${{github.workspace}}/build/${{ env.BUILD_TYPE }}/z.dll
|
${{github.workspace}}/build/z.dll
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
name: Linux Build
|
name: Linux Build
|
||||||
@@ -90,7 +107,9 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
working-directory: ${{github.workspace}}/build
|
working-directory: ${{github.workspace}}/build
|
||||||
shell: bash
|
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
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@@ -112,11 +131,10 @@ jobs:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
ANDROID_SDK_ROOT: ${{ github.workspace }}/android-sdk
|
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_PLATFORM_API: 36
|
||||||
ANDROID_BUILD_TOOLS_VERSION: 36.0.0
|
ANDROID_BUILD_TOOLS_VERSION: 36.0.0
|
||||||
ADB: /bin/true
|
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
|
# build.sh reads MATRIX_ABI to decide which ABI to build when no --abi flag is passed
|
||||||
MATRIX_ABI: ${{ matrix.abi }}
|
MATRIX_ABI: ${{ matrix.abi }}
|
||||||
|
|
||||||
@@ -125,12 +143,14 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Cache Android command-line tools
|
- name: Cache Android command-line tools
|
||||||
|
id: cache-android-tools
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ github.workspace }}/android-sdk/cmdline-tools
|
path: ${{ env.ANDROID_SDK_ROOT }}
|
||||||
key: android-cmdline-tools-v36
|
key: android-cmdline-tools-v36
|
||||||
|
|
||||||
- name: Setup Android command line tools
|
- name: Setup Android command line tools
|
||||||
|
if: steps.cache-android-tools.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
if [ ! -d "$ANDROID_SDK_ROOT/cmdline-tools/latest" ]; then
|
if [ ! -d "$ANDROID_SDK_ROOT/cmdline-tools/latest" ]; then
|
||||||
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
|
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
|
||||||
@@ -140,19 +160,21 @@ jobs:
|
|||||||
fi
|
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}"
|
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
|
- name: Cache Android NDK r14b
|
||||||
|
id: cache-android-ndk
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ github.workspace }}/android-ndk-r14b
|
path: ${{ github.workspace }}/android-ndk-r14b
|
||||||
key: android-ndk-r14b
|
key: android-ndk-r14b
|
||||||
|
|
||||||
- name: Install Android NDK r14b
|
- name: Install Android NDK r14b
|
||||||
|
if: steps.cache-android-ndk.outputs.cache-hit != 'true'
|
||||||
run: |
|
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"
|
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"
|
unzip -q ndk.zip -d "$GITHUB_WORKSPACE"
|
||||||
fi
|
fi
|
||||||
echo "ANDROID_NDK_PATH=$GITHUB_WORKSPACE/android-ndk-r14b" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Install system prerequisites
|
- name: Install system prerequisites
|
||||||
run: |
|
run: |
|
||||||
@@ -214,13 +236,13 @@ jobs:
|
|||||||
- name: Zip Windows Artifacts
|
- name: Zip Windows Artifacts
|
||||||
uses: vimtor/action-zip@v1.2
|
uses: vimtor/action-zip@v1.2
|
||||||
with:
|
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
|
dest: minecraftpe-${{ steps.ref.outputs.hash }}-windows.zip
|
||||||
|
|
||||||
- name: Zip Linux Artifacts
|
- name: Zip Linux Artifacts
|
||||||
uses: vimtor/action-zip@v1.2
|
uses: vimtor/action-zip@v1.2
|
||||||
with:
|
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
|
dest: minecraftpe-${{ steps.ref.outputs.hash }}-linux.zip
|
||||||
|
|
||||||
- name: Zip Linux Server Artifacts
|
- name: Zip Linux Server Artifacts
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,8 +9,6 @@ CMakeFiles/
|
|||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
Makefile
|
Makefile
|
||||||
*.cmake
|
|
||||||
!cmake/CPM.cmake
|
|
||||||
|
|
||||||
# Compiled object files
|
# Compiled object files
|
||||||
*.o
|
*.o
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ 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")
|
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ## Config options ###
|
|
||||||
include(CMakeDependentOption)
|
|
||||||
include(cmake/EnumOption.cmake)
|
include(cmake/EnumOption.cmake)
|
||||||
|
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
@@ -30,7 +28,8 @@ if (${PLATFORM} STREQUAL "Desktop")
|
|||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
set(EXTRA_LIBS ws2_32)
|
include_directories(misc/windows)
|
||||||
|
set(EXTRA_LIBS ws2_32 winhttp)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
find_library(pthread NAMES pthread)
|
find_library(pthread NAMES pthread)
|
||||||
set(EXTRA_LIBS pthread m)
|
set(EXTRA_LIBS pthread m)
|
||||||
@@ -102,6 +101,7 @@ CPMAddPackage(
|
|||||||
"ALSOFT_TESTS OFF"
|
"ALSOFT_TESTS OFF"
|
||||||
"ALSOFT_UTILS OFF"
|
"ALSOFT_UTILS OFF"
|
||||||
"LIBTYPE ${AL_LIBTYPE}"
|
"LIBTYPE ${AL_LIBTYPE}"
|
||||||
|
"ALSOFT_ENABLE_MODULES OFF"
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: Clear this paths with *
|
# TODO: Clear this paths with *
|
||||||
@@ -363,7 +363,7 @@ endif()
|
|||||||
|
|
||||||
# Client
|
# Client
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
|
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)
|
if (OpenSSL_FOUND)
|
||||||
target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
|
target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -113,7 +113,7 @@ cmake --build .
|
|||||||
$HOME/Android/Sdk/cmdline-tools/bin/sdkmanager
|
$HOME/Android/Sdk/cmdline-tools/bin/sdkmanager
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!Note]
|
||||||
> `sdkmanager` expects the SDK to include a `cmdline-tools/latest/` folder.
|
> `sdkmanager` expects the SDK to include a `cmdline-tools/latest/` folder.
|
||||||
> If you only have `cmdline-tools/bin`, create the required layout:
|
> 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"
|
sdkmanager --install "platform-tools" "platforms;android-35" "build-tools;35.0.0"
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!Note]
|
||||||
> if you want build.sh to always find the SDK,
|
> 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:
|
> 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/`
|
7. Extract the archive to `/home/username/`, so that the final directory path is `/home/username/android-ndk-r14b/`
|
||||||
|
|
||||||
> [!WARNING]
|
> [!Warning]
|
||||||
> Make sure you don’t end up with a nested folder like `/home/username/android-ndk-r14b/android-ndk-r14b/`.
|
> Make sure you don’t end up with a nested folder like `/home/username/android-ndk-r14b/android-ndk-r14b/`.
|
||||||
|
|
||||||
8. Re run `build.sh`
|
8. Re run `build.sh`
|
||||||
|
|
||||||
## Web
|
## Web
|
||||||
1. Download and install **emsdk**: https://emscripten.org/docs/getting_started/downloads.html
|
1. Download and install **emsdk**: https://emscripten.org/docs/getting_started/downloads.html
|
||||||
> [!NOTE]
|
> [!Note]
|
||||||
> On arch linux you can use AUR:
|
> On arch linux you can use AUR:
|
||||||
> `yay -Sy emsdk`
|
> `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 .. -B . -G Ninja "-DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
|
||||||
cmake --build . --target MinecraftPE
|
cmake --build . --target MinecraftPE
|
||||||
```
|
```
|
||||||
> [!NOTE]
|
> [!Note]
|
||||||
> If you are using VSCode with CMake plugin, you can add Emscripten kit
|
> If you are using VSCode with CMake plugin, you can add Emscripten kit
|
||||||
> 1. Press Ctrl + Shift + P
|
> 1. Press Ctrl + Shift + P
|
||||||
> 2. Type `CMake: Edit User-Local CMake Kits` and hit Enter
|
> 2. Type `CMake: Edit User-Local CMake Kits` and hit Enter
|
||||||
|
|||||||
9
cmake/EnumOption.cmake
Normal file
9
cmake/EnumOption.cmake
Normal 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 |
@@ -152,6 +152,7 @@ options.group.graphics=Graphics
|
|||||||
options.group.tweaks=Tweaks
|
options.group.tweaks=Tweaks
|
||||||
options.allowSprint=Allow sprint
|
options.allowSprint=Allow sprint
|
||||||
options.barOnTop=HUD above inventory
|
options.barOnTop=HUD above inventory
|
||||||
|
options.rpiCursor=Show Raspberry PI cursor
|
||||||
options.autojump=Auto Jump
|
options.autojump=Auto Jump
|
||||||
options.thirdperson=Third Person
|
options.thirdperson=Third Person
|
||||||
options.servervisible=Server Visible
|
options.servervisible=Server Visible
|
||||||
@@ -181,9 +182,10 @@ options.graphics.fast=Fast
|
|||||||
options.guiScale=GUI Scale
|
options.guiScale=GUI Scale
|
||||||
options.guiScale.auto=Auto
|
options.guiScale.auto=Auto
|
||||||
options.guiScale.small=Small
|
options.guiScale.small=Small
|
||||||
options.guiScale.normal=Normal
|
options.guiScale.medium=Medium
|
||||||
options.guiScale.large=Large
|
options.guiScale.large=Large
|
||||||
options.guiScale.larger=Larger
|
options.guiScale.larger=Larger
|
||||||
|
options.guiScale.largest=Largest
|
||||||
options.advancedOpengl=Advanced OpenGL
|
options.advancedOpengl=Advanced OpenGL
|
||||||
options.renderClouds=Clouds
|
options.renderClouds=Clouds
|
||||||
options.farWarning1=A 64 bit Java installation is recommended
|
options.farWarning1=A 64 bit Java installation is recommended
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<!-- This is the platform API where NativeActivity was introduced. -->
|
<!-- This is the platform API where NativeActivity was introduced. -->
|
||||||
<uses-sdk android:minSdkVersion="19"
|
<uses-sdk android:minSdkVersion="19"
|
||||||
android:targetSdkVersion="36" />
|
android:targetSdkVersion="30" />
|
||||||
|
|
||||||
<!-- uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true"/ -->
|
<!-- uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true"/ -->
|
||||||
|
|
||||||
|
|||||||
@@ -168,9 +168,10 @@ options.graphics.fast=Fast
|
|||||||
options.guiScale=GUI Scale
|
options.guiScale=GUI Scale
|
||||||
options.guiScale.auto=Auto
|
options.guiScale.auto=Auto
|
||||||
options.guiScale.small=Small
|
options.guiScale.small=Small
|
||||||
options.guiScale.normal=Normal
|
options.guiScale.medium=Medium
|
||||||
options.guiScale.large=Large
|
options.guiScale.large=Large
|
||||||
options.guiScale.larger=Larger
|
options.guiScale.larger=Larger
|
||||||
|
options.guiScale.largest=Largest
|
||||||
options.advancedOpengl=Advanced OpenGL
|
options.advancedOpengl=Advanced OpenGL
|
||||||
options.renderClouds=Clouds
|
options.renderClouds=Clouds
|
||||||
options.farWarning1=A 64 bit Java installation is recommended
|
options.farWarning1=A 64 bit Java installation is recommended
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="19"
|
android:minSdkVersion="19"
|
||||||
android:targetSdkVersion="36"/>
|
android:targetSdkVersion="30"/>
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.touchscreen.multitouch"
|
android:name="android.hardware.touchscreen.multitouch"
|
||||||
|
|||||||
@@ -168,8 +168,10 @@ options.graphics.fast=Fast
|
|||||||
options.guiScale=GUI Scale
|
options.guiScale=GUI Scale
|
||||||
options.guiScale.auto=Auto
|
options.guiScale.auto=Auto
|
||||||
options.guiScale.small=Small
|
options.guiScale.small=Small
|
||||||
options.guiScale.normal=Normal
|
options.guiScale.medium=Medium
|
||||||
options.guiScale.large=Large
|
options.guiScale.large=Large
|
||||||
|
options.guiScale.larger=Larger
|
||||||
|
options.guiScale.largest=Largest
|
||||||
options.advancedOpengl=Advanced OpenGL
|
options.advancedOpengl=Advanced OpenGL
|
||||||
options.renderClouds=Clouds
|
options.renderClouds=Clouds
|
||||||
options.farWarning1=A 64 bit Java installation is recommended
|
options.farWarning1=A 64 bit Java installation is recommended
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public class MainActivity extends Activity {
|
|||||||
private static final int PERMISSION_REQUEST_CODE = 123;
|
private static final int PERMISSION_REQUEST_CODE = 123;
|
||||||
|
|
||||||
private GLView _glView;
|
private GLView _glView;
|
||||||
|
private boolean _nativeInitialized = false;
|
||||||
public float invScale = 1.0f;// / 1.5f;
|
public float invScale = 1.0f;// / 1.5f;
|
||||||
private int _screenWidth = 0;
|
private int _screenWidth = 0;
|
||||||
private int _screenHeight = 0;
|
private int _screenHeight = 0;
|
||||||
@@ -77,63 +78,48 @@ public class MainActivity extends Activity {
|
|||||||
_screenWidth = Math.max(_dm.widthPixels, _dm.heightPixels);
|
_screenWidth = Math.max(_dm.widthPixels, _dm.heightPixels);
|
||||||
_screenHeight = Math.min(_dm.widthPixels, _dm.heightPixels);
|
_screenHeight = Math.min(_dm.widthPixels, _dm.heightPixels);
|
||||||
|
|
||||||
nativeOnCreate(_screenWidth, _screenHeight);
|
|
||||||
|
|
||||||
_glView = new GLView(getApplication(), this);
|
_glView = new GLView(getApplication(), this);
|
||||||
//_glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
|
//_glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
|
||||||
|
|
||||||
_glView.setEGLConfigChooser(true);
|
_glView.setEGLConfigChooser(true);
|
||||||
//_glView
|
//_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();
|
_glView.commit();
|
||||||
setContentView(_glView);
|
setContentView(_glView);
|
||||||
|
|
||||||
_soundPlayer = new SoundPlayer(this, AudioManager.STREAM_MUSIC);
|
_soundPlayer = new SoundPlayer(this, AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
// request dangerous permissions at runtime if necessary
|
|
||||||
checkAndRequestPermissions();
|
checkAndRequestPermissions();
|
||||||
|
initNative();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndRequestPermissions() {
|
private void initNative() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (_nativeInitialized) {
|
||||||
boolean needRequest = false;
|
return;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
_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
|
@Override
|
||||||
@@ -146,8 +132,18 @@ public class MainActivity extends Activity {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!granted) {
|
if (granted) {
|
||||||
// user denied; you might want to warn or close the app
|
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);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#if defined(X360__)
|
#if defined(X360__)
|
||||||
#elif defined (_WIN32)
|
#elif defined (_WIN32)
|
||||||
#include <WinSock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
// Must always include Winsock2.h before windows.h
|
// Must always include Winsock2.h before windows.h
|
||||||
// or else:
|
// or else:
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ public:
|
|||||||
virtual TextureData loadTextureFromMemory(const unsigned char* data, size_t size) { return TextureData(); }
|
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 playSound(const std::string& fn, float volume, float pitch) {}
|
||||||
|
|
||||||
|
virtual void hideCursor(bool hide) {}
|
||||||
|
|
||||||
virtual void showDialog(int dialogId) {}
|
virtual void showDialog(int dialogId) {}
|
||||||
virtual void createUserInput() {}
|
virtual void createUserInput() {}
|
||||||
|
|||||||
@@ -73,50 +73,20 @@ public:
|
|||||||
: filename_;
|
: filename_;
|
||||||
std::ifstream source(filename.c_str(), std::ios::binary);
|
std::ifstream source(filename.c_str(), std::ios::binary);
|
||||||
|
|
||||||
if (source) {
|
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
|
|
||||||
{
|
|
||||||
LOGI("Couldn't find file: %s\n", filename.c_str());
|
LOGI("Couldn't find file: %s\n", filename.c_str());
|
||||||
return out;
|
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 {
|
TextureData loadTextureFromMemory(const unsigned char* data, size_t size) override {
|
||||||
@@ -139,6 +109,11 @@ public:
|
|||||||
|
|
||||||
virtual bool supportsTouchscreen() override { return true; }
|
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 {
|
virtual void openURL(const std::string& url) override {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ void NinecraftApp::init()
|
|||||||
I18n::loadLanguage(platform(), "en_US");
|
I18n::loadLanguage(platform(), "en_US");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!externalStoragePath.empty()) {
|
||||||
|
options.setOptionsFilePath(externalStoragePath);
|
||||||
|
}
|
||||||
Minecraft::init();
|
Minecraft::init();
|
||||||
|
|
||||||
#if !defined(DEMO_MODE) && !defined(APPLE_DEMO_PROMOTION) && !defined(NO_STORAGE)
|
#if !defined(DEMO_MODE) && !defined(APPLE_DEMO_PROMOTION) && !defined(NO_STORAGE)
|
||||||
|
|||||||
@@ -1143,6 +1143,8 @@ void Minecraft::init()
|
|||||||
checkGlError("Init complete");
|
checkGlError("Init complete");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
options.load();
|
||||||
|
|
||||||
setIsCreativeMode(false); // false means it's Survival Mode
|
setIsCreativeMode(false); // false means it's Survival Mode
|
||||||
reloadOptions();
|
reloadOptions();
|
||||||
}
|
}
|
||||||
@@ -1158,12 +1160,13 @@ void Minecraft::setSize(int w, int h) {
|
|||||||
|
|
||||||
// determine gui scale, optionally overriding auto
|
// determine gui scale, optionally overriding auto
|
||||||
if (guiScale != 0) {
|
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) {
|
switch (guiScale) {
|
||||||
case 1: Gui::GuiScale = 2.0f; break;
|
case 1: Gui::GuiScale = 2.0f; break;
|
||||||
case 2: Gui::GuiScale = 3.0f; break;
|
case 2: Gui::GuiScale = 3.0f; break;
|
||||||
case 3: Gui::GuiScale = 4.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
|
default: Gui::GuiScale = 1.0f; break; // auto
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ OptionBool fixedCamera("fixedCamera", false);
|
|||||||
OptionBool isFlying("isflying", false);
|
OptionBool isFlying("isflying", false);
|
||||||
OptionBool barOnTop("barOnTop", false);
|
OptionBool barOnTop("barOnTop", false);
|
||||||
OptionBool allowSprint("allowSprint", true);
|
OptionBool allowSprint("allowSprint", true);
|
||||||
|
OptionBool rpiCursor("rpiCursor", false);
|
||||||
OptionBool autoJump("autoJump", true);
|
OptionBool autoJump("autoJump", true);
|
||||||
|
|
||||||
|
|
||||||
@@ -158,6 +159,7 @@ void Options::initTable() {
|
|||||||
|
|
||||||
m_options[OPTIONS_BAR_ON_TOP] = &barOnTop;
|
m_options[OPTIONS_BAR_ON_TOP] = &barOnTop;
|
||||||
m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint;
|
m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint;
|
||||||
|
m_options[OPTIONS_RPI_CURSOR] = &rpiCursor;
|
||||||
|
|
||||||
m_options[OPTIONS_AUTOJUMP] = &autoJump;
|
m_options[OPTIONS_AUTOJUMP] = &autoJump;
|
||||||
m_options[OPTIONS_LAST_IP] = &lastIp;
|
m_options[OPTIONS_LAST_IP] = &lastIp;
|
||||||
@@ -283,6 +285,10 @@ void Options::save() {
|
|||||||
optionsFile.save(stringVec);
|
optionsFile.save(stringVec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Options::setOptionsFilePath(const std::string& path) {
|
||||||
|
optionsFile.setOptionsPath(path + "/options.txt");
|
||||||
|
}
|
||||||
|
|
||||||
void Options::notifyOptionUpdate(OptionId key, bool value) {
|
void Options::notifyOptionUpdate(OptionId key, bool value) {
|
||||||
minecraft->optionUpdated(key, value);
|
minecraft->optionUpdated(key, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ enum OptionId {
|
|||||||
OPTIONS_FIRST_LAUNCH,
|
OPTIONS_FIRST_LAUNCH,
|
||||||
OPTIONS_LAST_IP,
|
OPTIONS_LAST_IP,
|
||||||
|
|
||||||
|
OPTIONS_RPI_CURSOR,
|
||||||
// Should be last!
|
// Should be last!
|
||||||
OPTIONS_COUNT
|
OPTIONS_COUNT
|
||||||
};
|
};
|
||||||
@@ -100,15 +101,10 @@ public:
|
|||||||
// elements werent initialized so i was getting a garbage pointer and a crash
|
// elements werent initialized so i was getting a garbage pointer and a crash
|
||||||
m_options.fill(nullptr);
|
m_options.fill(nullptr);
|
||||||
initTable();
|
initTable();
|
||||||
load();
|
// load() is deferred to init() where path is configured correctly
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTable();
|
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);
|
|
||||||
|
|
||||||
int getIntValue(OptionId key) {
|
int getIntValue(OptionId key) {
|
||||||
auto option = opt<OptionInt>(key);
|
auto option = opt<OptionInt>(key);
|
||||||
@@ -144,6 +140,11 @@ public:
|
|||||||
|
|
||||||
void load();
|
void load();
|
||||||
void save();
|
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, bool value);
|
||||||
void notifyOptionUpdate(OptionId key, float value);
|
void notifyOptionUpdate(OptionId key, float value);
|
||||||
|
|||||||
@@ -4,6 +4,13 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <platform/log.h>
|
#include <platform/log.h>
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <direct.h>
|
||||||
|
#else
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
OptionsFile::OptionsFile() {
|
OptionsFile::OptionsFile() {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
settingsPath = "./Documents/options.txt";
|
settingsPath = "./Documents/options.txt";
|
||||||
@@ -14,18 +21,54 @@ OptionsFile::OptionsFile() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsFile::save(const StringVector& settings) {
|
void OptionsFile::setOptionsPath(const std::string& path) {
|
||||||
FILE* pFile = fopen(settingsPath.c_str(), "w");
|
settingsPath = path;
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 OptionsFile::getOptionStrings() {
|
||||||
StringVector returnVector;
|
StringVector returnVector;
|
||||||
FILE* pFile = fopen(settingsPath.c_str(), "r");
|
FILE* pFile = fopen(settingsPath.c_str(), "r");
|
||||||
@@ -46,7 +89,8 @@ StringVector OptionsFile::getOptionStrings() {
|
|||||||
}
|
}
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
} else {
|
} 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;
|
return returnVector;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ public:
|
|||||||
OptionsFile();
|
OptionsFile();
|
||||||
void save(const StringVector& settings);
|
void save(const StringVector& settings);
|
||||||
StringVector getOptionStrings();
|
StringVector getOptionStrings();
|
||||||
|
void setOptionsPath(const std::string& path);
|
||||||
|
std::string getOptionsPath() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string settingsPath;
|
std::string settingsPath;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ void Font::draw( const std::string& str, float x, float y, int color, bool darke
|
|||||||
glPushMatrix2();
|
glPushMatrix2();
|
||||||
glTranslatef2((GLfloat)x, (GLfloat)y, 0.0f);
|
glTranslatef2((GLfloat)x, (GLfloat)y, 0.0f);
|
||||||
for (unsigned int i = 0; i < str.length(); i++) {
|
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]));
|
int cc = hex.find((char)tolower(str[i + 1]));
|
||||||
if (cc < 0 || cc > 15) cc = 15;
|
if (cc < 0 || cc > 15) cc = 15;
|
||||||
lists[index++] = listPos + 256 + cc + (darken ? 16 : 0);
|
lists[index++] = listPos + 256 + cc + (darken ? 16 : 0);
|
||||||
@@ -235,7 +235,7 @@ int Font::width( const std::string& str )
|
|||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < str.length(); i++) {
|
for (unsigned int i = 0; i < str.length(); i++) {
|
||||||
if (str[i] == '§') {
|
if (str[i] == '\xa7') {
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
//int ch = SharedConstants.acceptableLetters.indexOf(str.charAt(i));
|
//int ch = SharedConstants.acceptableLetters.indexOf(str.charAt(i));
|
||||||
@@ -274,7 +274,7 @@ std::string Font::sanitize( const std::string& str )
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < str.length(); i++) {
|
for (unsigned int i = 0; i < str.length(); i++) {
|
||||||
if (str[i] == '§') {
|
if (str[i] == '\xa7') {
|
||||||
i++;
|
i++;
|
||||||
//} else if (SharedConstants.acceptableLetters.indexOf(str.charAt(i)) >= 0) {
|
//} else if (SharedConstants.acceptableLetters.indexOf(str.charAt(i)) >= 0) {
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
|||||||
|
|
||||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
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);
|
addChild(item);
|
||||||
setupPositions();
|
setupPositions();
|
||||||
@@ -77,7 +77,7 @@ void OptionsGroup::createProgressSlider(OptionId optId, Minecraft* minecraft ) {
|
|||||||
element->height = 20;
|
element->height = 20;
|
||||||
|
|
||||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
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);
|
addChild(item);
|
||||||
setupPositions();
|
setupPositions();
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ void OptionsGroup::createStepSlider(OptionId optId, Minecraft* minecraft ) {
|
|||||||
element->width = 100;
|
element->width = 100;
|
||||||
element->height = 20;
|
element->height = 20;
|
||||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
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);
|
addChild(item);
|
||||||
setupPositions();
|
setupPositions();
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ void OptionsGroup::createTextbox(OptionId optId, Minecraft* minecraft) {
|
|||||||
element->height = 20;
|
element->height = 20;
|
||||||
|
|
||||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
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);
|
addChild(item);
|
||||||
setupPositions();
|
setupPositions();
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ void OptionsGroup::createKey(OptionId optId, Minecraft* minecraft) {
|
|||||||
element->height = 20;
|
element->height = 20;
|
||||||
|
|
||||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
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);
|
addChild(item);
|
||||||
setupPositions();
|
setupPositions();
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
#include "OptionsItem.h"
|
#include "OptionsItem.h"
|
||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
|
#include "../../../locale/I18n.h"
|
||||||
#include "../../../util/Mth.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),
|
: GuiElementContainer(false, true, 0, 0, 24, 12),
|
||||||
label(label) {
|
m_optionId(optionId),
|
||||||
|
m_label(label) {
|
||||||
addChild(element);
|
addChild(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,6 +21,22 @@ void OptionsItem::setupPositions() {
|
|||||||
|
|
||||||
void OptionsItem::render( Minecraft* minecraft, int xm, int ym ) {
|
void OptionsItem::render( Minecraft* minecraft, int xm, int ym ) {
|
||||||
int yOffset = (height - 8) / 2;
|
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);
|
super::render(minecraft, xm, ym);
|
||||||
}
|
}
|
||||||
@@ -15,12 +15,13 @@ class OptionsItem: public GuiElementContainer
|
|||||||
{
|
{
|
||||||
typedef GuiElementContainer super;
|
typedef GuiElementContainer super;
|
||||||
public:
|
public:
|
||||||
OptionsItem(std::string label, GuiElement* element);
|
OptionsItem(OptionId optionId, std::string label, GuiElement* element);
|
||||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||||
void setupPositions();
|
void setupPositions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string label;
|
OptionId m_optionId;
|
||||||
|
std::string m_label;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsItem_H__*/
|
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsItem_H__*/
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
#include "../../renderer/Textures.h"
|
#include "../../renderer/Textures.h"
|
||||||
#include "../Screen.h"
|
#include "../Screen.h"
|
||||||
|
#include "../../../locale/I18n.h"
|
||||||
#include "../../../util/Mth.h"
|
#include "../../../util/Mth.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -21,7 +22,7 @@ void Slider::render( Minecraft* minecraft, int xm, int ym ) {
|
|||||||
|
|
||||||
if (m_numSteps > 2) {
|
if (m_numSteps > 2) {
|
||||||
int stepDistance = barWidth / (m_numSteps-1);
|
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;
|
int renderSliderStepPosX = xSliderStart + a * stepDistance + 1;
|
||||||
fill(renderSliderStepPosX - 1, ySliderStart - 2, renderSliderStepPosX + 1, ySliderEnd + 2, 0xff606060);
|
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)
|
SliderInt::SliderInt(Minecraft* minecraft, OptionId option)
|
||||||
: Slider(option), m_option(dynamic_cast<OptionInt*>(minecraft->options.getOpt(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);
|
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 ) {
|
void SliderInt::mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
||||||
Slider::mouseReleased(minecraft, x, y, buttonNum);
|
Slider::mouseReleased(minecraft, x, y, buttonNum);
|
||||||
|
|
||||||
if (pointInside(x, y)) {
|
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);
|
m_percentage = float(curStep - m_option->getMin()) / (m_numSteps-1);
|
||||||
|
|
||||||
minecraft->options.set(m_optId, curStep);
|
minecraft->options.set(m_optId, curStep);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class SliderInt : public Slider {
|
|||||||
public:
|
public:
|
||||||
SliderInt(Minecraft* minecraft, OptionId option);
|
SliderInt(Minecraft* minecraft, OptionId option);
|
||||||
|
|
||||||
|
virtual void render( Minecraft* minecraft, int xm, int ym ) override;
|
||||||
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
|
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -216,8 +216,5 @@ void ConsoleScreen::render(int /*xm*/, int /*ym*/, float /*a*/)
|
|||||||
displayed += '_';
|
displayed += '_';
|
||||||
|
|
||||||
// Placeholder hint when empty
|
// Placeholder hint when empty
|
||||||
if (_input.empty() && (_cursorBlink / 10) % 2 != 0)
|
font->drawShadow(displayed, (float)(boxX0 + 2), (float)(boxY + 2), 0xffffffff);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,7 +225,8 @@ void OptionsScreen::generateOptionScreens() {
|
|||||||
.addOptionItem(OPTIONS_AMBIENT_OCCLUSION, minecraft);
|
.addOptionItem(OPTIONS_AMBIENT_OCCLUSION, minecraft);
|
||||||
|
|
||||||
optionPanes[4]->addOptionItem(OPTIONS_ALLOW_SPRINT, 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) {
|
void OptionsScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "JoinGameScreen.h"
|
#include "JoinGameScreen.h"
|
||||||
#include "PauseScreen.h"
|
#include "PauseScreen.h"
|
||||||
#include "RenameMPLevelScreen.h"
|
#include "RenameMPLevelScreen.h"
|
||||||
|
#include "ConsoleScreen.h"
|
||||||
#include "IngameBlockSelectionScreen.h"
|
#include "IngameBlockSelectionScreen.h"
|
||||||
#include "JoinByIPScreen.h"
|
#include "JoinByIPScreen.h"
|
||||||
#include "touch/TouchStartMenuScreen.h"
|
#include "touch/TouchStartMenuScreen.h"
|
||||||
@@ -19,6 +20,7 @@ Screen* ScreenChooser::createScreen( ScreenId id )
|
|||||||
{
|
{
|
||||||
Screen* screen = NULL;
|
Screen* screen = NULL;
|
||||||
|
|
||||||
|
// :sob:
|
||||||
if (_mc->useTouchscreen()) {
|
if (_mc->useTouchscreen()) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case SCREEN_STARTMENU: screen = new Touch::StartMenuScreen(); break;
|
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_PAUSEPREV: screen = new PauseScreen(true); break;
|
||||||
case SCREEN_BLOCKSELECTION: screen = new Touch::IngameBlockSelectionScreen(); break;
|
case SCREEN_BLOCKSELECTION: screen = new Touch::IngameBlockSelectionScreen(); break;
|
||||||
case SCREEN_JOINBYIP: screen = new JoinByIPScreen(); break;
|
case SCREEN_JOINBYIP: screen = new JoinByIPScreen(); break;
|
||||||
|
case SCREEN_CONSOLE: screen = new ConsoleScreen(); break;
|
||||||
case SCREEN_NONE:
|
case SCREEN_NONE:
|
||||||
default:
|
default:
|
||||||
// Do nothing
|
// Do nothing
|
||||||
@@ -42,7 +45,7 @@ Screen* ScreenChooser::createScreen( ScreenId id )
|
|||||||
case SCREEN_PAUSEPREV: screen = new PauseScreen(true); break;
|
case SCREEN_PAUSEPREV: screen = new PauseScreen(true); break;
|
||||||
case SCREEN_BLOCKSELECTION: screen = new IngameBlockSelectionScreen(); break;
|
case SCREEN_BLOCKSELECTION: screen = new IngameBlockSelectionScreen(); break;
|
||||||
case SCREEN_JOINBYIP: screen = new JoinByIPScreen(); break;
|
case SCREEN_JOINBYIP: screen = new JoinByIPScreen(); break;
|
||||||
|
case SCREEN_CONSOLE: screen = new ConsoleScreen(); break;
|
||||||
case SCREEN_NONE:
|
case SCREEN_NONE:
|
||||||
default:
|
default:
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ enum ScreenId {
|
|||||||
SCREEN_PAUSEPREV,
|
SCREEN_PAUSEPREV,
|
||||||
SCREEN_SELECTWORLD,
|
SCREEN_SELECTWORLD,
|
||||||
SCREEN_BLOCKSELECTION,
|
SCREEN_BLOCKSELECTION,
|
||||||
SCREEN_JOINBYIP
|
SCREEN_JOINBYIP,
|
||||||
|
SCREEN_CONSOLE
|
||||||
};
|
};
|
||||||
|
|
||||||
class Screen;
|
class Screen;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -187,6 +188,33 @@ static bool ensureDirectoryExists(const std::string& path) {
|
|||||||
return _mkdir(path.c_str()) == 0 || errno == EEXIST;
|
return _mkdir(path.c_str()) == 0 || errno == EEXIST;
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
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))
|
if (stat(path.c_str(), &st) == 0 && S_ISDIR(st.st_mode))
|
||||||
return true;
|
return true;
|
||||||
return mkdir(path.c_str(), 0755) == 0 || errno == EEXIST;
|
return mkdir(path.c_str(), 0755) == 0 || errno == EEXIST;
|
||||||
@@ -236,7 +264,8 @@ static void* fetchSkinForPlayer(void* param) {
|
|||||||
std::vector<unsigned char> skinData;
|
std::vector<unsigned char> skinData;
|
||||||
if (!HttpClient::download(skinUrl, skinData) || skinData.empty()) {
|
if (!HttpClient::download(skinUrl, skinData) || skinData.empty()) {
|
||||||
LOGW("[Skin] download failed for %s\n", skinUrl.c_str());
|
LOGW("[Skin] download failed for %s\n", skinUrl.c_str());
|
||||||
return NULL;
|
player->setTextureName("mob/char.png");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save to cache
|
// Save to cache
|
||||||
|
|||||||
@@ -426,9 +426,7 @@ public:
|
|||||||
virtual void onConfigChanged(const Config& c) {
|
virtual void onConfigChanged(const Config& c) {
|
||||||
_move.onConfigChanged(c);
|
_move.onConfigChanged(c);
|
||||||
_turnBuild.moveArea = _move.getRectangleArea();
|
_turnBuild.moveArea = _move.getRectangleArea();
|
||||||
#ifdef __APPLE__
|
|
||||||
_turnBuild.pauseArea = _move.getPauseRectangleArea();
|
_turnBuild.pauseArea = _move.getPauseRectangleArea();
|
||||||
#endif
|
|
||||||
_turnBuild.inventoryArea = _mc->gui.getRectangleArea( _mc->options.getBooleanValue(OPTIONS_IS_LEFT_HANDED)? 1 : -1 );
|
_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);
|
_turnBuild.setSensitivity(c.options->getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)? 1.8f : 1.0f);
|
||||||
((ITurnInput*)&_turnBuild)->onConfigChanged(c);
|
((ITurnInput*)&_turnBuild)->onConfigChanged(c);
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
#include "../../../../platform/log.h"
|
#include "../../../../platform/log.h"
|
||||||
#include "../../../renderer/Textures.h"
|
#include "../../../renderer/Textures.h"
|
||||||
#include "../../../sound/SoundEngine.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_FIRST = 100;
|
||||||
static const int AREA_DPAD_N = 100;
|
static const int AREA_DPAD_N = 100;
|
||||||
static const int AREA_DPAD_S = 101;
|
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_E = 103;
|
||||||
static const int AREA_DPAD_C = 104;
|
static const int AREA_DPAD_C = 104;
|
||||||
static const int AREA_PAUSE = 105;
|
static const int AREA_PAUSE = 105;
|
||||||
|
static const int AREA_CHAT = 106;
|
||||||
|
|
||||||
static int cPressed = 0;
|
static int cPressed = 0;
|
||||||
static int cReleased = 0;
|
static int cReleased = 0;
|
||||||
@@ -158,14 +162,11 @@ void TouchscreenInput_TestFps::onConfigChanged(const Config& c) {
|
|||||||
xx = BaseX + 2 * Bw; yy = BaseY + Bh;
|
xx = BaseX + 2 * Bw; yy = BaseY + Bh;
|
||||||
_model.addArea(AREA_DPAD_E, aRight = new RectangleArea(xx, yy, xx+Bw, yy+Bh));
|
_model.addArea(AREA_DPAD_E, aRight = new RectangleArea(xx, yy, xx+Bw, yy+Bh));
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
float maxPixels = _minecraft->pixelCalc.millimetersToPixels(10);
|
float maxPixels = _minecraft->pixelCalc.millimetersToPixels(10);
|
||||||
float btnSize = Mth::Min(18 * Gui::GuiScale, maxPixels);
|
// float btnSize = Mth::Min(18 * Gui::GuiScale, maxPixels);
|
||||||
_model.addArea(AREA_PAUSE, aPause = new RectangleArea(w - 4 - btnSize,
|
float btnSize = pc.millimetersToPixels(50);
|
||||||
4,
|
_model.addArea(AREA_PAUSE, aPause = new RectangleArea(w - 4 - btnSize, 4, w - 4, 4 + btnSize));
|
||||||
w - 4,
|
_model.addArea(AREA_CHAT, aChat = new RectangleArea(w - 8 - btnSize * 2, 4, w - 8 - btnSize, 4 + btnSize));
|
||||||
4 + btnSize));
|
|
||||||
#endif /* __APPLE__ */
|
|
||||||
|
|
||||||
//rebuild();
|
//rebuild();
|
||||||
}
|
}
|
||||||
@@ -309,14 +310,19 @@ void TouchscreenInput_TestFps::tick( Player* player )
|
|||||||
setButton = true;
|
setButton = true;
|
||||||
xa -= 1;
|
xa -= 1;
|
||||||
}
|
}
|
||||||
#ifdef __APPLE__
|
|
||||||
else if (areaId == AREA_PAUSE) {
|
else if (areaId == AREA_PAUSE) {
|
||||||
if (Multitouch::isReleased(p)) {
|
if (Multitouch::isReleased(p)) {
|
||||||
_minecraft->soundEngine->playUI("random.click", 1, 1);
|
_minecraft->soundEngine->playUI("random.click", 1, 1);
|
||||||
_minecraft->screenChooser.setScreen(SCREEN_PAUSE);
|
_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;
|
_buttons[areaId - AREA_DPAD_FIRST] = setButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,15 +505,14 @@ void TouchscreenInput_TestFps::rebuild() {
|
|||||||
drawRectangleArea(t, aJump, imageU + imageSize * 4, imageV, (float)imageSize);
|
drawRectangleArea(t, aJump, imageU + imageSize * 4, imageV, (float)imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
if (!_minecraft->screen) {
|
if (!_minecraft->screen) {
|
||||||
if (isButtonDown(AREA_PAUSE)) t.colorABGR(cPressedPause);
|
t.colorABGR(0xFFFFFFFF);
|
||||||
else t.colorABGR(cReleasedPause);
|
// if (isButtonDown(AREA_PAUSE)) t.colorABGR(cPressedPause);
|
||||||
|
// else t.colorABGR(cReleasedPause);
|
||||||
|
|
||||||
drawRectangleArea(t, aPause, 200, 64, 18.0f);
|
drawRectangleArea(t, aPause, 200, 64, 18.0f);
|
||||||
|
drawRectangleArea(t, aChat, 200, 82, 18.0f);
|
||||||
}
|
}
|
||||||
#endif /*__APPLE__*/
|
|
||||||
//t.end(true, _bufferId);
|
//t.end(true, _bufferId);
|
||||||
//return;
|
//return;
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ private:
|
|||||||
RectangleArea* aUp;
|
RectangleArea* aUp;
|
||||||
RectangleArea* aDown;
|
RectangleArea* aDown;
|
||||||
RectangleArea* aPause;
|
RectangleArea* aPause;
|
||||||
|
RectangleArea* aChat;
|
||||||
//RectangleArea* aUpJump;
|
//RectangleArea* aUpJump;
|
||||||
RectangleArea* aJump;
|
RectangleArea* aJump;
|
||||||
RectangleArea* aUpLeft;
|
RectangleArea* aUpLeft;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "GameRenderer.h"
|
#include "GameRenderer.h"
|
||||||
|
#include "client/Options.h"
|
||||||
#include "gles.h"
|
#include "gles.h"
|
||||||
|
|
||||||
#include "../../util/PerfTimer.h"
|
#include "../../util/PerfTimer.h"
|
||||||
@@ -214,12 +215,14 @@ void GameRenderer::render(float a) {
|
|||||||
glDisable2(GL_SCISSOR_TEST);
|
glDisable2(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
mc->screen->render(xMouse, yMouse, a);
|
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);
|
renderCursor(xMouse, yMouse, mc);
|
||||||
#endif
|
|
||||||
// Screen might have been removed, so check it again
|
// Screen might have been removed, so check it again
|
||||||
if (mc->screen && !mc->screen->isInGameScreen())
|
if (mc->screen && !mc->screen->isInGameScreen())
|
||||||
sleepMs(15);
|
sleepMs(15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,13 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void additionalRendering(Mob* mob, float a);
|
void additionalRendering(Mob* mob, float a);
|
||||||
|
|
||||||
private:
|
|
||||||
HumanoidModel* humanoidModel;
|
HumanoidModel* humanoidModel;
|
||||||
|
|
||||||
// Last rotation values for cape smoothing (reduces jitter)
|
// Last rotation values for cape smoothing (reduces jitter)
|
||||||
float lastCapeXRot;
|
float lastCapeXRot;
|
||||||
float lastCapeZRot;
|
float lastCapeZRot;
|
||||||
|
private:
|
||||||
|
// i guess ill keep this just in case seomthing breaks
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*NET_MINECRAFT_CLIENT_RENDERER_ENTITY__HumanoidMobRenderer_H__*/
|
#endif /*NET_MINECRAFT_CLIENT_RENDERER_ENTITY__HumanoidMobRenderer_H__*/
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void setArmor(Model* armor);
|
void setArmor(Model* armor);
|
||||||
Model* getArmor();
|
Model* getArmor();
|
||||||
|
Model* model; // allows derived renderers to swap models dynamically for skin formats
|
||||||
private:
|
private:
|
||||||
Model* model;
|
|
||||||
Model* armor;
|
Model* armor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "PlayerRenderer.h"
|
#include "PlayerRenderer.h"
|
||||||
#include "EntityRenderDispatcher.h"
|
#include "EntityRenderDispatcher.h"
|
||||||
|
#include "../Textures.h"
|
||||||
#include "../../../world/entity/player/Player.h"
|
#include "../../../world/entity/player/Player.h"
|
||||||
#include "../../../world/level/Level.h"
|
#include "../../../world/level/Level.h"
|
||||||
#include "../../../world/item/ArmorItem.h"
|
#include "../../../world/item/ArmorItem.h"
|
||||||
@@ -14,12 +15,22 @@ static const std::string armorFilenames[10] = {
|
|||||||
|
|
||||||
PlayerRenderer::PlayerRenderer( HumanoidModel* humanoidModel, float shadow )
|
PlayerRenderer::PlayerRenderer( HumanoidModel* humanoidModel, float shadow )
|
||||||
: super(humanoidModel, shadow),
|
: super(humanoidModel, shadow),
|
||||||
|
playerModel64(humanoidModel),
|
||||||
|
playerModel32(new HumanoidModel(0, 0, 64, 32)),
|
||||||
armorParts1(new HumanoidModel(1.0f, 0, 64, 64)),
|
armorParts1(new HumanoidModel(1.0f, 0, 64, 64)),
|
||||||
armorParts2(new HumanoidModel(0.5f, 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() {
|
PlayerRenderer::~PlayerRenderer() {
|
||||||
|
// prevent MobRenderer destructor from deleting model pointers we manage manually
|
||||||
|
model = nullptr;
|
||||||
|
|
||||||
|
delete playerModel32;
|
||||||
|
delete playerModel64;
|
||||||
delete armorParts1;
|
delete armorParts1;
|
||||||
delete armorParts2;
|
delete armorParts2;
|
||||||
}
|
}
|
||||||
@@ -43,6 +54,15 @@ void PlayerRenderer::setupRotations( Entity* mob, float bob, float bodyRot, floa
|
|||||||
super::setupRotations(mob, bob, bodyRot, a);
|
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 ){
|
void PlayerRenderer::renderName( Mob* mob, float x, float y, float z ){
|
||||||
//@todo: figure out how to handle HideGUI
|
//@todo: figure out how to handle HideGUI
|
||||||
if (mob != entityRenderDispatcher->cameraEntity && mob->level->adventureSettings.showNameTags) {
|
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) {
|
int PlayerRenderer::prepareArmor(Mob* mob, int layer, float a) {
|
||||||
Player* player = (Player*) mob;
|
Player* player = (Player*) mob;
|
||||||
|
|
||||||
@@ -80,8 +114,11 @@ int PlayerRenderer::prepareArmor(Mob* mob, int layer, float a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlayerRenderer::onGraphicsReset() {
|
void PlayerRenderer::onGraphicsReset() {
|
||||||
super::onGraphicsReset();
|
if (playerModel32) playerModel32->onGraphicsReset();
|
||||||
|
if (playerModel64) playerModel64->onGraphicsReset();
|
||||||
|
|
||||||
if (armorParts1) armorParts1->onGraphicsReset();
|
if (armorParts1) armorParts1->onGraphicsReset();
|
||||||
if (armorParts2) armorParts2->onGraphicsReset();
|
if (armorParts2) armorParts2->onGraphicsReset();
|
||||||
|
|
||||||
|
super::onGraphicsReset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ public:
|
|||||||
~PlayerRenderer();
|
~PlayerRenderer();
|
||||||
|
|
||||||
virtual int prepareArmor(Mob* mob, int layer, float a);
|
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 setupPosition(Entity* mob, float x, float y, float z);
|
||||||
virtual void setupRotations(Entity* mob, float bob, float bodyRot, float a);
|
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 renderName(Mob* mob, float x, float y, float z);
|
||||||
virtual void onGraphicsReset();
|
virtual void onGraphicsReset();
|
||||||
private:
|
private:
|
||||||
|
HumanoidModel* playerModel32;
|
||||||
|
HumanoidModel* playerModel64;
|
||||||
HumanoidModel* armorParts1;
|
HumanoidModel* armorParts1;
|
||||||
HumanoidModel* armorParts2;
|
HumanoidModel* armorParts2;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
// #else
|
// #else
|
||||||
// // Uglyness to fix redeclaration issues
|
// // Uglyness to fix redeclaration issues
|
||||||
// #ifdef WIN32
|
// #ifdef WIN32
|
||||||
// #include <WinSock2.h>
|
// #include <winsock2.h>
|
||||||
// #include <Windows.h>
|
// #include <Windows.h>
|
||||||
// #endif
|
// #endif
|
||||||
// #include <gl/glew.h>
|
// #include <gl/glew.h>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef PLATFORM_DESKTOP
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||||
#include "main_glfw.h"
|
#include "main_glfw.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -25,12 +25,33 @@ static void setupExternalPath(struct android_app* state, MAIN_CLASS* app)
|
|||||||
{
|
{
|
||||||
LOGI("Environment exists");
|
LOGI("Environment exists");
|
||||||
}
|
}
|
||||||
jclass clazz = env->FindClass("android/os/Environment");
|
// try appspecific external directory first
|
||||||
jmethodID method = env->GetStaticMethodID(clazz, "getExternalStorageDirectory", "()Ljava/io/File;");
|
jobject activity = state->activity->clazz;
|
||||||
if (env->ExceptionOccurred()) {
|
jclass activityClass = env->GetObjectClass(activity);
|
||||||
env->ExceptionDescribe();
|
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);
|
jclass fileClass = env->GetObjectClass(file);
|
||||||
jmethodID fileMethod = env->GetMethodID(fileClass, "getAbsolutePath", "()Ljava/lang/String;");
|
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);
|
const char* str = env->GetStringUTFChars((jstring) pathString, NULL);
|
||||||
app->externalStoragePath = str;
|
app->externalStoragePath = str;
|
||||||
app->externalCacheStoragePath = str;
|
app->externalCacheStoragePath = str;
|
||||||
LOGI("%s", str);
|
LOGI("%s", str);
|
||||||
|
|
||||||
// ensure the process working directory is set to a writable location
|
// ensure the process working directory is set to a writable location
|
||||||
|
|||||||
@@ -30,12 +30,33 @@ static void setupExternalPath(JNIEnv* env, MAIN_CLASS* app)
|
|||||||
{
|
{
|
||||||
LOGI("Environment exists");
|
LOGI("Environment exists");
|
||||||
}
|
}
|
||||||
jclass clazz = env->FindClass("android/os/Environment");
|
// try appspecific external directory first
|
||||||
jmethodID method = env->GetStaticMethodID(clazz, "getExternalStorageDirectory", "()Ljava/io/File;");
|
jobject activity = g_pActivity;
|
||||||
if (env->ExceptionOccurred()) {
|
jclass activityClass = env->GetObjectClass(activity);
|
||||||
env->ExceptionDescribe();
|
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);
|
jclass fileClass = env->GetObjectClass(file);
|
||||||
jmethodID fileMethod = env->GetMethodID(fileClass, "getAbsolutePath", "()Ljava/lang/String;");
|
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);
|
const char* str = env->GetStringUTFChars((jstring) pathString, NULL);
|
||||||
app->externalStoragePath = str;
|
app->externalStoragePath = str;
|
||||||
app->externalCacheStoragePath = str;
|
app->externalCacheStoragePath = str;
|
||||||
LOGI("%s", str);
|
LOGI("%s", str);
|
||||||
|
|
||||||
// same fix as the native entry point: make sure cwd is writable
|
// same fix as the native entry point: make sure cwd is writable
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ int main(void) {
|
|||||||
|
|
||||||
AppPlatform_glfw* platform = (AppPlatform_glfw*)appContext.platform;
|
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) {
|
if (platform->window == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
@@ -205,16 +205,16 @@ int main(void) {
|
|||||||
|
|
||||||
delete app;
|
delete app;
|
||||||
|
|
||||||
appContext.platform->finish();
|
|
||||||
|
|
||||||
delete appContext.platform;
|
|
||||||
|
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
// Exit.
|
// Exit.
|
||||||
glfwDestroyWindow(platform->window);
|
glfwDestroyWindow(platform->window);
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
appContext.platform->finish();
|
||||||
|
|
||||||
|
delete appContext.platform;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
|
|
||||||
#include <WinSock2.h>
|
#include <winsock2.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include "SharedConstants.h"
|
#include "SharedConstants.h"
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <WinSock2.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|||||||
@@ -140,7 +140,9 @@ RakNet::TimeUS GetTimeUS_Windows( void )
|
|||||||
#if _MSC_VER >= 1400 && defined (_M_X64)
|
#if _MSC_VER >= 1400 && defined (_M_X64)
|
||||||
GetProcessAffinityMask(mProc, (PDWORD_PTR)&mProcMask, (PDWORD_PTR)&mSysMask);
|
GetProcessAffinityMask(mProc, (PDWORD_PTR)&mProcMask, (PDWORD_PTR)&mSysMask);
|
||||||
#else
|
#else
|
||||||
|
#ifndef __MINGW32__
|
||||||
GetProcessAffinityMask(mProc, &mProcMask, &mSysMask);
|
GetProcessAffinityMask(mProc, &mProcMask, &mSysMask);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
mThread = GetCurrentThread();
|
mThread = GetCurrentThread();
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#if defined(X360__)
|
#if defined(X360__)
|
||||||
#elif defined (_WIN32)
|
#elif defined (_WIN32)
|
||||||
#include <WinSock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
// Must always include Winsock2.h before windows.h
|
// Must always include Winsock2.h before windows.h
|
||||||
// or else:
|
// or else:
|
||||||
|
|||||||
Reference in New Issue
Block a user