MenuWidget.h 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __MENU_WIDGET_H__
  21. #define __MENU_WIDGET_H__
  22. class idMenuHandler;
  23. class idMenuWidget;
  24. enum menuOption_t {
  25. OPTION_INVALID = -1,
  26. OPTION_BUTTON_TEXT,
  27. OPTION_SLIDER_BAR,
  28. OPTION_SLIDER_TEXT,
  29. OPTION_SLIDER_TOGGLE,
  30. OPTION_BUTTON_INFO,
  31. OPTION_BUTTON_FULL_TEXT_SLIDER,
  32. MAX_MENU_OPTION_TYPES
  33. };
  34. enum widgetEvent_t {
  35. WIDGET_EVENT_PRESS,
  36. WIDGET_EVENT_RELEASE,
  37. WIDGET_EVENT_ROLL_OVER,
  38. WIDGET_EVENT_ROLL_OUT,
  39. WIDGET_EVENT_FOCUS_ON,
  40. WIDGET_EVENT_FOCUS_OFF,
  41. WIDGET_EVENT_SCROLL_UP_LSTICK,
  42. WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE,
  43. WIDGET_EVENT_SCROLL_DOWN_LSTICK,
  44. WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE,
  45. WIDGET_EVENT_SCROLL_LEFT_LSTICK,
  46. WIDGET_EVENT_SCROLL_LEFT_LSTICK_RELEASE,
  47. WIDGET_EVENT_SCROLL_RIGHT_LSTICK,
  48. WIDGET_EVENT_SCROLL_RIGHT_LSTICK_RELEASE,
  49. WIDGET_EVENT_SCROLL_UP_RSTICK,
  50. WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE,
  51. WIDGET_EVENT_SCROLL_DOWN_RSTICK,
  52. WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE,
  53. WIDGET_EVENT_SCROLL_LEFT_RSTICK,
  54. WIDGET_EVENT_SCROLL_LEFT_RSTICK_RELEASE,
  55. WIDGET_EVENT_SCROLL_RIGHT_RSTICK,
  56. WIDGET_EVENT_SCROLL_RIGHT_RSTICK_RELEASE,
  57. WIDGET_EVENT_SCROLL_UP,
  58. WIDGET_EVENT_SCROLL_UP_RELEASE,
  59. WIDGET_EVENT_SCROLL_DOWN,
  60. WIDGET_EVENT_SCROLL_DOWN_RELEASE,
  61. WIDGET_EVENT_SCROLL_LEFT,
  62. WIDGET_EVENT_SCROLL_LEFT_RELEASE,
  63. WIDGET_EVENT_SCROLL_RIGHT,
  64. WIDGET_EVENT_SCROLL_RIGHT_RELEASE,
  65. WIDGET_EVENT_DRAG_START,
  66. WIDGET_EVENT_DRAG_STOP,
  67. WIDGET_EVENT_SCROLL_PAGEDWN,
  68. WIDGET_EVENT_SCROLL_PAGEDWN_RELEASE,
  69. WIDGET_EVENT_SCROLL_PAGEUP,
  70. WIDGET_EVENT_SCROLL_PAGEUP_RELEASE,
  71. WIDGET_EVENT_SCROLL,
  72. WIDGET_EVENT_SCROLL_RELEASE,
  73. WIDGET_EVENT_BACK,
  74. WIDGET_EVENT_COMMAND,
  75. WIDGET_EVENT_TAB_NEXT,
  76. WIDGET_EVENT_TAB_PREV,
  77. MAX_WIDGET_EVENT
  78. };
  79. enum scrollType_t {
  80. SCROLL_SINGLE, // scroll a single unit
  81. SCROLL_PAGE, // scroll a page
  82. SCROLL_FULL, // scroll all the way to the end
  83. SCROLL_TOP, // scroll to the first selection
  84. SCROLL_END, // scroll to the last selection
  85. };
  86. enum widgetAction_t {
  87. WIDGET_ACTION_NONE,
  88. WIDGET_ACTION_COMMAND,
  89. WIDGET_ACTION_FUNCTION, // call the SWF function
  90. WIDGET_ACTION_SCROLL_VERTICAL, // scroll something. takes one param = amount to scroll (can be negative)
  91. WIDGET_ACTION_SCROLL_VERTICAL_VARIABLE,
  92. WIDGET_ACTION_SCROLL_PAGE,
  93. WIDGET_ACTION_SCROLL_HORIZONTAL, // scroll something. takes one param = amount to scroll (can be negative)
  94. WIDGET_ACTION_SCROLL_TAB,
  95. WIDGET_ACTION_START_REPEATER,
  96. WIDGET_ACTION_STOP_REPEATER,
  97. WIDGET_ACTION_ADJUST_FIELD,
  98. WIDGET_ACTION_PRESS_FOCUSED,
  99. WIDGET_ACTION_JOY3_ON_PRESS,
  100. WIDGET_ACTION_JOY4_ON_PRESS,
  101. //
  102. WIDGET_ACTION_GOTO_MENU,
  103. WIDGET_ACTION_GO_BACK,
  104. WIDGET_ACTION_EXIT_GAME,
  105. WIDGET_ACTION_LAUNCH_MULTIPLAYER,
  106. WIDGET_ACTION_MENU_BAR_SELECT,
  107. WIDGET_ACTION_EMAIL_HOVER,
  108. // PDA USER DATA ACTIONS
  109. WIDGET_ACTION_PDA_SELECT_USER,
  110. WIDGET_ACTION_SELECT_GAMERTAG,
  111. WIDGET_ACTION_PDA_SELECT_NAV,
  112. WIDGET_ACTION_SELECT_PDA_AUDIO,
  113. WIDGET_ACTION_SELECT_PDA_VIDEO,
  114. WIDGET_ACTION_SELECT_PDA_ITEM,
  115. WIDGET_ACTION_SCROLL_DRAG,
  116. // PDA EMAIL ACTIONS
  117. WIDGET_ACTION_PDA_SELECT_EMAIL,
  118. WIDGET_ACTION_PDA_CLOSE,
  119. WIDGET_ACTION_REFRESH,
  120. WIDGET_ACTION_MUTE_PLAYER,
  121. MAX_WIDGET_ACTION
  122. };
  123. enum actionHandler_t {
  124. WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER,
  125. WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE,
  126. WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER,
  127. WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE,
  128. WIDGET_ACTION_EVENT_SCROLL_LEFT_START_REPEATER,
  129. WIDGET_ACTION_EVENT_SCROLL_RIGHT_START_REPEATER,
  130. WIDGET_ACTION_EVENT_SCROLL_PAGE_DOWN_START_REPEATER,
  131. WIDGET_ACTION_EVENT_SCROLL_PAGE_UP_START_REPEATER,
  132. WIDGET_ACTION_EVENT_STOP_REPEATER,
  133. WIDGET_ACTION_EVENT_TAB_NEXT,
  134. WIDGET_ACTION_EVENT_TAB_PREV,
  135. WIDGET_ACTION_EVENT_DRAG_START,
  136. WIDGET_ACTION_EVENT_DRAG_STOP,
  137. WIDGET_ACTION_EVENT_JOY3_ON_PRESS,
  138. };
  139. struct widgetTransition_t {
  140. widgetTransition_t() :
  141. animationName( NULL ) {
  142. }
  143. const char * animationName; // name of the animation to run
  144. idStaticList< const char *, 4 > prefixes; // prefixes to try to use for animation
  145. };
  146. /*
  147. ================================================
  148. scoreboardInfo_t
  149. ================================================
  150. */
  151. struct scoreboardInfo_t {
  152. scoreboardInfo_t() :
  153. index( -1 ),
  154. voiceState( VOICECHAT_DISPLAY_NONE ) {
  155. }
  156. idList< idStr, TAG_IDLIB_LIST_MENU> values;
  157. int index;
  158. voiceStateDisplay_t voiceState;
  159. };
  160. /*
  161. ================================================
  162. idSort_SavesByDate
  163. ================================================
  164. */
  165. class idSort_SavesByDate : public idSort_Quick< idSaveGameDetails, idSort_SavesByDate > {
  166. public:
  167. int Compare( const idSaveGameDetails & a, const idSaveGameDetails & b ) const {
  168. return b.date - a.date;
  169. }
  170. };
  171. /*
  172. ================================================
  173. idMenuDataSource
  174. ================================================
  175. */
  176. class idMenuDataSource {
  177. public:
  178. virtual ~idMenuDataSource() { }
  179. virtual void LoadData() = 0;
  180. virtual void CommitData() = 0;
  181. virtual bool IsDataChanged() const = 0;
  182. virtual idSWFScriptVar GetField( const int fieldIndex ) const = 0;
  183. virtual void AdjustField( const int fieldIndex, const int adjustAmount ) = 0;
  184. };
  185. /*
  186. ================================================
  187. idWidgetEvent
  188. ================================================
  189. */
  190. class idWidgetEvent {
  191. public:
  192. idWidgetEvent() :
  193. type( WIDGET_EVENT_PRESS ),
  194. arg( 0 ),
  195. thisObject( NULL ) {
  196. }
  197. idWidgetEvent( const widgetEvent_t type_, const int arg_, idSWFScriptObject * thisObject_, const idSWFParmList & parms_ ) :
  198. type( type_ ),
  199. arg( arg_ ),
  200. thisObject( thisObject_ ),
  201. parms( parms_ ) {
  202. }
  203. widgetEvent_t type;
  204. int arg;
  205. idSWFScriptObject * thisObject;
  206. idSWFParmList parms;
  207. };
  208. /*
  209. ================================================
  210. idWidgetAction
  211. ================================================
  212. */
  213. class idWidgetAction {
  214. public:
  215. idWidgetAction() :
  216. action( WIDGET_ACTION_NONE ),
  217. scriptFunction( NULL ) {
  218. }
  219. idWidgetAction( const idWidgetAction & src ) {
  220. action = src.action;
  221. parms = src.parms;
  222. scriptFunction = src.scriptFunction;
  223. if ( scriptFunction != NULL ) {
  224. scriptFunction->AddRef();
  225. }
  226. }
  227. ~idWidgetAction() {
  228. if ( scriptFunction != NULL ) {
  229. scriptFunction->Release();
  230. }
  231. }
  232. void operator=( const idWidgetAction & src ) {
  233. action = src.action;
  234. parms = src.parms;
  235. scriptFunction = src.scriptFunction;
  236. if ( scriptFunction != NULL ) {
  237. scriptFunction->AddRef();
  238. }
  239. }
  240. bool operator==( const idWidgetAction & otherAction ) const {
  241. if ( GetType() != otherAction.GetType()
  242. || GetParms().Num() != otherAction.GetParms().Num() ) {
  243. return false;
  244. }
  245. // everything else is equal, so check all parms. NOTE: this assumes we are only sending
  246. // integral types.
  247. for ( int i = 0; i < GetParms().Num(); ++i ) {
  248. if ( GetParms()[ i ].GetType() != otherAction.GetParms()[ i ].GetType()
  249. || GetParms()[ i ].ToInteger() != otherAction.GetParms()[ i ].ToInteger() ) {
  250. return false;
  251. }
  252. }
  253. return true;
  254. }
  255. void Set( idSWFScriptFunction * function ) {
  256. action = WIDGET_ACTION_FUNCTION;
  257. if ( scriptFunction != NULL ) {
  258. scriptFunction->Release();
  259. }
  260. scriptFunction = function;
  261. scriptFunction->AddRef();
  262. }
  263. void Set( widgetAction_t action_ ) {
  264. action = action_;
  265. parms.Clear();
  266. }
  267. void Set( widgetAction_t action_, const idSWFScriptVar & var1 ) {
  268. action = action_;
  269. parms.Clear();
  270. parms.Append( var1 );
  271. }
  272. void Set( widgetAction_t action_, const idSWFScriptVar & var1, const idSWFScriptVar & var2 ) {
  273. action = action_;
  274. parms.Clear();
  275. parms.Append( var1 );
  276. parms.Append( var2 );
  277. }
  278. void Set( widgetAction_t action_, const idSWFScriptVar & var1, const idSWFScriptVar & var2, const idSWFScriptVar & var3 ) {
  279. action = action_;
  280. parms.Clear();
  281. parms.Append( var1 );
  282. parms.Append( var2 );
  283. parms.Append( var3 );
  284. }
  285. void Set( widgetAction_t action_, const idSWFScriptVar & var1, const idSWFScriptVar & var2, const idSWFScriptVar & var3, const idSWFScriptVar & var4 ) {
  286. action = action_;
  287. parms.Clear();
  288. parms.Append( var1 );
  289. parms.Append( var2 );
  290. parms.Append( var3 );
  291. parms.Append( var4 );
  292. }
  293. idSWFScriptFunction * GetScriptFunction() { return scriptFunction; }
  294. const widgetAction_t GetType() const { return action; }
  295. const idSWFParmList & GetParms() const { return parms; }
  296. private:
  297. widgetAction_t action;
  298. idSWFParmList parms;
  299. idSWFScriptFunction * scriptFunction;
  300. };
  301. typedef idList< idMenuWidget *, TAG_IDLIB_LIST_MENU > idMenuWidgetList;
  302. /*
  303. ================================================
  304. idMenuWidget
  305. We're using a model/view architecture, so this is the combination of both model and view. The
  306. other part of the view is the SWF itself.
  307. ================================================
  308. */
  309. class idMenuWidget {
  310. public:
  311. /*
  312. ================================================
  313. WrapWidgetSWFEvent
  314. ================================================
  315. */
  316. class WrapWidgetSWFEvent : public idSWFScriptFunction_RefCounted {
  317. public:
  318. WrapWidgetSWFEvent( idMenuWidget * widget, const widgetEvent_t event, const int eventArg ) :
  319. targetWidget( widget ),
  320. targetEvent( event ),
  321. targetEventArg( eventArg ) {
  322. }
  323. idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
  324. targetWidget->ReceiveEvent( idWidgetEvent( targetEvent, targetEventArg, thisObject, parms ) );
  325. return idSWFScriptVar();
  326. }
  327. private:
  328. idMenuWidget * targetWidget;
  329. widgetEvent_t targetEvent;
  330. int targetEventArg;
  331. };
  332. enum widgetState_t {
  333. WIDGET_STATE_HIDDEN, // hidden
  334. WIDGET_STATE_NORMAL, // normal
  335. WIDGET_STATE_SELECTING, // going into the selected state
  336. WIDGET_STATE_SELECTED, // fully selected
  337. WIDGET_STATE_DISABLED, // disabled
  338. WIDGET_STATE_MAX
  339. };
  340. idMenuWidget();
  341. virtual ~idMenuWidget();
  342. void Cleanup();
  343. // typically this is where the allocations for a widget will occur: sub widgets, etc.
  344. // Note that SWF sprite objects may not be accessible at this point.
  345. virtual void Initialize( idMenuHandler * data ) { menuData = data; }
  346. // takes the information described in this widget and applies it to a given script object.
  347. // the script object should point to the root that you want to run from. Running this will
  348. // also create the sprite binding, if any.
  349. virtual void Update() {}
  350. virtual void Show();
  351. virtual void Hide();
  352. widgetState_t GetState() const { return widgetState; }
  353. void SetState( const widgetState_t state );
  354. // actually binds the sprite. this must be called after setting sprite path!
  355. idSWFSpriteInstance * GetSprite() { return boundSprite; }
  356. idSWF * GetSWFObject();
  357. idMenuHandler * GetMenuData();
  358. bool BindSprite( idSWFScriptObject & root );
  359. void ClearSprite();
  360. void SetSpritePath( const char * arg1, const char * arg2 = NULL, const char * arg3 = NULL, const char * arg4 = NULL, const char * arg5 = NULL );
  361. void SetSpritePath( const idList< idStr > & spritePath_, const char * arg1 = NULL, const char * arg2 = NULL, const char * arg3 = NULL, const char * arg4 = NULL, const char * arg5 = NULL );
  362. idList< idStr, TAG_IDLIB_LIST_MENU > & GetSpritePath() { return spritePath; }
  363. int GetRefCount() const { return refCount; }
  364. void AddRef() { refCount++; }
  365. void Release() { assert( refCount > 0 ); if ( --refCount == 0 && !noAutoFree ) { delete this; } }
  366. //------------------------
  367. // Event Handling
  368. //------------------------
  369. virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
  370. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) { }
  371. void SendEventToObservers( const idWidgetEvent & event );
  372. void RegisterEventObserver( idMenuWidget * observer );
  373. void ReceiveEvent( const idWidgetEvent & event );
  374. // Executes an event in the context of this widget. Only rarely should this be called
  375. // directly. Instead calls should go through ReceiveEvent which will propagate the event
  376. // through the standard focus order.
  377. virtual bool ExecuteEvent( const idWidgetEvent & event );
  378. // returns the list of actions for a given event, or NULL if no actions are registered for
  379. // that event. Events should not be directly added to the returned list. Instead use
  380. // AddEventAction for adding new events.
  381. idList< idWidgetAction, TAG_IDLIB_LIST_MENU > * GetEventActions( const widgetEvent_t eventType );
  382. // allocates an action for the given event
  383. idWidgetAction & AddEventAction( const widgetEvent_t eventType );
  384. void ClearEventActions();
  385. //------------------------
  386. // Data modeling
  387. //------------------------
  388. void SetDataSource( idMenuDataSource * dataSource, const int fieldIndex );
  389. idMenuDataSource * GetDataSource() { return dataSource; }
  390. void SetDataSourceFieldIndex( const int dataSourceFieldIndex_ ) { dataSourceFieldIndex = dataSourceFieldIndex_; }
  391. int GetDataSourceFieldIndex() const { return dataSourceFieldIndex; }
  392. idMenuWidget * GetFocus() { return ( focusIndex >= 0 && focusIndex < children.Num() ) ? children[ focusIndex ] : NULL; }
  393. int GetFocusIndex() const { return focusIndex; }
  394. void SetFocusIndex( const int index, bool skipSound = false );
  395. //------------------------
  396. // Hierarchy
  397. //------------------------
  398. idMenuWidgetList & GetChildren() { return children; }
  399. const idMenuWidgetList & GetChildren() const { return children; }
  400. idMenuWidget & GetChildByIndex( const int index ) const { return *children[ index ]; }
  401. void AddChild( idMenuWidget * widget );
  402. void RemoveChild( idMenuWidget * widget );
  403. bool HasChild( idMenuWidget * widget );
  404. void RemoveAllChildren();
  405. idMenuWidget * GetParent() { return parent; }
  406. const idMenuWidget * GetParent() const { return parent; }
  407. void SetParent( idMenuWidget * parent_ ) { parent = parent_; }
  408. void SetSWFObj( idSWF * obj ) { swfObj = obj; }
  409. bool GetHandlerIsParent() { return handlerIsParent; }
  410. void SetHandlerIsParent( bool val ) { handlerIsParent = val; }
  411. void SetNoAutoFree( bool b ) { noAutoFree = b; }
  412. protected:
  413. void ForceFocusIndex( const int index ) { focusIndex = index; }
  414. protected:
  415. bool handlerIsParent;
  416. idMenuHandler * menuData;
  417. idSWF * swfObj;
  418. idSWFSpriteInstance * boundSprite;
  419. idMenuWidget * parent;
  420. idList< idStr, TAG_IDLIB_LIST_MENU > spritePath;
  421. idMenuWidgetList children;
  422. idMenuWidgetList observers;
  423. static const int INVALID_ACTION_INDEX = -1;
  424. idList< idList< idWidgetAction, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > eventActions;
  425. idStaticList< int, MAX_WIDGET_EVENT > eventActionLookup;
  426. idMenuDataSource * dataSource;
  427. int dataSourceFieldIndex;
  428. int focusIndex;
  429. widgetState_t widgetState;
  430. int refCount;
  431. bool noAutoFree;
  432. };
  433. /*
  434. ================================================
  435. idMenuWidget_Button
  436. This might be better named "ComboButton", as it contains behavior for several controls along
  437. with standard button behavior.
  438. ================================================
  439. */
  440. class idMenuWidget_Button : public idMenuWidget {
  441. public:
  442. enum animState_t {
  443. ANIM_STATE_UP, // standard
  444. ANIM_STATE_DOWN, // pressed down
  445. ANIM_STATE_OVER, // hovered over this
  446. ANIM_STATE_MAX
  447. };
  448. idMenuWidget_Button() :
  449. animState( ANIM_STATE_UP ),
  450. img( NULL ),
  451. ignoreColor( false ) {
  452. }
  453. virtual ~idMenuWidget_Button() {}
  454. virtual bool ExecuteEvent( const idWidgetEvent & event );
  455. virtual void Update();
  456. //---------------
  457. // Model
  458. //---------------
  459. void SetLabel( const idStr & label ) { btnLabel = label; }
  460. const idStr & GetLabel() const { return btnLabel; }
  461. void SetValues( idList< idStr > & list );
  462. const idStr & GetValue( int index ) const;
  463. void SetImg( const idMaterial * val ) { img = val; }
  464. const idMaterial * GetImg() { return img; }
  465. void SetDescription( const char * desc_ ) { description = desc_; }
  466. const idStr & GetDescription() const { return description; }
  467. void SetIgnoreColor( const bool b ) { ignoreColor = b; }
  468. animState_t GetAnimState() const { return animState; }
  469. void SetAnimState( const animState_t state ) { animState = state; }
  470. void SetOnPressFunction( idSWFScriptFunction * func ) { scriptFunction = func; }
  471. protected:
  472. void SetupTransitionInfo( widgetTransition_t & trans, const widgetState_t buttonState, const animState_t sourceAnimState, const animState_t destAnimState ) const;
  473. void AnimateToState( const animState_t targetState, const bool force = false );
  474. idList< idStr, TAG_IDLIB_LIST_MENU > values;
  475. idStr btnLabel;
  476. idStr description;
  477. animState_t animState;
  478. const idMaterial * img;
  479. idSWFScriptFunction * scriptFunction;
  480. bool ignoreColor;
  481. };
  482. /*
  483. ================================================
  484. idMenuWidget_LobbyButton
  485. ================================================
  486. */
  487. class idMenuWidget_LobbyButton : public idMenuWidget_Button {
  488. public:
  489. idMenuWidget_LobbyButton() :
  490. voiceState( VOICECHAT_DISPLAY_NONE ) {
  491. }
  492. virtual void Update();
  493. void SetButtonInfo( idStr name_, voiceStateDisplay_t voiceState_ );
  494. bool IsValid() { return !name.IsEmpty(); }
  495. protected:
  496. idStr name;
  497. voiceStateDisplay_t voiceState;
  498. };
  499. /*
  500. ================================================
  501. idMenuWidget_ScoreboardButton
  502. ================================================
  503. */
  504. class idMenuWidget_ScoreboardButton : public idMenuWidget_Button {
  505. public:
  506. idMenuWidget_ScoreboardButton() :
  507. voiceState( VOICECHAT_DISPLAY_NONE ),
  508. index( -1 ) {
  509. }
  510. virtual void Update();
  511. void SetButtonInfo( int index_, idList< idStr > & list, voiceStateDisplay_t voiceState_ );
  512. protected:
  513. voiceStateDisplay_t voiceState;
  514. int index;
  515. };
  516. /*
  517. ================================================
  518. idMenuWidget_ControlButton
  519. ================================================
  520. */
  521. class idMenuWidget_ControlButton : public idMenuWidget_Button {
  522. public:
  523. idMenuWidget_ControlButton() :
  524. optionType( OPTION_BUTTON_TEXT ),
  525. disabled( false ) {
  526. }
  527. virtual void Update();
  528. void SetOptionType( const menuOption_t type ) { optionType = type; }
  529. menuOption_t GetOptionType() const { return optionType; }
  530. void SetupEvents( int delay, int index );
  531. void SetDisabled( bool disable ) { disabled = disable; }
  532. protected:
  533. menuOption_t optionType;
  534. bool disabled;
  535. };
  536. /*
  537. ================================================
  538. idMenuWidget_ServerButton
  539. ================================================
  540. */
  541. class idMenuWidget_ServerButton : public idMenuWidget_Button {
  542. public:
  543. idMenuWidget_ServerButton() :
  544. players( 0 ),
  545. index( 0 ),
  546. maxPlayers( 0 ),
  547. joinable( false ),
  548. validMap( false ) {
  549. }
  550. virtual void Update();
  551. void SetButtonInfo( idStr name_, idStrId mapName_, idStr modeName_, int index_ = 0, int players_ = 0, int maxPlayers_ = 0, bool joinable_ = false, bool validMap_ = false );
  552. bool IsValid() { return !serverName.IsEmpty(); }
  553. bool CanJoin() { return ( joinable && validMap ); }
  554. protected:
  555. idStr serverName;
  556. int index;
  557. int players;
  558. int maxPlayers;
  559. bool joinable;
  560. bool validMap;
  561. idStrId mapName;
  562. idStr modeName;
  563. };
  564. /*
  565. ================================================
  566. idMenuWidget_NavButton
  567. ================================================
  568. */
  569. class idMenuWidget_NavButton : public idMenuWidget_Button {
  570. public:
  571. enum navWidgetState_t {
  572. NAV_WIDGET_LEFT, // option on left side
  573. NAV_WIDGET_RIGHT, // option on right side
  574. NAV_WIDGET_SELECTED // option is selected
  575. };
  576. idMenuWidget_NavButton() :
  577. navIndex( 0 ),
  578. xPos( 0 ) {
  579. }
  580. virtual bool ExecuteEvent( const idWidgetEvent & event );
  581. virtual void Update();
  582. void SetNavIndex( int i, const navWidgetState_t type ) { navIndex = i; navState = type; }
  583. void SetPosition( float pos ) { xPos = pos; }
  584. private:
  585. int navIndex;
  586. float xPos;
  587. navWidgetState_t navState;
  588. };
  589. /*
  590. ================================================
  591. idMenuWidget_NavButton
  592. ================================================
  593. */
  594. class idMenuWidget_MenuButton : public idMenuWidget_Button {
  595. public:
  596. idMenuWidget_MenuButton() :
  597. xPos( 0 ) {
  598. }
  599. virtual void Update();
  600. void SetPosition( float pos ) { xPos = pos; }
  601. private:
  602. float xPos;
  603. };
  604. /*
  605. ================================================
  606. idMenuWidget_List
  607. Stores a list of widgets but displays only a segment of them at a time.
  608. ================================================
  609. */
  610. class idMenuWidget_List : public idMenuWidget {
  611. public:
  612. idMenuWidget_List() :
  613. numVisibleOptions( 0 ),
  614. viewOffset( 0 ),
  615. viewIndex( 0 ),
  616. allowWrapping( false ) {
  617. }
  618. virtual void Update();
  619. virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
  620. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event );
  621. virtual void Scroll( const int scrollIndexAmount, const bool wrapAround = false );
  622. virtual void ScrollOffset( const int scrollIndexAmount );
  623. virtual int GetTotalNumberOfOptions() const { return GetChildren().Num(); }
  624. virtual bool PrepareListElement( idMenuWidget & widget, const int childIndex ) { return true; }
  625. bool IsWrappingAllowed() const { return allowWrapping; }
  626. void SetWrappingAllowed( const bool allow ) { allowWrapping = allow; }
  627. void SetNumVisibleOptions( const int numVisibleOptions_ ) { numVisibleOptions = numVisibleOptions_; }
  628. int GetNumVisibleOptions() const { return numVisibleOptions; }
  629. int GetViewOffset() const { return viewOffset; }
  630. void SetViewOffset( const int offset ) { viewOffset = offset; }
  631. int GetViewIndex() const { return viewIndex; }
  632. void SetViewIndex( const int index ) { viewIndex = index; }
  633. void CalculatePositionFromIndexDelta( int & outIndex, int & outOffset, const int currentIndex, const int currentOffset, const int windowSize, const int maxSize, const int indexDelta, const bool allowWrapping, const bool wrapAround = false ) const;
  634. void CalculatePositionFromOffsetDelta( int & outIndex, int & outOffset, const int currentIndex, const int currentOffset, const int windowSize, const int maxSize, const int offsetDelta ) const;
  635. private:
  636. int numVisibleOptions;
  637. int viewOffset;
  638. int viewIndex;
  639. bool allowWrapping;
  640. };
  641. class idBrowserEntry_t {
  642. public:
  643. idStr serverName;
  644. int index;
  645. int players;
  646. int maxPlayers;
  647. bool joinable;
  648. bool validMap;
  649. idStrId mapName;
  650. idStr modeName;
  651. };
  652. /*
  653. ================================================
  654. idMenuWidget_GameBrowserList
  655. ================================================
  656. */
  657. class idMenuWidget_GameBrowserList : public idMenuWidget_List {
  658. public:
  659. virtual void Update();
  660. virtual bool PrepareListElement( idMenuWidget & widget, const int childIndex );
  661. virtual int GetTotalNumberOfOptions() const;
  662. void ClearGames();
  663. void AddGame( idStr name_, idStrId mapName_, idStr modeName_, int index_ = 0, int players_ = 0, int maxPlayers_ = 0, bool joinable_ = false, bool validMap_ = false );
  664. int GetServerIndex();
  665. private:
  666. idList< idBrowserEntry_t > games;
  667. };
  668. /*
  669. ================================================
  670. idMenuWidget_Carousel
  671. Displays a list of items in a looping carousel pattern
  672. ================================================
  673. */
  674. class idMenuWidget_Carousel : public idMenuWidget {
  675. public:
  676. idMenuWidget_Carousel() :
  677. numVisibleOptions( 0 ),
  678. viewIndex( 0 ),
  679. moveToIndex( 0 ),
  680. scrollLeft( false ),
  681. fastScroll( false ),
  682. moveDiff( 0 ) {
  683. }
  684. virtual void Initialize( idMenuHandler * data );
  685. virtual void Update();
  686. virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
  687. virtual int GetTotalNumberOfOptions() const { return imgList.Num(); }
  688. virtual bool PrepareListElement( idMenuWidget & widget, const int childIndex ) { return true; }
  689. void SetNumVisibleOptions( const int numVisibleOptions_ ) { numVisibleOptions = numVisibleOptions_; }
  690. int GetNumVisibleOptions() const { return numVisibleOptions; }
  691. void MoveToIndex( int index, bool instant = false );
  692. void MoveToFirstItem( bool instant = true );
  693. void MoveToLastItem( bool instant = true );
  694. int GetMoveToIndex() { return moveToIndex; }
  695. void SetMoveToIndex( int index ) { moveToIndex = index; }
  696. void SetViewIndex( int index ) { viewIndex = index; }
  697. int GetViewIndex() const { return viewIndex; }
  698. void SetListImages( idList<const idMaterial *> & list );
  699. void SetMoveDiff( int val ) { moveDiff = val; }
  700. int GetMoveDiff() { return moveDiff; }
  701. bool GetScrollLeft() { return scrollLeft; }
  702. private:
  703. int numVisibleOptions;
  704. int viewIndex;
  705. int moveToIndex;
  706. int moveDiff;
  707. bool fastScroll;
  708. bool scrollLeft;
  709. idList<const idMaterial *> imgList;
  710. };
  711. /*
  712. ================================================
  713. idMenuWidget_Help
  714. Knows how to display help tooltips by observing events from other widgets
  715. ================================================
  716. */
  717. class idMenuWidget_Help : public idMenuWidget {
  718. public:
  719. virtual void Update();
  720. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event );
  721. private:
  722. idStr lastFocusedMessage; // message from last widget that had focus
  723. idStr lastHoveredMessage; // message from last widget that was hovered over
  724. bool hideMessage;
  725. };
  726. /*
  727. ================================================
  728. idMenuWidget_CommandBar
  729. ================================================
  730. */
  731. class idMenuWidget_CommandBar : public idMenuWidget {
  732. public:
  733. enum button_t {
  734. BUTTON_JOY1,
  735. BUTTON_JOY2,
  736. BUTTON_JOY3,
  737. BUTTON_JOY4,
  738. BUTTON_JOY10,
  739. BUTTON_TAB,
  740. MAX_BUTTONS
  741. };
  742. enum alignment_t {
  743. LEFT,
  744. RIGHT
  745. };
  746. struct buttonInfo_t {
  747. idStr label; // empty labels are treated as hidden buttons
  748. idWidgetAction action;
  749. };
  750. idMenuWidget_CommandBar() :
  751. alignment( LEFT ) {
  752. buttons.SetNum( MAX_BUTTONS );
  753. }
  754. virtual void Update();
  755. virtual bool ExecuteEvent( const idWidgetEvent & event );
  756. buttonInfo_t * GetButton( const button_t button ) { return &buttons[ button ]; }
  757. void ClearAllButtons();
  758. alignment_t GetAlignment() const { return alignment; }
  759. void SetAlignment( const alignment_t alignment_ ) { alignment = alignment_; }
  760. private:
  761. idStaticList< buttonInfo_t, MAX_BUTTONS > buttons;
  762. alignment_t alignment;
  763. };
  764. /*
  765. ================================================
  766. idMenuWidget_DynamicList
  767. ================================================
  768. */
  769. class idMenuWidget_LobbyList : public idMenuWidget_List {
  770. public:
  771. idMenuWidget_LobbyList() :
  772. numEntries( 0 ) {
  773. }
  774. virtual void Update();
  775. virtual bool PrepareListElement( idMenuWidget & widget, const int childIndex );
  776. virtual int GetTotalNumberOfOptions() const { return numEntries; }
  777. void SetEntryData( int index, idStr name, voiceStateDisplay_t voiceState );
  778. void SetHeadingInfo( idList< idStr > & list );
  779. void SetNumEntries( int num ) { numEntries = num; }
  780. int GetNumEntries() { return numEntries; }
  781. void SetRefreshFunction( const char* func );
  782. private:
  783. idList< idStr, TAG_IDLIB_LIST_MENU > headings;
  784. int numEntries;
  785. };
  786. /*
  787. ================================================
  788. idMenuWidget_DynamicList
  789. ================================================
  790. */
  791. class idMenuWidget_DynamicList : public idMenuWidget_List {
  792. public:
  793. idMenuWidget_DynamicList() :
  794. controlList( false ),
  795. ignoreColor( false ) {
  796. }
  797. virtual void Update();
  798. virtual void Initialize( idMenuHandler * data );
  799. virtual int GetTotalNumberOfOptions() const;
  800. virtual bool PrepareListElement( idMenuWidget & widget, const int childIndex );
  801. virtual void Recalculate();
  802. virtual void SetListData( idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > & list );
  803. void SetControlList( bool val ) { controlList = val; }
  804. void SetIgnoreColor( bool val ) { ignoreColor = val; }
  805. protected:
  806. idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > listItemInfo;
  807. bool controlList;
  808. bool ignoreColor;
  809. };
  810. /*
  811. ================================================
  812. idMenuWidget_ScoreboardList
  813. ================================================
  814. */
  815. class idMenuWidget_ScoreboardList : public idMenuWidget_DynamicList {
  816. public:
  817. virtual void Update();
  818. virtual int GetTotalNumberOfOptions() const;
  819. };
  820. /*
  821. ================================================
  822. idMenuWidget_NavBar
  823. The nav bar is set up with the main option being at the safe frame line.
  824. ================================================
  825. */
  826. class idMenuWidget_NavBar : public idMenuWidget_DynamicList {
  827. public:
  828. idMenuWidget_NavBar() :
  829. initialPos( 0.0f ),
  830. buttonPos( 0.0f ),
  831. leftSpacer( 0.0f ),
  832. rightSpacer( 0.0f ),
  833. selectedSpacer( 0.0f ) {
  834. }
  835. virtual void Update();
  836. virtual void Initialize( idMenuHandler * data );
  837. virtual void SetInitialXPos( float pos ) { initialPos = pos; }
  838. virtual void SetButtonSpacing( float lSpace, float rSpace, float sSpace ) { leftSpacer = lSpace; rightSpacer = rSpace; selectedSpacer = sSpace; }
  839. virtual bool PrepareListElement( idMenuWidget & widget, const int navIndex );
  840. virtual void SetListHeadings( idList< idStr > & list );
  841. virtual int GetTotalNumberOfOptions() const;
  842. private:
  843. idList< idStr, TAG_IDLIB_LIST_MENU > headings;
  844. float initialPos;
  845. float buttonPos;
  846. float leftSpacer;
  847. float rightSpacer;
  848. float selectedSpacer;
  849. };
  850. /*
  851. ================================================
  852. idMenuWidget_NavBar
  853. The nav bar is set up with the main option being at the safe frame line.
  854. ================================================
  855. */
  856. class idMenuWidget_MenuBar : public idMenuWidget_DynamicList {
  857. public:
  858. idMenuWidget_MenuBar() :
  859. totalWidth( 0.0f ),
  860. buttonPos( 0.0f ),
  861. rightSpacer( 0.0f ) {
  862. }
  863. virtual void Update();
  864. virtual void Initialize( idMenuHandler * data );
  865. virtual void SetButtonSpacing( float rSpace ) { rightSpacer = rSpace; }
  866. virtual bool PrepareListElement( idMenuWidget & widget, const int navIndex );
  867. virtual void SetListHeadings( idList< idStr > & list );
  868. virtual int GetTotalNumberOfOptions() const;
  869. private:
  870. idList< idStr, TAG_IDLIB_LIST_MENU > headings;
  871. float totalWidth;
  872. float buttonPos;
  873. float rightSpacer;
  874. };
  875. /*
  876. ================================================
  877. idMenuWidget_PDA_UserData
  878. ================================================
  879. */
  880. class idMenuWidget_PDA_UserData : public idMenuWidget {
  881. public:
  882. idMenuWidget_PDA_UserData() :
  883. pdaIndex( 0 ) {
  884. }
  885. virtual ~idMenuWidget_PDA_UserData() {}
  886. virtual void Update();
  887. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event );
  888. private:
  889. int pdaIndex;
  890. };
  891. /*
  892. ================================================
  893. idMenuWidget_DynamicList
  894. ================================================
  895. */
  896. class idMenuWidget_ScrollBar : public idMenuWidget {
  897. public:
  898. idMenuWidget_ScrollBar() :
  899. yTop( 0.0f ),
  900. yBot( 0.0f ),
  901. dragging( false ) {
  902. }
  903. virtual void Initialize( idMenuHandler * data );
  904. virtual void Update();
  905. virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
  906. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event );
  907. void CalcTopAndBottom();
  908. void CalculatePosition( float x, float y );
  909. float yTop;
  910. float yBot;
  911. bool dragging;
  912. };
  913. /*
  914. ================================================
  915. idMenuWidget_InfoBox
  916. ================================================
  917. */
  918. class idMenuWidget_InfoBox: public idMenuWidget {
  919. public:
  920. idMenuWidget_InfoBox() :
  921. scrollbar( NULL ) {
  922. }
  923. virtual void Initialize( idMenuHandler * data );
  924. virtual void Update();
  925. virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
  926. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event );
  927. void SetHeading( idStr val ) { heading = val; }
  928. void SetBody( idStr val ) { info = val; }
  929. void ResetInfoScroll();
  930. void Scroll( int d );
  931. int GetScroll();
  932. int GetMaxScroll();
  933. void SetScroll( int scroll );
  934. void SetScrollbar( idMenuWidget_ScrollBar * bar );
  935. private:
  936. idMenuWidget_ScrollBar * scrollbar;
  937. idStr heading;
  938. idStr info;
  939. };
  940. /*
  941. ================================================
  942. idMenuWidget_PDA_Objective
  943. ================================================
  944. */
  945. class idMenuWidget_PDA_Objective: public idMenuWidget {
  946. public:
  947. idMenuWidget_PDA_Objective() :
  948. pdaIndex( 0 ) {
  949. }
  950. virtual void Update();
  951. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event );
  952. private:
  953. int pdaIndex;
  954. };
  955. /*
  956. ================================================
  957. idMenuWidget_Shell_SaveInfo
  958. ================================================
  959. */
  960. class idMenuWidget_Shell_SaveInfo: public idMenuWidget {
  961. public:
  962. idMenuWidget_Shell_SaveInfo() :
  963. loadIndex( 0 ),
  964. forSaveScreen( false ) {
  965. }
  966. virtual void Update();
  967. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event );
  968. void SetForSaveScreen( bool val ) { forSaveScreen = val; }
  969. private:
  970. int loadIndex;
  971. bool forSaveScreen;
  972. };
  973. /*
  974. ================================================
  975. idMenuWidget_PDA_AudioFiles
  976. ================================================
  977. */
  978. class idMenuWidget_PDA_AudioFiles: public idMenuWidget {
  979. public:
  980. idMenuWidget_PDA_AudioFiles() :
  981. pdaIndex( 0 ) {
  982. }
  983. virtual ~idMenuWidget_PDA_AudioFiles();
  984. virtual void Update();
  985. virtual void Initialize( idMenuHandler * data );
  986. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event );
  987. private:
  988. int pdaIndex;
  989. idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > audioFileNames;
  990. };
  991. /*
  992. ================================================
  993. idMenuWidget_PDA_AudioFiles
  994. ================================================
  995. */
  996. class idMenuWidget_PDA_EmailInbox: public idMenuWidget {
  997. public:
  998. idMenuWidget_PDA_EmailInbox() :
  999. pdaIndex( 0 ),
  1000. emailList( NULL ),
  1001. scrollbar( NULL ) {
  1002. }
  1003. virtual void Update();
  1004. virtual void Initialize( idMenuHandler * data );
  1005. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event );
  1006. idMenuWidget_DynamicList * GetEmailList() { return emailList; }
  1007. idMenuWidget_ScrollBar * GetScrollbar() { return scrollbar; }
  1008. private:
  1009. idMenuWidget_DynamicList * emailList;
  1010. idMenuWidget_ScrollBar * scrollbar;
  1011. int pdaIndex;
  1012. idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > emailInfo;
  1013. };
  1014. /*
  1015. ================================================
  1016. idMenuWidget_PDA_AudioFiles
  1017. ================================================
  1018. */
  1019. class idMenuWidget_ItemAssignment: public idMenuWidget {
  1020. public:
  1021. idMenuWidget_ItemAssignment() :
  1022. slotIndex( 0 ) {
  1023. }
  1024. virtual void Update();
  1025. void SetIcon( int index, const idMaterial * icon );
  1026. void FindFreeSpot();
  1027. int GetSlotIndex() { return slotIndex; }
  1028. void SetSlotIndex( int num ) { slotIndex = num; }
  1029. private:
  1030. const idMaterial * images[ NUM_QUICK_SLOTS ];
  1031. int slotIndex;
  1032. };
  1033. /*
  1034. ================================================
  1035. idMenuWidget_PDA_AudioFiles
  1036. ================================================
  1037. */
  1038. class idMenuWidget_PDA_VideoInfo: public idMenuWidget {
  1039. public:
  1040. virtual void Update();
  1041. virtual void ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event );
  1042. private:
  1043. int videoIndex;
  1044. };
  1045. /*
  1046. ================================================
  1047. idWidgetActionHandler
  1048. ================================================
  1049. */
  1050. class idWidgetActionHandler : public idSWFScriptFunction_RefCounted {
  1051. public:
  1052. idWidgetActionHandler( idMenuWidget * widget, actionHandler_t actionEventType, widgetEvent_t _event ) :
  1053. targetWidget( widget ),
  1054. type( actionEventType ),
  1055. targetEvent( _event ) {
  1056. }
  1057. idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
  1058. idWidgetAction action;
  1059. bool handled = false;
  1060. switch ( type ) {
  1061. case WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER: {
  1062. action.Set( (widgetAction_t)WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL, 1 );
  1063. handled = true;
  1064. break;
  1065. }
  1066. case WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER: {
  1067. action.Set( (widgetAction_t)WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL, -1 );
  1068. handled = true;
  1069. break;
  1070. }
  1071. case WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE: {
  1072. action.Set( (widgetAction_t)WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL_VARIABLE, 1 );
  1073. handled = true;
  1074. break;
  1075. }
  1076. case WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE: {
  1077. action.Set( (widgetAction_t)WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL_VARIABLE, -1 );
  1078. handled = true;
  1079. break;
  1080. }
  1081. case WIDGET_ACTION_EVENT_SCROLL_PAGE_DOWN_START_REPEATER: {
  1082. action.Set( (widgetAction_t)WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_PAGE, 1 );
  1083. handled = true;
  1084. break;
  1085. }
  1086. case WIDGET_ACTION_EVENT_SCROLL_PAGE_UP_START_REPEATER: {
  1087. action.Set( (widgetAction_t)WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_PAGE, -1 );
  1088. handled = true;
  1089. break;
  1090. }
  1091. case WIDGET_ACTION_EVENT_STOP_REPEATER: {
  1092. action.Set( (widgetAction_t)WIDGET_ACTION_STOP_REPEATER );
  1093. handled = true;
  1094. break;
  1095. }
  1096. case WIDGET_ACTION_EVENT_TAB_NEXT: {
  1097. action.Set( (widgetAction_t)WIDGET_ACTION_SCROLL_TAB, 1 );
  1098. handled = true;
  1099. break;
  1100. }
  1101. case WIDGET_ACTION_EVENT_TAB_PREV: {
  1102. action.Set( (widgetAction_t)WIDGET_ACTION_SCROLL_TAB, -1 );
  1103. handled = true;
  1104. break;
  1105. }
  1106. case WIDGET_ACTION_EVENT_JOY3_ON_PRESS: {
  1107. action.Set( (widgetAction_t)WIDGET_ACTION_JOY3_ON_PRESS );
  1108. handled = true;
  1109. break;
  1110. }
  1111. case WIDGET_ACTION_EVENT_SCROLL_LEFT_START_REPEATER: {
  1112. action.Set( (widgetAction_t)WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_HORIZONTAL, -1 );
  1113. handled = true;
  1114. break;
  1115. }
  1116. case WIDGET_ACTION_EVENT_SCROLL_RIGHT_START_REPEATER: {
  1117. action.Set( (widgetAction_t)WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_HORIZONTAL, 1 );
  1118. handled = true;
  1119. break;
  1120. }
  1121. case WIDGET_ACTION_EVENT_DRAG_START: {
  1122. action.Set( (widgetAction_t)WIDGET_ACTION_SCROLL_DRAG );
  1123. handled = true;
  1124. break;
  1125. }
  1126. case WIDGET_ACTION_EVENT_DRAG_STOP: {
  1127. action.Set( (widgetAction_t)WIDGET_ACTION_EVENT_DRAG_STOP );
  1128. handled = true;
  1129. break;
  1130. }
  1131. }
  1132. if ( handled ) {
  1133. targetWidget->HandleAction( action, idWidgetEvent( targetEvent, 0, thisObject, parms ), targetWidget );
  1134. }
  1135. return idSWFScriptVar();
  1136. }
  1137. private:
  1138. idMenuWidget * targetWidget;
  1139. actionHandler_t type;
  1140. widgetEvent_t targetEvent;
  1141. };
  1142. #endif