Files
source/Tactical/InterfaceItemImages.cpp
T
MaddMugsy 49a590ed34 1. PItems are now variable, from 3-20 and can be set in JA2Options.ini via NUM_P_ITEMS
2. USE_XML_TILESETS moved from JA2.ini to JA2Options.ini
3. New Feature - Ctrl+Click on an item with an item in hand to auto-attach/merge them.  Attach works with stacks.  Merge only works on single items, for now at least.
4. New Feature - To accompany Quiet Training, there are now Quiet Repairing and Quiet Doctoring options.
5. Bugfix - inseparable attachments of attachments were getting lost again when using ctrl+f/the map screen button to remove attachments
6. Bugfix - INT8 overflow error causing vehicle repair to actually lower its status
7. GasMask tag in items.xml can now be applied to helmets as well as face items.
8. Bugfix - AI code was referencing hard coded GASMASK item number instead of looking for the tag
9. Bugfix - "break;" was removed in Explosion Control.cpp, thereby causing mustard gas to deal out fire damage. (Not sure if this was deliberate?  But the new implementation differs from the JA2 standard, so it should be added to JA2Options.ini at least)

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5320 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2012-05-30 10:19:53 +00:00

135 lines
3.6 KiB
C++

#include "InterfaceItemImages.h"
#include "DEBUG.H"
#include "vobject.h"
#include "utilities.h"
#include "GameSettings.h"
#include <vfs/Core/vfs.h>
extern void WriteMessageToFile( const STR16 pString );
/******************************************************************************/
bool g_bUsePngItemImages = false;
// old item image handles
UINT32 guiGUNSM;
UINT32 guiPITEMS[MAX_PITEMS];
// new item image handles
MDItemVideoObjects g_oGUNSM;
MDItemVideoObjects g_oPITEMS[MAX_PITEMS];
/******************************************************************************/
MDItemVideoObjects::MDItemVideoObjects()
{}
UINT32 MDItemVideoObjects::getVObjectForItem(UINT32 key)
{
std::map<UINT32,UINT32>::iterator it = m_mapVObjects.find(key);
if(it != m_mapVObjects.end())
{
return it->second;
}
SGP_THROW(_BS(L"Item key not registered : ") << key << _BS::wget);
}
void MDItemVideoObjects::registerItem(UINT32 key, vfs::Path const& sFileName)
{
std::map<UINT32,UINT32>::iterator it = m_mapVObjects.find(key);
if(it != m_mapVObjects.end())
{
SGP_THROW(_BS(L"Item image already registered : ") << key << _BS::wget);
}
// LOAD INTERFACE GUN PICTURES
UINT32 uiVObject;
VOBJECT_DESC VObjectDesc;
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP(const_cast<STR>(sFileName.to_string().c_str()), VObjectDesc.ImageFile);
if(! AddVideoObject( &VObjectDesc, &uiVObject ))
{
SGP_THROW(_BS(L"Could not add video object for file \"") << sFileName << _BS::wget);
}
m_mapVObjects.insert(std::make_pair(key,uiVObject));
}
bool MDItemVideoObjects::registerItemsFromFilePattern(vfs::Path const& sFilePattern)
{
std::wstringstream wss;
int item = 0;
vfs::CVirtualFileSystem::Iterator it = getVFS()->begin(sFilePattern);
if(it.end())
{
return false;
}
for(; !it.end(); it.next())
{
wss.str(it.value()->getName().c_wcs());
if( !(wss >> item) )
{
std::wstring err = _BS(L"Could not extract item number from file \"") << wss.str() << L"\"" << _BS::wget;
WriteMessageToFile( const_cast<STR16>(err.c_str()) );
continue;
}
try
{
this->registerItem(item, it.value()->getPath());
}
catch(std::exception& ex)
{
SGP_RETHROW( _BS(L"Registering item from file \"") << wss.str() << L"\" failed" << _BS::wget, ex );
}
}
return true;
}
void MDItemVideoObjects::unRegisterAllItems()
{
std::map<UINT32,UINT32>::iterator it = m_mapVObjects.begin();
for(; it != m_mapVObjects.end(); ++it)
{
// later
}
}
/******************************************************************************/
bool RegisterItemImages()
{
VOBJECT_DESC VObjectDesc;
//// LOAD INTERFACE GUN PICTURES
if(!g_bUsePngItemImages)
{
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\mdguns.sti", VObjectDesc.ImageFile);
if( !AddVideoObject( &VObjectDesc, &guiGUNSM ) )
AssertMsg(0, "Missing INTERFACE\\mdguns.sti" );
}
else if(!g_oGUNSM.registerItemsFromFilePattern(L"INTERFACE/mdguns/*.png"))
{
return false;
}
for (UINT8 ubLoop = 0; ubLoop < gGameExternalOptions.ubNumPItems; ubLoop++)
{
// LOAD INTERFACE ITEM PICTURES
if(!g_bUsePngItemImages)
{
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP(String("INTERFACE\\mdp%ditems.sti",ubLoop+1), VObjectDesc.ImageFile);
if( !AddVideoObject( &VObjectDesc, &guiPITEMS[ubLoop] ) )
AssertMsg(0, String("Missing INTERFACE\\mdp%ditems.sti",ubLoop+1) );
}
else if(!g_oPITEMS[ubLoop].registerItemsFromFilePattern(String("INTERFACE/MDP%dITEMS/*.png",ubLoop+1)))
{
return false;
}
}
return true;
}