Fix Perspective correction on ViewPort PGEX. Implement windowing system and remove sprite reliance from all menu components.
This commit is contained in:
@@ -45,7 +45,7 @@ using A=Attribute;
|
||||
|
||||
class ScrollableWindowComponent:public MenuComponent{
|
||||
protected:
|
||||
Renderable r;
|
||||
ViewPort subWindow;
|
||||
std::vector<MenuComponent*>components;
|
||||
MenuComponent*upButton=nullptr;
|
||||
MenuComponent*downButton=nullptr;
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
:MenuComponent(rect,"",[](MenuFuncData data){return true;},ButtonAttr::UNSELECTABLE|ButtonAttr::UNSELECTABLE_VIA_KEYBOARD){
|
||||
background=attributes&ComponentAttr::BACKGROUND;
|
||||
border=attributes&ComponentAttr::OUTLINE;
|
||||
r.Create(uint32_t(rect.size.x),uint32_t(rect.size.y));
|
||||
subWindow=ViewPort::rectViewPort({},rect.size,rect.pos);
|
||||
}
|
||||
virtual inline void RemoveAllComponents(){
|
||||
while(components.size()>0){
|
||||
@@ -163,19 +163,7 @@ protected:
|
||||
downButton->disabled=true;
|
||||
}
|
||||
}
|
||||
virtual inline void Draw(Crawler*game,vf2d parentPos)override{
|
||||
MenuComponent::Draw(game,parentPos);
|
||||
Sprite*prevDrawTarget=game->GetDrawTarget();
|
||||
game->SetDrawTarget(r.Sprite());
|
||||
game->Clear(BLANK);
|
||||
for(MenuComponent*component:components){
|
||||
component->_Draw(game,V(A::SCROLL_OFFSET));
|
||||
}
|
||||
game->SetDrawTarget(prevDrawTarget);
|
||||
game->DrawSprite(parentPos+rect.pos,r.Sprite());
|
||||
}
|
||||
|
||||
inline void DrawScrollbar(Crawler*game,vf2d parentPos,bool focused){
|
||||
inline void DrawScrollbar(ViewPort&window,vf2d parentPos,bool focused){
|
||||
float spaceBetweenTopAndBottomArrows=rect.size.y-24;
|
||||
float viewHeight=rect.size.y;
|
||||
float totalContentHeight=bounds.size.y;
|
||||
@@ -186,19 +174,19 @@ protected:
|
||||
|
||||
float focusedWindowColorMult=(focused?1:"ThemeGlobal.MenuUnfocusedColorMult"_F);
|
||||
|
||||
game->FillRectDecal(rect.pos+parentPos+vf2d{rect.size.x-11.75f,scrollBarTop+12},{12,scrollBarHeight},PixelLerp(Menu::GetCurrentTheme().GetButtonCol(),Menu::GetCurrentTheme().GetHighlightCol(),scrollBarHoverTime/"ThemeGlobal.HighlightTime"_F)*focusedWindowColorMult);
|
||||
game->DrawRectDecal(rect.pos+parentPos+vf2d{rect.size.x-11.75f,scrollBarTop+12},{12,scrollBarHeight},WHITE*focusedWindowColorMult);
|
||||
window.FillRectDecal(rect.pos+parentPos+vf2d{rect.size.x-11.75f,scrollBarTop+12},{12,scrollBarHeight},PixelLerp(Menu::GetCurrentTheme().GetButtonCol(),Menu::GetCurrentTheme().GetHighlightCol(),scrollBarHoverTime/"ThemeGlobal.HighlightTime"_F)*focusedWindowColorMult);
|
||||
window.DrawRectDecal(rect.pos+parentPos+vf2d{rect.size.x-11.75f,scrollBarTop+12},{12,scrollBarHeight},WHITE*focusedWindowColorMult);
|
||||
}
|
||||
|
||||
virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{
|
||||
MenuComponent::DrawDecal(game,parentPos,focused);
|
||||
virtual inline void DrawDecal(ViewPort&window,vf2d parentPos,bool focused)override{
|
||||
MenuComponent::DrawDecal(window,parentPos,focused);
|
||||
if(border){
|
||||
game->DrawRectDecal(rect.pos+Menu::menus[parentMenu]->pos,rect.size);
|
||||
}
|
||||
for(MenuComponent*component:components){
|
||||
component->_DrawDecal(game,rect.pos+Menu::menus[parentMenu]->pos+V(A::SCROLL_OFFSET),focused);
|
||||
component->_DrawDecal(subWindow,rect.pos+Menu::menus[parentMenu]->pos+V(A::SCROLL_OFFSET),focused);
|
||||
}
|
||||
DrawScrollbar(game,Menu::menus[parentMenu]->pos,focused);
|
||||
DrawScrollbar(window,Menu::menus[parentMenu]->pos,focused);
|
||||
}
|
||||
virtual bool GetHoverState(Crawler*game,MenuComponent*child)override{
|
||||
return geom2d::overlaps(geom2d::rect<float>{Menu::menus[parentMenu]->pos+rect.pos+child->rect.pos+V(A::SCROLL_OFFSET),child->rect.size},game->GetMousePos());
|
||||
|
||||
Reference in New Issue
Block a user