@ -63,6 +63,7 @@ MenuType Menu::lastMenuTypeCreated;
std : : string Menu : : lastRegisteredComponent ;
std : : string Menu : : lastRegisteredComponent ;
bool Menu : : cover ;
bool Menu : : cover ;
INCLUDE_game
INCLUDE_GFX
INCLUDE_GFX
extern vi2d WINDOW_SIZE ;
extern vi2d WINDOW_SIZE ;
@ -301,9 +302,9 @@ void Menu::Update(Crawler*game){
void Menu : : Draw ( Crawler * game ) {
void Menu : : Draw ( Crawler * game ) {
if ( GetCurrentTheme ( ) . IsScaled ( ) ) {
if ( GetCurrentTheme ( ) . IsScaled ( ) ) {
DrawScaledWindowBackground ( game , pos ) ;
DrawScaledWindowBackground ( game , pos , size , GetRenderColor ( ) ) ;
} else {
} else {
DrawTiledWindowBackground ( game , pos ) ;
DrawTiledWindowBackground ( game , pos , size , GetRenderColor ( ) ) ;
}
}
game - > SetDrawTarget ( r . Sprite ( ) ) ;
game - > SetDrawTarget ( r . Sprite ( ) ) ;
@ -340,9 +341,9 @@ void Menu::Draw(Crawler*game){
}
}
if ( GetCurrentTheme ( ) . IsScaled ( ) ) {
if ( GetCurrentTheme ( ) . IsScaled ( ) ) {
DrawScaledWindowBorder ( game , pos ) ;
DrawScaledWindowBorder ( game , pos , size , GetRenderColor ( ) ) ;
} else {
} else {
DrawTiledWindowBorder ( game , pos ) ;
DrawTiledWindowBorder ( game , pos , size , GetRenderColor ( ) ) ;
}
}
if ( draggingComponent ! = nullptr ) {
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 ] } ;
vf2d patchSize = { " Interface.9PatchSize " _f [ 0 ] , " Interface.9PatchSize " _f [ 1 ] } ;
//Upper-Left
//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
//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
//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
//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
//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
//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
//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
//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 ] } ;
vf2d patchSize = { " Interface.9PatchSize " _f [ 0 ] , " Interface.9PatchSize " _f [ 1 ] } ;
//Upper-Left
//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
//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
//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
//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
//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
//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
//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
//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 ] } ;
vf2d patchSize = { " Interface.9PatchSize " _f [ 0 ] , " Interface.9PatchSize " _f [ 1 ] } ;
//Center
//Center
if ( GetCurrentTheme ( ) . HasBackground ( ) ) {
if ( GetCurrentTheme ( ) . HasBackground ( ) ) {
Decal * back = GetCurrentTheme ( ) . GetBackground ( ) ;
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 {
} 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 ] } ;
vf2d patchSize = { " Interface.9PatchSize " _f [ 0 ] , " Interface.9PatchSize " _f [ 1 ] } ;
//Center
//Center
if ( GetCurrentTheme ( ) . HasBackground ( ) ) {
if ( GetCurrentTheme ( ) . HasBackground ( ) ) {
Decal * back = GetCurrentTheme ( ) . GetBackground ( ) ;
Decal * back = GetCurrentTheme ( ) . GetBackground ( ) ;
game - > DrawPartialDecal ( menuPos , size , back , { 0 , 0 } , size , GetRenderColor ( ) ) ;
game - > DrawPartialDecal ( menuPos , size , back , { 0 , 0 } , size , renderColor ) ;
} else {
} 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 ) ;
}
}
}
}
@ -702,3 +703,13 @@ void Menu::CleanupAllMenus(){
}
}
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 ) ;
}
}