Initial commit of Command & Conquer Generals and Command & Conquer Generals Zero Hour source code.

This commit is contained in:
LFeenanEA 2025-02-27 17:34:39 +00:00
parent 2e338c00cb
commit 3d0ee53a05
No known key found for this signature in database
GPG key ID: C6EBE8C2EA08F7E0
6072 changed files with 2283311 additions and 0 deletions

View file

@ -0,0 +1,207 @@
# Microsoft Developer Studio Project File - Name="ImagePacker" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=ImagePacker - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "ImagePacker.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "ImagePacker.mak" CFG="ImagePacker - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ImagePacker - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "ImagePacker - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE "ImagePacker - Win32 Internal" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "ImagePacker"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "ImagePacker - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /G6 /MD /W3 /WX /GX /O2 /Ob2 /I ".\Include" /I ".\Resource" /I "..\..\Libraries\Include" /I "..\..\GameEngine\Include" /I "..\..\GameEngineDevice\Include" /I "..\..\Libraries\Source\WWVegas" /I "..\..\Libraries\Source\WWVegas\WWLib" /I "..\..\Libraries\Source\WWVegas\WWMath" /I "..\..\Libraries\Source\WWVegas\WWDebug" /I "..\..\Libraries\Source\WWVegas\WWSaveLoad" /I "..\..\Libraries\Source\WWVegas\WW3D2" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 WW3D2.lib WWDebug.lib WWLib.lib WWUtil.lib WWMath.lib GameEngine.lib GameEngineDevice.lib Benchmark.lib wsock32.lib wininet.lib dxguid.lib dinput8.lib d3dx8.lib d3d8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib vfw32.lib winmm.lib dsound.lib comctl32.lib imm32.lib /nologo /subsystem:windows /pdb:"..\..\..\Run\ImagePacker.pdb" /map:"..\..\..\Run\ImagePacker.map" /debug /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\..\Run\ImagePacker.exe" /libpath:"..\..\GameEngine\Lib" /libpath:"..\..\GameEngineDevice\Lib" /libpath:"..\..\Libraries\Lib" /libpath:"..\..\GameEngine"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "ImagePacker - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /G6 /MDd /W3 /WX /Gm /GX /ZI /Od /I ".\Include" /I ".\Resource" /I "..\..\Libraries\Include" /I "..\..\GameEngine\Include" /I "..\..\GameEngineDevice\Include" /I "..\..\Libraries\Source\WWVegas" /I "..\..\Libraries\Source\WWVegas\WWLib" /I "..\..\Libraries\Source\WWVegas\WWMath" /I "..\..\Libraries\Source\WWVegas\WWDebug" /I "..\..\Libraries\Source\WWVegas\WWSaveLoad" /I "..\..\Libraries\Source\WWVegas\WW3D2" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
# ADD LINK32 WW3D2Debug.lib WWDebugDebug.lib WWUtilDebug.lib WWLibDebug.lib WWMathDebug.lib GameEngineDebug.lib GameEngineDeviceDebug.lib BenchmarkD.lib wsock32.lib wininet.lib dxguid.lib dinput8.lib d3dx8.lib d3d8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib vfw32.lib winmm.lib dsound.lib comctl32.lib imm32.lib /nologo /subsystem:windows /pdb:"..\..\..\Run\ImagePackerD.pdb" /map:"..\..\..\Run\ImagePackerD.map" /debug /machine:I386 /nodefaultlib:"libcd msvcrt" /out:"..\..\..\Run\ImagePackerD.exe" /libpath:"..\..\GameEngine\Lib" /libpath:"..\..\GameEngineDevice\Lib" /libpath:"..\..\Libraries\Lib" /libpath:"..\..\GameEngine"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "ImagePacker - Win32 Internal"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Internal"
# PROP BASE Intermediate_Dir "Internal"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Internal"
# PROP Intermediate_Dir "Internal"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /WX /GX /O2 /I ".\Include" /I ".\Resource" /I "..\..\Libraries\Include" /I "..\..\GameEngine\Include" /I "..\..\GameEngineDevice\Include" /I "..\..\Libraries\Source\WWVegas" /I "..\..\Libraries\Source\WWVegas\WWLib" /I "..\..\Libraries\Source\WWVegas\WWMath" /I "..\..\Libraries\Source\WWVegas\WWDebug" /I "..\..\Libraries\Source\WWVegas\WWSaveLoad" /I "..\..\Libraries\Source\WWVegas\WW3D2" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G6 /MD /W3 /WX /GX /O2 /I ".\Include" /I ".\Resource" /I "..\..\Libraries\Include" /I "..\..\GameEngine\Include" /I "..\..\GameEngineDevice\Include" /I "..\..\Libraries\Source\WWVegas" /I "..\..\Libraries\Source\WWVegas\WWLib" /I "..\..\Libraries\Source\WWVegas\WWMath" /I "..\..\Libraries\Source\WWVegas\WWDebug" /I "..\..\Libraries\Source\WWVegas\WWSaveLoad" /I "..\..\Libraries\Source\WWVegas\WW3D2" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 WW3D2.lib WWDebug.lib WWLib.lib WWUtil.lib WWMath.lib GameEngine.lib GameEngineDevice.lib dxguid.lib dinput8.lib d3dx8.lib d3d8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib vfw32.lib winmm.lib dsound.lib comctl32.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\..\Run\ImagePacker.exe" /libpath:"..\..\GameEngine\Lib" /libpath:"..\..\GameEngineDevice\Lib" /libpath:"..\..\Libraries\Lib" /libpath:"..\..\GameEngine"
# ADD LINK32 WW3D2Internal.lib WWDebugInternal.lib WWLibInternal.lib WWUtilInternal.lib WWMathInternal.lib GameEngineInternal.lib GameEngineDeviceInternal.lib Benchmark.lib wsock32.lib wininet.lib dxguid.lib dinput8.lib d3dx8.lib d3d8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib vfw32.lib winmm.lib dsound.lib comctl32.lib imm32.lib /nologo /subsystem:windows /pdb:"..\..\..\Run\ImagePackerI.pdb" /map:"..\..\..\Run\ImagePackerI.map" /debug /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\..\Run\ImagePackerI.exe" /libpath:"..\..\GameEngine\Lib" /libpath:"..\..\GameEngineDevice\Lib" /libpath:"..\..\Libraries\Lib" /libpath:"..\..\GameEngine"
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "ImagePacker - Win32 Release"
# Name "ImagePacker - Win32 Debug"
# Name "ImagePacker - Win32 Internal"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Group "Window Procedures"
# PROP Default_Filter ""
# Begin Source File
SOURCE=".\Source\Window Procedures\DirectorySelect.cpp"
# End Source File
# Begin Source File
SOURCE=".\Source\Window Procedures\ImageErrorProc.cpp"
# End Source File
# Begin Source File
SOURCE=".\Source\Window Procedures\ImagePackerProc.cpp"
# End Source File
# Begin Source File
SOURCE=".\Source\Window Procedures\PageErrorProc.cpp"
# End Source File
# Begin Source File
SOURCE=".\Source\Window Procedures\PreviewProc.cpp"
# End Source File
# End Group
# Begin Source File
SOURCE=.\Source\ImageInfo.cpp
# End Source File
# Begin Source File
SOURCE=.\Source\ImagePacker.cpp
# End Source File
# Begin Source File
SOURCE=.\Source\TexturePage.cpp
# End Source File
# Begin Source File
SOURCE=.\Source\WinMain.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\Include\ImageDirectory.h
# End Source File
# Begin Source File
SOURCE=.\Include\ImageInfo.h
# End Source File
# Begin Source File
SOURCE=.\Include\ImagePacker.h
# End Source File
# Begin Source File
SOURCE=.\Include\TexturePage.h
# End Source File
# Begin Source File
SOURCE=.\Include\WindowProc.h
# End Source File
# Begin Source File
SOURCE=.\Include\WinMain.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\Resource\ImagePacker.rc
# End Source File
# Begin Source File
SOURCE=.\Resource\Resource.h
# End Source File
# End Group
# End Target
# End Project

