CModuleChooserButton* CModuleChooserBar::addButton( CSwordModuleInfo* const module )
{
	CModuleChooserButton* b = new CModuleChooserButton(module, m_moduleType, ++m_idCounter, this);
	QAction* a = addWidget(b);
	m_buttonList.append(b);
	connect( b, SIGNAL(sigAddButton()), this, SLOT(addButton()) );
	connect( b, SIGNAL(sigRemoveButton(const int)), this, SLOT(removeButton(const int)) );
	connect( b, SIGNAL(sigChanged()), SIGNAL(sigChanged()) );
	connect( b, SIGNAL(sigChanged()), SLOT(updateMenuItems()) );
	a->setVisible(true);
	updateMenuItems(); //make sure the items are up to date with the newest module list
	return b;
}
예제 #2
0
	//------------------------------------------------------------------------------------
	ToolOperation* CameraPositionTool::activate(const Any& _toolParameter)
	{
		const ToolParam& tp = any_cast<ToolParam>(_toolParameter);
		if(tp.store)
		{
			World* world = WorldManager::getSingleton().getActiveWorld();
			if(world)
			{
				Camera* camera = world->getCamera();
				savePosition( tp.index, camera->getPosition(), camera->getOrientation());
				updateMenuItems();
			}
		}
		else
		{
			Vector3 position;
			Quaternion rotation;
			readPosition(tp.index, position, rotation);
			World* world = WorldManager::getSingleton().getActiveWorld();
			Camera* camera = world->getCamera();
			camera->setPosition(position);
			camera->setOrientation(rotation);
		}
		return nullptr;
	}
/** Sets the number of the maximum count of buttons. */
void CModuleChooserBar::setButtonLimit(const int limit) {
	m_buttonLimit = limit;
	if (limit == -1) //no need to delete buttons
		return;

	const int tooMuch = m_buttonList.size() - limit;
	for (int i = 0; i < tooMuch; ++i) {
		CModuleChooserButton* b = m_buttonList.takeLast();
		b->deleteLater();
	}

	updateMenuItems();
}
/** Removes a button from the toolbar */
void CModuleChooserBar::removeButton( const int ID ) {
	QMutableListIterator<CModuleChooserButton*> it(m_buttonList);
	while (it.hasNext()) {
		CModuleChooserButton* b = it.next();
		if (b->getId() == ID) { //found the right button to remove
			it.remove();
			b->deleteLater();
			break;
		}
	}
	emit sigChanged();
	updateMenuItems(); //make sure the items are up to date with the newest module list
}
/** Sets the modules which are chosen in this module chooser bar. */
void CModuleChooserBar::setModules( QList<CSwordModuleInfo*> useModules ) {
	setButtonLimit(0);
	setButtonLimit(-1);  //these two lines clear the bar

	if (!useModules.count()) return;

	QList<CSwordModuleInfo*>::iterator end_it = useModules.end();
	for (QList<CSwordModuleInfo*>::iterator it(useModules.begin()); it != end_it; ++it) {
		if ( (m_buttonLimit != -1) && (m_buttonLimit <= (int)m_buttonList.count()) ) {
			break;
		}
		addButton( *it );
	}

	if ( (m_buttonLimit == -1) || (m_buttonLimit > (int)m_buttonList.count()) ) {
		addButton(0);//add button without module set
	}

	updateMenuItems();
}
예제 #6
0
void GameParamUserInterface::onActivate()
{
   TNLAssert(getUIManager()->cameFrom<EditorUserInterface>(), "GameParamUserInterface should only be called from the editor!");

   Level *level = getUIManager()->getUI<EditorUserInterface>()->getLevel();
   const GameType *gameType = level->getGameType();

   // Force rebuild of all params for current gameType; this will make sure we have the latest info if we've loaded a new level,
   // but will also preserve any values entered for gameTypes that are not current.
   clearCurrentGameTypeParams(gameType);
   
   // Load filename from editor only when we activate the menu
   mLevelFilename = stripExtension(getUIManager()->getUI<EditorUserInterface>()->getLevelFileName());
   if(mLevelFilename == EditorUserInterface::UnnamedFile)
      mLevelFilename = "";

   updateMenuItems(gameType);   
   mOrigGameParams = level->toLevelCode();   // Save a copy of the params coming in for comparison when we leave to see what changed
   Cursor::disableCursor();
}
void ListGeneratedPopupMenu::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);
	
	if(whichField & ModelFieldMask)
	{
		if(getModel() != NULL)
		{
			getModel()->addListDataListener(&_ModelListener);
		}
	}

	if((whichField & ModelFieldMask) ||
	   (whichField & CellGeneratorFieldMask))
	{
		updateMenuItems();
	}
}
예제 #8
0
	//------------------------------------------------------------------------------------
	CameraPositionTool::CameraPositionTool()
	{
		initConstants();

		MenuBar* mb = MenuBarList::getSingleton().getMenuBar( "EditorMenuBar" );
		mb->insertItem( ROOT_MENU_ID, MenuItemType::Popup, ROOT_MENU_CAPTION );
		mb->insertItem( MENU_SEPARATOR_ID[0], MenuItemType::Separator, StringUtil::BLANK, ROOT_MENU_ID );
		mb->insertItem( POPUP_MENU_ID, MenuItemType::Popup, POPUP_MENU_CAPTION, ROOT_MENU_ID );

		size_t i;
		for(i = 0; i != NUM_POSITIONS; ++i)
		{
			mb->insertItem( STORE_MENU_ITEM_ID[i], MenuItemType::Normal, STORE_MENU_ITEM_CAPTION[i], POPUP_MENU_ID );
			mb->insertHotkey( STORE_MENU_ITEM_ID[i], STORE_HOTKEY_CONFIG_KEY_NAME[i], "Editor", DEFAULT_STORE_HOTKEY[i] );
			mb->setItemDescription( STORE_MENU_ITEM_ID[i], STORE_MENU_ITEM_DESC );

			ToolParam tp;
			tp.store = true;
			tp.index = i;
			mb->attachTool( STORE_MENU_ITEM_ID[i], this, (AnyLite) tp );
		}
		
		mb->insertItem( MENU_SEPARATOR_ID[1], MenuItemType::Separator, StringUtil::BLANK, POPUP_MENU_ID );

		for(i = 0; i != NUM_POSITIONS; ++i)
		{
			mb->insertItem( RESTORE_MENU_ITEM_ID[i], MenuItemType::Normal, RESTORE_MENU_ITEM_CAPTION[i], POPUP_MENU_ID );
			mb->insertHotkey( RESTORE_MENU_ITEM_ID[i], RESTORE_HOTKEY_CONFIG_KEY_NAME[i], "Editor", DEFAULT_RESTORE_HOTKEY[i]);
			mb->setItemDescription( RESTORE_MENU_ITEM_ID[i], RESTORE_MENU_ITEM_DESC );
			
			ToolParam tp;
			tp.store = false;
			tp.index = i;
			mb->attachTool(RESTORE_MENU_ITEM_ID[i], this, (AnyLite) tp);
		}

		updateMenuItems();
		registerWorldListener();
	}
예제 #9
0
	//------------------------------------------------------------------------------------
	void CameraPositionTool::worldActiveChanged(const WorldEvent& _evt)
	{
		updateMenuItems();
	}