Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,10 @@ if(PLAYER_TARGET_PLATFORM STREQUAL "SDL3")
if(ANDROID)
set(PLAYER_BUILD_EXECUTABLE OFF)
endif()

if(WIN32)
target_link_libraries(${PROJECT_NAME} "Dwmapi")
endif()
elseif(PLAYER_TARGET_PLATFORM STREQUAL "SDL2")
target_sources(${PROJECT_NAME} PRIVATE
src/platform/sdl/sdl2_ui.cpp
Expand Down
15 changes: 0 additions & 15 deletions resources/emscripten/emscripten-post.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
// Move to different directory to prevent save file collisions in IDBFS
FS.mkdir("easyrpg");
FS.chdir("easyrpg");

if (Module.game.length > 0) {
FS.mkdir(Module.game);
FS.chdir(Module.game);
}

// Use IDBFS for save file storage when the filesystem was not
// overwritten by a custom emscripten shell file
if (Module.saveFs === undefined) {
Module.saveFs = IDBFS;
}

Module.initApi = function() {
Module.api_private.download_js = function (buffer, size, filename) {
const blob = new Blob([Module.HEAPU8.slice(buffer, buffer + size)]);
Expand Down
15 changes: 15 additions & 0 deletions resources/emscripten/emscripten-pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,23 @@ function parseArgs () {
}

function onPreRun () {
// Move to different directory to prevent save file collisions in IDBFS
FS.mkdir("easyrpg");
FS.chdir("easyrpg");

if (Module.game.length > 0) {
FS.mkdir(Module.game);
FS.chdir(Module.game);
}

// Retrieve save directory from persistent storage before using it
FS.mkdir("Save");

// Use IDBFS for save file storage when the filesystem was not
// overwritten by a custom emscripten shell file
if (Module.saveFs === undefined) {
Module.saveFs = IDBFS;
}
FS.mount(Module.saveFs, {}, 'Save');

// For preserving the configuration. Shared across website
Expand Down
16 changes: 8 additions & 8 deletions src/async_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <fstream>
#include <map>

#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
# include <emscripten.h>
# include <lcf/reader_util.h>
# include <nlohmann/json.hpp>
Expand All @@ -45,7 +45,7 @@ namespace {
std::unordered_map<std::string, FileRequestAsync> async_requests;
std::unordered_map<std::string, std::string> file_mapping;
int next_id = 0;
#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
int index_version = 1;
#endif

Expand All @@ -69,7 +69,7 @@ namespace {
return std::make_shared<int>(next_id++);
}

#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
constexpr size_t ASYNC_MAX_RETRY_COUNT{ 16 };

struct async_download_context {
Expand Down Expand Up @@ -140,7 +140,7 @@ namespace {
}

void AsyncHandler::CreateRequestMapping(const std::string& file) {
#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
auto f = FileFinder::Game().OpenInputStream(file);
if (!f) {
Output::Error("Emscripten: Reading index.json failed");
Expand Down Expand Up @@ -263,7 +263,7 @@ bool AsyncHandler::IsFilePending(bool important, bool graphic) {
}

void AsyncHandler::SaveFilesystem() {
#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
// Save changed file system
EM_ASM({
FS.syncfs(function(err) {
Expand Down Expand Up @@ -316,7 +316,7 @@ void FileRequestAsync::Start() {

state = State_Pending;

#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
std::string request_path;
# ifdef EM_GAME_URL
request_path = EM_GAME_URL;
Expand Down Expand Up @@ -388,7 +388,7 @@ void FileRequestAsync::Start() {
}

void FileRequestAsync::UpdateProgress() {
#ifndef EMSCRIPTEN
#ifndef __EMSCRIPTEN__
// Fake download for testing event handlers

if (!IsReady() && Rand::ChanceOf(1, 100)) {
Expand Down Expand Up @@ -435,7 +435,7 @@ void FileRequestAsync::DownloadDone(bool success) {
}

if (success) {
#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
if (state == State_Pending) {
// Update directory structure (new file was added)
if (FileFinder::Game()) {
Expand Down
2 changes: 1 addition & 1 deletion src/exe_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// All of this code is unused on EMSCRIPTEN. *Do not use it*!

#ifndef EMSCRIPTEN
#ifndef __EMSCRIPTEN__

#include "exe_reader.h"
#include "image_bmp.h"
Expand Down
2 changes: 1 addition & 1 deletion src/filefinder_rtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#endif

FileFinder_RTP::FileFinder_RTP(bool no_rtp, bool no_rtp_warnings, std::string rtp_path) {
#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
// No RTP support for emscripten at the moment.
disable_rtp = true;
#else
Expand Down
8 changes: 4 additions & 4 deletions src/game_destiny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include "game_destiny.h"
#include "filefinder.h"

#ifndef EMSCRIPTEN
#ifndef __EMSCRIPTEN__
#include "exe_reader.h"
#endif // !EMSCRIPTEN
#endif // !__EMSCRIPTEN__
#include "output.h"

using Destiny::InterpretFlag;
Expand Down Expand Up @@ -52,7 +52,7 @@ void Game_Destiny::Load()
uint32_t floatSize = 0;
uint32_t stringSize = 0;

#ifndef EMSCRIPTEN
#ifndef __EMSCRIPTEN__
Filesystem_Stream::InputStream exe = FileFinder::Game().OpenFile(EXE_NAME);

if (exe)
Expand Down Expand Up @@ -80,7 +80,7 @@ void Game_Destiny::Load()
gameVersion = 0x20000107;
extra = 0x01;
dwordSize = floatSize = stringSize = 0x64;
#endif // !EMSCRIPTEN
#endif // !__EMSCRIPTEN__

Initialize(dllVersion, language, gameVersion, extra, dwordSize, floatSize, stringSize);
}
Expand Down
2 changes: 1 addition & 1 deletion src/game_interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Game_Interpreter : public Game_BaseInterpreterContext
static Game_Interpreter& GetForegroundInterpreter();

Game_Interpreter(bool _main_flag = false);
#ifndef EMSCRIPTEN
#ifndef __EMSCRIPTEN__
// No idea why but emscripten will complain about a missing destructor when
// using virtual here
virtual
Expand Down
6 changes: 3 additions & 3 deletions src/game_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ void Game_Map::SetPositionX(int x, bool reset_panorama) {
const int map_width = GetTilesX() * SCREEN_TILE_SIZE;
if (LoopHorizontal()) {
x = Utils::PositiveModulo(x, map_width);

// If the map is too small to fit in the screen, add an offset corresponding to the black border's size
if (Player::game_config.fake_resolution.Get()) {
int map_width_in_pixels = Game_Map::GetTilesX() * TILE_SIZE;
Expand Down Expand Up @@ -2016,7 +2016,7 @@ std::string Game_Map::ConstructMapName(int map_id, bool is_easyrpg) {
}

FileRequestAsync* Game_Map::RequestMap(int map_id) {
#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
Player::translation.RequestAndAddMap(map_id);
#endif

Expand Down Expand Up @@ -2157,7 +2157,7 @@ void Game_Map::Parallax::ResetPositionX() {
if (!params.scroll_horz && !LoopHorizontal()) {
// What is the width of the panorama to display on screen?
int pan_screen_width = Player::screen_width;
if (Player::game_config.fake_resolution.Get()) {
if (Player::game_config.fake_resolution.Get()) {
int map_width = Game_Map::GetTilesX() * TILE_SIZE;
if (map_width < pan_screen_width) {
pan_screen_width = map_width;
Expand Down
2 changes: 1 addition & 1 deletion src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void Graphics::UpdateTitle() {
return;
}

#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
return;
#else
std::string fps;
Expand Down
8 changes: 4 additions & 4 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <chrono>
#include <fmt/color.h>
#include <fmt/ostream.h>
#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
# include "platform/emscripten/interface.h"
#endif

Expand Down Expand Up @@ -137,7 +137,7 @@ void Output::SetLogCallback(LogCallbackFn fn, LogCallbackUserData userdata) {

static void WriteLog(LogLevel lvl, std::string const& msg, Color const& c = Color()) {
// skip writing log file
#ifndef EMSCRIPTEN
#ifndef __EMSCRIPTEN__
std::string prefix = Output::LogLevelToString(lvl) + ": ";

// Every new message is written once to the file.
Expand Down Expand Up @@ -198,7 +198,7 @@ void Output::Quit() {
}

bool Output::TakeScreenshot(bool is_auto_screenshot) {
#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
Emscripten_Interface::TakeScreenshot(is_auto_screenshot);
return true;
#else
Expand Down Expand Up @@ -286,7 +286,7 @@ void Output::ErrorStr(std::string const& err) {
#if defined (PLAYER_NINTENDO) || defined(__vita__)
// stdin is non-blocking
Game_Clock::SleepFor(5s);
#elif defined (EMSCRIPTEN)
#elif defined (__EMSCRIPTEN__)
// Don't show JavaScript Window.prompt from stdin call
std::cout << " Process finished.";
#else
Expand Down
2 changes: 1 addition & 1 deletion src/platform/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using Platform_Clock = NxClock;
#elif defined(__vita__)
#include "platform/psvita/clock.h"
using Platform_Clock = Psp2Clock;
#elif defined(EMSCRIPTEN)
#elif defined(__EMSCRIPTEN__)
#include "platform/emscripten/clock.h"
using Platform_Clock = EmscriptenClock;
#elif defined(USE_LIBRETRO)
Expand Down
4 changes: 3 additions & 1 deletion src/platform/sdl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
#include "utils.h"
#include "output.h"

#if USE_SDL == 3 // This is needed on Windows, SDL wraps main()
#if USE_SDL == 3
# include <SDL3/SDL.h>
// This is needed on Windows, SDL wraps main()
# include <SDL3/SDL_main.h>
#elif USE_SDL <= 2
# include <SDL.h>
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/platform/sdl/sdl2_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <SDL_audio.h>
#include <SDL_version.h>

#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
# include <emscripten.h>
#endif

Expand Down Expand Up @@ -75,7 +75,7 @@ Sdl2Audio::Sdl2Audio(const Game_ConfigAudio& cfg) :
return;
}

#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
// Get preferred sample rate from Browser (-> OS)
const int frequency = EM_ASM_INT_V({
var context;
Expand Down
Loading
Loading