예제 #1
0
void TweaksPlugin::patchReadingLife()
{
    LOG_TRACE(l);
    FooterLabelWidget *readingLife = qApp->activeWindow()->findChild<FooterLabelWidget *>("readingLife");
    if(readingLife)
    {
        ReadingLifeMenuController* fbmc = readingLife->findChildren<ReadingLifeMenuController *>().last();
        NickelTouchMenu *ntm = readingLife->findChildren<NickelTouchMenu *>().last();

        if (fbmc && ntm)
        {
            // Clear menu and add entries based on configuration
            static QPoint origPos = ntm->pos();
            static int elemHeight = ntm->sizeHint().height()/2;

            ntm->clear();

            QList<MenuEntry>::iterator it;
            int activeEntries = 0;
            for(it = menuEntries.begin(); it != menuEntries.end(); it++) {
                if (it->enabled()) {
                    MenuTextItem *mti = NULL;
                    mti = fbmc->createMenuTextItem(ntm, it->name(), false, false);
                    mti->setSelected(false);
                    fbmc->addWidgetActionWithMapper(ntm, mti, &mapper, it->action(), true, true);
                    ntm->addSeparator();
                    activeEntries++;
                }
            }

            pluginSettings->beginGroup("CustomCommands");
            QStringList keys = pluginSettings->allKeys();

            QList<QString>::iterator keyit;
            for(keyit = keys.begin(); keyit != keys.end(); keyit++) {
                LOG_DEBUG(l) << "custom command: " << keyit->toStdString();
                QString action = pluginSettings->value(*keyit,QString()).toString();
                LOG_DEBUG(l) << "action: " << action.toStdString();

                MenuTextItem *mti = NULL;
                mti = fbmc->createMenuTextItem(ntm, *keyit, false, false);
                mti->setSelected(false);
                fbmc->addWidgetActionWithMapper(ntm, mti, &mapper, action, true, true);
                ntm->addSeparator();
                activeEntries++;
            }
            pluginSettings->endGroup();

            QPoint x = origPos;
            x.setY(origPos.y() + (2 - activeEntries) * elemHeight);
            x.setY(x.y() + (abs(2 - activeEntries) * 10));

            //cout << qPrintable(QString("x %1 | y %2").arg(x.x()).arg(x.y())) << endl << flush;

            ntm->move(x);
            ntm->update();
            ntm->layout();
        }
    }
}
예제 #2
0
void display_menu (void *dummy) throw() {
  // If the world has started, change "Start Game" to "Resume Game".
  if (world) {
    MenuTextItem *mti = (MenuTextItem*)menu->get_widget (0);
    mti->set_text ("Resume Game");
  }

  set_title ("Xeno Story");
  activity = MAIN_MENU;
}
예제 #3
0
bool TweaksPlugin::createHomeMenuEntry(QString mapping, QString icon, QString text, HomeMenuController *hmc, NickelTouchMenu *ntm)
{
    MenuTextItem *mti = NULL;

    mti = hmc->createMenuTextItem(ntm, text, false);
    if(!icon.isEmpty())
        mti->setSelectedImage(icon);

    mti->setSelected(true);
    hmc->addWidgetActionWithMapper(ntm, mti, &mapper, mapping, true, true);
    ntm->addSeparator();
    return true;
}
예제 #4
0
	void Menu::_determineLargestTextItemWidth()
	{
		mMaxTextItemWidth = 0;
		float textWidth = 0;
		MenuTextItem* mti = NULL;
		for( std::list<MenuItem*>::iterator it = mItems.begin(); it != mItems.end(); ++it )
		{
			mti = dynamic_cast<MenuTextItem*>((*it));
			if(mti != NULL)
			{
				textWidth = mti->getTextWidth();

				if(textWidth > mMaxTextItemWidth)
					mMaxTextItemWidth = textWidth;
			}
		}
	}
예제 #5
0
	MenuItem* Menu::createItem(MenuItemDesc* d, int index)
	{
		if(d->widget_name == "")
		{
			d->widget_name = getName() + ".AutoName.MenuItem." + Ogre::StringConverter::toString(mAutoNameCounter);
			++mAutoNameCounter;
		}

		// Make sure new MenuItem will maintain link to owner ToolBar
		d->toolBar = mDesc->toolBar;

		// Make sure new MenuItem will maintain link to owner ContextMenu
		d->contextMenu = mDesc->contextMenu;

		// Make sure new MenuItem will maintain link to owner Menu
		d->menu = this;

		// Determine position of MenuItem
		d->widget_dimensions.size.width = mMenuPanel->getClientDimensions().size.width;
		d->widget_dimensions.size.height = mDesc->menu_itemHeight;
		d->index = index;
		
		MenuItem* newMenuItem = dynamic_cast<MenuItem*>(_createWidget(d));
		addChild(newMenuItem);

		if(mDesc->menu_autoWidenMenuPanel)
		{
			MenuTextItem* mti = dynamic_cast<MenuTextItem*>(newMenuItem);
			if(mti != NULL)
			{
				float textWidth = mti->getTextWidth();
				if(textWidth > mMaxTextItemWidth)
				{
					mMaxTextItemWidth = textWidth;

					if(mMenuPanel != NULL)
						mMenuPanel->setWidth(mMenuPanel->getLeftRightBorderWidth() + mMaxTextItemWidth + 5);
				}
			}
		}

		return newMenuItem;
	}