Fix border display drawing for menus. Fix scrollable window components that went outside to use proper scrolling offsets. Fix issue with same-frame clicking and releasing causing a different button to be selected.
This commit is contained in:
+12
-16
@@ -45,7 +45,7 @@ INCLUDE_game
|
||||
using A=Attribute;
|
||||
|
||||
MenuComponent::MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,ButtonAttr attributes)
|
||||
:rect(rect),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(!(attributes&ButtonAttr::UNSELECTABLE)),selectableViaKeyboard(!(attributes&ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)),memoryLeakInfo(Menu::GetMemoryLeakReportInfo()){
|
||||
:rect(rect),originalPos(rect.pos),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(!(attributes&ButtonAttr::UNSELECTABLE)),selectableViaKeyboard(!(attributes&ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)),memoryLeakInfo(Menu::GetMemoryLeakReportInfo()){
|
||||
Menu::unhandledComponents.push_back(this);
|
||||
}
|
||||
|
||||
@@ -95,26 +95,26 @@ void MenuComponent::_Update(Crawler*game){
|
||||
|
||||
void MenuComponent::OnEquipStatsUpdate(){}
|
||||
|
||||
void MenuComponent::DrawDecal(ViewPort&window,vf2d parentPos,bool focused){
|
||||
void MenuComponent::DrawDecal(ViewPort&window,bool focused){
|
||||
if(background){
|
||||
window.FillRectDecal(rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F));
|
||||
window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET),rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F));
|
||||
}
|
||||
if(selected&&selectionType==HIGHLIGHT){
|
||||
window.FillRectDecal(rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),util::lerp(0.75f,1.0f,hoverEffect/"ThemeGlobal.HighlightTime"_F)));
|
||||
window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET),rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),util::lerp(0.75f,1.0f,hoverEffect/"ThemeGlobal.HighlightTime"_F)));
|
||||
}
|
||||
if(border){
|
||||
window.FillRectDecal(rect.pos+parentPos,{rect.size.x+1,1});
|
||||
window.FillRectDecal(rect.pos+parentPos,{1,rect.size.y+1});
|
||||
window.FillRectDecal(rect.pos+parentPos+vf2d{rect.size.x-1+1,0},{1,rect.size.y+1});
|
||||
window.FillRectDecal(rect.pos+parentPos+vf2d{0,rect.size.y-1+1},{rect.size.x+1,1});
|
||||
window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET),{rect.size.x+1,1});
|
||||
window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET),{1,rect.size.y+1});
|
||||
window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET)+vf2d{rect.size.x-1+1,0},{1,rect.size.y+1});
|
||||
window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET)+vf2d{0,rect.size.y-1+1},{rect.size.x+1,1});
|
||||
}
|
||||
if(showDefaultLabel){
|
||||
window.DrawStringPropDecal(rect.pos+parentPos+rect.size/2-vf2d(game->GetTextSizeProp(label))/2.f*labelScaling,label,WHITE,labelScaling);
|
||||
window.DrawStringPropDecal(rect.pos+V(A::DRAW_OFFSET)+rect.size/2-vf2d(game->GetTextSizeProp(label))/2.f*labelScaling,label,WHITE,labelScaling);
|
||||
}
|
||||
if(selected){
|
||||
switch(selectionType){
|
||||
case CROSSHAIR:drawutil::DrawCrosshairDecalViewPort(window,{parentPos+rect.pos,rect.size},0);break;
|
||||
case INNER_BOX:window.DrawRectDecal(rect.pos+parentPos+vi2d{1,1},rect.size-vi2d{2,2});break;
|
||||
case CROSSHAIR:drawutil::DrawCrosshairDecalViewPort(window,{rect.pos+V(A::DRAW_OFFSET),rect.size},0);break;
|
||||
case INNER_BOX:window.DrawRectDecal(rect.pos+V(A::DRAW_OFFSET)+vi2d{1,1},rect.size-vi2d{2,2});break;
|
||||
case HIGHLIGHT:break;//Not used.
|
||||
default:ERR("Undefined selection type selected: "<<int(selectionType));
|
||||
}
|
||||
@@ -122,12 +122,8 @@ void MenuComponent::DrawDecal(ViewPort&window,vf2d parentPos,bool focused){
|
||||
}
|
||||
|
||||
void MenuComponent::_DrawDecal(ViewPort&window,bool focused){
|
||||
_DrawDecal(window,{0,0},focused);
|
||||
}
|
||||
|
||||
void MenuComponent::_DrawDecal(ViewPort&window,vf2d parentPos,bool focused){
|
||||
if(!disabled){
|
||||
DrawDecal(window,parentPos,focused);
|
||||
DrawDecal(window,focused);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user