View file

@ -0,0 +1,87 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: ImageDirectory.h /////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: ImageDirectory.h
//
// Created: Colin Day, August 2001
//
// Desc: Image directory description for directories containing
// image files to pack
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __IMAGEDIRECTORY_H_
#define __IMAGEDIRECTORY_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
// FORWARD REFERENCES /////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// ImageDirectory -------------------------------------------------------------
/** Directory to contain art files */
//-----------------------------------------------------------------------------
class ImageDirectory
{
public:
ImageDirectory();
~ImageDirectory();
char *m_path; ///< path for directory
UnsignedInt m_imageCount; ///< images to consider in this directory
ImageDirectory *m_next;
ImageDirectory *m_prev;
};
///////////////////////////////////////////////////////////////////////////////
// INLINING ///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
inline ImageDirectory::~ImageDirectory( void ) { delete m_path; }
inline ImageDirectory::ImageDirectory( void )
{
m_path = NULL;
m_next = NULL;
m_prev = NULL;
m_imageCount = 0;
}
// EXTERNALS //////////////////////////////////////////////////////////////////
#endif // __IMAGEDIRECTORY_H_

View file

@ -0,0 +1,116 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: ImageInfo.h //////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: ImageInfo.h
//
// Created: Colin Day, August 2001
//
// Desc: Image descriptor for the image packer
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __IMAGEINFO_H_
#define __IMAGEINFO_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Lib/BaseType.h"
///////////////////////////////////////////////////////////////////////////////
// FORWARD REFERENCES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class TexturePage;
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// ImageInfo ------------------------------------------------------------------
/** Image file information */
//-----------------------------------------------------------------------------
class ImageInfo
{
public:
enum
{
UNPACKED = 0x00000001, ///< this image has not yet been packed
PACKED = 0x00000002, ///< this image has been packed and is done
TOOBIG = 0x00000004, ///< this image was too big to process
ROTATED90C = 0x00000008, ///< image is fitted after 90 clockwise rotation
CANTPROCESS = 0x00000010, ///< can't be processed
INVALIDCOLORDEPTH = 0x00000020, ///< unsupported source image format
};
enum
{
FIT_XGUTTER = 0x00000001, ///< x gutter is present in fit region
FIT_YGUTTER = 0x00000002, ///< y gutter is present in fit region
FIT_XBORDER_RIGHT = 0x00000004, ///< x border of 1 pixel on right side of region
FIT_XBORDER_LEFT = 0x00000008, ///< x border of 1 pixel on left side of region
FIT_YBORDER_TOP = 0x00000010, ///< y border of 1 pixel on top of region
FIT_YBORDER_BOTTOM = 0x00000020, ///< y border of 1 pixel on bottom of image
};
public:
ImageInfo();
~ImageInfo();
char *m_path; ///< path to file
char *m_filenameOnly; ///< filename with extension only (no path information)
char *m_filenameOnlyNoExt; ///< filename without extension and no path info
Int m_colorDepth; ///< bits per pixel
UnsignedInt m_area; ///< width and height area
ICoord2D m_size; ///< width and height of image
UnsignedInt m_status; ///< status bits for image
TexturePage *m_page; ///< pointer to page this image is now packed on
ImageInfo *m_nextPageImage; ///< next image on texture page
ImageInfo *m_prevPageImage; ///< previous image on texture page
IRegion2D m_pagePos; /** once placed on a texture page this has the
coords of the image on the page, it does not include
any padding from stretching borders and gutters */
UnsignedInt m_fitBits; /**< bit flags of the region used to fit this image on
a page and therefore to create m_pagePos */
ICoord2D m_gutterUsed; ///< the gutter size actually used in this image fit
};
// INLINING ///////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
#endif // __IMAGEINFO_H_

View file

