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. 54
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 2
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 4
      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. 34
      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(){
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!"<<std::endl<<"========================"<<std::endl<<std::endl;
}
return true;
}
@ -1726,8 +1735,14 @@ void AiL::InitializeLevel(std::string mapFile,MapName map){
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::string mapPath="assets/maps/"+tileset.GetData().ImageData.data["source"];
if(gamepack.Loaded()){
r->Load(mapPath,&gamepack);
}else
if(std::filesystem::exists(mapPath)){
r->Load(mapPath);
if("GENERATE_GAMEPACK"_B){
gamepack.AddFile(mapPath);
}
}else{
std::cout<<"WARNING! "<<mapPath<<" does not exist, auto-generating mock-up texture"<<std::endl;
r->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 "<<backPath<<"..."<<std::endl;
if(!GFX.count(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()};
}else{
@ -2811,7 +2836,7 @@ void AiL::InitializeGraphics(){
for(std::string img:VisualNovel::graphicsToLoad){
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;
@ -3306,4 +3331,17 @@ const float AiL::LastMouseMovement()const{
const bool AiL::GameInitialized()const {
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={};
bool paused=false;
bool gameInitialized=false;
ResourcePack gamepack;
void ValidateGameStatus();
#ifndef __EMSCRIPTEN__
@ -288,6 +289,7 @@ public:
void PauseGame();
void ResumeGame();
const bool GameInitialized()const;
rcode LoadResource(Renderable&renderable,std::string_view imgPath,bool filter=false,bool clamp=true);
struct TileGroupData{
vi2d tilePos;

@ -94,8 +94,8 @@ void GameSettings::Initialize(){
utils::datafile loadSystemFile;
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")){
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!");
std::string imgPath="assets/"+"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 setName="";

@ -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

@ -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

@ -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

@ -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.

@ -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<void*> 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)

@ -536,6 +536,17 @@ namespace olc::utils
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
{
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_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)
$<$<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(
${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()

@ -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