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