Esempio n. 1
0
pugi::xml_node Syscfg::GetNode(const char * name)
{
	pugi::xml_node node = GetRootNode().child(name);
	if (!node)
		node = GetRootNode().append_child(name);
	return node;
}
Esempio n. 2
0
/**
 *  Moves a node to other branch.
 *  @param  refNode     Reference node.
 *  @param  moveNode    Node to be moved.
 *  @param  position    Position of the moved node.
*/
void VDFTree::MoveToBranch(VDFNode *refNode, VDFNode *moveNode, VDF_MOVEPOS position)
{
    VDFNode *targetPrevious;
    VDFNode *targetNext;
    VDFNode *srcPrevious;
    VDFNode *srcNext;

    if(refNode == NULL || moveNode == NULL || refNode == moveNode)
        return;

    if(!IsTreeNode(refNode) || !IsTreeNode(moveNode))
        return;

    targetPrevious = refNode->previousNode;
    targetNext = refNode->nextNode;
    srcPrevious = moveNode->previousNode;
    srcNext = moveNode->nextNode;

    if(position == VDF_MOVEPOS_AFTER) {

        if(srcPrevious == NULL) {
            if(moveNode->parentNode)
                moveNode->parentNode->childNode = srcNext;
        }

        refNode->nextNode = moveNode;
        moveNode->previousNode = refNode;
        moveNode->nextNode = targetNext;
        if(targetNext != NULL)
            targetNext->previousNode = moveNode;

        if(moveNode == rootNode)
            rootNode = GetRootNode(moveNode);

    }
    else {
        if(srcPrevious == NULL) {
            if(moveNode->parentNode)
                moveNode->parentNode->childNode = srcNext;
        }

        refNode->previousNode = moveNode;
        moveNode->nextNode = refNode;
        moveNode->previousNode = targetPrevious;

        if(moveNode == rootNode)
            rootNode = GetRootNode(moveNode);
        else if(refNode == rootNode)
            rootNode = moveNode;

    }

    if(srcNext)
        srcNext->previousNode = srcPrevious;

    if(srcPrevious)
        srcPrevious->nextNode = srcNext;

}
Esempio n. 3
0
void CTreeWnd::Layout(CRect& area)
{
	if (m_style & MTS_HEADER)
	{
		m_pHeader->SetWindowPos(NULL,area.left,area.top,area.Width(),DEF_HDR_HEIGHT,SWP_NOZORDER);
	}

	// No nodes in the tree, so quit without doing anything.
	if (!GetRootNode())
    {
        ClearAllShapes();
		return;
    }

    // Set up first visible node if it isn't already.
	if (!m_firstVisible)
    {
        m_firstVisible = GetRootNode();
    }

	// Skip root node if we need to...
	if (m_firstVisible == GetRootNode() && (!(m_style & MTS_SHOWROOT)))
	{
		m_firstVisible = m_firstVisible->FirstChild();
	}

	// build list of shapes for m_rendering.
    m_rendering = false;

	mtNode* pNode = m_pTree->getRoot();
	if (!(m_style & MTS_SHOWROOT))
		pNode = pNode->firstChild();

	CRect shapeArea = area;
	if (pNode)
	{
        if (m_style & MTS_HEADER)
            shapeArea.OffsetRect(0,DEF_HDR_HEIGHT);
		shapeArea.bottom = shapeArea.top + DEF_NODE_HEIGHT;
        ClearAllShapes();
		BuildNodeShapes(pNode,shapeArea,area,0);
	}

    // If we've got some space left and the first node isn't the root, then
    // re-layout.
    int extraSpace = area.bottom - shapeArea.bottom;
    if (extraSpace >= (DEF_NODE_HEIGHT*2) && m_firstVisible != GetRootNode())
    {
        int numNodes = extraSpace / DEF_NODE_HEIGHT;
        while (numNodes > 0 && m_firstVisible)
        {
            m_firstVisible = m_firstVisible->PrevNode();
            numNodes--;
        }
    }

	m_dirtyLayout = false;
}
Esempio n. 4
0
void GameView::UpdateCamera()
{
    bool bAnooneAline = false;
    for (Player* p : m_players)
    {
        if (p->IsAlive())
        {
            bAnooneAline = true;
            break;
        }
    }

    if (bAnooneAline)
    {
        // Fit players in view
        Vector2 minPlayer((float)m_pTilemap->getWidth(), (float)m_pTilemap->getHeight());
        Vector2 maxPlayer(0.f);

        for (auto pPlayer : m_players)
        {
            minPlayer.x = onut::min(pPlayer->GetPosition().x, minPlayer.x);
            minPlayer.y = onut::min(pPlayer->GetPosition().y, minPlayer.y);
            maxPlayer.x = onut::max(pPlayer->GetPosition().x, maxPlayer.x);
            maxPlayer.y = onut::max(pPlayer->GetPosition().y, maxPlayer.y);
        }

        minPlayer.x -= 3;
        minPlayer.y -= 3;
        maxPlayer.x += 3;
        maxPlayer.y += 3;

        m_camera = (minPlayer + maxPlayer) * .5f;

        float playerViewHeight = maxPlayer.y - minPlayer.y;
        float zoomH = OScreenHf / playerViewHeight;
        if (zoomH > 64.f) zoomH = 64.f;

        float playerViewWidth = maxPlayer.x - minPlayer.x;
        float zoomW = OScreenWf / playerViewWidth;
        if (zoomW > 64.f) zoomW = 64.f;

        m_zoom = onut::min(zoomW, zoomH);
    }

    // Animate to target position
    m_cameraReal = Vector2::Lerp(m_cameraReal, m_camera, ODT * 1.5f);
    m_zoomReal = lerpf(m_zoomReal, m_zoom, ODT * 4.f);

    // Update camera based on the players position
    GetRootNode()->SetScale(Vector2(m_zoomReal));
    GetRootNode()->SetPosition(-m_cameraReal * m_zoomReal + OScreenf * .5f);
}
Esempio n. 5
0
void CTreeWnd::SetFirstVisibleNode()
{
	m_firstVisibleIdx = 0;

	int index = GetScrollPos32(SB_VERT);

    CTreeNode* pNode = GetRootNode();
	if (!pNode)
		return;

	if (!(m_style & MTS_SHOWROOT))
		pNode = pNode->FirstChild();

	m_firstVisible = pNode;

	int pos = 0;
	while (pNode && pos < index)
	{
		pos ++;//= DEF_NODE_HEIGHT;
		pNode = pNode->NextNode();
		if (pNode)
		{
			m_firstVisible = pNode;
			m_firstVisibleIdx++;
		}
	}
}
Esempio n. 6
0
void RadialPlot::RefreshTree(void const *startNode, int _maxLevel, int _maxValue)
{
	if (!startNode)
		startNode = GetRootNode();

	if (!startNode)
		return;

	numItems = 0;

	maxLevel = _maxLevel;

	autoLevel = !maxLevel;

	maxValue  = _maxValue;

	unsigned int val = GetValue(startNode);


	if (!val)
		val = 1;

	if (val > maxValue)
	{
		maxValue = val;
	}

	ScanTree(startNode, 0, 0, M_PI * 2 * val / maxValue);
}
void SDetailsViewBase::UpdateFilteredDetails()
{
	auto RootPropertyNode = GetRootNode();
	if (RootPropertyNode.IsValid())
	{
		RootPropertyNode->FilterNodes(CurrentFilter.FilterStrings);
		RootPropertyNode->ProcessSeenFlags(true);

		for (int32 NodeIndex = 0; NodeIndex < ExternalRootPropertyNodes.Num(); ++NodeIndex)
		{
			TSharedPtr<FPropertyNode> PropertyNode = ExternalRootPropertyNodes[NodeIndex].Pin();

			if (PropertyNode.IsValid())
			{
				PropertyNode->FilterNodes(CurrentFilter.FilterStrings);
				PropertyNode->ProcessSeenFlags(true);
			}
		}

		if (DetailLayout.IsValid())
		{
			DetailLayout->FilterDetailLayout(CurrentFilter);
		}

		RootTreeNodes = DetailLayout->GetRootTreeNodes();
	}

	RefreshTree();
}
void SDetailsViewBase::RestoreExpandedItems(TSharedPtr<FPropertyNode> InitialStartNode)
{
	auto RootPropertyNode = GetRootNode();
	check(RootPropertyNode.IsValid());
	TSharedPtr<FPropertyNode> StartNode = InitialStartNode;
	if (!StartNode.IsValid())
	{
		StartNode = RootPropertyNode;
	}

	ExpandedDetailNodes.Empty();

	TArray<FString> ExpandedPropertyItems;
	FString ExpandedCustomItems;
	UStruct* BestBaseStruct = RootPropertyNode->GetBaseStructure();
	//while a valid class, and we're either the same as the base class (for multiple actors being selected and base class is AActor) OR we're not down to AActor yet)
	for (UStruct* Struct = BestBaseStruct; Struct && ((BestBaseStruct == Struct) || (Struct != AActor::StaticClass())); Struct = Struct->GetSuperStruct())
	{
		GConfig->GetSingleLineArray(TEXT("DetailPropertyExpansion"), *Struct->GetName(), ExpandedPropertyItems, GEditorPerProjectIni);
		SetExpandedItems(StartNode, ExpandedPropertyItems);
	}

	if (BestBaseStruct)
	{
		GConfig->GetString(TEXT("DetailCustomWidgetExpansion"), *BestBaseStruct->GetName(), ExpandedCustomItems, GEditorPerProjectIni);
		TArray<FString> ExpandedCustomItemsArray;
		ExpandedCustomItems.ParseIntoArray(ExpandedCustomItemsArray, TEXT(","), true);

		ExpandedDetailNodes.Append(ExpandedCustomItemsArray);
	}
}
void SDetailsViewBase::UpdatePropertyMap()
{
	// Reset everything
	ClassToPropertyMap.Empty();
	ClassesWithProperties.Empty();

	// We need to be able to create a new detail layout and properly clean up the old one in the process
	check(!DetailLayout.IsValid() || DetailLayout.IsUnique());

	RootTreeNodes.Empty();

	DetailLayout = MakeShareable(new FDetailLayoutBuilderImpl(ClassToPropertyMap, PropertyUtilities.ToSharedRef(), SharedThis(this)));


	auto RootPropertyNode = GetRootNode();
	check(RootPropertyNode.IsValid());
	// Currently object property nodes do not provide any useful information other than being a container for its children.  We do not draw anything for them.
	// When we encounter object property nodes, add their children instead of adding them to the tree.
	UpdatePropertyMapRecursive(*RootPropertyNode, *DetailLayout, NAME_None, RootPropertyNode.Get());

	CustomUpdatePropertyMap();

	// Ask for custom detail layouts, unless disabled. One reason for disabling custom layouts is that the custom layouts
	// inhibit our ability to find a single property's tree node. This is problematic for the diff and merge tools, that need
	// to display and highlight each changed property for the user. We could whitelist 'good' customizations here if 
	// we can make them work with the diff/merge tools.
	if( !bDisableCustomDetailLayouts )
	{
		QueryCustomDetailLayout(*DetailLayout);
	}
	
	DetailLayout->GenerateDetailLayout();

	UpdateFilteredDetails();
}
void
PhraseDictionaryMemory::
GetTargetPhraseCollectionBatch(const InputPathList &inputPathQueue) const
{
  InputPathList::const_iterator iter;
  for (iter = inputPathQueue.begin(); iter != inputPathQueue.end(); ++iter) {
    InputPath &node = **iter;
    const Phrase &phrase = node.GetPhrase();
    const InputPath *prevPath = node.GetPrevPath();

    const PhraseDictionaryNodeMemory *prevPtNode = NULL;

    if (prevPath) {
      prevPtNode = static_cast<const PhraseDictionaryNodeMemory*>(prevPath->GetPtNode(*this));
    } else {
      // Starting subphrase.
      assert(phrase.GetSize() == 1);
      prevPtNode = &GetRootNode();
    }

    if (prevPtNode) {
      Word lastWord = phrase.GetWord(phrase.GetSize() - 1);
      lastWord.OnlyTheseFactors(m_inputFactors);

      const PhraseDictionaryNodeMemory *ptNode = prevPtNode->GetChild(lastWord);
      if (ptNode) {
        const TargetPhraseCollection &targetPhrases = ptNode->GetTargetPhraseCollection();
        node.SetTargetPhrases(*this, &targetPhrases, ptNode);
      } else {
        node.SetTargetPhrases(*this, NULL, NULL);
      }
    }
  }
}
Esempio n. 11
0
nsresult nsWebBrowserFind::SetRangeAroundDocument(nsIDOMRange* aSearchRange,
                                                  nsIDOMRange* aStartPt,
                                                  nsIDOMRange* aEndPt,
                                                  nsIDOMDocument* aDoc)
{
    nsCOMPtr<nsIDOMNode> bodyNode;
    nsresult rv = GetRootNode(aDoc, getter_AddRefs(bodyNode));
    nsCOMPtr<nsIContent> bodyContent (do_QueryInterface(bodyNode));
    NS_ENSURE_SUCCESS(rv, rv);
    NS_ENSURE_ARG_POINTER(bodyContent);

    uint32_t childCount = bodyContent->GetChildCount();

    aSearchRange->SetStart(bodyNode, 0);
    aSearchRange->SetEnd(bodyNode, childCount);

    if (mFindBackwards)
    {
        aStartPt->SetStart(bodyNode, childCount);
        aStartPt->SetEnd(bodyNode, childCount);
        aEndPt->SetStart(bodyNode, 0);
        aEndPt->SetEnd(bodyNode, 0);
    }
    else
    {
        aStartPt->SetStart(bodyNode, 0);
        aStartPt->SetEnd(bodyNode, 0);
        aEndPt->SetStart(bodyNode, childCount);
        aEndPt->SetEnd(bodyNode, childCount);
    }

    return NS_OK;
}
Esempio n. 12
0
long CTreeWnd::GetScrollExtent(int nBar)
{
    int extent = 0;
    if (nBar == SB_HORZ)
    {
        for (int i = 0; i < m_pHeader->GetNumPanes(); i++)
        {
            extent	+= m_pHeader->GetPaneWidth(i);
        }
    }
    else if (nBar == SB_VERT)
    {
        // vertical scroll size is total height of all expanded nodes...
		CTreeNode* pNode = GetRootNode();
        if (pNode && (!(m_style & MTS_SHOWROOT)))
            pNode = pNode->FirstChild();
        
		bool done = false;
		while (pNode && !done)
        {
			//extent += DEF_NODE_HEIGHT;
			extent++;

			CTreeNode* pNext = pNode->NextNode();
			if (pNext == pNode)
				done = true;
			else
				pNode = pNext;
        }
    }

	return extent;
}
Esempio n. 13
0
void SGP_MaxInterface::GetNodeTree( INode* pNode )
{
	if( pNode == NULL )
	{
		pNode = GetRootNode();
	}
	if( !pNode )
		return;
	if( pNode != GetRootNode() )
		m_vectorNode.add( pNode );

	for (int i = 0; i < pNode->NumberOfChildren(); i++) 
	{
		GetNodeTree( pNode->GetChildNode( i ) );
	}
}
Esempio n. 14
0
void Tree<N>::CollapseNodes(float support)
{
	std::queue<N*> queue;
	std::vector<N*> children = GetRootNode()->GetChildren();
	foreach(N* child, children)
	{
		queue.push(child);
	}
Esempio n. 15
0
NS_IMETHODIMP
inDOMView::Rebuild()
{
  nsCOMPtr<nsIDOMNode> root;
  GetRootNode(getter_AddRefs(root));
  SetRootNode(root);
  return NS_OK;
}
// ****************************************************************************
// Method: AccessViewerSession::WriteConfigFile
//
// Purpose: 
//   Writes the modified data tree to a session file.
//
// Arguments:
//   filename : The name of the file to write.
//
// Programmer: Brad Whitlock
// Creation:   Mon Nov 13 15:45:25 PST 2006
//
// Modifications:
//   
// ****************************************************************************
bool
AccessViewerSession::WriteConfigFile(std::ostream& out)
{
    // Write the output file to stdout for now.
    out << "<?xml version=\"1.0\"?>\n";
    WriteObject(out, GetRootNode());

    return true;
}
// ****************************************************************************
// Method: AccessViewerSession::ReadConfigFile
//
// Purpose: 
//   Reads the session file and stores it internally.
//
// Arguments:
//   filename : The name of the session file to open.
//
// Returns:    A pointer to the root data node or 0.
//
// Programmer: Brad Whitlock
// Creation:   Mon Nov 13 15:44:26 PST 2006
//
// Modifications:
//   Brad Whitlock, Tue Apr 22 12:19:30 PDT 2008
//   Skip the XML tag.
//
// ****************************************************************************
DataNode *
AccessViewerSession::ReadConfigFile(std::istream& in)
{
    // Skip the XML tag
    FinishTag(in);

    root = new DataNode("root");
    ReadObject(in, root);

    return GetRootNode();
}
Esempio n. 18
0
void SceneManager3D::Render( tRendererType *renderer )
{
	assert( renderer );

	renderer->SetViewport( &GetCamera()->GetViewport() );
	renderer->BeginFrame();
	
	RenderVisitor<tRendererType> visitor;
	visitor.SetRenderer( renderer );
	visitor.SetCamera( GetCamera() );
	visitor.Visit( GetRootNode() );

	renderer->EndFrame();
	renderer->SetViewport( NULL );
}
Esempio n. 19
0
bool FXmlFile::Save(const FString& Path)
{
	FString Xml;
	Xml += TEXT("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") LINE_TERMINATOR;

	TArray<const FXmlNode*> NodeStack;
	static const TCHAR Tabs[] = TEXT("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
	auto Indent = &Tabs[ARRAY_COUNT(Tabs) - 1];
	const auto* CurrentNode = GetRootNode();
	while (CurrentNode)
	{
		if (auto Child = CurrentNode->GetFirstChildNode())
		{
			NodeStack.Push(CurrentNode);
			Xml += FString::Printf(TEXT("%s<%s>") LINE_TERMINATOR, Indent, *CurrentNode->GetTag());

			CurrentNode = Child;	
			// Actually increases the indent by one tab
			--Indent;
			continue;
		}

		auto Tag = *CurrentNode->GetTag();
		Xml += FString::Printf(TEXT("%s<%s>%s</%s>") LINE_TERMINATOR, Indent, Tag, *CurrentNode->GetContent(), Tag);
		CurrentNode = CurrentNode->GetNextNode();

		while (!CurrentNode && NodeStack.Num() != 0)
		{
			// Actually decreases the indent by one tab
			++Indent;
			CurrentNode = NodeStack.Pop();
			Xml += FString::Printf(TEXT("%s</%s>") LINE_TERMINATOR, Indent, *CurrentNode->GetTag());
			CurrentNode = CurrentNode->GetNextNode();
		}
	}
	
	TUniquePtr<FArchive> Archive(IFileManager::Get().CreateFileWriter(*Path));
	if (!Archive)
	{
		ErrorMessage = NSLOCTEXT("XmlParser", "FileSaveFail", "Failed to save the file").ToString();
		ErrorMessage += FString::Printf(TEXT("\"%s\""), *Path);
		return false;
	}

	FTCHARToUTF8 Converter(*Xml);
	Archive->Serialize(const_cast<char*>(Converter.Get()), Converter.Length());
	return true;
}
Esempio n. 20
0
int CMapFileIO::SaveMap(const CLevelMap &map, HANDLE hFile) const
{
	XML_MANAGER_HANDLE xml = 0;
	std::wostringstream os;
	xml = CreateWorker();
	if(!xml)
		return 1;
	BeginDoc(xml, L"map");
	XML_NODE_HANDLE root = GetRootNode(xml);
	if(!root)
		return 1;
	XML_NODE_HANDLE node;

	int w, h;
	D3DXVECTOR3 pos;

	//dimensions
	node = AddNode(xml, root, L"dimensions");
	if(!node)
		return 1;
	w = map.GetWidth();
	h = map.GetHeight();
	os << w;
	SetNodeAttr(xml, node, L"width", os.str().c_str());
	os.str(L"");
	os << h;
	SetNodeAttr(xml, node, L"height", os.str().c_str());
	os.str(L"");
	ReleaseNode(node);

	//background
	SaveBackground(*map.GetBackground(), xml, root);

	//player
	SavePlayer( map.GetPlayer(), xml, root );

	//tiles
	SaveTileList(map.m_pTiles, xml, root);

	//creatures
	SaveCreatureList(map.m_pCreatures, xml, root);

	SaveToFileHandle(xml, hFile, true);
	CloseHandle(hFile);
	ReleaseWorker(xml);
	return 0;
}
Esempio n. 21
0
void GameView::OnRender()
{
    if (m_gameover)
        return;

#if defined(_DEBUG)
    auto pFont = OGetBMFont("font.fnt");
    pFont->draw("Time: " + std::to_string(GetDayTimeHour()), Vector2::Zero);
    switch (GetTimeOfDay())
    {
        case TimeOfDay::Night:
            pFont->draw("Night", Vector2(0, 20));
            break;
        case TimeOfDay::Dawn:
            pFont->draw("Dawn", Vector2(0, 20));
            break;
        case TimeOfDay::Day:
            pFont->draw("Day", Vector2(0, 20));
            break;
        case TimeOfDay::Dusk:
            pFont->draw("Dusk", Vector2(0, 20));
            break;
    }
    pFont->draw("Monster spawn Rate: " + std::to_string(GetMonsterSpawnRate()), Vector2(0, 40));
    pFont->draw("Monster count: " + std::to_string(Monster::count), Vector2(0, 60));
    pFont->draw("Day: " + std::to_string(m_day), Vector2(0, 80));

#if 0 // Show path
    OSB->end();
    for (auto pEntity : m_entities)
    {
        auto pMonster = dynamic_cast<Monster*>(pEntity);
        if (pMonster)
        {
            OPB->begin(onut::ePrimitiveType::LINE_STRIP, nullptr, GetRootNode()->GetTransform());
            for (auto& p : pMonster->m_path)
            {
                OPB->draw(p);
            }
            OPB->end();
        }
    }
    OSB->begin();
#endif
#endif
}
Esempio n. 22
0
/*
	 Function name		: CXML::LoadFile
	 Description	    : This function load the given XML file using
						  m_pXMLDoc object. 	
	 Return type		: bool 
	 Argument			: LPCTSTR lpszXmlFile
	 Tested				: Ok
 */	
bool CXML::LoadFile(LPCTSTR lpszXmlFile)
{
	if (!lpszXmlFile || !m_pXMLDoc)
		return false;

	m_csXmlFileName = lpszXmlFile;
	long lXmlSate = 0;
	
	_variant_t vtFileName(m_csXmlFileName);
   
	VARIANT_BOOL vSuccess;
	m_hr = m_pXMLDoc->load(vtFileName,&vSuccess);

	if(!SUCCEEDED(m_hr) || vSuccess == FALSE)
	{
		return FALSE;
	}

	m_hr = m_pXMLDoc->get_readyState(&lXmlSate);
    if(SUCCEEDED(m_hr) && lXmlSate == 4)
	{	

		m_hr = m_pXMLDoc->get_documentElement(&m_pIRootElement);
		if(SUCCEEDED(m_hr) == 0)
			return false;

		BSTR bstrTagName;
		m_pIRootElement->get_tagName(&bstrTagName);
		CString csRootTag = bstrTagName;


		SysFreeString(bstrTagName);

		if(GetRootNode(csRootTag))
		{
			m_pICurrentNode = m_pIRootNode;
			m_pICurrentNode->AddRef();
		}
		else
			return false;
	}
	else
		return false;

	return true;
}
Esempio n. 23
0
/*
	 Function name		: CXML::LoadString
	 Description	    : This function load the given XML String using
						  m_pXMLDoc object. 	
	 Return type		: bool 
	 Argument			: LPCTSTR lpszXmlFile
	 Tested				: Ok
 */	
bool CXML::LoadString(LPCTSTR lpszXmlString)
{
	if (!lpszXmlString || !m_pXMLDoc)
		return false;
	
	_bstr_t bstrXMLString(lpszXmlString);
	long lXmlSate = 0;
   
	VARIANT_BOOL vSuccess;
	m_hr = m_pXMLDoc->loadXML(bstrXMLString,&vSuccess);


	if(!SUCCEEDED(m_hr) || vSuccess == FALSE)
	{
		return FALSE;
	}

	m_hr = m_pXMLDoc->get_readyState(&lXmlSate);
    if(SUCCEEDED(m_hr) && lXmlSate == 4)
	{	
		m_hr = m_pXMLDoc->get_documentElement(&m_pIRootElement);
		if(!SUCCEEDED(m_hr))
			return false;

		BSTR bstrTagName;
		m_pIRootElement->get_tagName(&bstrTagName);
		CString csRootTag;

		csRootTag = bstrTagName;
		SysFreeString(bstrTagName);

		if(GetRootNode(csRootTag))
		{
			m_pICurrentNode = m_pIRootNode;
			m_pICurrentNode->AddRef();
		}
		else
				return false;
	}
	else
		return false;

	return true;
}
bool THISCLASS::Open(const wxFileName &filename) {
	// Read the file
	wxLogNull log;
	mIsOpen = mDocument.Load(filename.GetFullPath());
	if (! mIsOpen) {
		mDocument.SetRoot(new wxXmlNode(0, wxXML_ELEMENT_NODE, wxT("swistrack")));
		SelectRootNode();
		return false;
	}

	// Select the root element and check its name
	SetRootNode(mDocument.GetRoot());
	if (GetRootNode()->GetName() != wxT("swistrack")) {
		mIsOpen = false;
		return false;
	}

	return true;
}
Esempio n. 25
0
bool FXmlFile::Save(const FString& Path)
{
	FString Xml = TEXT("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") LINE_TERMINATOR;

	const FXmlNode* CurrentNode = GetRootNode();
	if(CurrentNode != nullptr)
	{
		WriteNodeHierarchy(*CurrentNode, FString(), Xml);
	}
	
	TUniquePtr<FArchive> Archive(IFileManager::Get().CreateFileWriter(*Path));
	if (!Archive)
	{
		ErrorMessage = NSLOCTEXT("XmlParser", "FileSaveFail", "Failed to save the file").ToString();
		ErrorMessage += FString::Printf(TEXT("\"%s\""), *Path);
		return false;
	}

	FTCHARToUTF8 Converter(*Xml);
	Archive->Serialize(const_cast<char*>(Converter.Get()), Converter.Length());
	return true;
}
Esempio n. 26
0
bool PhantomTree::SetFirstPhantomNodeToPhoton(SharedFlyingPhotonPtr &photon)
{

  SharedPhantomNodePtr root =GetRootNode();

  if( root.get()->IsInside( photon->GetCurrentPosition() ) ){ //Start Inside of Tree
  
    return SetCurrentChildrenNodeToPhoton(root, photon);

  }else{ //Start Outside of Tree
    
    double t0;    
    if( !root.get()->GetForwardNodeRayParameter( photon->GetPhotonRay(1.0), t0) ){
      return false;
    }//not captured

    photon->MoveForwardByRayParameter(t0);
    photon->SetCurrentPhantomNode(root);
    return true;

  }
  return false;
}
static void ParseListResults(const TArray<FXmlFile>& ResultsXml, TArray< TSharedRef<FSubversionSourceControlLabel> >& OutLabels)
{
	static const FString Lists(TEXT("lists"));
	static const FString List(TEXT("list"));
	static const FString Path(TEXT("path"));
	static const FString Entry(TEXT("entry"));
	static const FString Kind(TEXT("kind"));
	static const FString Dir(TEXT("dir"));
	static const FString Name(TEXT("name"));
	static const FString Commit(TEXT("commit"));
	static const FString Revision(TEXT("revision"));

	for(auto ResultIt(ResultsXml.CreateConstIterator()); ResultIt; ResultIt++)
	{
		const FXmlNode* ListsNode = ResultIt->GetRootNode();
		if(ListsNode != NULL && ListsNode->GetTag() == Lists)
		{ 
			const TArray<FXmlNode*> ListsChildren = ListsNode->GetChildrenNodes();
			for(auto ListIter(ListsChildren.CreateConstIterator()); ListIter; ListIter++)
			{
				const FXmlNode* ListNode = *ListIter;
				if(ListNode == NULL || ListNode->GetTag() != List)
				{
					continue;
				}

				FString DirectoryPath = ListNode->GetAttribute(Path);

				const TArray<FXmlNode*> ListChildren = ListNode->GetChildrenNodes();
				for(auto EntryIter(ListChildren.CreateConstIterator()); EntryIter; EntryIter++)
				{
					const FXmlNode* EntryNode = *EntryIter;
					if(EntryNode == NULL || EntryNode->GetTag() != Entry)
					{
						continue;
					}

					if(EntryNode->GetAttribute(Kind) == Dir)
					{
						// find a name & revision for this directory
						const FXmlNode* NameNode = EntryNode->FindChildNode(Name);
						if(NameNode != NULL)
						{
							FString LabelName = NameNode->GetContent();
							if (LabelName.Len() > 0)
							{
								const FXmlNode* CommitNode = EntryNode->FindChildNode(Commit);
								if(CommitNode != NULL)
								{
									FString RevisionString = CommitNode->GetAttribute(Revision);
									if(RevisionString.Len() > 0)
									{
										int RevisionNum = FCString::Atoi(*RevisionString);
										OutLabels.Add(MakeShareable(new FSubversionSourceControlLabel(LabelName, DirectoryPath / LabelName, RevisionNum)));
									}
								}
							}
						}
					}
				}
			}
		}
	}
}
Esempio n. 28
0
// Set the range to go from the end of the current selection to the
// end of the document (forward), or beginning to beginning (reverse).
// or around the whole document if there's no selection.
nsresult
nsWebBrowserFind::GetSearchLimits(nsIDOMRange* aSearchRange,
                                  nsIDOMRange* aStartPt,
                                  nsIDOMRange* aEndPt,
                                  nsIDOMDocument* aDoc,
                                  nsISelection* aSel,
                                  bool aWrap)
{
    NS_ENSURE_ARG_POINTER(aSel);

    // There is a selection.
    int32_t count = -1;
    nsresult rv = aSel->GetRangeCount(&count);
    NS_ENSURE_SUCCESS(rv, rv);
    if (count < 1)
        return SetRangeAroundDocument(aSearchRange, aStartPt, aEndPt, aDoc);

    // Need bodyNode, for the start/end of the document
    nsCOMPtr<nsIDOMNode> bodyNode;
    rv = GetRootNode(aDoc, getter_AddRefs(bodyNode));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIContent> bodyContent (do_QueryInterface(bodyNode));
    NS_ENSURE_ARG_POINTER(bodyContent);

    uint32_t childCount = bodyContent->GetChildCount();

    // There are four possible range endpoints we might use:
    // DocumentStart, SelectionStart, SelectionEnd, DocumentEnd.

    nsCOMPtr<nsIDOMRange> range;
    nsCOMPtr<nsIDOMNode> node;
    int32_t offset;

    // Forward, not wrapping: SelEnd to DocEnd
    if (!mFindBackwards && !aWrap)
    {
        // This isn't quite right, since the selection's ranges aren't
        // necessarily in order; but they usually will be.
        aSel->GetRangeAt(count-1, getter_AddRefs(range));
        if (!range) return NS_ERROR_UNEXPECTED;
        range->GetEndContainer(getter_AddRefs(node));
        if (!node) return NS_ERROR_UNEXPECTED;
        range->GetEndOffset(&offset);

        aSearchRange->SetStart(node, offset);
        aSearchRange->SetEnd(bodyNode, childCount);
        aStartPt->SetStart(node, offset);
        aStartPt->SetEnd(node, offset);
        aEndPt->SetStart(bodyNode, childCount);
        aEndPt->SetEnd(bodyNode, childCount);
    }
    // Backward, not wrapping: DocStart to SelStart
    else if (mFindBackwards && !aWrap)
    {
        aSel->GetRangeAt(0, getter_AddRefs(range));
        if (!range) return NS_ERROR_UNEXPECTED;
        range->GetStartContainer(getter_AddRefs(node));
        if (!node) return NS_ERROR_UNEXPECTED;
        range->GetStartOffset(&offset);

        aSearchRange->SetStart(bodyNode, 0);
        aSearchRange->SetEnd(bodyNode, childCount);
        aStartPt->SetStart(node, offset);
        aStartPt->SetEnd(node, offset);
        aEndPt->SetStart(bodyNode, 0);
        aEndPt->SetEnd(bodyNode, 0);
    }
    // Forward, wrapping: DocStart to SelEnd
    else if (!mFindBackwards && aWrap)
    {
        aSel->GetRangeAt(count-1, getter_AddRefs(range));
        if (!range) return NS_ERROR_UNEXPECTED;
        range->GetEndContainer(getter_AddRefs(node));
        if (!node) return NS_ERROR_UNEXPECTED;
        range->GetEndOffset(&offset);

        aSearchRange->SetStart(bodyNode, 0);
        aSearchRange->SetEnd(bodyNode, childCount);
        aStartPt->SetStart(bodyNode, 0);
        aStartPt->SetEnd(bodyNode, 0);
        aEndPt->SetStart(node, offset);
        aEndPt->SetEnd(node, offset);
    }
    // Backward, wrapping: SelStart to DocEnd
    else if (mFindBackwards && aWrap)
    {
        aSel->GetRangeAt(0, getter_AddRefs(range));
        if (!range) return NS_ERROR_UNEXPECTED;
        range->GetStartContainer(getter_AddRefs(node));
        if (!node) return NS_ERROR_UNEXPECTED;
        range->GetStartOffset(&offset);

        aSearchRange->SetStart(bodyNode, 0);
        aSearchRange->SetEnd(bodyNode, childCount);
        aStartPt->SetStart(bodyNode, childCount);
        aStartPt->SetEnd(bodyNode, childCount);
        aEndPt->SetStart(node, offset);
        aEndPt->SetEnd(node, offset);
    }
    return NS_OK;
}
THISCLASS::ConfigurationWriterXML():
		ConfigurationXML(new wxXmlNode(0, wxXML_ELEMENT_NODE, wxT("swistrack")), false), mErrorList(), mDocument() {

	mDocument.SetRoot(GetRootNode());
}
Esempio n. 30
0
int _tmain(int argc, _TCHAR* argv [])
{
	std::cout << "usage : FbxRerouteSkeleton.exe /m:<origin mesh and skeleton data.fbx> /m:<other origin mesh and skeleton data.fbx> /a:<animated skeleton.fbx> /o:<output fbx> [/prefix:<prefix added to each bone in animated skeleton.fbx>]" << std::endl;
	std::vector<std::string> meshFiles;
	std::string skeletonFile;
	std::string outputPath;
	std::string prefix;
	for (auto ix = 1; ix < argc; ++ix){
		std::wstring warg = argv[ix];
		if (warg.find(L"/m:") == 0){
			meshFiles.push_back(wstringToUtf8(warg.substr(3)));
		}
		else if (warg.find(L"/a:") == 0)
		{
			if (skeletonFile.size()>0){

				std::wcout << L"only one animated skeleton file is allowed" << std::endl;
				return -2;
			}
			skeletonFile = wstringToUtf8(warg.substr(3));
		}
		else if (warg.find(L"/o:") == 0){
			if (outputPath.size() > 0){

				std::wcout << L"only one output file is allowed" << std::endl;
				return -3;
			}

			CloseHandle(CreateFile(warg.substr(3).c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, nullptr));
			outputPath = wstringToUtf8(warg.substr(3));
		}
		else if (warg.find(L"/prefix:") == 0){
			if (prefix.size() > 0){

				std::wcout << L"only one prefix is allowed" << std::endl;
				return -4;
			}
			prefix = wstringToUtf8(warg.substr(8));
		}
		else{
			std::wcout << L"unrecognized parameter " << warg << std::endl;
			return -1;
		}
	}
	if (meshFiles.size() == 0){

		std::wcout << L"no origin mesh file" << std::endl;
		return -5;
	}
	if (skeletonFile.size() == 0){

		std::wcout << L"skeleton file unspecified" << std::endl;
		return -6;
	}
	if (outputPath.size() == 0){

		std::wcout << L"output file unspecified" << std::endl;
		return -7;
	}

	auto fbxManager = std::unique_ptr<FbxManager, FbxManagerDeleter>( FbxManager::Create());
	auto iosettings = std::unique_ptr<FbxIOSettings, FbxDeleter>(FbxIOSettings::Create(fbxManager.get(), IOSROOT));

	iosettings->SetBoolProp(IMP_FBX_MATERIAL, true);
	iosettings->SetBoolProp(IMP_FBX_TEXTURE, true);
	iosettings->SetBoolProp(IMP_FBX_LINK, true);
	iosettings->SetBoolProp(IMP_FBX_SHAPE, true);
	iosettings->SetBoolProp(IMP_FBX_GOBO, true);
	iosettings->SetBoolProp(IMP_FBX_ANIMATION, true);
	iosettings->SetBoolProp(IMP_SKINS, true);
	iosettings->SetBoolProp(IMP_DEFORMATION, true);
	iosettings->SetBoolProp(IMP_FBX_GLOBAL_SETTINGS, true);
	iosettings->SetBoolProp(IMP_TAKE, true);


	iosettings->SetBoolProp(EXP_FBX_MATERIAL, true);
	iosettings->SetBoolProp(EXP_FBX_TEXTURE, true);
	iosettings->SetBoolProp(EXP_MESHPOLY, true);
	iosettings->SetBoolProp(EXP_FBX_SHAPE, true);
	iosettings->SetBoolProp(EXP_FBX_GOBO, true);
	iosettings->SetBoolProp(EXP_FBX_ANIMATION, true);
	iosettings->SetBoolProp(EXP_SKINS, true);
	iosettings->SetBoolProp(EXP_DEFORMATION, true);
	iosettings->SetBoolProp(EXP_FBX_GLOBAL_SETTINGS, true);
	iosettings->SetBoolProp(EXP_MESHTRIANGLE, true);
	iosettings->SetBoolProp(EXP_EMBEDTEXTURE, true);
	fbxManager->SetIOSettings(iosettings.get());

	auto importer = std::unique_ptr<FbxImporter, FbxDeleter> (FbxImporter::Create(fbxManager.get(), "SceneImporter"));
	importer->Initialize(skeletonFile.c_str(), -1, iosettings.get());
	auto globalScene = std::unique_ptr<FbxScene, FbxDeleter>(FbxScene::Create(fbxManager.get(), "merged scene"));
	importer->Import(globalScene.get());

	std::map<std::string, FbxNode*> animatedSkeletonNodesMap;
	populateNodeMap(animatedSkeletonNodesMap, globalScene->GetRootNode());

	for (auto& f : meshFiles){
		importAdditionalFile(globalScene.get(), importer.get(), f);
	}

	patchSkins(globalScene->GetRootNode(), animatedSkeletonNodesMap, prefix);

	auto exporter = std::unique_ptr<FbxExporter, FbxDeleter>(FbxExporter::Create(fbxManager.get(), "SceneExporter"));
	auto res = exporter->Initialize(outputPath.c_str(), -1, iosettings.get());
	res = exporter->Export(globalScene.get());
	auto status = exporter->GetStatus();

	return 0;
}