subtitle.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. *
  20. * FILE
  21. * $Archive: /Commando/Code/BinkMovie/subtitle.cpp $
  22. *
  23. * DESCRIPTION
  24. * Subtitling support.
  25. *
  26. * PROGRAMMER
  27. * Denzil E. Long, Jr.
  28. *
  29. * VERSION INFO
  30. * $Author: Denzil_l $
  31. * $Modtime: 1/15/02 8:48p $
  32. * $Revision: 2 $
  33. *
  34. ****************************************************************************/
  35. #include "always.h"
  36. #include "subtitle.h"
  37. /******************************************************************************
  38. *
  39. * NAME
  40. * SubTitleClass::SubTitleClass
  41. *
  42. * DESCRIPTION
  43. *
  44. * INPUTS
  45. * NONE
  46. *
  47. * RESULTS
  48. * NONE
  49. *
  50. ******************************************************************************/
  51. SubTitleClass::SubTitleClass()
  52. :
  53. mTimeStamp(0),
  54. mDuration(20 * 60),
  55. mRGBColor(0x00FFFFFF),
  56. mLinePosition(15),
  57. mAlignment(Center),
  58. mCaption(NULL)
  59. {
  60. }
  61. /******************************************************************************
  62. *
  63. * NAME
  64. * SubTitleClass::~SubTitleClass
  65. *
  66. * DESCRIPTION
  67. *
  68. * INPUTS
  69. * NONE
  70. *
  71. * RESULTS
  72. * NONE
  73. *
  74. ******************************************************************************/
  75. SubTitleClass::~SubTitleClass()
  76. {
  77. if (mCaption != NULL) {
  78. delete[] mCaption;
  79. }
  80. }
  81. /******************************************************************************
  82. *
  83. * NAME
  84. * SubTitleClass::SetRGBColor
  85. *
  86. * DESCRIPTION
  87. * Set the color the subtitle caption should be displayed in.
  88. *
  89. * INPUTS
  90. * unsigned char red
  91. * unsigned char green
  92. * unsigned char blue
  93. *
  94. * RESULTS
  95. * NONE
  96. *
  97. ******************************************************************************/
  98. void SubTitleClass::Set_RGB_Color(
  99. unsigned char red,
  100. unsigned char green,
  101. unsigned char blue)
  102. {
  103. // Combine components as 8:8:8
  104. mRGBColor = (
  105. ((unsigned long)red << 16) |
  106. ((unsigned long)green << 8) |
  107. (unsigned long)blue);
  108. }
  109. /******************************************************************************
  110. *
  111. * NAME
  112. * SubTitleClass::SetCaption
  113. *
  114. * DESCRIPTION
  115. * Set the caption text
  116. *
  117. * INPUTS
  118. * Caption - Caption string
  119. *
  120. * RESULTS
  121. * NONE
  122. *
  123. ******************************************************************************/
  124. void SubTitleClass::Set_Caption(wchar_t* string)
  125. {
  126. // Release existing caption
  127. if (mCaption != NULL) {
  128. delete[] mCaption;
  129. mCaption = NULL;
  130. }
  131. // Make a copy of caption
  132. if (string != NULL) {
  133. unsigned int length = wcslen(string);
  134. mCaption = new wchar_t[length + 1];
  135. WWASSERT(mCaption != NULL);
  136. if (mCaption != NULL) {
  137. wcscpy(mCaption, string);
  138. }
  139. }
  140. }