From 46eae742cb5e2bae0d8ffb3a4ade1e5ba446fbeb Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Fri, 30 Dec 2022 18:01:47 -0800 Subject: [PATCH] VGUI: Make sure defaults are filled into the attributes inside Spawned() for inherited ones. --- src/client/NSInteractiveSurface.qc | 2 -- src/gs-entbase/server/light.qc | 6 +++++- src/menu-vgui/ui_modelviewer.qc | 32 +++++++++++++++--------------- src/vgui/ui.qc | 9 +++++---- src/vgui/ui_3dview.qc | 14 ++++++------- src/vgui/ui_button.qc | 15 ++++++-------- src/vgui/ui_checkbox.qc | 10 +++++++--- src/vgui/ui_label.qc | 10 ++++++++-- src/vgui/ui_list.qc | 8 ++++++-- src/vgui/ui_listbox.qc | 8 ++++++-- src/vgui/ui_menubutton.qc | 10 ++++++++-- src/vgui/ui_pic.qc | 10 ++++++++-- src/vgui/ui_radio.qc | 10 +++++++--- src/vgui/ui_scrollbar.qc | 2 -- src/vgui/ui_slider.qc | 10 +++++++--- src/vgui/ui_tabview.qc | 10 ++++++++-- src/vgui/ui_textbox.qc | 9 ++++++--- src/vgui/ui_window.qc | 19 ++++++++++++------ 18 files changed, 123 insertions(+), 71 deletions(-) diff --git a/src/client/NSInteractiveSurface.qc b/src/client/NSInteractiveSurface.qc index 3b1b13b6..2f6e6dbb 100644 --- a/src/client/NSInteractiveSurface.qc +++ b/src/client/NSInteractiveSurface.qc @@ -303,7 +303,5 @@ TestUI::Spawned(void) void TestUI::TestUI(void) { - m_vecSize = [512,512]; - m_iFlags |= WINDOW_VISIBLE; } #endif diff --git a/src/gs-entbase/server/light.qc b/src/gs-entbase/server/light.qc index ffffa98f..fd2ac4c7 100644 --- a/src/gs-entbase/server/light.qc +++ b/src/gs-entbase/server/light.qc @@ -136,9 +136,13 @@ light::Restore(string strKey, string strValue) void light::RestoreComplete(void) { + /* not switchable */ + if (m_flStyle < 12) + return; + if (m_iEnabled == 0) { lightstyle(m_flStyle, "a"); - } else if (m_flStyle > 12) { + } else { lightstyle(m_flStyle, m_strPattern); } } diff --git a/src/menu-vgui/ui_modelviewer.qc b/src/menu-vgui/ui_modelviewer.qc index 6cd7b110..87f16430 100644 --- a/src/menu-vgui/ui_modelviewer.qc +++ b/src/menu-vgui/ui_modelviewer.qc @@ -119,9 +119,9 @@ void UI_ModelViewer_Show ( void ) } if ( chkBackground.GetValue() == TRUE ) { - picBackground.FlagAdd( IMAGE_VISIBLE ); + picBackground.Show(); } else { - picBackground.FlagRemove( IMAGE_VISIBLE ); + picBackground.Hide(); } } static float UI_ModelViewer_Input ( float flEVType, float flKey, float flChar, float flDevID ) { @@ -205,26 +205,26 @@ void UI_ModelViewer_Show ( void ) btnSeqNext.SetPos( btnTabRenderer.GetPos() + [ 64, 50 ] ); } static void UI_ModelViewer_HideAll( void ) { - chkBackground.FlagRemove( 1 ); - chkGround.FlagRemove( 1 ); - chkMirror.FlagRemove( 1 ); - lblSeqFrame.FlagRemove( 1 ); - btnSeqPrev.FlagRemove( 1 ); - btnSeqNext.FlagRemove( 1 ); - btnFirstperson.FlagRemove( 1 ); + chkBackground.Hide(); + chkGround.Hide(); + chkMirror.Hide(); + lblSeqFrame.Hide(); + btnSeqPrev.Hide(); + btnSeqNext.Hide(); + btnFirstperson.Hide(); } static void UI_ModelViewer_ShowRenderer( void ) { UI_ModelViewer_HideAll(); - chkBackground.FlagAdd( 1 ); - chkGround.FlagAdd( 1 ); - chkMirror.FlagAdd( 1 ); - btnFirstperson.FlagAdd( 1 ); + chkBackground.Show(); + chkGround.Show(); + chkMirror.Show(); + btnFirstperson.Show(); } static void UI_ModelViewer_ShowSequence( void ) { UI_ModelViewer_HideAll(); - lblSeqFrame.FlagAdd( 1 ); - btnSeqPrev.FlagAdd( 1 ); - btnSeqNext.FlagAdd( 1 ); + lblSeqFrame.Show(); + btnSeqPrev.Show(); + btnSeqNext.Show(); } static void UI_ModelViewer_ShowBody( void ) { UI_ModelViewer_HideAll(); diff --git a/src/vgui/ui.qc b/src/vgui/ui.qc index f3d900ce..91e006f0 100644 --- a/src/vgui/ui.qc +++ b/src/vgui/ui.qc @@ -190,8 +190,8 @@ VGUIWidget::SizeChanged(vector vecOld, vector vecNew) void VGUIWidget::SetPos(vector vecNewPos) { - m_vecOrigin[0] = bound(0, vecNewPos[0], video_res[0] - 32); - m_vecOrigin[1] = bound(0, vecNewPos[1], video_res[1] - 32); + m_vecOrigin[0] = bound(0, vecNewPos[0], 9999.0); + m_vecOrigin[1] = bound(0, vecNewPos[1], 9999.0); } vector @@ -296,6 +296,7 @@ VGUIWidget::Add(VGUIWidget wNew) wNew.m_parent = this; } +.string classname; void VGUIWidget::Draw(void) { @@ -303,7 +304,7 @@ VGUIWidget::Draw(void) g_vguiWidgetCount = 0; do { wNext = wNext.m_next; - if (wNext && wNext.m_iFlags & 1 && wNext.m_parent.m_iFlags & 1) { + if (wNext && wNext.Visible() && wNext.m_parent.Visible()) { g_vguiWidgetCount++; wNext.Draw(); } @@ -342,7 +343,7 @@ VGUIWidget::Input(float flEVType, float flKey, float flChar, float flDevID) for (int x = c-1; x >= 0; x--) { wNext = tree[x].member; - if (wNext && wNext.m_iFlags & 1 && wNext.m_parent.m_iFlags & 1) + if (wNext && wNext.Visible() && wNext.m_parent.Visible()) if (wNext.Input(flEVType, flKey, flChar, flDevID) == true) { memfree(tree); return (true); diff --git a/src/vgui/ui_3dview.qc b/src/vgui/ui_3dview.qc index 1fed603f..53cb0630 100644 --- a/src/vgui/ui_3dview.qc +++ b/src/vgui/ui_3dview.qc @@ -21,11 +21,6 @@ noref .vector maxs; noref .string model; noref .float frame, frame2, lerpfrac, renderflags, frame1time; -enumflags -{ - VIEW_VISIBLE -}; - class VGUI3DView:VGUIWidget { public: @@ -47,6 +42,7 @@ public: /* overrides */ virtual void Draw(void); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: vector m_vec3DPos; @@ -60,9 +56,13 @@ void VGUI3DView::VGUI3DView(void) { m_flFOV = 90; - m_vecSize = [64,64]; m_vec3DPos = m_vec3DAngles = [0,0,0]; - m_iFlags = VIEW_VISIBLE; +} + +void +VGUI3DView::Spawned(void) +{ + SetSize([64,64]); } void diff --git a/src/vgui/ui_button.qc b/src/vgui/ui_button.qc index ac051c71..88cd54a6 100644 --- a/src/vgui/ui_button.qc +++ b/src/vgui/ui_button.qc @@ -16,7 +16,6 @@ enumflags { - BUTTON_VISIBLE, BUTTON_HOVER, BUTTON_DOWN, BUTTON_LASTACTIVE @@ -61,9 +60,13 @@ VGUIButton::VGUIButton(void) { m_vecColor = UI_MAINCOLOR; m_flAlpha = 1.0f; - m_vecSize = [96,24]; m_vecIconColor = [1,1,1]; - m_iFlags = BUTTON_VISIBLE; +} + +void +VGUIButton::Spawned(void) +{ + SetSize([96,24]); } void @@ -121,9 +124,6 @@ VGUIButton::SetExec(string exe) void VGUIButton::Draw(void) { - if (!Visible()) - return; - #ifndef CLASSIC_VGUI drawfill(m_parent.m_vecOrigin + m_vecOrigin, m_vecSize, m_vecColor, m_flAlpha); @@ -168,9 +168,6 @@ VGUIButton::Input(float flEVType, float flKey, float flChar, float flDevID) { bool ret = false; - if (!Visible()) - return false; - if (flEVType == IE_KEYDOWN) { if (flKey == K_MOUSE1) { FlagRemove(BUTTON_LASTACTIVE); diff --git a/src/vgui/ui_checkbox.qc b/src/vgui/ui_checkbox.qc index ba18061c..b7247673 100644 --- a/src/vgui/ui_checkbox.qc +++ b/src/vgui/ui_checkbox.qc @@ -16,7 +16,6 @@ enumflags { - CHECKBOX_VISIBLE, CHECKBOX_HOVER, CHECKBOX_DOWN, CHECKBOX_CHECKED @@ -33,6 +32,7 @@ public: virtual void Draw(void); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: vector m_vecColor; @@ -44,8 +44,12 @@ void VGUICheckbox::VGUICheckbox(void) { m_vecColor = UI_MAINCOLOR; m_flAlpha = 1.0f; - m_vecSize = [96,18]; - m_iFlags = CHECKBOX_VISIBLE; +} + +void +VGUICheckbox::Spawned(void) +{ + SetSize([96,18]); } void VGUICheckbox::SetTitle (string strName) diff --git a/src/vgui/ui_label.qc b/src/vgui/ui_label.qc index a39418c8..55536b6b 100644 --- a/src/vgui/ui_label.qc +++ b/src/vgui/ui_label.qc @@ -23,6 +23,7 @@ public: virtual void Draw(void); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: string m_strTitle; @@ -31,8 +32,13 @@ private: void VGUILabel::VGUILabel(void) { - m_vecSize = [96,16]; - m_iFlags = BUTTON_VISIBLE; + m_strTitle = __NULL__; +} + +void +VGUILabel::Spawned(void) +{ + SetSize([96,16]); } void diff --git a/src/vgui/ui_list.qc b/src/vgui/ui_list.qc index 161f76ab..124176a4 100644 --- a/src/vgui/ui_list.qc +++ b/src/vgui/ui_list.qc @@ -38,6 +38,7 @@ public: virtual void Draw(void); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: string m_strTitle; @@ -50,11 +51,14 @@ private: void VGUIList::VGUIList(void) { - m_vecSize = [96,16]; - m_iFlags = 1; m_iSelected = -1; } +void VGUIList::Spawned(void) +{ + SetSize([96,16]); +} + void VGUIList::Draw(void) { int iMaxDisplay; diff --git a/src/vgui/ui_listbox.qc b/src/vgui/ui_listbox.qc index a9a7f018..8fc4d5f0 100644 --- a/src/vgui/ui_listbox.qc +++ b/src/vgui/ui_listbox.qc @@ -27,6 +27,7 @@ public: virtual void Draw(void); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: vector m_vecSize; @@ -39,11 +40,14 @@ private: void VGUIListBox::VGUIListBox(void) { - m_vecSize = [96,16]; - m_iFlags = 1; m_iSelected = -1; } +void VGUIListBox::Spawned(void) +{ + SetSize([96,16]); +} + void VGUIListBox::SetItemCount (int iCount) { if (!m_iItemCount) { diff --git a/src/vgui/ui_menubutton.qc b/src/vgui/ui_menubutton.qc index e49b904f..3ab39f3c 100644 --- a/src/vgui/ui_menubutton.qc +++ b/src/vgui/ui_menubutton.qc @@ -37,6 +37,7 @@ public: virtual void Draw(void); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: vector m_vecColor; @@ -52,8 +53,13 @@ VGUIMenuButton::VGUIMenuButton(void) { m_vecColor = UI_MAINCOLOR; m_flAlpha = 1.0f; - m_vecSize = [96,24]; - m_iFlags = MBUTTON_VISIBLE | MBUTTON_SHOWOFFLINE | MBUTTON_SHOWSP | MBUTTON_SHOWMP; +} + +void +VGUIMenuButton::Spawned(void) +{ + SetSize([96,24]); + FlagAdd(MBUTTON_VISIBLE | MBUTTON_SHOWOFFLINE | MBUTTON_SHOWSP | MBUTTON_SHOWMP); } void diff --git a/src/vgui/ui_pic.qc b/src/vgui/ui_pic.qc index a69487d7..25278134 100644 --- a/src/vgui/ui_pic.qc +++ b/src/vgui/ui_pic.qc @@ -30,6 +30,7 @@ public: virtual void Draw(void); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: string m_strImage; @@ -38,8 +39,13 @@ private: void VGUIPic::VGUIPic(void) { - m_vecSize = [16,16]; - m_iFlags = IMAGE_VISIBLE; + m_strImage = __NULL__; +} + +void +VGUIPic::Spawned(void) +{ + SetSize([16,16]); } void diff --git a/src/vgui/ui_radio.qc b/src/vgui/ui_radio.qc index ac688732..d09f9521 100644 --- a/src/vgui/ui_radio.qc +++ b/src/vgui/ui_radio.qc @@ -16,7 +16,6 @@ enumflags { - RADIO_VISIBLE, RADIO_HOVER, RADIO_DOWN, RADIO_ACTIVE @@ -34,6 +33,7 @@ public: virtual void Draw(void); virtual bool(float, float, float, float) Input; + virtual void Spawned(void); private: vector m_vecColor; @@ -47,8 +47,12 @@ void VGUIRadio::VGUIRadio(void) { m_vecColor = UI_MAINCOLOR; m_flAlpha = 1.0f; - m_vecSize = [96,24]; - m_iFlags = RADIO_VISIBLE; +} + +void +VGUIRadio::Spawned(void) +{ + SetSize([96,24]); } diff --git a/src/vgui/ui_scrollbar.qc b/src/vgui/ui_scrollbar.qc index 0564c411..0c243b99 100644 --- a/src/vgui/ui_scrollbar.qc +++ b/src/vgui/ui_scrollbar.qc @@ -16,7 +16,6 @@ enumflags { - SCROLLBAR_VISIBLE, SCROLLBAR_UP_DOWN, SCROLLBAR_DN_DOWN, SCROLLBAR_SLIDER_DOWN @@ -62,7 +61,6 @@ void VGUIScrollbar::VGUIScrollbar(void) { m_vecColor = UI_MAINCOLOR; m_flAlpha = 1.0f; - m_iFlags = SCROLLBAR_VISIBLE; } void VGUIScrollbar::Draw(void) diff --git a/src/vgui/ui_slider.qc b/src/vgui/ui_slider.qc index a5cfdeb4..ac11017f 100644 --- a/src/vgui/ui_slider.qc +++ b/src/vgui/ui_slider.qc @@ -16,7 +16,6 @@ enumflags { - SLIDER_VISIBLE, SLIDER_HOVER, SLIDER_DOWN, }; @@ -31,6 +30,7 @@ public: /* overrides */ virtual void Draw(void); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: float m_flAlpha; @@ -42,8 +42,12 @@ void VGUISlider::VGUISlider(void) { m_vecColor = [76,88,68] / 255; m_flAlpha = 1.0f; - m_vecSize = [96,24]; - m_iFlags = BUTTON_VISIBLE; +} + +void +VGUISlider::Spawned(void) +{ + SetSize([96,24]); } void VGUISlider::Draw(void) diff --git a/src/vgui/ui_tabview.qc b/src/vgui/ui_tabview.qc index 887ceedf..e949b270 100644 --- a/src/vgui/ui_tabview.qc +++ b/src/vgui/ui_tabview.qc @@ -27,6 +27,7 @@ public: virtual void SizeChanged(vector, vector); virtual void Draw(void); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: vector m_vecOutlineSize; @@ -36,8 +37,13 @@ private: void VGUITabView::VGUITabView(void) { - m_vecSize = [96,16]; - m_iFlags = BUTTON_VISIBLE; + m_vecOutlinePos = m_vecOutlineSize = g_vec_null; + m_strTitle = __NULL__; +} + +void VGUITabView::Spawned(void) +{ + SetSize([96,16]); } void VGUITabView:: PositionChanged (vector vecOld, vector vecNew) diff --git a/src/vgui/ui_textbox.qc b/src/vgui/ui_textbox.qc index a0c47afb..7d549ab8 100644 --- a/src/vgui/ui_textbox.qc +++ b/src/vgui/ui_textbox.qc @@ -16,7 +16,6 @@ enumflags { - TEXTBOX_VISIBLE, TEXTBOX_HOVER, TEXTBOX_DOWN, TEXTBOX_FOCUS @@ -35,6 +34,7 @@ public: /* overrides */ virtual void Draw(void); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: vector m_vecColor; @@ -47,8 +47,11 @@ void VGUITextBox::VGUITextBox(void) { m_vecColor = UI_MAINCOLOR; m_flAlpha = 1.0f; - m_vecSize = [96,24]; - m_iFlags = BUTTON_VISIBLE; +} + +void VGUITextBox:: Spawned(void) +{ + SetSize([96,24]); } void VGUITextBox::SetText (string strName) diff --git a/src/vgui/ui_window.qc b/src/vgui/ui_window.qc index a7d84ba2..cbf89eaf 100644 --- a/src/vgui/ui_window.qc +++ b/src/vgui/ui_window.qc @@ -16,7 +16,6 @@ enumflags { - WINDOW_VISIBLE, WINDOW_DRAGGING, WINDOW_RESIZING, WINDOW_CANRESIZE @@ -47,6 +46,7 @@ public: virtual void Draw(void); virtual void SizeChanged(vector, vector); virtual bool Input(float, float, float, float); + virtual void Spawned(void); private: vector m_vecColor; @@ -61,16 +61,22 @@ private: virtual void(void) m_vMoveCB = 0; }; -void VGUIWindow::VGUIWindow(void) +void +VGUIWindow::VGUIWindow(void) +{ + m_vecColor = UI_MAINCOLOR; + m_flAlpha = 1.0f; +} + +void +VGUIWindow::Spawned(void) { static void WindowButtonClose(void) { m_parent.Hide(); } - m_vecColor = UI_MAINCOLOR; - m_flAlpha = 1.0f; - m_vecMinSize = [64,64]; - m_vecMaxSize = [640,480]; // TODO: Make this the screen res + SetMinSize([64,64]); + SetMaxSize([640,480]); // TODO: Make this the screen res m_strTitle = "Window"; @@ -87,6 +93,7 @@ void VGUIWindow::VGUIWindow(void) m_btnClose.SetFunc(WindowButtonClose); m_btnClose.SetSize([20,20]); Add(m_btnClose); + SetSize([320,240]); }