diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/game/client/game_controls/mouseoverhtmlbutton.h | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/game/client/game_controls/mouseoverhtmlbutton.h')
| -rw-r--r-- | mp/src/game/client/game_controls/mouseoverhtmlbutton.h | 238 |
1 files changed, 119 insertions, 119 deletions
diff --git a/mp/src/game/client/game_controls/mouseoverhtmlbutton.h b/mp/src/game/client/game_controls/mouseoverhtmlbutton.h index b4143029..e3800832 100644 --- a/mp/src/game/client/game_controls/mouseoverhtmlbutton.h +++ b/mp/src/game/client/game_controls/mouseoverhtmlbutton.h @@ -1,119 +1,119 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef MOUSEOVERHTMLBUTTON_H
-#define MOUSEOVERHTMLBUTTON_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Triggers a new html page when the mouse goes over the button
-//-----------------------------------------------------------------------------
-class MouseOverHTMLButton : public vgui::Button
-{
-public:
- MouseOverHTMLButton(vgui::Panel *parent, const char *panelName, vgui::HTML *html, const char *page) :
- Button( parent, panelName, "MouseOverHTMLButton")
- {
- m_pHTML = html;
- m_iClass = 0;
- m_iIndex = -1;
- m_bAddShortCut = true;
- if ( page )
- {
- Q_strncpy( m_sPage, page, sizeof( m_sPage ) );
- }
- else
- {
- memset(m_sPage, 0x0, sizeof( m_sPage ) );
- }
- }
-
- void SetClass(int pClass, int index) { m_iClass = pClass; m_iIndex = index;}
- int GetClass() { return m_iClass; }
-
- void SetAddHotKey( bool state ) { m_bAddShortCut = state; }
-
- void SetPage( const char *page )
- {
- if ( page )
- {
- Q_strncpy( m_sPage, page, sizeof( m_sPage ) );
- }
- else
- {
- memset(m_sPage, 0x0, sizeof( m_sPage ) );
- }
- }
-
- void SetHTML( vgui::HTML *html)
- {
- m_pHTML = html;
- }
-
-
-private:
-
- virtual void OnCursorEntered()
- {
- Button::OnCursorEntered();
- if ( m_pHTML && strlen(m_sPage) > 0 )
- {
- m_pHTML->OpenURL(m_sPage);
- }
- }
-
- virtual void SetText(const char *text)
- {
- if ( m_iIndex != -1 )
- {
- wchar_t newText[ 128 ];
- wchar_t localizeText[ 128 ];
- wchar_t *ansiLocal;
- if ( text[0] == '#' && ( ansiLocal = g_pVGuiLocalize->Find( text ) ) )
- {
- // wcsncpy will crash if ansiLocal is null... *sigh*
- wcsncpy(localizeText, ansiLocal, sizeof(localizeText)/sizeof(wchar_t));
- }
- else
- {
- g_pVGuiLocalize->ConvertANSIToUnicode( text, localizeText, sizeof( localizeText ) );
- }
-
- if ( m_bAddShortCut )
- {
-#ifdef WIN32
- _snwprintf( newText, sizeof( newText )/ sizeof( wchar_t ), L"&%i %s", m_iIndex, localizeText);
-#else
- _snwprintf( newText, sizeof( newText )/ sizeof( wchar_t ), L"&%i %S", m_iIndex, localizeText);
-#endif
-
- }
- else
- {
- memcpy( newText, localizeText, sizeof( newText ) );
- }
-
- Button::SetText( newText );
- }
- else
- {
- Button::SetText( text );
- }
- }
-
- vgui::HTML *m_pHTML;
- char m_sPage[ 255 ];
- int m_iClass;
- int m_iIndex;
- bool m_bAddShortCut;
-};
-
-
-#endif // MOUSEOVERHTMLBUTTON_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef MOUSEOVERHTMLBUTTON_H +#define MOUSEOVERHTMLBUTTON_H +#ifdef _WIN32 +#pragma once +#endif + + +//----------------------------------------------------------------------------- +// Purpose: Triggers a new html page when the mouse goes over the button +//----------------------------------------------------------------------------- +class MouseOverHTMLButton : public vgui::Button +{ +public: + MouseOverHTMLButton(vgui::Panel *parent, const char *panelName, vgui::HTML *html, const char *page) : + Button( parent, panelName, "MouseOverHTMLButton") + { + m_pHTML = html; + m_iClass = 0; + m_iIndex = -1; + m_bAddShortCut = true; + if ( page ) + { + Q_strncpy( m_sPage, page, sizeof( m_sPage ) ); + } + else + { + memset(m_sPage, 0x0, sizeof( m_sPage ) ); + } + } + + void SetClass(int pClass, int index) { m_iClass = pClass; m_iIndex = index;} + int GetClass() { return m_iClass; } + + void SetAddHotKey( bool state ) { m_bAddShortCut = state; } + + void SetPage( const char *page ) + { + if ( page ) + { + Q_strncpy( m_sPage, page, sizeof( m_sPage ) ); + } + else + { + memset(m_sPage, 0x0, sizeof( m_sPage ) ); + } + } + + void SetHTML( vgui::HTML *html) + { + m_pHTML = html; + } + + +private: + + virtual void OnCursorEntered() + { + Button::OnCursorEntered(); + if ( m_pHTML && strlen(m_sPage) > 0 ) + { + m_pHTML->OpenURL(m_sPage); + } + } + + virtual void SetText(const char *text) + { + if ( m_iIndex != -1 ) + { + wchar_t newText[ 128 ]; + wchar_t localizeText[ 128 ]; + wchar_t *ansiLocal; + if ( text[0] == '#' && ( ansiLocal = g_pVGuiLocalize->Find( text ) ) ) + { + // wcsncpy will crash if ansiLocal is null... *sigh* + wcsncpy(localizeText, ansiLocal, sizeof(localizeText)/sizeof(wchar_t)); + } + else + { + g_pVGuiLocalize->ConvertANSIToUnicode( text, localizeText, sizeof( localizeText ) ); + } + + if ( m_bAddShortCut ) + { +#ifdef WIN32 + _snwprintf( newText, sizeof( newText )/ sizeof( wchar_t ), L"&%i %s", m_iIndex, localizeText); +#else + _snwprintf( newText, sizeof( newText )/ sizeof( wchar_t ), L"&%i %S", m_iIndex, localizeText); +#endif + + } + else + { + memcpy( newText, localizeText, sizeof( newText ) ); + } + + Button::SetText( newText ); + } + else + { + Button::SetText( text ); + } + } + + vgui::HTML *m_pHTML; + char m_sPage[ 255 ]; + int m_iClass; + int m_iIndex; + bool m_bAddShortCut; +}; + + +#endif // MOUSEOVERHTMLBUTTON_H |