Commit e8f419a9 authored by D-AIRY's avatar D-AIRY

GUI transition inheritance; chat panel; item pickup; ent cloning; minor fixes

parent 006ee784
......@@ -30,6 +30,12 @@ show_in_listing = 1
;model = "models/mag/mag_ak74_30.dse"
capacity = 30
[item_keycard]
base_class = base_item
show_in_listing = 1
inv_name = "Ключ-карта"
inv_stackable = 0
[weapon_ak74]
base_class = base_riffle
show_in_listing = 1
......
......@@ -46,3 +46,22 @@
transform: rotateY(15deg);
}
#chatlog
{
position: fixed;
width: 400px;
height: 150px;
bottom: 300px;
left:8%;
font-size: 18px;
font-name: default;
transform: rotateY(10deg);
transition-property: color;
transition-duration: 0.3s;
color: #c6f0fdFF;
}
#chatlog:disabled
{
color: #c6f0fd00;
}
......@@ -34,5 +34,7 @@
<div style="position: fixed; top: 50%; left: 0; right: 0; bottom: 0;"><div id="aim_range" style="position: relative; top: 20px; text-align: center;font-size: 12px">1</div></div>
<div id="dmg_overlay" style="position: fixed; top: 0px; left: 0px; bottom: 0px; right: 0px; background-image: /hud/damage_overlay.png;background-size-x: 100%;background-size-y: 100%; visisbility: hidden;"> </div>
<div id="chatlog"></div>
</body>
</html>
......@@ -72,6 +72,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sxleveleditor", "..\..\sxle
ProjectSection(ProjectDependencies) = postProject
{D381001E-C1FF-415F-A269-5264AD9013D5} = {D381001E-C1FF-415F-A269-5264AD9013D5}
{0292BE32-298E-4E18-BC42-5A39F9487EBA} = {0292BE32-298E-4E18-BC42-5A39F9487EBA}
{97D8EE94-0A6D-47F2-BE01-63F7C89715BC} = {97D8EE94-0A6D-47F2-BE01-63F7C89715BC}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sxmaterialeditor", "..\..\sxmaterialeditor\vs2013\sxmaterialeditor.vcxproj", "{9C34362D-7FA6-4BD1-A48B-8FDE541344B0}"
......
......@@ -340,7 +340,7 @@ SX_LIB_API int64_t Core_TimeTotalMcsGet(ID id);
SX_LIB_API int64_t Core_TimeTotalMcsGetU(ID id);
//! возвращает общее время работы таймера в микросекундах (независимо от обновления)
//! возвращает общее время работы таймера в миллисекундах (независимо от обновления)
#define Core_TimeTotalMlsGetU(id) Core_TimeTotalMcsGetU(id)/1000
//! возвращает общее время работы таймера в миллисекундах (независимо от обновления)
......
......@@ -384,6 +384,7 @@ void CBaseCharacter::updateHitboxes()
//SMMATRIX mBone = m_pAnimPlayer->getBoneTransformPos(hb->bone_id);
//@TODO: Cache hitbox transform
m_pHitboxBodies[i]->getWorldTransform().setFromOpenGLMatrix((btScalar*)&(SMMatrixRotationX(hb->rot.x)
* SMMatrixRotationY(hb->rot.y)
* SMMatrixRotationZ(hb->rot.z)
......
......@@ -5,6 +5,7 @@ See the license in LICENSE
***********************************************************/
#include "BaseItem.h"
#include "BaseCharacter.h"
/*! \skydocent base_item
Базовый объект элемента инвентаря игрока
......@@ -23,6 +24,9 @@ BEGIN_PROPTABLE(CBaseItem)
DEFINE_FIELD_FLOAT(m_iInvWeight, PDFF_NOEDIT | PDFF_NOEXPORT, "inv_weight", "", EDITOR_NONE)
//! Можно ли поднимать объект
DEFINE_FIELD_BOOL(m_bPickable, PDFF_NOEDIT | PDFF_NOEXPORT, "inv_pickable", "", EDITOR_NONE)
DEFINE_OUTPUT(m_onPickUp, "OnPickUp", "On pickup")
DEFINE_OUTPUT(m_onDrop, "OnDrop", "On drop")
END_PROPTABLE()
REGISTER_ENTITY_NOLISTING(CBaseItem, base_item);
......@@ -41,3 +45,51 @@ float CBaseItem::getWeight()
{
return(m_iInvWeight);
}
void CBaseItem::onUse(CBaseEntity *pUser)
{
BaseClass::onUse(pUser);
if(!m_bPickable)
{
return;
}
CBaseCharacter *pCharacter = (CBaseCharacter*)pUser;
pCharacter->getInventory()->putItem(this);
FIRE_OUTPUT(m_onPickUp, pUser);
if(m_bInvStackable)
{
REMOVE_ENTITY(this);
}
else
{
setModeInventory();
}
}
void CBaseItem::setModeInventory()
{
if(!m_bWorldMode)
{
return;
}
m_bWorldMode = false;
releasePhysics();
if(m_pAnimPlayer)
{
mem_release(m_pAnimPlayer);
}
}
void CBaseItem::setModeWorld()
{
if(m_bWorldMode)
{
return;
}
m_bWorldMode = true;
setModel(m_szModelFile);
}
......@@ -24,9 +24,18 @@ class CBaseItem: public CBaseAnimating
{
DECLARE_CLASS(CBaseItem, CBaseAnimating);
DECLARE_PROPTABLE();
friend class CCharacterInventory;
public:
DECLARE_CONSTRUCTOR();
//! Масса объекта
virtual float getWeight();
void onUse(CBaseEntity *pUser);
void setModeInventory();
void setModeWorld();
protected:
const char * m_szInvName; //!< Имя, отображаемое в инвентаре
bool m_bInvStackable; //!< Можно ли хранить несколько итемов в одной ячейке
int m_iInvStackCurSize; //!< Количество итемов в стеке
......@@ -34,9 +43,11 @@ public:
float m_iInvWeight; //!< Масса объекта
bool m_bPickable; //!< Можно ли поднять объект
output_t m_onPickUp;
output_t m_onDrop;
bool m_bWorldMode = true;
//! Масса объекта
virtual float getWeight();
};
#endif
......
#include "CharacterInventory.h"
#include "BaseCharacter.h"
#include "HUDcontroller.h"
CCharacterInventory::CCharacterInventory(CBaseCharacter * pOwner, int iSlotCount):
m_pOwner(pOwner),
......@@ -134,6 +135,82 @@ void CCharacterInventory::putItems(const char *szClassName, int iCount)
}
}
void CCharacterInventory::putItem(CBaseItem *pItem)
{
assert(pItem);
for(int i = 0; i < m_iSlotCount; ++i)
{
if(m_ppSlots[i] && pItem->m_bInvStackable && !fstrcmp(m_ppSlots[i]->getClassName(), pItem->getClassName()))
{
int iCanAdd = m_ppSlots[i]->m_iInvStackMaxSize - m_ppSlots[i]->m_iInvStackCurSize;
if(iCanAdd > 0)
{
if(iCanAdd >= pItem->m_iInvStackCurSize)
{
m_ppSlots[i]->m_iInvStackCurSize += pItem->m_iInvStackCurSize;
pItem->m_iInvStackCurSize = 0;
break;
}
else
{
pItem->m_iInvStackCurSize -= iCanAdd;
m_ppSlots[i]->m_iInvStackCurSize += iCanAdd;
}
}
}
}
if(pItem->m_iInvStackCurSize > 0 || !pItem->m_bInvStackable)
{
for(int i = 0; i < m_iSlotCount; ++i)
{
if(!m_ppSlots[i])
{
if(pItem->m_bInvStackable)
{
if((m_ppSlots[i] = (CBaseItem*)CREATE_ENTITY(pItem->getClassName(), m_pOwner->getManager())))
{
int iCanAdd = m_ppSlots[i]->m_iInvStackMaxSize - m_ppSlots[i]->m_iInvStackCurSize;
if(iCanAdd > 0)
{
if(iCanAdd >= pItem->m_iInvStackCurSize)
{
m_ppSlots[i]->m_iInvStackCurSize += pItem->m_iInvStackCurSize;
pItem->m_iInvStackCurSize = 0;
break;
}
else
{
pItem->m_iInvStackCurSize -= iCanAdd;
m_ppSlots[i]->m_iInvStackCurSize += iCanAdd;
}
}
}
else
{
break;
}
}
else
{
m_ppSlots[i] = pItem;
break;
}
}
}
}
CHUDcontroller *pHUD = m_pOwner->getHUDcontroller();
if(pHUD)
{
char str[128];
sprintf(str, "Найден предмет: %s", pItem->m_szInvName);
pHUD->chatMsg(str);
}
}
int CCharacterInventory::getSlotCount() const
{
return(m_iSlotCount);
......
......@@ -16,6 +16,7 @@ public:
int getItemCount(const char *szClassName);
void putItems(const char *szClassName, int iCount = 1);
void putItem(CBaseItem *pItem);
//void putItems(CBaseItem *pItem);
int getSlotCount() const;
......
......@@ -359,7 +359,7 @@ bool CEntityManager::exportList(const char * file)
{
for(int j = 0; j < pTbl->numFields; ++j)
{
if(pTbl->pData[j].szKey && !(pTbl->pData[j].flags & PDFF_INPUT) && !conf->keyExists(sect, pTbl->pData[j].szKey))
if(pTbl->pData[j].szKey && !(pTbl->pData[j].flags & (PDFF_INPUT | PDFF_NOEXPORT)) && !conf->keyExists(sect, pTbl->pData[j].szKey))
{
pEnt->getKV(pTbl->pData[j].szKey, buf, sizeof(buf));
conf->set(sect, pTbl->pData[j].szKey, buf);
......@@ -747,6 +747,49 @@ CBaseEntity * CEntityManager::getById(ID id)
return(pEnt ? (pEnt->getFlags() & EF_REMOVED ? NULL : pEnt) : NULL);
}
CBaseEntity * CEntityManager::cloneEntity(CBaseEntity *pOther)
{
if(!pOther)
{
return(NULL);
}
CBaseEntity *pEnt = CREATE_ENTITY_NOPOST(pOther->getClassName(), this);
pEnt->setKV("name", pOther->getName());
pEnt->setPos(pOther->getPos());
pEnt->setOrient(pOther->getOrient());
pEnt->setParent(pOther->getParent());
pEnt->setOwner(pOther->getOwner());
char buf[4096];
proptable_t *pTbl = CEntityFactoryMap::GetInstance()->getPropTable(pOther->getClassName());
do
{
for(int j = 0; j < pTbl->numFields; ++j)
{
if(pTbl->pData[j].szKey && !(pTbl->pData[j].flags & PDFF_INPUT))
{
if(fstrcmp(pTbl->pData[j].szKey, "origin")
&& fstrcmp(pTbl->pData[j].szKey, "name")
&& fstrcmp(pTbl->pData[j].szKey, "rotation")
&& fstrcmp(pTbl->pData[j].szKey, "parent")
&& fstrcmp(pTbl->pData[j].szKey, "owner"))
{
pOther->getKV(pTbl->pData[j].szKey, buf, sizeof(buf));
pEnt->setKV(pTbl->pData[j].szKey, buf);
}
}
}
}
while((pTbl = pTbl->pBaseProptable));
pEnt->setFlags(pOther->getFlags());
pEnt->onPostLoad();
return(pEnt);
}
void CEntityManager::setOutputTimeout(named_output_t * pOutput, inputdata_t * pData)
{
timeout_output_t t;
......
......@@ -104,6 +104,8 @@ public:
int getCount();
CBaseEntity * getById(ID id);
CBaseEntity * cloneEntity(CBaseEntity *pEnt);
void sheduleDestroy(CBaseEntity *pEnt);
protected:
......
......@@ -269,6 +269,9 @@ GameData::GameData(HWND hWnd, bool isGame):
Core_0RegisterCVarFloat("lvl_debris_remove_time_min", 120.0f, "Debris collector time min");
Core_0RegisterCVarFloat("lvl_debris_remove_time_max", 200.0f, "Debris collector time max");
Core_0RegisterCVarFloat("hud_chat_time", 5.0f, "Chat hide time");
Core_0RegisterCVarInt("hud_chat_lines", 5, "Chat lines limit");
Core_0RegisterCVarBool("hud_crosshair", true, "Отображать метку прицела");
Core_0RegisterCVarBool("hud_rangefinder", true, "Отображать дальномер");
......@@ -789,6 +792,7 @@ void GameData::update()
{
m_pHUDcontroller->setAimRange(-1.0f);
}
m_pHUDcontroller->update();
/*
float3 start(-10.0f, 100.0f, -10.0f),
end = start + float3(10.0f, -200.0f, 10.0f);
......
......@@ -26,6 +26,12 @@ CHUDcontroller::CHUDcontroller():
m_pHealthSpin = m_pDesktop->getDocument()->getElementById(L"health_spin");
m_pDeadOverlay = m_pDesktop->getDocument()->getElementById(L"dmg_overlay");
m_pChatLog = m_pDesktop->getDocument()->getElementById(L"chatlog");
if(m_pChatLog)
{
m_pChatLog->addPseudoclass(0x00004);
}
Core_0RegisterCVarBool("hud_draw", true, "Включает отображение HUD");
}
......@@ -175,3 +181,29 @@ void CHUDcontroller::setPlayerHealth(float fHealth, float fHealthMax)
void CHUDcontroller::fadeScreenDmg()
{
}
void CHUDcontroller::chatMsg(const char *msg)
{
static const float *s_fChatTime = GET_PCVAR_FLOAT("hud_chat_time");
static const int *s_fChatLines = GET_PCVAR_INT("hud_chat_lines");
if(m_pChatLog)
{
m_pChatLog->appendHTML(StringW(L"<div>")+StringW(String(msg))+L"</div>");
while(m_pChatLog->getChilds()->size() > *s_fChatLines)
{
m_pChatLog->removeChild(m_pChatLog->getChilds()[0][0]);
}
m_pChatLog->removePseudoclass(0x00004);
m_i64TimeHideChat = TimeGetMcsU(Core_RIntGet(G_RI_INT_TIMER_RENDER)) + *s_fChatTime * 1000000.0f;
}
}
void CHUDcontroller::update()
{
if(m_i64TimeHideChat != 0 && TimeGetMcsU(Core_RIntGet(G_RI_INT_TIMER_RENDER)) > m_i64TimeHideChat)
{
m_i64TimeHideChat = 0;
m_pChatLog->addPseudoclass(0x00004);
}
}
......@@ -43,6 +43,10 @@ public:
void setPlayerHealth(float fHealth, float fHealthMax = 100.0f);
void fadeScreenDmg();
void chatMsg(const char *msg);
void update();
protected:
gui::IDesktop * m_pDesktop;
......@@ -57,6 +61,7 @@ protected:
gui::dom::IDOMnode * m_pAimRange;
gui::dom::IDOMnode * m_pHealthSpin;
gui::dom::IDOMnode * m_pDeadOverlay;
gui::dom::IDOMnode * m_pChatLog;
float3_t m_vLevelMin, m_vLevelMax;
......@@ -66,6 +71,8 @@ protected:
int m_iWeaponCurrentLoad;
float m_fAimRange;
int64_t m_i64TimeHideChat = 0;
};
#endif
......@@ -213,7 +213,7 @@ SX_LIB_API void SXGame_PlayerSpawn();
SX_LIB_API void SXGame_Render();
SX_LIB_API void SXGame_RenderHUD();
SX_LIB_API void SXGame_EditorRender(ID id, ID id_sel_tex);
SX_LIB_API void SXGame_EditorRender(ID id, ID id_sel_tex, const float3 *pvRenderPos=NULL);
SX_LIB_API ICamera * SXGame_GetActiveCamera();
......@@ -262,6 +262,10 @@ SX_LIB_API void SXGame_OnLevelLoad(const char *szName);
SX_LIB_API void SXGame_SetDebugText(const char *szText);
/*! Копирует объект, возвращает ID копии
*/
SX_LIB_API ID SXGame_EntClone(ID idSrc);
#endif
......
......@@ -196,7 +196,7 @@ SX_LIB_API void SXGame_PlayerSpawn()
GameData::m_pPlayer->spawn();
}
SX_LIB_API void SXGame_EditorRender(ID id, ID id_sel_tex)
SX_LIB_API void SXGame_EditorRender(ID id, ID id_sel_tex, const float3 *pvRenderPos)
{
SG_PRECOND(_VOID);
......@@ -211,7 +211,7 @@ SX_LIB_API void SXGame_EditorRender(ID id, ID id_sel_tex)
SGCore_GetDXDevice()->SetTransform(D3DTS_VIEW, (D3DMATRIX*)&mView);
SGCore_GetDXDevice()->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)&mProj);
if (strcmp(bEnt->getClassName(), "path_corner") == 0)
if(strcmp(bEnt->getClassName(), "path_corner") == 0)
{
CPathCorner * pStartPoint = (CPathCorner*)bEnt;
if (!pStartPoint)
......@@ -279,7 +279,7 @@ SX_LIB_API void SXGame_EditorRender(ID id, ID id_sel_tex)
SGCore_GetDXDevice()->SetTransform(D3DTS_VIEW, (D3DMATRIX*)&mView);
SGCore_GetDXDevice()->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)&mProj);
SGCore_GetDXDevice()->SetTransform(D3DTS_WORLD, (D3DMATRIX*)&(bEnt->getOrient().GetMatrix() * SMMatrixTranslation(bEnt->getPos()))/*bEnt->getWorldTM()*/);
SGCore_GetDXDevice()->SetTransform(D3DTS_WORLD, (D3DMATRIX*)&(bEnt->getOrient().GetMatrix() * SMMatrixTranslation(pvRenderPos ? *pvRenderPos : bEnt->getPos()))/*bEnt->getWorldTM()*/);
SGCore_GetDXDevice()->SetTexture(0, SGCore_LoadTexGetTex(id_sel_tex));
g_pFigureBox->DrawSubset(0);
......@@ -405,3 +405,16 @@ SX_LIB_API void SXGame_SetDebugText(const char *szText)
//static gui::dom::IDOMnode * pNode = GameData::m_pStatsUI->getDocument()->getElementById(L"wrapper");
//pNode->setHTML(StringW(String(szText)).c_str());
}
SX_LIB_API ID SXGame_EntClone(ID idSrc)
{
SG_PRECOND(NULL);
CBaseEntity *pEnt = GameData::m_pMgr->cloneEntity(GameData::m_pMgr->getById(idSrc));
if(!pEnt)
{
return(-1);
}
return(pEnt->getId());
}
......@@ -42,14 +42,14 @@ if (!(idVisCalcObj >= 0 && m_aVisInfo.size() > idVisCalcObj && m_aVisInfo[idVisC
}
#define STATIC_PRECOND_MODEL_ID(idModel, retVal) \
if (!(idModel < (int)m_aModels.size() && m_aModels[idModel]))\
if(!(idModel >= 0 && idModel < (int)m_aModels.size() && m_aModels[idModel]))\
{\
LibReport(REPORT_MSG_LEVEL_ERROR, "%s - static: unresolved id '%d' for array of models", GEN_MSG_LOCATION, idModel); \
return retVal; \
}
#define STATIC_PRECOND_TRANSPARENCY_MODEL_ID(idModel, retVal) \
if (!(idModel < (int)m_aTransparency.size() && m_aTransparency[idModel]))\
if(!(idModel >= 0 &&idModel < (int)m_aTransparency.size() && m_aTransparency[idModel]))\
{\
LibReport(REPORT_MSG_LEVEL_ERROR, "%s - static: unresolved id '%d' for array of transparency models", GEN_MSG_LOCATION, idModel); \
return retVal; \
......
......@@ -313,6 +313,11 @@ namespace gui
}
}*/
if(pStyle != this)
{
inheritTransitions(pStyle);
}
for(int i = 0, l = pStyle->m_aTransitions.size(); i < l; ++i)
{
const CTransitionItem * pTI = &pStyle->m_aTransitions[i];
......@@ -350,5 +355,28 @@ namespace gui
}
}
}
void CCSSstyle::inheritTransitions(const CCSSstyle *pOther)
{
const CTransitionItem *pTransition;
bool bFound;
for(int i = 0, l = pOther->m_aTransitions.size(); i < l; ++i)
{
pTransition = &pOther->m_aTransitions[i];
bFound = false;
for(int j = 0, jl = m_aTransitions.size(); j < jl; ++j)
{
if(pTransition->m_szProperty == m_aTransitions[j].m_szProperty)
{
bFound = true;
break;
}
}
if(!bFound)
{
m_aTransitions.push_back(*pTransition);
}
}
}
};
};
......@@ -797,6 +797,8 @@ namespace gui
void setupTransitions(const CCSSstyle *pStyle);
void cancelTransitions();
void inheritTransitions(const CCSSstyle *pOther);
protected:
struct CPropPtr
......
......@@ -168,6 +168,11 @@ namespace gui
APPLY_RULE(p_text_decoration_line);
APPLY_RULE(p_visibility);
node->m_css.inheritTransitions(&m_css);
node->m_css.setupTransitions(&node->m_css);
//APPLY_RULE(p_transition_property);
//APPLY_RULE(p_transition_duration);
node->applyChildStyle();
}
}
......
......@@ -3048,7 +3048,7 @@ namespace gui
}
else if(key == L"transition")
{
printf(COLOR_LRED "transition property is not supperter, use 'transition-duration', 'transition-property', 'transition-timing-function', 'transition-delay' instead\n" COLOR_RESET);
printf(COLOR_LRED "transition property is not supporter, use 'transition-duration', 'transition-property', 'transition-timing-function', 'transition-delay' instead\n" COLOR_RESET);
}
else if(key == L"transition-duration")
{
......
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