dlgcredits.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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/commando/dlgcredits.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/27/02 11:33a $*
  29. * *
  30. * $Revision:: 5 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dlgcredits.h"
  36. #include "wwfile.h"
  37. #include "ffactory.h"
  38. ////////////////////////////////////////////////////////////////
  39. //
  40. // CreditsMenuClass
  41. //
  42. ////////////////////////////////////////////////////////////////
  43. CreditsMenuClass::CreditsMenuClass (void) :
  44. MenuDialogClass (IDD_OPTIONS_CREDITS)
  45. {
  46. return ;
  47. }
  48. ////////////////////////////////////////////////////////////////
  49. //
  50. // On_Init_Dialog
  51. //
  52. ////////////////////////////////////////////////////////////////
  53. void
  54. CreditsMenuClass::On_Init_Dialog (void)
  55. {
  56. const char *CREDITS_TXT_FILENAME = "credits.txt";
  57. //
  58. // Open the text file
  59. //
  60. FileClass *credits_txt_file = _TheFileFactory->Get_File (CREDITS_TXT_FILENAME);
  61. if (credits_txt_file != NULL && credits_txt_file->Is_Available ()) {
  62. if (credits_txt_file->Open ()) {
  63. //
  64. // Read the data from the file
  65. //
  66. int size = credits_txt_file->Size ();
  67. StringClass ascii_text;
  68. credits_txt_file->Read (ascii_text.Get_Buffer (size + 1), size);
  69. ascii_text.Peek_Buffer ()[size] = 0;
  70. //
  71. // Convert the text to wide character format and
  72. // strip off any carriage-returns
  73. //
  74. WideStringClass wide_text;
  75. WCHAR *buffer = wide_text.Get_Buffer (size + 1);
  76. int dest_index = 0;
  77. int len = ascii_text.Get_Length ();
  78. for (int index = 0; index < len; index ++) {
  79. if (ascii_text[index] != '\r') {
  80. buffer[dest_index ++] = (unsigned char)ascii_text[index];
  81. }
  82. }
  83. buffer[dest_index] = 0;
  84. //
  85. // Put the text into the control
  86. //
  87. Set_Dlg_Item_Text (IDC_CREDITS_EDIT, wide_text);
  88. }
  89. //
  90. // Close the text file
  91. //
  92. _TheFileFactory->Return_File (credits_txt_file);
  93. }
  94. MenuDialogClass::On_Init_Dialog ();
  95. return ;
  96. }
  97. ////////////////////////////////////////////////////////////////
  98. //
  99. // On_Command
  100. //
  101. ////////////////////////////////////////////////////////////////
  102. void
  103. CreditsMenuClass::On_Command (int ctrl_id, int message_id, DWORD param)
  104. {
  105. MenuDialogClass::On_Command (ctrl_id, message_id, param);
  106. return ;
  107. }