@ -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 ( ) ;
@ -2472,7 +2497,7 @@ void AiL::InitializeLevels(){
}
}
if ( MAP_DATA . find ( cp . map ) ! = MAP_DATA . end ( ) ) {
if ( MAP_DATA . find ( cp . map ) ! = MAP_DATA . end ( ) ) {
MAP_DATA [ cp . map ] . name = cp . name ;
MAP_DATA [ cp . map ] . name = cp . name ;
//Boss arena map zone check.
//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 ( ) ) ) ;
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 " ] ) {
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 ;
@ -3306,4 +3331,17 @@ 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 ;
}
}