PageErrorProc.cpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. ** Command & Conquer Generals(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: PageErrorProc.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: PageErrorProc.cpp
  31. //
  32. // Created: Colin Day, August 2001
  33. //
  34. // Desc: Window procedure for the error dialog for texture pages
  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. // PageErrorProc ==============================================================
  56. /** Dialog proc for the error window */
  57. //=============================================================================
  58. BOOL CALLBACK PageErrorProc( 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 pages 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 pages
  74. TexturePage *page;
  75. HWND list = GetDlgItem( hWndDialog, LIST_PAGES );
  76. char buffer[ _MAX_PATH + 256 ];
  77. char reason[ 32 ];
  78. for( page = TheImagePacker->getFirstTexturePage();
  79. page;
  80. page = page->m_next )
  81. {
  82. // if image can't be processed find out why
  83. if( BitTest( page->m_status, TexturePage::PAGE_ERROR ) )
  84. {
  85. if( BitTest( page->m_status, TexturePage::CANT_ALLOCATE_PACKED_IMAGE ) )
  86. sprintf( reason, "Can't allocate image memory" );
  87. else if( BitTest( page->m_status, TexturePage::CANT_ADD_IMAGE_DATA ) )
  88. sprintf( reason, "Can't add image(s) data" );
  89. else if( BitTest( page->m_status, TexturePage::NO_TEXTURE_DATA ) )
  90. sprintf( reason, "No texture data to write" );
  91. else if( BitTest( page->m_status, TexturePage::ERROR_DURING_SAVE ) )
  92. sprintf( reason, "Error writing texture file" );
  93. else
  94. sprintf( reason, "Unknown Reason" );
  95. sprintf( buffer, "%s: (%dx%d) %s%d",
  96. reason, page->getWidth(), page->getHeight(),
  97. TheImagePacker->getOutputFile(), page->getID() );
  98. SendMessage( list, LB_INSERTSTRING, -1, (LPARAM)buffer );
  99. } // end if
  100. } // end for i
  101. // set the extents for the horizontal scroll bar in the listbox
  102. SendMessage( list, LB_SETHORIZONTALEXTENT, 1280, 0 );
  103. return TRUE;
  104. } // end init
  105. // ------------------------------------------------------------------------
  106. case WM_COMMAND:
  107. {
  108. Int controlID = LOWORD( wParam );
  109. // Int notifyCode = HIWORD( wParam );
  110. // HWND hWndControl = (HWND)lParam;
  111. switch( controlID )
  112. {
  113. // --------------------------------------------------------------------
  114. case IDOK:
  115. {
  116. EndDialog( hWndDialog, TRUE );
  117. break;
  118. } // end proceed
  119. } // end switch
  120. break;
  121. } // end command
  122. } // end switch message
  123. return 0;
  124. } // end PageErrorProc