Render all background windows, foreground window is the only one with direct focus. Background windows are darkened.
This commit is contained in:
parent
d70297578c
commit
d3f26d4bb0
@ -1708,7 +1708,10 @@ void Crawler::RenderMenu(){
|
|||||||
Menu::stack.back()->Update(this);
|
Menu::stack.back()->Update(this);
|
||||||
}
|
}
|
||||||
if(Menu::stack.size()>0){
|
if(Menu::stack.size()>0){
|
||||||
Menu::stack.back()->Draw(this);
|
FillRectDecal({0,0},WINDOW_SIZE,{0,0,0,uint8_t(255*0.4)});
|
||||||
|
for(Menu*menu:Menu::stack){
|
||||||
|
menu->Draw(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +98,11 @@ void Menu::Draw(Crawler*game){
|
|||||||
|
|
||||||
for(auto&key:buttons){
|
for(auto&key:buttons){
|
||||||
for(auto&button:key.second){
|
for(auto&button:key.second){
|
||||||
button->Draw(game,upperLeftPos);
|
button->Draw(game,upperLeftPos,this==Menu::stack.back());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(auto&component:displayComponents){
|
for(auto&component:displayComponents){
|
||||||
component->Draw(game,upperLeftPos);
|
component->Draw(game,upperLeftPos,this==Menu::stack.back());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -243,27 +243,27 @@ void Menu::DrawScaledWindow(Crawler*game,vf2d menuPos){
|
|||||||
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);
|
game->DrawPartialDecal(menuPos-patchSize,patchSize,GetPatchPart(0,0).Decal(),{patchSize.x*0,patchSize.y*0},patchSize,GetRenderColor());
|
||||||
//Upper-Right
|
//Upper-Right
|
||||||
game->DrawPartialDecal(menuPos+vf2d{size.x,-patchSize.y},patchSize,GetPatchPart(2,0).Decal(),{patchSize.x*2,patchSize.y*0},patchSize);
|
game->DrawPartialDecal(menuPos+vf2d{size.x,-patchSize.y},patchSize,GetPatchPart(2,0).Decal(),{patchSize.x*2,patchSize.y*0},patchSize,GetRenderColor());
|
||||||
//Bottom-Left
|
//Bottom-Left
|
||||||
game->DrawPartialDecal(menuPos+vf2d{-patchSize.x,size.y},patchSize,GetPatchPart(0,2).Decal(),{patchSize.x*0,patchSize.y*2},patchSize);
|
game->DrawPartialDecal(menuPos+vf2d{-patchSize.x,size.y},patchSize,GetPatchPart(0,2).Decal(),{patchSize.x*0,patchSize.y*2},patchSize,GetRenderColor());
|
||||||
//Bottom-Right
|
//Bottom-Right
|
||||||
game->DrawPartialDecal(menuPos+vf2d{size.x,size.y},patchSize,GetPatchPart(2,2).Decal(),{patchSize.x*2,patchSize.y*2},patchSize);
|
game->DrawPartialDecal(menuPos+vf2d{size.x,size.y},patchSize,GetPatchPart(2,2).Decal(),{patchSize.x*2,patchSize.y*2},patchSize,GetRenderColor());
|
||||||
//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);
|
game->DrawPartialDecal(menuPos+vf2d{0,-patchSize.y},vf2d{size.x,patchSize.y},GetPatchPart(1,0).Decal(),{patchSize.x*1,patchSize.y*0},patchSize,GetRenderColor());
|
||||||
//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);
|
game->DrawPartialDecal(menuPos+vf2d{-patchSize.x,0},vf2d{patchSize.x,size.y},GetPatchPart(0,1).Decal(),{patchSize.x*0,patchSize.y*1},patchSize,GetRenderColor());
|
||||||
//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);
|
game->DrawPartialDecal(menuPos+vf2d{size.x,0},vf2d{patchSize.x,size.y},GetPatchPart(2,1).Decal(),{patchSize.x*2,patchSize.y*1},patchSize,GetRenderColor());
|
||||||
//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);
|
game->DrawPartialDecal(menuPos+vf2d{0,size.y},vf2d{size.x,patchSize.y},GetPatchPart(1,2).Decal(),{patchSize.x*1,patchSize.y*2},patchSize,GetRenderColor());
|
||||||
//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());
|
game->DrawPartialDecal(menuPos,size,back,{0,0},back->sprite->Size(),GetRenderColor());
|
||||||
}else{
|
}else{
|
||||||
game->DrawPartialDecal(menuPos,size,GetPatchPart(1,1).Decal(),{patchSize.x*1,patchSize.y*1},patchSize);
|
game->DrawPartialDecal(menuPos,size,GetPatchPart(1,1).Decal(),{patchSize.x*1,patchSize.y*1},patchSize,GetRenderColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,27 +271,27 @@ void Menu::DrawTiledWindow(Crawler*game,vf2d menuPos){
|
|||||||
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);
|
game->DrawPartialDecal(menuPos-patchSize,patchSize,GetPatchPart(0,0).Decal(),{0,0},patchSize,GetRenderColor());
|
||||||
//Upper-Right
|
//Upper-Right
|
||||||
game->DrawPartialDecal(menuPos+vf2d{size.x,-patchSize.y},patchSize,GetPatchPart(2,0).Decal(),{0,0},patchSize);
|
game->DrawPartialDecal(menuPos+vf2d{size.x,-patchSize.y},patchSize,GetPatchPart(2,0).Decal(),{0,0},patchSize,GetRenderColor());
|
||||||
//Bottom-Left
|
//Bottom-Left
|
||||||
game->DrawPartialDecal(menuPos+vf2d{-patchSize.x,size.y},patchSize,GetPatchPart(0,2).Decal(),{0,0},patchSize);
|
game->DrawPartialDecal(menuPos+vf2d{-patchSize.x,size.y},patchSize,GetPatchPart(0,2).Decal(),{0,0},patchSize,GetRenderColor());
|
||||||
//Bottom-Right
|
//Bottom-Right
|
||||||
game->DrawPartialDecal(menuPos+vf2d{size.x,size.y},patchSize,GetPatchPart(2,2).Decal(),{0,0},patchSize);
|
game->DrawPartialDecal(menuPos+vf2d{size.x,size.y},patchSize,GetPatchPart(2,2).Decal(),{0,0},patchSize,GetRenderColor());
|
||||||
//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});
|
game->DrawPartialDecal(menuPos+vf2d{0,-patchSize.y},vf2d{size.x,patchSize.y},GetPatchPart(1,0).Decal(),{0,0},vf2d{size.x,patchSize.y},GetRenderColor());
|
||||||
//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});
|
game->DrawPartialDecal(menuPos+vf2d{-patchSize.x,0},vf2d{patchSize.x,size.y},GetPatchPart(0,1).Decal(),{0,0},vf2d{patchSize.x,size.y},GetRenderColor());
|
||||||
//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});
|
game->DrawPartialDecal(menuPos+vf2d{size.x,0},vf2d{patchSize.x,size.y},GetPatchPart(2,1).Decal(),{0,0},vf2d{patchSize.x,size.y},GetRenderColor());
|
||||||
//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});
|
game->DrawPartialDecal(menuPos+vf2d{0,size.y},vf2d{size.x,patchSize.y},GetPatchPart(1,2).Decal(),{0,0},vf2d{size.x,patchSize.y},GetRenderColor());
|
||||||
//Center
|
//Center
|
||||||
if(GetCurrentTheme().HasBackground()){
|
if(GetCurrentTheme().HasBackground()){
|
||||||
Decal*back=GetCurrentTheme().GetBackground();
|
Decal*back=GetCurrentTheme().GetBackground();
|
||||||
game->DrawPartialDecal(menuPos,size,back,{0,0},size);
|
game->DrawPartialDecal(menuPos,size,back,{0,0},size,GetRenderColor());
|
||||||
}else{
|
}else{
|
||||||
game->DrawPartialDecal(menuPos,size,GetPatchPart(1,1).Decal(),{0,0},patchSize);
|
game->DrawPartialDecal(menuPos,size,GetPatchPart(1,1).Decal(),{0,0},patchSize,GetRenderColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,3 +302,12 @@ Renderable&Menu::GetPatchPart(int x,int y){
|
|||||||
Theme&Menu::GetCurrentTheme(){
|
Theme&Menu::GetCurrentTheme(){
|
||||||
return themes[themeSelection];
|
return themes[themeSelection];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pixel Menu::GetRenderColor(){
|
||||||
|
bool focused=Menu::stack.back()==this;
|
||||||
|
Pixel col=WHITE;
|
||||||
|
if(!focused){
|
||||||
|
col=WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F;
|
||||||
|
}
|
||||||
|
return col;
|
||||||
|
}
|
@ -42,5 +42,7 @@ private:
|
|||||||
void KeyboardButtonNavigation(Crawler*game,vf2d menuPos);
|
void KeyboardButtonNavigation(Crawler*game,vf2d menuPos);
|
||||||
void DrawScaledWindow(Crawler*game,vf2d menuPos);
|
void DrawScaledWindow(Crawler*game,vf2d menuPos);
|
||||||
void DrawTiledWindow(Crawler*game,vf2d menuPos);
|
void DrawTiledWindow(Crawler*game,vf2d menuPos);
|
||||||
|
|
||||||
|
Pixel GetRenderColor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@ void MenuComponent::Update(Crawler*game){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuComponent::Draw(Crawler*game,vf2d parentPos){
|
void MenuComponent::Draw(Crawler*game,vf2d parentPos,bool focused){
|
||||||
game->FillRectDecal(rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F));
|
game->FillRectDecal(rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F)*(focused?1:"ThemeGlobal.MenuUnfocusedColorMult"_F));
|
||||||
if(border){
|
if(border){
|
||||||
game->DrawRectDecal(rect.pos+parentPos,rect.size,GREY);
|
game->DrawRectDecal(rect.pos+parentPos,rect.size,focused?GREY:GREY*"ThemeGlobal.MenuUnfocusedColorMult"_F);
|
||||||
}
|
}
|
||||||
game->DrawStringPropDecal(rect.pos+parentPos+rect.size/2-game->GetTextSizeProp(label)/2,label);
|
game->DrawStringPropDecal(rect.pos+parentPos+rect.size/2-game->GetTextSizeProp(label)/2,label,focused?WHITE:WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F);
|
||||||
}
|
}
|
@ -22,5 +22,5 @@ public:
|
|||||||
MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,bool selectable=true);
|
MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,bool selectable=true);
|
||||||
MenuComponent(geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick,bool selectable=true);
|
MenuComponent(geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick,bool selectable=true);
|
||||||
virtual void Update(Crawler*game);
|
virtual void Update(Crawler*game);
|
||||||
virtual void Draw(Crawler*game,vf2d parentPos);
|
virtual void Draw(Crawler*game,vf2d parentPos,bool focused);
|
||||||
};
|
};
|
@ -15,8 +15,8 @@ protected:
|
|||||||
virtual void inline Update(Crawler*game)override{
|
virtual void inline Update(Crawler*game)override{
|
||||||
MenuComponent::Update(game);
|
MenuComponent::Update(game);
|
||||||
}
|
}
|
||||||
virtual void inline Draw(Crawler*game,vf2d parentPos)override{
|
virtual void inline Draw(Crawler*game,vf2d parentPos,bool focused)override{
|
||||||
MenuComponent::Draw(game,parentPos);
|
MenuComponent::Draw(game,parentPos,focused);
|
||||||
game->DrawRotatedDecal(parentPos+rect.middle(),icon,0,icon->sprite->Size()/2);
|
game->DrawRotatedDecal(parentPos+rect.middle(),icon,0,icon->sprite->Size()/2,{1,1},focused?WHITE:WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F);
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -18,7 +18,7 @@ protected:
|
|||||||
virtual void inline Update(Crawler*game)override{
|
virtual void inline Update(Crawler*game)override{
|
||||||
MenuComponent::Update(game);
|
MenuComponent::Update(game);
|
||||||
}
|
}
|
||||||
virtual void inline Draw(Crawler*game,vf2d parentPos)override{
|
virtual void inline Draw(Crawler*game,vf2d parentPos,bool focused)override{
|
||||||
MenuComponent::Draw(game,parentPos);
|
MenuComponent::Draw(game,parentPos,focused);
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 1753
|
#define VERSION_BUILD 1761
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -2,6 +2,8 @@ ThemeGlobal
|
|||||||
{
|
{
|
||||||
# How long it takes for the fade-in/fade-out effect to occur.
|
# How long it takes for the fade-in/fade-out effect to occur.
|
||||||
HighlightTime = 0.2
|
HighlightTime = 0.2
|
||||||
|
# How much the R,G,B color components of a menu are multiplied to unfocused windows.
|
||||||
|
MenuUnfocusedColorMult = 0.4
|
||||||
}
|
}
|
||||||
|
|
||||||
Themes
|
Themes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user