@ -63,6 +63,7 @@ MenuType Menu::lastMenuTypeCreated;
std : : string Menu : : lastRegisteredComponent ;
bool Menu : : cover ;
INCLUDE_game
INCLUDE_GFX
extern vi2d WINDOW_SIZE ;
@ -301,9 +302,9 @@ void Menu::Update(Crawler*game){
void Menu : : Draw ( Crawler * game ) {
if ( GetCurrentTheme ( ) . IsScaled ( ) ) {
DrawScaledWindowBackground ( game , pos ) ;
DrawScaledWindowBackground ( game , pos , size , GetRenderColor ( ) ) ;
} else {
DrawTiledWindowBackground ( game , pos ) ;
DrawTiledWindowBackground ( game , pos , size , GetRenderColor ( ) ) ;
}
game - > SetDrawTarget ( r . Sprite ( ) ) ;
@ -340,9 +341,9 @@ void Menu::Draw(Crawler*game){
}
if ( GetCurrentTheme ( ) . IsScaled ( ) ) {
DrawScaledWindowBorder ( game , pos ) ;
DrawScaledWindowBorder ( game , pos , size , GetRenderColor ( ) ) ;
} else {
DrawTiledWindowBorder ( game , pos ) ;
DrawTiledWindowBorder ( game , pos , size , GetRenderColor ( ) ) ;
}
if ( draggingComponent ! = nullptr ) {
@ -535,69 +536,69 @@ void Menu::KeyboardButtonNavigation(Crawler*game,vf2d menuPos){
}
}
void Menu : : DrawScaledWindowBorder ( Crawler * game , vf2d menuPos ) {
void Menu : : DrawScaledWindowBorder ( Crawler * game , vf2d menuPos , vf2d size , Pixel renderColor ) {
vf2d patchSize = { " Interface.9PatchSize " _f [ 0 ] , " Interface.9PatchSize " _f [ 1 ] } ;
//Upper-Left
game - > DrawPartialDecal ( menuPos - patchSize , patchSize , GetPatchPart ( 0 , 0 ) . Decal ( ) , { patchSize . x * 0 , patchSize . y * 0 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos - patchSize , patchSize , GetPatchPart ( 0 , 0 ) . Decal ( ) , { patchSize . x * 0 , patchSize . y * 0 } , patchSize , renderColor ) ;
//Upper-Right
game - > DrawPartialDecal ( menuPos + vf2d { size . x , - patchSize . y } , patchSize , GetPatchPart ( 2 , 0 ) . Decal ( ) , { patchSize . x * 2 , patchSize . y * 0 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { size . x , - patchSize . y } , patchSize , GetPatchPart ( 2 , 0 ) . Decal ( ) , { patchSize . x * 2 , patchSize . y * 0 } , patchSize , renderColor ) ;
//Bottom-Left
game - > DrawPartialDecal ( menuPos + vf2d { - patchSize . x , size . y } , patchSize , GetPatchPart ( 0 , 2 ) . Decal ( ) , { patchSize . x * 0 , patchSize . y * 2 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { - patchSize . x , size . y } , patchSize , GetPatchPart ( 0 , 2 ) . Decal ( ) , { patchSize . x * 0 , patchSize . y * 2 } , patchSize , renderColor ) ;
//Bottom-Right
game - > DrawPartialDecal ( menuPos + vf2d { size . x , size . y } , patchSize , GetPatchPart ( 2 , 2 ) . Decal ( ) , { patchSize . x * 2 , patchSize . y * 2 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { size . x , size . y } , patchSize , GetPatchPart ( 2 , 2 ) . Decal ( ) , { patchSize . x * 2 , patchSize . y * 2 } , patchSize , renderColor ) ;
//Top
game - > DrawPartialDecal ( menuPos + vf2d { 0 , - patchSize . y } , vf2d { size . x , patchSize . y } , GetPatchPart ( 1 , 0 ) . Decal ( ) , { patchSize . x * 1 , patchSize . y * 0 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { 0 , - patchSize . y } , vf2d { size . x , patchSize . y } , GetPatchPart ( 1 , 0 ) . Decal ( ) , { patchSize . x * 1 , patchSize . y * 0 } , patchSize , renderColor ) ;
//Left
game - > DrawPartialDecal ( menuPos + vf2d { - patchSize . x , 0 } , vf2d { patchSize . x , size . y } , GetPatchPart ( 0 , 1 ) . Decal ( ) , { patchSize . x * 0 , patchSize . y * 1 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { - patchSize . x , 0 } , vf2d { patchSize . x , size . y } , GetPatchPart ( 0 , 1 ) . Decal ( ) , { patchSize . x * 0 , patchSize . y * 1 } , patchSize , renderColor ) ;
//Right
game - > DrawPartialDecal ( menuPos + vf2d { size . x , 0 } , vf2d { patchSize . x , size . y } , GetPatchPart ( 2 , 1 ) . Decal ( ) , { patchSize . x * 2 , patchSize . y * 1 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { size . x , 0 } , vf2d { patchSize . x , size . y } , GetPatchPart ( 2 , 1 ) . Decal ( ) , { patchSize . x * 2 , patchSize . y * 1 } , patchSize , renderColor ) ;
//Bottom
game - > DrawPartialDecal ( menuPos + vf2d { 0 , size . y } , vf2d { size . x , patchSize . y } , GetPatchPart ( 1 , 2 ) . Decal ( ) , { patchSize . x * 1 , patchSize . y * 2 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { 0 , size . y } , vf2d { size . x , patchSize . y } , GetPatchPart ( 1 , 2 ) . Decal ( ) , { patchSize . x * 1 , patchSize . y * 2 } , patchSize , renderColor ) ;
}
void Menu : : DrawTiledWindowBorder ( Crawler * game , vf2d menuPos ) {
void Menu : : DrawTiledWindowBorder ( Crawler * game , vf2d menuPos , vf2d size , Pixel renderColor ) {
vf2d patchSize = { " Interface.9PatchSize " _f [ 0 ] , " Interface.9PatchSize " _f [ 1 ] } ;
//Upper-Left
game - > DrawPartialDecal ( menuPos - patchSize , patchSize , GetPatchPart ( 0 , 0 ) . Decal ( ) , { 0 , 0 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos - patchSize , patchSize , GetPatchPart ( 0 , 0 ) . Decal ( ) , { 0 , 0 } , patchSize , renderColor ) ;
//Upper-Right
game - > DrawPartialDecal ( menuPos + vf2d { size . x , - patchSize . y } , patchSize , GetPatchPart ( 2 , 0 ) . Decal ( ) , { 0 , 0 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { size . x , - patchSize . y } , patchSize , GetPatchPart ( 2 , 0 ) . Decal ( ) , { 0 , 0 } , patchSize , renderColor ) ;
//Bottom-Left
game - > DrawPartialDecal ( menuPos + vf2d { - patchSize . x , size . y } , patchSize , GetPatchPart ( 0 , 2 ) . Decal ( ) , { 0 , 0 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { - patchSize . x , size . y } , patchSize , GetPatchPart ( 0 , 2 ) . Decal ( ) , { 0 , 0 } , patchSize , renderColor ) ;
//Bottom-Right
game - > DrawPartialDecal ( menuPos + vf2d { size . x , size . y } , patchSize , GetPatchPart ( 2 , 2 ) . Decal ( ) , { 0 , 0 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { size . x , size . y } , patchSize , GetPatchPart ( 2 , 2 ) . Decal ( ) , { 0 , 0 } , patchSize , renderColor ) ;
//Top
game - > DrawPartialDecal ( menuPos + vf2d { 0 , - patchSize . y } , vf2d { size . x , patchSize . y } , GetPatchPart ( 1 , 0 ) . Decal ( ) , { 0 , 0 } , vf2d { size . x , patchSize . y } , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { 0 , - patchSize . y } , vf2d { size . x , patchSize . y } , GetPatchPart ( 1 , 0 ) . Decal ( ) , { 0 , 0 } , vf2d { size . x , patchSize . y } , renderColor ) ;
//Left
game - > DrawPartialDecal ( menuPos + vf2d { - patchSize . x , 0 } , vf2d { patchSize . x , size . y } , GetPatchPart ( 0 , 1 ) . Decal ( ) , { 0 , 0 } , vf2d { patchSize . x , size . y } , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { - patchSize . x , 0 } , vf2d { patchSize . x , size . y } , GetPatchPart ( 0 , 1 ) . Decal ( ) , { 0 , 0 } , vf2d { patchSize . x , size . y } , renderColor ) ;
//Right
game - > DrawPartialDecal ( menuPos + vf2d { size . x , 0 } , vf2d { patchSize . x , size . y } , GetPatchPart ( 2 , 1 ) . Decal ( ) , { 0 , 0 } , vf2d { patchSize . x , size . y } , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { size . x , 0 } , vf2d { patchSize . x , size . y } , GetPatchPart ( 2 , 1 ) . Decal ( ) , { 0 , 0 } , vf2d { patchSize . x , size . y } , renderColor ) ;
//Bottom
game - > DrawPartialDecal ( menuPos + vf2d { 0 , size . y } , vf2d { size . x , patchSize . y } , GetPatchPart ( 1 , 2 ) . Decal ( ) , { 0 , 0 } , vf2d { size . x , patchSize . y } , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos + vf2d { 0 , size . y } , vf2d { size . x , patchSize . y } , GetPatchPart ( 1 , 2 ) . Decal ( ) , { 0 , 0 } , vf2d { size . x , patchSize . y } , renderColor ) ;
}
void Menu : : DrawScaledWindowBackground ( Crawler * game , vf2d menuPos ) {
void Menu : : DrawScaledWindowBackground ( Crawler * game , vf2d menuPos , vf2d size , Pixel renderColor ) {
vf2d patchSize = { " Interface.9PatchSize " _f [ 0 ] , " Interface.9PatchSize " _f [ 1 ] } ;
//Center
if ( GetCurrentTheme ( ) . HasBackground ( ) ) {
Decal * back = GetCurrentTheme ( ) . GetBackground ( ) ;
game - > DrawPartialDecal ( menuPos , size , back , { 0 , 0 } , back - > sprite - > Size ( ) , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos , size , back , { 0 , 0 } , back - > sprite - > Size ( ) , renderColor ) ;
} else {
game - > DrawPartialDecal ( menuPos , size , GetPatchPart ( 1 , 1 ) . Decal ( ) , { patchSize . x * 1 , patchSize . y * 1 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos , size , GetPatchPart ( 1 , 1 ) . Decal ( ) , { patchSize . x * 1 , patchSize . y * 1 } , patchSize , renderColor ) ;
}
}
void Menu : : DrawTiledWindowBackground ( Crawler * game , vf2d menuPos ) {
void Menu : : DrawTiledWindowBackground ( Crawler * game , vf2d menuPos , vf2d size , Pixel renderColor ) {
vf2d patchSize = { " Interface.9PatchSize " _f [ 0 ] , " Interface.9PatchSize " _f [ 1 ] } ;
//Center
if ( GetCurrentTheme ( ) . HasBackground ( ) ) {
Decal * back = GetCurrentTheme ( ) . GetBackground ( ) ;
game - > DrawPartialDecal ( menuPos , size , back , { 0 , 0 } , size , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos , size , back , { 0 , 0 } , size , renderColor ) ;
} else {
game - > DrawPartialDecal ( menuPos , size , GetPatchPart ( 1 , 1 ) . Decal ( ) , { 0 , 0 } , patchSize , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos , size , GetPatchPart ( 1 , 1 ) . Decal ( ) , { 0 , 0 } , patchSize , renderColor ) ;
}
}
@ -701,4 +702,14 @@ void Menu::CleanupAllMenus(){
Menu : : menus . clear ( ) ;
}
void Menu : : Cleanup ( ) { }
void Menu : : Cleanup ( ) { }
void Menu : : DrawThemedWindow ( vf2d menuPos , vf2d size , Pixel renderColor ) {
if ( GetCurrentTheme ( ) . IsScaled ( ) ) {
DrawScaledWindowBackground ( game , menuPos , size , renderColor ) ;
DrawScaledWindowBorder ( game , menuPos , size , renderColor ) ;
} else {
DrawTiledWindowBackground ( game , menuPos , size , renderColor ) ;
DrawTiledWindowBorder ( game , menuPos , size , renderColor ) ;
}
}