CString& agnes_article::get_inside(const CString& root, const CString& archive, bool bTar){ if (got_inside.StrLength()) return (got_inside); #ifdef ANSI if (bTar) agnes_article_detar(root, archive); #endif CString lRoot(root); if (archive.StrLength()) { lRoot+=archive; lRoot.append_backslash(); } lRoot += article_node(); nextgen_v2 a_inside(lRoot); if (a_inside.contained.StrLength()) { int DelimPos = a_inside.contained.isSubStr('\0'); if (DelimPos >= 0) { got_inside = a_inside.contained.Copy(0, DelimPos); } else got_inside = a_inside.contained; } return(got_inside); }
BOOL CBrowseTreeCtrl::CleanItems(CBrowseTreeItem* pItem, DWORD nCookie, BOOL bVisible) { CSingleLock lRoot( &m_csRoot, TRUE ); CBrowseTreeItem** pChild = pItem->m_pList + pItem->m_nCount - 1; BOOL bChanged = FALSE; for ( int nChild = pItem->m_nCount ; nChild ; nChild--, pChild-- ) { if ( (*pChild)->m_nCleanCookie != nCookie ) { if ( m_pFocus == *pChild ) m_pFocus = NULL; if ( (*pChild)->m_bSelected ) Select( *pChild, TS_FALSE, FALSE ); bChanged |= DeselectAll( NULL, *pChild, FALSE ); if ( bVisible ) { m_nTotal -= (*pChild)->GetChildCount() + 1; bChanged = TRUE; } delete *pChild; MoveMemory( pChild, pChild + 1, 4 * ( pItem->m_nCount - nChild ) ); pItem->m_nCount--; } } return bChanged; }
void agnes_article::write_contents(const CString& root, const CString& article_contents){ CString lRoot(root); lRoot+=article_node(); ofstream container_file(lRoot.asString(), ios::out | ios::trunc, filebuf::openprot); container_file << article_contents; container_file << '\0'; article_descriptor(& container_file); }
Classification_t classify(const parsenode& aNode) { DeweyClassification lVisitor; aNode.accept(lVisitor); unique_ptr<Node> lRoot(lVisitor.getRoot()); if(lRoot.get() != 0) { lRoot->accept(&lVisitor); } return lVisitor.getClassification(); }
void CBrowseTreeCtrl::OnTreePacket(CG2Packet* pPacket) { CSingleLock lRoot( &m_csRoot, TRUE ); Clear( FALSE ); pPacket->Seek( 0 ); OnTreePacket( pPacket, pPacket->m_nLength, m_pRoot ); m_nTotal = m_pRoot->GetChildCount(); Invalidate(); }
void CBrowseTreeCtrl::ScrollTo(int nPosition) { CSingleLock lRoot( &m_csRoot, TRUE ); if ( nPosition == m_nScroll ) return; m_nScroll = nPosition; UpdateScroll(); CRect rc; GetClientRect( &rc ); RedrawWindow( &rc, NULL, RDW_INVALIDATE ); }
void CBrowseTreeCtrl::UpdateScroll() { CSingleLock lRoot( &m_csRoot, TRUE ); SCROLLINFO pInfo; pInfo.cbSize = sizeof(pInfo); pInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE; pInfo.nMin = 0; pInfo.nMax = m_nTotal * ITEM_HEIGHT; pInfo.nPage = m_nVisible; pInfo.nPos = m_nScroll = max( 0, min( m_nScroll, pInfo.nMax - (int)pInfo.nPage + 1 ) ); SetScrollInfo( SB_VERT, &pInfo, IsWindowVisible() ); }
BOOL CBrowseTreeCtrl::Expand(CBrowseTreeItem* pItem, TRISTATE bExpand, BOOL bInvalidate) { CSingleLock lRoot( &m_csRoot, TRUE ); if ( pItem == NULL ) return FALSE; switch ( bExpand ) { case TS_UNKNOWN: pItem->m_bExpanded = ! pItem->m_bExpanded; break; case TS_TRUE: if ( pItem->m_bExpanded ) return FALSE; pItem->m_bExpanded = TRUE; break; case TS_FALSE: if ( ! pItem->m_bExpanded ) return FALSE; pItem->m_bExpanded = FALSE; break; } if ( ! pItem->IsVisible() ) return FALSE; if ( pItem->m_bExpanded ) { m_nTotal += pItem->GetChildCount(); } else { m_nTotal -= pItem->GetChildCount(); DeselectAll( NULL, pItem, FALSE ); } pItem->m_bContract1 = pItem->m_bExpanded == TRUE && bExpand == TS_TRUE && bInvalidate == FALSE; if ( pItem->m_bContract1 == FALSE ) { for ( CBrowseTreeItem* pParent = pItem ; pParent != NULL ; pParent = pParent->m_pParent ) pParent->m_bContract1 = FALSE; } if ( bInvalidate ) { UpdateScroll(); Invalidate(); } return TRUE; }
void CBrowseTreeCtrl::OnLButtonDblClk(UINT nFlags, CPoint point) { CSingleLock lRoot( &m_csRoot, TRUE ); OnLButtonDown( nFlags, point ); if ( m_pFocus != NULL && m_pFocus->m_nCount ) { if ( Expand( m_pFocus, TS_UNKNOWN ) ) { lRoot.Unlock(); NotifySelection(); } } }
BOOL CBrowseTreeCtrl::GetRect(CBrowseTreeItem* pItem, RECT* pRect) { CSingleLock lRoot( &m_csRoot, TRUE ); CRect rcClient; GetClientRect( &rcClient ); CPoint pt( rcClient.left, rcClient.top - m_nScroll ); CBrowseTreeItem** pChild = m_pRoot->m_pList; for ( int nCount = m_pRoot->m_nCount ; nCount ; nCount--, pChild++ ) { if ( GetRect( pt, *pChild, pItem, pRect ) ) return TRUE; } return FALSE; }
BOOL CBrowseTreeCtrl::CollapseRecursive(CBrowseTreeItem* pItem) { CSingleLock lRoot( &m_csRoot, TRUE ); BOOL bChanged = FALSE; if ( pItem != m_pRoot && pItem->m_bExpanded && pItem->m_bContract1 ) { bChanged |= Expand( pItem, TS_FALSE, FALSE ); } CBrowseTreeItem** pChild = pItem->m_pList; for ( int nCount = pItem->m_nCount ; nCount ; nCount--, pChild++ ) { bChanged |= CollapseRecursive( *pChild ); } return bChanged; }
CBrowseTreeItem* CBrowseTreeCtrl::HitTest(const POINT& point, RECT* pRect) const { CSingleLock lRoot( (CCriticalSection*)&m_csRoot, TRUE ); CRect rcClient; GetClientRect( &rcClient ); CPoint pt( rcClient.left, rcClient.top - m_nScroll ); CBrowseTreeItem** pChild = m_pRoot->m_pList; for ( int nCount = m_pRoot->m_nCount ; nCount && pt.y < rcClient.bottom ; nCount--, pChild++ ) { CBrowseTreeItem* pItem = HitTest( rcClient, pt, *pChild, point, pRect ); if ( pItem ) return pItem; } return NULL; }
void CBrowseTreeCtrl::Clear(BOOL bGUI) { CSingleLock lRoot( &m_csRoot, TRUE ); if ( m_pRoot->m_nCount == 0 ) return; m_pRoot->Clear(); m_nTotal = 0; m_nSelected = 0; m_pSelFirst = NULL; m_pSelLast = NULL; m_pFocus = NULL; if ( bGUI ) { UpdateScroll(); Invalidate(); } }
BOOL CBrowseTreeCtrl::Highlight(CBrowseTreeItem* pItem) { CSingleLock lRoot( &m_csRoot, TRUE ); m_pFocus = pItem; for ( CBrowseTreeItem* pParent = m_pFocus->m_pParent ; pParent ; pParent = pParent->m_pParent ) { Expand( pParent, TS_TRUE, FALSE ); pParent->m_bContract2 = pParent->m_bContract1; pParent->m_bContract1 = FALSE; } CollapseRecursive( m_pRoot ); for ( CBrowseTreeItem* pParent = m_pFocus->m_pParent ; pParent ; pParent = pParent->m_pParent ) { pParent->m_bContract1 = pParent->m_bContract2; } CRect rcItem, rcClient; if ( GetRect( m_pFocus, &rcItem ) ) { GetClientRect( &rcClient ); if ( rcItem.top <= rcClient.top ) ScrollBy( rcItem.top - rcClient.top ); else if ( rcItem.bottom > rcClient.bottom ) ScrollBy( rcItem.bottom - rcClient.bottom ); } UpdateScroll(); Invalidate(); return TRUE; }
void CBrowseTreeCtrl::OnPaint() { CSingleLock lRoot( &m_csRoot, TRUE ); CPaintDC dc( this ); CRect rcClient; GetClientRect( &rcClient ); CPoint pt( rcClient.left, rcClient.top - m_nScroll ); CBrowseTreeItem** pChild = m_pRoot->m_pList; CFont* pOldFont = (CFont*)dc.SelectObject( &CoolInterface.m_fntNormal ); for ( int nCount = m_pRoot->m_nCount ; nCount && pt.y < rcClient.bottom ; nCount--, pChild++ ) { Paint( dc, rcClient, pt, *pChild ); } dc.SelectObject( pOldFont ); dc.FillSolidRect( &rcClient, CoolInterface.m_crWindow ); }
void CBrowseTreeCtrl::OnLButtonDown(UINT nFlags, CPoint point) { CSingleLock lRoot( &m_csRoot, TRUE ); CRect rc; CBrowseTreeItem* pHit = HitTest( point, &rc ); BOOL bChanged = FALSE; SetFocus(); if ( pHit && pHit->m_nCount && point.x >= rc.left && point.x < rc.left + 16 ) { bChanged = Expand( pHit, TS_UNKNOWN ); } else if ( nFlags & MK_CONTROL ) { if ( pHit ) bChanged = Select( pHit, TS_UNKNOWN ); } else if ( nFlags & MK_SHIFT ) { if ( pHit ) bChanged = Select( pHit ); } else { if ( ( nFlags & MK_RBUTTON ) == 0 || ( pHit && pHit->m_bSelected == FALSE ) ) bChanged = DeselectAll( pHit ); if ( pHit ) bChanged |= Select( pHit ); } if ( pHit ) m_pFocus = pHit; if ( bChanged ) { lRoot.Unlock(); NotifySelection(); } }
BOOL CBrowseTreeCtrl::DeselectAll(CBrowseTreeItem* pExcept, CBrowseTreeItem* pParent, BOOL bInvalidate) { CSingleLock lRoot( &m_csRoot, TRUE ); if ( pParent == NULL ) pParent = m_pRoot; CBrowseTreeItem** pChild = pParent->m_pList; BOOL bChanged = FALSE; for ( int nCount = pParent->m_nCount ; nCount ; nCount--, pChild++ ) { if ( *pChild != pExcept && (*pChild)->m_bSelected ) { Select( *pChild, TS_FALSE, FALSE ); bChanged = TRUE; } if ( (*pChild)->m_nCount ) bChanged |= DeselectAll( pExcept, *pChild, FALSE ); } if ( bInvalidate && bChanged && pParent == m_pRoot ) Invalidate(); return bChanged; }
int main(int argc, char* argv[]) { std::unique_ptr<ExecutionArgs> exArgs(new ExecutionArgs()); if (!processCommandLineArgs(argc, argv, *exArgs)) { return -1; } else if (exArgs->helpPrompt) { std::cout << "Usage: sts [--help] || [--config]" << std::endl; std::cout << "Options:" << std::endl; std::cout << "\t --help - print this message;" << std::endl; std::cout << "\t --config - show config dialog." << std::endl; std::cout << std::endl; return 0; } try { Ogre::String lConfigFileName = "ogre.cfg"; Ogre::String lPluginsFileName = "plugins.cfg"; Ogre::String lLogFileName = "Ogre_STS.log"; std::unique_ptr<Ogre::Root> lRoot(new Ogre::Root(lPluginsFileName, lConfigFileName, lLogFileName)); if (exArgs->showConfigDialog) { if (!lRoot->showConfigDialog()) { return 0; } } Ogre::String lWindowTitle = "STS"; Ogre::String lCustomCapacities = ""; /* Check for the valid ogre.cfg */ bool lCreateAWindowAutomatically = lRoot->restoreConfig(); if (!lCreateAWindowAutomatically) { initSomeRenderSystem(lRoot); } Ogre::RenderWindow* lWindow = lRoot->initialise(lCreateAWindowAutomatically, lWindowTitle, lCustomCapacities); if (!lWindow) { /* ogre.cfg is not available - start with hardcoded parameters */ unsigned int lSizeX = 800; unsigned int lSizeY = 600; bool lFullscreen = false; Ogre::NameValuePairList lParams; lParams["FSAA"] = "0"; lParams["vsync"] = "true"; lWindow = lRoot->createRenderWindow(lWindowTitle, lSizeX, lSizeY, lFullscreen, &lParams); } /* Create a scene manager */ Ogre::SceneManager* lScene = lRoot->createSceneManager(Ogre::ST_GENERIC, "SceneManager"); Ogre::SceneNode* lRootSceneNode = lScene->getRootSceneNode(); /* Create camera */ Ogre::Camera* lCamera = lScene->createCamera("MyCamera"); /* Create viewport (camera <-> window) */ Ogre::Viewport* vp = lWindow->addViewport(lCamera); vp->setAutoUpdated(true); vp->setBackgroundColour(Ogre::ColourValue(1, 0, 1)); lCamera->setAspectRatio(float(vp->getActualWidth()) / vp->getActualHeight()); lCamera->setPosition(Ogre::Vector3(0, 100, -1)); lCamera->lookAt(Ogre::Vector3(0, 0, 0)); /* Set clipping*/ lCamera->setNearClipDistance(1.5f); lCamera->setFarClipDistance(3000.0f); /* Lighting */ Ogre::Light* lLight = lScene->createLight("MainLight"); lLight->setPosition(Ogre::Vector3(0, 100, 0)); /* Resource manager */ Ogre::String lRcGroupName = "Main group"; initResourceMainGroup(lRcGroupName); /* Load model */ Ogre::Entity* lShipEntity = lScene->createEntity("airship.mesh"); lShipEntity->setCastShadows(false); Ogre::SceneNode* lShipNode = lRootSceneNode->createChildSceneNode(); lShipNode->attachObject(lShipEntity); lShipNode->setScale(Ogre::Vector3(3.15f, 3.15f, 3.15f)); /* Starship start point */ Ogre::Vector3 razorSP(0, -200, -100); lShipNode->setPosition(razorSP); /* Sprite billboard */ Ogre::SceneNode* lSpriteNode = lRootSceneNode->createChildSceneNode(); Ogre::BillboardSet* lBillboardSet = lScene->createBillboardSet(); lBillboardSet->setMaterialName("enemy_01", lRcGroupName); lBillboardSet->setTextureStacksAndSlices(1, 4); Ogre::Billboard* lSpriteBillboard = lBillboardSet->createBillboard(Ogre::Vector3(0, 0, 0)); lSpriteBillboard->setDimensions(48.0f / 2.0f, 58.0f / 2.0f); lSpriteBillboard->setTexcoordIndex(1); lSpriteNode->attachObject(lBillboardSet); lSpriteNode->setPosition(Ogre::Vector3(0, -200, 100)); /* Obtain the timer pointer */ Ogre::Timer* lTimer = lRoot->getTimer(); /* Skip all the messages */ lWindow->setAutoUpdated(false); lRoot->clearEventTimes(); while (!lWindow->isClosed()) { float angle = Ogre::Math::Sin(float(lTimer->getMilliseconds()) * Ogre::Math::PI / 2000.0f) * Ogre::Math::PI / 4.0f; float diplacement = Ogre::Math::Cos(float(lTimer->getMilliseconds()) * Ogre::Math::PI / 2000.0f) * 100.0f; lShipNode->setOrientation(Ogre::Quaternion(Ogre::Radian(angle), Ogre::Vector3(0, 0, 1))); lShipNode->setPosition(razorSP + Ogre::Vector3(diplacement, 0.0f, 0.0f)); unsigned int spriteFrame = (lTimer->getMilliseconds() / 125) % 2; lSpriteBillboard->setTexcoordIndex(spriteFrame); lWindow->update(false); lWindow->swapBuffers(); lRoot->renderOneFrame(); Ogre::WindowEventUtilities::messagePump(); } Ogre::LogManager::getSingleton().logMessage("Render window closed."); } catch (Ogre::Exception &e) { std::cerr << "Ogre::Exception: " << e.what() << std::endl; } catch (std::exception &e) { std::cerr << "std::exception: " << e.what() << std::endl; } return 0; }
BOOL CBrowseTreeCtrl::Select(CBrowseTreeItem* pItem, TRISTATE bSelect, BOOL bInvalidate) { CSingleLock lRoot( &m_csRoot, TRUE ); if ( pItem == NULL ) return FALSE; switch ( bSelect ) { case TS_UNKNOWN: pItem->m_bSelected = ! pItem->m_bSelected; break; case TS_TRUE: if ( pItem->m_bSelected ) return FALSE; pItem->m_bSelected = TRUE; break; case TS_FALSE: if ( ! pItem->m_bSelected ) return FALSE; pItem->m_bSelected = FALSE; break; } if ( pItem->m_bSelected ) { m_nSelected++; if ( m_pSelLast ) { m_pSelLast->m_pSelNext = pItem; pItem->m_pSelPrev = m_pSelLast; pItem->m_pSelNext = NULL; m_pSelLast = pItem; } else { m_pSelFirst = m_pSelLast = pItem; pItem->m_pSelPrev = pItem->m_pSelNext = NULL; } } else { m_nSelected--; if ( pItem->m_pSelPrev ) pItem->m_pSelPrev->m_pSelNext = pItem->m_pSelNext; else m_pSelFirst = pItem->m_pSelNext; if ( pItem->m_pSelNext ) pItem->m_pSelNext = pItem->m_pSelNext->m_pSelPrev = pItem->m_pSelPrev; else m_pSelLast = pItem->m_pSelPrev; } if ( pItem->IsVisible() ) { if ( bInvalidate ) Invalidate(); return TRUE; } else { return FALSE; } }
void CBrowseTreeCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { CSingleLock lRoot( &m_csRoot, TRUE ); CBrowseTreeItem* pTo = NULL; BOOL bChanged = FALSE; CRect rc; if ( nChar == VK_HOME || ( nChar == VK_UP && m_pFocus == NULL ) ) { if ( m_pRoot->m_nCount ) pTo = m_pRoot->m_pList[0]; } else if ( nChar == VK_END || ( nChar == VK_DOWN && m_pFocus == NULL ) ) { if ( m_pRoot->m_nCount ) pTo = m_pRoot->m_pList[ m_pRoot->m_nCount - 1 ]; } else if ( nChar == VK_UP && m_pFocus != NULL ) { if ( GetRect( m_pFocus, &rc ) ) { CPoint pt( rc.left, ( rc.top + rc.bottom ) / 2 ); pt.y -= ITEM_HEIGHT; pTo = HitTest( pt ); } } else if ( nChar == VK_DOWN && m_pFocus != NULL ) { if ( GetRect( m_pFocus, &rc ) ) { CPoint pt( rc.left, ( rc.top + rc.bottom ) / 2 ); pt.y += ITEM_HEIGHT; pTo = HitTest( pt ); } } else if ( ( nChar == VK_LEFT || nChar == VK_SUBTRACT ) && m_pFocus != NULL ) { while ( TRUE ) { if ( m_pFocus->m_bExpanded && m_pFocus->m_nCount ) { Expand( m_pFocus, TS_FALSE ); break; } if ( m_pFocus->m_pParent == m_pRoot ) break; m_pFocus = m_pFocus->m_pParent; bChanged |= DeselectAll( m_pFocus ); bChanged |= Select( m_pFocus ); } Highlight( m_pFocus ); } else if ( ( nChar == VK_RIGHT || nChar == VK_ADD ) && m_pFocus != NULL ) { if ( ! m_pFocus->m_bExpanded && m_pFocus->m_nCount ) { bChanged |= Expand( m_pFocus, TS_TRUE ); } } else if ( _istalnum( nChar ) ) { CBrowseTreeItem* pStart = m_pFocus; CBrowseTreeItem* pBase = pStart ? pStart->m_pParent : m_pRoot; for ( int nLoop = 0 ; nLoop < 2 ; nLoop++ ) { CBrowseTreeItem** pChild = pBase->m_pList; for ( int nCount = pBase->m_nCount ; nCount ; nCount--, pChild++ ) { if ( pStart != NULL ) { if ( pStart == *pChild ) pStart = NULL; } else if ( toupper( (*pChild)->m_sText.GetAt( 0 ) ) == (int)nChar ) { DeselectAll( m_pFocus = *pChild, NULL, FALSE ); Select( m_pFocus, TS_TRUE, FALSE ); Highlight( m_pFocus ); lRoot.Unlock(); NotifySelection(); return; } } } } if ( pTo != NULL ) { if ( ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) == 0 || m_pFocus == NULL ) { bChanged |= DeselectAll( m_pFocus = pTo ); bChanged |= Select( m_pFocus ); } else { bChanged |= Select( m_pFocus = pTo ); } Highlight( m_pFocus ); } if ( bChanged ) { lRoot.Unlock(); NotifySelection(); } }