ImageErrorProc.cpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. // FILE: ImageErrorProc.cpp ///////////////////////////////////////////////////
  19. //-----------------------------------------------------------------------------
  20. //
  21. // Westwood Studios Pacific.
  22. //
  23. // Confidential Information
  24. // Copyright (C) 2001 - All Rights Reserved
  25. //
  26. //-----------------------------------------------------------------------------
  27. //
  28. // Project: ImagePacker
  29. //
  30. // File name: ImageErrorProc.cpp
  31. //
  32. // Created: Colin Day, August 2001
  33. //
  34. // Desc: Window procedure for the error dialog
  35. //
  36. //-----------------------------------------------------------------------------
  37. ///////////////////////////////////////////////////////////////////////////////
  38. ///////////////////////////////////////////////////////////////////////////////
  39. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  40. ///////////////////////////////////////////////////////////////////////////////
  41. #include <windows.h>
  42. #include <stdio.h>
  43. // USER INCLUDES //////////////////////////////////////////////////////////////
  44. #include "ImagePacker.h"
  45. #include "Resource.h"
  46. // DEFINES ////////////////////////////////////////////////////////////////////
  47. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  48. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  49. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  50. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  51. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  52. ///////////////////////////////////////////////////////////////////////////////
  53. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  54. ///////////////////////////////////////////////////////////////////////////////
  55. // ImageErrorProc =============================================================
  56. /** Dialog proc for the error window */
  57. //=============================================================================
  58. BOOL CALLBACK ImageErrorProc( HWND hWndDialog, UINT message,
  59. WPARAM wParam, LPARAM lParam )
  60. {
  61. switch( message )
  62. {
  63. // ------------------------------------------------------------------------
  64. case WM_INITDIALOG:
  65. {
  66. //
  67. // load the listbox with images that could not be processed
  68. // and the reasons for it
  69. //
  70. // sanity
  71. if( TheImagePacker == NULL )
  72. return TRUE;
  73. // go through all images
  74. Int i, count;
  75. HWND list = GetDlgItem( hWndDialog, LIST_IMAGES );
  76. char buffer[ _MAX_PATH + 256 ];
  77. char reason[ 32 ];
  78. ImageInfo *image;
  79. count = TheImagePacker->getImageCount();
  80. for( i = 0; i < count; i++ )
  81. {
  82. // get image
  83. image = TheImagePacker->getImage( i );
  84. // sanity
  85. if( image == NULL )
  86. continue;
  87. // if image can't be processed find out why
  88. if( BitTest( image->m_status, ImageInfo::CANTPROCESS ) )
  89. {
  90. if( BitTest( image->m_status, ImageInfo::TOOBIG ) )
  91. sprintf( reason, "Too Big" );
  92. else if( BitTest( image->m_status, ImageInfo::INVALIDCOLORDEPTH ) )
  93. sprintf( reason, "Unsupported Color Depth" );
  94. else
  95. sprintf( reason, "Unknown Reason" );
  96. sprintf( buffer, "%s: (%dx%dx%d) %s",
  97. reason, image->m_size.x, image->m_size.y, image->m_colorDepth,
  98. image->m_path );
  99. SendMessage( list, LB_INSERTSTRING, -1, (LPARAM)buffer );
  100. } // end if
  101. } // end for i
  102. // set the extents for the horizontal scroll bar in the listbox
  103. SendMessage( list, LB_SETHORIZONTALEXTENT, 1280, 0 );
  104. return TRUE;
  105. } // end init
  106. // ------------------------------------------------------------------------
  107. case WM_COMMAND:
  108. {
  109. Int controlID = LOWORD( wParam );
  110. // Int notifyCode = HIWORD( wParam );
  111. // HWND hWndControl = (HWND)lParam;
  112. switch( controlID )
  113. {
  114. // --------------------------------------------------------------------
  115. case BUTTON_PROCEED:
  116. {
  117. EndDialog( hWndDialog, TRUE );
  118. break;
  119. } // end proceed
  120. // --------------------------------------------------------------------
  121. case BUTTON_CANCEL:
  122. {
  123. EndDialog( hWndDialog, FALSE );
  124. break;
  125. } // end cancel
  126. } // end switch
  127. break;
  128. } // end command
  129. } // end switch message
  130. return 0;
  131. } // end ImageErrorProc