Emscripten compatibility fixes.

mac-build
sigonasr2 8 months ago
parent cd8944db96
commit 36775982a6
  1. 8
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 8
      Adventures in Lestoria/CharacterMenuWindow.cpp
  3. 12
      Adventures in Lestoria/Item.cpp
  4. 6
      Adventures in Lestoria/Monster.cpp
  5. 6
      Adventures in Lestoria/Player.cpp
  6. 2
      Adventures in Lestoria/State_MainMenu.cpp
  7. 11
      Adventures in Lestoria/Unlock.cpp
  8. 2
      Adventures in Lestoria/emscripten_compat.h

@ -2513,7 +2513,9 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){
}); });
LoadingScreen::AddPhase([&](){ LoadingScreen::AddPhase([&](){
if(SteamUserStats())SteamUserStats()->StoreStats(); STEAMUSERSTATS(
SteamUserStats()->StoreStats();
)
ClearGarbage(); ClearGarbage();
return true; return true;
}); });
@ -2746,9 +2748,9 @@ bool Steam_Init(){
LOG(std::format("STEAM[{}]: {}",severity,std::string(message))); LOG(std::format("STEAM[{}]: {}",severity,std::string(message)));
}); });
} }
if(SteamUserStats()){ STEAMUSERSTATS(
SteamUserStats()->RequestCurrentStats(); SteamUserStats()->RequestCurrentStats();
} )
return true; return true;
} }
#endif #endif

