ui_signup.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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_signup.c
  21. //
  22. #include "ui_local.h"
  23. #define SIGNUP_FRAME "menu/art/cut_frame"
  24. #define ID_NAME 100
  25. #define ID_NAME_BOX 101
  26. #define ID_PASSWORD 102
  27. #define ID_PASSWORD_BOX 103
  28. #define ID_AGAIN 104
  29. #define ID_AGAIN_BOX 105
  30. #define ID_EMAIL 106
  31. #define ID_EMAIL_BOX 107
  32. #define ID_SIGNUP 108
  33. #define ID_CANCEL 109
  34. typedef struct
  35. {
  36. menuframework_s menu;
  37. menubitmap_s frame;
  38. menutext_s name;
  39. menufield_s name_box;
  40. menutext_s password;
  41. menufield_s password_box;
  42. menutext_s again;
  43. menufield_s again_box;
  44. menutext_s email;
  45. menufield_s email_box;
  46. menutext_s signup;
  47. menutext_s cancel;
  48. } signup_t;
  49. static signup_t s_signup;
  50. static menuframework_s s_signup_menu;
  51. static menuaction_s s_signup_signup;
  52. static menuaction_s s_signup_cancel;
  53. static vec4_t s_signup_color_prompt = {1.00, 0.43, 0.00, 1.00};
  54. /*
  55. ===============
  56. Signup_MenuEvent
  57. ===============
  58. */
  59. static void Signup_MenuEvent( void* ptr, int event ) {
  60. //char cmd[1024];
  61. if( event != QM_ACTIVATED ) {
  62. return;
  63. }
  64. switch( ((menucommon_s*)ptr)->id ) {
  65. case ID_SIGNUP:
  66. if( strcmp(s_signup.password_box.field.buffer,
  67. s_signup.again_box.field.buffer) != 0 )
  68. {
  69. // GRANK_FIXME - password mismatch
  70. break;
  71. }
  72. // set name
  73. //trap_Cvar_Set( "name", s_signup.name_box.field.buffer );
  74. /*
  75. trap_Cvar_Set( "rank_name", s_signup.name_box.field.buffer );
  76. trap_Cvar_Set( "rank_pwd", s_signup.password_box.field.buffer );
  77. */
  78. // create account
  79. /*
  80. sprintf( cmd, "cmd rank_create \"%s\" \"%s\" \"%s\"\n",
  81. s_signup.name_box.field.buffer,
  82. s_signup.password_box.field.buffer,
  83. s_signup.email_box.field.buffer );
  84. trap_Cmd_ExecuteText( EXEC_APPEND, cmd );
  85. */
  86. trap_CL_UI_RankUserCreate(
  87. s_signup.name_box.field.buffer,
  88. s_signup.password_box.field.buffer,
  89. s_signup.email_box.field.buffer );
  90. UI_ForceMenuOff();
  91. break;
  92. case ID_CANCEL:
  93. UI_PopMenu();
  94. break;
  95. }
  96. }
  97. /*
  98. ===============
  99. Signup_MenuInit
  100. ===============
  101. */
  102. void Signup_MenuInit( void ) {
  103. grank_status_t status;
  104. int y;
  105. memset( &s_signup, 0, sizeof(s_signup) );
  106. Signup_Cache();
  107. s_signup.menu.wrapAround = qtrue;
  108. s_signup.menu.fullscreen = qfalse;
  109. s_signup.frame.generic.type = MTYPE_BITMAP;
  110. s_signup.frame.generic.flags = QMF_INACTIVE;
  111. s_signup.frame.generic.name = SIGNUP_FRAME;
  112. s_signup.frame.generic.x = 142; //320-233;
  113. s_signup.frame.generic.y = 118; //240-166;
  114. s_signup.frame.width = 359; //466;
  115. s_signup.frame.height = 256; //332;
  116. y = 194;
  117. s_signup.name.generic.type = MTYPE_PTEXT;
  118. s_signup.name.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
  119. s_signup.name.generic.id = ID_NAME;
  120. s_signup.name.generic.x = 310;
  121. s_signup.name.generic.y = y;
  122. s_signup.name.string = "NAME";
  123. s_signup.name.style = UI_RIGHT|UI_SMALLFONT;
  124. s_signup.name.color = s_signup_color_prompt;
  125. s_signup.name_box.generic.type = MTYPE_FIELD;
  126. s_signup.name_box.generic.ownerdraw = Rankings_DrawName;
  127. s_signup.name_box.generic.name = "";
  128. s_signup.name_box.generic.flags = 0;
  129. s_signup.name_box.generic.x = 330;
  130. s_signup.name_box.generic.y = y;
  131. s_signup.name_box.field.widthInChars = 16;
  132. s_signup.name_box.field.maxchars = 16;
  133. y += 20;
  134. s_signup.password.generic.type = MTYPE_PTEXT;
  135. s_signup.password.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
  136. s_signup.password.generic.id = ID_PASSWORD;
  137. s_signup.password.generic.x = 310;
  138. s_signup.password.generic.y = y;
  139. s_signup.password.string = "PASSWORD";
  140. s_signup.password.style = UI_RIGHT|UI_SMALLFONT;
  141. s_signup.password.color = s_signup_color_prompt;
  142. s_signup.password_box.generic.type = MTYPE_FIELD;
  143. s_signup.password_box.generic.ownerdraw = Rankings_DrawPassword;
  144. s_signup.password_box.generic.name = "";
  145. s_signup.password_box.generic.flags = 0;
  146. s_signup.password_box.generic.x = 330;
  147. s_signup.password_box.generic.y = y;
  148. s_signup.password_box.field.widthInChars = 16;
  149. s_signup.password_box.field.maxchars = 16;
  150. y += 20;
  151. s_signup.again.generic.type = MTYPE_PTEXT;
  152. s_signup.again.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
  153. s_signup.again.generic.id = ID_AGAIN;
  154. s_signup.again.generic.x = 310;
  155. s_signup.again.generic.y = y;
  156. s_signup.again.string = "(AGAIN)";
  157. s_signup.again.style = UI_RIGHT|UI_SMALLFONT;
  158. s_signup.again.color = s_signup_color_prompt;
  159. s_signup.again_box.generic.type = MTYPE_FIELD;
  160. s_signup.again_box.generic.ownerdraw = Rankings_DrawPassword;
  161. s_signup.again_box.generic.name = "";
  162. s_signup.again_box.generic.flags = 0;
  163. s_signup.again_box.generic.x = 330;
  164. s_signup.again_box.generic.y = y;
  165. s_signup.again_box.field.widthInChars = 16;
  166. s_signup.again_box.field.maxchars = 16;
  167. y += 20;
  168. s_signup.email.generic.type = MTYPE_PTEXT;
  169. s_signup.email.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
  170. s_signup.email.generic.id = ID_EMAIL;
  171. s_signup.email.generic.x = 310;
  172. s_signup.email.generic.y = y;
  173. s_signup.email.string = "EMAIL";
  174. s_signup.email.style = UI_RIGHT|UI_SMALLFONT;
  175. s_signup.email.color = s_signup_color_prompt;
  176. s_signup.email_box.generic.type = MTYPE_FIELD;
  177. s_signup.email_box.generic.ownerdraw = Rankings_DrawText;
  178. s_signup.email_box.generic.name = "";
  179. s_signup.email_box.generic.flags = 0;
  180. s_signup.email_box.generic.x = 330;
  181. s_signup.email_box.generic.y = y;
  182. s_signup.email_box.field.widthInChars = 16;
  183. s_signup.email_box.field.maxchars = MAX_EDIT_LINE;
  184. y += 40;
  185. s_signup.signup.generic.type = MTYPE_PTEXT;
  186. s_signup.signup.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
  187. s_signup.signup.generic.id = ID_SIGNUP;
  188. s_signup.signup.generic.callback = Signup_MenuEvent;
  189. s_signup.signup.generic.x = 310;
  190. s_signup.signup.generic.y = y;
  191. s_signup.signup.string = "SIGN UP";
  192. s_signup.signup.style = UI_RIGHT|UI_SMALLFONT;
  193. s_signup.signup.color = colorRed;
  194. s_signup.cancel.generic.type = MTYPE_PTEXT;
  195. s_signup.cancel.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
  196. s_signup.cancel.generic.id = ID_CANCEL;
  197. s_signup.cancel.generic.callback = Signup_MenuEvent;
  198. s_signup.cancel.generic.x = 330;
  199. s_signup.cancel.generic.y = y;
  200. s_signup.cancel.string = "CANCEL";
  201. s_signup.cancel.style = UI_LEFT|UI_SMALLFONT;
  202. s_signup.cancel.color = colorRed;
  203. y += 20;
  204. status = (grank_status_t)trap_Cvar_VariableValue("client_status");
  205. if( (status != QGR_STATUS_NEW) && (status != QGR_STATUS_SPECTATOR) )
  206. {
  207. s_signup.name_box.generic.flags |= QMF_INACTIVE;
  208. s_signup.password_box.generic.flags |= QMF_INACTIVE;
  209. s_signup.again_box.generic.flags |= QMF_INACTIVE;
  210. s_signup.email_box.generic.flags |= QMF_INACTIVE;
  211. s_signup.signup.generic.flags |= QMF_INACTIVE;
  212. s_signup.signup.color = colorMdGrey;
  213. }
  214. Menu_AddItem( &s_signup.menu, (void*) &s_signup.frame );
  215. Menu_AddItem( &s_signup.menu, (void*) &s_signup.name );
  216. Menu_AddItem( &s_signup.menu, (void*) &s_signup.name_box );
  217. Menu_AddItem( &s_signup.menu, (void*) &s_signup.password );
  218. Menu_AddItem( &s_signup.menu, (void*) &s_signup.password_box );
  219. Menu_AddItem( &s_signup.menu, (void*) &s_signup.again );
  220. Menu_AddItem( &s_signup.menu, (void*) &s_signup.again_box );
  221. Menu_AddItem( &s_signup.menu, (void*) &s_signup.email );
  222. Menu_AddItem( &s_signup.menu, (void*) &s_signup.email_box );
  223. Menu_AddItem( &s_signup.menu, (void*) &s_signup.signup );
  224. Menu_AddItem( &s_signup.menu, (void*) &s_signup.cancel );
  225. }
  226. /*
  227. ===============
  228. Signup_Cache
  229. ===============
  230. */
  231. void Signup_Cache( void ) {
  232. trap_R_RegisterShaderNoMip( SIGNUP_FRAME );
  233. }
  234. /*
  235. ===============
  236. UI_SignupMenu
  237. ===============
  238. */
  239. void UI_SignupMenu( void ) {
  240. Signup_MenuInit();
  241. UI_PushMenu ( &s_signup.menu );
  242. }