MenuWidget_Button.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  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. #pragma hdrstop
  21. #include "../../idLib/precompiled.h"
  22. #include "../Game_local.h"
  23. /*
  24. ================================================================================================
  25. idMenuWidget_Button
  26. SWF object structure
  27. --------------------
  28. BUTTON (Frames: up, over, out, down, release, disabled, sel_up, sel_over, sel_out, sel_down, sel_release, selecting, unselecting)
  29. txtOption
  30. txtValue (Text)
  31. optionType (Frames: One per mainMenuOption_t enum)
  32. sliderBar
  33. bar (Frames: 1-100 for percentage filled)
  34. btnLess
  35. btnMore
  36. sliderText
  37. txtVal (Text)
  38. btnLess
  39. btnMore
  40. Future work:
  41. - Perhaps this should be called "MultiButton", since it merges additional controls with a standard button?
  42. ================================================================================================
  43. */
  44. //---------------------------------
  45. // Animation State Transitions
  46. //
  47. // Maps animations that should be called when transitioning states:
  48. //
  49. // X-axis = state transitioning FROM
  50. // Y-axis = state transitioning TO
  51. //
  52. // An empty string indicates remain at current animation.
  53. //---------------------------------
  54. static const char * ANIM_STATE_TRANSITIONS[ idMenuWidget_Button::ANIM_STATE_MAX * idMenuWidget_Button::ANIM_STATE_MAX ] = {
  55. // UP DOWN OVER
  56. "", "release", "out", // UP
  57. "down", "", "down", // DOWN
  58. "over", "over", "", // OVER
  59. };
  60. // script name for the control object for a given type of button
  61. static const char * const CONTROL_SPRITE_NAMES[ MAX_MENU_OPTION_TYPES ] = {
  62. NULL,
  63. "sliderBar",
  64. "sliderText",
  65. "sliderText",
  66. NULL,
  67. "sliderText",
  68. };
  69. compile_time_assert( sizeof( CONTROL_SPRITE_NAMES ) / sizeof( CONTROL_SPRITE_NAMES[ 0 ] ) == MAX_MENU_OPTION_TYPES );
  70. /*
  71. ========================
  72. idMenuWidget_Button::Update
  73. ========================
  74. */
  75. void idMenuWidget_Button::Update() {
  76. if ( menuData != NULL && menuData->GetGUI() != NULL ) {
  77. BindSprite( menuData->GetGUI()->GetRootObject() );
  78. }
  79. if ( GetSprite() == NULL ) {
  80. return;
  81. }
  82. idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
  83. if ( btnLabel.IsEmpty() ) {
  84. if ( values.Num() > 0 ) {
  85. for ( int val = 0; val < values.Num(); ++val ) {
  86. idSWFScriptObject * const textObject = spriteObject->GetNestedObj( va( "label%d", val ), "txtVal" );
  87. if ( textObject != NULL ) {
  88. idSWFTextInstance * const text = textObject->GetText();
  89. text->SetIgnoreColor( ignoreColor );
  90. text->tooltip = ignoreColor; // ignoreColor does double duty as "allow tooltips"
  91. text->SetText( values[ val ].c_str() );
  92. text->SetStrokeInfo( true, 0.75f, 2.0f );
  93. }
  94. }
  95. } else if ( img != NULL ) {
  96. idSWFSpriteInstance * btnImg = spriteObject->GetNestedSprite( "img" );
  97. if ( btnImg != NULL ) {
  98. btnImg->SetMaterial( img );
  99. }
  100. btnImg = spriteObject->GetNestedSprite( "imgTop" );
  101. if ( btnImg != NULL ) {
  102. btnImg->SetMaterial( img );
  103. }
  104. } else {
  105. ClearSprite();
  106. }
  107. } else {
  108. idSWFScriptObject * const textObject = spriteObject->GetNestedObj( "label0", "txtVal" );
  109. if ( textObject != NULL ) {
  110. idSWFTextInstance * const text = textObject->GetText();
  111. text->SetIgnoreColor( ignoreColor );
  112. text->tooltip = ignoreColor; // ignoreColor does double duty as "allow tooltips"
  113. text->SetText( btnLabel.c_str() );
  114. text->SetStrokeInfo( true, 0.75f, 2.0f );
  115. }
  116. }
  117. // events
  118. spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
  119. spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
  120. idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
  121. if ( hitBox == NULL ) {
  122. hitBox = spriteObject;
  123. }
  124. hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
  125. hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
  126. }
  127. /*
  128. ========================
  129. idMenuWidget_Button::ExecuteEvent
  130. ========================
  131. */
  132. bool idMenuWidget_Button::ExecuteEvent( const idWidgetEvent & event ) {
  133. bool handled = false;
  134. // do nothing at all if it's disabled
  135. if ( GetState() != WIDGET_STATE_DISABLED ) {
  136. switch ( event.type ) {
  137. case WIDGET_EVENT_PRESS: {
  138. if ( GetMenuData() != NULL ) {
  139. GetMenuData()->PlaySound( GUI_SOUND_ADVANCE );
  140. }
  141. AnimateToState( ANIM_STATE_DOWN );
  142. handled = true;
  143. break;
  144. }
  145. case WIDGET_EVENT_RELEASE: {
  146. AnimateToState( ANIM_STATE_UP );
  147. GetMenuData()->ClearWidgetActionRepeater();
  148. handled = true;
  149. break;
  150. }
  151. case WIDGET_EVENT_ROLL_OVER: {
  152. if ( GetMenuData() != NULL ) {
  153. GetMenuData()->PlaySound( GUI_SOUND_ROLL_OVER );
  154. }
  155. AnimateToState( ANIM_STATE_OVER );
  156. handled = true;
  157. break;
  158. }
  159. case WIDGET_EVENT_ROLL_OUT: {
  160. AnimateToState( ANIM_STATE_UP );
  161. GetMenuData()->ClearWidgetActionRepeater();
  162. handled = true;
  163. break;
  164. }
  165. case WIDGET_EVENT_FOCUS_OFF: {
  166. SetState( WIDGET_STATE_NORMAL );
  167. handled = true;
  168. break;
  169. }
  170. case WIDGET_EVENT_FOCUS_ON: {
  171. SetState( WIDGET_STATE_SELECTING );
  172. handled = true;
  173. break;
  174. }
  175. case WIDGET_EVENT_SCROLL_LEFT_RELEASE: {
  176. GetMenuData()->ClearWidgetActionRepeater();
  177. break;
  178. }
  179. case WIDGET_EVENT_SCROLL_RIGHT_RELEASE: {
  180. GetMenuData()->ClearWidgetActionRepeater();
  181. break;
  182. }
  183. }
  184. }
  185. idMenuWidget::ExecuteEvent( event );
  186. return handled;
  187. }
  188. /*
  189. ========================
  190. idMenuWidget_Button::AddValue
  191. ========================
  192. */
  193. void idMenuWidget_Button::SetValues( idList< idStr > & list ) {
  194. values.Clear();
  195. for ( int i = 0; i < list.Num(); ++ i ) {
  196. values.Append( list[ i ] );
  197. }
  198. }
  199. /*
  200. ========================
  201. idMenuWidget_Button::GetValue
  202. ========================
  203. */
  204. const idStr & idMenuWidget_Button::GetValue( int index ) const {
  205. return values[ index ];
  206. }
  207. /*
  208. ========================
  209. idMenuWidget_Button::SetupTransitionInfo
  210. ========================
  211. */
  212. void idMenuWidget_Button::SetupTransitionInfo( widgetTransition_t & trans, const widgetState_t buttonState, const animState_t sourceAnimState, const animState_t destAnimState ) const {
  213. trans.prefixes.Clear();
  214. if ( buttonState == WIDGET_STATE_DISABLED ) {
  215. trans.animationName = "disabled";
  216. } else {
  217. const int animIndex = (int)destAnimState * ANIM_STATE_MAX + (int)sourceAnimState;
  218. trans.animationName = ANIM_STATE_TRANSITIONS[ animIndex ];
  219. if ( buttonState == WIDGET_STATE_SELECTING ) {
  220. trans.prefixes.Append( "sel_" );
  221. }
  222. }
  223. trans.prefixes.Append( "" );
  224. }
  225. /*
  226. ========================
  227. idMenuWidget_Button::AnimateToState
  228. Plays an animation from the current state to the target state.
  229. ========================
  230. */
  231. void idMenuWidget_Button::AnimateToState( const animState_t targetAnimState, const bool force ) {
  232. if ( !force && targetAnimState == GetAnimState() ) {
  233. return;
  234. }
  235. if ( GetSprite() != NULL ) {
  236. widgetTransition_t trans;
  237. SetupTransitionInfo( trans, GetState(), GetAnimState(), targetAnimState );
  238. if ( trans.animationName[0] != '\0' ) {
  239. for ( int i = 0; i < trans.prefixes.Num(); ++i ) {
  240. const char * const frameLabel = va( "%s%s", trans.prefixes[ i ], trans.animationName );
  241. if ( GetSprite()->FrameExists( frameLabel ) ) {
  242. GetSprite()->PlayFrame( frameLabel );
  243. Update();
  244. break;
  245. }
  246. }
  247. }
  248. idSWFSpriteInstance * const focusSprite = GetSprite()->GetScriptObject()->GetSprite( "focusIndicator" );
  249. if ( focusSprite != NULL ) {
  250. if ( targetAnimState == ANIM_STATE_OVER ) {
  251. focusSprite->PlayFrame( "show" );
  252. } else {
  253. focusSprite->PlayFrame( "hide" );
  254. }
  255. }
  256. }
  257. SetAnimState( targetAnimState );
  258. }
  259. //*****************************************************************************************************************
  260. // CONTROL BUTTON
  261. /*
  262. ========================
  263. idMenuWidget_ControlButton::Update
  264. ========================
  265. */
  266. void idMenuWidget_ControlButton::Update() {
  267. if ( GetSprite() == NULL ) {
  268. return;
  269. }
  270. idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject()->GetNestedObj( "type" );
  271. if ( spriteObject == NULL ) {
  272. return;
  273. }
  274. idSWFSpriteInstance * type = spriteObject->GetSprite();
  275. if ( type == NULL ) {
  276. return;
  277. }
  278. if ( GetOptionType() != OPTION_BUTTON_FULL_TEXT_SLIDER ) {
  279. type->StopFrame( GetOptionType() + 1 );
  280. }
  281. idSWFTextInstance * text = spriteObject->GetNestedText( "label0", "txtVal" );
  282. if ( text != NULL ) {
  283. text->SetText( btnLabel );
  284. text->SetStrokeInfo( true, 0.75f, 2.0f );
  285. }
  286. if ( CONTROL_SPRITE_NAMES[ GetOptionType() ] != NULL ) {
  287. idSWFSpriteInstance * controlSprite = NULL;
  288. if ( CONTROL_SPRITE_NAMES[ GetOptionType() ] != NULL ) {
  289. controlSprite = type->GetScriptObject()->GetSprite( CONTROL_SPRITE_NAMES[ GetOptionType() ] );
  290. if ( verify( controlSprite != NULL ) ) {
  291. if ( verify( GetDataSource() != NULL ) ) {
  292. idSWFScriptVar fieldValue = GetDataSource()->GetField( GetDataSourceFieldIndex() );
  293. if ( GetOptionType() == OPTION_SLIDER_BAR ) {
  294. controlSprite->StopFrame( 1 + fieldValue.ToInteger() );
  295. } else if ( GetOptionType() == OPTION_SLIDER_TOGGLE ) {
  296. idSWFTextInstance * const txtInfo = controlSprite->GetScriptObject()->GetNestedText( "txtVal" );
  297. if ( verify( txtInfo != NULL ) ) {
  298. txtInfo->SetText( fieldValue.ToBool() ? "#str_swf_enabled" : "#str_swf_disabled" );
  299. txtInfo->SetStrokeInfo( true, 0.75f, 2.0f );
  300. }
  301. } else if ( GetOptionType() == OPTION_SLIDER_TEXT || GetOptionType() == OPTION_BUTTON_FULL_TEXT_SLIDER ) {
  302. idSWFTextInstance * const txtInfo = controlSprite->GetScriptObject()->GetNestedText( "txtVal" );
  303. if ( verify( txtInfo != NULL ) ) {
  304. txtInfo->SetText( fieldValue.ToString() );
  305. txtInfo->SetStrokeInfo( true, 0.75f, 2.0f );
  306. }
  307. }
  308. }
  309. idSWFScriptObject * const btnLess = GetSprite()->GetScriptObject()->GetObject( "btnLess" );
  310. idSWFScriptObject * const btnMore = GetSprite()->GetScriptObject()->GetObject( "btnMore" );
  311. if ( btnLess != NULL && btnMore != NULL ) {
  312. if ( disabled ) {
  313. btnLess->GetSprite()->SetVisible( false );
  314. btnMore->GetSprite()->SetVisible( false );
  315. } else {
  316. btnLess->GetSprite()->SetVisible( true );
  317. btnMore->GetSprite()->SetVisible( true );
  318. btnLess->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT, 0 ) );
  319. btnLess->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT_RELEASE, 0 ) );
  320. btnMore->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT, 0 ) );
  321. btnMore->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT_RELEASE, 0 ) );
  322. btnLess->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
  323. btnLess->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
  324. btnMore->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
  325. btnMore->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
  326. }
  327. }
  328. }
  329. }
  330. } else {
  331. idSWFScriptObject * const btnLess = GetSprite()->GetScriptObject()->GetObject( "btnLess" );
  332. idSWFScriptObject * const btnMore = GetSprite()->GetScriptObject()->GetObject( "btnMore" );
  333. if ( btnLess != NULL && btnMore != NULL ) {
  334. btnLess->GetSprite()->SetVisible( false );
  335. btnMore->GetSprite()->SetVisible( false );
  336. }
  337. }
  338. // events
  339. GetSprite()->GetScriptObject()->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
  340. GetSprite()->GetScriptObject()->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
  341. idSWFScriptObject * hitBox = GetSprite()->GetScriptObject()->GetObject( "hitBox" );
  342. if ( hitBox == NULL ) {
  343. hitBox = GetSprite()->GetScriptObject();
  344. }
  345. hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
  346. hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
  347. }
  348. /*
  349. ========================
  350. idMenuWidget_ControlButton::Update
  351. ========================
  352. */
  353. void idMenuWidget_ControlButton::SetupEvents( int delay, int index ) {
  354. AddEventAction( WIDGET_EVENT_SCROLL_LEFT ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, -1, delay, index );
  355. AddEventAction( WIDGET_EVENT_SCROLL_RIGHT ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, 1, delay, index );
  356. AddEventAction( WIDGET_EVENT_SCROLL_LEFT_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
  357. AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
  358. AddEventAction( WIDGET_EVENT_SCROLL_LEFT_LSTICK ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, -1, delay, index );
  359. AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_LSTICK ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, 1, delay, index );
  360. AddEventAction( WIDGET_EVENT_SCROLL_LEFT_LSTICK_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
  361. AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_LSTICK_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
  362. }
  363. //****************************************************************
  364. // SERVER BUTTON
  365. //****************************************************************
  366. /*
  367. ========================
  368. idMenuWidget_ServerButton::Update
  369. ========================
  370. */
  371. void idMenuWidget_ServerButton::Update() {
  372. if ( GetSprite() == NULL ) {
  373. return;
  374. }
  375. idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
  376. idSWFTextInstance * const txtName = spriteObject->GetNestedText( "label0", "txtVal" );
  377. if ( txtName != NULL ) {
  378. txtName->SetText( serverName );
  379. txtName->SetStrokeInfo( true, 0.75f, 1.75f );
  380. }
  381. // events
  382. spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
  383. spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
  384. idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
  385. if ( hitBox == NULL ) {
  386. hitBox = spriteObject;
  387. }
  388. hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
  389. hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
  390. }
  391. /*
  392. ========================
  393. idMenuWidget_ServerButton::SetButtonInfo
  394. ========================
  395. */
  396. void idMenuWidget_ServerButton::SetButtonInfo( idStr name_, idStrId mapName_, idStr modeName_, int index_, int players_, int maxPlayers_, bool joinable_, bool validMap_ ) {
  397. serverName = name_;
  398. index = index_;
  399. players = players_;
  400. maxPlayers = maxPlayers_;
  401. joinable = joinable_;
  402. validMap = validMap_;
  403. mapName = mapName_;
  404. modeName = modeName_;
  405. idStr desc;
  406. if ( index >= 0 ) {
  407. idStr playerVal = va( "%s %d/%d", idLocalization::GetString( "#str_02396" ), players, maxPlayers );
  408. idStr lobbyMapName = va( "%s %s", idLocalization::GetString( "#str_02045" ), mapName.GetLocalizedString() );
  409. idStr lobbyMode;
  410. if ( !modeName.IsEmpty() ) {
  411. lobbyMode = va( "%s %s", idLocalization::GetString( "#str_02044" ), modeName.c_str() );
  412. }
  413. desc = va( "%s %s %s", playerVal.c_str(), lobbyMapName.c_str(), lobbyMode.c_str() );
  414. }
  415. SetDescription( desc );
  416. }
  417. //****************************************************************
  418. // LOBBY BUTTON
  419. //****************************************************************
  420. /*
  421. ========================
  422. idMenuWidget_LobbyButton::Update
  423. ========================
  424. */
  425. void idMenuWidget_LobbyButton::Update() {
  426. if ( GetSprite() == NULL ) {
  427. return;
  428. }
  429. idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
  430. idSWFTextInstance * const txtName = spriteObject->GetNestedText( "itemName", "txtVal" );
  431. idSWFSpriteInstance * talkIcon = spriteObject->GetNestedSprite( "chaticon" );
  432. if ( txtName != NULL ) {
  433. txtName->SetText( name );
  434. }
  435. if ( talkIcon != NULL ) {
  436. talkIcon->StopFrame( voiceState + 1 );
  437. talkIcon->GetScriptObject()->Set( "onPress", new (TAG_SWF) WrapWidgetSWFEvent( this, WIDGET_EVENT_COMMAND, WIDGET_ACTION_MUTE_PLAYER ) );
  438. }
  439. // events
  440. spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
  441. spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
  442. idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
  443. if ( hitBox == NULL ) {
  444. hitBox = spriteObject;
  445. }
  446. hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
  447. hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
  448. }
  449. /*
  450. ========================
  451. idMenuWidget_LobbyButton::SetButtonInfo
  452. ========================
  453. */
  454. void idMenuWidget_LobbyButton::SetButtonInfo( idStr name_, voiceStateDisplay_t voiceState_ ) {
  455. name = name_;
  456. voiceState = voiceState_;
  457. }
  458. //****************************************************************
  459. // SCOREBOARD BUTTON
  460. //****************************************************************
  461. /*
  462. ========================
  463. idMenuWidget_ScoreboardButton::Update
  464. ========================
  465. */
  466. void idMenuWidget_ScoreboardButton::Update() {
  467. if ( GetSprite() == NULL ) {
  468. return;
  469. }
  470. if ( index == -1 ) {
  471. GetSprite()->SetVisible( false );
  472. return;
  473. }
  474. GetSprite()->SetVisible( true );
  475. idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
  476. for ( int val = 0; val < values.Num(); ++val ) {
  477. idSWFScriptObject * const textObject = spriteObject->GetNestedObj( va( "label%d", val ), "txtVal" );
  478. if ( textObject != NULL ) {
  479. idSWFTextInstance * const text = textObject->GetText();
  480. text->SetIgnoreColor( ignoreColor );
  481. text->tooltip = ignoreColor; // ignoreColor does double duty as "allow tooltips"
  482. text->SetText( values[ val ].c_str() );
  483. text->SetStrokeInfo( true, 0.75f, 2.0f );
  484. }
  485. }
  486. idSWFSpriteInstance * talkIcon = spriteObject->GetNestedSprite( "chaticon" );
  487. if ( talkIcon != NULL ) {
  488. talkIcon->StopFrame( voiceState + 1 );
  489. talkIcon->GetScriptObject()->Set( "onPress", new (TAG_SWF) WrapWidgetSWFEvent( this, WIDGET_EVENT_COMMAND, WIDGET_ACTION_MUTE_PLAYER ) );
  490. }
  491. // events
  492. spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
  493. spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
  494. idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
  495. if ( hitBox == NULL ) {
  496. hitBox = spriteObject;
  497. }
  498. hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
  499. hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
  500. }
  501. /*
  502. ========================
  503. idMenuWidget_ScoreboardButton::SetButtonInfo
  504. ========================
  505. */
  506. void idMenuWidget_ScoreboardButton::SetButtonInfo( int index_, idList< idStr > & list, voiceStateDisplay_t voiceState_ ) {
  507. index = index_;
  508. voiceState = voiceState_;
  509. SetValues( list );
  510. }