forked from Kolyah35/minecraft-pe-0.6.1
Merge branch 'main' of https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1
This commit is contained in:
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
|
||||||
90
.github/workflows/build.yml
vendored
90
.github/workflows/build.yml
vendored
@@ -19,7 +19,7 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
build-windows:
|
build-windows:
|
||||||
name: Windows Build
|
name: Windows Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -27,87 +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: Download xwin
|
- name: Setup Ninja
|
||||||
uses: robinraju/release-downloader@v1.10
|
uses: ./.github/actions/setup-ninja
|
||||||
with:
|
with:
|
||||||
repository: Jake-Shadle/xwin
|
host: linux
|
||||||
latest: true
|
|
||||||
fileName: 'xwin-*-x86_64-unknown-linux-musl.tar.gz'
|
- name: Download llvm-mingw
|
||||||
tarBall: false
|
|
||||||
zipBall: false
|
|
||||||
out-file-path: "epic-xwin"
|
|
||||||
|
|
||||||
- name: Prepare xwin
|
|
||||||
run: |
|
run: |
|
||||||
tar -xzf epic-xwin/xwin-*-x86_64-unknown-linux-musl.tar.gz -C epic-xwin
|
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
|
||||||
mv epic-xwin/xwin-*-x86_64-unknown-linux-musl/xwin ./xwin
|
tar -xf llvm-mingw.tar.xz
|
||||||
./xwin --arch x86_64 --sdk-version 10.0.22621 --accept-license list
|
mv llvm-mingw-* llvm-mingw
|
||||||
|
|
||||||
# this caches '.xwin-cache/**/*' but that's actually only gonna
|
|
||||||
# contain the manifest cuz we only ran `xwin list` so far
|
|
||||||
- name: Setup xwin Cache
|
|
||||||
id: xwin-cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: .xwin-cache
|
|
||||||
key: xwin-win-v1-${{ hashFiles('.xwin-cache/**/*') }}
|
|
||||||
|
|
||||||
- name: Download clang-msvc-sdk toolchain
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: 'Nemirtingas/clang-msvc-sdk'
|
|
||||||
path: toolchain
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Install Clang
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y wget lsb-release software-properties-common gnupg
|
|
||||||
|
|
||||||
wget https://apt.llvm.org/llvm.sh
|
|
||||||
chmod +x llvm.sh
|
|
||||||
sudo ./llvm.sh 21 all
|
|
||||||
|
|
||||||
- name: Add LLVM 21 to path
|
|
||||||
run: echo "/usr/lib/llvm-21/bin" >> $GITHUB_PATH
|
|
||||||
|
|
||||||
- name: Verify LLVM
|
|
||||||
run: |
|
|
||||||
which clang-cl
|
|
||||||
which lld-link
|
|
||||||
clang-cl --version
|
|
||||||
lld-link --version
|
|
||||||
|
|
||||||
- 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
|
||||||
working-directory: ${{github.workspace}}/build
|
working-directory: ${{github.workspace}}/build
|
||||||
run: cmake $env:GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
|
run: |
|
||||||
env:
|
cmake $GITHUB_WORKSPACE \
|
||||||
SPLAT_DIR: ${{ github.workspace }}/.xwin-cache/splat
|
-G Ninja \
|
||||||
TOOLCHAIN: ${{ github.workspace }}/toolchain/clang-cl-msvc.cmake
|
-DCMAKE_SYSTEM_NAME=Windows \
|
||||||
HOST_ARCH: x86_64
|
-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
|
||||||
run: cmake --build . --config $env:BUILD_TYPE --target MinecraftPE --parallel
|
run: cmake --build . --config $BUILD_TYPE --target MinecraftPE --parallel
|
||||||
|
|
||||||
- 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
|
||||||
|
|||||||
@@ -28,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)
|
||||||
@@ -100,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 *
|
||||||
|
|||||||
@@ -182,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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public:
|
|||||||
|
|
||||||
virtual bool supportsTouchscreen() override { return true; }
|
virtual bool supportsTouchscreen() override { return true; }
|
||||||
|
|
||||||
virtual void hideCursor(bool hide) {
|
virtual void hideCursor(bool hide) override {
|
||||||
int isHide = hide ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN;
|
int isHide = hide ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN;
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, isHide);
|
glfwSetInputMode(window, GLFW_CURSOR, isHide);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1160,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 {
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <platform/log.h>
|
#include <platform/log.h>
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <sys/stat.h>
|
#include <direct.h>
|
||||||
#include <sys/types.h>
|
#else
|
||||||
#include <unistd.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OptionsFile::OptionsFile() {
|
OptionsFile::OptionsFile() {
|
||||||
@@ -27,39 +28,44 @@ void OptionsFile::setOptionsPath(const std::string& path) {
|
|||||||
std::string OptionsFile::getOptionsPath() const {
|
std::string OptionsFile::getOptionsPath() const {
|
||||||
return settingsPath;
|
return settingsPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsFile::save(const StringVector& settings) {
|
void OptionsFile::save(const StringVector& settings) {
|
||||||
FILE* pFile = fopen(settingsPath.c_str(), "w");
|
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 {
|
|
||||||
if (errno != ENOENT)
|
|
||||||
LOGI("OptionsFile::save failed to open '%s' for writing: %s", settingsPath.c_str(), strerror(errno));
|
|
||||||
|
|
||||||
// Ensure parent directory exists for safekeeping if path contains directories
|
if (!pFile && errno == ENOENT) {
|
||||||
std::string dir = settingsPath;
|
std::string dir = settingsPath;
|
||||||
size_t fpos = dir.find_last_of("/\\");
|
size_t fpos = dir.find_last_of("/\\");
|
||||||
if (fpos != std::string::npos) {
|
if (fpos != std::string::npos) {
|
||||||
dir.resize(fpos);
|
dir.resize(fpos);
|
||||||
struct stat st;
|
|
||||||
if (stat(dir.c_str(), &st) != 0) {
|
std::string toCreate;
|
||||||
// attempt recursive mkdir
|
for (size_t i = 0; i <= dir.size(); ++i) {
|
||||||
std::string toCreate;
|
if (i == dir.size() || dir[i] == '/' || dir[i] == '\\') {
|
||||||
for (size_t i = 0; i <= dir.size(); ++i) {
|
if (!toCreate.empty()) {
|
||||||
if (i == dir.size() || dir[i] == '/' || dir[i] == '\\') {
|
#if defined(_WIN32)
|
||||||
if (!toCreate.empty()) {
|
_mkdir(toCreate.c_str());
|
||||||
mkdir(toCreate.c_str(), 0755);
|
#else
|
||||||
}
|
mkdir(toCreate.c_str(), 0755);
|
||||||
}
|
#endif
|
||||||
if (i < dir.size())
|
}
|
||||||
toCreate.push_back(dir[i]);
|
}
|
||||||
}
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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