PROGRESS.H 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. /* $Header: /Commando/Code/Tools/max2w3d/PROGRESS.H 5 10/28/97 6:08p Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando / G 3D engine *
  24. * *
  25. * File Name : PROGRESS.H *
  26. * *
  27. * Programmer : James McNeil *
  28. * *
  29. * Start Date : 06/19/97 *
  30. * *
  31. * Last Update : June 19, 1997 [GH] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef PROGRESS_H
  37. #define PROGRESS_H
  38. #include "always.h"
  39. class Progress_Meter_Class
  40. {
  41. public:
  42. Progress_Meter_Class
  43. (
  44. Interface * gi,
  45. float base,
  46. float range
  47. ):
  48. Max ( gi ),
  49. Base ( base ),
  50. Range ( range ),
  51. Amount_Done ( 0.0f ),
  52. Increment ( 0.0f ),
  53. Accum( 0.0f ),
  54. Cancel_Requested ( FALSE )
  55. {
  56. }
  57. Progress_Meter_Class ( Progress_Meter_Class & other, float sub_amount ):
  58. Max ( other.Max ),
  59. Base ( other.Base + other.Amount_Done * other.Range ),
  60. Range ( other.Range * sub_amount ),
  61. Amount_Done ( 0.0f ),
  62. Increment ( 0.0f ),
  63. Accum ( other.Accum ),
  64. Cancel_Requested ( other.Cancel_Requested )
  65. {
  66. }
  67. void Finish_In_Steps ( int number_of_steps )
  68. {
  69. Increment = (1.0f - Amount_Done) / number_of_steps;
  70. }
  71. void Add_Increment ()
  72. {
  73. Set_Amount_Done ( Amount_Done + Increment );
  74. }
  75. void Set_Amount_Done ( float percentage )
  76. {
  77. Accum += percentage;
  78. Amount_Done = percentage;
  79. if (Accum > 0.01f) {
  80. Max->ProgressUpdate ( (int) (Amount_Done * Range + Base) );
  81. Accum = 0.0f;
  82. }
  83. if (Max->GetCancel())
  84. {
  85. int choice = MessageBox
  86. (
  87. Max->GetMAXHWnd(),
  88. _T("Do you really want to cancel the export?"),
  89. _T("Cancel Export?"), MB_ICONQUESTION | MB_YESNO
  90. );
  91. if ( choice == IDYES )
  92. Cancel_Requested = TRUE;
  93. else
  94. Max->SetCancel ( FALSE );
  95. }
  96. }
  97. BOOL Cancelled () { return Cancel_Requested; }
  98. float Increment;
  99. private:
  100. Interface * Max;
  101. float Base;
  102. float Range;
  103. float Amount_Done;
  104. float Accum;
  105. BOOL Cancel_Requested;
  106. };
  107. #endif /* PROGRESS_H */