@ -0,0 +1,217 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: ImagePacker.h ////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: ImagePacker.h
//
// Created: Colin Day, August 2001
//
// Desc: Image packer tool
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __IMAGEPACKER_H_
#define __IMAGEPACKER_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <windows.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Lib/BaseType.h"
#include "WWLib/Targa.h"
#include "ImageDirectory.h"
#include "ImageInfo.h"
#include "TexturePage.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#define MAX_OUTPUT_FILE_LEN 128
#define DEFAULT_TARGET_SIZE 512
// ImagePacker ----------------------------------------------------------------
// Class interface for running the image packer */
//-----------------------------------------------------------------------------
class ImagePacker
{
public:
enum
{
GAP_METHOD_EXTEND_RGB = 0x00000001, ///< extend RGB (no alpha) of image on all sides
GAP_METHOD_GUTTER = 0x00000002, ///< put transparent gutter on right and bottom side of image
};
public:
ImagePacker( void );
virtual ~ImagePacker( void );
Bool init( void ); ///< initialize the system
Bool process( void ); ///< run the process
Bool getSettingsFromDialog( HWND dialog ); ///< get the options for exection
void setWindowHandle( HWND hWnd ); ///< set window handle for 'dialog' app
HWND getWindowHandle( void ); ///< get window handle for 'dialog' app
ICoord2D *getTargetSize( void ); ///< get target size
Int getTargetWidth( void ); ///< get target width
Int getTargetHeight( void ); ///< bet target height
void statusMessage( char *message ); ///< set a status message
UnsignedInt getImageCount( void ); ///< get image count
ImageInfo *getImage( Int index ); ///< get image
TexturePage *getFirstTexturePage( void ); ///< get first texture page
UnsignedInt getPageCount( void ); ///< get the count of texutre pages
void setTargetPreviewPage( Int page ); ///< set the target preview page to view
Int getTargetPreviewPage( void ); ///< get the target preview page to view
void setGutter( UnsignedInt size ); ///< set gutter size in pixels
UnsignedInt getGutter( void ); ///< get gutter size in pixels
void setGapMethod( UnsignedInt methodBit ); ///< set gap method option
void clearGapMethod( UnsignedInt methodBit ); ///< clear gap method option
UnsignedInt getGapMethod( void ); ///< get gap method option
void setOutputAlpha( Bool outputAlpha ); ///< set output alpha option
Bool getOutputAlpha( void ); ///< get output alpha option
void setPreviewWindow( HWND window ); ///< assign preview window handle
HWND getPreviewWindow( void ); ///< get the preview window handle
void setUseTexturePreview( Bool use ); ///< use the real image data in preview
Bool getUseTexturePreview( void ); ///< get texture preview option
void setINICreate( Bool create ); ///< set create INI file option
Bool createINIFile( void ); ///< get create INI option
char *getOutputFile( void ); ///< get output filename
char *getOutputDirectory( void ); ///< get output directory
void setCompressTextures( Bool compress ); ///< set compress textures option
Bool getCompressTextures( void ); ///< get compress textures option
protected:
void setTargetSize( Int width, Int height ); ///< set the size of the output target image
Bool checkOutputDirectory( void ); ///< verify output directory is OK
void resetImageDirectoryList( void ); ///< clear the image directory list
void resetImageList( void ); ///< clear the image list
void resetPageList( void ); ///< clear the texture page list
void addDirectory( char *path, Bool subDirs ); ///< add directory to directory list
void addImagesInDirectory( char *dir ); ///< add all images from the specified directory
void addImage( char *path ); ///< add image to image list
Bool validateImages( void ); ///< validate that the loaded images can all be processed
Bool packImages( void ); ///< do the packing
void writeFinalTextures( void ); ///< write the packed textures
Bool generateINIFile( void ); ///< generate the INI file for this image set
TexturePage *createNewTexturePage( void ); ///< create a new texture page
void sortImageList( void ); ///< sort the image list
HWND m_hWnd; ///< window handle for app
ICoord2D m_targetSize; ///< the target size
Bool m_useSubFolders; ///< use subfolders option
char m_outputFile[ MAX_OUTPUT_FILE_LEN ]; ///< output filename
char m_outputDirectory[ _MAX_PATH ]; ///< destination for texture files
ImageDirectory *m_dirList; ///< the directory list
UnsignedInt m_dirCount; ///< length of dirList
UnsignedInt m_imagesInDirs; ///< number of images in all directories
ImageInfo **m_imageList; ///< the image list
UnsignedInt m_imageCount; ///< length of imageList
char m_statusBuffer[ 1024 ]; ///< for printing status messages
TexturePage *m_pageTail; ///< end of the texture page list
TexturePage *m_pageList; ///< the final images generated from the packer
UnsignedInt m_pageCount; ///< length of page list
UnsignedInt m_gapMethod; ///< gap method option bits
UnsignedInt m_gutterSize; ///< gutter gaps between images in pixels
Bool m_outputAlpha; ///< final image files will have an alpha channel
Bool m_createINI; ///< create the INI file from compressed image data
Int m_targetPreviewPage; ///< preview page we're looking at
HWND m_hWndPreview; ///< the preview window
Bool m_showTextureInPreview; ///< show actual texture in preview window
Targa *m_targa; ///< targa for loading file headers
Bool m_compressTextures; ///< compress the final textures
};
///////////////////////////////////////////////////////////////////////////////
// INLINING ///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
inline void ImagePacker::setTargetSize( Int width, Int height ) { m_targetSize.x = width; m_targetSize.y = height; }
inline ICoord2D *ImagePacker::getTargetSize( void ) { return &m_targetSize; }
inline Int ImagePacker::getTargetWidth( void ) { return m_targetSize.x; }
inline Int ImagePacker::getTargetHeight( void ) { return m_targetSize.y; }
inline void ImagePacker::setWindowHandle( HWND hWnd ) { m_hWnd = hWnd; }
inline HWND ImagePacker::getWindowHandle( void ) { return m_hWnd; }
inline UnsignedInt ImagePacker::getImageCount( void ) { return m_imageCount; }
inline ImageInfo *ImagePacker::getImage( Int index ) { return m_imageList[ index ]; }
inline void ImagePacker::setTargetPreviewPage( Int page ) { m_targetPreviewPage = page; }
inline Int ImagePacker::getTargetPreviewPage( void ) { return m_targetPreviewPage; }
inline UnsignedInt ImagePacker::getPageCount( void ) { return m_pageCount; }
inline void ImagePacker::setPreviewWindow( HWND window ) { m_hWndPreview = window; }
inline HWND ImagePacker::getPreviewWindow( void ) { return m_hWndPreview; }
inline void ImagePacker::setGutter( UnsignedInt size ) { m_gutterSize = size; }
inline UnsignedInt ImagePacker::getGutter( void ) { return m_gutterSize; }
inline void ImagePacker::setOutputAlpha( Bool outputAlpha ) { m_outputAlpha = outputAlpha; }
inline Bool ImagePacker::getOutputAlpha( void ) { return m_outputAlpha; }
inline TexturePage *ImagePacker::getFirstTexturePage( void ) { return m_pageList; }
inline void ImagePacker::setUseTexturePreview( Bool use ) { m_showTextureInPreview = use; }
inline Bool ImagePacker::getUseTexturePreview( void ) { return m_showTextureInPreview; }
inline void ImagePacker::setINICreate( Bool create ) { m_createINI = create; };
inline Bool ImagePacker::createINIFile( void ) { return m_createINI; }
inline char *ImagePacker::getOutputFile( void ) { return m_outputFile; }
inline char *ImagePacker::getOutputDirectory( void ) { return m_outputDirectory; }
inline void ImagePacker::setCompressTextures( Bool compress ) { m_compressTextures = compress; }
inline Bool ImagePacker::getCompressTextures( void ) { return m_compressTextures; }
inline void ImagePacker::setGapMethod( UnsignedInt methodBit ) { BitSet( m_gapMethod, methodBit ); }
inline void ImagePacker::clearGapMethod( UnsignedInt methodBit ) { BitClear( m_gapMethod, methodBit ); }
inline UnsignedInt ImagePacker::getGapMethod( void ) { return m_gapMethod; }
///////////////////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
extern ImagePacker *TheImagePacker;
#endif // __IMAGEPACKER_H_

View file

@ -0,0 +1,172 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: TexturePage.h ////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: TexturePage.h
//
// Created: Colin Day, August 2001
//
// Desc: This class represents a texture that contains packed
// images.
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __TEXTUREPAGE_H_
#define __TEXTUREPAGE_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <stdlib.h>
///////////////////////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include "WWLib/Targa.h"
#include "Lib/BaseType.h"
#include "ImageInfo.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// TexturePage ----------------------------------------------------------------
/** A texture page continaing multiple source images */
//-----------------------------------------------------------------------------
class TexturePage
{
public:
enum
{
FREE = 0, ///< open pixel in the cavas
USED = 1, ///< used pixel in the canvas
};
enum
{
READY = 0x00000001, ///< texture page here and OK
PAGE_ERROR = 0x00000002, ///< error on page somewhere
CANT_ALLOCATE_PACKED_IMAGE = 0x00000004, ///< couldn't generate final image
CANT_ADD_IMAGE_DATA = 0x00000008, ///< couldn't add image data to page
NO_TEXTURE_DATA = 0x00000010, ///< there was no image data to write
ERROR_DURING_SAVE = 0x00000020, ///< couldn't save final file
};
TexturePage( Int width, Int height );
~TexturePage( void );
Bool addImage( ImageInfo *image ); ///< try to add image to this page
void setID( Int id ); ///< set page id
Int getID( void ); ///< get page id
Bool generateTexture( void ); ///< generate the final packed texture
Bool writeFile( char *baseFilename ); ///< write generated texture to file
ImageInfo *getFirstImage( void ); ///< get the first image in the list
Int getWidth( void ); ///< get width of texture page
Int getHeight( void ); ///< get height of texture page
// get rgb from final generated texture (putting this in for quick preview)
void getPixel( Int x, Int y, Byte *r, Byte *g, Byte *b, Byte *a = NULL );
TexturePage *m_next;
TexturePage *m_prev;
UnsignedInt m_status; ///< status bits
protected:
Bool spotUsed( Int x, Int y ); ///< is this spot used
Bool lineUsed( Int sx, Int sy, Int ex, Int ey ); ///< is any spot on the line used
/// build a region to try to fit given the position, size, and border options
UnsignedInt buildFitRegion( IRegion2D *region,
Int startX, Int startY,
Int imageWidth, Int imageHeight,
Int *xGutter, Int *yGutter,
Bool allSidesBorder );
void markRegionUsed( IRegion2D *region ); ///< mark this region as used
/// add the actual image data of 'image' to the destination buffer
Bool addImageData( Byte *destBuffer,
Int destWidth,
Int destHeight,
Int destBPP,
ImageInfo *image );
/// extend edges of image outward into border if present
void extendImageEdges( Byte *destBuffer,
Int destWidth,
Int destHeight,
Int destBPP,
ImageInfo *image,
Bool extendAlpha );
/// if the pixel at abolve/below row is open, extend pixel at src to its location
void extendToRowIfOpen( char *src,
Int buffWidth,
Int buffBPP,
Bool extendAlpha,
Int imageHeight,
UnsignedInt fitBits,
Int srcX, Int srcY );
Int m_id; ///< texture page ID
ICoord2D m_size; ///< dimensions of texture page
UnsignedByte *m_canvas; ///< as big as the texture page, a used spot is non zero
ImageInfo *m_imageList; ///< list of images packed on this page
Byte *m_packedImage; ///< final generated image data
Targa *m_targa; ///< final packed image all in a nice little targa file
};
///////////////////////////////////////////////////////////////////////////////
// INLINING ///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
inline void TexturePage::setID( Int id ) { m_id = id; }
inline Int TexturePage::getID( void ) { return m_id; }
inline ImageInfo *TexturePage::getFirstImage( void ) { return m_imageList; }
inline Int TexturePage::getWidth( void ) { return m_size.x; }
inline Int TexturePage::getHeight( void ) { return m_size.y; }
// EXTERNALS //////////////////////////////////////////////////////////////////
#endif // __TEXTUREPAGE_H_

