dialogmgr.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program 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. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/wwui/dialogmgr.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 2/05/02 1:04p $*
  29. * *
  30. * $Revision:: 40 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dialogmgr.h"
  36. #include "dialogbase.h"
  37. #include "childdialog.h"
  38. #include "dx8wrapper.h"
  39. #include "assetmgr.h"
  40. #include "rinfo.h"
  41. #include "camera.h"
  42. #include "mousemgr.h"
  43. #include "tooltipmgr.h"
  44. #include "stylemgr.h"
  45. #include "dialogcontrol.h"
  46. #include "menudialog.h"
  47. #include "wwuiinput.h"
  48. #include "wwmemlog.h"
  49. #include "dialogtransition.h"
  50. #include "systimer.h"
  51. #include "tooltip.h"
  52. ////////////////////////////////////////////////////////////////
  53. // Static member initialization
  54. ////////////////////////////////////////////////////////////////
  55. DynamicVectorClass<DialogBaseClass *> DialogMgrClass::DialogList;
  56. DialogBaseClass ** DialogMgrClass::TestArray;
  57. int DialogMgrClass::TestArrayCount;
  58. int DialogMgrClass::TestArrayMaxCount;
  59. bool DialogMgrClass::IsFirstRender = false;
  60. bool DialogMgrClass::IsInMenuMode = false;
  61. DialogBaseClass * DialogMgrClass::ActiveDialog = NULL;
  62. BYTE DialogMgrClass::KeyboardState[256];
  63. DialogControlClass * DialogMgrClass::InputCapture = NULL;
  64. DialogControlClass * DialogMgrClass::FocusControl = NULL;
  65. WWUIInputClass * DialogMgrClass::Input = NULL;
  66. DialogTransitionClass * DialogMgrClass::Transition = NULL;
  67. DialogBaseClass * DialogMgrClass::PendingActiveDialog = NULL;
  68. DialogBaseClass * DialogMgrClass::TransitionDialog = NULL;
  69. uint32 DialogMgrClass::CurrTime = 0;
  70. uint32 DialogMgrClass::LastFrameTime = 0;
  71. Vector3 DialogMgrClass::LastMousePos (0, 0, 0);
  72. bool DialogMgrClass::LastMouseButtonState[MB_COUNT] = { 0 };
  73. bool DialogMgrClass::IsFlushing = false;
  74. ToolTipClass* DialogMgrClass::mIMEMessage = NULL;
  75. uint32 DialogMgrClass::mIMEMessageTime = 0;
  76. static bool GameWasInFocus;
  77. ////////////////////////////////////////////////////////////////
  78. //
  79. // Initialize
  80. //
  81. ////////////////////////////////////////////////////////////////
  82. void
  83. DialogMgrClass::Initialize (const char *stylemgr_ini)
  84. {
  85. StyleMgrClass::Initialize_From_INI (stylemgr_ini);
  86. MouseMgrClass::Initialize ();
  87. ToolTipMgrClass::Initialize ();
  88. MenuDialogClass::Initialize ();
  89. ::memset (KeyboardState, 0, sizeof (KeyboardState));
  90. TestArrayMaxCount = 0;
  91. return ;
  92. }
  93. ////////////////////////////////////////////////////////////////
  94. //
  95. // Shutdown
  96. //
  97. ////////////////////////////////////////////////////////////////
  98. void
  99. DialogMgrClass::Shutdown (void)
  100. {
  101. //
  102. // Remove all the dialogs from our list
  103. //
  104. Flush_Dialogs ();
  105. MenuDialogClass::Shutdown ();
  106. StyleMgrClass::Shutdown ();
  107. MouseMgrClass::Shutdown ();
  108. ToolTipMgrClass::Shutdown ();
  109. Set_Active_Dialog (NULL);
  110. delete[] TestArray;
  111. TestArray=NULL;
  112. if (mIMEMessage) {
  113. delete mIMEMessage;
  114. mIMEMessage = NULL;
  115. mIMEMessageTime = 0;
  116. }
  117. //
  118. // Release our hold on the input mechanism
  119. //
  120. REF_PTR_RELEASE (Input);
  121. return ;
  122. }
  123. ////////////////////////////////////////////////////////////////
  124. //
  125. // Reset_Inputs
  126. //
  127. ////////////////////////////////////////////////////////////////
  128. void
  129. DialogMgrClass::Reset_Inputs (void)
  130. {
  131. //
  132. // Update the cached mouse button states
  133. //
  134. LastMouseButtonState[MB_LBUTTON] = Input->Is_Button_Down (VK_LBUTTON);
  135. LastMouseButtonState[MB_MBUTTON] = Input->Is_Button_Down (VK_MBUTTON);
  136. LastMouseButtonState[MB_RBUTTON] = Input->Is_Button_Down (VK_RBUTTON);
  137. return ;
  138. }
  139. ////////////////////////////////////////////////////////////////
  140. //
  141. // Register_Dialog
  142. //
  143. ////////////////////////////////////////////////////////////////
  144. void
  145. DialogMgrClass::Register_Dialog (DialogBaseClass *dialog)
  146. {
  147. //
  148. // Check to see if this dialog is already in our list
  149. //
  150. if (DialogList.ID (dialog) == -1) {
  151. Reset_Inputs ();
  152. //
  153. // Keep a lock on the dialog
  154. //
  155. dialog->Add_Ref ();
  156. //
  157. // Add the dialog to our list. Note: We keep popup dialogs
  158. // as the topmost windows in our z order. Z order is determined
  159. // by the order in the list.
  160. //
  161. bool is_top_level = true;
  162. if (dialog->As_PopupDialogClass () == NULL) {
  163. int new_index = DialogList.Count () - 1;
  164. for (; new_index >= 0; new_index --) {
  165. if (DialogList[new_index]->As_PopupDialogClass () == NULL) {
  166. break;
  167. }
  168. is_top_level = false;
  169. }
  170. DialogList.Insert (new_index + 1, dialog);
  171. } else {
  172. DialogList.Add (dialog);
  173. }
  174. //
  175. // Make this the active dialog
  176. //
  177. if (is_top_level && dialog->Wants_Activation ()) {
  178. Set_Active_Dialog (dialog);
  179. }
  180. //
  181. // Update the framework
  182. //
  183. On_Dialog_Added ();
  184. //
  185. // Handle the first dialog...
  186. //
  187. if (DialogList.Count () == 1) {
  188. MouseMgrClass::Show_Cursor (true);
  189. IsFirstRender = true;
  190. }
  191. }
  192. return ;
  193. }
  194. ////////////////////////////////////////////////////////////////
  195. //
  196. // UnRegister_Dialog
  197. //
  198. ////////////////////////////////////////////////////////////////
  199. void
  200. DialogMgrClass::UnRegister_Dialog (DialogBaseClass *dialog)
  201. {
  202. //
  203. // Is this dialog in our list?
  204. //
  205. int index = DialogList.ID (dialog);
  206. if (index != -1) {
  207. Reset_Inputs ();
  208. //
  209. // Remove the dialog from our list
  210. //
  211. DialogList.Delete (index);
  212. REF_PTR_RELEASE (dialog);
  213. //
  214. // Update the framework
  215. //
  216. On_Dialog_Removed ();
  217. }
  218. return ;
  219. }
  220. ////////////////////////////////////////////////////////////////
  221. //
  222. // On_Dialog_Added
  223. //
  224. ////////////////////////////////////////////////////////////////
  225. void
  226. DialogMgrClass::On_Dialog_Added (void)
  227. {
  228. //
  229. // Center the mouse in the window
  230. //
  231. #if (0)
  232. HWND wnd = (HWND)WW3D::Get_Window ();
  233. RECT rect = { 0 };
  234. ::GetClientRect (wnd, &rect);
  235. #endif //(0)
  236. /*Vector3 mouse_pos = Get_Mouse_Pos ();
  237. mouse_pos.X = rect.left + (rect.right - rect.left) / 2;
  238. mouse_pos.Y = rect.top + (rect.bottom - rect.top) / 2;
  239. Set_Mouse_Pos (mouse_pos);*/
  240. return ;
  241. }
  242. ////////////////////////////////////////////////////////////////
  243. //
  244. // On_Dialog_Removed
  245. //
  246. ////////////////////////////////////////////////////////////////
  247. void
  248. DialogMgrClass::On_Dialog_Removed (void)
  249. {
  250. //
  251. // Are there any dialogs left?
  252. //
  253. if (DialogList.Count () == 0) {
  254. //
  255. // Revert from "dialog" mode.
  256. //
  257. MouseMgrClass::Show_Cursor (false);
  258. Set_Active_Dialog (NULL);
  259. } else if (IsFlushing == false) {
  260. //
  261. // Force "focus" to go to the most recent dialog
  262. //
  263. int index = DialogList.Count ();
  264. while (index --) {
  265. if (DialogList[index]->Wants_Activation ()) {
  266. Set_Active_Dialog (DialogList[index]);
  267. break;
  268. }
  269. }
  270. }
  271. return ;
  272. }
  273. ////////////////////////////////////////////////////////////////
  274. //
  275. // Update_Transition
  276. //
  277. ////////////////////////////////////////////////////////////////
  278. void
  279. DialogMgrClass::Update_Transition (void)
  280. {
  281. if (Transition != NULL) {
  282. //
  283. // Allow the transition to think
  284. //
  285. Transition->On_Frame_Update ();
  286. Transition->Render ();
  287. //
  288. // Did the transition finish?
  289. //
  290. if (Transition->Is_Complete ()) {
  291. //
  292. // Let the dialog controls be displayed (as necessary)
  293. //
  294. if (TransitionDialog != NULL) {
  295. TransitionDialog->Set_Controls_Hidden (false);
  296. }
  297. if (PendingActiveDialog != NULL) {
  298. PendingActiveDialog->Set_Controls_Hidden (false);
  299. }
  300. //
  301. // Now make the pending dialog active
  302. //
  303. Internal_Set_Active_Dialog (PendingActiveDialog);
  304. PendingActiveDialog = NULL;
  305. TransitionDialog = NULL;
  306. //
  307. // Release our hold on the transition
  308. //
  309. REF_PTR_RELEASE (Transition);
  310. }
  311. }
  312. return ;
  313. }
  314. ////////////////////////////////////////////////////////////////
  315. //
  316. // On_Frame_Update
  317. //
  318. ////////////////////////////////////////////////////////////////
  319. void
  320. DialogMgrClass::On_Frame_Update (void)
  321. {
  322. WWMEMLOG(MEM_GAMEDATA);
  323. //
  324. // Update the timing
  325. //
  326. uint32 old_time = CurrTime;
  327. CurrTime = TIMEGETTIME ();
  328. LastFrameTime = CurrTime - old_time;
  329. // DynamicVectorClass<DialogBaseClass *> test_list = DialogList;
  330. if (DialogList.Count()>TestArrayMaxCount) {
  331. delete[] TestArray;
  332. TestArrayMaxCount=DialogList.Count();
  333. TestArray=new DialogBaseClass*[TestArrayMaxCount];
  334. }
  335. TestArrayCount=DialogList.Count();
  336. for (int i=0;i<TestArrayCount;++i) {
  337. TestArray[i]=DialogList[i];
  338. }
  339. //
  340. // Let each dialog think
  341. //
  342. for (int index = 0; index < DialogList.Count (); index ++) {
  343. //
  344. // Simple check to ensure that the DialogList hasn't changed
  345. // due to this On_Frame_Update () call
  346. //
  347. if (index >= TestArrayCount || DialogList[index] != TestArray[index]) {
  348. break;
  349. }
  350. DialogBaseClass* dialog = DialogList[index];
  351. WWASSERT(dialog != NULL);
  352. dialog->Add_Ref();
  353. if (dialog->Is_Active () && dialog->As_ChildDialogClass () == NULL) {
  354. dialog->On_Frame_Update ();
  355. }
  356. //
  357. // Force an "On_Periodic" for dialogs that aren't in focus...
  358. //
  359. dialog->On_Periodic ();
  360. dialog->Release_Ref();
  361. }
  362. //
  363. // Return from "dialog" mode if the ESC key has been let up...
  364. //
  365. if (IsInMenuMode && DialogList.Count () == 0 && ((KeyboardState[VK_ESCAPE] & 0x80) == 0)) {
  366. IsInMenuMode = false;
  367. Input->Exit_Menu_Mode ();
  368. }
  369. return ;
  370. }
  371. ////////////////////////////////////////////////////////////////
  372. //
  373. // Render
  374. //
  375. ////////////////////////////////////////////////////////////////
  376. void
  377. DialogMgrClass::Render (void)
  378. {
  379. WWMEMLOG(MEM_GAMEDATA);
  380. if (!GameInFocus) {
  381. GameWasInFocus=false;
  382. return;
  383. }
  384. if (!GameWasInFocus) {
  385. DialogMgrClass::Reset();
  386. GameWasInFocus=true;
  387. }
  388. //
  389. // Enable static sorting levels
  390. //
  391. bool enable_static_sort = WW3D::Are_Static_Sort_Lists_Enabled ();
  392. WW3D::Enable_Static_Sort_Lists (true);
  393. //
  394. // Enable the "console" mode if this is the first dialog
  395. // we're rendering
  396. //
  397. if (IsFirstRender) {
  398. IsFirstRender = false;
  399. IsInMenuMode = true;
  400. Input->Enter_Menu_Mode ();
  401. }
  402. //
  403. // Update any transitions
  404. //
  405. Update_Transition ();
  406. //
  407. // Render each dialog
  408. //
  409. for (int index = 0; index < DialogList.Count (); index ++) {
  410. bool render = false;
  411. //
  412. // Should this dialog be rendered?
  413. //
  414. DialogBaseClass *dialog = DialogList[index];
  415. if ( dialog->Is_Visible () /*&&
  416. dialog != PendingActiveDialog &&
  417. dialog != TransitionOutDialog*/ )
  418. {
  419. //
  420. // Don't render here if its a child-dialog
  421. //
  422. render = (dialog->As_ChildDialogClass () == NULL);
  423. }
  424. //
  425. // Render the dialog
  426. //
  427. if (render) {
  428. dialog->Render ();
  429. }
  430. }
  431. //
  432. // Render the tooltip
  433. //
  434. Vector3 cursor_pos = Get_Mouse_Pos ();
  435. ToolTipMgrClass::Update (Vector2 (cursor_pos.X, cursor_pos.Y));
  436. ToolTipMgrClass::Render ();
  437. if ((mIMEMessageTime > CurrTime) && mIMEMessage) {
  438. mIMEMessage->Render();
  439. }
  440. //
  441. // Render the mouse cursor
  442. //
  443. MouseMgrClass::Render ();
  444. //
  445. // Update the cached mouse button states
  446. //
  447. Reset_Inputs ();
  448. //
  449. // Put the static sort flag back the way we found it
  450. //
  451. WW3D::Enable_Static_Sort_Lists (enable_static_sort);
  452. return ;
  453. }
  454. ////////////////////////////////////////////////////////////////
  455. //
  456. // Set_Active_Dialog
  457. //
  458. ////////////////////////////////////////////////////////////////
  459. void
  460. DialogMgrClass::Set_Active_Dialog (DialogBaseClass *dialog)
  461. {
  462. if (ActiveDialog == dialog) {
  463. return ;
  464. }
  465. //REF_PTR_RELEASE (Transition);
  466. if (Transition != NULL) {
  467. PendingActiveDialog = dialog;
  468. return ;
  469. }
  470. //
  471. // Check to see if we should play an outro-transition for
  472. // the currently active dialog
  473. //
  474. if (ActiveDialog != NULL) {
  475. Transition = ActiveDialog->Get_Transition_Out (dialog);
  476. if (Transition != NULL) {
  477. PendingActiveDialog = dialog;
  478. TransitionDialog = ActiveDialog;
  479. //
  480. // Hide the controls on the pending dialog (if necessary)
  481. //
  482. if (PendingActiveDialog != NULL) {
  483. //PendingActiveDialog->Set_Controls_Hidden (true);
  484. }
  485. }
  486. }
  487. //
  488. // Check to see if we should play an intro-transition for
  489. // the new active dialog
  490. //
  491. if (dialog != NULL && Transition == NULL) {
  492. Transition = dialog->Get_Transition_In (ActiveDialog);
  493. if (Transition != NULL) {
  494. PendingActiveDialog = dialog;
  495. TransitionDialog = dialog;
  496. //
  497. // Hide the controls on the transitioning dialog
  498. //
  499. //TransitionDialog->Set_Controls_Hidden (true);
  500. }
  501. }
  502. //
  503. // If we don't have any transition to play, then simply
  504. // set the active dialog
  505. //
  506. if (Transition == NULL) {
  507. Internal_Set_Active_Dialog (dialog);
  508. }
  509. return ;
  510. }
  511. void
  512. DialogMgrClass::Reset (void)
  513. {
  514. // REF_PTR_RELEASE (Transition);
  515. // if (PendingActiveDialog) {
  516. // REF_PTR_SET(ActiveDialog,PendingActiveDialog);
  517. // REF_PTR_RELEASE(PendingActiveDialog);
  518. // }
  519. // Internal_Set_Active_Dialog (ActiveDialog);
  520. if (ActiveDialog) {
  521. ActiveDialog->Set_Dirty();
  522. }
  523. if (PendingActiveDialog) {
  524. PendingActiveDialog->Set_Dirty();
  525. }
  526. }
  527. ////////////////////////////////////////////////////////////////
  528. //
  529. // Internal_Set_Active_Dialog
  530. //
  531. ////////////////////////////////////////////////////////////////
  532. void
  533. DialogMgrClass::Internal_Set_Active_Dialog (DialogBaseClass *dialog)
  534. {
  535. //
  536. // Get rid of the input capture and focus
  537. //
  538. Release_Capture ();
  539. //
  540. // Switch the active dialog
  541. //
  542. DialogBaseClass *old_dialog = ActiveDialog;
  543. ActiveDialog = dialog;
  544. //
  545. // Notify the old dialog
  546. //
  547. if (old_dialog != NULL) {
  548. old_dialog->On_Activate (false);
  549. REF_PTR_RELEASE (old_dialog);
  550. }
  551. Set_Focus (NULL);
  552. //
  553. // Notify the new dialog (if necessary)
  554. //
  555. if (ActiveDialog != NULL) {
  556. ActiveDialog->Add_Ref ();
  557. ActiveDialog->On_Activate (true);
  558. }
  559. //
  560. // Remove any tooltips
  561. //
  562. ToolTipMgrClass::Reset ();
  563. return ;
  564. }
  565. ////////////////////////////////////////////////////////////////
  566. //
  567. // On_Key_Down
  568. //
  569. ////////////////////////////////////////////////////////////////
  570. bool
  571. DialogMgrClass::On_Key_Down (uint32 key_id, uint32 key_data)
  572. {
  573. if (Transition != NULL) {
  574. return false;
  575. }
  576. //
  577. // Update the keyboard state
  578. //
  579. ::GetKeyboardState (KeyboardState);
  580. //
  581. // Notify the active dialog (if any)
  582. //
  583. if (ActiveDialog != NULL) {
  584. return ActiveDialog->On_Key_Down (key_id, key_data);
  585. }
  586. return false;
  587. }
  588. ////////////////////////////////////////////////////////////////
  589. //
  590. // On_Key_Up
  591. //
  592. ////////////////////////////////////////////////////////////////
  593. bool
  594. DialogMgrClass::On_Key_Up (uint32 key_id)
  595. {
  596. if (Transition != NULL) {
  597. return false;
  598. }
  599. //
  600. // Update the keyboard state
  601. //
  602. ::GetKeyboardState (KeyboardState);
  603. //
  604. // Notify the active dialog (if any)
  605. //
  606. if (ActiveDialog != NULL) {
  607. return ActiveDialog->On_Key_Up (key_id);
  608. }
  609. return false;
  610. }
  611. ////////////////////////////////////////////////////////////////
  612. //
  613. // On_Unicode_Char
  614. //
  615. ////////////////////////////////////////////////////////////////
  616. void
  617. DialogMgrClass::On_Unicode_Char (uint16 unicode)
  618. {
  619. if (Transition != NULL) {
  620. return ;
  621. }
  622. //
  623. // Update the keyboard state
  624. //
  625. ::GetKeyboardState (KeyboardState);
  626. //
  627. // Notify the active dialog (if any)
  628. //
  629. if (ActiveDialog != NULL) {
  630. ActiveDialog->On_Unicode_Char (unicode);
  631. }
  632. return ;
  633. }
  634. ////////////////////////////////////////////////////////////////
  635. //
  636. // Find_Control
  637. //
  638. ////////////////////////////////////////////////////////////////
  639. DialogControlClass *
  640. DialogMgrClass::Find_Control (const Vector2 &mouse_pos)
  641. {
  642. DialogControlClass *retval = NULL;
  643. //
  644. // Get this information from the active dialog
  645. //
  646. if (ActiveDialog != NULL) {
  647. retval = ActiveDialog->Find_Control (mouse_pos);
  648. }
  649. return retval;
  650. }
  651. ////////////////////////////////////////////////////////////////
  652. //
  653. // Set_Capture
  654. //
  655. ////////////////////////////////////////////////////////////////
  656. void
  657. DialogMgrClass::Set_Capture (DialogControlClass *control)
  658. {
  659. InputCapture = control;
  660. return ;
  661. }
  662. ////////////////////////////////////////////////////////////////
  663. //
  664. // Release_Capture
  665. //
  666. ////////////////////////////////////////////////////////////////
  667. void
  668. DialogMgrClass::Release_Capture (void)
  669. {
  670. InputCapture = NULL;
  671. return ;
  672. }
  673. ////////////////////////////////////////////////////////////////
  674. //
  675. // Flush_Dialogs
  676. //
  677. ////////////////////////////////////////////////////////////////
  678. void
  679. DialogMgrClass::Flush_Dialogs (void)
  680. {
  681. WWDEBUG_SAY(("DialogMgrClass: Flushing dialogs\n"));
  682. IsFlushing = true;
  683. Set_Active_Dialog (NULL);
  684. //
  685. // Remove all the dialogs from our list
  686. //
  687. while (DialogList.Count () > 0) {
  688. DialogList[DialogList.Count () - 1]->End_Dialog ();
  689. }
  690. Set_Focus (NULL);
  691. //
  692. // Reset our transition variables
  693. //
  694. TransitionDialog = NULL;
  695. PendingActiveDialog = NULL;
  696. REF_PTR_RELEASE (Transition);
  697. //
  698. // Release our hold on the transitioning dialogs
  699. //
  700. //REF_PTR_RELEASE (TransitionInDialog);
  701. //REF_PTR_RELEASE (TransitionOutDialog);
  702. //
  703. // Reset the list
  704. //
  705. DialogList.Delete_All ();
  706. IsFlushing = false;
  707. WWDEBUG_SAY(("DialogMgrClass: Flush complete\n"));
  708. return ;
  709. }
  710. bool DialogMgrClass::Is_Flushing_Dialogs(void)
  711. {
  712. return IsFlushing;
  713. }
  714. ////////////////////////////////////////////////////////////////
  715. //
  716. // Was_Button_Down
  717. //
  718. ////////////////////////////////////////////////////////////////
  719. bool
  720. DialogMgrClass::Was_Button_Down (int vk_mouse_button_id)
  721. {
  722. bool retval = false;
  723. switch (vk_mouse_button_id)
  724. {
  725. case VK_LBUTTON:
  726. retval = LastMouseButtonState[MB_LBUTTON];
  727. break;
  728. case VK_MBUTTON:
  729. retval = LastMouseButtonState[MB_MBUTTON];
  730. break;
  731. case VK_RBUTTON:
  732. retval = LastMouseButtonState[MB_RBUTTON];
  733. break;
  734. }
  735. return retval;
  736. }
  737. ////////////////////////////////////////////////////////////////
  738. //
  739. // Set_Focus
  740. //
  741. ////////////////////////////////////////////////////////////////
  742. void
  743. DialogMgrClass::Set_Focus (DialogControlClass *control)
  744. {
  745. if (FocusControl == control) {
  746. return ;
  747. }
  748. //
  749. // Change the focus
  750. //
  751. DialogControlClass *old_focus_ctrl = FocusControl;
  752. FocusControl = control;
  753. //
  754. // Let go of the currently focus'd control
  755. //
  756. if (old_focus_ctrl != NULL) {
  757. old_focus_ctrl->On_Kill_Focus (control);
  758. }
  759. //
  760. // Reset the focus
  761. //
  762. if (FocusControl != NULL) {
  763. FocusControl->On_Set_Focus ();
  764. }
  765. //
  766. // Remove the input capture
  767. //
  768. Release_Capture ();
  769. return ;
  770. }
  771. DialogBaseClass* DialogMgrClass::Find_Dialog(int dialogID)
  772. {
  773. for (int index = 0; index < DialogList.Count(); ++index) {
  774. if (DialogList[index]->Get_Dlg_ID() == dialogID) {
  775. return DialogList[index];
  776. }
  777. }
  778. return NULL;
  779. }
  780. ////////////////////////////////////////////////////////////////
  781. //
  782. // Rollback
  783. //
  784. ////////////////////////////////////////////////////////////////
  785. void
  786. DialogMgrClass::Rollback (DialogBaseClass *dialog)
  787. {
  788. for (int index = DialogList.Count () - 1; index >= 0; index --) {
  789. //
  790. // Stop once we've come across the dialog we're rolling back to
  791. //
  792. if (DialogList[index] == dialog) {
  793. break;
  794. }
  795. //
  796. // Close this dialog (if necessary)
  797. //
  798. if (DialogList[index]->As_ChildDialogClass () == NULL) {
  799. DialogList[index]->End_Dialog ();
  800. }
  801. }
  802. return ;
  803. }
  804. void DialogMgrClass::Show_IME_Message(const wchar_t* message, uint32 duration)
  805. {
  806. if (mIMEMessage == NULL) {
  807. mIMEMessage = new ToolTipClass;
  808. }
  809. if (mIMEMessage) {
  810. mIMEMessage->Set_Position(Vector2(10,10));
  811. mIMEMessage->Set_Text(message);
  812. mIMEMessageTime = (CurrTime + duration);
  813. }
  814. }