@ -51,7 +51,7 @@ All rights reserved.
#include "ProgressBar.h" #include "ProgressBar.h"
#include "MenuItemLabel.h" #include "MenuItemLabel.h"
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
#include <isteamuserstats.h> #include "steam/isteamuserstats.h"
#endif #endif
INCLUDE_game INCLUDE_game
@ -103,16 +103,14 @@ namespace CharacterMenuWindow{
if(SelectedEquipIsDifferent(comp)){ //If we find that the opposite ring slot is equipped to us, this would be an item swap or the exact same ring, therefore no stat calculations apply. if(SelectedEquipIsDifferent(comp)){ //If we find that the opposite ring slot is equipped to us, this would be an item swap or the exact same ring, therefore no stat calculations apply.
Inventory::EquipItem(comp.lock()->GetItem(),EquipSlot(comp.lock()->I(Attribute::EQUIP_TYPE))); Inventory::EquipItem(comp.lock()->GetItem(),EquipSlot(comp.lock()->I(Attribute::EQUIP_TYPE)));
#pragma region Achievement Stuff
if(SteamUserStats()){
#pragma region Fully Decked Out Achievement #pragma region Fully Decked Out Achievement
STEAMUSERSTATS(
datafile&unlock=DATA.GetProperty("Achievement.Equip Unlocks.Fully Decked Out"); datafile&unlock=DATA.GetProperty("Achievement.Equip Unlocks.Fully Decked Out");
if(Inventory::EquipsFullyMaxedOut(unlock["Weapon Max Level"].GetInt(),unlock["Armor Max Level"].GetInt())){ if(Inventory::EquipsFullyMaxedOut(unlock["Weapon Max Level"].GetInt(),unlock["Armor Max Level"].GetInt())){
SteamUserStats()->SetAchievement(unlock["API Name"].GetString().c_str()); SteamUserStats()->SetAchievement(unlock["API Name"].GetString().c_str());
SteamUserStats()->StoreStats(); SteamUserStats()->StoreStats();
} }
#pragma endregion )
}
#pragma endregion #pragma endregion
if(Menu::IsCurrentlyActive(data.menu.GetType())){ if(Menu::IsCurrentlyActive(data.menu.GetType())){

@ -48,7 +48,7 @@ All rights reserved.
#include "ClassInfo.h" #include "ClassInfo.h"
#include "RowInventoryScrollableWindowComponent.h" #include "RowInventoryScrollableWindowComponent.h"
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
#include <isteamuserstats.h> #include "steam/isteamuserstats.h"
#endif #endif
INCLUDE_game INCLUDE_game
@ -929,15 +929,15 @@ void Item::EnhanceItem(uint8_t qty){
enhancementLevel++; enhancementLevel++;
if(SteamUserStats()){ #pragma region Achievements
#pragma region Fully Decked Out Achievement STEAMUSERSTATS(
// Fully Decked Out Achievement
datafile&unlock=DATA.GetProperty("Achievement.Equip Unlocks.Fully Decked Out"); datafile&unlock=DATA.GetProperty("Achievement.Equip Unlocks.Fully Decked Out");
if(Inventory::EquipsFullyMaxedOut(unlock["Weapon Max Level"].GetInt(),unlock["Armor Max Level"].GetInt())){ if(Inventory::EquipsFullyMaxedOut(unlock["Weapon Max Level"].GetInt(),unlock["Armor Max Level"].GetInt())){
SteamUserStats()->SetAchievement(unlock["API Name"].GetString().c_str()); SteamUserStats()->SetAchievement(unlock["API Name"].GetString().c_str());
SteamUserStats()->StoreStats(); SteamUserStats()->StoreStats();
} }
#pragma endregion // Equipment achievement unlocks
#pragma region Equipment achievement unlocks
for(auto&[key,size]:DATA.GetProperty("Achievement.Equip Unlocks")){ for(auto&[key,size]:DATA.GetProperty("Achievement.Equip Unlocks")){
datafile&unlock=DATA.GetProperty(std::format("Achievement.Equip Unlocks.{}",key)); datafile&unlock=DATA.GetProperty(std::format("Achievement.Equip Unlocks.{}",key));
if(!(unlock.HasProperty("Upgrade Requirement")&&unlock.HasProperty("Equip Slot")))continue; //Ignore any achievements that don't have an upgrade requirement/equipment slot defined. if(!(unlock.HasProperty("Upgrade Requirement")&&unlock.HasProperty("Equip Slot")))continue; //Ignore any achievements that don't have an upgrade requirement/equipment slot defined.
@ -953,8 +953,8 @@ void Item::EnhanceItem(uint8_t qty){
} }
} }
} }
)
#pragma endregion #pragma endregion
}
const CraftingRequirement&consumedResources=GetEnhancementInfo()[EnhancementLevel()].craftingRequirement; const CraftingRequirement&consumedResources=GetEnhancementInfo()[EnhancementLevel()].craftingRequirement;

@ -49,7 +49,7 @@ All rights reserved.
#include "SoundEffect.h" #include "SoundEffect.h"
#include "Unlock.h" #include "Unlock.h"
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
#include <isteamuserstats.h> #include "steam/isteamuserstats.h"
#endif #endif
INCLUDE_ANIMATION_DATA INCLUDE_ANIMATION_DATA
@ -729,7 +729,7 @@ void Monster::OnDeath(){
Unlock::IncreaseKillCount(); Unlock::IncreaseKillCount();
if(SteamUserStats()){ STEAMUSERSTATS(
for(auto&[key,size]:DATA.GetProperty("Achievement.Kill Unlocks")){ for(auto&[key,size]:DATA.GetProperty("Achievement.Kill Unlocks")){
//Monster-specific achievement unlocks. //Monster-specific achievement unlocks.
datafile&unlock=DATA.GetProperty(std::format("Achievement.Kill Unlocks.{}",key)); datafile&unlock=DATA.GetProperty(std::format("Achievement.Kill Unlocks.{}",key));
@ -746,7 +746,7 @@ void Monster::OnDeath(){
} }
} }
} }
} )
if(hasStrategyDeathFunction){ if(hasStrategyDeathFunction){
GameEvent::AddEvent(std::make_unique<MonsterStrategyGameEvent>(strategyDeathFunc,*this,MONSTER_DATA[name].GetAIStrategy())); GameEvent::AddEvent(std::make_unique<MonsterStrategyGameEvent>(strategyDeathFunc,*this,MONSTER_DATA[name].GetAIStrategy()));

@ -58,7 +58,7 @@ All rights reserved.
#include "Unlock.h" #include "Unlock.h"
#include "Tutorial.h" #include "Tutorial.h"
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
#include <isteamuserstats.h> #include "steam/isteamuserstats.h"
#endif #endif
INCLUDE_MONSTER_DATA INCLUDE_MONSTER_DATA
@ -1327,7 +1327,7 @@ void Player::OnLevelUp(){
stats.SetBaseStat("Attack",GetBaseStat("Attack")+atkGrowthRate); stats.SetBaseStat("Attack",GetBaseStat("Attack")+atkGrowthRate);
Heal(GetBaseStat("Health")); Heal(GetBaseStat("Health"));
if(SteamUserStats()){ STEAMUSERSTATS(
for(auto&[key,size]:DATA.GetProperty("Achievement.Class Unlocks")){ for(auto&[key,size]:DATA.GetProperty("Achievement.Class Unlocks")){
datafile&unlock=DATA.GetProperty(std::format("Achievement.Class Unlocks.{}",key)); datafile&unlock=DATA.GetProperty(std::format("Achievement.Class Unlocks.{}",key));
if(classutils::StringToClass(unlock["Class Requirement"].GetString())==GetClass()&& if(classutils::StringToClass(unlock["Class Requirement"].GetString())==GetClass()&&
@ -1337,7 +1337,7 @@ void Player::OnLevelUp(){
SteamUserStats()->StoreStats(); SteamUserStats()->StoreStats();
} }
} }
} )
} }
const uint8_t Player::LevelCap()const{ const uint8_t Player::LevelCap()const{
return levelCap; return levelCap;

@ -43,7 +43,7 @@ All rights reserved.
#include "ItemDrop.h" #include "ItemDrop.h"
#include "util.h" #include "util.h"
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
#include <isteamuserstats.h> #include "steam/isteamuserstats.h"
#endif #endif
INCLUDE_game INCLUDE_game

@ -40,8 +40,9 @@ All rights reserved.
#include "config.h" #include "config.h"
#include "olcUTIL_DataFile.h" #include "olcUTIL_DataFile.h"
#include "DEFINES.h" #include "DEFINES.h"
#include "emscripten_compat.h"
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
#include <isteamuserstats.h> #include "steam/isteamuserstats.h"
#endif #endif
INCLUDE_DATA INCLUDE_DATA
@ -57,13 +58,13 @@ void Unlock::Initialize(){
void Unlock::UnlockArea(std::string mapName){ void Unlock::UnlockArea(std::string mapName){
if(mapName=="NPCs.Sherman.Potion Crafting Unlock Condition"_S&& //When we beat the bonus chapter 1 fight, before sherman's potion crafting is unlocked, if the current map we just unlocked for is the bonus boss stage we will notify the Hub connection point and reset it so the player has a notification to go there again. if(mapName=="NPCs.Sherman.Potion Crafting Unlock Condition"_S&& //When we beat the bonus chapter 1 fight, before sherman's potion crafting is unlocked, if the current map we just unlocked for is the bonus boss stage we will notify the Hub connection point and reset it so the player has a notification to go there again.
!Unlock::IsUnlocked("NPCs.Sherman.Potion Crafting Unlock Condition"_S))State_OverworldMap::ConnectionPointFromString("HUB").value()->ResetVisitedFlag(); !Unlock::IsUnlocked("NPCs.Sherman.Potion Crafting Unlock Condition"_S))State_OverworldMap::ConnectionPointFromString("HUB").value()->ResetVisitedFlag();
if(SteamUserStats()){ STEAMUSERSTATS(
datafile&areaUnlocks=DATA.GetProperty("Achievement.Area Unlocks"); datafile&areaUnlocks=DATA.GetProperty("Achievement.Area Unlocks");
for(auto&[key,size]:areaUnlocks){ for(auto&[key,size]:areaUnlocks){
datafile&unlock = areaUnlocks[key]; datafile&unlock = areaUnlocks[key];
if(mapName==unlock["Unlock Name"].GetString())SteamUserStats()->SetAchievement(unlock["API Name"].GetString().c_str()); if(mapName==unlock["Unlock Name"].GetString())SteamUserStats()->SetAchievement(unlock["API Name"].GetString().c_str());
} }
} )
unlocks.insert(mapName); unlocks.insert(mapName);
} }
bool Unlock::IsUnlocked(std::string mapName){ bool Unlock::IsUnlocked(std::string mapName){
@ -80,7 +81,7 @@ void Unlock::UnlockCurrentMap(){
void Unlock::IncreaseKillCount(){ void Unlock::IncreaseKillCount(){
monsterKillCount++; monsterKillCount++;
if(SteamUserStats()){ STEAMUSERSTATS(
SteamUserStats()->SetStat("Achievement.Kill Unlocks.Total Kill API Name"_S.c_str(),Unlock::monsterKillCount); SteamUserStats()->SetStat("Achievement.Kill Unlocks.Total Kill API Name"_S.c_str(),Unlock::monsterKillCount);
datafile&killUnlocks=DATA.GetProperty("Achievement.Kill Unlocks"); datafile&killUnlocks=DATA.GetProperty("Achievement.Kill Unlocks");
for(auto&[key,size]:killUnlocks){ for(auto&[key,size]:killUnlocks){
@ -92,5 +93,5 @@ void Unlock::IncreaseKillCount(){
} }
} }
} }
} )
} }

@ -15,7 +15,9 @@ inline void SteamAPI_RunCallbacks(){};
#define STEAMINPUT(statement) if(false){} #define STEAMINPUT(statement) if(false){}
#define STEAMUTILS(statement) if(false){} #define STEAMUTILS(statement) if(false){}
#define STEAMUSERSTATS(statement) if(false){}
#else #else
#define STEAMINPUT(statement) if(SteamInput()){statement} #define STEAMINPUT(statement) if(SteamInput()){statement}
#define STEAMUTILS(statement) if(SteamUtils()){statement} #define STEAMUTILS(statement) if(SteamUtils()){statement}
#define STEAMUSERSTATS(statement) if(SteamUserStats()){statement}
#endif #endif

Loading…
Cancel
Save