00001
#include "StdAfx.h"
00002
#include "AddAnimationSettings.h"
00003
00004 CAddAnimationSettings::CAddAnimationSettings()
00005 {
00006 m_pCurrentAnimation = NULL;
00007 m_pstrAnimationNames = m_pstrAnimationFilenames = NULL;
00008
00009 m_iLoopCount = m_iFrameCount = 0;
00010 m_iAnimationIndex = 0;
00011 m_iAnimationID = 1;
00012
00013
if(
CAnimationManager::GetSingletonPtr() == NULL)
00014
return;
00015
00016
if(
CAnimationManager::GetSingleton().
size() > 0)
00017 {
00018 m_pstrAnimationNames =
new CString[
CAnimationManager::GetSingleton().
size()];
00019 m_pstrAnimationFilenames =
new CString[
CAnimationManager::GetSingleton().
size()];
00020 }
00021
else
00022 m_pstrAnimationNames = m_pstrAnimationFilenames = NULL;
00023 }
00024
00025 CAddAnimationSettings::~CAddAnimationSettings()
00026 {
00027 SAFEDEL_ARRAY(m_pstrAnimationNames)
00028 SAFEDEL_ARRAY(m_pstrAnimationFilenames)
00029 }
00030
00031
bool CAddAnimationSettings::PropertyChanging( const
void* pvProperty ,
void* pvNewValue )
00032 {
00033
bool bChangeOK = CAddResourceSettings::PropertyChanging(pvProperty, pvNewValue);
00034
00035
if(
CAnimationManager::GetSingletonPtr() == NULL)
00036
return false;
00037
00038
if(pvProperty == &m_strResourceName)
00039 {
00040
CAnimation *pAnimation =
CAnimationManager::GetSingleton().
GetResource(-1, -1, (*(CString *)pvNewValue),
"");
00041
if(pAnimation !=NULL)
00042
return false;
00043
else
00044 {
00045 m_strResourceName = *(CString *)pvNewValue;
00046 m_pCurrentAnimation->SetName(m_strResourceName);
00047
00048
for (
int i=0; i<
CAnimationManager::GetSingleton().
size(); i++)
00049 {
00050
CAnimation *pAnimation = (
CAnimation *)
CAnimationManager::GetSingleton().
at(i);
00051
if(pAnimation == m_pCurrentAnimation)
00052 {
00053 m_iAnimationIndex = i;
00054
break;
00055 }
00056 }
00057
00058 m_bUpdateRequired =
true;
00059 }
00060 }
00061
00062
if(pvProperty == &m_strResourceXMLFilename)
00063 {
00064
CAnimation *pAnimation =
CAnimationManager::GetSingleton().
LoadResource(NULL, (*(CString *)pvNewValue));
00065
if(pAnimation != NULL && m_pCurrentAnimation !=pAnimation)
00066 {
00067 m_pCurrentAnimation = pAnimation;
00068 m_strResourceXMLFilename = *(CString *)pvNewValue;
00069 m_strResourceName = pAnimation->
GetName();
00070
00071 m_bUpdateRequired =
true;
00072 }
00073 }
00074
00075
if(pvProperty == &m_strResourcesDatabaseFilename)
00076 {
00077
int iRetValue =
CAnimationManager::GetSingleton().
LoadXML(NULL, (*(CString *)pvNewValue));
00078
00079
00080
00081 m_strResourcesDatabaseFilename = *(CString *)pvNewValue;
00082
00083 m_bUpdateRequired =
true;
00084 }
00085
00086
if(pvProperty == &m_iAnimationIndex)
00087 {
00088
int iTempTexIndex = *(
int *)pvNewValue;
00089
CAnimation *pAnimation =
CAnimationManager::GetSingleton().
GetResource(iTempTexIndex);
00090
00091 m_strResourceName = pAnimation->
GetName();
00092 m_iAnimationIndex = iTempTexIndex;
00093 m_pCurrentAnimation = pAnimation;
00094
00095 m_bUpdateRequired =
true;
00096 }
00097
00098
return bChangeOK;
00099 }
00100
00101
void CAddAnimationSettings::GetProperties( EPropList& PropList )
00102 {
00103 CAddResourceSettings::GetProperties(PropList);
00104
00105
if(
CAnimationManager::GetSingletonPtr() == NULL)
00106
return;
00107
00108
if(m_pCurrentAnimation !=NULL)
00109 {
00110
if(m_pCurrentAnimation->GetEntityType() == Entity_TextureFrameAnimation)
00111 {
00112 m_iFrameCount = ((
CTextureFrameAnimation *)m_pCurrentAnimation)->GetFrameCount();
00113 m_iLoopCount = ((
CTextureFrameAnimation *)m_pCurrentAnimation)->GetLoopCount();
00114 }
00115 }
00116 PropList.AddTab(
"Animation(s)");
00117 PropList.AddPropSeparator(
this,
"Tools");
00118
00119 EPropertyCombo *pAnimationCombo = PropList.AddPropCombo(
this,
"Animation", &m_iAnimationIndex);
00120
for (
int i=0; i<
CAnimationManager::GetSingleton().
size(); i++)
00121 {
00122
CAnimation *pAnimation = (
CAnimation *)
CAnimationManager::GetSingleton().
at(i);
00123 pAnimationCombo->AddString(pAnimation->
GetName(), i);
00124 }
00125
00126 PropList.AddPropFile(
this,
"XML File", &m_strResourceXMLFilename,
"XML Files (*.xml)|*.xml|All Files (*.*)|*.*||")->SetComment(
"Animation XML File");
00127 PropList.AddPropFile(
this,
"XML Database", &m_strResourcesDatabaseFilename,
"XML Files (*.xml)|*.xml|All Files (*.*)|*.*||")->SetComment(
"Animations Database XML File");
00128
00129 PropList.AddPropSeparator(
this,
"Attributes");
00130 PropList.AddPropInt(
this,
"Frames", &m_iFrameCount,
"",
false)->SetComment(
"Animation' Frame Count");
00131 PropList.AddPropInt(
this,
"Loops", &m_iLoopCount,
"",
false)->SetComment(
"Animation' Loop Count");
00132 }