예제 #1
0
void save_matrix(map<Type::InputType, vector<vector<Integer> > >& input_map,
        InputType input_type, const string& type_string, const vector<vector<Integer> >& M) {
    //check if this type already exists
    if (exists_element(input_map, input_type)) {
        cerr << "Error: Multiple inputs of type \"" << type_string
                << "\" are not allowed!" << endl;
        throw BadInputException();
    }
    input_map[input_type] = M;
}
예제 #2
0
파일: input.cpp 프로젝트: mkoeppe/Normaliz
void save_matrix(map<Type::InputType, vector<vector<mpq_class> > >& input_map,
        InputType input_type, const vector<vector<mpq_class> >& M) {
    //check if this type already exists
    if (exists_element(input_map, input_type)) {
        /*throw BadInputException("Multiple inputs of type \"" + type_string
                + "\" are not allowed!");*/
	input_map[input_type].insert(input_map[input_type].end(),M.begin(),M.end());
        return;
    }
    input_map[input_type] = M;
}
예제 #3
0
LRESULT CControlsDlg::OnComboSelection(WPARAM nItem, LPARAM nSubItem)
{
	if (nItem >= 0)
	{
		// Control column
		if (nSubItem == 1) {

			// Find this combo key
			CString itemText = m_Ctrls.GetItemText(nItem, nSubItem);

			for (int i = 0; controlTable[i].vk != -1; i++) {
				if (itemText == controlTable[i].name) {
					application->m_Controls[nItem].comboIndex = i;
					application->m_Controls[nItem].vk = controlTable[i].vk;
					break;
				}
			}
		}
		// Player column
		else if (nSubItem == 2) {

			CString itemText = m_Ctrls.GetItemText(nItem, nSubItem);
			int newplayer = 0;

			for (int i = 0; i < 10; i++) {
				if (itemText == players[i]) {
					newplayer = i;
					break;
				}
			}

			// Check this item name doesnt exist already for this player
			CString controlName = m_Ctrls.GetItemText(nItem, 0);

			BehaviorControl bc;
			bc.name = controlName;
			bc.player = newplayer;

			if (application->m_Controls[nItem].player != newplayer && exists_element(application->m_Controls.begin(), application->m_Controls.end(), bc)) {
				//CString msg;
				//msg.Format("The control '%s' already exists for player %d.", controlName, newplayer+1);
				//MessageBox(msg, "Cannot change player", MB_OK | MB_ICONEXCLAMATION);
				return 0;
			}

			// Set the new player
			application->m_Controls[nItem].player = newplayer;

		}

	}

	return 0;
}
예제 #4
0
bool Box2DCollisionFilter::ShouldCollide(b2Shape *shape1, b2Shape *shape2)
{
	ExtObject* a = (ExtObject*)shape1->GetUserData();
	ExtObject* b = (ExtObject*)shape2->GetUserData();

	// Shape 2 = 'none' for collision mask - simulate but don't collide
	if (a->shape == 2 || b->shape == 2)
		return false;

	// Neither have disabled anything: ok to go
	if (a->disabledCollisions.empty() && b->disabledCollisions.empty())
		return true;

	// b's type exists in a's disabled list
	if (exists_element(a->disabledCollisions.begin(), a->disabledCollisions.end(), b->pLink->pType))
		return false;

	// a's type exists in b's disabled list
	if (exists_element(b->disabledCollisions.begin(), b->disabledCollisions.end(), a->pLink->pType))
		return false;

	return true;
}
예제 #5
0
bool CTypeChecker::ObjectBehaviorExists(CString objName, CString movementName)
{
	CObjType* oT = LookupObjectType(objName, objMap);

	// 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 
			oT = pApp->FindObjTypeFromNumber(f->identifier);
	}

	return exists_element(oT->behaviors.begin(), oT->behaviors.end(), movementName);
}
예제 #6
0
void CControlsDlg::OnBnClickedAdd()
{
	// Add a new control key
	int counter = 2;

	BehaviorControl mc;
	mc.name = "Control 1";
	mc.player = 0;

	while (exists_element(application->m_Controls.begin(), application->m_Controls.end(), mc))
		mc.name.Format("Control %d", counter++);

	// Add this control
	mc.comboIndex = 0;
	//mc.vk = controlTable[0].vk;
	application->m_Controls.push_back(mc);

	int nItem = m_Ctrls.GetItemCount();
	m_Ctrls.InsertItem(nItem, mc.name);
	m_Ctrls.SetComboBox(nItem, 1, TRUE, &controls, 20, 0);
	m_Ctrls.SetComboBox(nItem, 2, TRUE, &players, 10, 0);
}
예제 #7
0
bool CTypeChecker::PrivateVariableExists(CString objName, CString expName, int paramNum, int numParams, CString varName)
{
	CString actualvarName = varName;
	objName.MakeLower();
	expName.MakeLower();
	varName.MakeLower();

	if (objName == "<system>")
		if(exists_element(pApp->global_variables.begin(), pApp->global_variables.end(), varName))
			return true;
		else
		{
			// Variable is undefined, add it to our list of undefined variables
			push_back_unique(m_UndefinedVariables, CUndefinedVariable(true, 0, varName));
			return true;
		}

	CObjType* oT;

	POSITION pos = objMap->GetStartPosition();
	long mapKey;

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

		CString Name = oT->GetName();
		Name.MakeLower();

		if (Name == objName)
		{
			if(exists_element(oT->m_PrivateValues.begin(), oT->m_PrivateValues.end(), varName))
				return true;
			else
			{
				// Variable undefined, add it to our list of undefined variables
				push_back_unique(m_UndefinedVariables, CUndefinedVariable(false, oT, actualvarName));
				return true;
			}
		}
	}

	// Check families
	list<Family>::iterator f = pApp->families.begin();

	for ( ; f != pApp->families.end(); f++) {
		if(f->is_in_use)
		{
			CString familyName = f->name;
			familyName.MakeLower();

			f->UpdateFamilyData();

			if (objName == familyName) {

				return f->VariableNameExists(varName);

			}
		}
	}

	return false;
}
예제 #8
0
void CObjectsPage::OnDoubleClickList(NMHDR *pNMHDR, LRESULT *pResult)
{
	*pResult = 0;

	int selectedLine = m_List.GetSelectionMark();
	CString itemText = m_List.GetItemText(selectedLine, 0);

	if (selectedLine < 0 || selectedLine >= m_List.GetItemCount())
		return;

	// Add to watch
	WatchKey key;
	key.label = m_List.GetItemText(m_List.GetSelectionMark(), 0);

	WatchItem item;
	if (pMyObject) {
		if (itemText.Left(1) == "'") {

			itemText = itemText.Mid(1, itemText.GetLength() - 2);

			// System object i.e. a global variable
			if (pMyObject->pType == NULL) {
				item.type = WATCH_GLOBALVAR;
				item.pvIndex = find_index(pRuntime->globalNames.begin(), pRuntime->globalNames.end(), itemText);
				item.pPrivateVars = NULL;
			}
			// A normal object i.e. a private variable
			else {
				item.type = WATCH_INSTANCEPRIVATEVAR;
				item.pvIndex = find_index(pMyObject->pType->privateVars.begin(), pMyObject->pType->privateVars.end(), itemText);
				item.pPrivateVars = pCurrentVars;
			}
		}
		else {
			item.type = WATCH_INSTANCE;
			item.pvIndex = -1;
			item.pPrivateVars = NULL;
		}

		item.obj = lineOwners[selectedLine];
	}
	else if (pMyType) {
		item.type = WATCH_OBJTYPE;
		item.objType = pMyType;
	}

	vector<WatchKey>& watchKeys = pWatchPage->watch[item];	

	/*
	// Operator[] is insisting on merging unrelated items.  Loop to explicitly use operator==
	Watch::iterator w = pWatchPage->watch.begin();
	Watch::iterator watch_end = pWatchPage->watch.end();

	for ( ; w != watch_end; w++) {
		if (w->first == item)
			break;
	}

	// Not found: insert new
	if (w == watch_end)
		watchKeys = &(pWatchPage->watch[item]);
	// Found: use existing
	else
		watchKeys = &(w->second);
		*/

	if (!exists_element(watchKeys.begin(), watchKeys.end(), key))
		watchKeys.push_back(key);
}
예제 #9
0
void CObjectsPage::OnRClickList(NMHDR *pNMHDR, LRESULT *pResult)
{
	*pResult = 0;

	CMenu menu;
	menu.LoadMenu(MAKEINTRESOURCE(IDR_LISTCONTEXT));

	// Don't show Add to Watch if not a valid line
	int selectedLine = m_List.GetSelectionMark();
	if (selectedLine >= 0 && selectedLine < lineOwners.size() && lineOwners[selectedLine] == NULL)
		return;

	POINT p;
	GetCursorPos(&p);
	switch (menu.GetSubMenu(0)->TrackPopupMenuEx(TPM_RETURNCMD | TPM_LEFTALIGN, p.x, p.y, &m_List, NULL))
	{
		// Nothing selected
	case 0:
		break;
	case ID_ADDTOWATCH:

		{
			// Add this watch item
			WatchKey key;
			key.label = m_List.GetItemText(selectedLine, 0);
			CString itemText = key.label;

			WatchItem item;
			if (pMyObject) {
				if (itemText.Left(1) == "'") {
					/*
					item.type = WATCH_INSTANCEPRIVATEVAR;
					itemText = itemText.Mid(1, itemText.GetLength() - 2);
					item.pvIndex = find_index(pMyObject->pType->privateVars.begin(), pMyObject->pType->privateVars.end(), itemText);
					item.pPrivateVars = pCurrentVars;
					*/
					itemText = itemText.Mid(1, itemText.GetLength() - 2);

					// System object i.e. a global variable
					if (pMyObject->pType == NULL) {
						item.type = WATCH_GLOBALVAR;
						item.pvIndex = find_index(pRuntime->globalNames.begin(), pRuntime->globalNames.end(), itemText);
						item.pPrivateVars = NULL;
					}
					// A normal object i.e. a private variable
					else {
						item.type = WATCH_INSTANCEPRIVATEVAR;
						item.pvIndex = find_index(pMyObject->pType->privateVars.begin(), pMyObject->pType->privateVars.end(), itemText);
						item.pPrivateVars = pCurrentVars;
					}
				}
				else {
					item.type = WATCH_INSTANCE;
					item.pvIndex = -1;
					item.pPrivateVars = NULL;
				}

				item.obj = lineOwners[selectedLine];
			}
			else if (pMyType) {
				item.type = WATCH_OBJTYPE;
				item.objType = pMyType;
			}

			vector<WatchKey>& watchKeys = pWatchPage->watch[item];
			if (!exists_element(watchKeys.begin(), watchKeys.end(), key))
				watchKeys.push_back(key);
			break;
		}
	}
}