View file

@ -0,0 +1,62 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: WinMain.h ////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: WinMain.h
//
// Created: Colin Day, August 2001
//
// Desc: Header for main app
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __WINMAIN_H_
#define __WINMAIN_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <windows.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
// FORWARD REFERENCES /////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// INLINING ///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
extern HINSTANCE ApplicationHInstance;
#endif // __WINMAIN_H_

View file

@ -0,0 +1,74 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: WindowProc.h /////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: WindowProc.h
//
// Created: Colin Day, August 2001
//
// Desc: Dialog procedure header for image packer utility
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __WINDOWPROC_H_
#define __WINDOWPROC_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
// FORWARD REFERENCES /////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// INLINING ///////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
extern BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam );
extern HWND MakePreviewDisplay( void );
extern void UpdatePreviewWindow( void );
extern LRESULT CALLBACK PreviewProc( HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam );
extern BOOL CALLBACK ImageErrorProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam );
extern BOOL CALLBACK PageErrorProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam );
extern BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam );
#endif // __WINDOWPROC_H_

View file

@ -0,0 +1,214 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IMAGE_PACKER_DIALOG DIALOG DISCARDABLE 0, 0, 408, 313
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Image Packer"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Start",BUTTON_START,20,224,50,32
PUSHBUTTON "Exit",BUTTON_EXIT,80,224,50,32
LISTBOX LIST_FOLDERS,154,136,232,84,LBS_SORT | LBS_MULTIPLESEL |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL |
WS_TABSTOP
GROUPBOX "Folders Containing Source Images",IDC_STATIC,148,84,244,
144
GROUPBOX "",IDC_STATIC,4,4,396,304
GROUPBOX "Output Image Size",IDC_STATIC,12,84,128,108
CONTROL "128 x 128",RADIO_128X128,"Button",BS_AUTORADIOBUTTON,20,
99,47,10
CONTROL "256 x 256",RADIO_256X256,"Button",BS_AUTORADIOBUTTON,20,
111,47,10
CONTROL "512 x 512",RADIO_512X512,"Button",BS_AUTORADIOBUTTON,20,
123,47,10
CONTROL "Other",RADIO_TARGET_OTHER,"Button",BS_AUTORADIOBUTTON,
20,135,33,10
EDITTEXT EDIT_WIDTH,36,148,24,14,ES_CENTER | ES_AUTOHSCROLL |
ES_NUMBER | WS_DISABLED
EDITTEXT EDIT_HEIGHT,72,148,24,14,ES_CENTER | ES_AUTOHSCROLL |
ES_NUMBER | WS_DISABLED
CTEXT "x",STATIC_X,60,148,12,12,SS_CENTERIMAGE | WS_DISABLED
PUSHBUTTON "Add Folder(s)",BUTTON_ADD_FOLDER,196,100,70,14
PUSHBUTTON "Remove Folder(s)",BUTTON_REMOVE_FOLDER,276,100,72,14
EDITTEXT EDIT_FILENAME,12,30,128,14,ES_AUTOHSCROLL
LTEXT "Output File Base Name:",IDC_STATIC,12,20,124,8,
SS_CENTERIMAGE
CONTROL "Use Sub-folders",CHECK_USE_SUB_FOLDERS,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,156,120,66,10
LTEXT "Status",STATIC_STATUS,12,288,380,12,SS_CENTERIMAGE |
SS_SUNKEN
PUSHBUTTON "Open Preview",BUTTON_PREVIEW,176,244,68,14
GROUPBOX "Preview",IDC_STATIC,148,232,244,52
PUSHBUTTON "<- Prev",BUTTON_PREVIOUS,264,244,50,14
PUSHBUTTON "Next ->",BUTTON_NEXT,316,244,50,14
EDITTEXT EDIT_GUTTER,176,57,40,14,ES_CENTER | ES_AUTOHSCROLL |
ES_NUMBER | WS_DISABLED
LTEXT "Pixels Between Packed Images",STATIC_GAP_INFO,220,57,
128,12,SS_CENTERIMAGE | WS_DISABLED
CONTROL "Output Alpha Channel",CHECK_ALPHA,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,12,68,128,10
CONTROL "Show Texture In Preview",CHECK_BITMAP_PREVIEW,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,176,264,112,10
CONTROL "Create INI Mapped Image File",CHECK_INI,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,12,52,128,10
CONTROL "Compress Final Texture Pages",CHECK_COMPRESS,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,20,172,116,10
GROUPBOX "Gap Method",IDC_STATIC,148,12,244,68
CONTROL "Extend RGB at Image Edges (All Sides, NO Alpha)",
CHECK_GAP_EXTEND_RGB,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,156,28,174,10
CONTROL "Transparent Gap (Right and Bottom Only)",
CHECK_GAP_GUTTER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
156,44,146,10
END
IMAGE_ERRORS DIALOG DISCARDABLE 0, 0, 252, 257
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Processing Errors"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Proceed Anyway",BUTTON_PROCEED,44,232,72,14
LISTBOX LIST_IMAGES,4,20,244,200,LBS_SORT | LBS_NOINTEGRALHEIGHT |
LBS_NOSEL | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
LTEXT "The following images cannot be processed. Proceed anyway?",
IDC_STATIC,4,4,236,12
DEFPUSHBUTTON "Cancel Build",BUTTON_CANCEL,136,232,72,14
END
PAGE_ERRORS DIALOG DISCARDABLE 0, 0, 256, 257
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Texture Page Errors"
FONT 8, "MS Sans Serif"
BEGIN
LISTBOX LIST_PAGES,4,20,244,200,LBS_SORT | LBS_NOINTEGRALHEIGHT |
LBS_NOSEL | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
LTEXT "The following texture pages could not be generated and were ignored",
IDC_STATIC,4,4,236,12
PUSHBUTTON "OK",IDOK,104,232,50,14
END
DIRECTORY_SELECT_DIALOG DIALOG DISCARDABLE 0, 0, 192, 261
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select Directory"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Add Directory",BUTTON_ADD,28,8,63,14,WS_DISABLED
PUSHBUTTON "Cancel",BUTTON_CANCEL,100,8,63,14
LISTBOX LIST_DIR,4,80,184,176,LBS_SORT | LBS_MULTIPLESEL |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL |
WS_TABSTOP
LTEXT "Current Dir",STATIC_CURRENT_DIR,4,36,184,24,SS_SUNKEN
COMBOBOX COMBO_DRIVE,28,64,48,180,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
LTEXT "Drive",IDC_STATIC,4,64,20,12,SS_CENTERIMAGE
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IMAGE_PACKER_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 401
TOPMARGIN, 7
BOTTOMMARGIN, 306
END
IMAGE_ERRORS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 245
TOPMARGIN, 7
BOTTOMMARGIN, 250
END
PAGE_ERRORS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 249
TOPMARGIN, 7
BOTTOMMARGIN, 250
END
DIRECTORY_SELECT_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 185
TOPMARGIN, 7
BOTTOMMARGIN, 254
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1,55 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by ImagePacker.rc
//
#define IDD_DIALOG1 101
#define IMAGE_PACKER_DIALOG 101
#define IMAGE_ERRORS 102
#define PAGE_ERRORS 103
#define DIRECTORY_SELECT_DIALOG 104
#define BUTTON_START 1000
#define BUTTON_EXIT 1001
#define LIST_FOLDERS 1002
#define RADIO_128X128 1003
#define RADIO_256X256 1004
#define RADIO_512X512 1005
#define RADIO_TARGET_OTHER 1006
#define EDIT_WIDTH 1007
#define EDIT_HEIGHT 1008
#define BUTTON_ADD_FOLDER 1009
#define BUTTON_REMOVE_FOLDER 1010
#define EDIT_FILENAME 1011
#define CHECK_USE_SUB_FOLDERS 1012
#define STATIC_X 1013
#define STATIC_STATUS 1014
#define BUTTON_PREVIEW 1016
#define BUTTON_PREVIOUS 1017
#define BUTTON_NEXT 1018
#define LIST_IMAGES 1018
#define EDIT_GUTTER 1019
#define CHECK_ALPHA 1020
#define CHECK_BITMAP_PREVIEW 1021
#define CHECK_GDF 1022
#define CHECK_INI 1022
#define BUTTON_PROCEED 1023
#define BUTTON_CANCEL 1024
#define LIST_PAGES 1025
#define BUTTON_ADD 1027
#define LIST_DIR 1028
#define STATIC_CURRENT_DIR 1031
#define COMBO_DRIVE 1032
#define CHECK_COMPRESS 1033
#define CHECK_GAP_EXTEND_RGB 1037
#define CHECK_GAP_GUTTER 1038
#define STATIC_GAP_INFO 1039
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1040
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,107 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: ImageInfo.cpp ////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: ImageInfo.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Image information struct for images to pack into
// the texture pages
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <stdlib.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "ImageInfo.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// ImageInfo::ImageInfo =======================================================
/** */
//=============================================================================
ImageInfo::ImageInfo( void )
{
m_area = 0;
m_colorDepth = 0;
m_size.x = 0;
m_size.y = 0;
m_path = NULL;
m_filenameOnly = NULL;
m_filenameOnlyNoExt = NULL;
m_status = UNPACKED;
m_page = NULL;
m_nextPageImage = NULL;
m_prevPageImage = NULL;
m_pagePos.lo.x = 0;
m_pagePos.lo.y = 0;
m_pagePos.hi.x = 0;
m_pagePos.hi.y = 0;
m_fitBits = 0;
m_gutterUsed.x = 0;
m_gutterUsed.y = 0;
} // end ImageInfo
// ImageInfo::~ImageInfo ======================================================
/** */
//=============================================================================
ImageInfo::~ImageInfo( void )
{
// delete path name
if( m_path )
delete [] m_path;
if( m_filenameOnly )
delete [] m_filenameOnly;
if( m_filenameOnlyNoExt )
delete [] m_filenameOnlyNoExt;
} // end ~ImageInfo

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,124 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: WinMain.cpp //////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: WinMain.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Application entry point for the image packer tool
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <windows.h>
#include <stdlib.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Lib/BaseType.h"
#include "Common/GameMemory.h"
#include "Common/Debug.h"
#include "ImagePacker.h"
#include "Resource.h"
#include "WindowProc.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
HINSTANCE ApplicationHInstance = NULL; ///< our application instance
/// just to satisfy the game libraries we link to
HWND ApplicationHWnd = NULL;
const Char *g_strFile = "data\\Generals.str";
const Char *g_csfFile = "data\\%s\\Generals.csf";
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// WinMain ====================================================================
/** Application entry point */
//=============================================================================
Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, Int nCmdShow )
{
// start the log
DEBUG_INIT(DEBUG_FLAGS_DEFAULT);
initMemoryManager();
// save application instance
ApplicationHInstance = hInstance;
// allocate a new image packer system
TheImagePacker = new ImagePacker;
if( TheImagePacker == NULL )
return 0;
// initialize the system
if( TheImagePacker->init() == FALSE )
{
delete TheImagePacker;
TheImagePacker = NULL;
return 0;
} // end if
// load the dialog box
DialogBox( hInstance, (LPCTSTR)IMAGE_PACKER_DIALOG,
NULL, (DLGPROC)ImagePackerProc );
// delete the image packer
delete TheImagePacker;
TheImagePacker = NULL;
// close the log
shutdownMemoryManager();
DEBUG_SHUTDOWN();
// all done
return 0;
} // end WinMain

View file

@ -0,0 +1,387 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: DirectorySelect.cpp //////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: DirectorySelect.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Directory selection dialog
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <windows.h>
#include <stdio.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "ImagePacker.h"
#include "Resource.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
static char startDir[ _MAX_PATH ];
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// selectDrive ================================================================
/** Based on the drive of the current working directory, select the
* drive item in the COMBO_DRIVE combo box matching the current
* drive letter */
//=============================================================================
static void selectDrive( HWND dialog )
{
char currDir[ _MAX_PATH ];
char drive;
// get current directory
GetCurrentDirectory( _MAX_PATH, currDir );
// drive letter is the first character
drive = currDir[ 0 ];
// construct string to match in the combo
char string[ 32 ];
sprintf( string, "[-%c-]", drive );
// select the string in the combo
Int index;
index = SendDlgItemMessage( dialog, COMBO_DRIVE,
CB_FINDSTRINGEXACT, -1, (LPARAM)string );
if( index != CB_ERR )
SendDlgItemMessage( dialog, COMBO_DRIVE, CB_SETCURSEL, index, 0 );
} // end selectDrive
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// DirectorySelectProc ========================================================
/** Directory selection dialog */
//=============================================================================
BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam )
{
static char buffer[ _MAX_PATH ];
switch( message )
{
// ------------------------------------------------------------------------
case WM_INITDIALOG:
{
// save our current directory as we start up
GetCurrentDirectory( _MAX_PATH, startDir );
// set the extents for the horizontal scroll bar in the listbox
SendDlgItemMessage( hWndDialog, LIST_DIR,
LB_SETHORIZONTALEXTENT, 1280, 0 );
// load the listbox with directory items
SendDlgItemMessage( hWndDialog, LIST_DIR,
LB_DIR,
DDL_DIRECTORY | DDL_EXCLUSIVE,
(LPARAM)"*.*" );
// set the current directory in the top label
GetCurrentDirectory( _MAX_PATH, buffer );
if( buffer[ strlen( buffer ) - 1 ] != '\\' )
strcat( buffer, "\\" );
SetDlgItemText( hWndDialog, STATIC_CURRENT_DIR, buffer );
// load the drive box
SendDlgItemMessage( hWndDialog, COMBO_DRIVE,
CB_DIR,
DDL_DRIVES | DDL_EXCLUSIVE,
(LPARAM)"*.*" );
// select the right drive in the drive combo box
selectDrive( hWndDialog );
return TRUE;
} // end init
// ------------------------------------------------------------------------
case WM_COMMAND:
{
Int notifyCode = HIWORD( wParam );
Int controlID = LOWORD( wParam );
// HWND hWndControl = (HWND)lParam;
switch( controlID )
{
// --------------------------------------------------------------------
case BUTTON_ADD:
{
Int count;
char text[ _MAX_PATH ];
char toAdd[ _MAX_PATH ];
// get number of items in listbox
count = SendDlgItemMessage( hWndDialog, LIST_DIR, LB_GETCOUNT, 0, 0 );
// for each selected item add that directory
for( Int i = 0; i < count; i++ )
{
// is this item selected
if( SendDlgItemMessage( hWndDialog, LIST_DIR, LB_GETSEL, i, 0 ) > 0 )
{
// get the text
SendDlgItemMessage( hWndDialog, LIST_DIR, LB_GETTEXT,
i, (LPARAM)text );
// remove the brackets on the text
Int j, len = strlen( text );
for( j = 0; j < len - 1; j++ )
text[ j ] = text[ j + 1 ];
text[ len - 2 ] = '\0';
// ignore the ".." directory
if( strcmp( text, ".." ) == 0 )
continue;
//
// construct directory to add, make sure we have a '\' on the
// end cause we assume that in the image file name code
//
sprintf( toAdd, "%s%s\\", buffer, text );
// do not add directory if it's already in the listbox
if( SendDlgItemMessage( TheImagePacker->getWindowHandle(),
LIST_FOLDERS,
LB_FINDSTRINGEXACT, -1, (LPARAM)toAdd ) != LB_ERR )
{
char message[ _MAX_PATH + 32 ];
sprintf( message, "Ignoring folder '%s', already in list.", toAdd );
MessageBox( NULL, message, "Folder Already In List",
MB_OK | MB_ICONINFORMATION );
continue;
} // end if
// add path to the listbox
SendDlgItemMessage( TheImagePacker->getWindowHandle(),
LIST_FOLDERS,
LB_INSERTSTRING, -1, (LPARAM)toAdd );
} // end if
} // end if
SetCurrentDirectory( startDir );
EndDialog( hWndDialog, TRUE );
break;
} // end proceed
// --------------------------------------------------------------------
case BUTTON_CANCEL:
{
SetCurrentDirectory( startDir );
EndDialog( hWndDialog, FALSE );
break;
} // end cancel
// --------------------------------------------------------------------
case COMBO_DRIVE:
{
if( notifyCode == CBN_SELCHANGE )
{
Int selected;
// get selected index
selected = SendDlgItemMessage( hWndDialog, COMBO_DRIVE,
CB_GETCURSEL, 0, 0 );
if( selected != CB_ERR )
{
char string[ 32 ];
SendDlgItemMessage( hWndDialog, COMBO_DRIVE,
CB_GETLBTEXT, selected, (LPARAM)string );
//
// construct a drive letter and colon from the combo
// box strign [-x-]
//
string[ 0 ] = string[ 2 ]; // the drive letter in the form of "[-x-]"
string[ 1 ] = ':';
string[ 2 ] = '\0';
// switch to that drive
SetCurrentDirectory( string );
// construct new direcotry name and update status text
GetCurrentDirectory( _MAX_PATH, buffer );
if( buffer[ strlen( buffer ) - 1 ] != '\\' )
strcat( buffer, "\\" );
SetDlgItemText( hWndDialog, STATIC_CURRENT_DIR, buffer );
EnableWindow( GetDlgItem( hWndDialog, BUTTON_ADD ), FALSE );
// reset the content of the listbox and reload
SendDlgItemMessage( hWndDialog, LIST_DIR,
LB_RESETCONTENT, 0, 0 );
SendDlgItemMessage( hWndDialog, LIST_DIR,
LB_DIR,
DDL_DIRECTORY | DDL_EXCLUSIVE,
(LPARAM)"*.*" );
} // end if
} // end if
break;
} // end drive
// --------------------------------------------------------------------
case LIST_DIR:
{
if( notifyCode == LBN_SELCHANGE )
{
Int selCount;
Bool enable;
// get selected count
selCount = SendDlgItemMessage( hWndDialog, LIST_DIR,
LB_GETSELCOUNT, 0, 0 );
// if we have selected items, enable the add button
if( selCount > 0 )
{
//
// if the selected item is only the ".." directory we won't
// enable it, we know that _IF_ ".." is present it is at the
// top zero index position
//
enable = TRUE;
Int index = 0;
if( selCount == 1 &&
SendDlgItemMessage( hWndDialog, LIST_DIR,
LB_GETSEL, index, 0 ) > 0 )
{
char text[ _MAX_PATH ];
SendDlgItemMessage( hWndDialog, LIST_DIR, LB_GETTEXT,
index, (LPARAM)text );
if( strcmp( text, "[..]" ) == 0 )
enable = FALSE;
} // end if
} // end if
else
enable = FALSE;
// do the enable
EnableWindow( GetDlgItem( hWndDialog, BUTTON_ADD ), enable );
} // end if
if( notifyCode == LBN_DBLCLK )
{
Int selected;
char text[ _MAX_PATH ];
// get currently selected item
selected = SendDlgItemMessage( hWndDialog, LIST_DIR,
LB_GETCURSEL, 0, 0 );
// get text of selected item
SendDlgItemMessage( hWndDialog, LIST_DIR, LB_GETTEXT,
selected, (LPARAM)text );
// strip the backets off the directory listing
Int len = strlen( text );
for( Int i = 0; i < len - 1; i++ )
text[ i ] = text[ i + 1 ];
text[ len - 2 ] = '\0';
// go into that directory
SetCurrentDirectory( text );
// construct new direcotry name and update status text
GetCurrentDirectory( _MAX_PATH, buffer );
if( buffer[ strlen( buffer ) - 1 ] != '\\' )
strcat( buffer, "\\" );
SetDlgItemText( hWndDialog, STATIC_CURRENT_DIR, buffer );
EnableWindow( GetDlgItem( hWndDialog, BUTTON_ADD ), FALSE );
// reset the content of the listbox and reload
SendDlgItemMessage( hWndDialog, LIST_DIR,
LB_RESETCONTENT, 0, 0 );
SendDlgItemMessage( hWndDialog, LIST_DIR,
LB_DIR,
DDL_DIRECTORY | DDL_EXCLUSIVE,
(LPARAM)"*.*" );
} // end if
break;
} // end list command
} // end switch
break;
} // end command
} // end switch message
return 0;
} // end DirectorySelectProc

