Fix redistribution scripts and Linux scripts. Linux scripts now detect if Steam is installed and if the game properly initializes with steam. If it does not, it will restart itself to run in nosteam mode. Added the ability to read command line arguments into the game. Release Build 9441.

mac-build
sigonasr2 6 months ago
parent 71466f2b97
commit 764fdfb06d
  1. 59
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 2
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 2
      Adventures in Lestoria/Version.h
  4. 8
      distribute.sh
  5. 3
      runGame - NO STEAM.bat
  6. BIN
      x64/Release/Adventures in Lestoria.exe

@ -2944,8 +2944,20 @@ bool Steam_Init(){
return false; return false;
} }
int main() int main(char**args,const int argn)
{ {
debugLogger.open("debug.log");
LOG(std::format("Found {} args",argn));
bool usingSteam=true;
for(int i=0;i<argn;i++){
if(std::string(args[i])=="nosteam"){
LOG("nosteam flag detected. Disabling steam API...");
usingSteam=false;
}
LOG(std::format("{}: {}",i,args[i]));
}
if(!std::filesystem::exists("assets/config/configuration.txt")){ if(!std::filesystem::exists("assets/config/configuration.txt")){
ERR("WARNING! Could not find initial config file! Aborting."); ERR("WARNING! Could not find initial config file! Aborting.");
return false; return false;
@ -2953,7 +2965,8 @@ int main()
{ {
utils::datafile configFile; utils::datafile configFile;
utils::datafile::Read(configFile,"assets/config/configuration.txt"); utils::datafile::Read(configFile,"assets/config/configuration.txt");
if(configFile["steam_api"].GetBool()){ usingSteam&=configFile["steam_api"].GetBool();
if(usingSteam){
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
if(SteamAPI_RestartAppIfNecessary(2895980U))return false; //Immediately quit if steam is detected and can be started through it. if(SteamAPI_RestartAppIfNecessary(2895980U))return false; //Immediately quit if steam is detected and can be started through it.
if(Steam_Init()){ if(Steam_Init()){
@ -2967,6 +2980,8 @@ int main()
{ {
AiL demo; AiL demo;
demo.UsingSteamAPI(usingSteam);
#pragma region Load Window Settings #pragma region Load Window Settings
utils::datafile loadSystemFile; utils::datafile loadSystemFile;
@ -3040,10 +3055,42 @@ int main()
return 0; return 0;
} }
void get_command_line_args( int * argc, char *** argv )
{
// Get the command line arguments as wchar_t strings
wchar_t ** wargv = CommandLineToArgvW( GetCommandLineW(), argc );
if (!wargv) { *argc = 0; *argv = NULL; return; }
// Count the number of bytes necessary to store the UTF-8 versions of those strings
int n = 0;
for (int i = 0; i < *argc; i++)
n += WideCharToMultiByte( CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL ) + 1;
// Allocate the argv[] array + all the UTF-8 strings
*argv = (char**)(malloc( (*argc + 1) * sizeof(char *) + n ));
if (!*argv) { *argc = 0; return; }
// Convert all wargv[] --> argv[]
char * arg = (char *)&((*argv)[*argc + 1]);
for (int i = 0; i < *argc; i++)
{
(*argv)[i] = arg;
arg += WideCharToMultiByte( CP_UTF8, 0, wargv[i], -1, arg, n, NULL, NULL ) + 1;
}
(*argv)[*argc] = NULL;
}
#ifndef _DEBUG #ifndef _DEBUG
#ifdef _WIN32 #ifdef _WIN32
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){ int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){
main(); int argc;
char ** argv;
get_command_line_args( &argc, &argv );
for(int n = 0;n < argc;n++)
printf( " %d : %s\n", n, argv[n] );
main(argv,argc);
free( argv );
} }
#endif #endif
#endif #endif
@ -3938,7 +3985,7 @@ void AiL::UpdateDiscordStatus(std::string levelName,std::string className){
} }
SteamFriends()->SetRichPresence("steam_display","#Status"); SteamFriends()->SetRichPresence("steam_display","#Status");
}else{ }else{
if("steam_api"_B&&Steam_Init()){ if(steamAPIEnabled&&Steam_Init()){
retry=true; retry=true;
LOG("Steam API Initialized successfully!"); LOG("Steam API Initialized successfully!");
} }
@ -4298,3 +4345,7 @@ void AiL::SetWindSpeed(vf2d newWindSpd){
const vf2d&AiL::GetWindSpeed()const{ const vf2d&AiL::GetWindSpeed()const{
return windSpd; return windSpd;
} }
void AiL::UsingSteamAPI(const bool usingSteam){
steamAPIEnabled=usingSteam;
}

@ -209,6 +209,7 @@ private:
SteamKeyboardCallbackHandler*steamKeyboardCallbackListener=nullptr; SteamKeyboardCallbackHandler*steamKeyboardCallbackListener=nullptr;
SteamStatsReceivedHandler*steamStatsReceivedHandlerListener=nullptr; SteamStatsReceivedHandler*steamStatsReceivedHandlerListener=nullptr;
std::optional<vf2d>bossIndicatorPos{}; std::optional<vf2d>bossIndicatorPos{};
bool steamAPIEnabled{true};
Overlay hudOverlay{"pixel.png",BLANK}; Overlay hudOverlay{"pixel.png",BLANK};
public: public:
AiL(); AiL();
@ -220,6 +221,7 @@ public:
void GetAnyMousePress(int32_t mouseButton)override final; void GetAnyMousePress(int32_t mouseButton)override final;
void GetAnyMouseHeld(int32_t mouseButton)override final; void GetAnyMouseHeld(int32_t mouseButton)override final;
void GetAnyMouseRelease(int32_t mouseButton)override final; void GetAnyMouseRelease(int32_t mouseButton)override final;
void UsingSteamAPI(const bool usingSteam);
public: public:
geom2d::rect<float>NO_COLLISION={{0.f,0.f,},{0.f,0.f}}; geom2d::rect<float>NO_COLLISION={{0.f,0.f,},{0.f,0.f}};
TileTransformedView view; TileTransformedView view;

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 3 #define VERSION_PATCH 3
#define VERSION_BUILD 9509 #define VERSION_BUILD 9510
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -23,4 +23,10 @@ cp -R bin release
rm release/*.pdb rm release/*.pdb
touch release/runGame.sh touch release/runGame.sh
echo "bin/AdventuresInLestoria" > release/runGame.sh echo "#!/bin/bash
if [ `bin/AdventuresInLestoria | wc -l` == 0 ]; then
echo \"Failed to Load through Steam Restarting without Steam API!\"
bin/AdventuresInLestoria nosteam
else
echo \"Success!\"
fi" > release/runGame.sh

@ -0,0 +1,3 @@
cd "Adventures in Lestoria"
"..\x64\Release\Adventures in Lestoria.exe" nosteam
set /p DUMMY=Hit ENTER to exit...
Loading…
Cancel
Save