Skip to content

Commit

Permalink
Add portable engine mode
Browse files Browse the repository at this point in the history
  • Loading branch information
carstene1ns committed Oct 26, 2023
1 parent 3988a1d commit eb38e15
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
2 changes: 2 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ http://www.alister.eu/jazz/oj/build.php

- `DATAPATH` - add a fixed path for game data files
- `SCALE` - enable scaling of the video output (i.e. Scale2X...)
- `PORTABLE` - Do not use external directories for configuration saving, etc.
(This only affects Unix platforms, Windows version is always portable)

Some ports have their own options, see (Platforms)[PLATFORMS.md] for details.

Expand Down
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,25 @@ target_include_directories(OpenJazz PUBLIC src)

# Default Options

set(SCALE_STATUS "Disabled")
option(SCALE "Allow scaling" ${OJ_SCALE})
if(SCALE)
set(SCALE_STATUS "Enabled, scale2x")
target_compile_definitions(OpenJazz PRIVATE SCALE)
set(OJ_LIBS_SCALE scale2x)
endif()

set(PORTABLE_STATUS "Automatic")
option(PORTABLE "Do not write to external directories, etc." OFF)
if(PORTABLE)
set(PORTABLE_STATUS "Portable")
target_compile_definitions(OpenJazz PRIVATE PORTABLE)
endif()

# path to game data

set(DATAPATH "" CACHE PATH "Fixed path where game data is available")
if(${DATAPATH})
if(DATAPATH)
target_compile_definitions(OpenJazz PRIVATE DATAPATH="${DATAPATH}")
endif()

Expand Down Expand Up @@ -349,7 +358,12 @@ if(ROMFS)
message(STATUS "RomFS: Embedding directory \"${ROMFS_PATH}\"")
endif()
message(STATUS "Network: ${NETWORK_STATUS}")
message(STATUS "Scaling: ${SCALE_STATUS}")
if(DATAPATH)
message(STATUS "Additional/System Game Data Path: \"${DATAPATH}\"")
endif()
message(STATUS "Manual page: ${MANUAL_STATUS}")
message(STATUS "Engine mode: ${PORTABLE_STATUS}")
message(STATUS "")
message(STATUS "In case something goes wrong, report bugs to https://github.com/AlisterT/openjazz/issues")
message(STATUS "")
16 changes: 6 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,12 @@ void startUp (const char *argv0, int pathCount, char *paths[]) {

// Determine paths

// Use hard-coded data paths, if available
#ifdef DATAPATH
gamePaths.add(createString(DATAPATH), PATH_TYPE_SYSTEM|PATH_TYPE_GAME);
#endif

PLATFORM_AddGamePaths();

// Use any provided paths
for (int i = 0; i < pathCount; i++) {

for (int i = 0; i < pathCount; i++)
gamePaths.add(createString(paths[i]), PATH_TYPE_GAME);

}


// Use the path of the program, but check before, since it is not always available
// At least crashes in Dolphin emulator (Wii) and 3DS (.cia build)
Expand All @@ -193,9 +185,13 @@ void startUp (const char *argv0, int pathCount, char *paths[]) {

}

// Last Resort: Use the current working directory
// Use the current working directory
gamePaths.add(createString(""), PATH_TYPE_GAME|PATH_TYPE_CONFIG|PATH_TYPE_TEMP);

// Use hard-coded data paths, if available
#ifdef DATAPATH
gamePaths.add(createString(DATAPATH), PATH_TYPE_SYSTEM|PATH_TYPE_GAME);
#endif

// Default settings

Expand Down
3 changes: 3 additions & 0 deletions src/platforms/platforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ inline void PLATFORM_AddGamePaths() {

// using __unix__ might add too much
#if (__linux__ && !__ANDROID__) || __FreeBSD__ || __OpenBSD__
#ifndef PORTABLE
// Only use XDG dirs for installed package
XDG_AddGamePaths();
#endif
#endif
}

Expand Down

0 comments on commit eb38e15

Please sign in to comment.