Skip to content

Instantly share code, notes, and snippets.

@BSVino
Created July 30, 2014 20:03
Show Gist options
  • Select an option

  • Save BSVino/248747f2b6f3a6d2b314 to your computer and use it in GitHub Desktop.

Select an option

Save BSVino/248747f2b6f3a6d2b314 to your computer and use it in GitHub Desktop.
diff -Nuar vgui_controls/analogbar.cpp vgui_editor/analogbar.cpp
--- vgui_controls/analogbar.cpp 2014-07-30 12:53:43.295871881 -0700
+++ vgui_editor/analogbar.cpp 2014-07-30 13:01:35.118830789 -0700
@@ -8,8 +8,8 @@
#include <math.h>
#include <stdio.h>
-#include <vgui_controls/AnalogBar.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/analogbar.h>
+#include <vgui_controls/controls.h>
#include <vgui/ILocalize.h>
#include <vgui/IScheme.h>
diff -Nuar vgui_controls/animatingimagepanel.cpp vgui_editor/animatingimagepanel.cpp
--- vgui_controls/animatingimagepanel.cpp 2014-07-30 12:53:43.295871881 -0700
+++ vgui_editor/animatingimagepanel.cpp 2014-07-30 13:01:35.186830793 -0700
@@ -15,7 +15,7 @@
#include <vgui/IVGui.h>
#include <KeyValues.h>
-#include <vgui_controls/AnimatingImagePanel.h>
+#include <vgui_controls/animatingimagepanel.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/animationcontroller.cpp vgui_editor/animationcontroller.cpp
--- vgui_controls/animationcontroller.cpp 2014-07-30 12:53:43.299873881 -0700
+++ vgui_editor/animationcontroller.cpp 2014-07-30 13:01:35.210830794 -0700
@@ -10,14 +10,14 @@
#include <vgui/ISystem.h>
#include <vgui/IVGui.h>
#include <KeyValues.h>
-#include <vgui_controls/AnimationController.h>
-#include "FileSystem.h"
-#include "FileSystem_Helpers.h"
+#include <vgui_controls/animationcontroller.h>
+#include "filesystem.h"
+#include "filesystem_helpers.h"
#include <stdio.h>
#include <math.h>
#include "mempool.h"
-#include "UtlDict.h"
+#include "utldict.h"
#include "mathlib/mathlib.h"
#include "characterset.h"
@@ -147,10 +147,10 @@
int size = g_pFullFileSystem->Size(f);
// read into temporary memory block
int nBufSize = size+1;
- if ( IsXbox() )
- {
- nBufSize = AlignValue( nBufSize, 512 );
- }
+ //if ( IsXbox() )
+ //{
+ // nBufSize = AlignValue( nBufSize, 512 );
+ //}
char *pMem = (char *)malloc(nBufSize);
int bytesRead = g_pFullFileSystem->ReadEx(pMem, nBufSize, size, f);
Assert(bytesRead <= size);
diff -Nuar vgui_controls/bitmapimagepanel.cpp vgui_editor/bitmapimagepanel.cpp
--- vgui_controls/bitmapimagepanel.cpp 2014-07-30 12:53:43.299873881 -0700
+++ vgui_editor/bitmapimagepanel.cpp 2014-07-30 13:01:35.086830790 -0700
@@ -7,7 +7,7 @@
#include <stdio.h>
-#include "vgui_controls/BitmapImagePanel.h"
+#include "vgui_controls/bitmapimagepanel.h"
#include "vgui/ISurface.h"
#include "vgui/IScheme.h"
#include "vgui/IBorder.h"
diff -Nuar vgui_controls/buildfactoryhelper.cpp vgui_editor/buildfactoryhelper.cpp
--- vgui_controls/buildfactoryhelper.cpp 2014-07-30 12:53:43.299873881 -0700
+++ vgui_editor/buildfactoryhelper.cpp 2014-07-30 13:01:35.194830793 -0700
@@ -1,4 +1,4 @@
-//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
+//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Helper for the CHudElement class to add themselves to the list of hud elements
//
diff -Nuar vgui_controls/buildgroup.cpp vgui_editor/buildgroup.cpp
--- vgui_controls/buildgroup.cpp 2014-07-30 12:53:43.299873881 -0700
+++ vgui_editor/buildgroup.cpp 2014-07-30 13:01:35.210830794 -0700
@@ -1,4 +1,4 @@
-//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
+//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -32,18 +32,20 @@
#include <vgui/IVGui.h>
#include <vgui/ISurface.h>
-#include <vgui_controls/BuildGroup.h>
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/PHandle.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/EditablePanel.h>
-#include <vgui_controls/MessageBox.h>
+#include <vgui_controls/buildgroup.h>
+#include <vgui_controls/panel.h>
+#include <vgui_controls/phandle.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/editablepanel.h>
+#include <vgui_controls/messagebox.h>
#include "filesystem.h"
#if defined( _X360 )
#include "xbox/xbox_win32stubs.h"
#endif
+#include "vgui_editor_platform.h"
+
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -79,9 +81,6 @@
for (int i=0; i<4; ++i)
_rulerNumber[i] = NULL;
SetContextPanel(contextPanel);
- _controlGroup = NULL;
- _groupDeltaX = 0;
- _groupDeltaX = 0;
_showRulers = false;
}
@@ -677,7 +676,7 @@
ApplySnap(panel);
panel->Repaint();
- if (panel->GetVParent() != NULL)
+ if (panel->GetVParent() != 0)
{
panel->PostMessage(panel->GetVParent(), new KeyValues("Repaint"));
}
@@ -870,7 +869,7 @@
//-----------------------------------------------------------------------------
// Purpose: loads the control settings from file
//-----------------------------------------------------------------------------
-void BuildGroup::LoadControlSettings(const char *controlResourceName, const char *pathID, KeyValues *pPreloadedKeyValues)
+void BuildGroup::LoadControlSettings(const char *controlResourceName, const char *pathID, KeyValues *pPreloadedKeyValues, KeyValues *pConditions)
{
// make sure the file is registered
RegisterControlSettingsFile(controlResourceName, pathID);
@@ -907,6 +906,11 @@
rDat->ProcessResolutionKeys( "_minmode" );
}
}
+
+ if ( pConditions && pConditions->GetFirstSubKey() )
+ {
+ ProcessConditionalKeys( rDat, pConditions );
+ }
}
}
@@ -940,6 +944,52 @@
}
}
+void BuildGroup::ProcessConditionalKeys( KeyValues *pData, KeyValues *pConditions )
+{
+ // for each condition, look for it in keys
+ // if its a positive condition, promote all of its children, replacing values
+
+ if ( pData )
+ {
+ KeyValues *pSubKey = pData->GetFirstSubKey();
+ if ( !pSubKey )
+ {
+ // not a block
+ return;
+ }
+
+ for ( ; pSubKey != NULL; pSubKey = pSubKey->GetNextKey() )
+ {
+ // recursively descend each sub block
+ ProcessConditionalKeys( pSubKey, pConditions );
+
+ KeyValues *pCondition = pConditions->GetFirstSubKey();
+ for ( ; pCondition != NULL; pCondition = pCondition->GetNextKey() )
+ {
+ // if we match any conditions in this sub block, copy up
+ KeyValues *pConditionBlock = pSubKey->FindKey( pCondition->GetName() );
+ if ( pConditionBlock )
+ {
+ KeyValues *pOverridingKey;
+ for ( pOverridingKey = pConditionBlock->GetFirstSubKey(); pOverridingKey != NULL; pOverridingKey = pOverridingKey->GetNextKey() )
+ {
+ KeyValues *pExistingKey = pSubKey->FindKey( pOverridingKey->GetName() );
+ if ( pExistingKey )
+ {
+ pExistingKey->SetStringValue( pOverridingKey->GetString() );
+ }
+ else
+ {
+ KeyValues *copy = pOverridingKey->MakeCopy();
+ pSubKey->AddSubKey( copy );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
//-----------------------------------------------------------------------------
// Purpose: registers that a control settings file may be loaded
// use when the dialog may have multiple states and the editor will need to be able to switch between them
@@ -1209,6 +1259,7 @@
Panel *newPanel = NULL;
if (controlKeys)
{
+// Warning( "Creating new control \"%s\" of type \"%s\"\n", controlKeys->GetString( "fieldName" ), controlKeys->GetString( "ControlName" ) );
KeyValues *keyVal = new KeyValues("ControlFactory", "ControlName", controlKeys->GetString("ControlName"));
m_pBuildContext->RequestInfo(keyVal);
// returns NULL on failure
diff -Nuar vgui_controls/buildmodedialog.cpp vgui_editor/buildmodedialog.cpp
--- vgui_controls/buildmodedialog.cpp 2014-07-30 12:53:43.299873881 -0700
+++ vgui_editor/buildmodedialog.cpp 2014-07-30 13:01:35.134830792 -0700
@@ -1,4 +1,4 @@
-//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
+//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -7,7 +7,7 @@
#include <ctype.h>
#include <stdio.h>
-#include <UtlVector.h>
+#include <utlvector.h>
#include <vgui/IInput.h>
#include <vgui/ILocalize.h>
@@ -17,19 +17,21 @@
#include <KeyValues.h>
#include <vgui/MouseCode.h>
-#include <vgui_controls/BuildModeDialog.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/TextEntry.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/CheckButton.h>
-#include <vgui_controls/RadioButton.h>
-#include <vgui_controls/MenuButton.h>
-#include <vgui_controls/ComboBox.h>
-#include <vgui_controls/BuildGroup.h>
-#include <vgui_controls/MessageBox.h>
-#include <vgui_controls/Menu.h>
-#include <vgui_controls/Divider.h>
-#include <vgui_controls/PanelListPanel.h>
+#include <vgui_controls/buildmodedialog.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/textentry.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/checkbutton.h>
+#include <vgui_controls/radiobutton.h>
+#include <vgui_controls/menubutton.h>
+#include <vgui_controls/combobox.h>
+#include <vgui_controls/buildgroup.h>
+#include <vgui_controls/messagebox.h>
+#include <vgui_controls/menu.h>
+#include <vgui_controls/divider.h>
+#include <vgui_controls/panellistpanel.h>
+
+#include "vgui_editor_platform.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -90,7 +92,7 @@
void RemoveAll( void )
{
- for ( int i = 0; i < m_PanelList.Size(); i++ )
+ for ( int i = 0; i < m_PanelList.Count(); i++ )
{
PanelItem_t *item = &m_PanelList[i];
delete item->m_EditLabel;
@@ -144,7 +146,7 @@
// lookup the value
StringIndex_t val = g_pVGuiLocalize->FindIndex(token);
- if (val != INVALID_STRING_INDEX)
+ if (val != INVALID_LOCALIZE_STRING_INDEX)
{
m_pValueEntry->SetText(g_pVGuiLocalize->GetValueByIndex(val));
@@ -188,6 +190,43 @@
vgui::Button *m_pCancelButton;
};
+class CBuildModeDialogMgr
+{
+public:
+
+ void Add( BuildModeDialog *pDlg );
+ void Remove( BuildModeDialog *pDlg );
+
+ int Count() const;
+
+private:
+ CUtlVector< BuildModeDialog * > m_vecBuildDialogs;
+};
+
+static CBuildModeDialogMgr g_BuildModeDialogMgr;
+
+void CBuildModeDialogMgr::Add( BuildModeDialog *pDlg )
+{
+ if ( m_vecBuildDialogs.Find( pDlg ) == m_vecBuildDialogs.InvalidIndex() )
+ {
+ m_vecBuildDialogs.AddToTail( pDlg );
+ }
+}
+
+void CBuildModeDialogMgr::Remove( BuildModeDialog *pDlg )
+{
+ m_vecBuildDialogs.FindAndRemove( pDlg );
+}
+
+int CBuildModeDialogMgr::Count() const
+{
+ return m_vecBuildDialogs.Count();
+}
+
+int GetBuildModeDialogCount()
+{
+ return g_BuildModeDialogMgr.Count();
+}
//-----------------------------------------------------------------------------
// Purpose: Constructor
@@ -210,6 +249,8 @@
CreateControls();
LoadUserConfig("BuildModeDialog");
+
+ g_BuildModeDialogMgr.Add( this );
}
//-----------------------------------------------------------------------------
@@ -217,6 +258,8 @@
//-----------------------------------------------------------------------------
BuildModeDialog::~BuildModeDialog()
{
+ g_BuildModeDialogMgr.Remove( this );
+
m_pPanelList->m_pResourceData->deleteThis();
m_pPanelList->m_pControls->DeleteAllItems();
if (_undoSettings)
@@ -553,14 +596,14 @@
// find the first alnum character
const char *tok = *string;
- while ( !isalnum(*tok) && *tok != 0 )
+ while ( !V_isalnum(*tok) && *tok != 0 )
{
tok++;
}
// read in all the alnum characters
int pos = 0;
- while ( isalnum(tok[pos]) )
+ while ( V_isalnum(tok[pos]) )
{
buf[pos] = tok[pos];
pos++;
@@ -795,7 +838,7 @@
control->GetSettings( dat );
// apply the settings to the edit panels
- for ( int i = 0; i < m_pPanelList->m_PanelList.Size(); i++ )
+ for ( int i = 0; i < m_pPanelList->m_PanelList.Count(); i++ )
{
const char *name = m_pPanelList->m_PanelList[i].m_szName;
const char *datstring = dat->GetString( name, "" );
@@ -932,7 +975,7 @@
{
char messageString[255];
Q_snprintf(messageString, sizeof( messageString ), "Fieldname is not unique: %s\nRename it and try again.", fieldName);
- MessageBox *errorBox = new MessageBox("Cannot Apply", messageString , false);
+ MessageBox *errorBox = new MessageBox("Cannot Apply", messageString);
errorBox->DoModal();
UpdateControlData(m_pCurrentPanel);
m_pApplyButton->SetEnabled(false);
@@ -945,7 +988,7 @@
KeyValues *dat = new KeyValues( m_pCurrentPanel->GetName() );
// loop through the textedit filling in settings
- for ( int i = 0; i < m_pPanelList->m_PanelList.Size(); i++ )
+ for ( int i = 0; i < m_pPanelList->m_PanelList.Count(); i++ )
{
const char *name = m_pPanelList->m_PanelList[i].m_szName;
char buf[512];
@@ -1069,7 +1112,7 @@
storedSettings = new KeyValues( m_pCurrentPanel->GetName() );
// loop through the textedit filling in settings
- for ( int i = 0; i < m_pPanelList->m_PanelList.Size(); i++ )
+ for ( int i = 0; i < m_pPanelList->m_PanelList.Count(); i++ )
{
const char *name = m_pPanelList->m_PanelList[i].m_szName;
char buf[512];
diff -Nuar vgui_controls/button.cpp vgui_editor/button.cpp
--- vgui_controls/button.cpp 2014-07-30 12:53:43.303875881 -0700
+++ vgui_editor/button.cpp 2014-07-30 13:01:35.078830789 -0700
@@ -6,7 +6,7 @@
//=============================================================================//
#include <stdio.h>
-#include <UtlSymbol.h>
+#include <utlsymbol.h>
#include <vgui/IBorder.h>
#include <vgui/IInput.h>
@@ -18,8 +18,8 @@
#include <vgui/KeyCode.h>
#include <KeyValues.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/FocusNavGroup.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/focusnavgroup.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -531,9 +531,9 @@
//-----------------------------------------------------------------------------
void Button::SetAsCurrentDefaultButton(int state)
{
- if ( _buttonFlags.IsFlagSet( DEFAULT_BUTTON ) != (bool)state )
+ if ( _buttonFlags.IsFlagSet( DEFAULT_BUTTON ) != (state != 0) )
{
- _buttonFlags.SetFlag( DEFAULT_BUTTON, state );
+ _buttonFlags.SetFlag( DEFAULT_BUTTON, state != 0 );
if (state)
{
// post a message up notifying our nav group that we're now the default button
@@ -557,9 +557,9 @@
//-----------------------------------------------------------------------------
void Button::SetAsDefaultButton(int state)
{
- if ( _buttonFlags.IsFlagSet( DEFAULT_BUTTON ) != (bool)state )
+ if ( _buttonFlags.IsFlagSet( DEFAULT_BUTTON ) != (state != 0) )
{
- _buttonFlags.SetFlag( DEFAULT_BUTTON, state );
+ _buttonFlags.SetFlag( DEFAULT_BUTTON, state != 0 );
if (state)
{
// post a message up notifying our nav group that we're now the default button
@@ -824,7 +824,7 @@
//-----------------------------------------------------------------------------
void Button::OnSetState(int state)
{
- SetSelected((bool)state);
+ SetSelected(state != 0);
Repaint();
}
diff -Nuar vgui_controls/checkbutton.cpp vgui_editor/checkbutton.cpp
--- vgui_controls/checkbutton.cpp 2014-07-30 12:53:43.303875881 -0700
+++ vgui_editor/checkbutton.cpp 2014-07-30 13:01:35.194830793 -0700
@@ -12,9 +12,9 @@
#include <vgui/IScheme.h>
#include <KeyValues.h>
-#include <vgui_controls/Image.h>
-#include <vgui_controls/CheckButton.h>
-#include <vgui_controls/TextImage.h>
+#include <vgui_controls/image.h>
+#include <vgui_controls/checkbutton.h>
+#include <vgui_controls/textimage.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/checkbuttonlist.cpp vgui_editor/checkbuttonlist.cpp
--- vgui_controls/checkbuttonlist.cpp 2014-07-30 12:53:43.303875881 -0700
+++ vgui_editor/checkbuttonlist.cpp 2014-07-30 13:01:35.098830787 -0700
@@ -4,9 +4,9 @@
//
//=============================================================================//
-#include <vgui_controls/CheckButtonList.h>
-#include <vgui_controls/CheckButton.h>
-#include <vgui_controls/ScrollBar.h>
+#include <vgui_controls/checkbuttonlist.h>
+#include <vgui_controls/checkbutton.h>
+#include <vgui_controls/scrollbar.h>
#include <KeyValues.h>
// memdbgon must be the last include file in a .cpp file!!!
diff -Nuar vgui_controls/circularprogressbar.cpp vgui_editor/circularprogressbar.cpp
--- vgui_controls/circularprogressbar.cpp 2014-07-30 12:53:43.303875881 -0700
+++ vgui_editor/circularprogressbar.cpp 2014-07-30 13:01:35.082830790 -0700
@@ -9,7 +9,7 @@
#include <math.h>
#include <stdio.h>
-#include <vgui_controls/CircularProgressBar.h>
+#include <vgui_controls/circularprogressbar.h>
#include <vgui/ILocalize.h>
#include <vgui/IScheme.h>
diff -Nuar vgui_controls/combobox.cpp vgui_editor/combobox.cpp
--- vgui_controls/combobox.cpp 2014-07-30 12:53:43.303875881 -0700
+++ vgui_editor/combobox.cpp 2014-07-30 13:01:35.090830788 -0700
@@ -15,14 +15,16 @@
#include "vgui/IPanel.h"
#include "KeyValues.h"
-#include "vgui_controls/Button.h"
-#include "vgui_controls/ComboBox.h"
-#include "vgui_controls/Menu.h"
-#include "vgui_controls/MenuItem.h"
-#include "vgui_controls/TextImage.h"
+#include "vgui_controls/button.h"
+#include "vgui_controls/combobox.h"
+#include "vgui_controls/menu.h"
+#include "vgui_controls/menuitem.h"
+#include "vgui_controls/textimage.h"
#include <ctype.h>
+#include "vgui_editor_platform.h"
+
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -497,7 +499,7 @@
// try lookup in localization tables
StringIndex_t unlocalizedTextSymbol = g_pVGuiLocalize->FindIndex(cbuf + 1);
- if (unlocalizedTextSymbol != INVALID_STRING_INDEX)
+ if (unlocalizedTextSymbol != INVALID_LOCALIZE_STRING_INDEX)
{
// we have a new text value
text = g_pVGuiLocalize->GetValueByIndex(unlocalizedTextSymbol);
@@ -585,6 +587,8 @@
{
m_pButton->SetArmed(false);
}
+
+ PostActionSignal( new KeyValues( "OnMenuClose", "szName", GetName() ) );
}
//-----------------------------------------------------------------------------
diff -Nuar vgui_controls/consoledialog.cpp vgui_editor/consoledialog.cpp
--- vgui_controls/consoledialog.cpp 2014-07-30 12:53:43.303875881 -0700
+++ vgui_editor/consoledialog.cpp 1969-12-31 16:00:00.000000000 -0800
@@ -1,1230 +0,0 @@
-//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#include "vgui_controls/ConsoleDialog.h"
-
-#include "vgui/IInput.h"
-#include "vgui/IScheme.h"
-#include "vgui/IVGui.h"
-#include "vgui/ISurface.h"
-#include "vgui/ILocalize.h"
-#include "KeyValues.h"
-
-#include "vgui_controls/Button.h"
-#include "vgui/KeyCode.h"
-#include "vgui_controls/Menu.h"
-#include "vgui_controls/TextEntry.h"
-#include "vgui_controls/RichText.h"
-#include "tier1/convar.h"
-#include "tier1/convar_serverbounded.h"
-#include "icvar.h"
-#include "FileSystem.h"
-
-#include <stdlib.h>
-
-#if defined( _X360 )
-#include "xbox/xbox_win32stubs.h"
-#endif
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include "tier0/memdbgon.h"
-
-using namespace vgui;
-
-
-//-----------------------------------------------------------------------------
-// Used by the autocompletion system
-//-----------------------------------------------------------------------------
-class CNonFocusableMenu : public Menu
-{
- DECLARE_CLASS_SIMPLE( CNonFocusableMenu, Menu );
-
-public:
- CNonFocusableMenu( Panel *parent, const char *panelName )
- : BaseClass( parent, panelName ),
- m_pFocus( 0 )
- {
- }
-
- void SetFocusPanel( Panel *panel )
- {
- m_pFocus = panel;
- }
-
- VPANEL GetCurrentKeyFocus()
- {
- if ( !m_pFocus )
- return GetVPanel();
-
- return m_pFocus->GetVPanel();
- }
-
-private:
- Panel *m_pFocus;
-};
-
-
-//-----------------------------------------------------------------------------
-// Purpose: forwards tab key presses up from the text entry so we can do autocomplete
-//-----------------------------------------------------------------------------
-class TabCatchingTextEntry : public TextEntry
-{
-public:
- TabCatchingTextEntry(Panel *parent, const char *name, VPANEL comp) : TextEntry(parent, name), m_pCompletionList( comp )
- {
- SetAllowNonAsciiCharacters( true );
- SetDragEnabled( true );
- }
-
- virtual void OnKeyCodeTyped(KeyCode code)
- {
- if (code == KEY_TAB)
- {
- GetParent()->OnKeyCodeTyped(code);
- }
- else if ( code == KEY_ENTER )
- {
- PostMessage( GetParent()->GetVPanel(), new KeyValues( "Command", "command", "submit" ) );
- }
- else
- {
- TextEntry::OnKeyCodeTyped(code);
- }
- }
-
- virtual void OnKillFocus()
- {
- if ( input()->GetFocus() != m_pCompletionList ) // if its not the completion window trying to steal our focus
- {
- PostMessage(GetParent(), new KeyValues("CloseCompletionList"));
- }
- }
-
-private:
- VPANEL m_pCompletionList;
-};
-
-
-
-// Things the user typed in and hit submit/return with
-CHistoryItem::CHistoryItem( void )
-{
- m_text = NULL;
- m_extraText = NULL;
- m_bHasExtra = false;
-}
-
-CHistoryItem::CHistoryItem( const char *text, const char *extra )
-{
- Assert( text );
- m_text = NULL;
- m_extraText = NULL;
- m_bHasExtra = false;
- SetText( text , extra );
-}
-
-CHistoryItem::CHistoryItem( const CHistoryItem& src )
-{
- m_text = NULL;
- m_extraText = NULL;
- m_bHasExtra = false;
- SetText( src.GetText(), src.GetExtra() );
-}
-
-CHistoryItem::~CHistoryItem( void )
-{
- delete[] m_text;
- delete[] m_extraText;
- m_text = NULL;
-}
-
-const char *CHistoryItem::GetText() const
-{
- if ( m_text )
- {
- return m_text;
- }
- else
- {
- return "";
- }
-}
-
-const char *CHistoryItem::GetExtra() const
-{
- if ( m_extraText )
- {
- return m_extraText;
- }
- else
- {
- return NULL;
- }
-}
-
-void CHistoryItem::SetText( const char *text, const char *extra )
-{
- delete[] m_text;
- int len = strlen( text ) + 1;
-
- m_text = new char[ len ];
- Q_memset( m_text, 0x0, len );
- Q_strncpy( m_text, text, len );
-
- if ( extra )
- {
- m_bHasExtra = true;
- delete[] m_extraText;
- int elen = strlen( extra ) + 1;
- m_extraText = new char[ elen ];
- Q_memset( m_extraText, 0x0, elen);
- Q_strncpy( m_extraText, extra, elen );
- }
- else
- {
- m_bHasExtra = false;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-//
-// Console page completion item starts here
-//
-//-----------------------------------------------------------------------------
-CConsolePanel::CompletionItem::CompletionItem( void )
-{
- m_bIsCommand = true;
- m_pCommand = NULL;
- m_pText = NULL;
-}
-
-CConsolePanel::CompletionItem::CompletionItem( const CompletionItem& src )
-{
- m_bIsCommand = src.m_bIsCommand;
- m_pCommand = src.m_pCommand;
- if ( src.m_pText )
- {
- m_pText = new CHistoryItem( (const CHistoryItem& )src.m_pText );
- }
- else
- {
- m_pText = NULL;
- }
-}
-
-CConsolePanel::CompletionItem& CConsolePanel::CompletionItem::operator =( const CompletionItem& src )
-{
- if ( this == &src )
- return *this;
-
- m_bIsCommand = src.m_bIsCommand;
- m_pCommand = src.m_pCommand;
- if ( src.m_pText )
- {
- m_pText = new CHistoryItem( (const CHistoryItem& )*src.m_pText );
- }
- else
- {
- m_pText = NULL;
- }
-
- return *this;
-}
-
-CConsolePanel::CompletionItem::~CompletionItem( void )
-{
- if ( m_pText )
- {
- delete m_pText;
- m_pText = NULL;
- }
-}
-
-const char *CConsolePanel::CompletionItem::GetName() const
-{
- if ( m_bIsCommand )
- return m_pCommand->GetName();
- return m_pCommand ? m_pCommand->GetName() : GetCommand();
-}
-
-const char *CConsolePanel::CompletionItem::GetItemText( void )
-{
- static char text[256];
- text[0] = 0;
- if ( m_pText )
- {
- if ( m_pText->HasExtra() )
- {
- Q_snprintf( text, sizeof( text ), "%s %s", m_pText->GetText(), m_pText->GetExtra() );
- }
- else
- {
- Q_strncpy( text, m_pText->GetText(), sizeof( text ) );
- }
- }
- return text;
-}
-
-const char *CConsolePanel::CompletionItem::GetCommand( void ) const
-{
- static char text[256];
- text[0] = 0;
- if ( m_pText )
- {
- Q_strncpy( text, m_pText->GetText(), sizeof( text ) );
- }
- return text;
-}
-
-
-//-----------------------------------------------------------------------------
-//
-// Console page starts here
-//
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Constructor, destuctor
-//-----------------------------------------------------------------------------
-CConsolePanel::CConsolePanel( vgui::Panel *pParent, const char *pName, bool bStatusVersion ) :
- BaseClass( pParent, pName ), m_bStatusVersion( bStatusVersion )
-{
- SetKeyBoardInputEnabled( true );
-
- if ( !m_bStatusVersion )
- {
- SetMinimumSize(100,100);
- }
-
- // create controls
- m_pHistory = new RichText(this, "ConsoleHistory");
- m_pHistory->SetAllowKeyBindingChainToParent( false );
- SETUP_PANEL( m_pHistory );
- m_pHistory->SetVerticalScrollbar( !m_bStatusVersion );
- if ( m_bStatusVersion )
- {
- m_pHistory->SetDrawOffsets( 3, 3 );
- }
- m_pHistory->GotoTextEnd();
-
- m_pSubmit = new Button(this, "ConsoleSubmit", "#Console_Submit");
- m_pSubmit->SetCommand("submit");
- m_pSubmit->SetVisible( !m_bStatusVersion );
-
- CNonFocusableMenu *pCompletionList = new CNonFocusableMenu( this, "CompletionList" );
- m_pCompletionList = pCompletionList;
- m_pCompletionList->SetVisible(false);
-
- m_pEntry = new TabCatchingTextEntry(this, "ConsoleEntry", m_pCompletionList->GetVPanel() );
- m_pEntry->AddActionSignalTarget(this);
- m_pEntry->SendNewLine(true);
- pCompletionList->SetFocusPanel( m_pEntry );
-
- // need to set up default colors, since ApplySchemeSettings won't be called until later
- m_PrintColor = Color(216, 222, 211, 255);
- m_DPrintColor = Color(196, 181, 80, 255);
-
- m_pEntry->SetTabPosition(1);
-
- m_bAutoCompleteMode = false;
- m_szPartialText[0] = 0;
- m_szPreviousPartialText[0]=0;
-
- // Add to global console list
- g_pCVar->InstallConsoleDisplayFunc( this );
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Destructor
-//-----------------------------------------------------------------------------
-CConsolePanel::~CConsolePanel()
-{
- ClearCompletionList();
- m_CommandHistory.Purge();
- g_pCVar->RemoveConsoleDisplayFunc( this );
-}
-
-
-//-----------------------------------------------------------------------------
-// Updates the completion list
-//-----------------------------------------------------------------------------
-void CConsolePanel::OnThink()
-{
- BaseClass::OnThink();
-
- if ( !IsVisible() )
- return;
-
- if ( !m_pCompletionList->IsVisible() )
- return;
-
- UpdateCompletionListPosition();
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Clears the console
-//-----------------------------------------------------------------------------
-void CConsolePanel::Clear()
-{
- m_pHistory->SetText("");
- m_pHistory->GotoTextEnd();
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: color text print
-//-----------------------------------------------------------------------------
-void CConsolePanel::ColorPrint( const Color& clr, const char *msg )
-{
- if ( m_bStatusVersion )
- {
- Clear();
- }
-
- m_pHistory->InsertColorChange( clr );
- m_pHistory->InsertString( msg );
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: normal text print
-//-----------------------------------------------------------------------------
-void CConsolePanel::Print(const char *msg)
-{
- ColorPrint( m_PrintColor, msg );
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: debug text print
-//-----------------------------------------------------------------------------
-void CConsolePanel::DPrint( const char *msg )
-{
- ColorPrint( m_DPrintColor, msg );
-}
-
-
-void CConsolePanel::ClearCompletionList()
-{
- int c = m_CompletionList.Count();
- int i;
- for ( i = c - 1; i >= 0; i-- )
- {
- delete m_CompletionList[ i ];
- }
- m_CompletionList.Purge();
-}
-
-
-static ConCommand *FindAutoCompleteCommmandFromPartial( const char *partial )
-{
- char command[ 256 ];
- Q_strncpy( command, partial, sizeof( command ) );
-
- char *space = Q_strstr( command, " " );
- if ( space )
- {
- *space = 0;
- }
-
- ConCommand *cmd = g_pCVar->FindCommand( command );
- if ( !cmd )
- return NULL;
-
- if ( !cmd->CanAutoComplete() )
- return NULL;
-
- return cmd;
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: rebuilds the list of possible completions from the current entered text
-//-----------------------------------------------------------------------------
-void CConsolePanel::RebuildCompletionList(const char *text)
-{
- ClearCompletionList();
-
- // we need the length of the text for the partial string compares
- int len = Q_strlen(text);
- if ( len < 1 )
- {
- // Fill the completion list with history instead
- for ( int i = 0 ; i < m_CommandHistory.Count(); i++ )
- {
- CHistoryItem *item = &m_CommandHistory[ i ];
- CompletionItem *comp = new CompletionItem();
- m_CompletionList.AddToTail( comp );
- comp->m_bIsCommand = false;
- comp->m_pCommand = NULL;
- comp->m_pText = new CHistoryItem( *item );
- }
- return;
- }
-
- bool bNormalBuild = true;
-
- // if there is a space in the text, and the command isn't of the type to know how to autocomplet, then command completion is over
- const char *space = strstr( text, " " );
- if ( space )
- {
- ConCommand *pCommand = FindAutoCompleteCommmandFromPartial( text );
- if ( !pCommand )
- return;
-
- bNormalBuild = false;
-
- CUtlVector< CUtlString > commands;
- int count = pCommand->AutoCompleteSuggest( text, commands );
- Assert( count <= COMMAND_COMPLETION_MAXITEMS );
- int i;
-
- for ( i = 0; i < count; i++ )
- {
- // match found, add to list
- CompletionItem *item = new CompletionItem();
- m_CompletionList.AddToTail( item );
- item->m_bIsCommand = false;
- item->m_pCommand = NULL;
- item->m_pText = new CHistoryItem( commands[ i ].String() );
- }
- }
-
- if ( bNormalBuild )
- {
- // look through the command list for all matches
- ConCommandBase const *cmd = (ConCommandBase const *)cvar->GetCommands();
- while (cmd)
- {
- if ( cmd->IsFlagSet( FCVAR_DEVELOPMENTONLY ) || cmd->IsFlagSet( FCVAR_HIDDEN ) )
- {
- cmd = cmd->GetNext();
- continue;
- }
-
- if ( !strnicmp(text, cmd->GetName(), len))
- {
- // match found, add to list
- CompletionItem *item = new CompletionItem();
- m_CompletionList.AddToTail( item );
- item->m_pCommand = (ConCommandBase *)cmd;
- const char *tst = cmd->GetName();
- if ( !cmd->IsCommand() )
- {
- item->m_bIsCommand = false;
- ConVar *var = ( ConVar * )cmd;
- ConVar_ServerBounded *pBounded = dynamic_cast<ConVar_ServerBounded*>( var );
- if ( pBounded || var->IsFlagSet( FCVAR_NEVER_AS_STRING ) )
- {
- char strValue[512];
-
- int intVal = pBounded ? pBounded->GetInt() : var->GetInt();
- float floatVal = pBounded ? pBounded->GetFloat() : var->GetFloat();
-
- if ( floatVal == intVal )
- Q_snprintf( strValue, sizeof( strValue ), "%d", intVal );
- else
- Q_snprintf( strValue, sizeof( strValue ), "%f", floatVal );
-
- item->m_pText = new CHistoryItem( var->GetName(), strValue );
- }
- else
- {
- item->m_pText = new CHistoryItem( var->GetName(), var->GetString() );
- }
- }
- else
- {
- item->m_bIsCommand = true;
- item->m_pText = new CHistoryItem( tst );
- }
- }
-
- cmd = cmd->GetNext();
- }
-
- // Now sort the list by command name
- if ( m_CompletionList.Count() >= 2 )
- {
- for ( int i = 0 ; i < m_CompletionList.Count(); i++ )
- {
- for ( int j = i + 1; j < m_CompletionList.Count(); j++ )
- {
- const CompletionItem *i1, *i2;
- i1 = m_CompletionList[ i ];
- i2 = m_CompletionList[ j ];
-
- if ( Q_stricmp( i1->GetName(), i2->GetName() ) > 0 )
- {
- CompletionItem *temp = m_CompletionList[ i ];
- m_CompletionList[ i ] = m_CompletionList[ j ];
- m_CompletionList[ j ] = temp;
- }
- }
- }
- }
- }
-
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: auto completes current text
-//-----------------------------------------------------------------------------
-void CConsolePanel::OnAutoComplete(bool reverse)
-{
- if (!m_bAutoCompleteMode)
- {
- // we're not in auto-complete mode, Start
- m_iNextCompletion = 0;
- m_bAutoCompleteMode = true;
- }
-
- // if we're in reverse, move back to before the current
- if (reverse)
- {
- m_iNextCompletion -= 2;
- if (m_iNextCompletion < 0)
- {
- // loop around in reverse
- m_iNextCompletion = m_CompletionList.Size() - 1;
- }
- }
-
- // get the next completion
- if (!m_CompletionList.IsValidIndex(m_iNextCompletion))
- {
- // loop completion list
- m_iNextCompletion = 0;
- }
-
- // make sure everything is still valid
- if (!m_CompletionList.IsValidIndex(m_iNextCompletion))
- return;
-
- // match found, set text
- char completedText[256];
- CompletionItem *item = m_CompletionList[m_iNextCompletion];
- Assert( item );
-
- if ( !item->m_bIsCommand && item->m_pCommand )
- {
- Q_strncpy(completedText, item->GetCommand(), sizeof(completedText) - 2 );
- }
- else
- {
- Q_strncpy(completedText, item->GetItemText(), sizeof(completedText) - 2 );
- }
-
- if ( !Q_strstr( completedText, " " ) )
- {
- Q_strncat(completedText, " ", sizeof(completedText), COPY_ALL_CHARACTERS );
- }
-
- m_pEntry->SetText(completedText);
- m_pEntry->SelectNone();
- m_pEntry->GotoTextEnd();
-
- m_iNextCompletion++;
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Called whenever the user types text
-//-----------------------------------------------------------------------------
-void CConsolePanel::OnTextChanged(Panel *panel)
-{
- if (panel != m_pEntry)
- return;
-
- Q_strncpy( m_szPreviousPartialText, m_szPartialText, sizeof( m_szPreviousPartialText ) );
-
- // get the partial text the user type
- m_pEntry->GetText(m_szPartialText, sizeof(m_szPartialText));
-
- // see if they've hit the tilde key (which opens & closes the console)
- int len = Q_strlen(m_szPartialText);
-
- bool hitTilde = ( m_szPartialText[len - 1] == '~' || m_szPartialText[len - 1] == '`' ) ? true : false;
-
- bool altKeyDown = ( vgui::input()->IsKeyDown( KEY_LALT ) || vgui::input()->IsKeyDown( KEY_RALT ) ) ? true : false;
- bool ctrlKeyDown = ( vgui::input()->IsKeyDown( KEY_LCONTROL ) || vgui::input()->IsKeyDown( KEY_RCONTROL ) ) ? true : false;
-
- // Alt-Tilde toggles Japanese IME on/off!!!
- if ( ( len > 0 ) && hitTilde )
- {
- // Strip the last character (tilde)
- m_szPartialText[ len - 1 ] = L'\0';
-
- if( !altKeyDown && !ctrlKeyDown )
- {
- m_pEntry->SetText( "" );
-
- // close the console
- PostMessage( this, new KeyValues( "Close" ) );
- PostActionSignal( new KeyValues( "ClosedByHittingTilde" ) );
- }
- else
- {
- m_pEntry->SetText( m_szPartialText );
- }
- return;
- }
-
- // clear auto-complete state since the user has typed
- m_bAutoCompleteMode = false;
-
- RebuildCompletionList(m_szPartialText);
-
- // build the menu
- if ( m_CompletionList.Count() < 1 )
- {
- m_pCompletionList->SetVisible(false);
- }
- else
- {
- m_pCompletionList->SetVisible(true);
- m_pCompletionList->DeleteAllItems();
- const int MAX_MENU_ITEMS = 10;
-
- // add the first ten items to the list
- for (int i = 0; i < m_CompletionList.Count() && i < MAX_MENU_ITEMS; i++)
- {
- char text[256];
- text[0] = 0;
- if (i == MAX_MENU_ITEMS - 1)
- {
- Q_strncpy(text, "...", sizeof( text ) );
- }
- else
- {
- Assert( m_CompletionList[i] );
- Q_strncpy(text, m_CompletionList[i]->GetItemText(), sizeof( text ) );
- }
- KeyValues *kv = new KeyValues("CompletionCommand");
- kv->SetString("command",text);
- m_pCompletionList->AddMenuItem(text, kv, this);
- }
-
- UpdateCompletionListPosition();
- }
-
- RequestFocus();
- m_pEntry->RequestFocus();
-
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: generic vgui command handler
-//-----------------------------------------------------------------------------
-void CConsolePanel::OnCommand(const char *command)
-{
- if ( !Q_stricmp( command, "Submit" ) )
- {
- // submit the entry as a console commmand
- char szCommand[256];
- m_pEntry->GetText(szCommand, sizeof(szCommand));
- PostActionSignal( new KeyValues( "CommandSubmitted", "command", szCommand ) );
-
- // add to the history
- Print("] ");
- Print(szCommand);
- Print("\n");
-
- // clear the field
- m_pEntry->SetText("");
-
- // clear the completion state
- OnTextChanged(m_pEntry);
-
- // always go the end of the buffer when the user has typed something
- m_pHistory->GotoTextEnd();
-
- // Add the command to the history
- char *extra = strchr(szCommand, ' ');
- if ( extra )
- {
- *extra = '\0';
- extra++;
- }
-
- if ( Q_strlen( szCommand ) > 0 )
- {
- AddToHistory( szCommand, extra );
- }
- m_pCompletionList->SetVisible(false);
- }
- else
- {
- BaseClass::OnCommand(command);
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Focus related methods
-//-----------------------------------------------------------------------------
-bool CConsolePanel::TextEntryHasFocus() const
-{
- return ( input()->GetFocus() == m_pEntry->GetVPanel() );
-}
-
-void CConsolePanel::TextEntryRequestFocus()
-{
- m_pEntry->RequestFocus();
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: swallows tab key pressed
-//-----------------------------------------------------------------------------
-void CConsolePanel::OnKeyCodeTyped(KeyCode code)
-{
- BaseClass::OnKeyCodeTyped(code);
-
- // check for processing
- if ( TextEntryHasFocus() )
- {
- if (code == KEY_TAB)
- {
- bool reverse = false;
- if (input()->IsKeyDown(KEY_LSHIFT) || input()->IsKeyDown(KEY_RSHIFT))
- {
- reverse = true;
- }
-
- // attempt auto-completion
- OnAutoComplete(reverse);
- m_pEntry->RequestFocus();
- }
- else if (code == KEY_DOWN)
- {
- OnAutoComplete(false);
- // UpdateCompletionListPosition();
- // m_pCompletionList->SetVisible(true);
-
- m_pEntry->RequestFocus();
- }
- else if (code == KEY_UP)
- {
- OnAutoComplete(true);
- m_pEntry->RequestFocus();
- }
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: lays out controls
-//-----------------------------------------------------------------------------
-void CConsolePanel::PerformLayout()
-{
- BaseClass::PerformLayout();
-
- // setup tab ordering
- GetFocusNavGroup().SetDefaultButton(m_pSubmit);
-
- IScheme *pScheme = scheme()->GetIScheme( GetScheme() );
- m_pEntry->SetBorder(pScheme->GetBorder("DepressedButtonBorder"));
- m_pHistory->SetBorder(pScheme->GetBorder("DepressedButtonBorder"));
-
- // layout controls
- int wide, tall;
- GetSize(wide, tall);
-
- if ( !m_bStatusVersion )
- {
- const int inset = 8;
- const int entryHeight = 24;
- const int topHeight = 4;
- const int entryInset = 4;
- const int submitWide = 64;
- const int submitInset = 7; // x inset to pull the submit button away from the frame grab
-
- m_pHistory->SetPos(inset, inset + topHeight);
- m_pHistory->SetSize(wide - (inset * 2), tall - (entryInset * 2 + inset * 2 + topHeight + entryHeight));
- m_pHistory->InvalidateLayout();
-
- int nSubmitXPos = wide - ( inset + submitWide + submitInset );
- m_pSubmit->SetPos( nSubmitXPos, tall - (entryInset * 2 + entryHeight));
- m_pSubmit->SetSize( submitWide, entryHeight);
-
- m_pEntry->SetPos( inset, tall - (entryInset * 2 + entryHeight) );
- m_pEntry->SetSize( nSubmitXPos - entryInset - 2 * inset, entryHeight);
- }
- else
- {
- const int inset = 2;
-
- int entryWidth = wide / 2;
- if ( wide > 400 )
- {
- entryWidth = 200;
- }
-
- m_pEntry->SetBounds( inset, inset, entryWidth, tall - 2 * inset );
-
- m_pHistory->SetBounds( inset + entryWidth + inset, inset, ( wide - entryWidth ) - inset, tall - 2 * inset );
- }
-
- UpdateCompletionListPosition();
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: Sets the position of the completion list popup
-//-----------------------------------------------------------------------------
-void CConsolePanel::UpdateCompletionListPosition()
-{
- int ex, ey;
- m_pEntry->GetPos(ex, ey);
-
- if ( !m_bStatusVersion )
- {
- // Position below text entry
- ey += m_pEntry->GetTall();
- }
- else
- {
- // Position above text entry
- int menuwide, menutall;
- m_pCompletionList->GetSize( menuwide, menutall );
- ey -= ( menutall + 4 );
- }
-
- LocalToScreen( ex, ey );
- m_pCompletionList->SetPos( ex, ey );
-
- if ( m_pCompletionList->IsVisible() )
- {
- m_pEntry->RequestFocus();
- MoveToFront();
- m_pCompletionList->MoveToFront();
- }
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: Closes the completion list
-//-----------------------------------------------------------------------------
-void CConsolePanel::CloseCompletionList()
-{
- m_pCompletionList->SetVisible(false);
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: sets up colors
-//-----------------------------------------------------------------------------
-void CConsolePanel::ApplySchemeSettings(IScheme *pScheme)
-{
- BaseClass::ApplySchemeSettings(pScheme);
-
- m_PrintColor = GetSchemeColor("Console.TextColor", pScheme);
- m_DPrintColor = GetSchemeColor("Console.DevTextColor", pScheme);
- m_pHistory->SetFont( pScheme->GetFont( "ConsoleText", IsProportional() ) );
- m_pCompletionList->SetFont( pScheme->GetFont( "DefaultSmall", IsProportional() ) );
- InvalidateLayout();
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: Handles autocompletion menu input
-//-----------------------------------------------------------------------------
-void CConsolePanel::OnMenuItemSelected(const char *command)
-{
- if ( strstr( command, "..." ) ) // stop the menu going away if you click on ...
- {
- m_pCompletionList->SetVisible( true );
- }
- else
- {
- m_pEntry->SetText(command);
- m_pEntry->GotoTextEnd();
- m_pEntry->InsertChar(' ');
- m_pEntry->GotoTextEnd();
- }
-}
-
-void CConsolePanel::Hide()
-{
- OnClose();
- m_iNextCompletion = 0;
- RebuildCompletionList("");
-}
-
-void CConsolePanel::AddToHistory( const char *commandText, const char *extraText )
-{
- // Newest at end, oldest at head
- while ( m_CommandHistory.Count() >= MAX_HISTORY_ITEMS )
- {
- // Remove from head until size is reasonable
- m_CommandHistory.Remove( 0 );
- }
-
- // strip the space off the end of the command before adding it to the history
- char *command = static_cast<char *>( _alloca( (strlen( commandText ) + 1 ) * sizeof( char ) ));
- if ( command )
- {
- memset( command, 0x0, strlen( commandText ) + 1 );
- strncpy( command, commandText, strlen( commandText ));
- if ( command[ strlen( command ) -1 ] == ' ' )
- {
- command[ strlen( command ) -1 ] = '\0';
- }
- }
-
- // strip the quotes off the extra text
- char *extra = NULL;
-
- if ( extraText )
- {
- extra = static_cast<char *>( malloc( (strlen( extraText ) + 1 ) * sizeof( char ) ));
- if ( extra )
- {
- memset( extra, 0x0, strlen( extraText ) + 1 );
- strncpy( extra, extraText, strlen( extraText )); // +1 to dodge the starting quote
-
- // Strip trailing spaces
- int i = strlen( extra ) - 1;
- while ( i >= 0 && // Check I before referencing i == -1 into the extra array!
- extra[ i ] == ' ' )
- {
- extra[ i ] = '\0';
- i--;
- }
- }
- }
-
- // If it's already there, then remove since we'll add it to the end instead
- CHistoryItem *item = NULL;
- for ( int i = m_CommandHistory.Count() - 1; i >= 0; i-- )
- {
- item = &m_CommandHistory[ i ];
- if ( !item )
- continue;
-
- if ( stricmp( item->GetText(), command ) )
- continue;
-
- if ( extra || item->GetExtra() )
- {
- if ( !extra || !item->GetExtra() )
- continue;
-
- // stricmp so two commands with the same starting text get added
- if ( stricmp( item->GetExtra(), extra ) )
- continue;
- }
- m_CommandHistory.Remove( i );
- }
-
- item = &m_CommandHistory[ m_CommandHistory.AddToTail() ];
- Assert( item );
- item->SetText( command, extra );
-
- m_iNextCompletion = 0;
- RebuildCompletionList( m_szPartialText );
-
- free( extra );
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: writes out console to disk
-//-----------------------------------------------------------------------------
-void CConsolePanel::DumpConsoleTextToFile()
-{
- const int CONDUMP_FILES_MAX_NUM = 1000;
-
- FileHandle_t handle;
- bool found = false;
- char szfile[ 512 ];
-
- // we don't want to overwrite other condump.txt files
- for ( int i = 0 ; i < CONDUMP_FILES_MAX_NUM ; ++i )
- {
- _snprintf( szfile, sizeof(szfile), "condump%03d.txt", i );
- if ( !g_pFullFileSystem->FileExists(szfile) )
- {
- found = true;
- break;
- }
- }
-
- if ( !found )
- {
- Print( "Can't condump! Too many existing condump output files in the gamedir!\n" );
- return;
- }
-
- handle = g_pFullFileSystem->Open( szfile, "wb" );
- if ( handle != FILESYSTEM_INVALID_HANDLE )
- {
- int pos = 0;
- while (1)
- {
- wchar_t buf[512];
- m_pHistory->GetText(pos, buf, sizeof(buf));
- pos += sizeof(buf) / sizeof(wchar_t);
-
- // don't continue if none left
- if (buf[0] == 0)
- break;
-
- // convert to ansi
- char ansi[512];
- g_pVGuiLocalize->ConvertUnicodeToANSI(buf, ansi, sizeof(ansi));
-
- // write to disk
- int len = strlen(ansi);
- for (int i = 0; i < len; i++)
- {
- // preceed newlines with a return
- if (ansi[i] == '\n')
- {
- char ret = '\r';
- g_pFullFileSystem->Write( &ret, 1, handle );
- }
-
- g_pFullFileSystem->Write( ansi + i, 1, handle );
- }
- }
-
- g_pFullFileSystem->Close( handle );
-
- Print( "console dumped to " );
- Print( szfile );
- Print( "\n" );
- }
- else
- {
- Print( "Unable to condump to " );
- Print( szfile );
- Print( "\n" );
- }
-}
-
-
-//-----------------------------------------------------------------------------
-//
-// Console dialog starts here
-//
-//-----------------------------------------------------------------------------
-CConsoleDialog::CConsoleDialog( vgui::Panel *pParent, const char *pName, bool bStatusVersion ) :
- BaseClass( pParent, pName )
-{
- // initialize dialog
- SetVisible( false );
- SetTitle( "#Console_Title", true );
- m_pConsolePanel = new CConsolePanel( this, "ConsolePage", bStatusVersion );
-}
-
-void CConsoleDialog::OnScreenSizeChanged( int iOldWide, int iOldTall )
-{
- BaseClass::OnScreenSizeChanged( iOldWide, iOldTall );
-
- int sx, sy;
- surface()->GetScreenSize( sx, sy );
-
- int w, h;
- GetSize( w, h );
- if ( w > sx || h > sy )
- {
- if ( w > sx )
- {
- w = sx;
- }
- if ( h > sy )
- {
- h = sy;
- }
-
- // Try and lower the size to match the screen bounds
- SetSize( w, h );
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: brings dialog to the fore
-//-----------------------------------------------------------------------------
-void CConsoleDialog::PerformLayout()
-{
- BaseClass::PerformLayout();
-
- int x, y, w, h;
- GetClientArea( x, y, w, h );
- m_pConsolePanel->SetBounds( x, y, w, h );
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: brings dialog to the fore
-//-----------------------------------------------------------------------------
-void CConsoleDialog::Activate()
-{
- BaseClass::Activate();
- m_pConsolePanel->m_pEntry->RequestFocus();
-}
-
-
-//-----------------------------------------------------------------------------
-// Hides the dialog
-//-----------------------------------------------------------------------------
-void CConsoleDialog::Hide()
-{
- OnClose();
- m_pConsolePanel->Hide();
-}
-
-
-//-----------------------------------------------------------------------------
-// Close just hides the dialog
-//-----------------------------------------------------------------------------
-void CConsoleDialog::Close()
-{
- Hide();
-}
-
-
-//-----------------------------------------------------------------------------
-// Submits commands
-//-----------------------------------------------------------------------------
-void CConsoleDialog::OnCommandSubmitted( const char *pCommand )
-{
- PostActionSignal( new KeyValues( "CommandSubmitted", "command", pCommand ) );
-}
-
-
-//-----------------------------------------------------------------------------
-// Chain to the page
-//-----------------------------------------------------------------------------
-void CConsoleDialog::Print( const char *pMessage )
-{
- m_pConsolePanel->Print( pMessage );
-}
-
-void CConsoleDialog::DPrint( const char *pMessage )
-{
- m_pConsolePanel->DPrint( pMessage );
-}
-
-void CConsoleDialog::ColorPrint( const Color& clr, const char *msg )
-{
- m_pConsolePanel->ColorPrint( clr, msg );
-}
-
-void CConsoleDialog::Clear()
-{
- m_pConsolePanel->Clear( );
-}
-
-void CConsoleDialog::DumpConsoleTextToFile()
-{
- m_pConsolePanel->DumpConsoleTextToFile( );
-}
-
-
diff -Nuar vgui_controls/controls.cpp vgui_editor/controls.cpp
--- vgui_controls/controls.cpp 2014-07-30 12:53:43.303875881 -0700
+++ vgui_editor/controls.cpp 2014-07-30 13:01:35.070830786 -0700
@@ -5,7 +5,7 @@
// $NoKeywords: $
//===========================================================================//
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/controls.h>
#include <locale.h>
// memdbgon must be the last include file in a .cpp file!!!
@@ -13,6 +13,16 @@
extern int g_nYou_Must_Add_Public_Vgui_Controls_Vgui_ControlsCpp_To_Your_Project;
+class CircularProgressBar;
+CircularProgressBar *g_CircularProgressBarLinkerHack;
+
+namespace vgui
+{
+ class Slider;
+}
+
+vgui::Slider *g_SliderLinkerHack;
+
namespace vgui
{
diff -Nuar vgui_controls/directoryselectdialog.cpp vgui_editor/directoryselectdialog.cpp
--- vgui_controls/directoryselectdialog.cpp 2014-07-30 12:53:43.307877882 -0700
+++ vgui_editor/directoryselectdialog.cpp 2014-07-30 13:01:35.174830792 -0700
@@ -6,12 +6,12 @@
#define PROTECTED_THINGS_DISABLE
-#include <vgui_controls/Button.h>
-#include <vgui_controls/ComboBox.h>
-#include <vgui_controls/DirectorySelectDialog.h>
-#include <vgui_controls/TreeView.h>
-#include <vgui_controls/ImageList.h>
-#include <vgui_controls/MessageBox.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/combobox.h>
+#include <vgui_controls/directoryselectdialog.h>
+#include <vgui_controls/treeview.h>
+#include <vgui_controls/imagelist.h>
+#include <vgui_controls/messagebox.h>
#include <vgui/Cursor.h>
#include <KeyValues.h>
#include <vgui/IInput.h>
diff -Nuar vgui_controls/divider.cpp vgui_editor/divider.cpp
--- vgui_controls/divider.cpp 2014-07-30 12:53:43.307877882 -0700
+++ vgui_editor/divider.cpp 2014-07-30 13:01:35.166830791 -0700
@@ -7,7 +7,7 @@
#include <vgui/IScheme.h>
-#include <vgui_controls/Divider.h>
+#include <vgui_controls/divider.h>
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
diff -Nuar vgui_controls/editablepanel.cpp vgui_editor/editablepanel.cpp
--- vgui_controls/editablepanel.cpp 2014-07-30 12:53:43.307877882 -0700
+++ vgui_editor/editablepanel.cpp 2014-07-30 13:01:35.162830792 -0700
@@ -13,28 +13,28 @@
#include <KeyValues.h>
#include "vgui/ivgui.h"
-#include <vgui_controls/BuildGroup.h>
-#include <vgui_controls/BuildModeDialog.h>
-#include <vgui_controls/EditablePanel.h>
+#include <vgui_controls/buildgroup.h>
+#include <vgui_controls/buildmodedialog.h>
+#include <vgui_controls/editablepanel.h>
// these includes are all for the virtual contruction factory Dialog::CreateControlByName()
-#include <vgui_controls/Button.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/CheckButton.h>
-#include <vgui_controls/ComboBox.h>
-#include <vgui_controls/Menu.h>
-#include <vgui_controls/MenuItem.h>
-#include <vgui_controls/MessageBox.h>
-#include <vgui_controls/ProgressBar.h>
-#include <vgui_controls/RadioButton.h>
-#include <vgui_controls/ScrollBar.h>
-#include <vgui_controls/ToggleButton.h>
-#include <vgui_controls/ImagePanel.h>
-#include <vgui_controls/AnimatingImagePanel.h>
-#include <vgui_controls/Divider.h>
-#include <vgui_controls/URLLabel.h>
-#include <vgui_controls/RichText.h>
-#include <vgui_controls/BitmapImagePanel.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/checkbutton.h>
+#include <vgui_controls/combobox.h>
+#include <vgui_controls/menu.h>
+#include <vgui_controls/menuitem.h>
+#include <vgui_controls/messagebox.h>
+#include <vgui_controls/progressbar.h>
+#include <vgui_controls/radiobutton.h>
+#include <vgui_controls/scrollbar.h>
+#include <vgui_controls/togglebutton.h>
+#include <vgui_controls/imagepanel.h>
+#include <vgui_controls/animatingimagepanel.h>
+#include <vgui_controls/divider.h>
+#include <vgui_controls/urllabel.h>
+#include <vgui_controls/richtext.h>
+#include <vgui_controls/bitmapimagepanel.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/expandbutton.cpp vgui_editor/expandbutton.cpp
--- vgui_controls/expandbutton.cpp 2014-07-30 12:53:43.307877882 -0700
+++ vgui_editor/expandbutton.cpp 2014-07-30 13:01:35.162830792 -0700
@@ -12,9 +12,9 @@
#include <vgui/IScheme.h>
#include <KeyValues.h>
-#include <vgui_controls/Image.h>
-#include <vgui_controls/ExpandButton.h>
-#include <vgui_controls/TextImage.h>
+#include <vgui_controls/image.h>
+#include <vgui_controls/expandbutton.h>
+#include <vgui_controls/textimage.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/fileopendialog.cpp vgui_editor/fileopendialog.cpp
--- vgui_controls/fileopendialog.cpp 2014-07-30 12:53:43.307877882 -0700
+++ vgui_editor/fileopendialog.cpp 2014-07-30 13:01:35.182830793 -0700
@@ -26,18 +26,20 @@
#include <vgui/ILocalize.h>
#include <vgui/IInput.h>
-#include <vgui_controls/FileOpenDialog.h>
+#include <vgui_controls/fileopendialog.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/ComboBox.h>
-#include <vgui_controls/ImagePanel.h>
-#include <vgui_controls/InputDialog.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/ListPanel.h>
-#include <vgui_controls/TextEntry.h>
-#include <vgui_controls/ImageList.h>
-#include <vgui_controls/MenuItem.h>
-#include <vgui_controls/Tooltip.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/combobox.h>
+#include <vgui_controls/imagepanel.h>
+#include <vgui_controls/inputdialog.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/listpanel.h>
+#include <vgui_controls/textentry.h>
+#include <vgui_controls/imagelist.h>
+#include <vgui_controls/menuitem.h>
+#include <vgui_controls/tooltip.h>
+#include <vgui_controls/promptsimple.h>
+#include <vgui_controls/checkbutton.h>
#if defined( _X360 )
#include "xbox/xbox_win32stubs.h"
@@ -56,6 +58,8 @@
static int s_nLastSortColumn = 0;
+#define CUSTOM_POPULATE 1
+
static int ListFileNameSortFunc(ListPanel *pPanel, const ListPanelItem &item1, const ListPanelItem &item2 )
{
NOTE_UNUSED( pPanel );
@@ -347,6 +351,8 @@
void FileCompletionEdit::ShowMenu(void)
{
+ return; // >_>
+
// reset the dropdown's position
m_pDropDown->InvalidateLayout();
@@ -473,14 +479,15 @@
static ColumnInfo_t g_ColInfo[] =
{
- { "text", "#FileOpenDialog_Col_Name", 175, 20, 10000, ListPanel::COLUMN_UNHIDABLE, &ListFileNameSortFunc , Label::a_west },
- { "filesize", "#FileOpenDialog_Col_Size", 100, 20, 10000, 0, &ListFileSizeSortFunc , Label::a_east },
- { "type", "#FileOpenDialog_Col_Type", 150, 20, 10000, 0, &ListFileTypeSortFunc , Label::a_west },
+ { "text", "#FileOpenDialog_Col_Name", 325, 20, 10000, ListPanel::COLUMN_UNHIDABLE, &ListFileNameSortFunc , Label::a_west },
+ { "filesize", "#FileOpenDialog_Col_Size", 50, 20, 10000, 0, &ListFileSizeSortFunc , Label::a_east },
+ { "type", "#FileOpenDialog_Col_Type", 50, 20, 10000, 0, &ListFileTypeSortFunc , Label::a_west },
{ "modified", "#FileOpenDialog_Col_DateModified", 125, 20, 10000, 0, &ListFileModifiedSortFunc , Label::a_west },
{ "created", "#FileOpenDialog_Col_DateCreated", 125, 20, 10000, ListPanel::COLUMN_HIDDEN, &ListFileCreatedSortFunc , Label::a_west },
{ "attributes", "#FileOpenDialog_Col_Attributes", 50, 20, 10000, ListPanel::COLUMN_HIDDEN, &ListFileAttributesSortFunc , Label::a_west },
};
+
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
@@ -558,6 +565,7 @@
( m_DialogType != FOD_SELECT_DIRECTORY ) ? "#FileOpenDialog_File_name" : "#FileOpenDialog_Directory_Name" );
m_pFolderIcon = new ImagePanel(NULL, "FolderIcon");
+ m_pCheckFullFileSystem = new CheckButton( this, "check_ffs", "Full filesystem" );
// set up the control's initial positions
SetSize( 600, 260 );
@@ -576,11 +584,13 @@
m_pCancelButton->SetBounds(336, 224, 74, 24);
lookIn->SetBounds(10, 32, 55, 24);
fileName->SetBounds(10, 194, nFileNameWidth, 24);
+ m_pCheckFullFileSystem->SetBounds( nFileEditLeftSide + 150, 224, 130, 24 );
// set autolayout parameters
m_pFullPathEdit->SetAutoResize( Panel::PIN_TOPLEFT, Panel::AUTORESIZE_RIGHT, 67, 32, -100, 0 );
m_pFileNameEdit->SetAutoResize( Panel::PIN_BOTTOMLEFT, Panel::AUTORESIZE_RIGHT, nFileEditLeftSide, -42, -104, 0 );
- m_pFileTypeCombo->SetAutoResize( Panel::PIN_BOTTOMLEFT, Panel::AUTORESIZE_RIGHT, nFileEditLeftSide, -12, -104, 0 );
+ //m_pFileTypeCombo->SetAutoResize( Panel::PIN_BOTTOMLEFT, Panel::AUTORESIZE_RIGHT, nFileEditLeftSide, -12, -104, 0 );
+ m_pFileTypeCombo->SetAutoResize( Panel::PIN_BOTTOMLEFT, Panel::AUTORESIZE_RIGHT, nFileEditLeftSide, -12, -250, 0 );
m_pFileList->SetAutoResize( Panel::PIN_TOPLEFT, Panel::AUTORESIZE_DOWNANDRIGHT, 10, 60, -10, -70 );
m_pFolderUpButton->SetPinCorner( Panel::PIN_TOPRIGHT, -40, 32 );
@@ -590,6 +600,7 @@
m_pCancelButton->SetPinCorner( Panel::PIN_BOTTOMRIGHT, -16, -12 );
lookIn->SetPinCorner( Panel::PIN_TOPLEFT, 10, 32 );
fileName->SetPinCorner( Panel::PIN_BOTTOMLEFT, 10, -42 );
+ m_pCheckFullFileSystem->SetPinCorner( Panel::PIN_BOTTOMRIGHT, -115, -12 );
// label settings
lookIn->SetContentAlignment(Label::a_west);
@@ -623,7 +634,7 @@
m_pNewFolderButton->SetCommand( new KeyValues( "OnNewFolder" ) );
m_pOpenInExplorerButton->SetCommand( new KeyValues( "OpenInExplorer" ) );
- SetSize( 600, 384 );
+ SetSize( 600, 460 );
m_nStartDirContext = s_StartDirContexts.InvalidIndex();
@@ -635,6 +646,14 @@
// Because these call through virtual functions, we can't issue them in the constructor, so we post a message to ourselves instead!!
PostMessage( GetVPanel(), new KeyValues( "PopulateFileList" ) );
PostMessage( GetVPanel(), new KeyValues( "PopulateDriveList" ) );
+
+ SetDeleteSelfOnClose( true );
+
+ m_bLockedToMod = m_DialogType == FOD_SAVE;
+ m_pCheckFullFileSystem->SetSelected( !m_bLockedToMod );
+
+ if ( m_DialogType == FOD_SAVE )
+ m_pCheckFullFileSystem->SetEnabled( false );
}
@@ -649,8 +668,21 @@
m_pContextKeyValues->deleteThis();
m_pContextKeyValues = NULL;
}
+ delete m_pFolderIcon;
}
+void FileOpenDialog::OnCheckButtonChecked( KeyValues *pData )
+{
+ Panel *pCaller = ((Panel*)pData->GetPtr( "panel" ));
+ bool bState = !!pData->GetInt( "state" );
+
+ if ( pCaller == m_pCheckFullFileSystem )
+ {
+ m_bLockedToMod = !bState;
+ PostMessage( GetVPanel(), new KeyValues( "PopulateFileList" ) );
+ PostMessage( GetVPanel(), new KeyValues( "PopulateDriveList" ) );
+ }
+}
//-----------------------------------------------------------------------------
// Purpose: Apply scheme settings
@@ -809,7 +841,7 @@
//-----------------------------------------------------------------------------
void FileOpenDialog::OnOpenInExplorer()
{
- char pCurrentDirectory[MAX_PATH];
+ char pCurrentDirectory[MAX_PATH * 4];
GetCurrentDirectory( pCurrentDirectory, sizeof(pCurrentDirectory) );
#if !defined( _X360 )
ShellExecute( NULL, NULL, pCurrentDirectory, NULL, NULL, SW_SHOWNORMAL );
@@ -826,6 +858,11 @@
{
Close();
}
+ else if (!stricmp(command, "onoverwrite"))
+ {
+ SaveFileToStartDirContext( pFullPath_TMPHACK );
+ PostFileSelectedMessage( pFullPath_TMPHACK );
+ }
else
{
BaseClass::OnCommand(command);
@@ -884,7 +921,7 @@
// Store this in the start directory list
if ( m_nStartDirContext != s_StartDirContexts.InvalidIndex() )
{
- char pDirBuf[MAX_PATH];
+ char pDirBuf[MAX_PATH*4];
GetCurrentDirectory( pDirBuf, sizeof(pDirBuf) );
s_StartDirContexts[ m_nStartDirContext ] = pDirBuf;
}
@@ -902,6 +939,7 @@
kv->SetString( "filter", filter );
kv->SetString( "filterinfo", pFilterInfo );
int itemID = m_pFileTypeCombo->AddItem(filterName, kv);
+ kv->deleteThis();
if ( bActive )
{
m_pFileTypeCombo->ActivateItem(itemID);
@@ -943,11 +981,11 @@
//-----------------------------------------------------------------------------
void FileOpenDialog::NewFolder( char const *folderName )
{
- char pCurrentDirectory[MAX_PATH];
+ char pCurrentDirectory[MAX_PATH*4];
GetCurrentDirectory( pCurrentDirectory, sizeof(pCurrentDirectory) );
- char pFullPath[MAX_PATH];
- char pNewFolderName[MAX_PATH];
+ char pFullPath[MAX_PATH*4];
+ char pNewFolderName[MAX_PATH*4];
Q_strncpy( pNewFolderName, folderName, sizeof(pNewFolderName) );
int i = 2;
do
@@ -1017,16 +1055,46 @@
}
// see if the path can be opened
+#if CUSTOM_POPULATE == 0
Q_strncat(fullpath, "*", sizeof( fullpath ), COPY_ALL_CHARACTERS );
+#endif
char *pData = fullpath;
while (*pData == ' ')
{
pData++;
}
+#if CUSTOM_POPULATE
+ char tmpLocal[MAX_PATH * 4];
+ if ( !g_pFullFileSystem->FullPathToRelativePath( pData, tmpLocal, MAX_PATH * 4 ) || !*tmpLocal )
+ Q_strcpy( tmpLocal, pData );
+
+ char fullpath2[MAX_PATH * 4];
+ Q_memset( fullpath2, 0, sizeof( fullpath2 ) );
+ Q_strcpy( fullpath2, fullpath );
+ Q_strncat(fullpath2, "*", sizeof( fullpath2 ), COPY_ALL_CHARACTERS );
+ char *pData2 = fullpath2;
+ while (*pData2 == ' ')
+ {
+ pData2++;
+ }
+
+ WIN32_FIND_DATA findData;
+ HANDLE findHandle = ::FindFirstFile(pData2, &findData);
+ bool bGlobalCheck = (findHandle != INVALID_HANDLE_VALUE);
+ Q_StripTrailingSlash( tmpLocal );
+ FileFindHandle_t _handle;
+ g_pFullFileSystem->FindFirst( tmpLocal, &_handle );
+ bool bLocal = (_handle >= 0) ? g_pFullFileSystem->FindIsDirectory( _handle ) : false;
+ g_pFullFileSystem->FindClose( _handle );
+
+ //if( g_pFullFileSystem->IsDirectory( tmpLocal, GetPathID() ) || bGlobalCheck )
+ if( bLocal || bGlobalCheck )
+#else
WIN32_FIND_DATA findData;
HANDLE findHandle = ::FindFirstFile(pData, &findData);
if (findHandle != INVALID_HANDLE_VALUE)
+#endif
{
// directory is valid, remove * and store
char *pos = strrchr(pData, '*');
@@ -1042,6 +1110,7 @@
Q_strcpy(pData, m_szLastPath);
}
+
m_pFullPathEdit->SetText(pData);
m_pFullPathEdit->GetTooltip()->SetText(pData);
}
@@ -1118,6 +1187,112 @@
// Purpose: Fill the filelist with the names of all the files in the current directory
//-----------------------------------------------------------------------------
#define MAX_FILTER_LENGTH 255
+
+#define ITRFLAGS_FILES 0x01
+#define ITRFLAGS_DIRECTORIES 0x02
+
+const char *FileOpenDialog::GetPathID()
+{
+ if ( m_bLockedToMod )
+ return "MOD";
+ return NULL;
+}
+void FileOpenDialog::GetLocalPath( const char *pszFullPath, char *pszLocalPath, int maxLen )
+{
+ if ( !g_pFullFileSystem->FullPathToRelativePathEx( pszFullPath, GetPathID(), pszLocalPath, maxLen ) || !*pszLocalPath )
+ Q_strcpy( pszLocalPath, pszFullPath );
+}
+void FileOpenDialog::BeginIterate( const char *szDir, const char *pszFilter, ListPanel *pList, int iFlags )
+{
+ const char *pPathID = GetPathID();
+
+ FileFindHandle_t _handle;
+ char szDirLocal[MAX_PATH*4];
+ GetLocalPath( szDir, szDirLocal, MAX_PATH*4 );
+
+ char tmp[MAX_PATH*4];
+ Q_snprintf( tmp, MAX_PATH*4, "%s%s\0", szDirLocal, pszFilter );
+
+ char curFile[ MAX_PATH*4 ] = { '\0' };
+ const char *tmpFile = g_pFullFileSystem->FindFirstEx( tmp, pPathID, &_handle );
+ if ( tmpFile )
+ Q_strncpy( curFile, tmpFile, sizeof(curFile) );
+
+ WIN32_FILE_ATTRIBUTE_DATA attr;
+
+ KeyValues *kv = new KeyValues( "item" );
+
+ while ( curFile[0] )
+ {
+ char FullPath[MAX_PATH*4];
+ Q_snprintf( FullPath, MAX_PATH*4, "%s%s\0", szDir, curFile );
+ Q_FixSlashes( FullPath );
+
+ char FullPath_Local[MAX_PATH*4];
+ Q_snprintf( FullPath_Local, MAX_PATH*4, "%s%s\0", szDirLocal, curFile );
+ Q_FixSlashes( FullPath_Local );
+
+ const bool bIsDirectory = g_pFullFileSystem->FindIsDirectory( _handle ); //g_pFullFileSystem->IsDirectory( FullPath_Local, pPathID );
+ const bool bFlagsValid = ( bIsDirectory && iFlags & ITRFLAGS_DIRECTORIES ) ||
+ ( !bIsDirectory && iFlags & ITRFLAGS_FILES );
+ if ( bFlagsValid && Q_stricmp( curFile, "." ) && Q_strlen( curFile ) >= 3 )
+ {
+ Q_memset( &attr, 0, sizeof( attr ) );
+ bool bAttributesOkay = true;
+ if ( GetFileAttributesEx( FullPath, GetFileExInfoStandard, &attr ) )
+ {
+ if ( attr.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN )
+ bAttributesOkay = false;
+ if ( attr.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM )
+ bAttributesOkay = false;
+ }
+ if ( bAttributesOkay )
+ {
+ kv->SetString("text", curFile );
+ kv->SetInt("image", bIsDirectory ? 2 : 1);
+ if ( !bIsDirectory )
+ {
+ IImage *image = surface()->GetIconImageForFullPath( FullPath );
+ if ( image )
+ {
+ kv->SetPtr( "iconImage", (void *)image );
+ }
+ }
+ kv->SetInt("imageSelected", bIsDirectory ? 3 : 1);
+ kv->SetInt("directory", bIsDirectory ? 1 : 0);
+ kv->SetInt( "filesizeint", bIsDirectory ? 0 : attr.nFileSizeLow );
+ kv->SetString( "filesize", bIsDirectory ? "" : Q_pretifymem( attr.nFileSizeLow, 0, true ) );
+
+ if ( bIsDirectory )
+ kv->SetString( "type", "#FileOpenDialog_FileType_Folder" );
+ else
+ {
+ wchar_t fileType[ 80 ];
+ g_pFullFileSystem->GetFileTypeForFullPath( FullPath, fileType, sizeof( fileType ) );
+ kv->SetWString( "type", fileType );
+ }
+
+ kv->SetString( "attributes", GetAttributesAsString( attr.dwFileAttributes ) );
+ kv->SetString( "modified", GetFileTimetamp( attr.ftLastWriteTime ) );
+ kv->SetString( "created", GetFileTimetamp( attr.ftCreationTime ) );
+ kv->SetInt( "modifiedint_low", attr.ftLastWriteTime.dwLowDateTime );
+ kv->SetInt( "modifiedint_high", attr.ftLastWriteTime.dwHighDateTime );
+ kv->SetInt( "createdint_low", attr.ftCreationTime.dwLowDateTime );
+ kv->SetInt( "createdint_high", attr.ftCreationTime.dwHighDateTime );
+ pList->AddItem(kv, 0, false, false);
+ }
+ }
+
+ const char *tmpFile = g_pFullFileSystem->FindNext( _handle );
+ if ( tmpFile )
+ Q_strncpy( curFile, tmpFile, sizeof(curFile) );
+ else
+ curFile[0] = '\0';
+ }
+
+ kv->deleteThis();
+ g_pFullFileSystem->FindClose( _handle );
+}
void FileOpenDialog::PopulateFileList()
{
// clear the current list
@@ -1142,9 +1317,10 @@
char *filterPtr = filterList;
KeyValues *kv = new KeyValues("item");
+#if CUSTOM_POPULATE == 0
WIN32_FIND_DATA findData;
HANDLE findHandle = NULL;
-
+#endif
if ( m_DialogType != FOD_SELECT_DIRECTORY )
{
while ((filterPtr != NULL) && (*filterPtr != 0))
@@ -1168,6 +1344,10 @@
break;
}
+#if CUSTOM_POPULATE
+ Q_snprintf(dir, MAX_PATH*4, "%s", currentDir);
+ BeginIterate( dir, curFilter, m_pFileList, ITRFLAGS_FILES );
+#else
Q_snprintf(dir, MAX_PATH*4, "%s%s", currentDir, curFilter);
// open the directory and walk it, loading files
@@ -1214,10 +1394,15 @@
break;
}
::FindClose(findHandle);
+#endif
}
}
// find all the directories
+
+#if CUSTOM_POPULATE
+ BeginIterate( currentDir, "*", m_pFileList, ITRFLAGS_DIRECTORIES );
+#else
GetCurrentDirectory(dir, sizeof(dir));
Q_strncat(dir, "*", sizeof( dir ), COPY_ALL_CHARACTERS);
findHandle = ::FindFirstFile(dir, &findData);
@@ -1251,6 +1436,7 @@
break;
}
::FindClose(findHandle);
+#endif
kv->deleteThis();
m_pFileList->SortList();
@@ -1357,7 +1543,7 @@
if ( m_nStartDirContext == s_StartDirContexts.InvalidIndex() )
return;
- char pPath[MAX_PATH];
+ char pPath[MAX_PATH*4];
pPath[0] = 0;
Q_ExtractFilePath( pFullPath, pPath, sizeof(pPath) );
s_StartDirContexts[ m_nStartDirContext ] = pPath;
@@ -1397,7 +1583,7 @@
ValidatePath();
// construct a file path
- char pFileName[MAX_PATH];
+ char pFileName[MAX_PATH*4];
GetSelectedFileName( pFileName, sizeof( pFileName ) );
Q_StripTrailingSlash( pFileName );
@@ -1457,7 +1643,7 @@
ValidatePath();
// construct a file path
- char pFileName[MAX_PATH];
+ char pFileName[MAX_PATH*4];
GetSelectedFileName( pFileName, sizeof( pFileName ) );
int nLen = Q_strlen( pFileName );
@@ -1496,9 +1682,21 @@
Q_strncpy( pFullPath, pFileName, sizeof(pFullPath) );
}
+ char tmpLocalPath[MAX_PATH*4];
+ GetLocalPath( pFullPath, tmpLocalPath, MAX_PATH*4 );
+
// If the name specified is a directory, then change directory
- if ( g_pFullFileSystem->IsDirectory( pFullPath, NULL ) )
+ FileFindHandle_t _handle;
+ g_pFullFileSystem->FindFirst( tmpLocalPath, &_handle );
+ bool bLocal = (_handle >= 0) ? g_pFullFileSystem->FindIsDirectory( _handle ) : false;
+ g_pFullFileSystem->FindClose( _handle );
+ bool bSystem = g_pFullFileSystem->IsDirectory( tmpLocalPath, GetPathID() );
+
+ if ( bLocal || bSystem )
{
+ if ( !bSystem )
+ Q_snprintf( pFullPath, sizeof(pFullPath), tmpLocalPath );
+
// it's a directory; change to the specified directory
if ( !bSpecifiedDirectory )
{
@@ -1532,11 +1730,25 @@
Q_SetExtension( pFullPath, extension, sizeof(pFullPath) );
}
- if ( g_pFullFileSystem->FileExists( pFullPath ) )
+ if ( g_pFullFileSystem->FileExists( tmpLocalPath, GetPathID() ) )
{
// open the file!
- SaveFileToStartDirContext( pFullPath );
- PostFileSelectedMessage( pFullPath );
+ if ( m_DialogType == FOD_SAVE )
+ {
+ Q_strcpy( pFullPath_TMPHACK, pFullPath );
+ pFullPath_TMPHACK[ Q_strlen( pFullPath ) + 1 ] = '\0';
+
+ PromptSimple *prompt = new PromptSimple( this, "File exists" );
+ prompt->MoveToCenterOfScreen();
+ prompt->SetText( "A file with the same name exists already. Overwrite?" );
+ prompt->AddButton( "Yes", "onoverwrite" );
+ prompt->AddButton( "No", "onclose_prompt" );
+ }
+ else
+ {
+ SaveFileToStartDirContext( pFullPath );
+ PostFileSelectedMessage( pFullPath );
+ }
return;
}
diff -Nuar vgui_controls/fileopenstatemachine.cpp vgui_editor/fileopenstatemachine.cpp
--- vgui_controls/fileopenstatemachine.cpp 2014-07-30 12:53:43.307877882 -0700
+++ vgui_editor/fileopenstatemachine.cpp 2014-07-30 13:01:35.218830794 -0700
@@ -7,8 +7,8 @@
#include "vgui_controls/fileopenstatemachine.h"
#include "tier1/keyvalues.h"
-#include "vgui_controls/FileOpenDialog.h"
-#include "vgui_controls/MessageBox.h"
+#include "vgui_controls/fileopendialog.h"
+#include "vgui_controls/messagebox.h"
#include "vgui_controls/perforcefilelistframe.h"
#include "vgui_controls/savedocumentquery.h"
#include "filesystem.h"
diff -Nuar vgui_controls/focusnavgroup.cpp vgui_editor/focusnavgroup.cpp
--- vgui_controls/focusnavgroup.cpp 2014-07-30 12:53:43.307877882 -0700
+++ vgui_editor/focusnavgroup.cpp 2014-07-30 13:01:35.098830787 -0700
@@ -14,9 +14,9 @@
#include <KeyValues.h>
#include <tier0/dbg.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/FocusNavGroup.h>
-#include <vgui_controls/Panel.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/focusnavgroup.h>
+#include <vgui_controls/panel.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/frame.cpp vgui_editor/frame.cpp
--- vgui_controls/frame.cpp 2014-07-30 12:53:43.311879882 -0700
+++ vgui_editor/frame.cpp 2014-07-30 13:01:35.182830793 -0700
@@ -20,18 +20,20 @@
#include "vgui/IScheme.h"
#include "vgui/KeyCode.h"
-#include "vgui_controls/AnimationController.h"
-#include "vgui_controls/Controls.h"
-#include "vgui_controls/Frame.h"
-#include "vgui_controls/Button.h"
-#include "vgui_controls/Menu.h"
-#include "vgui_controls/MenuButton.h"
-#include "vgui_controls/TextImage.h"
+#include "vgui_controls/animationcontroller.h"
+#include "vgui_controls/controls.h"
+#include "vgui_controls/frame.h"
+#include "vgui_controls/button.h"
+#include "vgui_controls/menu.h"
+#include "vgui_controls/menubutton.h"
+#include "vgui_controls/textimage.h"
#include "KeyValues.h"
#include <stdio.h>
+#include "vgui_editor_platform.h"
+
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -1311,7 +1313,7 @@
{
// try lookup in localization tables
StringIndex_t unlocalizedTextSymbol = g_pVGuiLocalize->FindIndex(newTitle + 1);
- if (unlocalizedTextSymbol != INVALID_STRING_INDEX)
+ if (unlocalizedTextSymbol != INVALID_LOCALIZE_STRING_INDEX)
{
// we have a new text value
wcsncpy( unicodeText, g_pVGuiLocalize->GetValueByIndex(unlocalizedTextSymbol), sizeof( unicodeText) / sizeof(wchar_t) );
@@ -1614,6 +1616,15 @@
}
}
}
+Color Frame::GetOutOfFocusColor()
+{
+ return m_OutOfFocusBgColor;
+}
+
+void Frame::SetOutOfFocusColor( Color col )
+{
+ m_OutOfFocusBgColor = col;
+}
//-----------------------------------------------------------------------------
// Purpose:
@@ -1821,7 +1832,10 @@
{
if (!stricmp(command, "Close"))
{
- Close();
+ if ( m_hPreviousModal != 0 )
+ CloseModal();
+ else
+ Close();
}
else if (!stricmp(command, "CloseModal"))
{
@@ -2228,7 +2242,7 @@
void Frame::OnDialogVariablesChanged( KeyValues *dialogVariables )
{
StringIndex_t index = _title->GetUnlocalizedTextSymbol();
- if (index != INVALID_STRING_INDEX)
+ if (index != INVALID_LOCALIZE_STRING_INDEX)
{
// reconstruct the string from the variables
wchar_t buf[1024];
diff -Nuar vgui_controls/graphpanel.cpp vgui_editor/graphpanel.cpp
--- vgui_controls/graphpanel.cpp 2014-07-30 12:53:43.311879882 -0700
+++ vgui_editor/graphpanel.cpp 2014-07-30 13:01:35.130830791 -0700
@@ -6,7 +6,7 @@
#include <math.h>
-#include <vgui_controls/GraphPanel.h>
+#include <vgui_controls/graphpanel.h>
#include <vgui/IScheme.h>
#include <vgui/ISurface.h>
#include <vgui/IVGui.h>
diff -Nuar vgui_controls/html.cpp vgui_editor/html.cpp
--- vgui_controls/html.cpp 2014-07-30 12:53:43.311879882 -0700
+++ vgui_editor/html.cpp 2014-07-30 13:01:35.122830789 -0700
@@ -18,10 +18,10 @@
#include "filesystem.h"
#include "vgui_controls/HTML.h"
-#include "vgui_controls/Controls.h"
-#include "vgui_controls/Label.h"
-#include "vgui_controls/Image.h"
-#include "vgui_controls/ScrollBar.h"
+#include "vgui_controls/controls.h"
+#include "vgui_controls/label.h"
+#include "vgui_controls/image.h"
+#include "vgui_controls/scrollbar.h"
#include "KeyValues.h"
#include <stdio.h>
@@ -41,12 +41,12 @@
vgui::Panel *HTML_NoJavascript_Factory()
{
- return new HTML( NULL, NULL, false );
+ return NULL; //new HTML( NULL, NULL, false );
}
vgui::Panel *HTML_Javascript_Factory()
{
- return new HTML( NULL, NULL, true );
+ return NULL;//new HTML( NULL, NULL, true );
}
//DECLARE_BUILD_FACTORY_CUSTOM_ALIAS( HTML, HTML_NoJavascript, HTML_NoJavascript_Factory );
@@ -266,8 +266,10 @@
}
_vbar->SetEnabled(false);
- _vbar->SetRangeWindow( h/2-5 );
- _vbar->SetRange( 0, img_h);
+ //_vbar->SetRangeWindow( h/2-5 );
+ //_vbar->SetRange( 0, img_h );
+ _vbar->SetRangeWindow( h/2 );
+ _vbar->SetRange( 0, img_h - h/2 );
_vbar->SetButtonPressedScrollValue( 5 );
_vbar->SetPos(w - (_vbar->GetWide()+WINDOW_BORDER_WIDTH), WINDOW_BORDER_WIDTH);
@@ -292,8 +294,10 @@
{
_hbar->SetVisible(true);
_hbar->SetEnabled(false);
- _hbar->SetRangeWindow( w/2-5 );
- _hbar->SetRange( 0, img_w);
+ //_hbar->SetRangeWindow( w/2-5 );
+ //_hbar->SetRange( 0, img_w);
+ _hbar->SetRangeWindow( w/2 );
+ _hbar->SetRange( 0, img_w - w/2);
_hbar->SetButtonPressedScrollValue( 5 );
_hbar->SetPos(WINDOW_BORDER_WIDTH,h-(_vbar->GetWide()+WINDOW_BORDER_WIDTH));
@@ -441,7 +445,7 @@
{
if (browser)
{
- browser->OnMouse(code,IHTML::DOWN,m_iMouseX,m_iMouseY);
+ //browser->OnMouse(code,IHTML::DOWN,m_iMouseX,m_iMouseY);
}
}
m_bRegenerateHTMLBitmap = true;
@@ -458,7 +462,7 @@
{
if (browser)
{
- browser->OnMouse(code, IHTML::UP, m_iMouseX, m_iMouseY);
+ //browser->OnMouse(code, IHTML::UP, m_iMouseX, m_iMouseY);
}
m_bRegenerateHTMLBitmap = true;
if ( !surface()->SupportsFeature( ISurface::DIRECT_HWND_RENDER ) )
@@ -472,10 +476,10 @@
//-----------------------------------------------------------------------------
void HTML::OnCursorMoved(int x,int y)
{
- MouseCode code=MOUSE_LEFT;
+ //MouseCode code=MOUSE_LEFT;
m_iMouseX=x;
m_iMouseY=y;
- if(browser) browser->OnMouse(code,IHTML::MOVE,x,y);
+ //if(browser) browser->OnMouse(code,IHTML::MOVE,x,y);
}
//-----------------------------------------------------------------------------
@@ -485,7 +489,7 @@
{
if (browser)
{
- browser->OnMouse(code, IHTML::DOWN, m_iMouseX, m_iMouseY);
+ //browser->OnMouse(code, IHTML::DOWN, m_iMouseX, m_iMouseY);
}
m_bRegenerateHTMLBitmap = true;
if ( !surface()->SupportsFeature( ISurface::DIRECT_HWND_RENDER ) )
@@ -522,7 +526,7 @@
}
- if(browser) browser->OnKeyDown(code);
+ //if(browser) browser->OnKeyDown(code);
m_bRegenerateHTMLBitmap = true;
Repaint();
}
@@ -618,7 +622,7 @@
if(browser)
{
- browser->OnSize(m_iScrollX + left, m_iScrollY + top, w-m_iScrollBorderX - right, h-m_iScrollBorderY - bottom);
+ //browser->OnSize(m_iScrollX + left, m_iScrollY + top, w-m_iScrollBorderX - right, h-m_iScrollBorderY - bottom);
}
}
@@ -675,6 +679,9 @@
}
}
+ m_bRegenerateHTMLBitmap = true;
+ Repaint();
+
int w, h;
GetSize(w, h);
CalcScrollBars(w, h);
diff -Nuar vgui_controls/image.cpp vgui_editor/image.cpp
--- vgui_controls/image.cpp 2014-07-30 12:53:43.311879882 -0700
+++ vgui_editor/image.cpp 2014-07-30 13:01:35.094830787 -0700
@@ -1,4 +1,4 @@
-//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
+//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -9,8 +9,8 @@
#include <vgui/IPanel.h>
#include <vgui/ISurface.h>
-#include <vgui_controls/Image.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/image.h>
+#include <vgui_controls/controls.h>
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -261,5 +261,22 @@
return _color;
}
+bool Image::Evict()
+{
+ return false;
+}
+
+int Image::GetNumFrames()
+{
+ return 0;
+}
+void Image::SetFrame( int nFrame )
+{
+}
+
+HTexture Image::GetID()
+{
+ return 0;
+}
diff -Nuar vgui_controls/imagelist.cpp vgui_editor/imagelist.cpp
--- vgui_controls/imagelist.cpp 2014-07-30 12:53:43.311879882 -0700
+++ vgui_editor/imagelist.cpp 2014-07-30 13:01:35.078830789 -0700
@@ -8,7 +8,7 @@
#include <vgui/VGUI.h>
#include <Color.h>
-#include <vgui_controls/ImageList.h>
+#include <vgui_controls/imagelist.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -27,6 +27,26 @@
virtual void GetSize(int &wide, int &tall) { wide = 0; tall = 0; }
virtual void SetSize(int wide, int tall) {}
virtual void SetColor(Color col) {}
+
+ bool Evict()
+ {
+ return false;
+ }
+
+ int GetNumFrames()
+ {
+ return 0;
+ }
+
+ void SetFrame( int nFrame )
+ {
+ }
+
+ HTexture GetID()
+ {
+ return 0;
+ }
+ void SetRotation( int iRotation ){};
};
//-----------------------------------------------------------------------------
@@ -46,7 +66,8 @@
if (m_bDeleteImagesWhenDone)
{
// delete all the images, except for the first image (which is always the blank image)
- for (int i = 1; i < m_Images.Count(); i++)
+ //for (int i = 1; i < m_Images.Count(); i++)
+ for (int i = 0; i < m_Images.Count(); i++)
{
delete m_Images[i];
}
diff -Nuar vgui_controls/imagepanel.cpp vgui_editor/imagepanel.cpp
--- vgui_controls/imagepanel.cpp 2014-07-30 12:53:43.311879882 -0700
+++ vgui_editor/imagepanel.cpp 2014-07-30 13:01:35.122830789 -0700
@@ -13,9 +13,9 @@
#include <vgui/IBorder.h>
#include <KeyValues.h>
-#include <vgui_controls/ImagePanel.h>
-#include <vgui_controls/Image.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/imagepanel.h>
+#include <vgui_controls/image.h>
+#include <vgui_controls/controls.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -222,11 +222,11 @@
m_pszImageName = NULL;
m_pszColorName = NULL;
- m_bScaleImage = inResourceData->GetInt("scaleImage", 0);
+ m_bScaleImage = inResourceData->GetBool("scaleImage");
m_fScaleAmount = inResourceData->GetFloat("scaleAmount", 0.0f);
- m_bTileImage = inResourceData->GetInt("tileImage", 0);
- m_bTileHorizontally = inResourceData->GetInt("tileHorizontally", m_bTileImage);
- m_bTileVertically = inResourceData->GetInt("tileVertically", m_bTileImage);
+ m_bTileImage = inResourceData->GetBool("tileImage");
+ m_bTileHorizontally = inResourceData->GetBool("tileHorizontally", m_bTileImage);
+ m_bTileVertically = inResourceData->GetBool("tileVertically", m_bTileImage);
const char *imageName = inResourceData->GetString("image", "");
if (*imageName)
{
diff -Nuar vgui_controls/inputdialog.cpp vgui_editor/inputdialog.cpp
--- vgui_controls/inputdialog.cpp 2014-07-30 12:53:43.311879882 -0700
+++ vgui_editor/inputdialog.cpp 2014-07-30 13:01:35.138830791 -0700
@@ -4,10 +4,10 @@
//
//=============================================================================//
-#include <vgui_controls/InputDialog.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/TextEntry.h>
+#include <vgui_controls/inputdialog.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/textentry.h>
#include "tier1/KeyValues.h"
#include "vgui/IInput.h"
diff -Nuar vgui_controls/keybindinghelpdialog.cpp vgui_editor/keybindinghelpdialog.cpp
--- vgui_controls/keybindinghelpdialog.cpp 2014-07-30 12:53:43.311879882 -0700
+++ vgui_editor/keybindinghelpdialog.cpp 2014-07-30 13:01:35.086830790 -0700
@@ -4,7 +4,7 @@
//
//=============================================================================
#include "vgui_controls/KeyBindingHelpDialog.h"
-#include "vgui_controls/ListPanel.h"
+#include "vgui_controls/listpanel.h"
#include "vgui/ISurface.h"
#include "vgui/IVGui.h"
#include "vgui/ILocalize.h"
@@ -12,7 +12,7 @@
#include "vgui/ISystem.h"
#include "KeyValues.h"
#include "vgui/Cursor.h"
-#include "tier1/UtlDict.h"
+#include "tier1/utldict.h"
#include "vgui_controls/KeyBoardEditorDialog.h"
using namespace vgui;
diff -Nuar vgui_controls/keyboardeditordialog.cpp vgui_editor/keyboardeditordialog.cpp
--- vgui_controls/keyboardeditordialog.cpp 2014-07-30 12:53:43.315881882 -0700
+++ vgui_editor/keyboardeditordialog.cpp 2014-07-30 13:01:35.150830791 -0700
@@ -4,16 +4,16 @@
//
//=============================================================================
#include "vgui_controls/KeyBoardEditorDialog.h"
-#include "vgui_controls/ListPanel.h"
-#include "vgui_controls/Button.h"
-#include "vgui_controls/TextEntry.h"
+#include "vgui_controls/listpanel.h"
+#include "vgui_controls/button.h"
+#include "vgui_controls/textentry.h"
#include "vgui/ISurface.h"
#include "vgui/IInput.h"
#include "vgui/IVGui.h"
#include "vgui/ILocalize.h"
#include "KeyValues.h"
#include "vgui/Cursor.h"
-#include "tier1/UtlDict.h"
+#include "tier1/utldict.h"
using namespace vgui;
diff -Nuar vgui_controls/label.cpp vgui_editor/label.cpp
--- vgui_controls/label.cpp 2014-07-30 12:53:43.315881882 -0700
+++ vgui_editor/label.cpp 2014-07-30 13:01:35.106830790 -0700
@@ -17,20 +17,18 @@
#include <vgui/IScheme.h>
#include <KeyValues.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/Image.h>
-#include <vgui_controls/TextImage.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/image.h>
+#include <vgui_controls/textimage.h>
+#include <vgui_controls/controls.h>
+
+#include "vgui_editor_platform.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
using namespace vgui;
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
DECLARE_BUILD_FACTORY_DEFAULT_TEXT( Label, Label );
//-----------------------------------------------------------------------------
@@ -131,7 +129,7 @@
wide += iWide;
// addin the image offsets as well
- for (int i=0; i < _imageDar.Size(); i++)
+ for (int i=0; i < _imageDar.Count(); i++)
wide += _imageDar[i].offset;
tall = max((ty1 - ty0) + _textInset[1], iTall);
@@ -313,7 +311,7 @@
void Label::OnDialogVariablesChanged(KeyValues *dialogVariables )
{
StringIndex_t index = _textImage->GetUnlocalizedTextSymbol();
- if (index != INVALID_STRING_INDEX)
+ if (index != INVALID_LOCALIZE_STRING_INDEX)
{
// reconstruct the string from the variables
wchar_t buf[1024];
@@ -882,7 +880,7 @@
//-----------------------------------------------------------------------------
void Label::EnsureImageCapacity(int maxIndex)
{
- while (_imageDar.Size() <= maxIndex)
+ while (_imageDar.Count() <= maxIndex)
{
AddImage(NULL, 0);
}
diff -Nuar vgui_controls/listpanel.cpp vgui_editor/listpanel.cpp
--- vgui_controls/listpanel.cpp 2014-07-30 12:53:43.315881882 -0700
+++ vgui_editor/listpanel.cpp 2014-07-30 13:01:35.154830792 -0700
@@ -21,16 +21,18 @@
#include <KeyValues.h>
#include <vgui/MouseCode.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/ImageList.h>
-#include <vgui_controls/ImagePanel.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/ListPanel.h>
-#include <vgui_controls/ScrollBar.h>
-#include <vgui_controls/TextImage.h>
-#include <vgui_controls/Menu.h>
-#include <vgui_controls/Tooltip.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/imagelist.h>
+#include <vgui_controls/imagepanel.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/listpanel.h>
+#include <vgui_controls/scrollbar.h>
+#include <vgui_controls/textimage.h>
+#include <vgui_controls/menu.h>
+#include <vgui_controls/tooltip.h>
+
+#include "vgui_editor_platform.h"
// memdbgon must be the last include file in a .cpp file
#include "tier0/memdbgon.h"
@@ -42,19 +44,6 @@
WINDOW_BORDER_WIDTH=2 // the width of the window's border
};
-
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef min
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-#ifndef clamp
-#define clamp( val, min, max ) ( ((val) > (max)) ? (max) : ( ((val) < (min)) ? (min) : (val) ) )
-#endif
-
//-----------------------------------------------------------------------------
//
// Button at the top of columns used to re-sort
@@ -604,10 +593,10 @@
column.m_pHeader = pButton;
column.m_iMinWidth = minWidth;
column.m_iMaxWidth = maxWidth;
- column.m_bResizesWithWindow = columnFlags & COLUMN_RESIZEWITHWINDOW;
+ column.m_bResizesWithWindow = (columnFlags & COLUMN_RESIZEWITHWINDOW) != 0;
column.m_bTypeIsText = !(columnFlags & COLUMN_IMAGE);
column.m_bHidden = false;
- column.m_bUnhidable = (columnFlags & COLUMN_UNHIDABLE);
+ column.m_bUnhidable = (columnFlags & COLUMN_UNHIDABLE) != 0;
column.m_nContentAlignment = Label::a_west;
Dragger *dragger = new Dragger(index);
@@ -1389,7 +1378,7 @@
if ( val[ 0 ] == '#' )
{
StringIndex_t si = g_pVGuiLocalize->FindIndex( val + 1 );
- if ( si != INVALID_STRING_INDEX )
+ if ( si != INVALID_LOCALIZE_STRING_INDEX )
{
wval = g_pVGuiLocalize->GetValueByIndex( si );
}
diff -Nuar vgui_controls/listviewpanel.cpp vgui_editor/listviewpanel.cpp
--- vgui_controls/listviewpanel.cpp 2014-07-30 12:53:43.319883882 -0700
+++ vgui_editor/listviewpanel.cpp 2014-07-30 13:01:35.126830790 -0700
@@ -17,13 +17,13 @@
#include <vgui/IPanel.h>
#include <vgui/ILocalize.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/ScrollBar.h>
-#include <vgui_controls/ImageList.h>
-#include <vgui_controls/ImagePanel.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/TextImage.h>
-#include <vgui_controls/ListViewPanel.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/scrollbar.h>
+#include <vgui_controls/imagelist.h>
+#include <vgui_controls/imagepanel.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/textimage.h>
+#include <vgui_controls/listviewpanel.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/menubar.cpp vgui_editor/menubar.cpp
--- vgui_controls/menubar.cpp 2014-07-30 12:53:43.319883882 -0700
+++ vgui_editor/menubar.cpp 2014-07-30 13:01:35.114830790 -0700
@@ -13,10 +13,12 @@
#include <vgui/KeyCode.h>
#include <KeyValues.h>
-#include <vgui_controls/MenuBar.h>
-#include <vgui_controls/MenuButton.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/menubar.h>
+#include <vgui_controls/menubutton.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/controls.h>
+
+#include "vgui_editor_platform.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -185,15 +187,17 @@
// Now position + resize all buttons
int x = MENUBARINDENT;
+ int minsizex = 54;
for ( int i = 0; i < m_pMenuButtons.Count(); ++i )
{
int nWide, nTall;
m_pMenuButtons[i]->GetContentSize(nWide, nTall);
m_pMenuButtons[i]->SetPos( x, MENUBARINDENT );
- m_pMenuButtons[i]->SetSize( nWide + Label::Content, nBarHeight - 2 * MENUBARINDENT );
-
- x += nWide + MENUBARINDENT;
+ int sizex = max( nWide + Label::Content, minsizex );
+ m_pMenuButtons[i]->SetSize( sizex, nBarHeight - 2 * MENUBARINDENT );
+ m_pMenuButtons[i]->SetContentAlignment( vgui::Label::a_center );
+ x += sizex;
}
m_nRightEdge = x;
diff -Nuar vgui_controls/menubutton.cpp vgui_editor/menubutton.cpp
--- vgui_controls/menubutton.cpp 2014-07-30 12:53:43.319883882 -0700
+++ vgui_editor/menubutton.cpp 2014-07-30 13:01:35.094830787 -0700
@@ -13,10 +13,10 @@
#include <KeyValues.h>
#include <vgui/IVGui.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/MenuButton.h>
-#include <vgui_controls/Menu.h>
-#include <vgui_controls/TextImage.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/menubutton.h>
+#include <vgui_controls/menu.h>
+#include <vgui_controls/textimage.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -201,6 +201,11 @@
m_pMenu->RequestFocus();
}
+void MenuButton::OnShowMenu(Menu *menu)
+{
+ PostActionSignal(new KeyValues("MenuOpen"));
+}
+
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
diff -Nuar vgui_controls/menu.cpp vgui_editor/menu.cpp
--- vgui_controls/menu.cpp 2014-07-30 12:53:43.319883882 -0700
+++ vgui_editor/menu.cpp 2014-07-30 13:01:35.090830788 -0700
@@ -7,6 +7,8 @@
#include "vgui_controls/pch_vgui_controls.h"
+#include "vgui_editor_platform.h"
+
// memdbgon must be the last include file in a .cpp file
#include "tier0/memdbgon.h"
#define MENU_SEPARATOR_HEIGHT 3
@@ -1010,12 +1012,12 @@
// orignalX - width of the parentmenuitem - width of this menu.
// add 2 pixels to offset one pixel onto the parent menu.
x -= (parentWide + wide);
- x -= 2;
+ //x -= 0;
}
else
{
// alignment move it in the amount of the insets.
- x += 1;
+ //x += 0;
}
if ( y + tall > workY + workTall )
@@ -1024,11 +1026,11 @@
int pixelsOffBottom = ( y + tall ) - lastWorkY;
y -= pixelsOffBottom;
- y -= 2;
+ //y -= 2;
}
else
{
- y -= 1;
+ //y -= 1;
}
SetPos(x, y);
@@ -1077,7 +1079,10 @@
int tall = 0;
- int startItem = m_pScroller->GetValue();
+ int startVisibleItem = m_pScroller->GetValue();
+ int visibleItemIndex = -1;
+ int startItem = 0;
+
Assert( startItem >= 0 );
do
{
@@ -1092,6 +1097,14 @@
continue;
}
+ visibleItemIndex++;
+
+ if ( startVisibleItem > visibleItemIndex )
+ {
+ ++startItem;
+ continue;
+ }
+
int itemHeight = m_iMenuItemHeight;
int sepIndex = m_Separators.Find( itemId );
if ( sepIndex != m_Separators.InvalidIndex() )
@@ -1704,6 +1717,11 @@
m_iCheckImageWidth = max ( m_iCheckImageWidth, wide );
}
+
+ if ( m_MenuItems[i]->HasImage() )
+ {
+ m_iCheckImageWidth = max ( m_iCheckImageWidth, m_MenuItems[i]->GetTall() );
+ }
}
_recalculateWidth = true;
CalculateWidth();
@@ -2113,7 +2131,7 @@
void Menu::SetCurrentlyHighlightedItem(int itemID)
{
SetCurrentlySelectedItem(itemID);
- int row = m_SortedItems.Find(itemID);
+ int row = GetVisibleItemIndex( m_SortedItems.Find(itemID) );
Assert(row != -1);
// if there is a scroll bar, and we scroll off lets move it.
@@ -2187,43 +2205,52 @@
// Purpose: Move up or down one in the list of items in the menu
// Direction is MENU_UP or MENU_DOWN
//-----------------------------------------------------------------------------
-void Menu::MoveAlongMenuItemList(int direction, int loopCount)
+void Menu::MoveAlongMenuItemList(int direction, int loopCount, bool bArmItem)
{
int itemID = m_iCurrentlySelectedItemID;
int row = m_SortedItems.Find(itemID);
row += direction;
+
+ int iLastVisible = GetLastVisibleIndex();
+ int iFirstVisible = GetFirstVisibleIndex();
- if ( row > m_SortedItems.Count() - 1 )
- {
- if ( m_pScroller->IsVisible() )
- {
- // stop at bottom of scrolled list
- row = m_SortedItems.Count() - 1;
- }
- else
- {
- // if no scroll bar we circle around
- row = 0;
- }
- }
- else if (row < 0)
+ if ( row > iLastVisible )
{
- if ( m_pScroller->IsVisible() )
- {
- // stop at top of scrolled list
- row = m_pScroller->GetValue();
- }
- else
- {
- // if no scroll bar circle around
- row = m_SortedItems.Count()-1;
- }
+ //if ( m_pScroller->IsVisible() )
+ //{
+ // // stop at bottom of scrolled list
+ // row = m_SortedItems.Count() - 1;
+ //}
+ //else
+ //{
+ // // if no scroll bar we circle around
+ // row = 0;
+ //}
+
+ row = iFirstVisible;
+ }
+ else if (row < iFirstVisible)
+ {
+ //if ( m_pScroller->IsVisible() )
+ //{
+ // // stop at top of scrolled list
+ // row = m_pScroller->GetValue();
+ //}
+ //else
+ //{
+ // // if no scroll bar circle around
+ // row = m_SortedItems.Count()-1;
+ //}
+
+ row = iLastVisible;
}
// if there is a scroll bar, and we scroll off lets move it.
if ( m_pScroller->IsVisible() )
{
- if ( row > m_pScroller->GetValue() + m_iNumVisibleLines - 1)
+ int numVisible = GetVisibleItemIndex( row );
+
+ if ( numVisible > m_pScroller->GetValue() + m_iNumVisibleLines - 1)
{
int val = m_pScroller->GetValue();
val -= -direction;
@@ -2235,7 +2262,7 @@
// menu draws the black border to the right of the scrollbar.
InvalidateLayout();
}
- else if ( row < m_pScroller->GetValue() )
+ else if ( numVisible < m_pScroller->GetValue() )
{
int val = m_pScroller->GetValue();
val -= -direction;
@@ -2252,10 +2279,10 @@
// by hand and created a situation in which we moved an item down, but the
// scroll bar is already too far down and should scroll up or vice versa
// so just snap the scroll bar straight to the item.
- if ( ( row > m_pScroller->GetValue() + m_iNumVisibleLines - 1) ||
- ( row < m_pScroller->GetValue() ) )
+ if ( ( numVisible > m_pScroller->GetValue() + m_iNumVisibleLines - 1) ||
+ ( numVisible < m_pScroller->GetValue() ) )
{
- m_pScroller->SetValue(row);
+ m_pScroller->SetValue(numVisible);
}
}
@@ -2277,6 +2304,76 @@
MoveAlongMenuItemList(direction, loopCount + 1);
}
}
+
+ if ( bArmItem )
+ {
+ if ( m_MenuItems.IsValidIndex( m_iCurrentlySelectedItemID ) )
+ {
+ m_MenuItems[m_iCurrentlySelectedItemID]->ArmItem();
+ }
+ }
+}
+
+
+int Menu::GetVisibleItemIndex( int sortedIndex )
+{
+ int numVisible = 0;
+ int findVisible = 0;
+
+ while ( m_SortedItems.IsValidIndex( findVisible ) && findVisible < sortedIndex )
+ {
+ if ( m_MenuItems.IsValidIndex( m_SortedItems[ findVisible ] ) && m_MenuItems[ m_SortedItems[ findVisible ] ]->IsVisible() )
+ numVisible++;
+
+ findVisible++;
+ }
+
+ return numVisible;
+}
+
+int Menu::GetFirstVisibleIndex()
+{
+ int findVisible = 0;
+
+ while ( m_SortedItems.IsValidIndex( findVisible ) )
+ {
+ if ( m_MenuItems.IsValidIndex( m_SortedItems[ findVisible ] ) && m_MenuItems[ m_SortedItems[ findVisible ] ]->IsVisible() )
+ return findVisible;
+
+ findVisible++;
+ }
+
+ return findVisible;
+}
+
+int Menu::GetLastVisibleIndex()
+{
+ int findVisible = 0;
+ int lastVisible = 0;
+
+ while ( findVisible >= 0 )
+ {
+ lastVisible = findVisible;
+
+ findVisible = GetNextVisible( findVisible );
+ }
+
+ return lastVisible;
+}
+
+int Menu::GetNextVisible( int sortedIndex )
+{
+ sortedIndex++;
+
+ while ( m_SortedItems.IsValidIndex( sortedIndex ) )
+ {
+ if ( m_MenuItems.IsValidIndex( m_SortedItems[ sortedIndex ] ) && m_MenuItems[ m_SortedItems[ sortedIndex ] ]->IsVisible() )
+ return sortedIndex;
+
+ sortedIndex++;
+ }
+
+ return -1;
}
//-----------------------------------------------------------------------------
diff -Nuar vgui_controls/menuitem.cpp vgui_editor/menuitem.cpp
--- vgui_controls/menuitem.cpp 2014-07-30 12:53:43.323885882 -0700
+++ vgui_editor/menuitem.cpp 2014-07-30 13:01:35.126830790 -0700
@@ -10,10 +10,12 @@
#include "vgui/ISurface.h"
#include <KeyValues.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/Menu.h>
-#include <vgui_controls/MenuItem.h>
-#include <vgui_controls/TextImage.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/menu.h>
+#include <vgui_controls/menuitem.h>
+#include <vgui_controls/textimage.h>
+
+#include "vgui_editor_platform.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -133,13 +135,16 @@
//-----------------------------------------------------------------------------
void MenuItem::Init( void )
{
+ m_bIgnoreFirstClick = false;
+ m_bFirstClick = false;
+ m_iImage = -1;
m_pCascadeArrow = NULL;
m_pCheck = NULL;
if (m_pCascadeMenu)
{
m_pCascadeMenu->SetParent(this);
- m_pCascadeArrow = new TextImage (" 4"); // this makes a right pointing arrow.
+ m_pCascadeArrow = new TextImage ("4"); // this makes a right pointing arrow.
m_pCascadeMenu->AddActionSignalTarget(this);
}
@@ -181,6 +186,31 @@
}
}
+void MenuItem::SetImage( int i )
+{
+ m_iImage = i;
+}
+
+bool MenuItem::HasImage()
+{
+ return m_iImage >= 0;
+}
+
+int MenuItem::GetImage()
+{
+ return m_iImage;
+}
+
+bool MenuItem::ShouldIgnoreFirstClick()
+{
+ return m_bIgnoreFirstClick;
+}
+
+void MenuItem::SetIgnoreFirstClick( bool bEnable )
+{
+ m_bIgnoreFirstClick = bEnable;
+}
+
//-----------------------------------------------------------------------------
// Purpose: Close the cascading menu if we have one.
//-----------------------------------------------------------------------------
@@ -281,6 +311,8 @@
//-----------------------------------------------------------------------------
void MenuItem::DisarmItem()
{
+ m_bFirstClick = false;
+
// normal behaviour is that the button becomes unarmed
// do not unarm if there is a cascading menu. CloseCascadeMenu handles this.
// and the menu handles it since we close at different times depending
@@ -321,6 +353,13 @@
//-----------------------------------------------------------------------------
void MenuItem::FireActionSignal()
{
+ if ( ShouldIgnoreFirstClick() && !m_bFirstClick )
+ {
+ GetParentMenu()->SetCurrentlyHighlightedItem( GetParentMenu()->m_MenuItems.Find( this ) );
+ m_bFirstClick = true;
+ return;
+ }
+
// cascading menus items don't trigger the parent menu to disappear
// (they trigger the cascading menu to open/close when cursor is moved over/off them)
if (!m_pCascadeMenu)
@@ -601,6 +640,16 @@
void MenuItem::Paint()
{
+ if ( HasImage() )
+ {
+ int iTall = GetTall();
+
+ surface()->DrawSetColor( Color(255,255,255,255) );
+ surface()->DrawSetTexture( GetImage() );
+ surface()->DrawTexturedRect( 0, 0, iTall, iTall );
+ }
+
+
BaseClass::Paint();
if ( !m_pCurrentKeyBinding )
return;
diff -Nuar vgui_controls/messagebox.cpp vgui_editor/messagebox.cpp
--- vgui_controls/messagebox.cpp 2014-07-30 12:53:43.323885882 -0700
+++ vgui_editor/messagebox.cpp 2014-07-30 13:01:35.170830791 -0700
@@ -9,20 +9,18 @@
#include <KeyValues.h>
#include <vgui/IInput.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/MessageBox.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/messagebox.h>
+
+#include "vgui_editor_platform.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
using namespace vgui;
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
vgui::Panel *MessageBox_Factory()
{
return new MessageBox("MessageBox", "MessageBoxText");
diff -Nuar vgui_controls/messagedialog.cpp vgui_editor/messagedialog.cpp
--- vgui_controls/messagedialog.cpp 2014-07-30 12:53:43.323885882 -0700
+++ vgui_editor/messagedialog.cpp 2014-07-30 13:01:35.074830788 -0700
@@ -8,6 +8,8 @@
#include "vgui/ILocalize.h"
#include "vgui/ISurface.h"
+#include "vgui_editor_platform.h"
+
//-----------------------------------------------------------------------------
// CMessageDialog
//-----------------------------------------------------------------------------
diff -Nuar vgui_controls/panel.cpp vgui_editor/panel.cpp
--- vgui_controls/panel.cpp 2014-07-30 12:53:43.327887883 -0700
+++ vgui_editor/panel.cpp 2014-07-30 13:01:35.158830793 -0700
@@ -8,7 +8,7 @@
#include <stdio.h>
#include <assert.h>
-#include <UtlVector.h>
+#include <utlvector.h>
#include <vstdlib/IKeyValuesSystem.h>
#include <vgui/IBorder.h>
@@ -22,22 +22,24 @@
#include <KeyValues.h>
#include <vgui/MouseCode.h>
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/BuildGroup.h>
-#include <vgui_controls/Tooltip.h>
-#include <vgui_controls/PHandle.h>
-#include <vgui_controls/Controls.h>
-#include "vgui_controls/Menu.h"
-#include "vgui_controls/MenuItem.h"
+#include <vgui_controls/panel.h>
+#include <vgui_controls/buildgroup.h>
+#include <vgui_controls/tooltip.h>
+#include <vgui_controls/phandle.h>
+#include <vgui_controls/controls.h>
+#include "vgui_controls/menu.h"
+#include "vgui_controls/menuitem.h"
-#include "UtlDict.h"
+#include "utldict.h"
#include "UtlBuffer.h"
#include "MemPool.h"
-#include "FileSystem.h"
+#include "filesystem.h"
#include "tier0/icommandline.h"
#include "tier0/vprof.h"
+#include "vgui_editor_platform.h"
+
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -670,6 +672,8 @@
m_hKeyBindingsContext = INVALID_KEYBINDINGCONTEXT_HANDLE;
#endif
+ m_iColorOverride = 0;
+
REGISTER_COLOR_AS_OVERRIDABLE( _fgColor, "fgcolor_override" );
REGISTER_COLOR_AS_OVERRIDABLE( _bgColor, "bgcolor_override" );
}
@@ -722,6 +726,8 @@
#if defined( VGUI_USEDRAGDROP )
delete m_pDragDrop;
#endif // VGUI_USEDRAGDROP
+
+ delete m_pTooltips;
}
//-----------------------------------------------------------------------------
@@ -993,7 +999,7 @@
float oldAlphaMultiplier = surface()->DrawGetAlphaMultiplier();
float newAlphaMultiplier = oldAlphaMultiplier * m_flAlpha * 1.0f/255.0f;
- if ( IsXbox() && !newAlphaMultiplier )
+ if ( /*IsXbox() &&*/ !newAlphaMultiplier )
{
// xbox optimization not suitable for pc
// xbox panels are compliant and can early out and not traverse their children
@@ -1086,7 +1092,7 @@
{
// outline all selected panels
CUtlVector<PHandle> *controlGroup = _buildGroup->GetControlGroup();
- for (int i=0; i < controlGroup->Size(); ++i)
+ for (int i=0; i < controlGroup->Count(); ++i)
{
surface()->PushMakeCurrent( ((*controlGroup)[i].Get())->GetVPanel(), false );
((*controlGroup)[i].Get())->PaintBuildOverlay();
@@ -1230,7 +1236,7 @@
//-----------------------------------------------------------------------------
bool Panel::IsRightAligned()
{
- return (_buildModeFlags & BUILDMODE_SAVE_XPOS_RIGHTALIGNED);
+ return (_buildModeFlags & BUILDMODE_SAVE_XPOS_RIGHTALIGNED) != 0;
}
//-----------------------------------------------------------------------------
@@ -1238,7 +1244,7 @@
//-----------------------------------------------------------------------------
bool Panel::IsBottomAligned()
{
- return (_buildModeFlags & BUILDMODE_SAVE_YPOS_BOTTOMALIGNED);
+ return (_buildModeFlags & BUILDMODE_SAVE_YPOS_BOTTOMALIGNED) != 0;
}
//-----------------------------------------------------------------------------
@@ -3044,7 +3050,7 @@
//-----------------------------------------------------------------------------
bool Panel::IsBuildModeDeletable()
{
- return (_buildModeFlags & BUILDMODE_DELETABLE);
+ return (_buildModeFlags & BUILDMODE_DELETABLE) != 0;
}
//-----------------------------------------------------------------------------
@@ -3129,7 +3135,7 @@
void Panel::RequestFocus(int direction)
{
// NOTE: This doesn't make any sense if we don't have keyboard input enabled
- Assert( IsX360() || IsKeyBoardInputEnabled() );
+// Assert( IsX360() || IsKeyBoardInputEnabled() );
// ivgui()->DPrintf2("RequestFocus(%s, %s)\n", GetName(), GetClassName());
OnRequestFocus(GetVPanel(), NULL);
}
@@ -3897,7 +3903,7 @@
SetVisible(true);
}
- SetEnabled( inResourceData->GetInt("enabled", true) );
+ SetEnabled( inResourceData->GetBool("enabled", true) );
// tab order
SetTabPosition(inResourceData->GetInt("tabPosition", 0));
@@ -3941,6 +3947,16 @@
m_OverridableColorEntries[i].m_bOverridden = true;
}
}
+
+ m_iColorOverride = inResourceData->GetInt( "allowColorOverrides" );
+ if ( inResourceData->FindKey( "bgcolor" ) && m_iColorOverride != 0 )
+ for ( int i = 0; i < m_OverridableColorEntries.Count(); i++ )
+ if ( !Q_stricmp( m_OverridableColorEntries[i].m_pszScriptName, "bgcolor_override" ) )
+ {
+ m_OverridableColorEntries[i].m_colFromScript = inResourceData->GetColor( "bgcolor" );
+ *m_OverridableColorEntries[i].m_pColor = m_OverridableColorEntries[i].m_colFromScript;
+ m_OverridableColorEntries[i].m_bOverridden = true;
+ }
}
//-----------------------------------------------------------------------------
@@ -4052,6 +4068,16 @@
outResourceData->SetColor( m_OverridableColorEntries[i].m_pszScriptName, m_OverridableColorEntries[i].m_colFromScript );
}
}
+
+ for ( int i = 0; i < m_OverridableColorEntries.Count(); i++ )
+ if ( !Q_stricmp( m_OverridableColorEntries[i].m_pszScriptName, "bgcolor_override" ) )
+ {
+ char colorString[MAX_PATH];
+ Color col = *m_OverridableColorEntries[i].m_pColor;
+ Q_snprintf( colorString, MAX_PATH, "%u %u %u %u", col.r(), col.g(), col.b(), col.a() );
+ outResourceData->SetString( "bgcolor", colorString );
+ }
+ outResourceData->SetInt( "allowColorOverrides", m_iColorOverride );
}
//-----------------------------------------------------------------------------
@@ -4109,7 +4135,8 @@
//-----------------------------------------------------------------------------
const char *Panel::GetDescription( void )
{
- static const char *panelDescription = "string fieldName, int xpos, int ypos, int wide, int tall, bool visible, bool enabled, int tabPosition, corner pinCorner, autoresize autoResize, string tooltiptext";
+ static const char *panelDescription = "string fieldName, int xpos, int ypos, int wide, int tall, bool visible, bool enabled,\
+ int tabPosition, corner pinCorner, autoresize autoResize, string tooltiptext, int allowColorOverrides, string bgcolor";
return panelDescription;
}
@@ -4523,7 +4550,7 @@
{
case DATATYPE_BOOL:
typedef void (Panel::*MessageFunc_Bool_t)(bool);
- (this->*((MessageFunc_Bool_t)pMessageMap[i].func))( (bool)params->GetInt(pMessageMap[i].firstParamName) );
+ (this->*((MessageFunc_Bool_t)pMessageMap[i].func))( (bool)params->GetBool(pMessageMap[i].firstParamName) );
break;
case DATATYPE_CONSTCHARPTR:
@@ -6677,7 +6704,7 @@
class CPanelMessageMapDictionary
{
public:
- CPanelMessageMapDictionary() : m_PanelMessageMapPool( sizeof(PanelMessageMap), 32, CMemoryPool::GROW_FAST, "CPanelMessageMapDictionary::m_PanelMessageMapPool" )
+ CPanelMessageMapDictionary() : m_PanelMessageMapPool( sizeof(PanelMessageMap), 32, CUtlMemoryPool::GROW_FAST, "CPanelMessageMapDictionary::m_PanelMessageMapPool" )
{
m_MessageMaps.RemoveAll();
}
@@ -6694,7 +6721,7 @@
char const *StripNamespace( char const *className );
CUtlDict< PanelMessageMapDictionaryEntry, int > m_MessageMaps;
- CMemoryPool m_PanelMessageMapPool;
+ CUtlMemoryPool m_PanelMessageMapPool;
};
@@ -6746,7 +6773,7 @@
class CPanelKeyBindingMapDictionary
{
public:
- CPanelKeyBindingMapDictionary() : m_PanelKeyBindingMapPool( sizeof(PanelKeyBindingMap), 32, CMemoryPool::GROW_FAST, "CPanelKeyBindingMapDictionary::m_PanelKeyBindingMapPool" )
+ CPanelKeyBindingMapDictionary() : m_PanelKeyBindingMapPool( sizeof(PanelKeyBindingMap), 32, CUtlMemoryPool::GROW_FAST, "CPanelKeyBindingMapDictionary::m_PanelKeyBindingMapPool" )
{
m_MessageMaps.RemoveAll();
}
@@ -6763,7 +6790,7 @@
char const *StripNamespace( char const *className );
CUtlDict< PanelKeyBindingMapDictionaryEntry, int > m_MessageMaps;
- CMemoryPool m_PanelKeyBindingMapPool;
+ CUtlMemoryPool m_PanelKeyBindingMapPool;
};
diff -Nuar vgui_controls/panellistpanel.cpp vgui_editor/panellistpanel.cpp
--- vgui_controls/panellistpanel.cpp 2014-07-30 12:53:43.327887883 -0700
+++ vgui_editor/panellistpanel.cpp 2014-07-30 13:01:35.114830790 -0700
@@ -10,12 +10,12 @@
#include "vgui/IScheme.h"
#include "vgui/ISurface.h"
-#include "vgui_controls/EditablePanel.h"
-#include "vgui_controls/ScrollBar.h"
-#include "vgui_controls/Label.h"
-#include "vgui_controls/Button.h"
-#include "vgui_controls/Controls.h"
-#include "vgui_controls/PanelListPanel.h"
+#include "vgui_controls/editablepanel.h"
+#include "vgui_controls/scrollbar.h"
+#include "vgui_controls/label.h"
+#include "vgui_controls/button.h"
+#include "vgui_controls/controls.h"
+#include "vgui_controls/panellistpanel.h"
#include "KeyValues.h"
@@ -30,6 +30,7 @@
PanelListPanel::PanelListPanel( vgui::Panel *parent, char const *panelName ) : Panel( parent, panelName )
{
SetBounds( 0, 0, 100, 100 );
+ m_bInnerPanel = false;
m_vbar = new ScrollBar(this, "PanelListPanelVScroll", true);
m_vbar->SetVisible(false);
@@ -64,6 +65,11 @@
DeleteAllItems();
}
+void PanelListPanel::SetInnerPanel( bool bInner )
+{
+ m_bInnerPanel = bInner;
+}
+
void PanelListPanel::SetVerticalBufferPixels( int buffer )
{
m_iPanelBuffer = buffer;
@@ -239,10 +245,13 @@
{
FOR_EACH_LL( m_DataItems, i )
{
- if ( m_DataItems[i].panel )
- {
- delete m_DataItems[i].panel;
- }
+ //if ( m_DataItems[i].panel )
+ //{
+ // delete m_DataItems[i].panel;
+ //}
+
+ delete m_DataItems[i].labelPanel;
+ delete m_DataItems[i].panel;
}
m_DataItems.RemoveAll();
@@ -283,7 +292,7 @@
int vpixels = ComputeVPixelsNeeded();
- m_vbar->SetVisible( true );
+ m_vbar->SetVisible( !m_bInnerPanel );
m_vbar->SetRange( 0, vpixels );
m_vbar->SetRangeWindow( tall );
m_vbar->SetButtonPressedScrollValue( tall / 4 ); // standard height of labels/buttons etc.
@@ -293,8 +302,10 @@
int top = m_vbar->GetValue();
+ int scrollBarWidth = m_bInnerPanel ? 0 : m_vbar->GetWide();
+
m_pPanelEmbedded->SetPos( 1, -top );
- m_pPanelEmbedded->SetSize( wide - m_vbar->GetWide() - 2, vpixels );
+ m_pPanelEmbedded->SetSize( wide - scrollBarWidth - 2, vpixels );
int sliderPos = m_vbar->GetValue();
@@ -304,7 +315,7 @@
int totalh = 0;
int xpos = m_iFirstColumnWidth + m_iPanelBuffer;
- int iColumnWidth = ( wide - xpos - m_vbar->GetWide() - 12 ) / m_iNumColumns;
+ int iColumnWidth = ( wide - xpos - scrollBarWidth - 12 ) / m_iNumColumns;
for ( int i = 0; i < m_SortedItems.Count(); i++ )
{
@@ -398,6 +409,12 @@
//-----------------------------------------------------------------------------
void PanelListPanel::OnMouseWheeled(int delta)
{
+ if ( m_bInnerPanel )
+ {
+ if ( GetParent() )
+ GetParent()->OnMouseWheeled( delta );
+ return;
+ }
int val = m_vbar->GetValue();
val -= (delta * DEFAULT_HEIGHT);
m_vbar->SetValue(val);
@@ -463,3 +480,7 @@
}
+ScrollBar *PanelListPanel::GetScrollbar()
+{
+ return m_vbar;
+}
\ No newline at end of file
diff -Nuar vgui_controls/perforcefileexplorer.cpp vgui_editor/perforcefileexplorer.cpp
--- vgui_controls/perforcefileexplorer.cpp 2014-07-30 12:53:43.327887883 -0700
+++ vgui_editor/perforcefileexplorer.cpp 2014-07-30 13:01:35.166830791 -0700
@@ -11,7 +11,7 @@
#include <vgui_controls/button.h>
#include <vgui_controls/tooltip.h>
#include "tier1/keyvalues.h"
-#include "vgui/isystem.h"
+#include "vgui/ISystem.h"
#include "filesystem.h"
#include <ctype.h>
#include "p4lib/ip4.h"
diff -Nuar vgui_controls/perforcefilelist.cpp vgui_editor/perforcefilelist.cpp
--- vgui_controls/perforcefilelist.cpp 2014-07-30 12:53:43.327887883 -0700
+++ vgui_editor/perforcefilelist.cpp 2014-07-30 13:01:35.202830794 -0700
@@ -6,9 +6,9 @@
//===========================================================================//
#include <vgui_controls/perforcefilelist.h>
-#include <vgui_controls/ListPanel.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/ImageList.h>
+#include <vgui_controls/listpanel.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/imagelist.h>
#include "tier1/keyvalues.h"
#include <vgui/ISurface.h>
#include "filesystem.h"
diff -Nuar vgui_controls/progressbar.cpp vgui_editor/progressbar.cpp
--- vgui_controls/progressbar.cpp 2014-07-30 12:53:43.327887883 -0700
+++ vgui_editor/progressbar.cpp 2014-07-30 13:01:35.222830795 -0700
@@ -9,8 +9,8 @@
#include <math.h>
#include <stdio.h>
-#include <vgui_controls/ProgressBar.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/progressbar.h>
+#include <vgui_controls/controls.h>
#include <vgui/ILocalize.h>
#include <vgui/IScheme.h>
diff -Nuar vgui_controls/progressbox.cpp vgui_editor/progressbox.cpp
--- vgui_controls/progressbox.cpp 2014-07-30 12:53:43.331889883 -0700
+++ vgui_editor/progressbox.cpp 2014-07-30 13:01:35.206830794 -0700
@@ -12,23 +12,21 @@
#include <vgui/IVGui.h>
#include <KeyValues.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/ProgressBar.h>
-#include <vgui_controls/ProgressBox.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/progressbar.h>
+#include <vgui_controls/progressbox.h>
#include <stdio.h>
+#include "vgui_editor_platform.h"
+
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
using namespace vgui;
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
diff -Nuar vgui_controls/propertydialog.cpp vgui_editor/propertydialog.cpp
--- vgui_controls/propertydialog.cpp 2014-07-30 12:53:43.331889883 -0700
+++ vgui_editor/propertydialog.cpp 2014-07-30 13:01:35.190830793 -0700
@@ -8,9 +8,9 @@
#include <vgui/KeyCode.h>
#include <KeyValues.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/PropertyDialog.h>
-#include <vgui_controls/PropertySheet.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/propertydialog.h>
+#include <vgui_controls/propertysheet.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/propertypage.cpp vgui_editor/propertypage.cpp
--- vgui_controls/propertypage.cpp 2014-07-30 12:53:43.331889883 -0700
+++ vgui_editor/propertypage.cpp 2014-07-30 13:01:35.118830789 -0700
@@ -10,8 +10,8 @@
#include "vgui/ISurface.h"
#include "KeyValues.h"
-#include "vgui_controls/PropertyPage.h"
-#include "vgui_controls/Controls.h"
+#include "vgui_controls/propertypage.h"
+#include "vgui_controls/controls.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
diff -Nuar vgui_controls/propertysheet.cpp vgui_editor/propertysheet.cpp
--- vgui_controls/propertysheet.cpp 2014-07-30 12:53:43.331889883 -0700
+++ vgui_editor/propertysheet.cpp 2014-07-30 13:01:35.142830790 -0700
@@ -15,17 +15,19 @@
#include <KeyValues.h>
#include <vgui/MouseCode.h>
#include <vgui/ISurface.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/PropertySheet.h>
-#include <vgui_controls/ComboBox.h>
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/ToolWindow.h>
-#include <vgui_controls/TextImage.h>
-#include <vgui_controls/ImagePanel.h>
-#include <vgui_controls/PropertyPage.h>
-#include "vgui_controls/AnimationController.h"
+#include <vgui_controls/button.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/propertysheet.h>
+#include <vgui_controls/combobox.h>
+#include <vgui_controls/panel.h>
+#include <vgui_controls/toolwindow.h>
+#include <vgui_controls/textimage.h>
+#include <vgui_controls/imagepanel.h>
+#include <vgui_controls/propertypage.h>
+#include "vgui_controls/animationcontroller.h"
+
+#include "vgui_editor_platform.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -126,9 +128,30 @@
ContextLabel *m_pContextLabel;
long m_hoverActivatePageTime;
long m_dropHoverTime;
+ Button *m_pButtonClose;
+ bool m_bShouldShowCloseButton;
+ bool m_bDragEnabled;
+
+ Color m_ColBgColor;
+ bool m_bDrawBg;
+
+ bool m_bClosing;
+ bool m_bOpening;
+ float m_flCurSizeX;
+
+#define __ptab_button_inset 3
+
+ int m_iDesignatedWidth;
+ int m_iLastMouseX;
+
+ //double flAnimTime;
+
+//#define __ptab_ANIMDUR 0.5f
public:
- PageTab(PropertySheet *parent, const char *panelName, const char *text, char const *imageName, int maxTabWidth, Panel *page, bool showContextButton, long hoverActivatePageTime = -1 ) :
+
+ PageTab(PropertySheet *parent, const char *panelName, const char *text, char const *imageName, int maxTabWidth, Panel *page, bool showContextButton,
+ long hoverActivatePageTime = -1, bool bCloseButton = false ) :
Button( (Panel *)parent, panelName, text),
m_pParent( parent ),
m_pPage( page ),
@@ -141,9 +164,21 @@
{
SetCommand(new KeyValues("TabPressed"));
_active = false;
+ m_bDrawBg = false;
m_bMaxTabWidth = maxTabWidth;
- SetDropEnabled( true );
- SetDragEnabled( m_pParent->IsDraggableTab() );
+ //SetDropEnabled( true );
+ //SetDragEnabled( m_pParent->IsDraggableTab() );
+ m_bDragEnabled = m_pParent->IsDraggableTab();
+
+ m_bClosing = false;
+ m_bOpening = bCloseButton;
+ m_flCurSizeX = 0;
+ m_iDesignatedWidth = 0;
+ m_iLastMouseX = 0;
+
+ //if ( m_bOpening )
+ // flAnimTime = system()->GetCurrentTime() + __ptab_ANIMDUR;
+
if ( imageName )
{
m_pImage = new ImagePanel( this, text );
@@ -152,11 +187,22 @@
Q_strncpy( m_pszImageName, imageName, buflen );
}
+
+ m_pActiveBorder = NULL;
+ m_pNormalBorder = NULL;
+
SetMouseClickEnabled( MOUSE_RIGHT, true );
m_pContextLabel = m_bShowContextLabel ? new ContextLabel( this, "Context", "9" ) : NULL;
REGISTER_COLOR_AS_OVERRIDABLE( _textColor, "selectedcolor" );
REGISTER_COLOR_AS_OVERRIDABLE( _dimTextColor, "unselectedcolor" );
+
+ m_bShouldShowCloseButton = true;
+
+ if ( bCloseButton )
+ m_pButtonClose = new Button( this, "closebutton", "x", this, "close_tab" );
+ else
+ m_pButtonClose = NULL;
}
~PageTab()
@@ -164,8 +210,62 @@
delete[] m_pszImageName;
}
+ const int GetDesignatedWidth()
+ {
+ int x, y;
+ GetSize(x,y);
+
+ return ( m_iDesignatedWidth > 0 ) ? m_iDesignatedWidth : x;
+ };
+
+ bool IsAnimating()
+ {
+ return m_bClosing || m_bOpening;
+ }
+
+ void CloseTab()
+ {
+ m_bClosing = true;
+ m_bOpening = false;
+
+ if ( m_iDesignatedWidth > 0 )
+ m_flCurSizeX = m_iDesignatedWidth;
+ //flAnimTime = system()->GetCurrentTime() + __ptab_ANIMDUR;
+ }
+
+ void SetText( const char *pszText )
+ {
+ BaseClass::SetText( pszText );
+ //InvalidateLayout(true);
+ //m_flCurSizeX = m_iDesignatedWidth;
+ }
+
+ bool IsClosing()
+ {
+ return m_bClosing;
+ }
+
+ void SetCloseButtonVisible( bool bVisible )
+ {
+ m_bShouldShowCloseButton = bVisible;
+ }
+
+ void SetCustomBgColor( Color c )
+ {
+ m_ColBgColor = c;
+ m_bDrawBg = true;
+ InvalidateLayout();
+ };
+
virtual void Paint()
{
+ if ( m_bDrawBg )
+ {
+ surface()->DrawSetColor( m_ColBgColor ); //GetBgColor() );
+ int sx, sy;
+ GetSize(sx,sy);
+ surface()->DrawFilledRect( 0, 0, sx, sy );
+ }
BaseClass::Paint();
}
@@ -193,6 +293,12 @@
}
m_bAttemptingDrop = false;
+ if ( m_bDragEnabled && input()->GetMouseCapture() == GetVPanel() )
+ {
+ if ( m_pParent->DoScroll() )
+ OnDoDrag();
+ }
+
BaseClass::OnThink();
}
@@ -316,6 +422,15 @@
_dimTextColor = GetSchemeColor("PropertySheet.TextColor", GetFgColor(), pScheme);
m_pActiveBorder = pScheme->GetBorder("TabActiveBorder");
m_pNormalBorder = pScheme->GetBorder("TabBorder");
+ }
+
+ void PerformLayout()
+ {
+ BaseClass::PerformLayout();
+
+ int tabHeight = m_pParent->GetTabHeight();
+ int maxWidth;
+ int maxHeight;
if ( m_pImage )
{
@@ -329,7 +444,9 @@
{
m_pImage->SetPos( 10, 0 );
}
- SetSize( w + 4, h + 2 );
+
+ maxWidth = w + 4;
+ maxHeight = h + 2;
}
else
{
@@ -340,12 +457,77 @@
wide = max(m_bMaxTabWidth, contentWide + 10); // 10 = 5 pixels margin on each side
wide += m_pContextLabel ? 10 : 0;
- SetSize(wide, tall);
+ if ( m_pButtonClose && m_bShouldShowCloseButton )
+ wide += tabHeight - 7;
+
+ maxWidth = wide;
+ maxHeight = tall;
+ }
+
+ if ( IsAnimating() )
+ {
+ int goal = m_bClosing ? 0 : maxWidth;
+
+ if ( abs( goal - m_flCurSizeX ) > 1 )
+ m_flCurSizeX = Approach( goal, m_flCurSizeX, m_pParent->m_dFrametime * 1000.0f * ((float)maxWidth/200.0f) );
+ else
+ m_flCurSizeX = goal;
+ //m_flCurSizeX = Lerp( clamp( 1.0f - (system()->GetCurrentTime() - flAnimTime)/__ptab_ANIMDUR, 0, 1 ),
+
+ if ( m_bClosing && m_flCurSizeX < 1 )
+ {
+ m_bClosing = false;
+ RemovePageAndTab();
+ return;
+ }
+ else if ( m_bOpening && abs( m_flCurSizeX - maxWidth ) < 1 )
+ {
+ m_bOpening = false;
+ m_flCurSizeX = maxWidth;
+ }
+
+ SetSize( m_flCurSizeX, maxHeight );
+ }
+ else
+ SetSize( maxWidth, maxHeight );
+
+ m_iDesignatedWidth = maxWidth;
+
+ if ( m_pButtonClose )
+ {
+ m_pButtonClose->SetSize( tabHeight - __ptab_button_inset * 2, tabHeight - __ptab_button_inset * 2 );
+ m_pButtonClose->SetVisible( m_bShouldShowCloseButton );
+ m_pButtonClose->SetTextInset( 7, 0 );
+
+ if ( m_bDrawBg )
+ {
+ Color cBG = Color( max( 0, m_ColBgColor.r() - 15 ),
+ max( 0, m_ColBgColor.g() - 15 ),
+ max( 0, m_ColBgColor.b() - 15 ),
+ m_ColBgColor.a() );
+ m_pButtonClose->SetDefaultColor( GetFgColor(), cBG );
+ m_pButtonClose->SetPaintBackgroundEnabled( true );
+ m_pButtonClose->SetPaintBackgroundType( 0 );
+ }
}
if ( m_pContextLabel )
{
SetTextInset( 12, 0 );
+ int w, h;
+ GetSize( w, h );
+ m_pContextLabel->SetBounds( 0, 0, 10, h );
+ }
+ }
+
+ virtual void OnSizeChanged(int newWide, int newTall)
+ {
+ BaseClass::OnSizeChanged(newWide,newTall);
+
+ if ( m_pButtonClose && m_pParent )
+ {
+ int tabHeight = m_pParent->GetTabHeight();
+ m_pButtonClose->SetPos( newWide - tabHeight + __ptab_button_inset, __ptab_button_inset );
}
}
@@ -375,9 +557,50 @@
PostActionSignal( kv );
return;
}
+ else if ( !Q_stricmp( cmd, "close_tab" ) )
+ {
+ TryPageClose();
+ return;
+ }
+
BaseClass::OnCommand( cmd );
}
+ void TryPageClose()
+ {
+ if ( !m_pParent->AllowClosing() )
+ return;
+
+ int ipagenum = m_pParent->FindPage( m_pPage );
+ KeyValues *pKV = new KeyValues( "AskPageClose" );
+ pKV->SetPtr( "PageTab", this );
+ pKV->SetInt( "TabIndex", ipagenum );
+ m_pParent->PostActionSignal( pKV );
+ }
+
+ MESSAGE_FUNC( OnCloseConfirmed, "OnCloseConfirmed" )
+ {
+ m_pParent->ClosePage( m_pPage );
+ }
+
+ void RemovePageAndTab()
+ {
+ if ( !m_bShouldShowCloseButton || !m_pButtonClose )
+ return;
+
+ if ( m_pParent->GetNumPages() > 1 )
+ {
+ int ipagenum = m_pParent->FindPage( m_pPage );
+ bool bWasActive = m_pPage == m_pParent->GetActivePage();
+
+ m_pParent->DeletePage( m_pPage );
+ m_pParent->PostActionSignal(new KeyValues("PageClosed", "pagenum", ipagenum));
+
+ if ( bWasActive )
+ m_pParent->ScrollToActivePage();
+ }
+ }
+
IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus)
{
if (_active)
@@ -413,10 +636,70 @@
InvalidateLayout();
}
- virtual bool CanBeDefaultButton(void)
- {
- return false;
- }
+ virtual bool CanBeDefaultButton(void)
+ {
+ return false;
+ }
+
+ virtual void OnCursorMoved( int x, int y )
+ {
+ if ( m_bDragEnabled && input()->IsMouseDown( MOUSE_LEFT ) )
+ {
+ if ( input()->GetMouseCapture() != GetVPanel() )
+ input()->SetMouseCapture(GetVPanel());
+
+ if ( m_iLastMouseX < 0 || abs( m_iLastMouseX - x ) > 3 )
+ {
+ m_iLastMouseX = -1;
+ OnDoDrag();
+ }
+ }
+ else
+ m_iLastMouseX = x;
+
+ BaseClass::OnCursorMoved( x, y );
+ }
+
+ virtual void OnDoDrag()
+ {
+ int mx, my;
+ input()->GetCursorPosition( mx, my );
+
+
+
+ //LocalToScreen( mx, my );
+ m_pParent->ScreenToLocal( mx, my );
+
+ int iBestTab = -1;
+ int iBestDist = 99999;
+ for ( int i = 0; i < m_pParent->GetNumPages() - 1; i++ )
+ {
+ PageTab *pTab0 = m_pParent->GetTab(i);
+ PageTab *pTab1 = m_pParent->GetTab(i+1);
+ int _x0, _x1, dummy;
+ pTab0->GetBounds( _x0, dummy, _x1, dummy );
+ _x1 += _x0;
+ int xmin = _x0;
+ pTab1->GetBounds( _x0, dummy, _x1, dummy );
+ _x1 += _x0;
+ int xmax = _x1;
+
+ if ( mx < xmin || mx > xmax )
+ continue;
+
+ int mid = (xmax-xmin)*0.5f+xmin;
+ int dist = abs( mx - mid );
+
+ if ( dist > iBestDist )
+ continue;
+
+ iBestDist = dist;
+ iBestTab = ( mx >= mid ) ? i + 1 : i;
+ }
+
+ if ( iBestTab >= 0 )
+ m_pParent->MoveTab( this, iBestTab );
+ }
//Fire action signal when mouse is pressed down instead of on release.
virtual void OnMousePressed(MouseCode code)
@@ -424,10 +707,16 @@
// check for context menu open
if (!IsEnabled())
return;
+
+ if ( code == MOUSE_MIDDLE )
+ {
+ TryPageClose();
+ return;
+ }
if (!IsMouseClickEnabled(code))
return;
-
+
if (IsUseCaptureMouseEnabled())
{
{
@@ -444,8 +733,9 @@
virtual void OnMouseReleased(MouseCode code)
{
+ if (input()->GetMouseCapture() == GetVPanel())
// ensure mouse capture gets released
- if (IsUseCaptureMouseEnabled())
+ //if (IsUseCaptureMouseEnabled())
{
input()->SetMouseCapture(NULL);
}
@@ -463,17 +753,33 @@
}
}
- virtual void PerformLayout()
+ void OnMouseWheeled( int d )
{
- BaseClass::PerformLayout();
+ m_pParent->DoScroll( d * -100 );
+ }
+};
- if ( m_pContextLabel )
- {
- int w, h;
- GetSize( w, h );
- m_pContextLabel->SetBounds( 0, 0, 10, h );
- }
+class CTabBar : public Panel
+{
+ DECLARE_CLASS_SIMPLE( CTabBar, Panel );
+public:
+
+ CTabBar( PropertySheet *parent ) : BaseClass( parent ) {
+ m_pParent = parent;
+ };
+
+ void OnMouseDoublePressed( MouseCode code )
+ {
+ GetParent()->OnCommand( "add_tab" );
+ BaseClass::OnMouseDoublePressed( code );
}
+
+ void OnMouseWheeled( int d )
+ {
+ m_pParent->DoScroll( d * -100 );
+ }
+
+ PropertySheet *m_pParent;
};
}; // namespace vgui
@@ -484,7 +790,8 @@
PropertySheet::PropertySheet(
Panel *parent,
const char *panelName,
- bool draggableTabs /*= false*/ ) : BaseClass(parent, panelName)
+ bool draggableTabs /*= false*/,
+ bool closeableTabs ) : BaseClass(parent, panelName)
{
_activePage = NULL;
_activeTab = NULL;
@@ -498,13 +805,16 @@
m_tabFont = 0;
m_bDraggableTabs = draggableTabs;
m_pTabKV = NULL;
+ m_bCloseableTabs = closeableTabs;
- if ( m_bDraggableTabs )
- {
- SetDropEnabled( true );
- }
+ //if ( m_bDraggableTabs )
+ //{
+ // SetDropEnabled( true );
+ //}
m_bKBNavigationEnabled = true;
+
+ Init();
}
//-----------------------------------------------------------------------------
@@ -525,6 +835,9 @@
m_tabFont = 0;
m_bDraggableTabs = false;
m_pTabKV = NULL;
+ m_bCloseableTabs = false;
+
+ Init();
}
//-----------------------------------------------------------------------------
@@ -534,6 +847,51 @@
{
}
+void PropertySheet::Init()
+{
+ m_iTabHeight = 28;
+
+ m_iTabXScroll_Target = 0;
+ m_flTabXScroll_Accum = 0;
+ m_iTabXScroll_Cur = 0;
+ m_dLastTime = 0;
+ m_dFrametime = 0;
+
+ m_flMouseScroll = 0;
+
+ m_pBut_Left = new Button( this, "scroll_left", "<", this, "scroll_left" );
+ m_pBut_Right = new Button( this, "scroll_right", ">", this, "scroll_right" );
+
+ m_pBut_Left->SetTextInset( 6, -1 );
+ m_pBut_Right->SetTextInset( 6, -1 );
+
+ //m_pBut_Left->MakePopup( false );
+ //m_pBut_Right->MakePopup( false );
+
+ m_pBut_Left->SetVisible( false );
+ m_pBut_Right->SetVisible( false );
+
+ pTabBar = new CTabBar( this );
+ m_pAddTab = NULL;
+}
+
+void PropertySheet::SetAddTabButtonEnabled( bool bEnabled )
+{
+ if ( !!m_pAddTab == bEnabled )
+ return;
+
+ if ( bEnabled )
+ {
+ m_pAddTab = new Button( pTabBar, "add_tab", "+", this, "add_tab" );
+ InvalidateLayout();
+ }
+ else
+ {
+ m_pAddTab->MarkForDeletion();
+ m_pAddTab = NULL;
+ }
+}
+
//-----------------------------------------------------------------------------
// Purpose: ToolWindow uses this to drag tools from container to container by dragging the tab
// Input : -
@@ -576,6 +934,12 @@
return m_bSmallTabs;
}
+
+int PropertySheet::GetTabHeight()
+{
+ return m_iTabHeight;
+}
+
//-----------------------------------------------------------------------------
// Purpose:
// Input : state -
@@ -620,11 +984,13 @@
return;
long hoverActivatePageTime = 250;
- PageTab *tab = new PageTab(this, "tab", title, imageName, _tabWidth, page, m_bContextButton && bHasContextMenu, hoverActivatePageTime );
- if ( m_bDraggableTabs )
- {
- tab->SetDragEnabled( true );
- }
+ PageTab *tab = new PageTab(this, "tab", title, imageName, _tabWidth, page, m_bContextButton && bHasContextMenu, hoverActivatePageTime, m_bCloseableTabs );
+ tab->SetParent( pTabBar );
+
+ //if ( m_bDraggableTabs )
+ //{
+ // tab->SetDragEnabled( true );
+ //}
tab->SetFont( m_tabFont );
if(_showTabs)
@@ -665,6 +1031,8 @@
_activePage->RequestFocus( 0 );
}
}
+
+ UpdateTabCloseButtons();
}
@@ -679,6 +1047,8 @@
return;
ChangeActiveTab(index);
+
+ ScrollToActivePage();
}
//-----------------------------------------------------------------------------
@@ -730,6 +1100,40 @@
return _activeTab;
}
+void PropertySheet::MoveTab( PageTab *pTab, int newIndex )
+{
+ int oldIndex = m_PageTabs.Find( pTab );
+
+ if ( !m_PageTabs.IsValidIndex( oldIndex ) )
+ return;
+
+ if ( newIndex == oldIndex )
+ return;
+
+ bool bAfter = oldIndex < newIndex;
+ if ( bAfter )
+ newIndex--;
+
+ Page_t tPage = m_Pages[oldIndex];
+
+ m_PageTabs.Remove( oldIndex );
+ m_Pages.Remove( oldIndex );
+ Assert( m_PageTabs.IsValidIndex( newIndex ) );
+
+ if ( bAfter )
+ {
+ m_PageTabs.InsertAfter( newIndex, pTab );
+ m_Pages.InsertAfter( newIndex, tPage );
+ }
+ else
+ {
+ m_PageTabs.InsertBefore( newIndex, pTab );
+ m_Pages.InsertBefore( newIndex, tPage );
+ }
+
+ InvalidateLayout();
+}
+
//-----------------------------------------------------------------------------
// Purpose: returns the number of panels in the sheet
//-----------------------------------------------------------------------------
@@ -879,11 +1283,15 @@
}
}
+ /*
if ( !IsProportional() )
{
m_iTabHeight = scheme()->GetProportionalNormalizedValueEx( GetScheme(), m_iTabHeight );
m_iTabHeightSmall = scheme()->GetProportionalNormalizedValueEx( GetScheme(), m_iTabHeightSmall );
}
+ */
+ m_iTabHeight = 28;
+ m_iTabHeightSmall = 14;
}
//-----------------------------------------------------------------------------
@@ -930,20 +1338,59 @@
if (!border)
return;
+ // draw the border underneath the buttons, with a break
+ int wide, tall;
+ GetSize(wide, tall);
+
// draw the border, but with a break at the active tab
int px = 0, py = 0, pwide = 0, ptall = 0;
if (_activeTab)
{
+ bool bShowArrows = ShouldShowArrows();
+
_activeTab->GetBounds(px, py, pwide, ptall);
ptall -= 1;
+
+ if ( bShowArrows )
+ px += GetScrollButtonSize();
}
- // draw the border underneath the buttons, with a break
- int wide, tall;
- GetSize(wide, tall);
border->Paint(0, py + ptall, wide, tall, IBorder::SIDE_TOP, px + 1, px + pwide - 1);
}
+bool PropertySheet::ShouldShowArrows()
+{
+ if ( !_showTabs )
+ return false;
+
+ int sx, sy;
+ GetSize( sx, sy );
+
+ return GetAccumTabX() > sx;
+}
+
+int PropertySheet::GetAccumTabX()
+{
+ int xtab;
+ xtab = m_iTabXIndent * 2;
+
+ int width, tall;
+ for (int i = 0; i < m_PageTabs.Count(); i++)
+ {
+ //m_PageTabs[i]->GetSize(width, tall);
+ width = m_PageTabs[i]->GetDesignatedWidth();
+ xtab += (width + 1) + m_iTabXDelta;
+ }
+
+ if ( m_pAddTab )
+ {
+ m_pAddTab->GetSize( width, tall );
+ xtab += width + 1;
+ }
+
+ return xtab;
+}
+
//-----------------------------------------------------------------------------
// Purpose: Lays out the dialog
//-----------------------------------------------------------------------------
@@ -968,18 +1415,35 @@
_activePage->InvalidateLayout();
}
+ int tabHeight = IsSmallTabs() ? (m_iTabHeightSmall-1) : (m_iTabHeight-1);
+
+ bool bShowArrows = ShouldShowArrows();
+ //int tabxSize = GetAccumTabX();
+ const int buttonscrollsize = GetScrollButtonSize();
+
+ if ( !bShowArrows )
+ {
+ m_iTabXScroll_Cur = 0;
+ pTabBar->SetSize( wide, tabHeight + 1 );
+ pTabBar->SetPos( 0, 0 );
+ }
+ else
+ {
+ //m_iTabXScroll = clamp( m_iTabXScroll, 0, tabxSize - wide + buttonscrollsize * 2 );
+ pTabBar->SetSize( wide - buttonscrollsize * 2, tabHeight + 1 );
+ pTabBar->SetPos( buttonscrollsize, 0 );
+ }
int xtab;
int limit = m_PageTabs.Count();
- xtab = m_iTabXIndent;
+ xtab = m_iTabXIndent - m_iTabXScroll_Cur;
// draw the visible tabs
if (_showTabs)
{
for (int i = 0; i < limit; i++)
{
- int tabHeight = IsSmallTabs() ? (m_iTabHeightSmall-1) : (m_iTabHeight-1);
int width, tall;
m_PageTabs[i]->GetSize(width, tall);
@@ -995,6 +1459,13 @@
m_PageTabs[i]->SetVisible(true);
xtab += (width + 1) + m_iTabXDelta;
}
+
+ if ( m_pAddTab )
+ {
+ m_pAddTab->SetVisible( true );
+ m_pAddTab->SetBounds( xtab, 2, buttonscrollsize, tabHeight );
+ xtab += buttonscrollsize + 1;
+ }
}
else
{
@@ -1002,6 +1473,9 @@
{
m_PageTabs[i]->SetVisible(false);
}
+
+ if ( m_pAddTab )
+ m_pAddTab->SetVisible( false );
}
// ensure draw order (page drawing over all the tabs except one)
@@ -1015,6 +1489,170 @@
_activeTab->MoveToFront();
_activeTab->Repaint();
}
+
+ m_pBut_Left->SetPos( 0, 2 );
+ m_pBut_Right->SetPos( wide - GetScrollButtonSize(), 2 );
+
+ m_pBut_Left->SetSize( buttonscrollsize, tabHeight );
+ m_pBut_Right->SetSize( buttonscrollsize, tabHeight );
+
+ m_pBut_Left->SetVisible( bShowArrows );
+ m_pBut_Right->SetVisible( bShowArrows );
+
+ Color fgCol = Color( 255,255,255,255 );
+ Color bgCol = Color( 127,127,127,255 );
+ Color armedfg = Color( 0, 0, 0, 255 );
+ Color armedbg = Color( 255,255,255,255 );
+
+ m_pBut_Left->SetDefaultColor( fgCol, bgCol );
+ m_pBut_Right->SetDefaultColor( fgCol, bgCol );
+ m_pBut_Left->SetDepressedColor( armedfg, armedbg );
+ m_pBut_Right->SetDepressedColor( armedfg, armedbg );
+
+ if ( m_pAddTab )
+ {
+ m_pAddTab->SetDefaultColor( fgCol, bgCol );
+ m_pAddTab->SetDepressedColor( armedfg, armedbg );
+ }
+}
+
+void PropertySheet::OnThink()
+{
+ double curTime = system()->GetCurrentTime();
+ m_dFrametime = curTime - m_dLastTime;
+ m_dLastTime = curTime;
+
+ if ( ShouldShowArrows() )
+ {
+ int wide, tall;
+ GetSize( wide, tall );
+ m_iTabXScroll_Target = clamp( m_iTabXScroll_Target, 0, GetAccumTabX() - wide + GetScrollButtonSize() * 2 );
+
+ int iOldPos = m_iTabXScroll_Cur;
+
+ if ( abs( m_iTabXScroll_Target - m_flTabXScroll_Accum ) > 1.0f )
+ m_flTabXScroll_Accum += ( (float)m_iTabXScroll_Target - m_flTabXScroll_Accum ) * min( 1.0f, m_dFrametime * 16.0f );
+ //m_flTabXScroll_Accum = Approach( m_iTabXScroll_Target, m_flTabXScroll_Accum, m_dFrametime * 1000.0f );
+ else
+ m_flTabXScroll_Accum = m_iTabXScroll_Target;
+
+ m_iTabXScroll_Cur = m_flTabXScroll_Accum;
+
+ if ( iOldPos != m_iTabXScroll_Cur )
+ InvalidateLayout();
+ }
+ else
+ {
+ m_flTabXScroll_Accum = 0;
+ m_iTabXScroll_Cur = 0;
+ m_iTabXScroll_Target = 0;
+ }
+
+ for ( int i = 0; i < m_PageTabs.Count(); i++ )
+ {
+ if ( m_PageTabs[i]->IsAnimating() )
+ {
+ m_PageTabs[i]->InvalidateLayout();
+ InvalidateLayout();
+ }
+ }
+
+ m_pBut_Left->MoveToFront();
+ m_pBut_Right->MoveToFront();
+
+ BaseClass::OnThink();
+}
+
+void PropertySheet::ClosePage( Panel *page )
+{
+ int i = FindPage( page );
+ if ( i == m_PageTabs.InvalidIndex() )
+ return;
+
+ m_PageTabs[i]->CloseTab();
+}
+
+bool PropertySheet::DoScroll()
+{
+ if ( !ShouldShowArrows() )
+ return false;
+
+ int x, y, sx, sy;
+ input()->GetCursorPosition( x, y );
+ ScreenToLocal( x, y );
+ GetSize( sx, sy );
+
+ int min = GetScrollButtonSize();
+ int max = sx - GetScrollButtonSize();
+
+ if ( x > min && x < max )
+ {
+ m_flMouseScroll = 0;
+ return false;
+ }
+
+ if ( x > min )
+ x-=max-1;
+ else
+ x -= min;
+
+ m_flMouseScroll += ( system()->GetCurrentTime() - system()->GetFrameTime() ) * x * 1000.0l;
+
+ if ( abs(m_flMouseScroll) < 1.0l )
+ return false;
+
+ double integral = floor( m_flMouseScroll );
+ m_iTabXScroll_Target += integral;
+ m_flMouseScroll -= integral;
+ InvalidateLayout();
+ return true;
+}
+
+void PropertySheet::DoScroll( int delta )
+{
+ if ( !ShouldShowArrows() )
+ return;
+
+ m_iTabXScroll_Target += delta;
+ InvalidateLayout();
+}
+
+void PropertySheet::ScrollToActivePage()
+{
+ if ( !ShouldShowArrows() )
+ return;
+
+ PageTab *pActive = (PageTab*)GetActiveTab();
+
+ if ( !pActive )
+ return;
+
+ InvalidateLayout(true);
+ pActive->InvalidateLayout(true);
+
+ int tab_px, tab_py, tab_sx, tab_sy;
+ pActive->GetBounds( tab_px, tab_py, tab_sx, tab_sy );
+ tab_sx = pActive->GetDesignatedWidth();
+ int sheet_px, sheet_py, sheet_sx, sheet_sy;
+ GetBounds( sheet_px, sheet_py, sheet_sx, sheet_sy );
+
+ //page_px += m_iTabXScroll;
+ int containersize = sheet_sx - GetScrollButtonSize() * 2;
+ int extent_x = tab_px + tab_sx;
+
+ if ( m_pAddTab && GetActiveTab() == GetTab( GetNumPages() - 1 ) )
+ {
+ extent_x += 1 + GetScrollButtonSize();
+ }
+
+ if ( tab_px < GetScrollButtonSize() )
+ m_iTabXScroll_Target += tab_px; //+= GetScrollButtonSize() - tab_px;
+ else if ( extent_x > containersize )
+ m_iTabXScroll_Target += extent_x - containersize + 1;
+ else
+ return;
+
+ InvalidateLayout();
}
//-----------------------------------------------------------------------------
@@ -1048,6 +1686,21 @@
return m_Pages[i].page;
}
+PageTab *PropertySheet::GetTab(int i)
+{
+ if ( !m_PageTabs.IsValidIndex(i) )
+ return NULL;
+
+ return m_PageTabs[i];
+}
+
+void PropertySheet::SetTabColor( int index, Color c )
+{
+ if ( !m_PageTabs.IsValidIndex(index) )
+ return;
+
+ m_PageTabs[index]->SetCustomBgColor( c );
+}
//-----------------------------------------------------------------------------
// Purpose: disables page by name
@@ -1097,6 +1750,33 @@
}
}
+void PropertySheet::UpdateTabCloseButtons()
+{
+ bool bShowCloseButtons = AllowClosing();
+
+ for ( int i = 0; i < m_PageTabs.Count(); i++ )
+ {
+ m_PageTabs[i]->SetCloseButtonVisible( bShowCloseButtons );
+ m_PageTabs[i]->InvalidateLayout(true);
+ }
+
+ InvalidateLayout( false, true );
+}
+
+int PropertySheet::GetNumActiveTabs()
+{
+ int activePages = 0;
+ for ( int i = 0; i < m_PageTabs.Count(); i++ )
+ if ( !m_PageTabs[i]->IsClosing() )
+ activePages++;
+ return activePages;
+}
+
+bool PropertySheet::AllowClosing()
+{
+ return GetNumActiveTabs() > 1;
+}
+
//-----------------------------------------------------------------------------
// Purpose: deletes the page associated with panel
// Input : *panel - the panel of the page to remove
@@ -1109,7 +1789,6 @@
// Since it's being deleted, don't animate!!!
m_hPreviouslyActivePage = NULL;
- _activeTab = NULL;
// ASSUMPTION = that the number of pages equals number of tabs
if( _showTabs )
@@ -1129,12 +1808,17 @@
if ( _activePage == panel )
{
+ _activeTab = NULL;
_activePage = NULL;
// if this page is currently active, backup to the page before this.
- ChangeActiveTab( max( location - 1, 0 ) );
+ if ( GetNumPages() <= location )
+ location--;
+ ChangeActiveTab( max( location, 0 ) );
}
PerformLayout();
+
+ UpdateTabCloseButtons();
}
//-----------------------------------------------------------------------------
@@ -1382,6 +2066,21 @@
{
CallParentFunction(new KeyValues("Command", "command", command));
}
+ else if (!stricmp(command, "scroll_left"))
+ {
+ m_iTabXScroll_Target -= 100;
+ InvalidateLayout();
+ }
+ else if (!stricmp(command, "scroll_right"))
+ {
+ m_iTabXScroll_Target += 100;
+ InvalidateLayout();
+ }
+ else if ( !stricmp(command, "add_tab" ) )
+ {
+ PostActionSignal( new KeyValues( "RequestAddTab" ) );
+ }
+
}
//-----------------------------------------------------------------------------
@@ -1487,7 +2186,7 @@
bool PropertySheet::IsDroppable( CUtlVector< KeyValues * >& msglist )
{
- if ( !m_bDraggableTabs )
+ //if ( !m_bDraggableTabs )
return false;
if ( msglist.Count() != 1 )
diff -Nuar vgui_controls/querybox.cpp vgui_editor/querybox.cpp
--- vgui_controls/querybox.cpp 2014-07-30 12:53:43.331889883 -0700
+++ vgui_editor/querybox.cpp 2014-07-30 13:01:35.178830793 -0700
@@ -10,16 +10,14 @@
#include <vgui/KeyCode.h>
-#include <vgui_controls/QueryBox.h>
-#include <vgui_controls/TextImage.h>
+#include <vgui_controls/querybox.h>
+#include <vgui_controls/textimage.h>
+
+#include "vgui_editor_platform.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
using namespace vgui;
//-----------------------------------------------------------------------------
diff -Nuar vgui_controls/radiobutton.cpp vgui_editor/radiobutton.cpp
--- vgui_controls/radiobutton.cpp 2014-07-30 12:53:43.331889883 -0700
+++ vgui_editor/radiobutton.cpp 2014-07-30 13:01:35.138830791 -0700
@@ -16,11 +16,11 @@
#include <vgui/KeyCode.h>
#include <KeyValues.h>
-#include <vgui_controls/FocusNavGroup.h>
-#include <vgui_controls/Image.h>
-#include <vgui_controls/RadioButton.h>
-#include <vgui_controls/TextImage.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/focusnavgroup.h>
+#include <vgui_controls/image.h>
+#include <vgui_controls/radiobutton.h>
+#include <vgui_controls/textimage.h>
+#include <vgui_controls/controls.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/richtext.cpp vgui_editor/richtext.cpp
--- vgui_controls/richtext.cpp 2014-07-30 12:53:43.335891883 -0700
+++ vgui_editor/richtext.cpp 2014-07-30 13:01:35.110830791 -0700
@@ -8,6 +8,8 @@
#include "vgui_controls/pch_vgui_controls.h"
#include "vgui/ilocalize.h"
+#include "vgui_editor_platform.h"
+
// memdbgon must be the last include file in a .cpp file
#include "tier0/memdbgon.h"
@@ -20,10 +22,6 @@
using namespace vgui;
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
namespace vgui
{
@@ -252,7 +250,7 @@
{
// Replace default format color if
// the stream is empty and the color is the default ( or the previous FgColor )
- if ( m_FormatStream.Size() == 1 &&
+ if ( m_FormatStream.Count() == 1 &&
( m_FormatStream[0].color == _defaultTextColor || m_FormatStream[0].color == GetFgColor() ) )
{
m_FormatStream[0].color = color;
@@ -337,7 +335,7 @@
{
// try lookup in localization tables
StringIndex_t index = g_pVGuiLocalize->FindIndex( pchLookup + 1 );
- if ( index == INVALID_STRING_INDEX )
+ if ( index == INVALID_LOCALIZE_STRING_INDEX )
{
/* // if it's not found, maybe it's a special expanded variable - look for an expansion
char rgchT[MAX_PATH];
@@ -362,7 +360,7 @@
}
// see if we have a valid string
- if ( index != INVALID_STRING_INDEX )
+ if ( index != INVALID_LOCALIZE_STRING_INDEX )
{
wchar_t *format = g_pVGuiLocalize->GetValueByIndex( index );
Assert( format );
@@ -2269,7 +2267,7 @@
{
BaseClass::ApplySettings(inResourceData);
SetMaximumCharCount(inResourceData->GetInt("maxchars", -1));
- SetVerticalScrollbar(inResourceData->GetInt("scrollbar", 1));
+ SetVerticalScrollbar(inResourceData->GetBool("scrollbar", true));
// get the starting text, if any
const char *text = inResourceData->GetString("text", "");
@@ -2278,8 +2276,28 @@
delete [] m_pszInitialText;
int len = Q_strlen(text) + 1;
m_pszInitialText = new char[ len ];
- Q_strncpy( m_pszInitialText, text, len );
- SetText(text);
+
+ const char *reader = text;
+ char *writer = m_pszInitialText;
+
+ for ( int i = 0; i < (len-1); i++ )
+ {
+ bool bInsertCLR = *reader == '\\' && *(reader+1) == 'n';
+ if ( bInsertCLR )
+ {
+ *writer = '\n';
+ reader++;
+ }
+ else
+ *writer = *reader;
+
+ reader++;
+ writer++;
+ }
+ *writer = '\0';
+
+ //Q_strncpy( m_pszInitialText, text, len );
+ SetText(m_pszInitialText);
}
else
{
@@ -2315,7 +2333,53 @@
outResourceData->SetInt("scrollbar", _vertScrollBar->IsVisible() );
if (m_pszInitialText)
{
- outResourceData->SetString("text", m_pszInitialText);
+ CUtlVector< char* >hSnippetsOut;
+
+ int len = Q_strlen( m_pszInitialText );
+ char *textcopy = new char[ len + 1 ];
+ Q_strcpy( textcopy, m_pszInitialText );
+
+ char *lastSnippetStart = textcopy;
+ char *readcopy = textcopy;
+ for ( int i = 0; i < len; i++ )
+ {
+ bool bGotCLR = *readcopy == '\n';
+ if ( bGotCLR|| (i == (len-1)) )
+ {
+ if ( bGotCLR )
+ *readcopy = '\0';
+ char *entry = new char[ Q_strlen( lastSnippetStart ) + 1 ];
+ Q_strcpy( entry, lastSnippetStart );
+ hSnippetsOut.AddToTail( entry );
+
+ lastSnippetStart = readcopy + 1;
+ }
+
+ readcopy++;
+ }
+
+ int completeLength = 0;
+ for ( int i = 0; i < hSnippetsOut.Count(); i++ )
+ completeLength += Q_strlen( hSnippetsOut[i] ) + 2; //(i==(hSnippetsOut.Count()-1)) ? 1 : 2;
+
+ char *targettext = new char[ completeLength ];
+ targettext[0] = '\0';
+ for ( int i = 0; i < hSnippetsOut.Count(); i++ )
+ {
+ Q_strcat( targettext, hSnippetsOut[i], completeLength );
+ if ( i < (hSnippetsOut.Count()-1) )
+ Q_strcat( targettext, "\\n", completeLength );
+ }
+
+ outResourceData->SetString("text", targettext);
+
+
+ for ( int i = 0; i < hSnippetsOut.Count(); i++ )
+ delete [] hSnippetsOut[i];
+ hSnippetsOut.Purge();
+ delete [] targettext;
+
+ //outResourceData->SetString("text", m_pszInitialText);
}
}
diff -Nuar vgui_controls/rotatingprogressbar.cpp vgui_editor/rotatingprogressbar.cpp
--- vgui_controls/rotatingprogressbar.cpp 2014-07-30 12:53:43.335891883 -0700
+++ vgui_editor/rotatingprogressbar.cpp 2014-07-30 13:01:35.214830794 -0700
@@ -9,7 +9,7 @@
#include <math.h>
#include <stdio.h>
-#include <vgui_controls/RotatingProgressBar.h>
+#include <vgui_controls/rotatingprogressbar.h>
#include <vgui/IVGui.h>
#include <vgui/ILocalize.h>
diff -Nuar vgui_controls/scalableimagepanel.cpp vgui_editor/scalableimagepanel.cpp
--- vgui_controls/scalableimagepanel.cpp 2014-07-30 12:53:43.335891883 -0700
+++ vgui_editor/scalableimagepanel.cpp 2014-07-30 13:01:35.086830790 -0700
@@ -13,7 +13,9 @@
#include <vgui/IBorder.h>
#include <KeyValues.h>
-#include <vgui_controls/ScalableImagePanel.h>
+#include <vgui_controls/scalableimagepanel.h>
+
+#include "vgui_editor_platform.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/scrollbar.cpp vgui_editor/scrollbar.cpp
--- vgui_controls/scrollbar.cpp 2014-07-30 12:53:43.335891883 -0700
+++ vgui_editor/scrollbar.cpp 2014-07-30 13:01:35.078830789 -0700
@@ -12,10 +12,10 @@
#include <vgui/IInput.h>
#include <KeyValues.h>
-#include <vgui_controls/ScrollBar.h>
-#include <vgui_controls/ScrollBarSlider.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/scrollbar.h>
+#include <vgui_controls/scrollbarslider.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/controls.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/scrollbarslider.cpp vgui_editor/scrollbarslider.cpp
--- vgui_controls/scrollbarslider.cpp 2014-07-30 12:53:43.335891883 -0700
+++ vgui_editor/scrollbarslider.cpp 2014-07-30 13:01:35.070830786 -0700
@@ -15,8 +15,8 @@
#include <vgui/MouseCode.h>
#include <KeyValues.h>
-#include <vgui_controls/ScrollBarSlider.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/scrollbarslider.h>
+#include <vgui_controls/controls.h>
#include <math.h>
diff -Nuar vgui_controls/sectionedlistpanel.cpp vgui_editor/sectionedlistpanel.cpp
--- vgui_controls/sectionedlistpanel.cpp 2014-07-30 12:53:43.339893883 -0700
+++ vgui_editor/sectionedlistpanel.cpp 2014-07-30 13:01:35.174830792 -0700
@@ -15,15 +15,15 @@
#include <KeyValues.h>
#include <vgui/MouseCode.h>
-#include <vgui_controls/SectionedListPanel.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/ScrollBar.h>
-#include <vgui_controls/TextImage.h>
-#include <vgui_controls/ImageList.h>
+#include <vgui_controls/sectionedlistpanel.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/scrollbar.h>
+#include <vgui_controls/textimage.h>
+#include <vgui_controls/imagelist.h>
-#include "UtlVector.h"
+#include "utlvector.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -731,7 +731,7 @@
int sectionStart = 0;
// layout the buttons
- for (int sectionIndex = 0; sectionIndex < m_Sections.Size(); sectionIndex++)
+ for (int sectionIndex = 0; sectionIndex < m_Sections.Count(); sectionIndex++)
{
section_t &section = m_Sections[sectionIndex];
sectionStart = m_SortedItems.Count();
@@ -832,7 +832,7 @@
int iEnd = -1;
// layout the buttons
- for (int sectionIndex = 0; sectionIndex < m_Sections.Size(); sectionIndex++)
+ for (int sectionIndex = 0; sectionIndex < m_Sections.Count(); sectionIndex++)
{
section_t &section = m_Sections[sectionIndex];
@@ -1234,7 +1234,7 @@
if (index < 0)
return NULL;
- return m_Sections[index].m_Columns.Size();
+ return m_Sections[index].m_Columns.Count();
}
//-----------------------------------------------------------------------------
@@ -1244,7 +1244,7 @@
const char *SectionedListPanel::GetColumnNameBySection(int sectionID, int columnIndex)
{
int index = FindSectionIndexByID(sectionID);
- if (index < 0 || columnIndex >= m_Sections[index].m_Columns.Size())
+ if (index < 0 || columnIndex >= m_Sections[index].m_Columns.Count())
return NULL;
return m_Sections[index].m_Columns[columnIndex].m_szColumnName;
@@ -1256,7 +1256,7 @@
const wchar_t *SectionedListPanel::GetColumnTextBySection(int sectionID, int columnIndex)
{
int index = FindSectionIndexByID(sectionID);
- if (index < 0 || columnIndex >= m_Sections[index].m_Columns.Size())
+ if (index < 0 || columnIndex >= m_Sections[index].m_Columns.Count())
return NULL;
return m_Sections[index].m_Columns[columnIndex].m_szColumnText;
@@ -1271,7 +1271,7 @@
if (index < 0)
return 0;
- if (columnIndex >= m_Sections[index].m_Columns.Size())
+ if (columnIndex >= m_Sections[index].m_Columns.Count())
return 0;
return m_Sections[index].m_Columns[columnIndex].m_iColumnFlags;
@@ -1286,7 +1286,7 @@
if (index < 0)
return 0;
- if (columnIndex >= m_Sections[index].m_Columns.Size())
+ if (columnIndex >= m_Sections[index].m_Columns.Count())
return 0;
return m_Sections[index].m_Columns[columnIndex].m_iWidth;
@@ -1297,7 +1297,7 @@
//-----------------------------------------------------------------------------
int SectionedListPanel::FindSectionIndexByID(int sectionID)
{
- for (int i = 0; i < m_Sections.Size(); i++)
+ for (int i = 0; i < m_Sections.Count(); i++)
{
if (m_Sections[i].m_iID == sectionID)
{
@@ -1834,7 +1834,7 @@
if (index < 0)
return INVALID_FONT;
- if (columnIndex >= m_Sections[index].m_Columns.Size())
+ if (columnIndex >= m_Sections[index].m_Columns.Count())
return INVALID_FONT;
return m_Sections[index].m_Columns[columnIndex].m_hFallbackFont;
diff -Nuar vgui_controls/slider.cpp vgui_editor/slider.cpp
--- vgui_controls/slider.cpp 2014-07-30 12:53:43.339893883 -0700
+++ vgui_editor/slider.cpp 2014-07-30 13:01:35.102830789 -0700
@@ -17,9 +17,9 @@
#include <vgui/ISurface.h>
#include <vgui/ILocalize.h>
-#include <vgui_controls/Slider.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/TextImage.h>
+#include <vgui_controls/slider.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/textimage.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -220,7 +220,10 @@
// Map into reduced range
fvalue = freepixels != 0.0f ? fnob / freepixels : 0.0f;
- return (int) (RemapVal( fvalue, 0.0, 1.0, userange[0], userange[1] ));
+ //return (int) (RemapVal( fvalue, 0.0, 1.0, userange[0], userange[1] ));
+
+ float val = ( fvalue * (userange[1] - userange[0]) );
+ return ceil(val - 0.5f); // Derp.
}
void Slider::SetInverted( bool bInverted )
diff -Nuar vgui_controls/splitter.cpp vgui_editor/splitter.cpp
--- vgui_controls/splitter.cpp 2014-07-30 12:53:43.339893883 -0700
+++ vgui_editor/splitter.cpp 2014-07-30 13:01:35.190830793 -0700
@@ -8,7 +8,7 @@
#include <vgui/IScheme.h>
#include <vgui/Cursor.h>
#include <vgui/iinput.h>
-#include <vgui_controls/Splitter.h>
+#include <vgui_controls/splitter.h>
#include "tier1/keyvalues.h"
#include <limits.h>
diff -Nuar vgui_controls/textentry.cpp vgui_editor/textentry.cpp
--- vgui_controls/textentry.cpp 2014-07-30 12:53:43.343895883 -0700
+++ vgui_editor/textentry.cpp 2014-07-30 13:01:35.154830792 -0700
@@ -9,7 +9,7 @@
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
-#include <UtlVector.h>
+#include <utlvector.h>
#include <vgui/Cursor.h>
#include <vgui/IInput.h>
@@ -21,11 +21,15 @@
#include <KeyValues.h>
#include <vgui/MouseCode.h>
-#include <vgui_controls/Menu.h>
-#include <vgui_controls/ScrollBar.h>
-#include <vgui_controls/TextEntry.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/MenuItem.h>
+#include <vgui_controls/menu.h>
+#include <vgui_controls/scrollbar.h>
+#include <vgui_controls/textentry.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/menuitem.h>
+#include "vgui_controls/colorpicker.h"
+
+#include "vgui_editor_platform.h"
+
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -81,6 +85,8 @@
m_nLangInset = 0;
m_bUseFallbackFont = false;
m_hFallbackFont = INVALID_FONT;
+ m_bTokenChannels = false;
+ m_pColorPicker = NULL;
//a -1 for _select[0] means that the selection is empty
_select[0] = -1;
@@ -116,6 +122,53 @@
delete m_pIMECandidates;
}
+void TextEntry::SetUseTokenChannelBehaviour( bool bEnable )
+{
+ m_bTokenChannels = bEnable;
+ UpdateColorPickerButton();
+}
+
+void TextEntry::UpdateColorPickerButton()
+{
+ const bool bHasButton = !!m_pColorPicker;
+ const bool bNeedsButton = m_bTokenChannels && GetParent();
+ if ( bHasButton != bNeedsButton )
+ {
+ if ( bNeedsButton )
+ {
+ m_pColorPicker = new Button( GetParent(), "", "Pick color", this, "colorpicker" );
+ }
+ else
+ {
+ m_pColorPicker->MarkForDeletion();
+ m_pColorPicker = NULL;
+ }
+ }
+
+ if ( !m_pColorPicker )
+ return;
+
+ m_pColorPicker->SetContentAlignment( Label::a_center );
+ m_pColorPicker->SetSize( 90, 24 );
+
+ int x,y,sx,sy;
+ GetBounds( x, y, sx, sy );
+
+ x += sx - 90;
+ y -= 24 + 6;
+ m_pColorPicker->SetPos( x, y );
+}
+
+void TextEntry::OnCommand( const char *cmd )
+{
+ if ( !Q_stricmp( cmd, "colorpicker" ) )
+ {
+ new vgui::ColorPicker( this, "cpicker", this );
+ return;
+ }
+ BaseClass::OnCommand( cmd );
+}
+
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@@ -268,6 +321,12 @@
SetText( unicode );
free( unicode );
}
+
+ if ( m_bTokenChannels )
+ {
+ RequestFocus();
+ SelectAllText( true );
+ }
}
//-----------------------------------------------------------------------------
@@ -944,6 +1003,8 @@
// force a Repaint
Repaint();
+
+ UpdateColorPickerButton();
}
// moves x,y to the Start of the next line of text
@@ -3674,11 +3735,12 @@
// _font = scheme()->GetFont(GetScheme(), "Default", IsProportional() );
// SetFont( _font );
- SetTextHidden((bool)inResourceData->GetInt("textHidden", 0));
- SetEditable((bool)inResourceData->GetInt("editable", 1));
+ SetTextHidden((bool)inResourceData->GetBool("textHidden"));
+ SetEditable((bool)inResourceData->GetBool("editable", true));
SetMaximumCharCount(inResourceData->GetInt("maxchars", -1));
- SetAllowNumericInputOnly(inResourceData->GetInt("NumericInputOnly", 0));
- SetAllowNonAsciiCharacters(inResourceData->GetInt("unicode", 0));
+ SetAllowNumericInputOnly(inResourceData->GetBool("NumericInputOnly"));
+ SetAllowNonAsciiCharacters(inResourceData->GetBool("unicode"));
+ SetUseTokenChannelBehaviour(inResourceData->GetBool("TokenChannels"));
}
//-----------------------------------------------------------------------------
@@ -3692,6 +3754,7 @@
outResourceData->SetInt("maxchars", GetMaximumCharCount());
outResourceData->SetInt("NumericInputOnly", m_bAllowNumericInputOnly);
outResourceData->SetInt("unicode", m_bAllowNonAsciiCharacters);
+ outResourceData->SetInt("TokenChannels", m_bTokenChannels);
}
//-----------------------------------------------------------------------------
@@ -3700,7 +3763,7 @@
const char *TextEntry::GetDescription()
{
static char buf[1024];
- Q_snprintf(buf, sizeof(buf), "%s, bool textHidden, bool editable, bool unicode, bool NumericInputOnly, int maxchars", BaseClass::GetDescription());
+ Q_snprintf(buf, sizeof(buf), "%s, bool textHidden, bool editable, bool unicode, bool NumericInputOnly, int maxchars, bool TokenChannels", BaseClass::GetDescription());
return buf;
}
diff -Nuar vgui_controls/textimage.cpp vgui_editor/textimage.cpp
--- vgui_controls/textimage.cpp 2014-07-30 12:53:43.343895883 -0700
+++ vgui_editor/textimage.cpp 2014-07-30 13:01:35.206830794 -0700
@@ -18,10 +18,13 @@
#include <vgui/ILocalize.h>
#include <KeyValues.h>
-#include <vgui_controls/TextImage.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/textimage.h>
+#include <vgui_controls/controls.h>
#include "tier0/dbg.h"
+
+#include "vgui_editor_platform.h"
+
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -39,7 +42,7 @@
_textBufferLen = 0;
_font = INVALID_FONT;
_fallbackFont = INVALID_FONT;
- _unlocalizedTextSymbol = INVALID_STRING_INDEX;
+ _unlocalizedTextSymbol = INVALID_LOCALIZE_STRING_INDEX;
_drawWidth = 0;
_textBufferLen = 0;
_textLen = 0;
@@ -63,7 +66,7 @@
_textBufferLen = 0;
_font = INVALID_FONT;
_fallbackFont = INVALID_FONT;
- _unlocalizedTextSymbol = INVALID_STRING_INDEX;
+ _unlocalizedTextSymbol = INVALID_LOCALIZE_STRING_INDEX;
_drawWidth = 0;
_textBufferLen = 0;
_textLen = 0;
@@ -101,7 +104,7 @@
// try lookup in localization tables
_unlocalizedTextSymbol = g_pVGuiLocalize->FindIndex(text + 1);
- if (_unlocalizedTextSymbol != INVALID_STRING_INDEX)
+ if (_unlocalizedTextSymbol != INVALID_LOCALIZE_STRING_INDEX)
{
wchar_t *unicode = g_pVGuiLocalize->GetValueByIndex(_unlocalizedTextSymbol);
SetText(unicode);
@@ -195,7 +198,7 @@
{
// Clear out unlocalized text symbol so that changing dialog variables
// doesn't stomp over the custom unicode string we're being set to.
- _unlocalizedTextSymbol = INVALID_STRING_INDEX;
+ _unlocalizedTextSymbol = INVALID_LOCALIZE_STRING_INDEX;
}
if (!unicode)
@@ -241,7 +244,7 @@
//-----------------------------------------------------------------------------
void TextImage::GetUnlocalizedText(char *buffer, int bufferSize)
{
- if (_unlocalizedTextSymbol != INVALID_STRING_INDEX)
+ if (_unlocalizedTextSymbol != INVALID_LOCALIZE_STRING_INDEX)
{
const char *text = g_pVGuiLocalize->GetNameByIndex(_unlocalizedTextSymbol);
buffer[0] = '#';
diff -Nuar vgui_controls/togglebutton.cpp vgui_editor/togglebutton.cpp
--- vgui_controls/togglebutton.cpp 2014-07-30 12:53:43.343895883 -0700
+++ vgui_editor/togglebutton.cpp 2014-07-30 13:01:35.218830794 -0700
@@ -7,7 +7,7 @@
#include <vgui/KeyCode.h>
-#include <vgui_controls/ToggleButton.h>
+#include <vgui_controls/togglebutton.h>
#include <KeyValues.h>
diff -Nuar vgui_controls/tooltip.cpp vgui_editor/tooltip.cpp
--- vgui_controls/tooltip.cpp 2014-07-30 12:53:43.343895883 -0700
+++ vgui_editor/tooltip.cpp 2014-07-30 13:01:35.214830794 -0700
@@ -16,9 +16,9 @@
#include <vgui/IVGui.h>
#include <vgui/IPanel.h>
-#include <vgui_controls/Tooltip.h>
-#include <vgui_controls/TextEntry.h>
-#include <vgui_controls/Controls.h>
+#include <vgui_controls/tooltip.h>
+#include <vgui_controls/textentry.h>
+#include <vgui_controls/controls.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@@ -95,7 +95,7 @@
text = "";
}
- if (m_Text.Size() > 0)
+ if (m_Text.Count() > 0)
{
m_Text.RemoveAll();
}
diff -Nuar vgui_controls/toolwindow.cpp vgui_editor/toolwindow.cpp
--- vgui_controls/toolwindow.cpp 2014-07-30 12:53:43.343895883 -0700
+++ vgui_editor/toolwindow.cpp 2014-07-30 13:01:35.158830793 -0700
@@ -11,8 +11,8 @@
#include "vgui/MouseCode.h"
#include "vgui/ISurface.h"
-#include <vgui_controls/ToolWindow.h>
-#include <vgui_controls/PropertySheet.h>
+#include <vgui_controls/toolwindow.h>
+#include <vgui_controls/propertysheet.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/treeview.cpp vgui_editor/treeview.cpp
--- vgui_controls/treeview.cpp 2014-07-30 12:53:43.347897883 -0700
+++ vgui_editor/treeview.cpp 2014-07-30 13:01:35.134830792 -0700
@@ -15,29 +15,27 @@
#include <vgui/IPanel.h>
#include <vgui/ISurface.h>
#include <vgui/ISystem.h>
-#include <vgui/IVgui.h>
+#include <vgui/IVGui.h>
#include <vgui/KeyCode.h>
#include <KeyValues.h>
#include <vgui/MouseCode.h>
-#include <vgui_controls/TreeView.h>
-#include <vgui_controls/ScrollBar.h>
-#include <vgui_controls/TextEntry.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/TextImage.h>
-#include <vgui_controls/ImageList.h>
-#include <vgui_controls/ImagePanel.h>
+#include <vgui_controls/treeview.h>
+#include <vgui_controls/scrollbar.h>
+#include <vgui_controls/textentry.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/textimage.h>
+#include <vgui_controls/imagelist.h>
+#include <vgui_controls/imagepanel.h>
#include "tier1/UtlString.h"
+#include "vgui_editor_platform.h"
+
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
using namespace vgui;
enum
{
@@ -669,7 +667,7 @@
// set text
m_pText->SetText(data->GetString("Text", ""));
- m_bExpandableWithoutChildren = data->GetInt("Expand");
+ m_bExpandableWithoutChildren = data->GetBool("Expand");
InvalidateLayout();
}
diff -Nuar vgui_controls/treeviewlistcontrol.cpp vgui_editor/treeviewlistcontrol.cpp
--- vgui_controls/treeviewlistcontrol.cpp 2014-07-30 12:53:43.347897883 -0700
+++ vgui_editor/treeviewlistcontrol.cpp 2014-07-30 13:01:35.102830789 -0700
@@ -19,15 +19,17 @@
#include <vgui/MouseCode.h>
#include <vgui/IBorder.h>
-#include <vgui_controls/TreeViewListControl.h>
-#include <vgui_controls/ScrollBar.h>
-#include <vgui_controls/TextEntry.h>
-#include <vgui_controls/TreeView.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/TextImage.h>
-#include <vgui_controls/ImageList.h>
-#include <vgui_controls/ImagePanel.h>
+#include <vgui_controls/treeviewlistcontrol.h>
+#include <vgui_controls/scrollbar.h>
+#include <vgui_controls/textentry.h>
+#include <vgui_controls/treeview.h>
+#include <vgui_controls/label.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/textimage.h>
+#include <vgui_controls/imagelist.h>
+#include <vgui_controls/imagepanel.h>
+
+#include "vgui_editor_platform.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/urllabel.cpp vgui_editor/urllabel.cpp
--- vgui_controls/urllabel.cpp 2014-07-30 12:53:43.347897883 -0700
+++ vgui_editor/urllabel.cpp 2014-07-30 13:01:35.110830791 -0700
@@ -13,8 +13,8 @@
#include "vgui/Cursor.h"
#include "KeyValues.h"
-#include "vgui_controls/URLLabel.h"
-#include "vgui_controls/TextImage.h"
+#include "vgui_controls/urllabel.h"
+#include "vgui_controls/textimage.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
diff -Nuar vgui_controls/wizardpanel.cpp vgui_editor/wizardpanel.cpp
--- vgui_controls/wizardpanel.cpp 2014-07-30 12:53:43.347897883 -0700
+++ vgui_editor/wizardpanel.cpp 2014-07-30 13:01:35.190830793 -0700
@@ -8,11 +8,11 @@
#include <vgui/IVGui.h>
#include <KeyValues.h>
-#include <vgui_controls/BuildGroup.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/WizardPanel.h>
-#include <vgui_controls/WizardSubPanel.h>
+#include <vgui_controls/buildgroup.h>
+#include <vgui_controls/button.h>
+#include <vgui_controls/controls.h>
+#include <vgui_controls/wizardpanel.h>
+#include <vgui_controls/wizardsubpanel.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
diff -Nuar vgui_controls/wizardsubpanel.cpp vgui_editor/wizardsubpanel.cpp
--- vgui_controls/wizardsubpanel.cpp 2014-07-30 12:53:43.347897883 -0700
+++ vgui_editor/wizardsubpanel.cpp 2014-07-30 13:01:35.074830788 -0700
@@ -5,9 +5,9 @@
// $NoKeywords: $
//=============================================================================//
-#include "vgui_controls/WizardPanel.h"
-#include "vgui_controls/WizardSubPanel.h"
-#include "vgui_controls/BuildGroup.h"
+#include "vgui_controls/wizardpanel.h"
+#include "vgui_controls/wizardsubpanel.h"
+#include "vgui_controls/buildgroup.h"
#include "KeyValues.h"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment