Render all background windows, foreground window is the only one with direct focus. Background windows are darkened.

pull/28/head
sigonasr2 1 year ago
parent d70297578c
commit d3f26d4bb0
  1. 5
      Crawler/Crawler.cpp
  2. 53
      Crawler/Menu.cpp
  3. 2
      Crawler/Menu.h
  4. 8
      Crawler/MenuComponent.cpp
  5. 2
      Crawler/MenuComponent.h
  6. 6
      Crawler/MenuIconButton.h
  7. 4
      Crawler/MenuLabel.h
  8. 2
      Crawler/Version.h
  9. 2
      Crawler/assets/config/gfx/themes.txt

@ -1708,7 +1708,10 @@ void Crawler::RenderMenu(){
Menu::stack.back()->Update(this);
}
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&button:key.second){
button->Draw(game,upperLeftPos);
button->Draw(game,upperLeftPos,this==Menu::stack.back());
}
}
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]};
//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
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
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
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
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
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
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
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
if(GetCurrentTheme().HasBackground()){
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{
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]};
//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
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
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
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
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
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
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
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
if(GetCurrentTheme().HasBackground()){
Decal*back=GetCurrentTheme().GetBackground();
game->DrawPartialDecal(menuPos,size,back,{0,0},size);
game->DrawPartialDecal(menuPos,size,back,{0,0},size,GetRenderColor());
}else{
game->DrawPartialDecal(menuPos,size,GetPatchPart(1,1).Decal(),{0,0},patchSize);
game->DrawPartialDecal(menuPos,size,GetPatchPart(1,1).Decal(),{0,0},patchSize,GetRenderColor());
}
}
@ -301,4 +301,13 @@ Renderable&Menu::GetPatchPart(int x,int y){
Theme&Menu::GetCurrentTheme(){
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 DrawScaledWindow(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){
game->FillRectDecal(rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F));
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)*(focused?1:"ThemeGlobal.MenuUnfocusedColorMult"_F));
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,MenuType menuDest,MenuFunc onClick,bool selectable=true);
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{
MenuComponent::Update(game);
}
virtual void inline Draw(Crawler*game,vf2d parentPos)override{
MenuComponent::Draw(game,parentPos);
game->DrawRotatedDecal(parentPos+rect.middle(),icon,0,icon->sprite->Size()/2);
virtual void inline Draw(Crawler*game,vf2d parentPos,bool focused)override{
MenuComponent::Draw(game,parentPos,focused);
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{
MenuComponent::Update(game);
}
virtual void inline Draw(Crawler*game,vf2d parentPos)override{
MenuComponent::Draw(game,parentPos);
virtual void inline Draw(Crawler*game,vf2d parentPos,bool focused)override{
MenuComponent::Draw(game,parentPos,focused);
}
};

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 1753
#define VERSION_BUILD 1761
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -2,6 +2,8 @@ ThemeGlobal
{
# How long it takes for the fade-in/fade-out effect to occur.
HighlightTime = 0.2
# How much the R,G,B color components of a menu are multiplied to unfocused windows.
MenuUnfocusedColorMult = 0.4
}
Themes

Loading…
Cancel
Save