fix FrameDecoration

Sven Eberhardt 2010-02-07 18:50:28 +01:00
parent 2b75615ba6
commit 4f96e19328
3 changed files with 38 additions and 8 deletions

View File

@ -1400,6 +1400,29 @@ void C4Def::ResetIncludeDependencies()
if (!fRankSymbolsOwned) { pRankSymbols = NULL; iNumRankSymbols = 0; }
}
C4PropList *C4Def::GetActionByName(const char *actname)
{
if (!actname) return NULL;
C4String * actname_str = Strings.RegString(actname);
actname_str->IncRef();
C4PropList *r = GetActionByName(actname_str);
actname_str->DecRef();
return r;
}
C4PropList *C4Def::GetActionByName(C4String *actname)
{
assert(actname);
// If we get the null string or ActIdle by name, return NULL action
if (!actname || actname == Strings.P[P_Idle]) return NULL;
// otherwise, query actmap
C4Value ActMap; GetProperty(Strings.P[P_ActMap], ActMap);
if (!ActMap.getPropList()) return false;
C4Value Action; ActMap.getPropList()->GetProperty(actname, Action);
if (!Action.getPropList()) return false;
return Action.getPropList();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -305,6 +305,9 @@ class C4Def: public C4PropList
void IncludeDefinition(C4Def *pIncludeDef); // inherit components from other definition
void ResetIncludeDependencies(); // resets all pointers into foreign definitions caused by include chains
C4PropList *GetActionByName(const char *actname);
C4PropList *GetActionByName(C4String *actname);
};
class C4DefList

View File

@ -66,16 +66,20 @@ void FrameDecoration::Clear()
bool FrameDecoration::SetFacetByAction(C4Def *pOfDef, C4TargetFacet &rfctTarget, const char *szFacetName)
{
// get action
/*FIXME StdStrBuf sActName;
StdStrBuf sActName;
sActName.Format("FrameDeco%s", szFacetName);
int cnt; C4ActionDef *pAct = pOfDef->ActMap;
for (cnt=pOfDef->ActNum; cnt; --cnt,++pAct)
if (sActName == pAct->Name)
break;
if (!cnt) return false;
C4PropList *act = pOfDef->GetActionByName(sActName.getData());
if (!act) return false;
// set facet by it
rfctTarget.Set(pOfDef->Graphics.GetBitmap(), pAct->Facet.x, pAct->Facet.y, pAct->Facet.Wdt, pAct->Facet.Hgt, pAct->Facet.tx, pAct->Facet.ty);
*/ return true;
int32_t x = act->GetPropertyInt(P_X);
int32_t y = act->GetPropertyInt(P_Y);
int32_t wdt = act->GetPropertyInt(P_Wdt);
int32_t hgt = act->GetPropertyInt(P_Hgt);
int32_t tx = act->GetPropertyInt(P_OffX);
int32_t ty = act->GetPropertyInt(P_OffY);
if (!wdt || !hgt) return false;
rfctTarget.Set(pOfDef->Graphics.GetBitmap(), x, y, wdt, hgt, tx, ty);
return true;
}
bool FrameDecoration::SetByDef(C4ID idSourceDef)