Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

D:/Programming/GUI Editor (Source)/AddTextureSettings.cpp

00001 #include "StdAfx.h" 00002 #include "AddTextureSettings.h" 00003 00004 CAddTextureSettings::CAddTextureSettings() 00005 { 00006 m_pCurrentTexture = NULL; 00007 m_strResourceRawFilename = ""; 00008 m_iTextureIndex = 0; 00009 m_TextureMask = 0; 00010 m_iTextureID = 1; 00011 } 00012 00013 CAddTextureSettings::~CAddTextureSettings() 00014 { 00015 00016 } 00017 00018 bool CAddTextureSettings::PropertyChanging( const void* pvProperty , void* pvNewValue ) 00019 { 00020 bool bChangeOK = CAddResourceSettings::PropertyChanging(pvProperty, pvNewValue); 00021 00022 if(CTextureManager::GetSingletonPtr() == NULL) 00023 return false; 00024 00025 if(pvProperty == &m_strResourceName) // strName has been changed, see if there are duplicates 00026 { 00027 CTexture *pTexture = CTextureManager::GetSingleton().GetResource(-1, -1, (*(CString *)pvNewValue), ""); 00028 if(pTexture !=NULL) 00029 return false; 00030 else 00031 { 00032 m_strResourceName = *(CString *)pvNewValue; 00033 m_pCurrentTexture->SetName(m_strResourceName); 00034 00035 for (int i=0; i<CTextureManager::GetSingleton().size(); i++) 00036 { 00037 CTexture *pTexture = (CTexture *)CTextureManager::GetSingleton().at(i); 00038 if(pTexture == m_pCurrentTexture) 00039 { 00040 m_iTextureIndex = i; 00041 m_TextureMask = RGB(pTexture->GetMask().R, pTexture->GetMask().G, pTexture->GetMask().B); 00042 m_strResourceRawFilename = pTexture->GetFilename(); 00043 break; 00044 } 00045 } 00046 00047 m_bUpdateRequired = true; 00048 } 00049 } 00050 00051 if(pvProperty == &m_strResourceRawFilename) 00052 { 00053 if(m_pCurrentTexture == NULL) 00054 return false; 00055 00056 CTexture *pDuplTexture = (CTexture *)CTextureManager::GetSingleton().begin(); 00057 CTextureManager::GetSingleton().set_ptr(pDuplTexture); 00058 00059 while(pDuplTexture !=NULL) 00060 { 00061 if(pDuplTexture->GetTextureFilename() == (*(CString *)pvNewValue)) 00062 return false; 00063 00064 pDuplTexture = (CTexture *)CTextureManager::GetSingleton().next(); 00065 } 00066 00067 m_pCurrentTexture->Destroy(); 00068 m_pCurrentTexture->LoadImage((*(CString *)pvNewValue)); 00069 m_pCurrentTexture->Create(); 00070 00071 m_strResourceRawFilename = *(CString *)pvNewValue; 00072 00073 } 00074 00075 if(pvProperty == &m_strResourceXMLFilename) 00076 { 00077 CTexture *pNewTexture = NULL; 00078 if(m_pCurrentTexture !=NULL) 00079 { 00080 m_pCurrentTexture->Destroy(); 00081 00082 m_pCurrentTexture->LoadXML(NULL, (*(CString *)pvNewValue)); 00083 pNewTexture = m_pCurrentTexture; 00084 } 00085 else 00086 { 00087 pNewTexture = CTextureManager::GetSingleton().LoadResource(NULL, (*(CString *)pvNewValue)); 00088 m_pCurrentTexture = pNewTexture; 00089 } 00090 00091 m_strResourceXMLFilename = *(CString *)pvNewValue; 00092 m_strResourceRawFilename = pNewTexture->GetFilename(); 00093 m_strResourceName = pNewTexture->GetName(); 00094 m_TextureMask = RGB(pNewTexture->GetMask().R, pNewTexture->GetMask().G, pNewTexture->GetMask().B); 00095 00096 m_bUpdateRequired = true; 00097 00098 } 00099 00100 if(pvProperty == &m_strResourcesDatabaseFilename) 00101 { 00102 int iRetValue = CTextureManager::GetSingleton().LoadXML(NULL, (*(CString *)pvNewValue)); 00103 if(iRetValue > 0) 00104 m_bUpdateRequired = true; 00105 00106 return false; 00107 } 00108 00109 if(pvProperty == &m_TextureMask) 00110 { 00111 if(m_pCurrentTexture !=NULL) 00112 { 00113 m_TextureMask = *(COLORREF *)pvNewValue; 00114 if((m_pCurrentTexture->GetMask().R != (float)GetRValue(m_TextureMask)) || (m_pCurrentTexture->GetMask().G != (float)GetGValue(m_TextureMask)) || (m_pCurrentTexture->GetMask().B != (float)GetBValue(m_TextureMask) )) 00115 { 00116 m_pCurrentTexture->Release(); 00117 m_pCurrentTexture->SetMask(tRGBA((float)GetRValue(m_TextureMask), (float)GetGValue(m_TextureMask), (float)GetBValue(m_TextureMask))); 00118 m_pCurrentTexture->Create(); 00119 } 00120 } 00121 } 00122 00123 if(pvProperty == &m_iTextureIndex) 00124 { 00125 int iTempTexIndex = *(int *)pvNewValue; 00126 CTexture *pTexture = CTextureManager::GetSingleton().GetResource(iTempTexIndex); 00127 if(iTempTexIndex == 1000) 00128 { 00129 CString NewTexName; 00130 NewTexName.Format("Texture #%d", m_iTextureID); 00131 00132 m_pCurrentTexture = CTextureManager::GetSingleton().AddResource(NewTexName); 00133 m_pCurrentTexture->SetName(NewTexName); 00134 00135 m_strResourceName = NewTexName; 00136 m_strResourceRawFilename = ""; 00137 m_TextureMask = 0; 00138 m_iTextureIndex = CTextureManager::GetSingleton().size() - 1; 00139 m_iTextureID++; 00140 m_bUpdateRequired = true; 00141 return false; 00142 } 00143 else 00144 { 00145 m_strResourceName = pTexture->GetName(); 00146 m_strResourceRawFilename = pTexture->GetTextureFilename(); 00147 m_TextureMask = RGB(pTexture->GetMask().R, pTexture->GetMask().G, pTexture->GetMask().B); 00148 m_iTextureIndex = iTempTexIndex; 00149 m_pCurrentTexture = pTexture; 00150 } 00151 } 00152 00153 /*if(pvProperty == &m_bDeleteResource) 00154 { 00155 delete CTextureManager::GetSingleton().remove(m_pCurrentTexture); 00156 m_pCurrentTexture = NULL; 00157 00158 m_strResourceName = ""; 00159 m_strResourceRawFilename = ""; 00160 m_strResourceXMLFilename = ""; 00161 m_bUpdateRequired = true; 00162 return false; 00163 }*/ 00164 00165 return bChangeOK; 00166 } 00167 00168 void CAddTextureSettings::GetProperties( EPropList& PropList ) 00169 { 00170 CAddResourceSettings::GetProperties(PropList); 00171 00172 if(CTextureManager::GetSingletonPtr() == NULL) 00173 return; 00174 00175 PropList.AddTab("Texture(s)"); 00176 PropList.AddPropSeparator(this, "Tools"); 00177 00178 EPropertyCombo *pTextureCombo = PropList.AddPropCombo(this, "Texture", &m_iTextureIndex); 00179 pTextureCombo->AddString("New Texture", 1000); 00180 for (int i=0; i<CTextureManager::GetSingleton().size(); i++) 00181 { 00182 CTexture *pTexture = (CTexture *)CTextureManager::GetSingleton().at(i); 00183 pTextureCombo->AddString(pTexture->GetName(), i); 00184 } 00185 00186 PropList.AddPropFile(this, "XML File", &m_strResourceXMLFilename, "XML Files (*.xml)|*.xml|All Files (*.*)|*.*||")->SetComment("Texture XML File"); 00187 PropList.AddPropFile(this, "XML Database", &m_strResourcesDatabaseFilename, "XML Files (*.xml)|*.xml|All Files (*.*)|*.*||")->SetComment("Textures Database XML File"); 00188 00189 PropList.AddPropSeparator(this, "Attributes"); 00190 PropList.AddPropString(this, "strName", &m_strResourceName, true)->SetComment("Texture strName"); 00191 PropList.AddPropColor(this, "Mask", &m_TextureMask, true)->SetComment("Texture' Mask Color"); 00192 PropList.AddPropFile(this, "Image File", &m_strResourceRawFilename, "Image Files (*.jpg;*.bmp;*.png;*.tga)|*.jpg;*.bmp;*.png;*.tga|All Files (*.*)|*.*||")->SetComment("Image strFilename"); 00193 }

Generated on Sun Jul 17 21:34:26 2005 for OpenGL GUI by doxygen 1.3.8