View file

@ -0,0 +1,175 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: ImageErrorProc.cpp ///////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: ImageErrorProc.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Window procedure for the error dialog
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <stdio.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "ImagePacker.h"
#include "Resource.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// ImageErrorProc =============================================================
/** Dialog proc for the error window */
//=============================================================================
BOOL CALLBACK ImageErrorProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam )
{
switch( message )
{
// ------------------------------------------------------------------------
case WM_INITDIALOG:
{
//
// load the listbox with images that could not be processed
// and the reasons for it
//
// sanity
if( TheImagePacker == NULL )
return TRUE;
// go through all images
Int i, count;
HWND list = GetDlgItem( hWndDialog, LIST_IMAGES );
char buffer[ _MAX_PATH + 256 ];
char reason[ 32 ];
ImageInfo *image;
count = TheImagePacker->getImageCount();
for( i = 0; i < count; i++ )
{
// get image
image = TheImagePacker->getImage( i );
// sanity
if( image == NULL )
continue;
// if image can't be processed find out why
if( BitTest( image->m_status, ImageInfo::CANTPROCESS ) )
{
if( BitTest( image->m_status, ImageInfo::TOOBIG ) )
sprintf( reason, "Too Big" );
else if( BitTest( image->m_status, ImageInfo::INVALIDCOLORDEPTH ) )
sprintf( reason, "Unsupported Color Depth" );
else
sprintf( reason, "Unknown Reason" );
sprintf( buffer, "%s: (%dx%dx%d) %s",
reason, image->m_size.x, image->m_size.y, image->m_colorDepth,
image->m_path );
SendMessage( list, LB_INSERTSTRING, -1, (LPARAM)buffer );
} // end if
} // end for i
// set the extents for the horizontal scroll bar in the listbox
SendMessage( list, LB_SETHORIZONTALEXTENT, 1280, 0 );
return TRUE;
} // end init
// ------------------------------------------------------------------------
case WM_COMMAND:
{
Int controlID = LOWORD( wParam );
// Int notifyCode = HIWORD( wParam );
// HWND hWndControl = (HWND)lParam;
switch( controlID )
{
// --------------------------------------------------------------------
case BUTTON_PROCEED:
{
EndDialog( hWndDialog, TRUE );
break;
} // end proceed
// --------------------------------------------------------------------
case BUTTON_CANCEL:
{
EndDialog( hWndDialog, FALSE );
break;
} // end cancel
} // end switch
break;
} // end command
} // end switch message
return 0;
} // end ImageErrorProc

View file

