Esempio n. 1
0
void  AppFileExplorer::updateItems(std::string path)
{
	mAttriVec.clear();
	mStrVec.clear();
 	
	if(path.length() == 0)	
			return;
	if(path[path.length()-1] != '\\')
		 path += "\\*";
	else 
		 path += "*";
 
	WIN32_FIND_DATAA fd;
	HANDLE hFindFile = FindFirstFileA(path.c_str(), &fd);
	if(hFindFile == INVALID_HANDLE_VALUE)
	{
		::FindClose(hFindFile); return;
	}

  	BOOL bIsDirectory;
 
	BOOL bFinish = FALSE;
	while(!bFinish)
	{
 	 	bIsDirectory = ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
		
		std::string fileName = fd.cFileName;
		
		if((fileName != ".") && ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0))
		{
			if(bIsDirectory || fileName == "..") 
			{
					mAttriVec.push_back(true);
					Ogre::DisplayString str = fd.cFileName;
 					mStrVec.push_back(str.asUTF8());
			}
			else 
			{
					std::string ext = fileName.substr(fileName.find_last_of('.'));
					if(ext  == mFilter)
					{
						mStrVec.push_back(fd.cFileName);
 						mAttriVec.push_back(false);
 					}
 			}
 			
		}
		bFinish = (FindNextFileA(hFindFile, &fd) == FALSE);
	}
		
	::FindClose(hFindFile);

	OgreBites::SelectMenu *selMenu = (OgreBites::SelectMenu*)mTrayMgr->getWidget(mExplorerName + "PathMenu");
	selMenu->setItems(mStrVec);
	if(mStrVec.size() > 1)
		selMenu->selectItem(1,false);
}
Esempio n. 2
0
void AppFileExplorer::show()
{
	mOldMouseListener = AppDemo::getSingleton().mMouse->getEventCallback();
	AppDemo::getSingleton().mMouse->setEventCallback(this);
	OgreBites::SelectMenu* diskM = (OgreBites::SelectMenu*)mTrayMgr->getWidget(mExplorerName + "DiskMenu");
 	updateItems(mCurrentFilePath[diskM->getSelectionIndex()]);

	mTrayMgr->showAll();

}
Esempio n. 3
0
bool RenderState::keyPressed(const OIS::KeyEvent &keyEventRef)
{
        OgreFramework* framework = OgreFramework::getSingletonPtr();
        OIS::Keyboard* keyboard =  framework->_keyboard;
        OgreBites::SdkTrayManager* trayMgr = framework->_trayMgr;
        OgreBites::SelectMenu* pMenu = 
                (OgreBites::SelectMenu*)trayMgr->getWidget("DisplayModeSelMenu");

        if(_settingsMode == true)
        {
                if(keyboard->isKeyDown(OIS::KC_S))
                {
                        if(pMenu->getSelectionIndex() + 1 < (int)pMenu->getNumItems())
                                pMenu->selectItem(pMenu->getSelectionIndex() + 1);
                }

                if(keyboard->isKeyDown(OIS::KC_W))
                {
                        if(pMenu->getSelectionIndex() - 1 >= 0)
                                pMenu->selectItem(pMenu->getSelectionIndex() - 1);
                }

                if(keyboard->isKeyDown(OIS::KC_R))
                {
                        steps = 20;
                }
        }

        if(keyboard->isKeyDown(OIS::KC_ESCAPE))
        {
                // pushAppState(findByName("PauseState"));
                exit();
                return true;
        }

        if(keyboard->isKeyDown(OIS::KC_I))
        {
                if(_detailsPanel->getTrayLocation() == OgreBites::TL_NONE)
                {
                        framework->_trayMgr->moveWidgetToTray(_detailsPanel, 
                                                              OgreBites::TL_BOTTOMRIGHT, 
                                                              0);
                        _detailsPanel->show();
                }
                else
                {
                        framework->_trayMgr->removeWidgetFromTray(_detailsPanel);
                        _detailsPanel->hide();
                }
        }

        if(keyboard->isKeyDown(OIS::KC_TAB))
        {
                _settingsMode = !_settingsMode;
                return true;
        }

        if(_settingsMode && keyboard->isKeyDown(OIS::KC_RETURN) ||
           keyboard->isKeyDown(OIS::KC_NUMPADENTER))
        {
        }

        if(!_settingsMode || (_settingsMode && !keyboard->isKeyDown(OIS::KC_O)))
                framework->keyPressed(keyEventRef);

        return true;
}
Esempio n. 4
0
void AppFileExplorer::itemSelected(OgreBites::SelectMenu* selMenu)
{
	OgreBites::SelectMenu* diskM = (OgreBites::SelectMenu*)mTrayMgr->getWidget(mExplorerName + "DiskMenu");
 	if(selMenu->getName() == mExplorerName + "PathMenu")
	{
		if(mAttriVec[selMenu->getSelectionIndex()])
		{
			std::string selItem = selMenu->getSelectedItem();
		
			if(selItem == "..")
			{
				int loc = mCurrentFilePath[diskM->getSelectionIndex()].find_last_of('\\');
				mCurrentFilePath[diskM->getSelectionIndex()] = mCurrentFilePath[diskM->getSelectionIndex()].substr(0,loc);
			}
			else 
			{
				if(mCurrentFilePath[diskM->getSelectionIndex()][mCurrentFilePath[diskM->getSelectionIndex()].length()-1] != '\\' 
					&& mCurrentFilePath[diskM->getSelectionIndex()][mCurrentFilePath[diskM->getSelectionIndex()].length()-1] != '/')
					mCurrentFilePath[diskM->getSelectionIndex()] += "\\";
				mCurrentFilePath[diskM->getSelectionIndex()] += selMenu->getSelectedItem();
			}
			int index = diskM->getSelectionIndex();
			diskM->setItems(mCurrentFilePath);
			diskM->selectItem(index,false);
			updateItems(mCurrentFilePath[diskM->getSelectionIndex()]);
		}
 	}
	if(selMenu->getName() == mExplorerName + "DiskMenu")
	{
		int index = diskM->getSelectionIndex();
		diskM->setItems(mCurrentFilePath);
		diskM->selectItem(index,false);
		updateItems(mCurrentFilePath[diskM->getSelectionIndex()]);
	}
}
Esempio n. 5
0
void AppFileExplorer::buttonHit(OgreBites::Button* button)
{
	OgreBites::SelectMenu* diskM = (OgreBites::SelectMenu*)mTrayMgr->getWidget(mExplorerName + "DiskMenu");
	
	if(button->getCaption() == "ok")
	{
		OgreBites::SelectMenu *selMenu = (OgreBites::SelectMenu*)mTrayMgr->getWidget(mExplorerName + "PathMenu");
		
		std::string selItem = selMenu->getSelectedItem();
		
		int index = selMenu->getSelectionIndex();
		
		if(mAttriVec[index])
		{
			if(selItem == "..")
			{
				int loc = mCurrentFilePath[diskM->getSelectionIndex()].find_last_of('\\');
				mCurrentFilePath[diskM->getSelectionIndex()] = mCurrentFilePath[diskM->getSelectionIndex()].substr(0,loc);
			}
			else 
			{
				if(mCurrentFilePath[diskM->getSelectionIndex()][mCurrentFilePath[diskM->getSelectionIndex()].length()-1] != '\\' 
					&& mCurrentFilePath[diskM->getSelectionIndex()][mCurrentFilePath[diskM->getSelectionIndex()].length()-1] != '/')
					mCurrentFilePath[diskM->getSelectionIndex()] += "\\";
				mCurrentFilePath[diskM->getSelectionIndex()] += selMenu->getSelectedItem();
			}
			int index = diskM->getSelectionIndex();
			diskM->setItems(mCurrentFilePath);
			diskM->selectItem(index,false);
			updateItems(mCurrentFilePath[diskM->getSelectionIndex()]);
 		 	return;
		}
		else 
		{
 			if(mCurrentFilePath[diskM->getSelectionIndex()][mCurrentFilePath[diskM->getSelectionIndex()].length()-1] != '\\' 
				&& mCurrentFilePath[diskM->getSelectionIndex()][mCurrentFilePath[diskM->getSelectionIndex()].length()-1] != '/')
					mCurrentFilePath[diskM->getSelectionIndex()] += "\\";
			if(mExplorerListener != NULL)
				mExplorerListener->notifyFileOpen(mCurrentFilePath[diskM->getSelectionIndex()] + selMenu->getSelectedItem());
  		}
   	}
	else if(button->getCaption() == "cancel")
	{
		mExplorerListener->notifyFileOpen("");
	}
	AppDemo::getSingleton().mMouse->setEventCallback(mOldMouseListener);
	mTrayMgr->hideAll();
 	
}
Esempio n. 6
0
void TutorialApplication::createFrameListener(void) {
	BaseApplication::createFrameListener();
	
	
	// create a params panel for displaying sample details
    Ogre::StringVector items;
   // items.push_back("Filtering");
   // items.push_back("Poly Mode");

    mStatusPanel = mTrayMgr->createParamsPanel(OgreBites::TL_BOTTOMRIGHT, "Params", 300, items);
	
	OgreBites::Slider* slider = NULL;

	mTrayMgr->createButton(OgreBites::TL_BOTTOMRIGHT, "Reset pose", "Reset pose");
	mTrayMgr->createButton(OgreBites::TL_BOTTOMRIGHT, "Reload controller", "Reload controller");
	mTrayMgr->createButton(OgreBites::TL_BOTTOMRIGHT, "Go to pose", "Go to pose");
	

	// animations control
	slider = mTrayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "Gravity X", "Gravity X", 400, 150, 50, -9.8, 9.8, 149 );
	slider->setValue(0);
	slider = mTrayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "Gravity Y", "Gravity Y", 400, 150, 50, -9.8, 9.8, 149 );
	slider->setValue(0.0f);
	slider = mTrayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "Gravity Z", "Gravity Z", 400, 150, 50, -9.8, 9.8, 149 );
	slider->setValue(0.0f);
	slider = mTrayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "Time multiplier", "Time multiplier", 400, 150, 50, 0, 1, 1000 );
	slider->setValue(DEFAULT_TIME_MULTIPLIER);
	slider = mTrayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "Animation speed", "Animation speed", 400, 150, 50, 0, 2, 1000 );
	slider->setValue(DEFAULT_ANIMATION_SPEED);
	
	
	// animation selector
	int defaultAnimationIndex = 0;
	Ogre::SkeletonInstance* skel = mFigureEnt->getSkeleton();
	
	Ogre::StringVector animationNames;
	animationNames.push_back("<none>");
	if ( skel ) {
		std::cout << "got skeleton" << std::endl;
		for ( int i=0; i<skel->getNumAnimations(); i++ ) {
			std::string name = skel->getAnimation(i)->getName();
			std::cout << " animation: " << name << std::endl;
			if ( /*i<5 || name == "WalkNew"*/true )
			{
				animationNames.push_back(name);
				if ( name == DEFAULT_ANIMATION ) {
					defaultAnimationIndex = i;
				}
			}
		}
		//mFigureEnt->setDisplaySkeleton(true);
	} else {
		std::cout << "no skeleton" << std::endl;
	}
	mAnimationSelectMenu = mTrayMgr->createThickSelectMenu( OgreBites::TL_TOPLEFT, "Animation", "Animation", 400, animationNames.size());
	if ( animationNames.size() ) {
		mAnimationSelectMenu->setItems(animationNames);
		mAnimationSelectMenu->selectItem(defaultAnimationIndex);
	}
	
	static const int debugDrawStyleCount = 8;
	OgreBites::SelectMenu* select = mTrayMgr->createThickSelectMenu( OgreBites::TL_BOTTOMRIGHT, "Debug draw", "Debug draw", 400, debugDrawStyleCount );
	Ogre::StringVector debugDrawStates;
	const char* debugDrawStateNames[debugDrawStyleCount] =  { "None", "Nodes", "Links", "Faces", "FaceAnchors", "Tetras", "TetraForces", "BadTetras" };
	for ( int i=0; i<debugDrawStyleCount; i++ ) {
		debugDrawStates.push_back(debugDrawStateNames[i]);
	}
	select->setItems(debugDrawStates);
	select->selectItem(0);
	
	
	showControls(false);
	
}