|
|
|
@ -75,26 +75,11 @@ void Menu::Update(Crawler*game){ |
|
|
|
|
void Menu::Draw(Crawler*game){ |
|
|
|
|
vf2d upperLeftPos=game->GetScreenSize()/2-size/2; |
|
|
|
|
|
|
|
|
|
vf2d patchSize=vf2d{float("Interface.9PatchSize"_i[0]),float("Interface.9PatchSize"_i[1])}; |
|
|
|
|
|
|
|
|
|
//Upper-Left
|
|
|
|
|
game->DrawPartialDecal(upperLeftPos-patchSize,patchSize,GFX["9patch.png"].Decal(),{patchSize.x*0,patchSize.y*0},patchSize); |
|
|
|
|
//Upper-Right
|
|
|
|
|
game->DrawPartialDecal(upperLeftPos+vf2d{size.x,-patchSize.y},patchSize,GFX["9patch.png"].Decal(),{patchSize.x*2,patchSize.y*0},patchSize); |
|
|
|
|
//Bottom-Left
|
|
|
|
|
game->DrawPartialDecal(upperLeftPos+vf2d{-patchSize.x,size.y},patchSize,GFX["9patch.png"].Decal(),{patchSize.x*0,patchSize.y*2},patchSize); |
|
|
|
|
//Bottom-Right
|
|
|
|
|
game->DrawPartialDecal(upperLeftPos+vf2d{size.x,size.y},patchSize,GFX["9patch.png"].Decal(),{patchSize.x*2,patchSize.y*2},patchSize); |
|
|
|
|
//Top
|
|
|
|
|
game->DrawPartialDecal(upperLeftPos+vf2d{0,-patchSize.y},patchSize+vf2d{size.x,0},GFX["9patch.png"].Decal(),{patchSize.x*1,patchSize.y*0},patchSize); |
|
|
|
|
//Left
|
|
|
|
|
game->DrawPartialDecal(upperLeftPos+vf2d{-patchSize.x,0},patchSize+vf2d{0,size.y},GFX["9patch.png"].Decal(),{patchSize.x*0,patchSize.y*1},patchSize); |
|
|
|
|
//Right
|
|
|
|
|
game->DrawPartialDecal(upperLeftPos+vf2d{size.x,0},patchSize+vf2d{0,size.y},GFX["9patch.png"].Decal(),{patchSize.x*2,patchSize.y*1},patchSize); |
|
|
|
|
//Bottom
|
|
|
|
|
game->DrawPartialDecal(upperLeftPos+vf2d{0,size.y},patchSize+vf2d{size.x,0},GFX["9patch.png"].Decal(),{patchSize.x*1,patchSize.y*2},patchSize); |
|
|
|
|
//Center
|
|
|
|
|
game->DrawPartialDecal(upperLeftPos,patchSize+size,GFX["9patch.png"].Decal(),{patchSize.x*1,patchSize.y*1},patchSize); |
|
|
|
|
if(scaled){ |
|
|
|
|
DrawScaledWindow(game,upperLeftPos); |
|
|
|
|
}else{ |
|
|
|
|
DrawTiledWindow(game,upperLeftPos); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for(auto&key:buttons){ |
|
|
|
|
for(auto&button:key.second){ |
|
|
|
@ -234,4 +219,58 @@ void Menu::KeyboardButtonNavigation(Crawler*game,vf2d menuPos){ |
|
|
|
|
MenuSelect(game); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Menu::SetScaledPatchBorder(bool scaled){ |
|
|
|
|
this->scaled=scaled; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Menu::DrawScaledWindow(Crawler*game,vf2d menuPos){ |
|
|
|
|
vf2d patchSize={"Interface.9PatchSize"_f[0],"Interface.9PatchSize"_f[1]}; |
|
|
|
|
|
|
|
|
|
//Upper-Left
|
|
|
|
|
game->DrawPartialDecal(menuPos-patchSize,patchSize,GFX["9patch.png"].Decal(),{patchSize.x*0,patchSize.y*0},patchSize); |
|
|
|
|
//Upper-Right
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{size.x,-patchSize.y},patchSize,GFX["9patch.png"].Decal(),{patchSize.x*2,patchSize.y*0},patchSize); |
|
|
|
|
//Bottom-Left
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{-patchSize.x,size.y},patchSize,GFX["9patch.png"].Decal(),{patchSize.x*0,patchSize.y*2},patchSize); |
|
|
|
|
//Bottom-Right
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{size.x,size.y},patchSize,GFX["9patch.png"].Decal(),{patchSize.x*2,patchSize.y*2},patchSize); |
|
|
|
|
//Top
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{0,-patchSize.y},vf2d{size.x,patchSize.y},GFX["9patch.png"].Decal(),{patchSize.x*1,patchSize.y*0},patchSize); |
|
|
|
|
//Left
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{-patchSize.x,0},vf2d{patchSize.x,size.y},GFX["9patch.png"].Decal(),{patchSize.x*0,patchSize.y*1},patchSize); |
|
|
|
|
//Right
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{size.x,0},vf2d{patchSize.x,size.y},GFX["9patch.png"].Decal(),{patchSize.x*2,patchSize.y*1},patchSize); |
|
|
|
|
//Bottom
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{0,size.y},vf2d{size.x,patchSize.y},GFX["9patch.png"].Decal(),{patchSize.x*1,patchSize.y*2},patchSize); |
|
|
|
|
//Center
|
|
|
|
|
game->DrawPartialDecal(menuPos,size,GFX["9patch.png"].Decal(),{patchSize.x*1,patchSize.y*1},patchSize); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Menu::DrawTiledWindow(Crawler*game,vf2d menuPos){ |
|
|
|
|
vf2d patchSize={"Interface.9PatchSize"_f[0],"Interface.9PatchSize"_f[1]}; |
|
|
|
|
|
|
|
|
|
//Upper-Left
|
|
|
|
|
game->DrawPartialDecal(menuPos-patchSize,patchSize,GetPatchPart(0,0).Decal(),{0,0},patchSize); |
|
|
|
|
//Upper-Right
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{size.x,-patchSize.y},patchSize,GetPatchPart(2,0).Decal(),{0,0},patchSize); |
|
|
|
|
//Bottom-Left
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{-patchSize.x,size.y},patchSize,GetPatchPart(0,2).Decal(),{0,0},patchSize); |
|
|
|
|
//Bottom-Right
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{size.x,size.y},patchSize,GetPatchPart(2,2).Decal(),{0,0},patchSize); |
|
|
|
|
//Top
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{0,-patchSize.y},vf2d{size.x,patchSize.y},GetPatchPart(1,0).Decal(),{0,0},vf2d{size.x,patchSize.y}); |
|
|
|
|
//Left
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{-patchSize.x,0},vf2d{patchSize.x,size.y},GetPatchPart(0,1).Decal(),{0,0},vf2d{patchSize.x,size.y}); |
|
|
|
|
//Right
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{size.x,0},vf2d{patchSize.x,size.y},GetPatchPart(2,1).Decal(),{0,0},vf2d{patchSize.x,size.y}); |
|
|
|
|
//Bottom
|
|
|
|
|
game->DrawPartialDecal(menuPos+vf2d{0,size.y},vf2d{size.x,patchSize.y},GetPatchPart(1,2).Decal(),{0,0},vf2d{size.x,patchSize.y}); |
|
|
|
|
//Center
|
|
|
|
|
game->DrawPartialDecal(menuPos,size,GetPatchPart(1,1).Decal(),{0,0},patchSize); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Renderable&Menu::GetPatchPart(int x,int y){ |
|
|
|
|
return GFX["9patch_"+std::to_string(x)+std::to_string(y)+".png"]; |
|
|
|
|
} |