|
27 | 27 | #include "materialsystem/materialsystem_config.h" |
28 | 28 | #include "materialsystem/imaterialsystem.h" |
29 | 29 | #include "sourcevr/isourcevirtualreality.h" |
| 30 | +#include "VGuiMatSurface/IMatSystemSurface.h" |
30 | 31 |
|
31 | 32 | using namespace vgui; |
32 | 33 |
|
@@ -86,6 +87,10 @@ using namespace vgui; |
86 | 87 | #include "tier1/utlstring.h" |
87 | 88 | #include "steam/steam_api.h" |
88 | 89 |
|
| 90 | +#ifdef USE_SDL |
| 91 | +#include <SDL_misc.h> |
| 92 | +#endif |
| 93 | + |
89 | 94 | #undef MessageBox // Windows helpfully #define's this to MessageBoxA, we're using vgui::MessageBox |
90 | 95 |
|
91 | 96 | // memdbgon must be the last include file in a .cpp file!!! |
@@ -197,6 +202,98 @@ void CGameMenuItem::SetRightAlignedText(bool state) |
197 | 202 | m_bRightAligned = state; |
198 | 203 | } |
199 | 204 |
|
| 205 | +class ImageButton : public vgui::Panel |
| 206 | +{ |
| 207 | +public: |
| 208 | + ImageButton(Panel *parent, const char *imageName) : Panel(parent) |
| 209 | + { |
| 210 | + m_szUrl = NULL; |
| 211 | + |
| 212 | + m_textureID = vgui::surface()->CreateNewTextureID(); |
| 213 | + vgui::surface()->DrawSetTextureFile( m_textureID, imageName, true, false); |
| 214 | + m_bSelected = false; |
| 215 | + } |
| 216 | + |
| 217 | + virtual void Paint() |
| 218 | + { |
| 219 | + if( GameUI().IsInLevel() ) return; |
| 220 | + |
| 221 | + int color = m_bSelected ? 120 : 160; |
| 222 | + |
| 223 | + vgui::surface()->DrawSetColor(color, color, color, 100); |
| 224 | + vgui::surface()->DrawFilledRect( 0, 0, GetWide(), GetTall() ); |
| 225 | + vgui::surface()->DrawSetTexture( m_textureID ); |
| 226 | + |
| 227 | + vgui::surface()->DrawSetColor( 255, 255, 255, 255 ); |
| 228 | + vgui::surface()->DrawTexturedRect( 0, 0, GetWide(), GetTall() ); |
| 229 | + } |
| 230 | + |
| 231 | + virtual void OnMousePressed(MouseCode code) |
| 232 | + { |
| 233 | + if( GameUI().IsInLevel() ) return; |
| 234 | + |
| 235 | + m_bSelected = true; |
| 236 | + input()->SetMouseCapture(GetVPanel()); |
| 237 | + } |
| 238 | + |
| 239 | + virtual void OnMouseReleased(MouseCode code) |
| 240 | + { |
| 241 | + if( GameUI().IsInLevel() ) return; |
| 242 | + |
| 243 | + m_bSelected = false; |
| 244 | +#ifdef USE_SDL |
| 245 | + if( m_szUrl ) SDL_OpenURL( m_szUrl ); |
| 246 | +#endif |
| 247 | + |
| 248 | + input()->SetMouseCapture(NULL); |
| 249 | + } |
| 250 | + |
| 251 | + void SetUrl( const char *url ) |
| 252 | + { |
| 253 | + m_szUrl = url; |
| 254 | + } |
| 255 | + |
| 256 | + virtual void OnScreenSizeChanged( int nOldWidth, int nOldHeight ) |
| 257 | + { |
| 258 | + int nw, nh; |
| 259 | + surface()->GetScreenSize(nw, nh); |
| 260 | + int scaled_w = scheme()->GetProportionalScaledValue(m_iOldW); |
| 261 | + |
| 262 | + Panel::SetPos(nw-scheme()->GetProportionalScaledValue(m_iOldX)-scaled_w, m_iOldY); |
| 263 | + Panel::SetSize(scaled_w, scheme()->GetProportionalScaledValue(m_iOldH)); |
| 264 | + } |
| 265 | + |
| 266 | + void SetBounds( int x, int y, int w, int h ) |
| 267 | + { |
| 268 | + m_iOldX = x; m_iOldY = y; |
| 269 | + m_iOldW = w; m_iOldH = h; |
| 270 | + |
| 271 | + int nw, nh; |
| 272 | + surface()->GetScreenSize(nw, nh); |
| 273 | + int scaled_w = scheme()->GetProportionalScaledValue(m_iOldW); |
| 274 | + |
| 275 | + Panel::SetPos(nw-scheme()->GetProportionalScaledValue(m_iOldX)-scaled_w, m_iOldY); |
| 276 | + Panel::SetSize(scaled_w, scheme()->GetProportionalScaledValue(m_iOldH)); |
| 277 | + } |
| 278 | + |
| 279 | +private: |
| 280 | + int m_iOldX, m_iOldY; |
| 281 | + int m_iOldW, m_iOldH; |
| 282 | + |
| 283 | + bool m_bSelected; |
| 284 | + int m_textureID; |
| 285 | + const char *m_szUrl; |
| 286 | +}; |
| 287 | + |
| 288 | +void AddUrlButton(vgui::Panel *parent, const char *imgName, const char *url ) |
| 289 | +{ |
| 290 | + static int i = 0; |
| 291 | + ImageButton *panel = new ImageButton( parent, imgName ); |
| 292 | + panel->SetUrl( url ); |
| 293 | + panel->SetBounds( 15+i*52, 10, 48, 48 ); |
| 294 | + i++; |
| 295 | +} |
| 296 | + |
200 | 297 | //----------------------------------------------------------------------------- |
201 | 298 | // Purpose: General purpose 1 of N menu |
202 | 299 | //----------------------------------------------------------------------------- |
@@ -816,7 +913,14 @@ CBasePanel::CBasePanel() : Panel(NULL, "BaseGameUIPanel") |
816 | 913 | m_iGameID = CONTEXT_GAME_GAME_TEAM_FORTRESS; |
817 | 914 | m_bSinglePlayer = false; |
818 | 915 | } |
| 916 | + } |
819 | 917 |
|
| 918 | + if( IsAndroid() ) |
| 919 | + { |
| 920 | + AddUrlButton( this, "vgui/\x64\x69\x73\x63\x6f\x72\x64\x5f\x6c\x6f\x67\x6f", "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x64\x69\x73\x63\x6f\x72\x64\x2e\x67\x67\x2f\x68\x5a\x52\x42\x37\x57\x4d\x67\x47\x77" ); |
| 921 | + AddUrlButton( this, "vgui/\x74\x77\x69\x74\x74\x65\x72\x5f\x6c\x6f\x67\x6f", "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x74\x77\x69\x74\x74\x65\x72\x2e\x63\x6f\x6d\x2f\x6e\x69\x6c\x6c\x65\x72\x75\x73\x72" ); |
| 922 | + AddUrlButton( this, "vgui/\x74\x65\x6c\x65\x67\x72\x61\x6d\x5f\x6c\x6f\x67\x6f", "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x74\x2e\x6d\x65\x2f\x6e\x69\x6c\x6c\x65\x72\x75\x73\x72\x5f\x73\x6f\x75\x72\x63\x65" ); |
| 923 | + AddUrlButton( this, "vgui/\x67\x69\x74\x68\x75\x62\x5f\x6c\x6f\x67\x6f", "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x67\x69\x74\x68\x75\x62\x2e\x63\x6f\x6d\x2f\x6e\x69\x6c\x6c\x65\x72\x75\x73\x72\x2f\x73\x6f\x75\x72\x63\x65\x2d\x65\x6e\x67\x69\x6e\x65" ); |
820 | 924 | } |
821 | 925 | } |
822 | 926 |
|
|
0 commit comments