@ -1,4 +1,3 @@
# define OLC_PGE_HEADLESS
# define OLC_PGE_APPLICATION
# define OLC_PGE_APPLICATION
# include "olcPixelGameEngine.h"
# include "olcPixelGameEngine.h"
# define OLC_PGEX_QUICKGUI
# define OLC_PGEX_QUICKGUI
@ -17,15 +16,13 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
struct ItemData {
struct ItemData {
std : : string name ;
std : : string name ;
Pixel borderCol ;
Pixel borderCol ;
vi2d tilesheetPos = { 0 , 0 } ;
std : : pair < std : : string , int > img ;
std : : pair < std : : string , int > img ;
std : : pair < std : : string , int > grade ;
std : : pair < std : : string , int > grade ;
void DrawIcon ( PixelGameEngine * pge , vf2d pos ) {
void DrawIcon ( PixelGameEngine * pge , vf2d pos ) {
Renderable * r = FilePathToImage [ img . first ] ;
Renderable * r = FilePathToImage [ img . first ] ;
tilesheetPos = { img . second % 7 , img . second / 7 } ;
pge - > DrawPartialDecal ( pos , { 32 , 32 } , r - > Decal ( ) , vi2d { img . second % 8 , img . second / 8 } * 32 , { 32 , 32 } ) ;
pge - > DrawPartialDecal ( pos , { 32 , 32 } , r - > Decal ( ) , tilesheetPos * 32 , { 32 , 32 } ) ;
if ( grade . first ! = " - " ) {
if ( grade . first ! = " - " ) {
pge - > DrawPartialDecal ( pos , FiestaCraftingCalculator : : GradeIcons . Decal ( ) , vi2d { grade . second % 7 , grade . second / 7 } * 32 , { 32 , 32 } ) ;
pge - > DrawPartialDecal ( pos , FiestaCraftingCalculator : : GradeIcons . Decal ( ) , vi2d { grade . second % 8 , grade . second / 8 } * 32 , { 32 , 32 } ) ;
}
}
pge - > DrawRectDecal ( pos , { 32 , 32 } , borderCol ) ;
pge - > DrawRectDecal ( pos , { 32 , 32 } , borderCol ) ;
}
}
@ -47,10 +44,16 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
ProduceIndex = data [ 1 ] ;
ProduceIndex = data [ 1 ] ;
DisplayName = data [ 2 ] ;
DisplayName = data [ 2 ] ;
Product = data [ 3 ] ;
Product = data [ 3 ] ;
if ( IDToName . find ( Product ) = = IDToName . end ( ) ) {
IDToName [ Product ] = ItemData ( ) ;
}
amt = stoi ( data [ 4 ] ) ;
amt = stoi ( data [ 4 ] ) ;
for ( int i = 5 ; i < = 20 ; i + = 2 ) {
for ( int i = 5 ; i < = 20 ; i + = 2 ) {
if ( data [ i ] . size ( ) > 1 ) {
if ( data [ i ] . size ( ) > 1 ) {
requiredItems . push_back ( { data [ i ] , stoi ( data [ i + 1 ] ) } ) ;
requiredItems . push_back ( { data [ i ] , stoi ( data [ i + 1 ] ) } ) ;
if ( IDToName . find ( data [ i ] ) = = IDToName . end ( ) ) {
IDToName [ data [ i ] ] = ItemData ( ) ;
}
}
}
}
}
expGained = stoi ( data [ 22 ] ) ;
expGained = stoi ( data [ 22 ] ) ;
@ -86,11 +89,11 @@ class FiestaCraftingCalculator : public olc::PixelGameEngine
static bool disabledAllCalculators ;
static bool disabledAllCalculators ;
public :
public :
Calculator ( ) {
Calculator ( ) {
PotionProd = new ImageCheckBox ( manager , FiestaCraftingCalculator : : ProdIcon , false , displayPos + vi2d { 10 , 10 } , { 40 , 40 } , { 192 , 128 } , { 32 , 32 } ) ;
PotionProd = new ImageCheckBox ( manager , FiestaCraftingCalculator : : Production Icons , false , displayPos + vi2d { 10 , 10 } , { 40 , 40 } , { 192 , 128 } , { 32 , 32 } ) ;
StoneProd = new ImageCheckBox ( manager , FiestaCraftingCalculator : : ProdIcon , false , displayPos + vi2d { 55 , 10 } , { 40 , 40 } , { 0 , 160 } , { 32 , 32 } ) ;
StoneProd = new ImageCheckBox ( manager , FiestaCraftingCalculator : : Production Icons , false , displayPos + vi2d { 55 , 10 } , { 40 , 40 } , { 0 , 160 } , { 32 , 32 } ) ;
ScrollProd = new ImageCheckBox ( manager , FiestaCraftingCalculator : : ProdIcon , false , displayPos + vi2d { 100 , 10 } , { 40 , 40 } , { 224 , 128 } , { 32 , 32 } ) ;
ScrollProd = new ImageCheckBox ( manager , FiestaCraftingCalculator : : Production Icons , false , displayPos + vi2d { 100 , 10 } , { 40 , 40 } , { 224 , 128 } , { 32 , 32 } ) ;
CompProd = new ImageCheckBox ( manager , FiestaCraftingCalculator : : ProdIcon , false , displayPos + vi2d { 145 , 10 } , { 40 , 40 } , { 96 , 160 } , { 32 , 32 } ) ;
CompProd = new ImageCheckBox ( manager , FiestaCraftingCalculator : : Production Icons , false , displayPos + vi2d { 145 , 10 } , { 40 , 40 } , { 96 , 160 } , { 32 , 32 } ) ;
DecompProd = new ImageCheckBox ( manager , FiestaCraftingCalculator : : ProdIcon , false , displayPos + vi2d { 190 , 10 } , { 40 , 40 } , { 64 , 160 } , { 32 , 32 } ) ;
DecompProd = new ImageCheckBox ( manager , FiestaCraftingCalculator : : Production Icons , false , displayPos + vi2d { 190 , 10 } , { 40 , 40 } , { 64 , 160 } , { 32 , 32 } ) ;
CloseButton = new CustomButton ( manager , FiestaCraftingCalculator : : CloseIcon , FiestaCraftingCalculator : : CloseBackIcon , displayPos + vf2d { PANEL_WIDTH - 30.f , 0 } , { 26 , 26 } , { 0 , 0 } , { 26 , 26 } ) ;
CloseButton = new CustomButton ( manager , FiestaCraftingCalculator : : CloseIcon , FiestaCraftingCalculator : : CloseBackIcon , displayPos + vf2d { PANEL_WIDTH - 30.f , 0 } , { 26 , 26 } , { 0 , 0 } , { 26 , 26 } ) ;
RecipeList = new ListBox ( manager , recipeItems , displayPos + vi2d { 10 , 90 } , { 300 , 140 } , 16 ) ;
RecipeList = new ListBox ( manager , recipeItems , displayPos + vi2d { 10 , 90 } , { 300 , 140 } , 16 ) ;
Amount = new TextBox ( manager , " 1 " , displayPos + vi2d { 356 , 10 } , { 68 , 24 } , { 2 , 2 } ) ;
Amount = new TextBox ( manager , " 1 " , displayPos + vi2d { 356 , 10 } , { 68 , 24 } , { 2 , 2 } ) ;
@ -281,7 +284,7 @@ public:
static std : : vector < Calculator * > calculators ;
static std : : vector < Calculator * > calculators ;
Manager manager ;
Manager manager ;
Button * AddButton ;
Button * AddButton ;
static Renderable ProdIcon , CloseIcon , CloseBackIcon , ProductionIcons , CollectibleIcons , CollectibleIcons2 , GradeIcons , PlusIcon , PlusBackIcon ;
static Renderable CloseIcon , CloseBackIcon , ProductionIcons , CollectibleIcons , CollectibleIcons2 , GradeIcons , PlusIcon , PlusBackIcon ;
public :
public :
std : : string slurp ( std : : ifstream & in ) {
std : : string slurp ( std : : ifstream & in ) {
std : : ostringstream sstr ;
std : : ostringstream sstr ;
@ -302,7 +305,7 @@ public:
// Called once at the start, so create things here
// Called once at the start, so create things here
std : : ifstream file = std : : ifstream ( " assets/Produce.txt " ) ;
std : : ifstream file = std : : ifstream ( " assets/Produce.txt " ) ;
std : : string fileContents = slurp ( file ) ;
std : : string fileContents = slurp ( file ) ;
fileContents + = ' \n ' ; //HACK ALERT! Our parser does not deal with data until a '\n' character occurs. If the file has no \n on the last line, we won't process it. This hack fixes that.
std : : string column = " " ;
std : : string column = " " ;
std : : vector < std : : string > data ;
std : : vector < std : : string > data ;
//HACK ALERT! If the number of recipes for any of these exceeds 300, a reallocation occurs and all pointers move...
//HACK ALERT! If the number of recipes for any of these exceeds 300, a reallocation occurs and all pointers move...
@ -359,8 +362,9 @@ public:
}
}
}
}
file = std : : ifstream ( " assets/Produce .txt " ) ;
file = std : : ifstream ( " assets/ItemViewinfo .txt " ) ;
fileContents = slurp ( file ) ;
fileContents = slurp ( file ) ;
fileContents + = ' \n ' ; //HACK ALERT! Our parser does not deal with data until a '\n' character occurs. If the file has no \n on the last line, we won't process it. This hack fixes that.
column = " " ;
column = " " ;
data . clear ( ) ;
data . clear ( ) ;
for ( int i = 0 ; i < fileContents . size ( ) ; i + + ) {
for ( int i = 0 ; i < fileContents . size ( ) ; i + + ) {
@ -378,29 +382,14 @@ public:
}
}
return false ;
return false ;
} else {
} else {
Recipe r ( data ) ;
//Recipe r(data);
int index = stoi ( data [ 0 ] ) ;
std : : string product = data [ 1 ] ;
Recipe * foundRecipe ;
if ( IDToName . find ( product ) ! = IDToName . end ( ) ) {
if ( StoneProdRecipeLink . find ( index ) ! = StoneProdRecipeLink . end ( ) ) {
IDToName [ product ] = ItemData { product , { uint8_t ( stoi ( data [ 8 ] ) ) , uint8_t ( stoi ( data [ 9 ] ) ) , uint8_t ( stoi ( data [ 10 ] ) ) } , { data [ 3 ] , stoi ( data [ 2 ] ) } , { data [ 5 ] , stoi ( data [ 4 ] ) } } ;
foundRecipe = StoneProdRecipeLink [ index ] ;
goto quitLoop ;
} else
if ( PotionProdRecipeLink . find ( index ) ! = PotionProdRecipeLink . end ( ) ) {
foundRecipe = PotionProdRecipeLink [ index ] ;
} else
if ( ScrollProdRecipeLink . find ( index ) ! = ScrollProdRecipeLink . end ( ) ) {
foundRecipe = ScrollProdRecipeLink [ index ] ;
} else
if ( CompRecipeLink . find ( index ) ! = CompRecipeLink . end ( ) ) {
foundRecipe = CompRecipeLink [ index ] ;
} else
if ( DecompRecipeLink . find ( index ) ! = DecompRecipeLink . end ( ) ) {
foundRecipe = DecompRecipeLink [ index ] ;
}
}
ItemData & item = IDToName [ foundRecipe - > ProduceIndex ] ;
item . borderCol = { uint8_t ( stoi ( data [ 8 ] ) ) , uint8_t ( stoi ( data [ 9 ] ) ) , uint8_t ( stoi ( data [ 10 ] ) ) } ;
item . img = { data [ 3 ] , stoi ( data [ 2 ] ) } ;
item . grade = { data [ 5 ] , stoi ( data [ 4 ] ) } ;
}
}
quitLoop :
data . clear ( ) ;
data . clear ( ) ;
} else {
} else {
column + = fileContents [ i ] ;
column + = fileContents [ i ] ;
@ -408,6 +397,38 @@ public:
}
}
file = std : : ifstream ( " assets/ItemInfo.txt " ) ;
fileContents = slurp ( file ) ;
fileContents + = ' \n ' ; //HACK ALERT! Our parser does not deal with data until a '\n' character occurs. If the file has no \n on the last line, we won't process it. This hack fixes that.
column = " " ;
data . clear ( ) ;
for ( int i = 0 ; i < fileContents . size ( ) ; i + + ) {
if ( fileContents [ i ] = = ' \t ' ) {
data . push_back ( column ) ;
column = " " ;
} else
if ( fileContents [ i ] = = ' \n ' ) {
data . push_back ( column ) ;
column = " " ;
if ( data . size ( ) ! = 57 ) {
std : : cout < < " Data size was " < < data . size ( ) < < " ! Expected 57 columns... " < < std : : endl ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
std : : cout < < " Col " < < i + 1 < < " : " < < data [ i ] < < std : : endl ;
}
return false ;
} else {
//Recipe r(data);
std : : string product = data [ 1 ] ;
if ( IDToName . find ( product ) ! = IDToName . end ( ) ) {
IDToName [ product ] . name = data [ 2 ] ;
}
}
data . clear ( ) ;
} else {
column + = fileContents [ i ] ;
}
}
std : : sort ( StoneProdRecipes . begin ( ) , StoneProdRecipes . end ( ) , [ ] ( Recipe & r1 , Recipe & r2 ) { return r1 . requiredExp < r2 . requiredExp ; } ) ;
std : : sort ( StoneProdRecipes . begin ( ) , StoneProdRecipes . end ( ) , [ ] ( Recipe & r1 , Recipe & r2 ) { return r1 . requiredExp < r2 . requiredExp ; } ) ;
std : : sort ( PotionProdRecipes . begin ( ) , PotionProdRecipes . end ( ) , [ ] ( Recipe & r1 , Recipe & r2 ) { return r1 . requiredExp < r2 . requiredExp ; } ) ;
std : : sort ( PotionProdRecipes . begin ( ) , PotionProdRecipes . end ( ) , [ ] ( Recipe & r1 , Recipe & r2 ) { return r1 . requiredExp < r2 . requiredExp ; } ) ;
@ -422,14 +443,14 @@ public:
std : : cout < < " " < < CompRecipes . size ( ) < < " Composition Recipes " < < std : : endl ;
std : : cout < < " " < < CompRecipes . size ( ) < < " Composition Recipes " < < std : : endl ;
std : : cout < < " " < < DecompRecipes . size ( ) < < " Decomposition Recipes " < < std : : endl ;
std : : cout < < " " < < DecompRecipes . size ( ) < < " Decomposition Recipes " < < std : : endl ;
ProdIcon . Load ( " assets/production_icons .png " , nullptr , true ) ;
Production Icons . Load ( " assets/Prdct000 .png " , nullptr , true ) ;
Karen . Load ( " assets/AdlF_Karen.png " , nullptr , true ) ;
Karen . Load ( " assets/AdlF_Karen.png " , nullptr , true ) ;
CloseIcon . Load ( " assets/close_button.png " , nullptr , true ) ;
CloseIcon . Load ( " assets/close_button.png " , nullptr , true ) ;
CloseBackIcon . Load ( " assets/button_mask.png " , nullptr , true ) ;
CloseBackIcon . Load ( " assets/button_mask.png " , nullptr , true ) ;
ProductionIcons . Load ( " assets/production_icons.png " , nullptr , true ) ;
ProductionIcons . Load ( " assets/production_icons.png " , nullptr , true ) ;
CollectibleIcons . Load ( " assets/collectibles .png " , nullptr , true ) ;
CollectibleIcons . Load ( " assets/Cllct000 .png " , nullptr , true ) ;
CollectibleIcons2 . Load ( " assets/collectibles2 .png " , nullptr , true ) ;
CollectibleIcons2 . Load ( " assets/QstItem000 .png " , nullptr , true ) ;
GradeIcons . Load ( " assets/g rade.png " , nullptr , true ) ;
GradeIcons . Load ( " assets/ItemG rade.png " , nullptr , true ) ;
PlusIcon . Load ( " assets/plus_button.png " , nullptr , true ) ;
PlusIcon . Load ( " assets/plus_button.png " , nullptr , true ) ;
PlusBackIcon . Load ( " assets/button_plus_mask.png " , nullptr , true ) ;
PlusBackIcon . Load ( " assets/button_plus_mask.png " , nullptr , true ) ;
calculators . push_back ( new Calculator ( ) ) ;
calculators . push_back ( new Calculator ( ) ) ;
@ -480,7 +501,7 @@ public:
}
}
} ;
} ;
Renderable FiestaCraftingCalculator : : ProdIcon , FiestaCraftingCalculator : : CloseIcon , FiestaCraftingCalculator : : CloseBackIcon , FiestaCraftingCalculator : : ProductionIcons , FiestaCraftingCalculator : : CollectibleIcons , FiestaCraftingCalculator : : CollectibleIcons2 , FiestaCraftingCalculator : : GradeIcons , FiestaCraftingCalculator : : PlusIcon , FiestaCraftingCalculator : : PlusBackIcon ;
Renderable FiestaCraftingCalculator : : CloseIcon , FiestaCraftingCalculator : : CloseBackIcon , FiestaCraftingCalculator : : ProductionIcons , FiestaCraftingCalculator : : CollectibleIcons , FiestaCraftingCalculator : : CollectibleIcons2 , FiestaCraftingCalculator : : GradeIcons , FiestaCraftingCalculator : : PlusIcon , FiestaCraftingCalculator : : PlusBackIcon ;
std : : vector < FiestaCraftingCalculator : : Recipe > FiestaCraftingCalculator : : PotionProdRecipes ;
std : : vector < FiestaCraftingCalculator : : Recipe > FiestaCraftingCalculator : : PotionProdRecipes ;
std : : vector < FiestaCraftingCalculator : : Recipe > FiestaCraftingCalculator : : StoneProdRecipes ;
std : : vector < FiestaCraftingCalculator : : Recipe > FiestaCraftingCalculator : : StoneProdRecipes ;
std : : vector < FiestaCraftingCalculator : : Recipe > FiestaCraftingCalculator : : ScrollProdRecipes ;
std : : vector < FiestaCraftingCalculator : : Recipe > FiestaCraftingCalculator : : ScrollProdRecipes ;