ui_rankstatus.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. //
  19. //
  20. // ui_rankstatus.c
  21. //
  22. #include "ui_local.h"
  23. #define RANKSTATUS_FRAME "menu/art/cut_frame"
  24. #define ID_MESSAGE 100
  25. #define ID_OK 101
  26. typedef struct
  27. {
  28. menuframework_s menu;
  29. menubitmap_s frame;
  30. menutext_s message;
  31. menutext_s ok;
  32. } rankstatus_t;
  33. static rankstatus_t s_rankstatus;
  34. static menuframework_s s_rankstatus_menu;
  35. static menuaction_s s_rankstatus_ok;
  36. static grank_status_t s_status = 0;
  37. static char* s_rankstatus_message = NULL;
  38. static vec4_t s_rankingstatus_color_prompt = {1.00, 0.43, 0.00, 1.00};
  39. /*
  40. ===============
  41. RankStatus_MenuEvent
  42. ===============
  43. */
  44. static void RankStatus_MenuEvent( void* ptr, int event ) {
  45. if( event != QM_ACTIVATED ) {
  46. return;
  47. }
  48. switch( ((menucommon_s*)ptr)->id ) {
  49. case ID_OK:
  50. UI_PopMenu();
  51. switch( s_status )
  52. {
  53. case QGR_STATUS_NO_USER:
  54. UI_RankingsMenu();
  55. break;
  56. case QGR_STATUS_BAD_PASSWORD:
  57. UI_RankingsMenu();
  58. UI_LoginMenu();
  59. break;
  60. case QGR_STATUS_USER_EXISTS:
  61. UI_RankingsMenu();
  62. UI_SignupMenu();
  63. break;
  64. case QGR_STATUS_NO_MEMBERSHIP:
  65. UI_RankingsMenu();
  66. break;
  67. case QGR_STATUS_TIMEOUT:
  68. UI_RankingsMenu();
  69. break;
  70. case QGR_STATUS_INVALIDUSER:
  71. UI_RankingsMenu();
  72. break;
  73. case QGR_STATUS_ERROR:
  74. UI_RankingsMenu();
  75. break;
  76. default:
  77. break;
  78. }
  79. break;
  80. }
  81. }
  82. /*
  83. ===============
  84. RankStatus_MenuInit
  85. ===============
  86. */
  87. void RankStatus_MenuInit( void ) {
  88. int y;
  89. memset( &s_rankstatus, 0, sizeof(s_rankstatus) );
  90. RankStatus_Cache();
  91. s_rankstatus.menu.wrapAround = qtrue;
  92. s_rankstatus.menu.fullscreen = qfalse;
  93. s_rankstatus.frame.generic.type = MTYPE_BITMAP;
  94. s_rankstatus.frame.generic.flags = QMF_INACTIVE;
  95. s_rankstatus.frame.generic.name = RANKSTATUS_FRAME;
  96. s_rankstatus.frame.generic.x = 142; //320-233;
  97. s_rankstatus.frame.generic.y = 118; //240-166;
  98. s_rankstatus.frame.width = 359; //466;
  99. s_rankstatus.frame.height = 256; //332;
  100. y = 214;
  101. s_rankstatus.message.generic.type = MTYPE_PTEXT;
  102. s_rankstatus.message.generic.flags = QMF_CENTER_JUSTIFY|QMF_INACTIVE;
  103. s_rankstatus.message.generic.id = ID_MESSAGE;
  104. s_rankstatus.message.generic.x = 320;
  105. s_rankstatus.message.generic.y = y;
  106. s_rankstatus.message.string = s_rankstatus_message;
  107. s_rankstatus.message.style = UI_CENTER|UI_SMALLFONT;
  108. s_rankstatus.message.color = s_rankingstatus_color_prompt;
  109. y += 40;
  110. s_rankstatus.ok.generic.type = MTYPE_PTEXT;
  111. s_rankstatus.ok.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  112. s_rankstatus.ok.generic.id = ID_OK;
  113. s_rankstatus.ok.generic.callback = RankStatus_MenuEvent;
  114. s_rankstatus.ok.generic.x = 320;
  115. s_rankstatus.ok.generic.y = y;
  116. s_rankstatus.ok.string = "OK";
  117. s_rankstatus.ok.style = UI_CENTER|UI_SMALLFONT;
  118. s_rankstatus.ok.color = colorRed;
  119. Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.frame );
  120. Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.message );
  121. Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.ok );
  122. }
  123. /*
  124. ===============
  125. RankStatus_Cache
  126. ===============
  127. */
  128. void RankStatus_Cache( void ) {
  129. trap_R_RegisterShaderNoMip( RANKSTATUS_FRAME );
  130. }
  131. /*
  132. ===============
  133. UI_RankStatusMenu
  134. ===============
  135. */
  136. void UI_RankStatusMenu( void ) {
  137. s_status = (grank_status_t)trap_Cvar_VariableValue("client_status");
  138. switch( s_status )
  139. {
  140. case QGR_STATUS_NEW:
  141. return;
  142. case QGR_STATUS_PENDING:
  143. // GRANK_FIXME
  144. return;
  145. case QGR_STATUS_NO_USER:
  146. // GRANK_FIXME - get this when user exists
  147. s_rankstatus_message = "Username unavailable";
  148. break;
  149. case QGR_STATUS_BAD_PASSWORD:
  150. s_rankstatus_message = "Invalid password";
  151. break;
  152. case QGR_STATUS_TIMEOUT:
  153. s_rankstatus_message = "Timed out";
  154. break;
  155. case QGR_STATUS_NO_MEMBERSHIP:
  156. s_rankstatus_message = "No membership";
  157. break;
  158. case QGR_STATUS_INVALIDUSER:
  159. s_rankstatus_message = "Validation failed";
  160. break;
  161. case QGR_STATUS_ERROR:
  162. s_rankstatus_message = "Error";
  163. break;
  164. case QGR_STATUS_SPECTATOR:
  165. case QGR_STATUS_ACTIVE:
  166. UI_ForceMenuOff();
  167. return;
  168. default:
  169. return;
  170. }
  171. RankStatus_MenuInit();
  172. trap_CL_UI_RankUserReset();
  173. UI_PushMenu ( &s_rankstatus.menu );
  174. }