ui_connect.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // leave this at the top of all UI_xxxx files for PCH reasons...
  2. //
  3. #include "../server/exe_headers.h"
  4. #include "ui_local.h"
  5. /*
  6. ===============================================================================
  7. CONNECTION SCREEN
  8. ===============================================================================
  9. */
  10. char connectionDialogString[1024];
  11. char connectionMessageString[1024];
  12. /*
  13. ========================
  14. UI_DrawConnect
  15. ========================
  16. */
  17. void UI_DrawConnect( const char *servername, const char *updateInfoString )
  18. {
  19. // We need to use this special hack variable, nothing else is set up yet:
  20. const char *s = Cvar_VariableString( "ui_mapname" );
  21. // Special case for first map:
  22. extern SavedGameJustLoaded_e g_eSavedGameJustLoaded;
  23. if ( g_eSavedGameJustLoaded != eFULL && (!strcmp(s,"yavin1") || !strcmp(s,"demo")) )
  24. {
  25. ui.R_SetColor( colorTable[CT_BLACK] );
  26. uis.whiteShader = ui.R_RegisterShaderNoMip( "*white" );
  27. ui.R_DrawStretchPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, uis.whiteShader );
  28. const char *t = SE_GetString( "SP_INGAME_ALONGTIME" );
  29. int w = ui.R_Font_StrLenPixels( t, uiInfo.uiDC.Assets.qhMediumFont, 1.0f );
  30. ui.R_Font_DrawString( (320)-(w/2), 140, t, colorTable[CT_ICON_BLUE], uiInfo.uiDC.Assets.qhMediumFont, -1, 1.0f );
  31. return;
  32. }
  33. // Grab the loading menu:
  34. extern menuDef_t *Menus_FindByName( const char *p );
  35. menuDef_t *menu = Menus_FindByName( "loadingMenu" );
  36. if( !menu )
  37. return;
  38. // Find the levelshot item, so we can fix up it's shader:
  39. itemDef_t *item = Menu_FindItemByName( menu, "mappic" );
  40. if( !item )
  41. return;
  42. item->window.background = ui.R_RegisterShaderNoMip( va( "levelshots/%s", s ) );
  43. if (!item->window.background) {
  44. item->window.background = ui.R_RegisterShaderNoMip( "menu/art/unknownmap" );
  45. }
  46. // Do the second levelshot as well:
  47. qhandle_t firstShot = item->window.background;
  48. item = Menu_FindItemByName( menu, "mappic2" );
  49. if( !item )
  50. return;
  51. item->window.background = ui.R_RegisterShaderNoMip( va( "levelshots/%s2", s ) );
  52. if (!item->window.background) {
  53. item->window.background = firstShot;
  54. }
  55. const char *b = SE_GetString( "BRIEFINGS", s );
  56. if( b && b[0] )
  57. Cvar_Set( "ui_missionbriefing", va("@BRIEFINGS_%s", s) );
  58. else
  59. Cvar_Set( "ui_missionbriefing", "@BRIEFINGS_NONE" );
  60. // Now, force it to draw:
  61. extern void Menu_Paint( menuDef_t *menu, qboolean forcePaint );
  62. Menu_Paint( menu, qtrue );
  63. }
  64. /*
  65. ========================
  66. UI_UpdateConnectionString
  67. ========================
  68. */
  69. void UI_UpdateConnectionString( char *string ) {
  70. Q_strncpyz( connectionDialogString, string, sizeof( connectionDialogString ) );
  71. UI_UpdateScreen();
  72. }
  73. /*
  74. ========================
  75. UI_UpdateConnectionMessageString
  76. ========================
  77. */
  78. void UI_UpdateConnectionMessageString( char *string ) {
  79. char *s;
  80. Q_strncpyz( connectionMessageString, string, sizeof( connectionMessageString ) );
  81. // strip \n
  82. s = strstr( connectionMessageString, "\n" );
  83. if ( s ) {
  84. *s = 0;
  85. }
  86. UI_UpdateScreen();
  87. }
  88. /*
  89. ===================
  90. UI_KeyConnect
  91. ===================
  92. */
  93. void UI_KeyConnect( int key )
  94. {
  95. if ( key == A_ESCAPE )
  96. {
  97. ui.Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
  98. return;
  99. }
  100. }