diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 531a552b..f14dadb2 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -226,6 +226,9 @@ AiL::AiL() } bool AiL::OnUserCreate(){ + std::string packKey="129jvgndsaf7dsa8932hj"; + gamepack.LoadPack("assets/"+"gamepack_file"_S,packKey); + GamePad::init(); Font::init(); @@ -315,6 +318,12 @@ bool AiL::OnUserCreate(){ #endif gameInitialized=true; + + if(!gamepack.Loaded()&&"GENERATE_GAMEPACK"_B){ + gamepack.SavePack("assets/"+"gamepack_file"_S,packKey); + std::cout<<"Game Pack has been generated!"<Load(mapPath,&gamepack); + }else if(std::filesystem::exists(mapPath)){ r->Load(mapPath); + if("GENERATE_GAMEPACK"_B){ + gamepack.AddFile(mapPath); + } }else{ std::cout<<"WARNING! "<Create(tileset.GetData().imagewidth,tileset.GetData().imageheight); @@ -2307,7 +2322,7 @@ int main() std::string loadSystemFilename="save_file_path"_S+"system.conf"; vi2d windowPosConf={30,30}; - vi2d windowSizeConf=WINDOW_SIZE; + vi2d windowSizeConf=WINDOW_SIZE*4; bool fullscreenConf=false; 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)}; } +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){ AiL::OutputDebugInfo(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(); } +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){ AiL::OutputDebugInfo(key,len); return DATA.GetProperty(std::string(key,len)).GetInt(); @@ -2472,7 +2497,7 @@ void AiL::InitializeLevels(){ } if(MAP_DATA.find(cp.map)!=MAP_DATA.end()){ MAP_DATA[cp.map].name=cp.name; - + //Boss arena map zone check. if(MAP_DATA[cp.map].GetMapType()=="Boss"&&MAP_DATA[cp.map].GetZones().at("BossArena").size()==0)ERR(std::format("WARNING! Map {} doesn't have a boss arena region defined! Add an object of class BossArena to the map.",MAP_DATA[cp.map].GetMapDisplayName())); @@ -2485,7 +2510,7 @@ void AiL::InitializeLevels(){ for(auto&[key,size]:DATA["Backdrops"]){ 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(); @@ -2759,8 +2784,8 @@ void AiL::InitializeGraphics(){ if(DATA["Images"][key].GetValueCount()>2){ clamping=bool(DATA["Images"][key].GetInt(2)); } - if(!GFX.count(imgFile)&&GFX[imgFile].Load("GFX_Prefix"_S+imgFile,nullptr,filtering,clamping)!=rcode::OK){ - ERR(" WARNING! Failed to load "+imgFile+"!") + if(!GFX.count(imgFile)&&LoadResource(GFX[imgFile],"GFX_Prefix"_S+imgFile,filtering,clamping)!=rcode::OK){ + ERR(" WARNING! Failed to load "+imgFile+" from game pack!") } } @@ -2776,7 +2801,7 @@ void AiL::InitializeGraphics(){ std::string themeName=key; std::string imgPath=DATA["Themes"][themeName]["filename"].GetString(); 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; Pixel::Mode prevMode=GetPixelMode(); SetPixelMode(Pixel::Mode::MASK); @@ -2801,7 +2826,7 @@ void AiL::InitializeGraphics(){ std::cout<<" Custom background detected, Loading "<LoadResource(img,imgPath); std::string scriptName="",description="",category=""; std::string setName=""; diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt index 2b36c4af..0d9779e7 100644 --- a/Adventures in Lestoria/TODO.txt +++ b/Adventures in Lestoria/TODO.txt @@ -19,12 +19,9 @@ January 31st - 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. - Condense stage track (loading times) -- SNES mosaic effect on stage select/stage transition. - - Credits/Licensing \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 9e53d119..c3f8f4a1 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 7485 +#define VERSION_BUILD 7515 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/config/configuration.txt b/Adventures in Lestoria/assets/config/configuration.txt index c516f0ad..07ff5da0 100644 --- a/Adventures in Lestoria/assets/config/configuration.txt +++ b/Adventures in Lestoria/assets/config/configuration.txt @@ -1,5 +1,10 @@ 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. WINDOW_SIZE = 360,240 diff --git a/Adventures in Lestoria/assets/gamepack.pak b/Adventures in Lestoria/assets/gamepack.pak new file mode 100644 index 00000000..1a830b27 Binary files /dev/null and b/Adventures in Lestoria/assets/gamepack.pak differ diff --git a/Adventures in Lestoria/config.h b/Adventures in Lestoria/config.h index 355d1078..75245235 100644 --- a/Adventures in Lestoria/config.h +++ b/Adventures in Lestoria/config.h @@ -42,6 +42,8 @@ using namespace olc; //Read a string array from the config. 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. utils::datafileintdata operator ""_i(const char*key,std::size_t len); //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); //Read a full string key from the config. 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. int operator ""_I(const char*key,std::size_t len); //Read a float key from the config. diff --git a/Adventures in Lestoria/olcPixelGameEngine.h b/Adventures in Lestoria/olcPixelGameEngine.h index dd10664e..48952f7c 100644 --- a/Adventures in Lestoria/olcPixelGameEngine.h +++ b/Adventures in Lestoria/olcPixelGameEngine.h @@ -935,6 +935,7 @@ namespace olc virtual olc::rcode DestroyDevice() = 0; virtual void DisplayFrame() = 0; virtual void PrepareDrawing() = 0; + virtual void PrepareRender(int width,int height) = 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 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) { struct DecalData{ - Decal*decal; + Decal*decal=nullptr; float expireTime=0.0f; }; 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) { struct DecalData{ - Decal*decal; + Decal*decal=nullptr; float expireTime=0.0f; }; 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){ struct DecalData{ - Decal*decal; + Decal*decal=nullptr; float expireTime=0.0f; }; 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){ struct DecalData{ - Decal*decal; + Decal*decal=nullptr; float expireTime=0.0f; }; 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){ struct DecalData{ - Decal*decal; + Decal*decal=nullptr; float expireTime=0.0f; }; 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){ struct DecalData{ - Decal*decal; + Decal*decal=nullptr; float expireTime=0.0f; }; 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){ struct DecalData{ - Decal*decal; + Decal*decal=nullptr; float expireTime=0.0f; }; if(sText.length()==0)return; @@ -4784,7 +4785,7 @@ namespace olc vLayers[0].bShow = true; SetDecalMode(DecalMode::NORMAL); renderer->PrepareDrawing(); - + for (auto layer = vLayers.rbegin(); layer != vLayers.rend(); ++layer) { if (layer->bShow) @@ -4798,11 +4799,16 @@ namespace olc layer->bUpdate = false; } + renderer->PrepareRender(ScreenWidth(),ScreenHeight()); renderer->DrawLayerQuad(layer->vOffset, layer->vScale, layer->tint); // 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); + } layer->vecDecalInstance.clear(); } else @@ -4946,6 +4952,7 @@ namespace olc virtual olc::rcode DestroyDevice() { return olc::rcode::OK; } virtual void DisplayFrame() {} virtual void PrepareDrawing() {} + virtual void PrepareRender(int width,int height) {}; virtual void SetDecalMode(const olc::DecalMode& mode) {} virtual void DrawLayerQuad(const olc::vf2d& offset, const olc::vf2d& scale, const olc::Pixel tint) {} virtual void DrawDecal(const olc::DecalInstance& decal) {} @@ -5125,7 +5132,7 @@ namespace olc glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); #endif } - + void PrepareRender(int width,int height)override{}; olc::rcode CreateDevice(std::vector params, bool bFullScreen, bool bVSYNC) override { #if defined(OLC_PLATFORM_WINAPI) @@ -5754,7 +5761,7 @@ namespace olc "uniform sampler2D sprTex;\n" "void main(){\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" "pixel = texture(sprTex, outputPos*texelSize) * oCol;\n" "}"; @@ -5876,6 +5883,11 @@ namespace olc #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 { if (mode != nDecalMode) diff --git a/Adventures in Lestoria/olcUTIL_DataFile.h b/Adventures in Lestoria/olcUTIL_DataFile.h index d899a077..931bd924 100644 --- a/Adventures in Lestoria/olcUTIL_DataFile.h +++ b/Adventures in Lestoria/olcUTIL_DataFile.h @@ -536,6 +536,17 @@ namespace olc::utils return finalStr; } }; + class datafilebooldata + { + std::reference_wrapperdata; + 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 { std::reference_wrapperdata; diff --git a/Adventures in Lestoria/x64/Release Desktop/CodeAnalysisResultManifest.txt b/Adventures in Lestoria/x64/Release Desktop/CodeAnalysisResultManifest.txt index d628a824..12503301 100644 Binary files a/Adventures in Lestoria/x64/Release Desktop/CodeAnalysisResultManifest.txt and b/Adventures in Lestoria/x64/Release Desktop/CodeAnalysisResultManifest.txt differ diff --git a/CMakeLists.txt b/CMakeLists.txt index 99407cb1..068ae71b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,8 @@ set(C_CXX_HEADERS_DIR "Adventures in Lestoria") # 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!! # ########################################################################## @@ -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(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_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${C_CXX_SOURCES_DIR}) @@ -318,7 +321,7 @@ if (EMSCRIPTEN) $<$:_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( ${OutputExecutable} PRIVATE @@ -332,7 +335,7 @@ if (EMSCRIPTEN) -sEXPORTED_RUNTIME_METHODS=stringToNewUTF8 -std=c++2a --proxy-to-worker - --preload-file ${SOURCE_DATA_DIR}@assets) + --preload-file ${SOURCE_DATA_EMSCRIPTEN_DIR}@assets) else() target_link_options( ${OutputExecutable} @@ -379,14 +382,14 @@ set(DATA_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bin/${ASSETS_DIR}) set (EXCLUDE_DIR "/assets/saves/") 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}) string (FIND ${fn} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND) if (NOT ${EXCLUDE_DIR_FOUND} EQUAL -1) add_custom_command( OUTPUT ${DATA_OUTPUT_DIR}/${fn} - COMMAND ${CMAKE_COMMAND} -E copy ${SOURCE_DATA_DIR}/${fn} ${DATA_OUTPUT_DIR}/${fn} - MAIN_DEPENDENCY ${SOURCE_DATA_DIR}/${fn}) + COMMAND ${CMAKE_COMMAND} -E copy ${SOURCE_DATA_EMSCRIPTEN_DIR}/${fn} ${DATA_OUTPUT_DIR}/${fn} + MAIN_DEPENDENCY ${SOURCE_DATA_EMSCRIPTEN_DIR}/${fn}) list(APPEND out_data_files ${DATA_OUTPUT_DIR}/${fn}) endif() endforeach() diff --git a/distribute.ps1 b/distribute.ps1 new file mode 100644 index 00000000..0093a8f5 --- /dev/null +++ b/distribute.ps1 @@ -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 \ No newline at end of file diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 64edc953..fc006d27 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