@ -0,0 +1,407 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: ImagePackerProc.cpp //////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: ImagePackerProc.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Window procedure for the image packer app
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <windows.h>
#include <io.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "ImagePacker.h"
#include "Resource.h"
#include "WindowProc.h"
#include "WinMain.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// ImagePackerProc ============================================================
/** Dialog procedure for the program flow */
//=============================================================================
BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam )
{
switch( message )
{
// ------------------------------------------------------------------------
case WM_INITDIALOG:
{
// we must have our program interface to continue
if( TheImagePacker == NULL )
{
MessageBox( NULL, "Internal Error, 'TheImagePacker' not initialized",
"Internal Error", MB_OK );
EndDialog( hWndDialog, FALSE );
} // end if
// save our window handlw
TheImagePacker->setWindowHandle( hWndDialog );
// get size of the screen
Int x, y;
x = GetSystemMetrics( SM_CXFULLSCREEN );
y = GetSystemMetrics( SM_CYFULLSCREEN );
// get size of our dialog
RECT rect;
ICoord2D size;
GetWindowRect( hWndDialog, &rect );
size.x = rect.right - rect.left;
size.y = rect.bottom - rect.top;
// center dialog on screen
MoveWindow( hWndDialog,
(x / 2) - (size.x / 2),
(y / 2) - (size.y / 2),
size.x,
size.y,
TRUE );
// setup the status message
TheImagePacker->statusMessage( "Select options and click 'Start'." );
// set gutter size
SetDlgItemInt( hWndDialog, EDIT_GUTTER, TheImagePacker->getGutter(), FALSE );
// set alpha check
if( TheImagePacker->getOutputAlpha() )
CheckDlgButton( hWndDialog, CHECK_ALPHA, BST_CHECKED );
// set the check for preview using the actual texture
if( TheImagePacker->getUseTexturePreview() )
CheckDlgButton( hWndDialog, CHECK_BITMAP_PREVIEW, BST_CHECKED );
// set the check for creating INI definition
if( TheImagePacker->createINIFile() )
CheckDlgButton( hWndDialog, CHECK_INI, BST_CHECKED );
// check the resursive checkbox by default
CheckDlgButton( hWndDialog, CHECK_USE_SUB_FOLDERS, BST_CHECKED );
// check the default image size radio button
CheckDlgButton( hWndDialog, RADIO_512X512, BST_CHECKED );
// fill out a default target filename
SetDlgItemText( hWndDialog, EDIT_FILENAME, "NewImage" );
// limit the size if the filename edit box
SendDlgItemMessage( hWndDialog, EDIT_FILENAME,
EM_LIMITTEXT, MAX_OUTPUT_FILE_LEN, 0 );
// set options for compressed textures
if( TheImagePacker->getCompressTextures() )
CheckDlgButton( hWndDialog, CHECK_COMPRESS, BST_CHECKED );
// set option checks for gap method
UnsignedInt gapOptions = TheImagePacker->getGapMethod();
if( BitTest( gapOptions, ImagePacker::GAP_METHOD_EXTEND_RGB ) )
CheckDlgButton( hWndDialog, CHECK_GAP_EXTEND_RGB, BST_CHECKED );
if( BitTest( gapOptions, ImagePacker::GAP_METHOD_GUTTER ) )
CheckDlgButton( hWndDialog, CHECK_GAP_GUTTER, BST_CHECKED );
return TRUE;
} // end init dialog
// ------------------------------------------------------------------------
case WM_COMMAND:
{
Int notifyCode = HIWORD( wParam );
Int controlID = LOWORD( wParam );
// HWND hWndControl = (HWND)lParam;
switch( controlID )
{
// --------------------------------------------------------------------
case BUTTON_PREVIOUS:
{
Int page = TheImagePacker->getTargetPreviewPage();
// target preview page back one
if( page > 1 )
{
page--;
TheImagePacker->setTargetPreviewPage( page );
UpdatePreviewWindow();
} // end if
break;
} // end previous
// --------------------------------------------------------------------
case BUTTON_NEXT:
{
UnsignedInt page = TheImagePacker->getTargetPreviewPage();
if( page < TheImagePacker->getPageCount() )
{
page++;
TheImagePacker->setTargetPreviewPage( page );
UpdatePreviewWindow();
} // end if
break;
} // end next
// --------------------------------------------------------------------
case CHECK_BITMAP_PREVIEW:
{
Bool useBitmap;
if( IsDlgButtonChecked( hWndDialog, controlID ) == BST_CHECKED )
useBitmap = TRUE;
else
useBitmap = FALSE;
TheImagePacker->setUseTexturePreview( useBitmap );
UpdatePreviewWindow();
break;
} // end preview using image
// --------------------------------------------------------------------
case CHECK_GAP_GUTTER:
{
Bool enable = FALSE;
if( IsDlgButtonChecked( hWndDialog, controlID ) == BST_CHECKED )
enable = TRUE;
EnableWindow( GetDlgItem( hWndDialog, STATIC_GAP_INFO ), enable );
EnableWindow( GetDlgItem( hWndDialog, EDIT_GUTTER ), enable );
break;
} // end transparent gutter
// --------------------------------------------------------------------
case BUTTON_PREVIEW:
{
HWND preview = TheImagePacker->getPreviewWindow();
if( preview )
{
// delete test display window
DestroyWindow( preview );
TheImagePacker->setPreviewWindow( NULL );
SetDlgItemText( hWndDialog, BUTTON_PREVIEW, "Open Preview" );
} // end if
else
{
HWND preview = MakePreviewDisplay();
if( preview )
{
TheImagePacker->setPreviewWindow( preview );
UpdatePreviewWindow();
SetDlgItemText( hWndDialog, BUTTON_PREVIEW, "Close Preview" );
} // end if
} // end else
break;
} // end test
// --------------------------------------------------------------------
case BUTTON_ADD_FOLDER:
{
// bring up the add directory dialog
DialogBox( ApplicationHInstance,
(LPCTSTR)DIRECTORY_SELECT_DIALOG,
TheImagePacker->getWindowHandle(),
(DLGPROC)DirectorySelectProc );
break;
} // end add folder
// --------------------------------------------------------------------
case BUTTON_REMOVE_FOLDER:
{
HWND folderList;
// get the directory listbox
folderList = GetDlgItem( hWndDialog, LIST_FOLDERS );
if( folderList == NULL )
break;;
// get the selected item in the folder listbox
Int selCount;
selCount = SendMessage( folderList, LB_GETSELCOUNT, 0, 0 );
if( selCount == 0 )
{
MessageBox( NULL, "You must first select a folder to remove it",
"Select Folder First", MB_OK | MB_ICONINFORMATION );
break;
} // end if
//
// start at the end of the listbox, delete any items that
// are selected
//
Int itemCount = SendMessage( folderList, LB_GETCOUNT, 0, 0 );
for( Int i = itemCount - 1; i >= 0; i-- )
if( SendMessage( folderList, LB_GETSEL, i, 0 ) > 0 )
SendMessage( folderList, LB_DELETESTRING, i, 0 );
break;
} // end remove folder
// --------------------------------------------------------------------
case RADIO_128X128:
case RADIO_256X256:
case RADIO_512X512:
case RADIO_TARGET_OTHER:
{
Bool enable;
//
// if this is the other button, enable the first edit box for
// user size, if not, disable that section of the UI
//
enable = IsDlgButtonChecked( hWndDialog, RADIO_TARGET_OTHER );
EnableWindow( GetDlgItem( hWndDialog, EDIT_WIDTH ), enable );
EnableWindow( GetDlgItem( hWndDialog, STATIC_X ), enable );
break;
} // end target image size radio buttons
// --------------------------------------------------------------------
case EDIT_WIDTH:
{
switch( notifyCode )
{
// ----------------------------------------------------------------
case EN_UPDATE:
{
char buffer[ 32 ];
//
// the text of the width has changed, since our requirements
// are that the image must be square automatically update
// the height box as well
//
GetDlgItemText( hWndDialog, EDIT_WIDTH, buffer, 32 );
SetDlgItemText( hWndDialog, EDIT_HEIGHT, buffer );
break;
} // end update
} // end switch
break;
} // end user defined width
// --------------------------------------------------------------------
case BUTTON_START:
{
Bool success;
// get all the options from the dialog into the image packer
success = TheImagePacker->getSettingsFromDialog( hWndDialog );
// run the packer if nothing went wrong
if( success )
TheImagePacker->process();
break;
} // end execute
// --------------------------------------------------------------------
case BUTTON_EXIT:
{
// quit the program
EndDialog( hWndDialog, TRUE );
break;
} // end exit
} // end switch
return 0;
} // end command
} // end switch
return 0;
} // end ImagePackerProc

