Added resource pack loading for sensitive commercial assets (direct inclusion for builds). Fixed bug with brand new settings loading the original window at 1/4 the normal size. Fixed bug with reading system configuration when no system configuration exists yet. Fixed bug with emscripten build mosaic effect shader not working (unsupported textureSize glsl call). Release Build 7515.

pull/35/head
sigonasr2 9 months ago
parent 0fc117235a
commit f9e00caaa4
  1. 52
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 2
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 2
      Adventures in Lestoria/GameSettings.cpp
  4. 2
      Adventures in Lestoria/Item.cpp
  5. 3
      Adventures in Lestoria/TODO.txt
  6. 2
      Adventures in Lestoria/Version.h
  7. 5
      Adventures in Lestoria/assets/config/configuration.txt
  8. 4
      Adventures in Lestoria/config.h
  9. 32
      Adventures in Lestoria/olcPixelGameEngine.h
  10. 11
      Adventures in Lestoria/olcUTIL_DataFile.h
  11. BIN
      Adventures in Lestoria/x64/Release Desktop/CodeAnalysisResultManifest.txt
  12. 13
      CMakeLists.txt
  13. 15
      distribute.ps1
  14. BIN
      x64/Release/Adventures in Lestoria.exe

@ -226,6 +226,9 @@ AiL::AiL()
} }
bool AiL::OnUserCreate(){ bool AiL::OnUserCreate(){
std::string packKey="129jvgndsaf7dsa8932hj";
gamepack.LoadPack("assets/"+"gamepack_file"_S,packKey);
GamePad::init(); GamePad::init();
Font::init(); Font::init();
@ -315,6 +318,12 @@ bool AiL::OnUserCreate(){
#endif #endif
gameInitialized=true; gameInitialized=true;
if(!gamepack.Loaded()&&"GENERATE_GAMEPACK"_B){
gamepack.SavePack("assets/"+"gamepack_file"_S,packKey);
std::cout<<"Game Pack has been generated!"<<std::endl<<"========================"<<std::endl<<std::endl;
}
return true; return true;
} }
@ -1726,8 +1735,14 @@ void AiL::InitializeLevel(std::string mapFile,MapName map){
MAP_TILESETS["assets/maps/"+baseSourceDir].isTerrain=tileset.GetData().isTerrain; MAP_TILESETS["assets/maps/"+baseSourceDir].isTerrain=tileset.GetData().isTerrain;
std::cout<<"assets/maps/"+baseSourceDir<<" Animation Data Size: "<<MAP_TILESETS["assets/maps/"+baseSourceDir].animationData.size()<<std::endl; std::cout<<"assets/maps/"+baseSourceDir<<" Animation Data Size: "<<MAP_TILESETS["assets/maps/"+baseSourceDir].animationData.size()<<std::endl;
std::string mapPath="assets/maps/"+tileset.GetData().ImageData.data["source"]; std::string mapPath="assets/maps/"+tileset.GetData().ImageData.data["source"];
if(gamepack.Loaded()){
r->Load(mapPath,&gamepack);
}else
if(std::filesystem::exists(mapPath)){ if(std::filesystem::exists(mapPath)){
r->Load(mapPath); r->Load(mapPath);
if("GENERATE_GAMEPACK"_B){
gamepack.AddFile(mapPath);
}
}else{ }else{
std::cout<<"WARNING! "<<mapPath<<" does not exist, auto-generating mock-up texture"<<std::endl; std::cout<<"WARNING! "<<mapPath<<" does not exist, auto-generating mock-up texture"<<std::endl;
r->Create(tileset.GetData().imagewidth,tileset.GetData().imageheight); r->Create(tileset.GetData().imagewidth,tileset.GetData().imageheight);
@ -2307,7 +2322,7 @@ int main()
std::string loadSystemFilename="save_file_path"_S+"system.conf"; std::string loadSystemFilename="save_file_path"_S+"system.conf";
vi2d windowPosConf={30,30}; vi2d windowPosConf={30,30};
vi2d windowSizeConf=WINDOW_SIZE; vi2d windowSizeConf=WINDOW_SIZE*4;
bool fullscreenConf=false; bool fullscreenConf=false;
if(std::filesystem::exists(loadSystemFilename)){ if(std::filesystem::exists(loadSystemFilename)){
@ -2365,6 +2380,11 @@ datafilestringdata operator ""_s(const char*key,std::size_t len){
return {DATA,std::string(key,len)}; return {DATA,std::string(key,len)};
} }
datafilebooldata operator ""_b(const char*key,std::size_t len){
AiL::OutputDebugInfo(key,len);
return {DATA,std::string(key,len)};
}
datafileintdata operator ""_i(const char*key,std::size_t len){ datafileintdata operator ""_i(const char*key,std::size_t len){
AiL::OutputDebugInfo(key,len); AiL::OutputDebugInfo(key,len);
return {DATA,std::string(key,len)}; return {DATA,std::string(key,len)};
@ -2390,6 +2410,11 @@ std::string operator ""_S(const char*key,std::size_t len){
return DATA.GetProperty(std::string(key,len)).GetString(); return DATA.GetProperty(std::string(key,len)).GetString();
} }
bool operator ""_B(const char*key,std::size_t len){
AiL::OutputDebugInfo(key,len);
return DATA.GetProperty(std::string(key,len)).GetBool();
}
int operator ""_I(const char*key,std::size_t len){ int operator ""_I(const char*key,std::size_t len){
AiL::OutputDebugInfo(key,len); AiL::OutputDebugInfo(key,len);
return DATA.GetProperty(std::string(key,len)).GetInt(); return DATA.GetProperty(std::string(key,len)).GetInt();
@ -2485,7 +2510,7 @@ void AiL::InitializeLevels(){
for(auto&[key,size]:DATA["Backdrops"]){ for(auto&[key,size]:DATA["Backdrops"]){
Renderable&backdrop=BACKDROP_DATA[key]; Renderable&backdrop=BACKDROP_DATA[key];
backdrop.Load("backdrop_directory"_S+DATA["Backdrops"][key].GetString(),nullptr,false,false); LoadResource(backdrop,"backdrop_directory"_S+DATA["Backdrops"][key].GetString(),false,false);
} }
Test::RunMapTests(); Test::RunMapTests();
@ -2759,8 +2784,8 @@ void AiL::InitializeGraphics(){
if(DATA["Images"][key].GetValueCount()>2){ if(DATA["Images"][key].GetValueCount()>2){
clamping=bool(DATA["Images"][key].GetInt(2)); clamping=bool(DATA["Images"][key].GetInt(2));
} }
if(!GFX.count(imgFile)&&GFX[imgFile].Load("GFX_Prefix"_S+imgFile,nullptr,filtering,clamping)!=rcode::OK){ if(!GFX.count(imgFile)&&LoadResource(GFX[imgFile],"GFX_Prefix"_S+imgFile,filtering,clamping)!=rcode::OK){
ERR(" WARNING! Failed to load "+imgFile+"!") ERR(" WARNING! Failed to load "+imgFile+" from game pack!")
} }
} }
@ -2776,7 +2801,7 @@ void AiL::InitializeGraphics(){
std::string themeName=key; std::string themeName=key;
std::string imgPath=DATA["Themes"][themeName]["filename"].GetString(); std::string imgPath=DATA["Themes"][themeName]["filename"].GetString();
Renderable&img=GFX["theme_img_directory"_S+imgPath+".png"]; Renderable&img=GFX["theme_img_directory"_S+imgPath+".png"];
img.Load("GFX_Prefix"_S+"theme_img_directory"_S+imgPath+".png"); LoadResource(img,"GFX_Prefix"_S+"theme_img_directory"_S+imgPath+".png");
Renderable&sourceImg=img; Renderable&sourceImg=img;
Pixel::Mode prevMode=GetPixelMode(); Pixel::Mode prevMode=GetPixelMode();
SetPixelMode(Pixel::Mode::MASK); SetPixelMode(Pixel::Mode::MASK);
@ -2801,7 +2826,7 @@ void AiL::InitializeGraphics(){
std::cout<<" Custom background detected, Loading "<<backPath<<"..."<<std::endl; std::cout<<" Custom background detected, Loading "<<backPath<<"..."<<std::endl;
if(!GFX.count(backPath)){ if(!GFX.count(backPath)){
Renderable&background=GFX[backPath]; Renderable&background=GFX[backPath];
background.Load("GFX_Prefix"_S+backPath,nullptr,false,false); LoadResource(background,"GFX_Prefix"_S+backPath,false,false);
} }
Menu::themes[themeName]=Theme{themeName,imgPath,bool(DATA["Themes"][themeName]["Tiled"].GetInt()),DATA["Themes"][themeName]["ButtonColor"].GetPixel(),DATA["Themes"][themeName]["HighlightColor"].GetPixel(),GFX.at(backPath).Decal()}; Menu::themes[themeName]=Theme{themeName,imgPath,bool(DATA["Themes"][themeName]["Tiled"].GetInt()),DATA["Themes"][themeName]["ButtonColor"].GetPixel(),DATA["Themes"][themeName]["HighlightColor"].GetPixel(),GFX.at(backPath).Decal()};
}else{ }else{
@ -2811,7 +2836,7 @@ void AiL::InitializeGraphics(){
for(std::string img:VisualNovel::graphicsToLoad){ for(std::string img:VisualNovel::graphicsToLoad){
Renderable&image=GFX[img]; Renderable&image=GFX[img];
image.Load("GFX_Prefix"_S+img); LoadResource(image,"GFX_Prefix"_S+img);
} }
std::cout<<VisualNovel::graphicsToLoad.size()<<" images for visual novel engine have been loaded."<<std::endl; std::cout<<VisualNovel::graphicsToLoad.size()<<" images for visual novel engine have been loaded."<<std::endl;
@ -3307,3 +3332,16 @@ const float AiL::LastMouseMovement()const{
const bool AiL::GameInitialized()const { const bool AiL::GameInitialized()const {
return gameInitialized; return gameInitialized;
} }
rcode AiL::LoadResource(Renderable&renderable,std::string_view imgPath,bool filter,bool clamp){
rcode returnCode;
if(gamepack.Loaded()){
returnCode=renderable.Load(std::string(imgPath),&gamepack);
}else{
returnCode=renderable.Load(std::string(imgPath));
if("GENERATE_GAMEPACK"_B){
gamepack.AddFile(std::string(imgPath));
}
}
return returnCode;
}

@ -166,6 +166,7 @@ private:
vi2d lastMousePos={}; vi2d lastMousePos={};
bool paused=false; bool paused=false;
bool gameInitialized=false; bool gameInitialized=false;
ResourcePack gamepack;
void ValidateGameStatus(); void ValidateGameStatus();
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
@ -288,6 +289,7 @@ public:
void PauseGame(); void PauseGame();
void ResumeGame(); void ResumeGame();
const bool GameInitialized()const; const bool GameInitialized()const;
rcode LoadResource(Renderable&renderable,std::string_view imgPath,bool filter=false,bool clamp=true);
struct TileGroupData{ struct TileGroupData{
vi2d tilePos; vi2d tilePos;

@ -95,7 +95,7 @@ void GameSettings::Initialize(){
std::string loadSystemFilename="save_file_path"_S+"system.conf"; std::string loadSystemFilename="save_file_path"_S+"system.conf";
utils::datafile::Read(loadSystemFile,loadSystemFilename); if(std::filesystem::exists(loadSystemFilename))utils::datafile::Read(loadSystemFile,loadSystemFilename);
if(loadSystemFile.HasProperty("Screen Shake")){ if(loadSystemFile.HasProperty("Screen Shake")){
GameSettings::SetScreenShake(loadSystemFile["Screen Shake"].GetBool()); GameSettings::SetScreenShake(loadSystemFile["Screen Shake"].GetBool());

@ -111,7 +111,7 @@ void ItemInfo::InitializeItems(){
if(key=="")ERR("Failed to read an item block ,no name specified!"); if(key=="")ERR("Failed to read an item block ,no name specified!");
std::string imgPath="assets/"+"item_img_directory"_S+key+".png"; std::string imgPath="assets/"+"item_img_directory"_S+key+".png";
Renderable&img=GFX["item_img_directory"_S+key+".png"]; Renderable&img=GFX["item_img_directory"_S+key+".png"];
img.Load(imgPath); game->LoadResource(img,imgPath);
std::string scriptName="",description="",category=""; std::string scriptName="",description="",category="";
std::string setName=""; std::string setName="";

@ -19,12 +19,9 @@ January 31st
- Hide mouse cursor during controller play. Reveal it again during mouse play. - Hide mouse cursor during controller play. Reveal it again during mouse play.
- Resource Packs
- Auto aim causes retreat-type moves to aim away from the auto target, and prefer the direction the player's moving in. - Auto aim causes retreat-type moves to aim away from the auto target, and prefer the direction the player's moving in.
- Condense stage track (loading times) - Condense stage track (loading times)
- SNES mosaic effect on stage select/stage transition.
- Credits/Licensing - Credits/Licensing

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 3 #define VERSION_MINOR 3
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 7485 #define VERSION_BUILD 7515
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -1,5 +1,10 @@
config_path = assets/config/ config_path = assets/config/
gamepack_file = gamepack.pak
# Once assets are loaded, a gamepack will be generated with the included resources.
GENERATE_GAMEPACK = True
# 360x240 is 15x10 tiles of visibility. # 360x240 is 15x10 tiles of visibility.
WINDOW_SIZE = 360,240 WINDOW_SIZE = 360,240

@ -42,6 +42,8 @@ using namespace olc;
//Read a string array from the config. //Read a string array from the config.
utils::datafilestringdata operator ""_s(const char*key,std::size_t len); utils::datafilestringdata operator ""_s(const char*key,std::size_t len);
//Read a boolean array from the config.
utils::datafilebooldata operator ""_b(const char*key,std::size_t len);
//Read an int array from the config. //Read an int array from the config.
utils::datafileintdata operator ""_i(const char*key,std::size_t len); utils::datafileintdata operator ""_i(const char*key,std::size_t len);
//Read a float array from the config. //Read a float array from the config.
@ -52,6 +54,8 @@ utils::datafiledoubledata operator ""_d(const char*key,std::size_t len);
std::string operator ""_S(const char*key,std::size_t len); std::string operator ""_S(const char*key,std::size_t len);
//Read a full string key from the config. //Read a full string key from the config.
std::string operator ""_FS(const char*key,std::size_t len); std::string operator ""_FS(const char*key,std::size_t len);
//Read a boolean key from the config.
bool operator ""_B(const char*key,std::size_t len);
//Read an integer key from the config. //Read an integer key from the config.
int operator ""_I(const char*key,std::size_t len); int operator ""_I(const char*key,std::size_t len);
//Read a float key from the config. //Read a float key from the config.

@ -935,6 +935,7 @@ namespace olc
virtual olc::rcode DestroyDevice() = 0; virtual olc::rcode DestroyDevice() = 0;
virtual void DisplayFrame() = 0; virtual void DisplayFrame() = 0;
virtual void PrepareDrawing() = 0; virtual void PrepareDrawing() = 0;
virtual void PrepareRender(int width,int height) = 0;
virtual void SetDecalMode(const olc::DecalMode& mode) = 0; virtual void SetDecalMode(const olc::DecalMode& mode) = 0;
virtual void DrawLayerQuad(const olc::vf2d& offset, const olc::vf2d& scale, const olc::Pixel tint) = 0; virtual void DrawLayerQuad(const olc::vf2d& offset, const olc::vf2d& scale, const olc::Pixel tint) = 0;
virtual void DrawDecal(const olc::DecalInstance& decal) = 0; virtual void DrawDecal(const olc::DecalInstance& decal) = 0;
@ -3432,7 +3433,7 @@ namespace olc
void PixelGameEngine::DrawStringDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const olc::vf2d& scale,const float width,const bool disableDynamicScaling) void PixelGameEngine::DrawStringDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const olc::vf2d& scale,const float width,const bool disableDynamicScaling)
{ {
struct DecalData{ struct DecalData{
Decal*decal; Decal*decal=nullptr;
float expireTime=0.0f; float expireTime=0.0f;
}; };
if(sText.length()==0)return; if(sText.length()==0)return;
@ -3466,7 +3467,7 @@ namespace olc
void PixelGameEngine::DrawStringPropDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const olc::vf2d& scale, const float width,const bool disableDynamicScaling) void PixelGameEngine::DrawStringPropDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const olc::vf2d& scale, const float width,const bool disableDynamicScaling)
{ {
struct DecalData{ struct DecalData{
Decal*decal; Decal*decal=nullptr;
float expireTime=0.0f; float expireTime=0.0f;
}; };
if(sText.length()==0)return; if(sText.length()==0)return;
@ -3499,7 +3500,7 @@ namespace olc
void PixelGameEngine::DrawShadowStringDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float width,const float shadowSizeFactor,const bool disableDynamicScaling){ void PixelGameEngine::DrawShadowStringDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float width,const float shadowSizeFactor,const bool disableDynamicScaling){
struct DecalData{ struct DecalData{
Decal*decal; Decal*decal=nullptr;
float expireTime=0.0f; float expireTime=0.0f;
}; };
if(sText.length()==0)return; if(sText.length()==0)return;
@ -3547,7 +3548,7 @@ namespace olc
void PixelGameEngine::DrawStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col, const olc::vf2d& scale){ void PixelGameEngine::DrawStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col, const olc::vf2d& scale){
struct DecalData{ struct DecalData{
Decal*decal; Decal*decal=nullptr;
float expireTime=0.0f; float expireTime=0.0f;
}; };
if(sText.length()==0)return; if(sText.length()==0)return;
@ -3569,7 +3570,7 @@ namespace olc
void PixelGameEngine::DrawShadowStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ void PixelGameEngine::DrawShadowStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){
struct DecalData{ struct DecalData{
Decal*decal; Decal*decal=nullptr;
float expireTime=0.0f; float expireTime=0.0f;
}; };
if(sText.length()==0)return; if(sText.length()==0)return;
@ -3598,7 +3599,7 @@ namespace olc
void PixelGameEngine::DrawDropShadowStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale){ void PixelGameEngine::DrawDropShadowStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale){
struct DecalData{ struct DecalData{
Decal*decal; Decal*decal=nullptr;
float expireTime=0.0f; float expireTime=0.0f;
}; };
if(sText.length()==0)return; if(sText.length()==0)return;
@ -3623,7 +3624,7 @@ namespace olc
void PixelGameEngine::DrawShadowStringPropDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float width,const float shadowSizeFactor,const bool disableDynamicScaling){ void PixelGameEngine::DrawShadowStringPropDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float width,const float shadowSizeFactor,const bool disableDynamicScaling){
struct DecalData{ struct DecalData{
Decal*decal; Decal*decal=nullptr;
float expireTime=0.0f; float expireTime=0.0f;
}; };
if(sText.length()==0)return; if(sText.length()==0)return;
@ -4798,11 +4799,16 @@ namespace olc
layer->bUpdate = false; layer->bUpdate = false;
} }
renderer->PrepareRender(ScreenWidth(),ScreenHeight());
renderer->DrawLayerQuad(layer->vOffset, layer->vScale, layer->tint); renderer->DrawLayerQuad(layer->vOffset, layer->vScale, layer->tint);
// Display Decals in order for this layer // Display Decals in order for this layer
for (auto& decal : layer->vecDecalInstance) for (auto& decal : layer->vecDecalInstance){
if(decal.decal!=nullptr){
renderer->PrepareRender(decal.decal->sprite->width,decal.decal->sprite->height);
}
renderer->DrawDecal(decal); renderer->DrawDecal(decal);
}
layer->vecDecalInstance.clear(); layer->vecDecalInstance.clear();
} }
else else
@ -4946,6 +4952,7 @@ namespace olc
virtual olc::rcode DestroyDevice() { return olc::rcode::OK; } virtual olc::rcode DestroyDevice() { return olc::rcode::OK; }
virtual void DisplayFrame() {} virtual void DisplayFrame() {}
virtual void PrepareDrawing() {} virtual void PrepareDrawing() {}
virtual void PrepareRender(int width,int height) {};
virtual void SetDecalMode(const olc::DecalMode& mode) {} virtual void SetDecalMode(const olc::DecalMode& mode) {}
virtual void DrawLayerQuad(const olc::vf2d& offset, const olc::vf2d& scale, const olc::Pixel tint) {} virtual void DrawLayerQuad(const olc::vf2d& offset, const olc::vf2d& scale, const olc::Pixel tint) {}
virtual void DrawDecal(const olc::DecalInstance& decal) {} virtual void DrawDecal(const olc::DecalInstance& decal) {}
@ -5125,7 +5132,7 @@ namespace olc
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
#endif #endif
} }
void PrepareRender(int width,int height)override{};
olc::rcode CreateDevice(std::vector<void*> params, bool bFullScreen, bool bVSYNC) override olc::rcode CreateDevice(std::vector<void*> params, bool bFullScreen, bool bVSYNC) override
{ {
#if defined(OLC_PLATFORM_WINAPI) #if defined(OLC_PLATFORM_WINAPI)
@ -5754,7 +5761,7 @@ namespace olc
"uniform sampler2D sprTex;\n" "uniform sampler2D sprTex;\n"
"void main(){\n" "void main(){\n"
"if(mosaic<=1){pixel = texture(sprTex,oTex) * oCol;return;}\n" "if(mosaic<=1){pixel = texture(sprTex,oTex) * oCol;return;}\n"
"vec2 texelSize = 1.0 / textureSize(sprTex,0); \n" "vec2 texelSize = 1.0 / size; \n"
"vec2 pos = oTex / texelSize; \n""vec2 outputPos = vec2(floor(pos.x/float(mosaic))*float(mosaic),floor(pos.y/float(mosaic))*float(mosaic));\n" "vec2 pos = oTex / texelSize; \n""vec2 outputPos = vec2(floor(pos.x/float(mosaic))*float(mosaic),floor(pos.y/float(mosaic))*float(mosaic));\n"
"pixel = texture(sprTex, outputPos*texelSize) * oCol;\n" "pixel = texture(sprTex, outputPos*texelSize) * oCol;\n"
"}"; "}";
@ -5876,6 +5883,11 @@ namespace olc
#endif #endif
} }
void PrepareRender(int width,int height)override{
GLint sizeUniformLoc = locGetUniformLocation(m_nQuadShader, "size");
locUniform2f(sizeUniformLoc,width,height);
}
void SetDecalMode(const olc::DecalMode& mode) override void SetDecalMode(const olc::DecalMode& mode) override
{ {
if (mode != nDecalMode) if (mode != nDecalMode)

@ -536,6 +536,17 @@ namespace olc::utils
return finalStr; return finalStr;
} }
}; };
class datafilebooldata
{
std::reference_wrapper<datafile>data;
std::string key;
public:
inline datafilebooldata(datafile&dat,std::string key)
:data(dat),key(key){};
int operator[](int index){
return data.get().GetProperty(key).GetBool(index);
};
};
class datafileintdata class datafileintdata
{ {
std::reference_wrapper<datafile>data; std::reference_wrapper<datafile>data;

@ -40,6 +40,8 @@ set(C_CXX_HEADERS_DIR "Adventures in Lestoria")
# #
set(ASSETS_DIR "Adventures in Lestoria/assets") set(ASSETS_DIR "Adventures in Lestoria/assets")
set(ASSETS_EMSCRIPTEN_DIR "bin/assets")
########################################################################## ##########################################################################
# DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!! # # DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!! #
########################################################################## ##########################################################################
@ -78,6 +80,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/bin")
set(SOURCE_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${ASSETS_DIR}) set(SOURCE_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${ASSETS_DIR})
set(SOURCE_DATA_EMSCRIPTEN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${ASSETS_EMSCRIPTEN_DIR})
set(SOURCE_CXX_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${C_CXX_HEADERS_DIR}) set(SOURCE_CXX_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${C_CXX_HEADERS_DIR})
set(SOURCE_CXX_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${C_CXX_SOURCES_DIR}) set(SOURCE_CXX_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${C_CXX_SOURCES_DIR})
@ -318,7 +321,7 @@ if (EMSCRIPTEN)
$<$<CONFIG:Debug>:_DEBUG> $<$<CONFIG:Debug>:_DEBUG>
) )
if(EXISTS "${SOURCE_DATA_DIR}" AND IS_DIRECTORY "${SOURCE_DATA_DIR}") if(EXISTS "${SOURCE_DATA_EMSCRIPTEN_DIR}" AND IS_DIRECTORY "${SOURCE_DATA_EMSCRIPTEN_DIR}")
target_link_options( target_link_options(
${OutputExecutable} ${OutputExecutable}
PRIVATE PRIVATE
@ -332,7 +335,7 @@ if (EMSCRIPTEN)
-sEXPORTED_RUNTIME_METHODS=stringToNewUTF8 -sEXPORTED_RUNTIME_METHODS=stringToNewUTF8
-std=c++2a -std=c++2a
--proxy-to-worker --proxy-to-worker
--preload-file ${SOURCE_DATA_DIR}@assets) --preload-file ${SOURCE_DATA_EMSCRIPTEN_DIR}@assets)
else() else()
target_link_options( target_link_options(
${OutputExecutable} ${OutputExecutable}
@ -379,14 +382,14 @@ set(DATA_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bin/${ASSETS_DIR})
set (EXCLUDE_DIR "/assets/saves/") set (EXCLUDE_DIR "/assets/saves/")
file(GLOB_RECURSE src_data_files file(GLOB_RECURSE src_data_files
RELATIVE ${SOURCE_DATA_DIR}/ "${SOURCE_DATA_DIR}/*.*" "${SOURCE_DATA_DIR}/*") RELATIVE ${SOURCE_DATA_EMSCRIPTEN_DIR}/ "${SOURCE_DATA_EMSCRIPTEN_DIR}/*.*" "${SOURCE_DATA_EMSCRIPTEN_DIR}/*")
foreach(fn ${src_data_files}) foreach(fn ${src_data_files})
string (FIND ${fn} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND) string (FIND ${fn} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND)
if (NOT ${EXCLUDE_DIR_FOUND} EQUAL -1) if (NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
add_custom_command( add_custom_command(
OUTPUT ${DATA_OUTPUT_DIR}/${fn} OUTPUT ${DATA_OUTPUT_DIR}/${fn}
COMMAND ${CMAKE_COMMAND} -E copy ${SOURCE_DATA_DIR}/${fn} ${DATA_OUTPUT_DIR}/${fn} COMMAND ${CMAKE_COMMAND} -E copy ${SOURCE_DATA_EMSCRIPTEN_DIR}/${fn} ${DATA_OUTPUT_DIR}/${fn}
MAIN_DEPENDENCY ${SOURCE_DATA_DIR}/${fn}) MAIN_DEPENDENCY ${SOURCE_DATA_EMSCRIPTEN_DIR}/${fn})
list(APPEND out_data_files ${DATA_OUTPUT_DIR}/${fn}) list(APPEND out_data_files ${DATA_OUTPUT_DIR}/${fn})
endif() endif()
endforeach() endforeach()

@ -0,0 +1,15 @@
mkdir bin
mkdir bin/assets
cp -R "Adventures in Lestoria/assets/Campaigns" bin/assets
cp -R "Adventures in Lestoria/assets/config" bin/assets
cp -R "Adventures in Lestoria/assets/maps" bin/assets
rm -R bin/assets/maps/commercial_assets
cp -R "Adventures in Lestoria/assets/monsters" bin/assets
cp -R "Adventures in Lestoria/assets/music" bin/assets
cp -R "Adventures in Lestoria/assets/npcs" bin/assets
cp -R "Adventures in Lestoria/assets/sounds" bin/assets
cp -R "Adventures in Lestoria/assets/gamepack.pak" bin/assets
cp -R "x64/Release/*" bin
rm bin/*.pdb
Loading…
Cancel
Save