mirror of
https://github.com/celisej567/mcpe.git
synced 2025-12-31 17:49:17 +03:00
Merge pull request #82 into master
This commit is contained in:
27
.github/workflows/build.yml
vendored
Normal file
27
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
name: 'Build'
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install --no-install-recommends -y build-essential cmake ninja-build libopenal-dev libsdl2-dev
|
||||
- name: Build Desktop
|
||||
run: |
|
||||
cd platforms/sdl
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -GNinja ..
|
||||
cmake --build .
|
||||
- name: Build WASM
|
||||
run: ./build-wasm.sh
|
||||
@@ -44,7 +44,7 @@ cmake --build .
|
||||
::bundle
|
||||
echo * Copying bundle data over.
|
||||
copy reminecraftpe.* ..\dist
|
||||
copy ..\..\platforms\sdl\wasm_shell.html ..\dist\reminecraftpe.html
|
||||
copy ..\..\platforms\sdl\emscripten\wasm_shell.html ..\dist\reminecraftpe.html
|
||||
copy ..\..\thirdparty\coi-serviceworker\coi-serviceworker.min.js ..\dist
|
||||
|
||||
::for me only
|
||||
|
||||
@@ -14,8 +14,8 @@ cd emsdk
|
||||
|
||||
# Update Emscripten SDK
|
||||
git pull
|
||||
./emsdk install 3.1.42 # https://github.com/emscripten-core/emscripten/issues/19921
|
||||
./emsdk activate 3.1.42 > /dev/null
|
||||
./emsdk install latest
|
||||
./emsdk activate latest > /dev/null
|
||||
|
||||
# Use Emscripten SDK
|
||||
export EMSDK_QUIET=1
|
||||
@@ -38,5 +38,5 @@ cmake --build .
|
||||
|
||||
# Bundle
|
||||
cp reminecraftpe.* ../dist
|
||||
cp ../../platforms/sdl/wasm_shell.html ../dist/reminecraftpe.html
|
||||
cp ../../platforms/sdl/emscripten/wasm_shell.html ../dist/reminecraftpe.html
|
||||
cp ../../thirdparty/coi-serviceworker/coi-serviceworker.min.js ../dist
|
||||
|
||||
21
platforms/openal/CMakeLists.txt
Normal file
21
platforms/openal/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
project(reminecraftpe-openal)
|
||||
|
||||
# Build
|
||||
add_library(reminecraftpe-openal STATIC
|
||||
SoundSystemAL.cpp
|
||||
)
|
||||
|
||||
# Core
|
||||
target_link_libraries(reminecraftpe-openal PUBLIC reminecraftpe-core)
|
||||
|
||||
# OpenAL
|
||||
if(EMSCRIPTEN)
|
||||
target_link_libraries(reminecraftpe-openal PUBLIC openal)
|
||||
else()
|
||||
find_library(OPENAL_LIBRARY NAMES openal REQUIRED)
|
||||
target_link_libraries(reminecraftpe-openal PUBLIC "${OPENAL_LIBRARY}")
|
||||
endif()
|
||||
|
||||
# Headers
|
||||
target_include_directories(reminecraftpe-openal PUBLIC .)
|
||||
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../sdl/AppPlatform_sdl.hpp"
|
||||
|
||||
class AppPlatform_emscripten : public AppPlatform_sdlbase
|
||||
{
|
||||
public:
|
||||
AppPlatform_emscripten(std::string storageDir, SDL_Window *window);
|
||||
|
||||
Texture loadTexture(const std::string& path, bool b = false) override;
|
||||
};
|
||||
@@ -1,7 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
project(reminecraftpe)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
project(reminecraftpe-sdl)
|
||||
|
||||
# SDL Build
|
||||
add_compile_definitions(USE_SDL USE_OPENAL HANDLE_CHARS_SEPARATELY)
|
||||
@@ -30,27 +28,26 @@ else()
|
||||
endif()
|
||||
|
||||
# Build
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
base/AppPlatform_sdl_base.cpp
|
||||
)
|
||||
if(EMSCRIPTEN)
|
||||
add_executable(reminecraftpe
|
||||
main.cpp
|
||||
AppPlatform_sdlbase.cpp
|
||||
AppPlatform_emscripten.cpp
|
||||
../openal/SoundSystemAL.cpp
|
||||
)
|
||||
list(APPEND SOURCES emscripten/AppPlatform_sdl.cpp)
|
||||
else()
|
||||
add_executable(reminecraftpe
|
||||
main.cpp
|
||||
AppPlatform_sdlbase.cpp
|
||||
AppPlatform_sdl.cpp
|
||||
../openal/SoundSystemAL.cpp
|
||||
)
|
||||
list(APPEND SOURCES desktop/AppPlatform_sdl.cpp)
|
||||
endif()
|
||||
add_executable(reminecraftpe ${SOURCES})
|
||||
|
||||
# Core
|
||||
add_subdirectory(../../source source)
|
||||
target_link_libraries(reminecraftpe reminecraftpe-core)
|
||||
|
||||
# LibPNG
|
||||
# OpenAL
|
||||
add_subdirectory(../openal openal)
|
||||
target_link_libraries(reminecraftpe reminecraftpe-openal)
|
||||
|
||||
# LibPNG (If Needed)
|
||||
if(NOT EMSCRIPTEN)
|
||||
find_package(PNG REQUIRED)
|
||||
target_link_libraries(reminecraftpe PNG::PNG)
|
||||
@@ -72,6 +69,6 @@ endif()
|
||||
# Assets
|
||||
if(EMSCRIPTEN)
|
||||
target_link_options(reminecraftpe PRIVATE --use-preload-plugins --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/../../game/assets@/assets")
|
||||
elseif(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/assets")
|
||||
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC)
|
||||
else()
|
||||
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/../../game/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC)
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "AppPlatform_sdlbase.hpp"
|
||||
#include "AppPlatform_sdl_base.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
#include "platforms/openal/SoundSystemAL.hpp"
|
||||
#include "SoundSystemAL.hpp"
|
||||
|
||||
void AppPlatform_sdlbase::_init(std::string storageDir, SDL_Window *window)
|
||||
void AppPlatform_sdl_base::_init(std::string storageDir, SDL_Window *window)
|
||||
{
|
||||
_storageDir = storageDir;
|
||||
_window = window;
|
||||
@@ -31,7 +31,7 @@ void AppPlatform_sdlbase::_init(std::string storageDir, SDL_Window *window)
|
||||
m_pSoundSystem = nullptr;
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::initSoundSystem()
|
||||
void AppPlatform_sdl_base::initSoundSystem()
|
||||
{
|
||||
if (!m_pSoundSystem)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ void AppPlatform_sdlbase::initSoundSystem()
|
||||
}
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::setIcon(const Texture& icon)
|
||||
void AppPlatform_sdl_base::setIcon(const Texture& icon)
|
||||
{
|
||||
if (!icon.m_pixels)
|
||||
return;
|
||||
@@ -59,7 +59,7 @@ void AppPlatform_sdlbase::setIcon(const Texture& icon)
|
||||
SDL_SetWindowIcon(_window, _icon);
|
||||
}
|
||||
|
||||
AppPlatform_sdlbase::~AppPlatform_sdlbase()
|
||||
AppPlatform_sdl_base::~AppPlatform_sdl_base()
|
||||
{
|
||||
if (_icon) SDL_FreeSurface(_icon);
|
||||
SAFE_DELETE(_iconTexture);
|
||||
@@ -70,7 +70,7 @@ AppPlatform_sdlbase::~AppPlatform_sdlbase()
|
||||
SAFE_DELETE(m_pLogger);
|
||||
}
|
||||
|
||||
SDL_Surface* AppPlatform_sdlbase::getSurfaceForTexture(const Texture* const texture)
|
||||
SDL_Surface* AppPlatform_sdl_base::getSurfaceForTexture(const Texture* const texture)
|
||||
{
|
||||
if (!texture) return nullptr;
|
||||
|
||||
@@ -90,71 +90,71 @@ SDL_Surface* AppPlatform_sdlbase::getSurfaceForTexture(const Texture* const text
|
||||
return surface;
|
||||
}
|
||||
|
||||
int AppPlatform_sdlbase::checkLicense()
|
||||
int AppPlatform_sdl_base::checkLicense()
|
||||
{
|
||||
// we own the game!!
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* const AppPlatform_sdlbase::getWindowTitle() const
|
||||
const char* const AppPlatform_sdl_base::getWindowTitle() const
|
||||
{
|
||||
return SDL_GetWindowTitle(_window);
|
||||
}
|
||||
|
||||
int AppPlatform_sdlbase::getScreenWidth() const
|
||||
int AppPlatform_sdl_base::getScreenWidth() const
|
||||
{
|
||||
int width;
|
||||
SDL_GL_GetDrawableSize(_window, &width, nullptr);
|
||||
return width;
|
||||
}
|
||||
|
||||
int AppPlatform_sdlbase::getScreenHeight() const
|
||||
int AppPlatform_sdl_base::getScreenHeight() const
|
||||
{
|
||||
int height;
|
||||
SDL_GL_GetDrawableSize(_window, nullptr, &height);
|
||||
return height;
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::setMouseGrabbed(bool b)
|
||||
void AppPlatform_sdl_base::setMouseGrabbed(bool b)
|
||||
{
|
||||
SDL_SetWindowGrab(_window, b ? SDL_TRUE : SDL_FALSE);
|
||||
SDL_SetRelativeMouseMode(b ? SDL_TRUE : SDL_FALSE);
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::setMouseDiff(int x, int y)
|
||||
void AppPlatform_sdl_base::setMouseDiff(int x, int y)
|
||||
{
|
||||
xrel = x;
|
||||
yrel = y;
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::getMouseDiff(int& x, int& y)
|
||||
void AppPlatform_sdl_base::getMouseDiff(int& x, int& y)
|
||||
{
|
||||
x = xrel;
|
||||
y = yrel;
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::clearDiff()
|
||||
void AppPlatform_sdl_base::clearDiff()
|
||||
{
|
||||
xrel = 0;
|
||||
yrel = 0;
|
||||
}
|
||||
|
||||
bool AppPlatform_sdlbase::shiftPressed()
|
||||
bool AppPlatform_sdl_base::shiftPressed()
|
||||
{
|
||||
return m_bShiftPressed[0] || m_bShiftPressed[1];
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::setShiftPressed(bool b, bool isLeft)
|
||||
void AppPlatform_sdl_base::setShiftPressed(bool b, bool isLeft)
|
||||
{
|
||||
m_bShiftPressed[isLeft ? 0 : 1] = b;
|
||||
}
|
||||
|
||||
int AppPlatform_sdlbase::getUserInputStatus()
|
||||
int AppPlatform_sdl_base::getUserInputStatus()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
MouseButtonType AppPlatform_sdlbase::GetMouseButtonType(SDL_Event event)
|
||||
MouseButtonType AppPlatform_sdl_base::GetMouseButtonType(SDL_Event event)
|
||||
{
|
||||
switch (event.button.button)
|
||||
{
|
||||
@@ -169,7 +169,7 @@ MouseButtonType AppPlatform_sdlbase::GetMouseButtonType(SDL_Event event)
|
||||
}
|
||||
}
|
||||
|
||||
bool AppPlatform_sdlbase::GetMouseButtonState(SDL_Event event)
|
||||
bool AppPlatform_sdl_base::GetMouseButtonState(SDL_Event event)
|
||||
{
|
||||
bool result;
|
||||
|
||||
@@ -200,7 +200,7 @@ bool AppPlatform_sdlbase::GetMouseButtonState(SDL_Event event)
|
||||
return result;
|
||||
}
|
||||
|
||||
Keyboard::KeyState AppPlatform_sdlbase::GetKeyState(SDL_Event event)
|
||||
Keyboard::KeyState AppPlatform_sdl_base::GetKeyState(SDL_Event event)
|
||||
{
|
||||
switch (event.key.state)
|
||||
{
|
||||
@@ -9,15 +9,15 @@
|
||||
#include "client/player/input/Keyboard.hpp"
|
||||
#include "common/Logger.hpp"
|
||||
|
||||
class AppPlatform_sdlbase : public AppPlatform
|
||||
class AppPlatform_sdl_base : public AppPlatform
|
||||
{
|
||||
public:
|
||||
void _init(std::string storageDir, SDL_Window *window);
|
||||
AppPlatform_sdlbase(std::string storageDir, SDL_Window *window)
|
||||
AppPlatform_sdl_base(std::string storageDir, SDL_Window *window)
|
||||
{
|
||||
_init(storageDir, window);
|
||||
}
|
||||
~AppPlatform_sdlbase();
|
||||
~AppPlatform_sdl_base();
|
||||
|
||||
void initSoundSystem() override;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
AppPlatform_sdl::AppPlatform_sdl(std::string storageDir, SDL_Window *window)
|
||||
: AppPlatform_sdlbase(storageDir, window)
|
||||
: AppPlatform_sdl_base(storageDir, window)
|
||||
{
|
||||
setIcon(loadTexture("icon.png"));
|
||||
}
|
||||
@@ -2,9 +2,13 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "AppPlatform_sdlbase.hpp"
|
||||
#include "../base/AppPlatform_sdl_base.hpp"
|
||||
|
||||
class AppPlatform_sdl : public AppPlatform_sdlbase
|
||||
#define EM_BOOL bool
|
||||
#define EM_TRUE true
|
||||
#define EM_FALSE false
|
||||
|
||||
class AppPlatform_sdl : public AppPlatform_sdl_base
|
||||
{
|
||||
public:
|
||||
AppPlatform_sdl(std::string storageDir, SDL_Window *window);
|
||||
@@ -1,15 +1,13 @@
|
||||
#include "AppPlatform_emscripten.hpp"
|
||||
|
||||
#include <emscripten.h>
|
||||
#include "AppPlatform_sdl.hpp"
|
||||
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
AppPlatform_emscripten::AppPlatform_emscripten(std::string storageDir, SDL_Window *window)
|
||||
: AppPlatform_sdlbase(storageDir, window)
|
||||
AppPlatform_sdl::AppPlatform_sdl(std::string storageDir, SDL_Window *window)
|
||||
: AppPlatform_sdl_base(storageDir, window)
|
||||
{
|
||||
}
|
||||
|
||||
Texture AppPlatform_emscripten::loadTexture(const std::string& path, bool b)
|
||||
Texture AppPlatform_sdl::loadTexture(const std::string& path, bool b)
|
||||
{
|
||||
Texture out;
|
||||
out.field_C = 1;
|
||||
@@ -27,7 +25,6 @@ Texture AppPlatform_emscripten::loadTexture(const std::string& path, bool b)
|
||||
return out;
|
||||
}
|
||||
|
||||
// I don't think this logic makes any sense
|
||||
LOG_E("Couldn't find file: %s", realPath.c_str());
|
||||
return out;
|
||||
}
|
||||
16
platforms/sdl/emscripten/AppPlatform_sdl.hpp
Normal file
16
platforms/sdl/emscripten/AppPlatform_sdl.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
|
||||
#include "../base/AppPlatform_sdl_base.hpp"
|
||||
|
||||
class AppPlatform_sdl : public AppPlatform_sdl_base
|
||||
{
|
||||
public:
|
||||
AppPlatform_sdl(std::string storageDir, SDL_Window *window);
|
||||
|
||||
Texture loadTexture(const std::string& path, bool b = false) override;
|
||||
};
|
||||
@@ -10,6 +10,7 @@
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
@@ -5,28 +5,16 @@
|
||||
#include "thirdparty/GL/GL.hpp"
|
||||
#include "client/app/App.hpp"
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#include "AppPlatform_emscripten.hpp"
|
||||
typedef AppPlatform_emscripten UsedAppPlatform;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "emscripten/AppPlatform_sdl.hpp"
|
||||
#else
|
||||
#include "AppPlatform_sdl.hpp"
|
||||
typedef AppPlatform_sdl UsedAppPlatform;
|
||||
#include "desktop/AppPlatform_sdl.hpp"
|
||||
#endif
|
||||
typedef AppPlatform_sdl UsedAppPlatform;
|
||||
|
||||
#include "client/app/NinecraftApp.hpp"
|
||||
#include "client/player/input/Multitouch.hpp"
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
#else
|
||||
#define EM_BOOL bool
|
||||
#define EM_TRUE true
|
||||
#define EM_FALSE false
|
||||
#endif
|
||||
|
||||
#undef main
|
||||
|
||||
static float g_fPointToPixelScale = 1.0f;
|
||||
|
||||
UsedAppPlatform *g_pAppPlatform;
|
||||
@@ -89,7 +77,7 @@ static void handle_events()
|
||||
}
|
||||
*/
|
||||
|
||||
Keyboard::feed(AppPlatform_sdlbase::GetKeyState(event), TranslateSDLKeyCodeToVirtual(event.key.keysym.sym));
|
||||
Keyboard::feed(AppPlatform_sdl_base::GetKeyState(event), TranslateSDLKeyCodeToVirtual(event.key.keysym.sym));
|
||||
if (event.key.keysym.sym == SDLK_LSHIFT || event.key.keysym.sym == SDLK_RSHIFT)
|
||||
{
|
||||
g_pAppPlatform->setShiftPressed(event.key.state == SDL_PRESSED, event.key.keysym.sym == SDLK_LSHIFT);
|
||||
@@ -100,15 +88,15 @@ static void handle_events()
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
const float scale = g_fPointToPixelScale;
|
||||
Mouse::feed(AppPlatform_sdlbase::GetMouseButtonType(event), AppPlatform_sdlbase::GetMouseButtonState(event), event.button.x * scale, event.button.y * scale);
|
||||
Multitouch::feed(AppPlatform_sdlbase::GetMouseButtonType(event), AppPlatform_sdlbase::GetMouseButtonState(event), event.button.x * scale, event.button.y * scale, 0);
|
||||
Mouse::feed(AppPlatform_sdl_base::GetMouseButtonType(event), AppPlatform_sdl_base::GetMouseButtonState(event), event.button.x * scale, event.button.y * scale);
|
||||
Multitouch::feed(AppPlatform_sdl_base::GetMouseButtonType(event), AppPlatform_sdl_base::GetMouseButtonState(event), event.button.x * scale, event.button.y * scale, 0);
|
||||
break;
|
||||
}
|
||||
case SDL_MOUSEMOTION:
|
||||
{
|
||||
float scale = g_fPointToPixelScale;
|
||||
float x = event.motion.x * scale;
|
||||
float y = event.motion.y * scale;
|
||||
float scale = g_fPointToPixelScale;
|
||||
float x = event.motion.x * scale;
|
||||
float y = event.motion.y * scale;
|
||||
Mouse::feed(BUTTON_NONE, false, x, y);
|
||||
Multitouch::feed(BUTTON_NONE, false, x, y, 0);
|
||||
g_pAppPlatform->setMouseDiff(event.motion.xrel * scale, event.motion.yrel * scale);
|
||||
@@ -116,7 +104,7 @@ static void handle_events()
|
||||
}
|
||||
case SDL_MOUSEWHEEL:
|
||||
{
|
||||
Mouse::feed(BUTTON_SCROLLWHEEL, AppPlatform_sdlbase::GetMouseButtonState(event), Mouse::getX(), Mouse::getY());
|
||||
Mouse::feed(BUTTON_SCROLLWHEEL, AppPlatform_sdl_base::GetMouseButtonState(event), Mouse::getX(), Mouse::getY());
|
||||
break;
|
||||
}
|
||||
case SDL_TEXTINPUT:
|
||||
@@ -151,14 +139,14 @@ static void handle_events()
|
||||
// Resizing
|
||||
static void resize()
|
||||
{
|
||||
int drawWidth, drawHeight;
|
||||
SDL_GL_GetDrawableSize(window,
|
||||
&drawWidth, &drawHeight);
|
||||
|
||||
int windowWidth, windowHeight;
|
||||
SDL_GetWindowSize(window,
|
||||
&windowWidth, &windowHeight);
|
||||
|
||||
int drawWidth, drawHeight;
|
||||
SDL_GL_GetDrawableSize(window,
|
||||
&drawWidth, &drawHeight);
|
||||
|
||||
int windowWidth, windowHeight;
|
||||
SDL_GetWindowSize(window,
|
||||
&windowWidth, &windowHeight);
|
||||
|
||||
Minecraft::width = drawWidth;
|
||||
Minecraft::height = drawHeight;
|
||||
|
||||
@@ -218,7 +206,7 @@ extern bool g_bAreCloudsAvailable; // client/renderer/LevelRenderer.cpp
|
||||
#ifdef __EMSCRIPTEN__
|
||||
bool DoesAssetExist(const std::string & fileName)
|
||||
{
|
||||
std::string realPath = g_pAppPlatform->getAssetPath(fileName);
|
||||
std::string realPath = g_pAppPlatform->getAssetPath(fileName);
|
||||
int width = 0, height = 0;
|
||||
char *data = emscripten_get_preloaded_image_data(("/" + realPath).c_str(), &width, &height);
|
||||
if (data == NULL)
|
||||
@@ -227,18 +215,15 @@ bool DoesAssetExist(const std::string & fileName)
|
||||
free(data);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
// access works just fine on linux and friends
|
||||
#define DoesAssetExist(fileName) (XPL_ACCESS("assets/" fileName, 0) == 0)
|
||||
#endif
|
||||
|
||||
void CheckOptionalTextureAvailability()
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
g_bIsMenuBackgroundAvailable = DoesAssetExist("gui/background/panorama_0.png");
|
||||
g_bAreCloudsAvailable = DoesAssetExist("environment/clouds.png");
|
||||
#else
|
||||
// access works just fine on linux and friends
|
||||
g_bIsMenuBackgroundAvailable = XPL_ACCESS("assets/gui/background/panorama_0.png", 0) == 0;
|
||||
g_bAreCloudsAvailable = XPL_ACCESS("assets/environment/clouds.png", 0) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Main
|
||||
@@ -314,7 +299,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
// Storage Directory
|
||||
std::string storagePath;
|
||||
std::string storagePath;
|
||||
#ifdef _WIN32
|
||||
storagePath = getenv("APPDATA");
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
@@ -323,7 +308,7 @@ int main(int argc, char *argv[])
|
||||
storagePath = getenv("HOME");
|
||||
#endif
|
||||
storagePath += "/.reminecraftpe";
|
||||
|
||||
|
||||
if (!storagePath.empty())
|
||||
createFolderIfNotExists(storagePath.c_str());
|
||||
|
||||
@@ -335,9 +320,9 @@ int main(int argc, char *argv[])
|
||||
g_pApp->init();
|
||||
|
||||
CheckOptionalTextureAvailability();
|
||||
|
||||
// Set Size
|
||||
resize();
|
||||
|
||||
// Set Size
|
||||
resize();
|
||||
|
||||
// Loop
|
||||
#ifndef __EMSCRIPTEN__
|
||||
|
||||
@@ -275,10 +275,10 @@ else()
|
||||
target_link_libraries(reminecraftpe-core PUBLIC OpenGL::OpenGL OpenGL::GLU)
|
||||
endif()
|
||||
|
||||
# OpenAL
|
||||
if(EMSCRIPTEN)
|
||||
target_link_libraries(reminecraftpe-core PUBLIC openal)
|
||||
else()
|
||||
find_library(OPENAL_LIBRARY NAMES openal REQUIRED)
|
||||
target_link_libraries(reminecraftpe-core PUBLIC "${OPENAL_LIBRARY}")
|
||||
# Sound Data
|
||||
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../sound_data/sounds.h")
|
||||
if(NOT DEFINED ENV{CI})
|
||||
message(WARNING "Missing sound data! Did you run tools/grabsounds.py?")
|
||||
endif()
|
||||
target_compile_definitions(reminecraftpe-core PRIVATE MISSING_SOUND_DATA)
|
||||
endif()
|
||||
|
||||
@@ -971,6 +971,9 @@ float Minecraft::getBestScaleForThisScreenSize(int width, int height)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (height > 1600)
|
||||
return 1.0f / 4.0f;
|
||||
|
||||
if (height > 1000)
|
||||
return 1.0f / 3.0f;
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "TouchAreaModel.hpp"
|
||||
|
||||
TouchAreaModel::~TouchAreaModel()
|
||||
|
||||
@@ -15,4 +15,6 @@
|
||||
// Check the readme for a guide on how to extract game sounds from the
|
||||
// mcpe01_canada.apk file.
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef MISSING_SOUND_DATA
|
||||
#include "../../sound_data/sounds.h"
|
||||
#endif
|
||||
|
||||
@@ -23,6 +23,7 @@ void SoundEngine::init(Options* options)
|
||||
// TODO: Who's the genius who decided it'd be better to check a name string rather than an enum?
|
||||
m_pOptions = options;
|
||||
|
||||
#ifndef MISSING_SOUND_DATA
|
||||
m_repository.add("step.cloth", SA_cloth1);
|
||||
m_repository.add("step.cloth", SA_cloth2);
|
||||
m_repository.add("step.cloth", SA_cloth3);
|
||||
@@ -56,6 +57,7 @@ void SoundEngine::init(Options* options)
|
||||
m_repository.add("random.splash", SA_splash);
|
||||
m_repository.add("random.explode", SA_explode);
|
||||
m_repository.add("random.click", SA_click);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SoundEngine::play(const std::string& name)
|
||||
|
||||
Reference in New Issue
Block a user