View file

@ -0,0 +1,163 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: PageErrorProc.cpp ////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: PageErrorProc.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Window procedure for the error dialog for texture pages
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <stdio.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "ImagePacker.h"
#include "Resource.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PageErrorProc ==============================================================
/** Dialog proc for the error window */
//=============================================================================
BOOL CALLBACK PageErrorProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam )
{
switch( message )
{
// ------------------------------------------------------------------------
case WM_INITDIALOG:
{
//
// load the listbox with pages that could not be processed
// and the reasons for it
//
// sanity
if( TheImagePacker == NULL )
return TRUE;
// go through all pages
TexturePage *page;
HWND list = GetDlgItem( hWndDialog, LIST_PAGES );
char buffer[ _MAX_PATH + 256 ];
char reason[ 32 ];
for( page = TheImagePacker->getFirstTexturePage();
page;
page = page->m_next )
{
// if image can't be processed find out why
if( BitTest( page->m_status, TexturePage::PAGE_ERROR ) )
{
if( BitTest( page->m_status, TexturePage::CANT_ALLOCATE_PACKED_IMAGE ) )
sprintf( reason, "Can't allocate image memory" );
else if( BitTest( page->m_status, TexturePage::CANT_ADD_IMAGE_DATA ) )
sprintf( reason, "Can't add image(s) data" );
else if( BitTest( page->m_status, TexturePage::NO_TEXTURE_DATA ) )
sprintf( reason, "No texture data to write" );
else if( BitTest( page->m_status, TexturePage::ERROR_DURING_SAVE ) )
sprintf( reason, "Error writing texture file" );
else
sprintf( reason, "Unknown Reason" );
sprintf( buffer, "%s: (%dx%d) %s%d",
reason, page->getWidth(), page->getHeight(),
TheImagePacker->getOutputFile(), page->getID() );
SendMessage( list, LB_INSERTSTRING, -1, (LPARAM)buffer );
} // end if
} // end for i
// set the extents for the horizontal scroll bar in the listbox
SendMessage( list, LB_SETHORIZONTALEXTENT, 1280, 0 );
return TRUE;
} // end init
// ------------------------------------------------------------------------
case WM_COMMAND:
{
Int controlID = LOWORD( wParam );
// Int notifyCode = HIWORD( wParam );
// HWND hWndControl = (HWND)lParam;
switch( controlID )
{
// --------------------------------------------------------------------
case IDOK:
{
EndDialog( hWndDialog, TRUE );
break;
} // end proceed
} // end switch
break;
} // end command
} // end switch message
return 0;
} // end PageErrorProc

View file

@ -0,0 +1,267 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FILE: PreviewProc.cpp //////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: ImagePacker
//
// File name: PreviewProc.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Window procedure for the preview window
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <windows.h>
#include <stdio.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "ImagePacker.h"
#include "WinMain.h"
///////////////////////////////////////////////////////////////////////////////
// DEFINES ////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#define PREVIEW_STYLE WS_CAPTION
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PreviewProc ================================================================
/** */
//=============================================================================
LRESULT CALLBACK PreviewProc( HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc;
HBRUSH whiteBrush = (HBRUSH)GetStockObject( WHITE_BRUSH );
hdc = BeginPaint(hWnd, &ps);
SelectObject( hdc, GetStockObject( WHITE_PEN ) );
// find the target texture page
TexturePage *page;
for( page = TheImagePacker->getFirstTexturePage();
page;
page = page->m_next )
{
// if this is not the target page, ignore it
if( page->getID() != TheImagePacker->getTargetPreviewPage() )
continue;
// draw image based on the generated texture or silhouette
if( TheImagePacker->getUseTexturePreview() )
{
Int x, y;
Byte r, g, b;
HPEN prevPen, pen;
for( y = 0; y < page->getHeight(); y++ )
{
for( x = 0; x < page->getWidth(); x++ )
{
// get the color here
page->getPixel( x, y, &r, &g, &b );
// create a new pen of the right color
pen = CreatePen( 1, 1, RGB( r, g, b, ) );
// select pen into hdc
prevPen = (HPEN)SelectObject( hdc, pen );
// draw ... what is the Win32 put pixel function???
MoveToEx( hdc, x, y, NULL );
LineTo( hdc, x + 1, y );
// put the old pen back
SelectObject( hdc, prevPen );
// delete the created pen
DeleteObject( pen );
} // end for x
} // end for y
} // end if
else
{
// go through all the images on this page
ImageInfo *image;
for( image = page->getFirstImage();
image;
image = image->m_nextPageImage )
{
RECT rect;
rect.left = image->m_pagePos.lo.x;
rect.top = image->m_pagePos.lo.y;
rect.right = image->m_pagePos.hi.x + 1; // FillRect not inclusive
rect.bottom = image->m_pagePos.hi.y + 1; // FillRect not inclusive
FillRect( hdc, &rect, whiteBrush );
} // end for image
} // end else
} // end for page
EndPaint( hWnd, &ps );
break;
} // end paint
} // end switch
return DefWindowProc( hWnd, message, wParam, lParam );
} // end PreviewProc
// MakePreviewDisplay =========================================================
/** */
//=============================================================================
HWND MakePreviewDisplay( void )
{
WNDCLASSEX wcex;
char *className = "PreviewDisplay";
HWND hWnd;
wcex.cbSize = sizeof( WNDCLASSEX );
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)PreviewProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = ApplicationHInstance;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
wcex.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wcex.lpszMenuName = NULL;
wcex.lpszClassName = className;
wcex.hIconSm = NULL;
RegisterClassEx( &wcex );
// create app window and keep handle
hWnd = CreateWindowEx( 0, // extended style
className, // window class name
"Preview", // window name
PREVIEW_STYLE, // window styles
30, // x position
30, // y position
TheImagePacker->getTargetWidth(),
TheImagePacker->getTargetHeight(),
NULL, // parent
NULL, // menu
ApplicationHInstance, // instance
NULL ); // creation data
if( hWnd == NULL )
return NULL;
// display the window
ShowWindow( hWnd, SW_SHOW );
return hWnd;
} // end MakePreviewDisplay
// UpdatePreviewWindow ========================================================
/** Update the preview window, if present */
//=============================================================================
void UpdatePreviewWindow( void )
{
HWND preview;
// sanity
if( TheImagePacker == NULL )
return;
// get preview window
preview = TheImagePacker->getPreviewWindow();
// if window not here don't bother
if( preview == NULL )
return;
// make the title
char title[ 256 ];
// construct title
sprintf( title, "Page #%d of %d",
TheImagePacker->getTargetPreviewPage(),
TheImagePacker->getPageCount() );
SetWindowText( preview, title );
// adjust the window rect so the client area is the target packed size
RECT clientRect;
POINT p;
p.x = 0;
p.y = 0;
ClientToScreen( preview, &p );
clientRect.left = p.x;
clientRect.right = clientRect.left + TheImagePacker->getTargetWidth();
clientRect.top = p.y;
clientRect.bottom = clientRect.top + TheImagePacker->getTargetHeight();
AdjustWindowRect( &clientRect, PREVIEW_STYLE, FALSE );
MoveWindow( preview,
clientRect.left,
clientRect.top,
clientRect.right - clientRect.left,
clientRect.bottom - clientRect.top,
TRUE );
// invalidate the client area for redraw
InvalidateRect( preview, NULL, TRUE );
} // end UpdatePreviewWindow