forked from Mirrors/openclonk
C4Object: Make parallaxity a property
Instead of Local(0) and Local(1), parallaxity is now stored as an array in the property "Parallaxity" of an object.stable-5.2
parent
c511615376
commit
ab5da9cc3f
|
@ -360,6 +360,7 @@ class C4Object: public C4PropList
|
|||
void DirectComContents(C4Object *pTarget, bool fDoCalls); // direct com: scroll contents to given ID
|
||||
inline void TargetPos(float &riTx, float &riTy, const C4Facet &fctViewport) // update scroll pos applying parallaxity
|
||||
{ if (Category & C4D_Parallax) ApplyParallaxity(riTx, riTy, fctViewport); }
|
||||
void GetParallaxity(int32_t *parX, int32_t *parY);
|
||||
void ApplyParallaxity(float &riTx, float &riTy, const C4Facet &fctViewport); // apply parallaxity by locals of object
|
||||
bool IsInLiquidCheck(); // returns whether the Clonk is within liquid material
|
||||
void UpdateInLiquid(); // makes splash when a liquid is entered
|
||||
|
|
|
@ -168,6 +168,7 @@ P_Collectible,
|
|||
P_ActMap,
|
||||
P_Attach,
|
||||
P_Visibility,
|
||||
P_Parallaxity,
|
||||
P_Procedure,
|
||||
P_Directions,
|
||||
P_FlipDir,
|
||||
|
|
|
@ -558,10 +558,12 @@ BOOL C4Object::ExecMovement() // Every Tick1 by Execute
|
|||
// never remove HUD objects
|
||||
if (Category & C4D_Parallax)
|
||||
{
|
||||
int parX, parY;
|
||||
GetParallaxity(&parX, &parY);
|
||||
fRemove = false;
|
||||
if (GetX()>GBackWdt || GetY()>GBackHgt) fRemove = true; // except if they are really out of the viewport to the right...
|
||||
else if (GetX()<0 && Local[0].getBool()) fRemove = true; // ...or it's not HUD horizontally and it's out to the left
|
||||
else if (!Local[0].getBool() && GetX()<-GBackWdt) fRemove = true; // ...or it's HUD horizontally and it's out to the left
|
||||
else if (GetX()<0 && !!parX) fRemove = true; // ...or it's not HUD horizontally and it's out to the left
|
||||
else if (!parX && GetX()<-GBackWdt) fRemove = true; // ...or it's HUD horizontally and it's out to the left
|
||||
}
|
||||
if (fRemove)
|
||||
{
|
||||
|
|
|
@ -5643,11 +5643,24 @@ void C4Object::DirectComContents(C4Object *pTarget, bool fDoCalls)
|
|||
return;
|
||||
}
|
||||
|
||||
void C4Object::GetParallaxity(int32_t *parX, int32_t *parY)
|
||||
{
|
||||
assert(parX); assert(parY);
|
||||
*parX = 100; *parY = 100;
|
||||
if (!(Category & C4D_Parallax)) return;
|
||||
C4Value parV; GetProperty(Strings.P[P_Parallaxity], parV);
|
||||
C4ValueArray *par = parV.getArray();
|
||||
if (!par) return;
|
||||
*parX = par->GetItem(0).getInt();
|
||||
*parY = par->GetItem(1).getInt();
|
||||
}
|
||||
|
||||
void C4Object::ApplyParallaxity(float &riTx, float &riTy, const C4Facet &fctViewport)
|
||||
{
|
||||
// parallaxity by locals
|
||||
// special: Negative positions with parallaxity 0 mean HUD elements positioned to the right/bottom
|
||||
int iParX = Local[0].getInt(), iParY = Local[1].getInt();
|
||||
int iParX, iParY;
|
||||
GetParallaxity(&iParX, &iParY);
|
||||
if (!iParX && GetX()<0)
|
||||
riTx = -fctViewport.Wdt;
|
||||
else
|
||||
|
@ -5680,7 +5693,8 @@ void C4Object::UnSelect(BOOL fCursor)
|
|||
|
||||
void C4Object::GetViewPosPar(float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport)
|
||||
{
|
||||
float iParX = float(Local[0].getInt()), iParY = float(Local[1].getInt());
|
||||
int iParX, iParY;
|
||||
GetParallaxity(&iParX, &iParY);
|
||||
// get drawing pos, then subtract original target pos to get drawing pos on landscape
|
||||
if (!iParX && GetX()<0)
|
||||
// HUD element at right viewport pos
|
||||
|
|
|
@ -115,6 +115,7 @@ C4StringTable::C4StringTable()
|
|||
P[P_Reverse] = RegString("Reverse");
|
||||
P[P_Step] = RegString("Step");
|
||||
P[P_Visibility] = RegString("Visibility");
|
||||
P[P_Parallaxity] = RegString("Parallaxity");
|
||||
for (unsigned int i = 0; i < P_LAST; ++i) P[i]->IncRef();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue