Make Steam AppID configurable through mkxp.json

This commit is contained in:
Struma 2020-02-29 03:25:25 -05:00 committed by Roza
parent 230f03d289
commit fc2e10d124
6 changed files with 63 additions and 24 deletions

View file

@ -68,16 +68,19 @@ if steamworks_path != ''
steamlib = compilers['cpp'].find_library(libname, required: false, dirs: [steam_libpath])
if steamlib.found() == true
if get_option('steam_appid') != ''
global_include_dirs += include_directories(steamworks_path + '/public')
global_args += ['-I@0@/public'.format(steamworks_path),
'-DHAVE_STEAMWORKS',
'-DSTEAM_APPID=' + get_option('steam_appid')]
global_dependencies += steamlib
steamworks = true
else
error('Steamworks SDK was found, but steam_appid isn\'t set!')
appid = get_option('steam_appid')
if appid == ''
appid = '0'
endif
if appid == '0'
warning('Steam support is enabled, but steam_appid is not set.')
warning('Please make sure to set the corresponding option in the configuration file.')
endif
global_args += ['-I@0@/public'.format(steamworks_path),
'-DHAVE_STEAMWORKS',
'-DSTEAM_APPID=' + appid]
global_dependencies += steamlib
steamworks = true
endif
endif

View file

@ -20,5 +20,5 @@ option('static_executable', type: 'boolean', value: false, description: 'Build a
option('independent_appimage', type: 'boolean', value: true, description: 'Set current directory to the original location of the AppImage when contained within one')
option('discord_sdk_path', type: 'string', value: '', description: 'Path to Discord GameSDK')
option('steamworks_path', type: 'string', value: '', description: 'Path to Steamworks SDK')
option('steam_appid', type: 'string', value: '', description: 'Steam application ID.')
option('steam_appid', type: 'string', value: '0', description: 'Steam application ID.')
option('appimagekit_path', type: 'string', value: '', description: 'Path to AppImageKit, used for building AppImages')

View file

@ -339,6 +339,19 @@
// mkxp-z's Client ID is used by default.
// Only has an effect if mkxp-z is built with Discord support.
//
// "discordClientId": 1234567890
// "discordClientId": 1234567890,
// The game's Steam AppID.
//
// If the ID was specified at build time, this setting is
// ignored. If the ID is specified neither here nor in
// the build itself, the program will raise an error
// at startup.
//
// Only has an effect if mkxp-z was built with
// Steam support.
//
// "steamAppId": 0
}

View file

@ -91,6 +91,10 @@ struct Config {
DiscordClientId discordClientId;
#endif
#ifdef HAVE_STEAMWORKS
unsigned int steamAppId;
#endif
std::string customScript;
std::vector<std::string> preloadScripts;
std::vector<std::string> rtps;

View file

@ -85,6 +85,9 @@ void Config::read(int argc, char *argv[]) {
@"encryptedGraphics" : @false,
#ifdef HAVE_DISCORDSDK
@"discordClientId" : @DEFAULT_CLIENT_ID,
#endif
#ifdef HAVE_STEAMWORKS
@"steamAppId" : @0,
#endif
@"useScriptNames" : @1,
@"preloadScript" : @[],
@ -189,6 +192,9 @@ void Config::read(int argc, char *argv[]) {
#ifdef HAVE_DISCORDSDK
SET_OPT(discordClientId, longLongValue);
#endif
#ifdef HAVE_STEAMWORKS
SET_OPT(steamAppId, uInt32Value);
#endif
}
static void setupScreenSize(Config &conf) {

View file

@ -125,7 +125,7 @@ static void printRgssVersion(int ver) {
const char *const makers[] = {"", "XP", "VX", "VX Ace"};
char buf[128];
snprintf(buf, sizeof(buf), "RGSS version %d (%s)", ver, makers[ver]);
snprintf(buf, sizeof(buf), "RGSS version %d (RPG Maker %s)", ver, makers[ver]);
Debug() << buf;
}
@ -138,7 +138,7 @@ static void rgssThreadError(RGSSThreadData *rtData, const std::string &msg) {
static void showInitError(const std::string &msg) {
Debug() << msg;
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "mkxp", msg.c_str(), 0);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "mkxp-z", msg.c_str(), 0);
}
static void setupWindowIcon(const Config &conf, SDL_Window *win) {
@ -159,17 +159,6 @@ static void setupWindowIcon(const Config &conf, SDL_Window *win) {
int main(int argc, char *argv[]) {
@autoreleasepool {
#ifdef HAVE_STEAMWORKS
if (SteamAPI_RestartAppIfNecessary(STEAM_APPID)) {
Debug() << "Restarting with Steam...";
return 0;
}
if (!SteamAPI_Init()) {
showInitError("Steamworks failed to initialize.");
return 0;
}
#endif
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
@ -242,6 +231,30 @@ int main(int argc, char *argv[]) {
conf.readGameINI();
#ifdef HAVE_STEAMWORKS
#if STEAM_APPID == 0
if (!conf.steamAppId) {
showInitError("Steam AppID is not set. The application cannot continue launching.");
SDL_Quit();
return 0;
}
if (SteamAPI_RestartAppIfNecessary(conf.steamAppId))
#else
if (SteamAPI_RestartAppIfNecessary(STEAM_APPID))
#endif
{
SDL_Quit();
return 0;
}
if (!SteamAPI_Init()) {
showInitError("Steamworks failed to initialize.");
SDL_Quit();
return 0;
}
#endif
if (conf.windowTitle.empty())
conf.windowTitle = conf.game.title;