wwuiinput.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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/wwuiinput.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/08/02 8:41p $*
  29. * *
  30. * $Revision:: 7 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "wwuiinput.h"
  36. #include "dialogmgr.h"
  37. #include "wwmemlog.h"
  38. WWUIInputClass::WWUIInputClass(void) :
  39. mIMEManager(NULL)
  40. {
  41. }
  42. WWUIInputClass::~WWUIInputClass(void)
  43. {
  44. if (mIMEManager) {
  45. mIMEManager->Release_Ref();
  46. }
  47. }
  48. void WWUIInputClass::InitIME(HWND hwnd)
  49. {
  50. if (mIMEManager == NULL) {
  51. mIMEManager = IME::IMEManager::Create(hwnd);
  52. if (mIMEManager) {
  53. Observer<IME::UnicodeChar>::NotifyMe(*mIMEManager);
  54. Observer<IME::IMEEvent>::NotifyMe(*mIMEManager);
  55. }
  56. }
  57. }
  58. IME::IMEManager* WWUIInputClass::GetIME(void) const
  59. {
  60. if (mIMEManager) {
  61. mIMEManager->Add_Ref();
  62. }
  63. return mIMEManager;
  64. }
  65. bool WWUIInputClass::ProcessMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& result)
  66. {
  67. WWMEMLOG(MEM_GAMEDATA);
  68. if (mIMEManager) {
  69. if (mIMEManager->ProcessMessage(hwnd, msg, wParam, lParam, result)) {
  70. return true;
  71. }
  72. }
  73. result = 0;
  74. switch (msg) {
  75. case WM_KEYDOWN:
  76. return DialogMgrClass::On_Key_Down(wParam, lParam);
  77. break;
  78. case WM_KEYUP:
  79. return DialogMgrClass::On_Key_Up(wParam);
  80. break;
  81. case WM_CHAR:
  82. DialogMgrClass::On_Unicode_Char((wchar_t)wParam);
  83. return true;
  84. break;
  85. default:
  86. break;
  87. }
  88. return false;
  89. }
  90. void WWUIInputClass::HandleNotification(IME::UnicodeChar& unicode)
  91. {
  92. DialogMgrClass::On_Unicode_Char(unicode.Subject());
  93. }
  94. void WWUIInputClass::HandleNotification(IME::IMEEvent& event)
  95. {
  96. if (IME::IME_LANGUAGECHANGED == event.GetAction())
  97. {
  98. const wchar_t* description = event.Subject()->GetDescription();
  99. DialogMgrClass::Show_IME_Message(description, 2500);
  100. }
  101. else if (IME::IME_GUIDELINE == event.GetAction())
  102. {
  103. wchar_t desc[255];
  104. unsigned long level = event.Subject()->GetGuideline(desc, sizeof(desc));
  105. if (GL_LEVEL_NOGUIDELINE != level)
  106. {
  107. DialogMgrClass::Show_IME_Message(desc, 30000);
  108. }
  109. }
  110. }