コード例 #1
0
bool CEditorCondition::Serialize(CArchive &ar, CChronoEventEditor* Ed)
{
	CString ExpectedName = "CEditorCondition";
	int     Version      = 2;

	if (!SerializeClassHeader(ExpectedName, Version, ar))
		return false;

	if( ar.IsLoading())
	{
		m_visible = true;
		m_Valid = true;
		ar >> mid;
		ar >> cndID;
		ar >> oid;
		if(Ed)	Ed->RegisterObjectID(oid, ar);
		ar >> m_Negate;
		ar >> m_Family >> m_FamilyName;

		ar >> m_rect_default;
		ar >> m_select_default;
		ar >> m_select_default;
		ar >> m_Anim.Space;
		ar // //m_Text - note: must call EventSheetEditor::ReformatCondition 
			>> m_Object >> m_Script;
		m_Anim.m_bDestroyed = false;

		m_Text = "";

		int size = 0;
		ar >> size;
		for (int i = 0; i < size; i++)
		{
			CEditorParam* Param = new CEditorParam;
			Param->Serialize(ar, Ed);
 			params.push_back(Param);
		}

		if (oid != -1)
		{
			CString name = "";
			ar >> name;
			OINFO* o = GetOINFO(name);
			if (!o)
			{
				CErrorDlg Dlg;
				Dlg.Error("Error in condition.", "An invalid object in a condition was referenced.");

				return false;
			}

			DLLIndex = o->oID;
		}
コード例 #2
0
ファイル: EditorAction.cpp プロジェクト: DavidPulido/Contruct
bool CEditorAction::Serialize(CArchive &ar, CChronoEventEditor* Ed )
{
	CString ExpectedName = "CEditorAction";
	int     Version      = 2;

	if (!SerializeClassHeader(ExpectedName, Version, ar))
		return false;

	if(ar.IsLoading())
	{
		m_visible = true;
		m_Valid = true;
		ar >> m_Family >> m_FamilyName;	
		ar >> actID;
		ar >> oid;

		if(Ed) Ed->RegisterObjectID(oid, ar);
		ar >> m_rect_default;
		ar >> m_select_default;
		ar >> m_Anim.Space;
		m_Anim.m_bDestroyed = false;
		ar //>> m_Text - note: must call EventSheetEditor::ReformatAction 
			>> m_Object >> m_Script;
		ar >> mid;

		m_Text = "";

		int size = 0;
		ar >> size;
		for (int i = 0; i < size; i++)
		{
			CEditorParam* Param = new CEditorParam;
			Param->Serialize(ar, Ed);
			params.push_back(Param);
		}

		CString name = "";
		ar >> name;
		OINFO* o = GetOINFO(name);

		if(o)
			DLLIndex = o->oID;
		else
			DLLIndex = -1;

		if(Version >= 2)
			ar >> m_bEnabled;
		else
コード例 #3
0
bool CEditorCondition::IsLoop(CApplication* app)
{
	if(m_Text != "")
	{
		return (m_Text.Find("<img>3</img>") != -1);
	}
	else
	{
		if(!app)
			return false;
		CObjType* objectType = app->FindObjTypeFromNumber(oid);
		if(!objectType)
			return false;
		ACESEntry2* acesEntry;

		if(mid == -1) // ace or custom ace
			acesEntry = objectType->GetACESEntry(CONDITION, cndID);
		else				 // movement			
		{
			//MovementIterator mi = objectType->m_Movements.begin();
			//advance(mi, mid);
			CBehavior* pMov = objectType->GetBehaviorByUniqueID(mid);
			if (pMov == NULL) throw;
			acesEntry = GetOINFO(pMov->BehaviorDLLIndex)->GetACEEntry(CONDITION, cndID);
		}

		// effects never have triggers

		if(!acesEntry)
			return false;
		if (acesEntry->aceDisplayText.Find("<img>3</img>") != -1)
			return true;
		return false;
	}



}
コード例 #4
0
ファイル: Animator Bar.cpp プロジェクト: aolko/construct
void AnimatorBar::AnimationHasChanged()
{
	if(m_pObjType)
	{
		OINFO* info = GetOINFO(m_pObjType->DLLIndex);

		vector<CObj*> objs;
		CObj* o;

		POSITION pos = application->layouts.GetHeadPosition();
		while(pos)
		{
			CLayout* layout = application->layouts.GetNext(pos);
			
			POSITION pos2 = layout->objects.GetStartPosition();

			for (int i = 0; i < layout->objects.GetCount(); i++) 
			{
				long ID;
				layout->objects.GetNextAssoc(pos2, ID, o);

				if (o->GetGlobalID() == m_pObjType->ObjectIdentifier)
						objs.push_back(o);

			}
		}

		// Now loop each of the objects and call the end animation function.
		for(vector<CObj*>::iterator i = objs.begin(); i!= objs.end(); i++)
		{
			if(info->ETOnNotify)
				info->ETOnNotify((*i)->editObject, 2);
		}
		if(objs.size() > 0)
			if(info->ETOnNotify)
				info->ETOnNotify((*objs.begin())->editObject, 3);
	}
}
コード例 #5
0
ファイル: Script Dlg.cpp プロジェクト: aolko/construct
void CScriptDlg::InitPythonForObject(CObjType* pType, PyInfoClass* pClass)
{
	OINFO* oInfo = GetOINFO(pType->DLLIndex);
	
	map<CString, int> possibleAttribute;

	int count = pType->GetTableCount(ACTION);
	for(int i = 0; i < count; i++)
	{
		ACESEntry2* a = pType->GetACESEntry(ACTION, i);


		if(a->scriptName == "")
			continue;

		if(a->params.size() == 1)
		{
			if(a->scriptName.GetLength() > 3)
			{
				if(a->scriptName.Left(3) == "Set")
				{
					possibleAttribute[a->scriptName.Mid(3)] = 1;
				}
			}
		}
		if(a->scriptName.Left(1) == "(" || a->scriptName.Left(1) == "<")
		{
			continue;
		}
		PyInfoFunc* pFunct = &pClass->functions[a->scriptName];
		pFunct->name = a->scriptName;
		pFunct->pParent = pClass;


		CString help = CString("Action: ") + pFunct->name;
		help += "(";
		for(int p = 0; p < a->params.size(); p++)
		{
			if(p>0)
				help += ", ";
			help += a->params.at(p).name;
		}
		help += ")";
		pFunct->help = help;



		PyInfoMapItem& item = m_IntellMap[a->scriptName];
		item[pClass] = PY_FUNCTION;
	}

	count = pType->GetTableCount(CONDITION);
	for(int i = 0; i < count; i++)
	{
		ACESEntry2* c = pType->GetACESEntry(CONDITION, i);

		if(c->scriptName == "")
			continue;

		if(c->scriptName.Left(1) == "("|| c->scriptName.Left(1) == "<")
			continue;

		PyInfoFunc* pFunct = &pClass->functions[c->scriptName];
		pFunct->name = c->scriptName;
		pFunct->pParent = pClass;

		CString help = CString("Condition: ") + pFunct->name;
		help += "(";
		for(int p = 0; p < c->params.size(); p++)
		{
			if(p>0)
				help += ", ";
			help += c->params.at(p).name;
		}
		help += ")";
		pFunct->help = help;

		PyInfoMapItem& item = m_IntellMap[c->scriptName];
		item[pClass] = PY_FUNCTION;
	}

	count = pType->GetTableCount(EXPRESSION);
	for(int i = 0; i < count; i++)
	{
		ACESEntry2* e = pType->GetACESEntry(EXPRESSION, i);
		if(e->scriptName == "")
			continue;
		if(e->scriptName.Left(1) == "(" || e->scriptName.Left(1) == "<")
			continue;


		if(e->params.size() == 0)
		{
			map<CString, int>::iterator find = possibleAttribute.find(e->scriptName);
			//if(find != possibleAttribute.end())
			{
				PyInfoVar* pVar = &pClass->variables[e->scriptName];
				pVar->name = e->scriptName;
				pVar->pParent = pClass;

				PyInfoMapItem& item = m_IntellMap[e->scriptName];
				item[pClass] = PY_VARIABLE;

				continue;
			}
		}
		PyInfoFunc* pFunct = &pClass->functions[e->scriptName];
		pFunct->name = e->scriptName;
		pFunct->pParent = pClass;

		CString help = CString("Expression: ") + pFunct->name;
		help += "(";
		for(int p = 0; p < e->params.size(); p++)
		{
			if(p>0)
				help += ", ";
			help += e->params.at(p).name;
		}
		help += ")";
		pFunct->help = help;

		PyInfoMapItem& item = m_IntellMap[e->scriptName];
		item[pClass] = PY_FUNCTION;
	}

}
コード例 #6
0
bool CTypeChecker::ParamValid(CString objName, CString expName, int paramNum, int numParams, ExpType type)
{
	// Impossible to tell if this parameter is correct using an undefined type
	if (type == EXPTYPE_NULL)
		return true;

	objName.MakeLower();
	expName.MakeLower(); 

	CString movementName;
	ParseBehaviorExpression(objName, objName, movementName);

	CObjType* oT = LookupObjectType(objName, objMap);
	int DLLIndex;

	// Couldn't find object type: try family
	if (oT == NULL) {
		list<Family>::iterator f = find(pApp->families.begin(), pApp->families.end(), objName);

		// Not found
		if (f == pApp->families.end() || !f->is_in_use)
			return false;
		else
			DLLIndex = f->DLLIndex;

	}
	else DLLIndex = oT->DLLIndex;

	// Default value, eg. ObjectName(5)
	if (expName == "<default>") {

		// Default value is private variable flag requires one private variable parameter
		if (GetOINFO(DLLIndex)->ideFlags & OF_DEFAULTVALUE_PRIVATEVAR)
			return type == EXPTYPE_VARIABLENAME;
		// No other way of defining default value parameters
		else
			return true;
	}

	vector<ACESEntry2>* pTable;

	if (movementName != "") {
		CBehavior* m = LookupBehavior(oT, movementName);
		if (m == NULL) return false;

		OINFO* oInfo = GetOINFO(m->BehaviorDLLIndex);
		pTable = oInfo->GetTable(2);
	}
	else
		pTable = GetOINFO(DLLIndex)->GetTable(2);

	// Lookup the entry, and get its param type.
	int Count = pTable->size();
	for (int i = 0; i < Count; i++)
	{
		CString Exp = pTable->at(i).aceDisplayText;
		Exp.MakeLower();
		if (Exp == expName)
		{
			switch (pTable->at(i).params[paramNum].type)
			{
			case 1:		// Value
				return (type == EXPTYPE_INTEGER || type == EXPTYPE_FLOAT);
				
			case 2:		// String
				return (type == EXPTYPE_STRING);
			
			case 14:	// Private variable
				return (type == EXPTYPE_VARIABLENAME);

			}
		}
	}

	// Not found - undefined expression - allow
	return true;
}
コード例 #7
0
bool CTypeChecker::ObjectExpressionExists(CString objName, CString expName)
{
	objName.MakeLower();
	expName.MakeLower();

	CString movementName;
	ParseBehaviorExpression(objName, objName, movementName);

	CObjType* oT = LookupObjectType(objName, objMap);
	int DLLIndex;

	// Couldn't find object type: try family
	if (oT == NULL) {
		list<Family>::iterator f = find(pApp->families.begin(), pApp->families.end(), objName);

		// Not found
		if (f == pApp->families.end() || !f->is_in_use)
			return false;
		else {
			DLLIndex = f->DLLIndex;
			oT = pApp->FindObjTypeFromNumber(f->identifier);
		}
	}
	else DLLIndex = oT->DLLIndex;

	// Behavior under object: objName[movementName]
	if (movementName != "") {
		CBehavior* m = LookupBehavior(oT, movementName);
		if (m == NULL) return false;

		OINFO* oInfo = GetOINFO(m->BehaviorDLLIndex);

		int Count = oInfo->GetTable(2)->size();

		for (int i = 0; i < Count; i++) {
			CString Exp = oInfo->GetACEEntry(2, i)->aceDisplayText;
			Exp.MakeLower();
			if (Exp == expName)
				return true;
		}

		return false;
	}

	OINFO* oInfo = GetOINFO(DLLIndex);

	if (oInfo == NULL)
		return false;

	// get count
	int Count = oInfo->GetTable(2)->size();

	for (int i = 0; i < Count; i++)
	{
		CString Exp = oInfo->GetACEEntry(2, i)->aceDisplayText;
		Exp.MakeLower();
		if (Exp == expName)
			return true;
	}

	// Expression name not found: allow if OF_UNDEFINEDEXPRESSIONS set
	return (oInfo->ideFlags & OF_UNDEFINEDEXPRESSIONS)!=0;
}
コード例 #8
0
bool CTypeChecker::CheckParamCount(CString objName, CString expName, int numParams)
{
	objName.MakeLower();
	expName.MakeLower();

	CString movementName;
	ParseBehaviorExpression(objName, objName, movementName);

	CObjType* oT = LookupObjectType(objName, objMap);
	int DLLIndex;

	// Couldn't find object type: try family
	if (oT == NULL) {
		list<Family>::iterator f = find(pApp->families.begin(), pApp->families.end(), objName);

		// Not found
		if (f == pApp->families.end() || !f->is_in_use)
			return false;
		else {
			DLLIndex = f->DLLIndex;
			oT = pApp->FindObjTypeFromNumber(f->identifier);
		}

	}
	else DLLIndex = oT->DLLIndex;

	// Default value, eg. ObjectName(5)
	if (expName == "<default>") {
		// The default value is private variable flag requires 1 parameter for default value.
		if (GetOINFO(DLLIndex)->ideFlags & OF_DEFAULTVALUE_PRIVATEVAR)
			return numParams == 1;
		// There is no other way of defining the default value parameters
		else
			return true;
	}

	vector<ACESEntry2>* pTable;

	if (movementName != "") {
		CBehavior* m = LookupBehavior(oT, movementName);
		if (m == NULL) return false;

		OINFO* oInfo = GetOINFO(m->BehaviorDLLIndex);
		pTable = oInfo->GetTable(2);
	}
	else
		pTable = GetOINFO(DLLIndex)->GetTable(2);

	// get count
	int Count = pTable->size();
	for (int i = 0; i < Count; i++)
	{
		CString Exp = pTable->at(i).aceDisplayText;
		Exp.MakeLower();
		if (Exp == expName)
		{
			return pTable->at(i).params.size() == numParams;
		}
	}

	// Not found - undefined expression - allow.
	return true;
}
コード例 #9
0
ExpType CTypeChecker::GetExpressionType(CString objName, CString expName)
{
	objName.MakeLower();
	expName.MakeLower();

	// No ACE system for default params yet.  Return any.
	if (expName == "<default>")
		return EXPTYPE_NULL;

	CString movementName;
	ParseBehaviorExpression(objName, objName, movementName);

	CObjType* oT = LookupObjectType(objName, objMap);
	int DLLIndex;

	// Couldn't find object type: try family
	if (oT == NULL) {
		list<Family>::iterator f = find(pApp->families.begin(), pApp->families.end(), objName);

		// Not found
		if (f == pApp->families.end() || !f->is_in_use)
			return EXPTYPE_NULL;
		else
			DLLIndex = f->DLLIndex;

	}
	else DLLIndex = oT->DLLIndex;

	vector<ACESEntry2>* pTable;

	if (movementName != "") {
		CBehavior* m = LookupBehavior(oT, movementName);
		if (m == NULL) return EXPTYPE_NULL;

		OINFO* oInfo = GetOINFO(m->BehaviorDLLIndex);
		pTable = oInfo->GetTable(2);
	}
	else
		pTable = GetOINFO(DLLIndex)->GetTable(2);

	// Find expression and get type
	int Count = pTable->size();
	for (int i = 0; i < Count; i++)
	{
		CString Exp = pTable->at(i).aceDisplayText;
		Exp.MakeLower();
		if (Exp == expName)
		{
			switch (pTable->at(i).retrn)
			{
			case 0:
				return EXPTYPE_NULL;
			case RETURN_INTEGER:
				return EXPTYPE_INTEGER;
			case RETURN_FLOAT:
				return EXPTYPE_FLOAT;
			case RETURN_STRING:
				return EXPTYPE_STRING;
			case RETURN_ARRAY:
				return EXPTYPE_ARRAY;
			}
		}
	}

	// Return type is 'any' if not found
	return EXPTYPE_NULL;
}
コード例 #10
0
void ObjectBarDialog::OnDblClickObject(NMHDR *pNMHDR, LRESULT *pResult)
{
	POSITION Pos = objects.GetFirstSelectedItemPosition();
	int Item = objects.GetNextSelectedItem(Pos);

	if (Item == -1) return;

	CObjType* pType;
	long ID = objects.GetItemData(Item);

	if (ID == -1)  // object folder
	{
		if (folderfilter == -1)  //Default folder
		{
			for(int i=0; i < application->object_folders.size(); i++)
			{
				if (objects.GetItemText(Item,0) == application->object_folders[i].name)
				{
					folderfilter=i;
					break;
				}
			}
		}
		else //return folder
		{
			folderfilter = -1;
		}
		Refresh();
		return;
	}

	application->object_types.Lookup(ID, pType);

	if (!pType) return;

	// If layout editor open..
	if (parent.m_tabs.SelectionGet() == 0 && parent.m_tabs.ItemGetCount() == 2)
	{
		POSITION ObjectPos = layout->objects.GetStartPosition();
		CObj* pObject;
		long ID = 0;

		for (int i = 0; i < layout->objects.GetCount(); i++) 
		{
			layout->objects.GetNextAssoc(ObjectPos, ID, pObject);

			CObjType* type = pObject->GetObjectType(application);

			if (type->ObjectIdentifier == pType->ObjectIdentifier)
			{
				OINFO* info = GetOINFO(pType->DLLIndex);
				if(info->ETOnNotify)
					info->ETOnNotify(pObject->editObject, 1);

				return;
			}
		}
	}

	// If event sheet editor, see if it has conditions. If so, open Event Wizard
	if ((parent.m_tabs.SelectionGet() == 1) && (parent.m_tabs.ItemGetCount() == 2) || parent.m_tabs.ItemGetCount() == 1)
	{
		bool bUse = false;

		for (int i = 0; i < pType->GetTableCount(CONDITION); i++)
		{
			ACESEntry2* pAce = pType->GetACESEntry(CONDITION, i);
			if(pAce == NULL || pAce->aceListName == "")
				continue; // Ignore null entries

			bUse = true;
		}

		if (bUse)
		{
			parent.m_pEventView[0][0]->m_InitialStage = 2;
			parent.m_pEventView[0][0]->m_InitialSelect = ID;
			parent.m_pEventView[0][0]->m_OldName = pType->GetName();
			parent.m_pEventView[0][0]->AddCondition(true);
		}
	}
}
コード例 #11
0
void ObjectBarDialog::OnClickObject(NMHDR *pNMHDR, LRESULT *pResult)
{
	POSITION Pos = objects.GetFirstSelectedItemPosition();
	int Item = objects.GetNextSelectedItem(Pos);

	if (!layout) return;

	if (layout->m_ObjectFrameIsLockedTo != 0) // InputLocked()
		return;

	// Select in layout editor, if it's open
	if (parent.m_tabs.SelectionGet() == 0 && parent.m_tabs.ItemGetCount() == 2)
	{
		parent.layout_editor[0][0]->m_sel.RemoveAll();

		// This is intentionally here; clear selection if clicked on whitespace
		if(Item == -1)
		{
			parent.layout_editor[0][0]->Invalidate();
			g_PropertyBar->Update(parent.layout_editor[0][0], TYPE_LAYOUT, NULL, layout, NULL, application); 

			return;
		}

		// Now we have to wangle in the selected object
		int ObjectIdentifier = objects.GetItemData(Item);

		if (ObjectIdentifier==-1)
			return; //folder

		CObj*			pObject = 0;
		CObjType*		pObjectType = 0;

		POSITION LayerPos = layout->layers.GetHeadPosition();

		// So we have to find all the CObj's with this CObjType in the layout, and add them
		// For each layer
		while(LayerPos)
		{
			CLayer* pLayer = layout->layers.GetNext(LayerPos);

			// Loop all objects
			CObjList Objects;
			pLayer->GetEveryObject(Objects, layout);

			POSITION ObjectPos = Objects.GetHeadPosition();

			for (int i = 0; i < Objects.GetCount(); i++) 
			{
				CObj* pTestObject;
				long ID = Objects.GetNext(ObjectPos);
				layout->objects.Lookup(ID, pTestObject);

				if (pTestObject->GetGlobalID() != -1) 
				{
					CObjType* pTestType = pTestObject->GetObjectType(application);

					if (pTestType->ObjectIdentifier == ObjectIdentifier)
					{
						pObjectType = pTestType;
						pObject = pTestObject;

						long nKey = pObject->GetInstanceID();
						parent.layout_editor[0][0]->m_sel.AddTail(nKey);
					}
				}
			}
		}

		g_PropertyBar->Update(parent.layout_editor[0][0], TYPE_OBJECT, &parent.layout_editor[0][0]->m_sel, layout, &layout->objects, application); // Show object properties

		parent.layout_editor[0][0]->Invalidate();

		// While we're here, show animations for object
		// Future note: .. to be continued

		if(!pObjectType)
			return;

		int iRoot = -1;
		OINFO* oInfo = GetOINFO(pObjectType->DLLIndex);
		if (oInfo->ETGetAnimationHandle)
		{
			oInfo->ETGetAnimationHandle(pObject->editObject, iRoot);
			pMainWnd->animator.UpdateAnimations(application, layout, pObjectType, iRoot);
		}
	}
}
コード例 #12
0
ファイル: UsedPluginDlg.cpp プロジェクト: aolko/construct
BOOL UsedPluginDialog::OnInitDialog() 
{
	CExtNCW<CExtResizableDialog>::OnInitDialog();
	
	objects.SetExtendedStyle(LVS_EX_FULLROWSELECT);

	objects.InsertColumn(0, "Name"   , LVCFMT_LEFT, 90);
	objects.InsertColumn(1, "Creator", LVCFMT_LEFT, 110);
	objects.InsertColumn(2, "License", LVCFMT_LEFT, 100);

	dialog_manager.Load(this->m_hWnd, "Software\\Construct\\UsedPlugins");
    dialog_anchor.Init(this->m_hWnd);

	dialog_anchor.Add(IDCLOSE, ANCHOR_LEFT | ANCHOR_BOTTOM);
	dialog_anchor.Add(IDC_APPNAME, ANCHOR_TOP | ANCHOR_LEFT | ANCHOR_RIGHT);
	dialog_anchor.Add(IDC_BOX1, ANCHOR_BOTTOMRIGHT | ANCHOR_TOPLEFT);
	dialog_anchor.Add(IDC_OBJECTS, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT);
	dialog_anchor.Add(IDC_INFORMATION, ANCHOR_RIGHT | ANCHOR_TOP);
	dialog_anchor.Add(IDCLOSE, ANCHOR_RIGHT | ANCHOR_TOP);

	SetDlgItemText(IDC_APPNAME, application->file_information.name);

	CString Title;
	Title.Format("Construct : Used plugins");
	SetWindowText(Title);

	// Loop and find all plugins
	CStringArray IDList;

	for (int j = 0; j < application->object_types.GetCount(); j++)
	{
		// Check if we have the specified ID
		CObjType* oT;

		POSITION pos = application->object_types.GetStartPosition();
		long mapKey;

		// Loop through and add the objects
		while (pos != NULL) 
		{
			application->object_types.GetNextAssoc(pos, mapKey, oT);

			// Do we have this ID
			bool Add = true;

			CString ID;
			ID.Format("%d", oT->DLLIndex);

			for (int k = 0; k < IDList.GetSize(); k++)
			{
				if (IDList.GetAt(k) == ID)
					Add = false;
			}

			if (Add) IDList.Add(ID);
		}
	}

	for (int i = 0; i < IDList.GetSize(); i++)
	{
		OINFO* oInfo = GetOINFO(atoi(IDList.GetAt(i)));

		char strText[1024];
		LoadString(oInfo->hInstLib, OBJ_AUTHOR, strText, 1024);

		int item = objects.InsertItem(i, oInfo->extName, 0);
		objects.SetItemText(i, 1, strText);

		LoadString(oInfo->hInstLib, 10, strText, 1024);

		objects.SetItemText(i, 2, strText);
	}

	// Setup buttons
	close.SetWindowText(CLOSE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}