Пример #1
0
/* Allow us to pre-load the DIB once for future draws */
#ifdef MESS
BOOL LoadScreenShotEx(int nGame, LPCSTR lpSoftwareName, int nType)
#else /* !MESS */
BOOL LoadScreenShot(int nGame, int nType)
#endif /* MESS */
{
	BOOL loaded = FALSE;
	/* No need to reload the same one again */
#ifndef MESS
	if (nGame == current_image_game && nType == current_image_type)
		return TRUE;
#endif

	/* Delete the last ones */
	FreeScreenShot();

	/* Load the DIB */
#ifdef MESS
	if (lpSoftwareName)
	{
		int nParentIndex = -1;
		loaded = LoadSoftwareScreenShot(drivers[nGame], lpSoftwareName, nType);
		if (!loaded && DriverIsClone(nGame) == TRUE)
		{
			nParentIndex = GetParentIndex(drivers[nGame]);
			loaded = LoadSoftwareScreenShot(drivers[nParentIndex], lpSoftwareName, nType);
		}
	}
	if (!loaded)
#endif /* MESS */
	{
		loaded = LoadDIB(drivers[nGame]->name, &m_hDIB, &m_hPal, nType);
	}

	/* If not loaded, see if there is a clone and try that */
	if (!loaded)
	{
		int nParentIndex = GetParentIndex(drivers[nGame]);
		if( nParentIndex >= 0)
		{
			loaded = LoadDIB(drivers[nParentIndex]->name, &m_hDIB, &m_hPal, nType);
			nParentIndex = GetParentIndex(drivers[nParentIndex]);
			if (!loaded && nParentIndex >= 0)
				loaded = LoadDIB(drivers[nParentIndex]->name, &m_hDIB, &m_hPal, nType);
		}
	}

	if (loaded)
	{
		HDC hdc = GetDC(GetMainWindow());
		m_hDDB = DIBToDDB(hdc, m_hDIB, NULL);
		ReleaseDC(GetMainWindow(),hdc);
		
		current_image_game = nGame;
		current_image_type = nType;

	}

	return (loaded) ? TRUE : FALSE;
}
Пример #2
0
void Heap::upheap(int node)
{
    if (GetParentIndex(node) < 0)
        return;

    if (SatisfiesHeapProperty(GetParentIndex(node)))
        return;

    std::swap(m_heap.at(node), m_heap.at(GetParentIndex(node)));

    upheap(GetParentIndex(node));
}
Пример #3
0
/***********************************************************************************
**
**	TreeViewModel::OnItemAdded
**
***********************************************************************************/
void TreeViewModel::OnItemAdded(OpTreeModel* tree_model, INT32 index)
{
	TreeViewModelItem* item = OP_NEW(TreeViewModelItem, (m_model->GetItemByPosition(index)));
    if (!item) return;
	if (GetSortListener())
	{
		INT32 parent = GetIndexByModelIndex(m_model->GetItemParent(index));
		if (parent == -1 && GetTreeModelGrouping() && GetTreeModelGrouping()->HasGrouping())
		{
			parent = static_cast<TreeViewModelItem*>(GetTreeModelGrouping()->GetGroupHeader(GetTreeModelGrouping()->GetGroupForItem(item)))->GetIndex();
		}

		AddSorted(item, parent);
	}
	else
	{
		INT32 parent = m_model->GetItemParent(index);

		if (index < GetCount() && GetParentIndex(index) == parent)
		{
			InsertBefore(item, index);
		}
		else
		{
			AddLast(item, parent);
		}
	}
}
Пример #4
0
/* Allow us to pre-load the DIB once for future draws */
BOOL LoadScreenShotEx(int nGame, LPCSTR lpSoftwareName, int nType)
{
	BOOL loaded = FALSE;

	/* Delete the last ones */
	FreeScreenShot();

	/* Load the DIB */

	if (lpSoftwareName)
	{
		int nParentIndex = -1;
		loaded = LoadSoftwareScreenShot(&driver_list::driver(nGame), lpSoftwareName, nType);
		if (!loaded && DriverIsClone(nGame) == TRUE)
		{
			nParentIndex = GetParentIndex(&driver_list::driver(nGame));
			loaded = LoadSoftwareScreenShot(&driver_list::driver(nParentIndex), lpSoftwareName, nType);
		}
	}

	if (!loaded)
		loaded = LoadDIB(driver_list::driver(nGame).name, &m_hDIB, &m_hPal, nType);

	/* If not loaded, see if there is a clone and try that */
	if (!loaded)
	{
		int nParentIndex = GetParentIndex(&driver_list::driver(nGame));
		if( nParentIndex >= 0)
		{
			loaded = LoadDIB(driver_list::driver(nParentIndex).name, &m_hDIB, &m_hPal, nType);
			nParentIndex = GetParentIndex(&driver_list::driver(nParentIndex));
			if (!loaded && nParentIndex >= 0)
				loaded = LoadDIB(driver_list::driver(nParentIndex).name, &m_hDIB, &m_hPal, nType);
		}
	}

	if (loaded)
	{
		HDC hdc = GetDC(GetMainWindow());
		m_hDDB = DIBToDDB(hdc, m_hDIB, NULL);
		ReleaseDC(GetMainWindow(),hdc);
	}

	return (loaded) ? TRUE : FALSE;
}
Пример #5
0
INT32 GenericTreeModel::GetPreviousLeafIndex(INT32 index)
{
	if (GetSubtreeSize(index) == 0)
	{
		// this is a leaf itself. Go up
		while (GetPreviousIndex(index) == -1 && index != -1)
			index = GetParentIndex(index);
		if (index == -1)
			return -1;
		
		index = GetPreviousIndex(index);
	}

	// Go down to the leaf
	return index + GetSubtreeSize(index);
}
Пример #6
0
INT32 GenericTreeModel::GetNextLeafIndex(INT32 index)
{
	if (GetSubtreeSize(index) == 0)
	{
		// this is a leaf itself. Go up
		while (GetSiblingIndex(index) == -1 && index != -1)
			index = GetParentIndex(index);
		if (index == -1)
			return -1;
		
		index = GetSiblingIndex(index);
	}

	// Go down to the leaf
	while (GetChildIndex(index) != -1)
		index = GetChildIndex(index);

	return index;
}
Пример #7
0
INT32 GenericTreeModel::ResortItem(INT32 index)
{
	OP_ASSERT(m_sort_listener);

	if (!m_sort_listener)
		return -1;

	INT32 sibling = -1;

	// Binary search until correct sibling is found

	INT32 tree_size = GetSubtreeSize(index) + 1;
	INT32 parent = GetParentIndex(index);
	INT32 parent_tree_size = GetSubtreeSize(parent);
	INT32 lowest = 0;
	INT32 highest = parent_tree_size - tree_size;
	GenericTreeModelItem* item = GetGenericItemByIndex(index);

	while (lowest < highest)
	{
		INT32 current_position = (lowest + highest) / 2;
		INT32 pos_to_compare_to = parent + current_position + 1;

		if (pos_to_compare_to >= index)
			pos_to_compare_to += tree_size;

		// convert any grandchildren up to same level we're inserting at
		INT32 parent_of_pos_to_compare_to	= GetParentIndex(pos_to_compare_to);

		while (parent_of_pos_to_compare_to != parent)
		{
			pos_to_compare_to = parent_of_pos_to_compare_to;
			parent_of_pos_to_compare_to = GetParentIndex(pos_to_compare_to);
		}

		INT32 comparison = m_sort_listener->OnCompareItems(this, item, GetGenericItemByIndex(pos_to_compare_to));

		if (comparison > 0)
		{
			lowest = current_position + 1;
		}
		else
		{
			sibling = pos_to_compare_to;
			highest = current_position;
		}
	}

	INT32 newpos = (sibling != -1 ? sibling : parent + 1 + parent_tree_size);
	if (newpos == index)
		return newpos;

	ModelLock lock(this);

	SetChangeType(TREE_CHANGED);

	GenericTreeModelItem** items = OP_NEWA(GenericTreeModelItem*, tree_size);
	if (!items)
		return -1;

	for (INT32 i = 0; i < tree_size; i++)
		items[i] = m_items.Get(index + i);

	m_items.Remove(index, tree_size);

	if (newpos > index)
		newpos -= tree_size;

	for (INT32 i = tree_size - 1; i >= 0; i--)
		m_items.Insert(newpos, items[i]);

	OP_DELETEA(items);

	return newpos;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pPatch - 
//			*pPoints - 
//			&vecNormal - 
//			flArea - 
//-----------------------------------------------------------------------------
bool CVRADDispColl::InitPatch( int iPatch, int iParentPatch, int iChild, Vector *pPoints, int *pIndices, float &flArea )
{
	// Get the current patch.
	CPatch *pPatch = &g_Patches[iPatch];
	if ( !pPatch )
		return false;

	// Clear the patch data.
	memset( pPatch, 0, sizeof( CPatch ) );

	// Setup the parent if we are not the parent.
	CPatch *pParentPatch = NULL;
	if ( iParentPatch != g_Patches.InvalidIndex() )
	{
		// Get the parent patch.
		pParentPatch = &g_Patches[iParentPatch];
		if ( !pParentPatch )
			return false;
	}

	// Attach the face to the correct lists.
	if ( !pParentPatch )
	{
		// This is a parent.
		pPatch->ndxNext = g_FacePatches.Element( GetParentIndex() );
		g_FacePatches[GetParentIndex()] = iPatch;
		pPatch->faceNumber = GetParentIndex();
	}
	else
	{
		pPatch->ndxNext = g_Patches.InvalidIndex();
		pPatch->faceNumber = pParentPatch->faceNumber;

		// Attach to the parent patch.
		if ( iChild == 0 )
		{
			pParentPatch->child1 = iPatch;
		}
		else
		{
			pParentPatch->child2 = iPatch;
		}
	}

	// Initialize parent and children indices.
	pPatch->child1 = g_Patches.InvalidIndex();
	pPatch->child2 = g_Patches.InvalidIndex();
	pPatch->ndxNextClusterChild = g_Patches.InvalidIndex();
	pPatch->ndxNextParent = g_Patches.InvalidIndex();
	pPatch->parent = iParentPatch;

	// Get triangle edges.
	Vector vecEdges[3];
	vecEdges[0] = pPoints[1] - pPoints[0];
	vecEdges[1] = pPoints[2] - pPoints[0];
	vecEdges[2] = pPoints[2] - pPoints[1];

	// Find the longest edge.
//	float flEdgeLength = 0.0f;
//	for ( int iEdge = 0; iEdge < 3; ++iEdge )
//	{
//		if ( flEdgeLength < vecEdges[iEdge].Length() )
//		{
//			flEdgeLength = vecEdges[iEdge].Length();
//		}
//	}

	// Calculate the triangle normal and area.
	Vector vecNormal = vecEdges[1].Cross( vecEdges[0] );
	flArea = VectorNormalize( vecNormal );
	flArea *= 0.5f;

	// Initialize the patch scale.
	pPatch->scale[0] = pPatch->scale[1] = 1.0f;

	// Set the patch chop - minchop (that is what the minimum area is based on).
	pPatch->chop = dispchop;

	// Displacements are not sky!
	pPatch->sky = false;

	// Copy the winding.
	Vector vecCenter( 0.0f, 0.0f, 0.0f );
	pPatch->winding = AllocWinding( 3 );
	pPatch->winding->numpoints = 3;
	for ( int iPoint = 0; iPoint < 3; ++iPoint )
	{
		VectorCopy( pPoints[iPoint], pPatch->winding->p[iPoint] );
		VectorAdd( pPoints[iPoint], vecCenter, vecCenter );

		pPatch->indices[iPoint] = static_cast<short>( pIndices[iPoint] );
	}

	// Set the origin and normal.
	VectorScale( vecCenter, ( 1.0f / 3.0f ), vecCenter );
	VectorCopy( vecCenter, pPatch->origin );
	VectorCopy( vecNormal, pPatch->normal );

	// Create the plane.
	pPatch->plane = new dplane_t;
	if ( !pPatch->plane )
		return false;

	VectorCopy( vecNormal, pPatch->plane->normal );
	pPatch->plane->dist = vecNormal.Dot( pPoints[0] );
	pPatch->plane->type = PlaneTypeForNormal( pPatch->plane->normal );
	pPatch->planeDist = pPatch->plane->dist;

	// Set the area.
	pPatch->area = flArea;

	// Calculate the mins/maxs.
	Vector vecMin( FLT_MAX, FLT_MAX, FLT_MAX );
	Vector vecMax( FLT_MIN, FLT_MIN, FLT_MIN );
	for ( int iPoint = 0; iPoint < 3; ++iPoint )
	{
		for ( int iAxis = 0; iAxis < 3; ++iAxis )
		{
			vecMin[iAxis] = MIN( vecMin[iAxis], pPoints[iPoint][iAxis] );
			vecMax[iAxis] = MAX( vecMax[iAxis], pPoints[iPoint][iAxis] );
		}
	}

	VectorCopy( vecMin, pPatch->mins );
	VectorCopy( vecMax, pPatch->maxs );

	if ( !pParentPatch )
	{
		VectorCopy( vecMin, pPatch->face_mins );
		VectorCopy( vecMax, pPatch->face_maxs );
	}
	else
	{
		VectorCopy( pParentPatch->face_mins, pPatch->face_mins );
		VectorCopy( pParentPatch->face_maxs, pPatch->face_maxs );
	}

	// Check for bumpmap.
	dface_t *pFace = dfaces + pPatch->faceNumber;
	texinfo_t *pTexInfo = &texinfo[pFace->texinfo];
	pPatch->needsBumpmap = pTexInfo->flags & SURF_BUMPLIGHT ? true : false;

	// Misc...
	pPatch->m_IterationKey = 0;

	// Get the base light for the face.
	if ( !pParentPatch )
	{
		BaseLightForFace( &g_pFaces[pPatch->faceNumber], pPatch->baselight, &pPatch->basearea, pPatch->reflectivity );
	}
	else
	{
		VectorCopy( pParentPatch->baselight, pPatch->baselight );
		pPatch->basearea = pParentPatch->basearea;
		pPatch->reflectivity = pParentPatch->reflectivity;
	}

	return true;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : iPatch - 
//			iParentPatch - 
//			iChild - 
//			*pPoints - 
//			*pIndices - 
//			&flArea - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CVRADDispColl::InitParentPatch( int iPatch, Vector *pPoints, float &flArea )
{
	// Get the current patch.
	CPatch *pPatch = &g_Patches[iPatch];
	if ( !pPatch )
		return false;

	// Clear the patch data.
	memset( pPatch, 0, sizeof( CPatch ) );

	// This is a parent.
	pPatch->ndxNext = g_FacePatches.Element( GetParentIndex() );
	g_FacePatches[GetParentIndex()] = iPatch;
	pPatch->faceNumber = GetParentIndex();

	// Initialize parent and children indices.
	pPatch->child1 = g_Patches.InvalidIndex();
	pPatch->child2 = g_Patches.InvalidIndex();
	pPatch->parent = g_Patches.InvalidIndex();
	pPatch->ndxNextClusterChild = g_Patches.InvalidIndex();
	pPatch->ndxNextParent = g_Patches.InvalidIndex();

	Vector vecEdges[2];
	vecEdges[0] = pPoints[1] - pPoints[0];
	vecEdges[1] = pPoints[3] - pPoints[0];

	// Calculate the triangle normal and area.
	Vector vecNormal = vecEdges[1].Cross( vecEdges[0] );
	flArea = VectorNormalize( vecNormal );

	// Initialize the patch scale.
	pPatch->scale[0] = pPatch->scale[1] = 1.0f;

	// Set the patch chop - minchop (that is what the minimum area is based on).
	pPatch->chop = dispchop;

	// Displacements are not sky!
	pPatch->sky = false;

	// Copy the winding.
	Vector vecCenter( 0.0f, 0.0f, 0.0f );
	pPatch->winding = AllocWinding( 4 );
	pPatch->winding->numpoints = 4;
	for ( int iPoint = 0; iPoint < 4; ++iPoint )
	{
		VectorCopy( pPoints[iPoint], pPatch->winding->p[iPoint] );
		VectorAdd( pPoints[iPoint], vecCenter, vecCenter );
	}

	// Set the origin and normal.
	VectorScale( vecCenter, ( 1.0f / 4.0f ), vecCenter );
	VectorCopy( vecCenter, pPatch->origin );
	VectorCopy( vecNormal, pPatch->normal );

	// Create the plane.
	pPatch->plane = new dplane_t;
	if ( !pPatch->plane )
		return false;

	VectorCopy( vecNormal, pPatch->plane->normal );
	pPatch->plane->dist = vecNormal.Dot( pPoints[0] );
	pPatch->plane->type = PlaneTypeForNormal( pPatch->plane->normal );
	pPatch->planeDist = pPatch->plane->dist;

	// Set the area.
	pPatch->area = flArea;

	// Calculate the mins/maxs.
	Vector vecMin( FLT_MAX, FLT_MAX, FLT_MAX );
	Vector vecMax( FLT_MIN, FLT_MIN, FLT_MIN );
	for ( int iPoint = 0; iPoint < 4; ++iPoint )
	{
		for ( int iAxis = 0; iAxis < 3; ++iAxis )
		{
			vecMin[iAxis] = MIN( vecMin[iAxis], pPoints[iPoint][iAxis] );
			vecMax[iAxis] = MAX( vecMax[iAxis], pPoints[iPoint][iAxis] );
		}
	}

	VectorCopy( vecMin, pPatch->mins );
	VectorCopy( vecMax, pPatch->maxs );
	VectorCopy( vecMin, pPatch->face_mins );
	VectorCopy( vecMax, pPatch->face_maxs );

	// Check for bumpmap.
	dface_t *pFace = dfaces + pPatch->faceNumber;
	texinfo_t *pTexInfo = &texinfo[pFace->texinfo];
	pPatch->needsBumpmap = pTexInfo->flags & SURF_BUMPLIGHT ? true : false;

	// Misc...
	pPatch->m_IterationKey = 0;

	// Calculate the base light, area, and reflectivity.
	BaseLightForFace( &g_pFaces[pPatch->faceNumber], pPatch->baselight, &pPatch->basearea, pPatch->reflectivity );

	return true;
}
Пример #10
0
/* Allow us to pre-load the DIB once for future draws */
#ifdef MESS
BOOL LoadScreenShotEx(int nGame, LPCSTR lpSoftwareName, int nType)
#else /* !MESS */
BOOL LoadScreenShot(int nGame, int nType)
#endif /* MESS */
{
	BOOL loaded = FALSE;
	/* No need to reload the same one again */
#ifndef MESS
	if (nGame == current_image_game && nType == current_image_type)
		return TRUE;
#endif

	/* Delete the last ones */
	FreeScreenShot();

	/* Load the DIB */
#ifdef MESS
	if (lpSoftwareName)
	{
		int nParentIndex = -1;
		loaded = LoadSoftwareScreenShot(&driver_list::driver(nGame), lpSoftwareName, nType);
		if (!loaded && DriverIsClone(nGame) == TRUE)
		{
			nParentIndex = GetParentIndex(&driver_list::driver(nGame));
			loaded = LoadSoftwareScreenShot(&driver_list::driver(nParentIndex), lpSoftwareName, nType);
		}
	}
	if (!loaded)
#endif /* MESS */
	{
		loaded = LoadDIB(driver_list::driver(nGame).name, &m_hDIB, &m_hPal, nType);
	}

	/* If not loaded, see if there is a clone and try that */
	if (!loaded)
	{
		int nParentIndex = GetParentIndex(&driver_list::driver(nGame));
		if( nParentIndex >= 0)
		{
			loaded = LoadDIB(driver_list::driver(nParentIndex).name, &m_hDIB, &m_hPal, nType);
			nParentIndex = GetParentIndex(&driver_list::driver(nParentIndex));
			if (!loaded && nParentIndex >= 0)
				loaded = LoadDIB(driver_list::driver(nParentIndex).name, &m_hDIB, &m_hPal, nType);
		}
	}

#ifndef MESS
	/* MSH 20071029 - If driver is broken and no images exists, look for nonworking.png */
	if (!loaded && DriverIsBroken(nGame))
	{
		loaded = LoadDIB("nonworking", &m_hDIB, &m_hPal, nType);
	}
#endif

	if (loaded)
	{
		HDC hdc = GetDC(GetMainWindow());
		m_hDDB = DIBToDDB(hdc, m_hDIB, NULL);
		ReleaseDC(GetMainWindow(),hdc);

		current_image_game = nGame;
		current_image_type = nType;

	}

	return (loaded) ? TRUE : FALSE;
}
Пример #11
0
/* Allow us to pre-load the DIB once for future draws */
#ifdef MESS
BOOL LoadScreenShotEx(int nGame, LPCSTR lpSoftwareName, int nType)
#else /* !MESS */
#ifdef USE_IPS
BOOL LoadScreenShot(int nGame, LPCWSTR lpIPSName, int nType)
#else /* USE_IPS */
BOOL LoadScreenShot(int nGame, int nType)
#endif /* USE_IPS */
#endif /* MESS */
{
	BOOL loaded = FALSE;
	int nIndex = nGame;

	/* No need to reload the same one again */
#ifndef MESS
	if (nGame == current_image_game && nType == current_image_type)
		return TRUE;
#endif

	/* Delete the last ones */
	FreeScreenShot();

	/* Load the DIB */
#ifdef MESS
	if (lpSoftwareName)
	{
		int nParentIndex = -1;
		loaded = LoadSoftwareScreenShot(&driver_list::driver(nGame), lpSoftwareName, nType);
		if (!loaded && DriverIsClone(nGame) == TRUE)
		{
			nParentIndex = GetParentIndex(drivers[nGame]);
			loaded = LoadSoftwareScreenShot(&driver_list::driver(nParentIndex), lpSoftwareName, nType);
		}
	}
	if (!loaded)
#endif /* MESS */
	{
#ifdef USE_IPS
		if (lpIPSName)
		{
			WCHAR *wdrv = driversw[nIndex]->name;
			WCHAR buf[MAX_PATH];

			wsprintf(buf, TEXT("%s/%s"), wdrv, lpIPSName);
			dwprintf(TEXT("found ipsname: %s"), buf);

			while (!loaded && nIndex >= 0)
			{
				wdrv = driversw[nIndex]->name;
				wsprintf(buf, TEXT("%s/%s"), wdrv, lpIPSName);
				loaded = LoadDIB(buf, &m_hDIB, &m_hPal, nType);
				nIndex = GetParentIndex(&driver_list::driver(nIndex));
			}
		}
		else
#endif /* USE_IPS */
		{
			dwprintf(TEXT("not found ipsname: %s"), driversw[nIndex]->name);

			while (!loaded && nIndex >= 0)
			{
				loaded = LoadDIB(driversw[nIndex]->name, &m_hDIB, &m_hPal, nType);
				nIndex = GetParentIndex(&driver_list::driver(nIndex));
			}
		}
	}

	if (loaded)
	{
		HDC hdc = GetDC(GetMainWindow());
		m_hDDB = DIBToDDB(hdc, m_hDIB, NULL);
		ReleaseDC(GetMainWindow(),hdc);

		current_image_game = nGame;
		current_image_type = nType;

	}

	return (loaded) ? TRUE : FALSE;
}
Пример #12
0
void FReferenceSkeleton::RemoveDuplicateBones(const UObject* Requester, TArray<FBoneIndexType> & DuplicateBones)
{
	const int32 NumBones = GetNum();
	DuplicateBones.Empty();

	TMap<FName, int32> BoneNameCheck;
	bool bRemovedBones = false;
	for (int32 BoneIndex = NumBones - 1; BoneIndex >= 0; BoneIndex--)
	{
		const FName& BoneName = GetBoneName(BoneIndex);
		const int32* FoundBoneIndexPtr = BoneNameCheck.Find(BoneName);

		// Not a duplicate bone, track it.
		if (FoundBoneIndexPtr == NULL)
		{
			BoneNameCheck.Add(BoneName, BoneIndex);
		}
		else
		{
			const int32 DuplicateBoneIndex = *FoundBoneIndexPtr;
			DuplicateBones.Add(DuplicateBoneIndex);

			UE_LOG(LogAnimation, Warning, TEXT("RemoveDuplicateBones: duplicate bone name (%s) detected for (%s)! Indices: %d and %d. Removing the latter."),
				*BoneName.ToString(), *GetNameSafe(Requester), DuplicateBoneIndex, BoneIndex);

			// Remove duplicate bone index, which was added later as a mistake.
			RefBonePose.RemoveAt(DuplicateBoneIndex, 1);
			RefBoneInfo.RemoveAt(DuplicateBoneIndex, 1);

			// Now we need to fix all the parent indices that pointed to bones after this in the array
			// These must be after this point in the array.
			for (int32 j = DuplicateBoneIndex; j < GetNum(); j++)
			{
				if (GetParentIndex(j) >= DuplicateBoneIndex)
				{
					RefBoneInfo[j].ParentIndex -= 1;
				}
			}

			// Update entry in case problem bones were added multiple times.
			BoneNameCheck.Add(BoneName, BoneIndex);

			// We need to make sure that any bone that has this old bone as a parent is fixed up
			bRemovedBones = true;
		}
	}

	// If we've removed bones, we need to rebuild our name table.
	if (bRemovedBones || (NameToIndexMap.Num() == 0))
	{
		RebuildNameToIndexMap();
	}

	// Make sure our arrays are in sync.
	checkSlow((RefBoneInfo.Num() == RefBonePose.Num()) && (RefBoneInfo.Num() == NameToIndexMap.Num()));

	// Additionally normalize all quaternions to be safe.
	for (int32 BoneIndex = 0; BoneIndex < GetNum(); BoneIndex++)
	{
		RefBonePose[BoneIndex].NormalizeRotation();
	}
}
Пример #13
0
static BOOL DevView_GetOpenFileName(HWND hwndDevView, const machine_config *config, const device_image_interface *dev, LPTSTR pszFilename, UINT nFilenameLength)
{
	BOOL bResult = 0;
	TCHAR *t_s;
	int i = 0;
	mess_image_type imagetypes[256];
	HWND hwndList = GetDlgItem(GetMainWindow(), IDC_LIST);
	int drvindex = Picker_GetSelectedItem(hwndList);
	std::string as, dst;
	const char *s, *opt_name = dev->instance_name();
	windows_options o;
	load_options(o, OPTIONS_GAME, drvindex);
	s = o.value(opt_name);

	/* Get the path to the currently mounted image */
	util::zippath_parent(as, s);
	dst = as;

	/* See if an image was loaded, and that the path still exists */
	if ((!osd::directory::open(as.c_str())) || (as.find(':') == std::string::npos))
	{
		/* Get the path from the software tab */
		int driver_index = drvindex;
		windows_options o;
		load_options(o, OPTIONS_GAME, driver_index);
		const char* paths = o.value(OPTION_SWPATH);
		if (paths && (paths[0] > 64)) 
		{} else
		// search deeper when looking for software
		{
			// not specified in driver, try parent if it has one
			int nParentIndex = -1;
			if (DriverIsClone(driver_index) == TRUE)
			{
				nParentIndex = GetParentIndex(&driver_list::driver(driver_index));
				if (nParentIndex >= 0)
				{
					load_options(o, OPTIONS_PARENT, nParentIndex);
					paths = o.value(OPTION_SWPATH);
				}
			}
			if (paths && (paths[0] > 64))
			{} else
			{
				// still nothing, try for a system in the 'compat' field
				if (nParentIndex >= 0)
					driver_index = nParentIndex;

				// now recycle variable as a compat system number
				nParentIndex = GetCompatIndex(&driver_list::driver(driver_index));
				if (nParentIndex >= 0)
				{
					load_options(o, OPTIONS_PARENT, nParentIndex);
					paths = o.value(OPTION_SWPATH);
				}
			}
		}

		as = paths;
		/* We only want the first path; throw out the rest */
		i = as.find(';');
		if (i > 0) as.substr(0, i);
		dst = as;

		/* Make sure a folder was specified in the tab, and that it exists */
		if ((!osd::directory::open(as.c_str())) || (as.find(':') == std::string::npos))
		{
			// Get the global loose software path
			as = GetSWDir();

			/* We only want the first path; throw out the rest */
			i = as.find(';');
			if (i > 0) as.substr(0, i);
			dst = as;

			/* Make sure a folder was specified in the tab, and that it exists */
			if ((!osd::directory::open(as.c_str())) || (as.find(':') == std::string::npos))
			{
				/* Default to emu directory */
				osd_get_full_path(dst,".");
			}
		}
	}

	SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev);
	t_s = ui_wstring_from_utf8(dst.c_str());
	bResult = CommonFileImageDialog(t_s, GetOpenFileName, pszFilename, config, imagetypes);
	CleanupImageTypes(imagetypes, ARRAY_LENGTH(imagetypes));

	free(t_s);

	return bResult;
}
Пример #14
0
void MyFillSoftwareList(int drvindex, BOOL bForce)
{
	BOOL is_same = 0;
	HWND hwndSoftwarePicker;
	HWND hwndSoftwareList;
	HWND hwndSoftwareDevView;

	// do we have to do anything?
	if (!bForce)
	{
		if (s_config != NULL)
			is_same = (drvindex == s_config->driver_index);
		else
			is_same = (drvindex < 0);
		if (is_same)
			return;
	}

	// free the machine config, if necessary
	MySoftwareListClose();

	// allocate the machine config, if necessary
	if (drvindex >= 0)
		s_config = software_config_alloc(drvindex);

	// locate key widgets
	hwndSoftwarePicker = GetDlgItem(GetMainWindow(), IDC_SWLIST);
	hwndSoftwareList = GetDlgItem(GetMainWindow(), IDC_SOFTLIST);
	hwndSoftwareDevView = GetDlgItem(GetMainWindow(), IDC_SWDEVVIEW);

	// set up the device view
	DevView_SetDriver(hwndSoftwareDevView, s_config);

	// set up the software picker
	SoftwarePicker_Clear(hwndSoftwarePicker);
	SoftwarePicker_SetDriver(hwndSoftwarePicker, s_config);

	// Get the game's software path
	int driver_index = drvindex;
	windows_options o;
	load_options(o, OPTIONS_GAME, driver_index);
	const char* paths = o.value(OPTION_SWPATH);
	if (paths && (paths[0] > 64)) 
	{} else
	// search deeper when looking for software
	{
		// not specified in driver, try parent if it has one
		int nParentIndex = -1;
		if (DriverIsClone(driver_index) == TRUE)
		{
			nParentIndex = GetParentIndex(&driver_list::driver(driver_index));
			if (nParentIndex >= 0)
			{
				load_options(o, OPTIONS_PARENT, nParentIndex);
				paths = o.value(OPTION_SWPATH);
			}
		}
		if (paths && (paths[0] > 64))
		{} else
		{

			// still nothing, try for a system in the 'compat' field
			if (nParentIndex >= 0)
				driver_index = nParentIndex;

			// now recycle variable as a compat system number
			nParentIndex = GetCompatIndex(&driver_list::driver(driver_index));
			if (nParentIndex >= 0)
			{
				load_options(o, OPTIONS_PARENT, nParentIndex);
				paths = o.value(OPTION_SWPATH);
			}
		}
	}

	// These are the only paths that matter
	AddSoftwarePickerDirs(hwndSoftwarePicker, paths, NULL);
	paths = 0;
	// set up the software picker
	SoftwareList_Clear(hwndSoftwareList);
	SoftwareList_SetDriver(hwndSoftwareList, s_config);

	/* allocate the machine config */
	machine_config config(driver_list::driver(drvindex),MameUIGlobal());

	for (software_list_device &swlistdev : software_list_device_iterator(config.root_device()))
	{
		for (const software_info &swinfo : swlistdev.get_info())
		{
			const software_part &swpart = swinfo.parts().front();

			// search for a device with the right interface
			for (device_image_interface &image : image_interface_iterator(config.root_device()))
			{
				const char *interface = image.image_interface();
				if (interface)
				{
					if (swpart.matches_interface(interface))
					{
						// Extract the Usage data from the "info" fields.
						const char* usage = NULL;
						for (const feature_list_item &flist : swinfo.other_info())
							if (flist.name() == "usage")
								usage = flist.value().c_str();
						// Now actually add the item
						SoftwareList_AddFile(hwndSoftwareList, swinfo.shortname().c_str(), swlistdev.list_name().c_str(), swinfo.longname().c_str(), swinfo.publisher().c_str(), swinfo.year().c_str(), usage, image.brief_instance_name());
						break;
					}
				}
			}
		}
	}
}