Commit 9c7030ed authored by D-AIRY's avatar D-AIRY

EditorObject implementation (part)

parent fa3b273d
......@@ -82,6 +82,5 @@ IXEditorObject *CEditable::getObject(UINT id)
}
IXEditorObject *CEditable::newObject(const char *szClassName)
{
return(new CEditorObject(this));
return(NULL);
return(new CEditorObject(this, szClassName));
}
......@@ -13,6 +13,8 @@ CEditorObject::CEditorObject(CEditable *pEditable, CBaseEntity *pEntity):
m_szClassName = pEntity->getClassName();
_iniFieldList();
m_vPos = pEntity->getPos();
//@TODO: fix me
m_vScale = float3(1.0f);
......@@ -22,8 +24,10 @@ CEditorObject::CEditorObject(CEditable *pEditable, CBaseEntity *pEntity):
CEditorObject::CEditorObject(CEditable *pEditable, const char *szClassName):
m_pEditable(pEditable)
{
m_pEntity = CREATE_ENTITY(szClassName, GameData::m_pMgr);
m_szClassName = m_pEntity->getClassName();
m_szClassName = CEntityFactoryMap::GetInstance()->getClassNamePtr(szClassName);
assert(m_szClassName);
_iniFieldList();
}
CEditorObject::~CEditorObject()
......@@ -31,6 +35,51 @@ CEditorObject::~CEditorObject()
}
void CEditorObject::_iniFieldList()
{
proptable_t *pTable = CEntityFactoryMap::GetInstance()->getPropTable(m_szClassName);
propdata_t *pField = NULL;
X_PROP_FIELD xField;
while(pTable)
{
for(int i = 0; i < pTable->numFields; ++i)
{
pField = &pTable->pData[i];
if(
!(pField->flags & (PDFF_INPUT | PDFF_MESSAGE | PDFF_NOEDIT | PDFF_OUTPUT))
&& pField->szKey
&& pField->szEdName
&& pField->editor.type != PDE_NONE
)
{
switch(pField->editor.type)
{
case PDE_COMBOBOX:
xField.editorType = XPET_COMBO;
xField.pEditorData = pField->editor.pData;
break;
case PDE_FILEFIELD:
xField.editorType = XPET_FILE;
break;
case PDE_FLAGS:
continue;
break;
case PDE_TEXTFIELD:
xField.editorType = XPET_TEXT;
break;
}
xField.szHelp = "";
xField.szKey = pField->szKey;
xField.szName = pField->szEdName;
m_aFields.push_back(xField);
}
}
pTable = pTable->pBaseProptable;
}
}
void CEditorObject::setPos(const float3_t &pos)
{
if(m_pEntity)
......@@ -65,6 +114,8 @@ void CEditorObject::getBound(float3 *pvMin, float3 *pvMax)
return;
}
m_pEntity->getMinMax(pvMin, pvMax);
*pvMin += m_vPos;
*pvMax += m_vPos;
}
void CEditorObject::renderSelection(bool is3D)
......@@ -140,41 +191,27 @@ void CEditorObject::setKV(const char *szKey, const char *szValue)
}
const char *CEditorObject::getKV(const char *szKey)
{
#if 0
if(!fstrcmp(szKey, "model"))
{
return(m_sModelName.c_str());
}
else if(!fstrcmp(szKey, "name"))
{
return(m_sName.c_str());
}
else if(!fstrcmp(szKey, "segmentate"))
if(!m_pEntity)
{
m_szSegmentation[0] = m_bSegmentation ? '1' : '0';
m_szSegmentation[1] = 0;
return(m_szSegmentation);
return(NULL);
}
#endif
return(NULL);
char tmp[4096];
m_pEntity->getKV(szKey, tmp, sizeof(tmp));
m_msPropCache[szKey] = tmp;
return(m_msPropCache[szKey].c_str());
}
const X_PROP_FIELD *CEditorObject::getPropertyMeta(UINT uKey)
{
static const X_PROP_FIELD s_szKeys[] = {
{"model", "Model file", XPET_TEXT, NULL, ""},
{"name", "Name", XPET_TEXT, NULL, ""},
{"segmentate", "Segmentate", XPET_TEXT /* XPET_YESNO */, NULL, ""}
};
assert(uKey < m_aFields.size());
if(uKey > 2)
{
return(NULL);
}
return(&s_szKeys[uKey]);
return(&m_aFields[uKey]);
}
UINT CEditorObject::getProperyCount()
{
return(3);
return(m_aFields.size());
}
const char *CEditorObject::getTypeName()
......
......@@ -43,6 +43,11 @@ protected:
const char *m_szClassName = NULL;
CEditable *m_pEditable;
Array<X_PROP_FIELD> m_aFields;
AssotiativeArray<String, String> m_msPropCache;
void _iniFieldList();
};
#endif
/***********************************************************
Copyright Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
See the license in LICENSE
***********************************************************/
......@@ -126,3 +126,13 @@ void CEntityFactoryMap::getListing(const char ** pszOut, int size)
}
}
}
const char *CEntityFactoryMap::getClassNamePtr(const char *szClassName)
{
IEntityFactory * pFactory = getFactory(szClassName);
if(pFactory)
{
return(pFactory->getClassName());
}
return(NULL);
}
/***********************************************************
Copyright Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
See the license in LICENSE
***********************************************************/
......@@ -48,6 +48,8 @@ public:
int getListCount();
void getListing(const char ** pszOut, int size);
const char *getClassNamePtr(const char *szClassName);
private:
IEntityFactory * getFactory(const char * szName);
AssotiativeArray<AAString, IEntityFactory*> m_mFactories;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment