mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Added **"scalecvar"** widget command (used by Spearhead and Breakthrough compass)
This commit is contained in:
parent
c958bef261
commit
6f1b23ddb8
2 changed files with 48 additions and 6 deletions
|
@ -401,6 +401,15 @@ Event EV_Widget_EnabledCvar
|
|||
"Set the cvar to check to see if this button is enabled or not"
|
||||
);
|
||||
|
||||
Event EV_Widget_ScaleCvar
|
||||
(
|
||||
"scalecvar",
|
||||
EV_DEFAULT,
|
||||
"s",
|
||||
"cvar_name",
|
||||
"Set the cvar to check to scale this component"
|
||||
);
|
||||
|
||||
Event EV_Layout_AliasCache
|
||||
(
|
||||
"aliascache",
|
||||
|
@ -474,6 +483,7 @@ CLASS_DECLARATION( USignal, UIWidget, NULL )
|
|||
{ &EV_Widget_Enable, &UIWidget::EnableEvent },
|
||||
{ &EV_Widget_Disable, &UIWidget::DisableEvent },
|
||||
{ &EV_Widget_EnabledCvar, &UIWidget::SetEnabledCvar },
|
||||
{ &EV_Widget_ScaleCvar, &UIWidget::SetScaleCvar },
|
||||
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
@ -752,6 +762,13 @@ void UIWidget::PropogateCoordinateSystem
|
|||
int n;
|
||||
UIWidget *subview;
|
||||
|
||||
if (m_parent)
|
||||
{
|
||||
if (m_parent->m_scaleCvar) {
|
||||
m_scaleCvar = m_parent->m_scaleCvar;
|
||||
}
|
||||
}
|
||||
|
||||
if( !m_parent || (m_flags & WF_NOPARENTADJUST) )
|
||||
{
|
||||
m_screenorigin = m_origin;
|
||||
|
@ -997,8 +1014,7 @@ void UIWidget::AlignPosition
|
|||
{
|
||||
vec2_t vNewVirtualScale;
|
||||
|
||||
vNewVirtualScale[0] = uid.vidWidth / 640.0;
|
||||
vNewVirtualScale[1] = uid.vidHeight / 480.0;
|
||||
SetVirtualScale(vNewVirtualScale);
|
||||
|
||||
if (!VectorCompare2D(m_vVirtualScale, vNewVirtualScale))
|
||||
{
|
||||
|
@ -1670,6 +1686,26 @@ void UIWidget::SetEnabledCvar
|
|||
m_enabledCvar = ev->GetString( 1 );
|
||||
}
|
||||
|
||||
void UIWidget::SetScaleCvar
|
||||
(
|
||||
Event *ev
|
||||
)
|
||||
{
|
||||
m_scaleCvar = uii.Cvar_Find(ev->GetString(1).c_str());
|
||||
}
|
||||
|
||||
void UIWidget::SetVirtualScale(vec2_t out)
|
||||
{
|
||||
out[0] = uid.vidWidth / 640.0;
|
||||
out[1] = uid.vidHeight / 480.0;
|
||||
|
||||
if (m_scaleCvar)
|
||||
{
|
||||
out[0] *= m_scaleCvar->value;
|
||||
out[1] *= m_scaleCvar->value;
|
||||
}
|
||||
}
|
||||
|
||||
void UIWidget::setParent
|
||||
(
|
||||
UIWidget *parent
|
||||
|
@ -2619,8 +2655,7 @@ void UIWidget::Realign
|
|||
{
|
||||
vec2_t vNewVirtualScale;
|
||||
|
||||
vNewVirtualScale[0] = uid.vidWidth / 640.0;
|
||||
vNewVirtualScale[1] = uid.vidHeight / 480.0;
|
||||
SetVirtualScale(vNewVirtualScale);
|
||||
|
||||
if (!VectorCompare2D(m_vVirtualScale, vNewVirtualScale))
|
||||
{
|
||||
|
@ -3017,8 +3052,7 @@ void UIWidgetContainer::AlignPosition
|
|||
{
|
||||
vec2_t vNewVirtualScale;
|
||||
|
||||
vNewVirtualScale[0] = uid.vidWidth / 640.0;
|
||||
vNewVirtualScale[1] = uid.vidHeight / 480.0;
|
||||
SetVirtualScale(vNewVirtualScale);
|
||||
|
||||
if (!VectorCompare2D(m_vVirtualScale, vNewVirtualScale))
|
||||
{
|
||||
|
|
|
@ -120,6 +120,10 @@ protected:
|
|||
fontvertjustify_t m_iFontAlignmentVertical;
|
||||
qboolean m_bVirtual;
|
||||
str m_enabledCvar;
|
||||
//
|
||||
// New since 2.0
|
||||
//
|
||||
cvar_t* m_scaleCvar;
|
||||
|
||||
public:
|
||||
CLASS_PROTOTYPE( UIWidget );
|
||||
|
@ -180,6 +184,9 @@ public:
|
|||
void TextAlignment( Event *ev );
|
||||
void LayoutAliasCache( Event *ev );
|
||||
void SetEnabledCvar( Event *ev );
|
||||
void SetScaleCvar( Event *ev );
|
||||
|
||||
void SetVirtualScale(vec2_t out);
|
||||
void setParent( UIWidget *parent );
|
||||
class UIWidget *getParent( void );
|
||||
class UIWidget *getFirstChild( void );
|
||||
|
@ -190,6 +197,7 @@ public:
|
|||
class UIWidget *getPrevSibling( UIWidget *curr );
|
||||
class UIWidget *getLastSibling( void );
|
||||
class UIWidget *findSibling( str name );
|
||||
|
||||
void Enable( void );
|
||||
void Disable( void );
|
||||
bool isEnabled( void );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue