void PlayerMenuUserInterface::playerSelected(U32 index) const
{
   // When we created the menu, names were not sorted, and item indices were assigned in "natural order".  Then
   // the menu items were sorted by name, and now the indices are now jumbled.  This bit here tries to get the
   // new, actual list index of an item given its original index.
   for(S32 i = 0; i < getMenuItemCount(); i++)
      if(getMenuItem(i)->getIndex() == (S32)index)
      {
         index = i;
         break;
      }

   GameType *gt = getGame()->getGameType();

   if(action == PlayerActionChangeTeam)
   {
      TeamMenuUserInterface *ui = getUIManager()->getUI<TeamMenuUserInterface>();
      ui->mNameToChange = getMenuItem(index)->getPrompt();

      getUIManager()->activate<TeamMenuUserInterface>();     // Show menu to let player select a new team
   }

   else if(gt)    // action == Kick
      gt->c2sKickPlayer(getMenuItem(index)->getPrompt());


   if(action != PlayerActionChangeTeam)      // Unless we need to move on to the change team screen...
      getUIManager()->reactivateGameUI();    // ...it's back to the game!
}
Example #2
0
MenuItem* MenuItemList::getNextMenuItem(void) {
	int size = getMenuItems().size();
	if (size == 0) {
		return 0;
	} else {
		int newIndex = (getActiveItemIndex() + 1) % size;
		MenuItem* nextItem = getMenuItem(newIndex);
		getMenuItem(getActiveItemIndex())->setActive(false);
		nextItem->setActive(true);
		setActiveItemIndex(newIndex);
		return nextItem;
	}
}
bool ItemListSelectUserInterface::processMenuSpecificKeys(InputCode inputCode)
{
   string inputString = InputCodeManager::inputCodeToPrintableChar(inputCode);

   if(inputString == "")
      return false;
   
   mNameSoFar.append(inputString);

   string mNameSoFarLc = lcase(mNameSoFar);

   if(stringContainsAllTheSameCharacter(mNameSoFarLc))
   {
      mSelectedIndex = getIndexOfNext(mNameSoFarLc.substr(0, 1));

      if(mNameSoFar.size() > 1 && lcase(getMenuItem(mSelectedIndex)->getValue()).substr(0, mNameSoFar.length()) != mNameSoFarLc)
         mNameSoFar = mNameSoFar.substr(0, mNameSoFar.length() - 1);    // Remove final char, the one we just added above
   }
   else
      mSelectedIndex = getIndexOfNext(mNameSoFarLc);


   mStillTypingNameTimer.reset();
   mItemSelectedWithMouse = false;

   // Move the mouse to the new selection to make things "feel better"
   MenuItemSize size = getMenuItem(mFirstVisibleItem)->getSize();
   S32 y = getYStart();

   for(S32 j = mFirstVisibleItem; j < mSelectedIndex; j++)
   {
      size = getMenuItem(j)->getSize();
      y += getTextSize(size) + getGap(size);
   }

   y += getTextSize(size) / 2;

   // WarpMouse fires a mouse event, which will cause the cursor to become visible, which we don't want.  Therefore,
   // we must resort to the kind of gimicky/hacky method of setting a flag, telling us that we should ignore the
   // next mouse event that comes our way.  It might be better to handle this at the Event level, by creating a custom
   // method called WarpMouse that adds the suppression.  At this point, however, the only place we care about this
   // is here so...  well... this works.
   SDL_WarpMouseInWindow(DisplayManager::getScreenInfo()->sdlWindow, (S32)DisplayManager::getScreenInfo()->getMousePos()->x, y);

   Cursor::disableCursor();
   mIgnoreNextMouseEvent = true;
   playBoop();

   return true;
}
// Return index of next level starting with specified string; if none exists, returns current index.
// If startingWith is only one character, the entry we're looking for could be behind us.  See tests
// for examples of this.
S32 ItemListSelectUserInterface::getIndexOfNext(const string &startingWithLc) const
{
   TNLAssert(startingWithLc.length() > 0, "Did not expect an empty string here!");
   TNLAssert(startingWithLc == lcase(startingWithLc), "Expected a lowercased string here");

   bool first = true;
   bool multiChar = startingWithLc.length() > 1;
   S32 offset = multiChar ? 0 : 1;

   // Loop until we hit the end of the list, or we hit an item that sorts > our startingString (meaning we overshot).
   // But we only care about overshoots in multiChar mode because there could well be single-char hits behind us in the list.
   while(true)
   {
      if(mSelectedIndex + offset >= getMenuItemCount())    // Hit end of list -- loop to beginning
         offset = -mSelectedIndex;

      string prospectiveItem = lcase(getMenuItem(mSelectedIndex + offset)->getValue());

      if(prospectiveItem.substr(0, startingWithLc.size()) == startingWithLc)
         return mSelectedIndex + offset;

      if(offset == 0 && !first)
         break;

      offset++;
      first = false;
   }

   // Found no match; return current index
   return mSelectedIndex;
}
// Runs as we're exiting the menu
void GameParamUserInterface::onEscape()
{
   EditorUserInterface *ui = getUIManager()->getUI<EditorUserInterface>();

   string newFilename = getMenuItem(1)->getValue();

   bool filenameChanged = mLevelFilename != newFilename;
   if(filenameChanged)
      ui->setLevelFileName(newFilename);

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

   const Vector<string> *keys = gameType->getGameParameterMenuKeys();

   for(S32 i = 0; i < keys->size(); i++)
   {
      MenuItemMap::iterator iter = mMenuItemMap.find(keys->get(i));

      MenuItem *menuItem = iter->second.get();
      gameType->saveMenuItem(menuItem, keys->get(i));
   }

   if(anythingChanged() || filenameChanged)
   {
      EditorUserInterface *ui = getUIManager()->getUI<EditorUserInterface>();
      // TODO -->Save undo state here!!!
      ui->validateLevel();
   }

   // Now back to our previously scheduled program...  (which will be the editor, of course)
   getUIManager()->reactivatePrevUI();
}
Example #6
0
void settingsMenu(int input)
{
	updateM = 1;
	switch(input)
	{
	case KEY_OK:
		stateMenu = audioMenuItem;
		audioMenu(1000); //calles for a first refresh
		updateM = 0;
		break;
	case KEY_LEFT:
		break;
	case KEY_RIGHT:
		break;
	case KEY_ESC:
		stateMenu = scrollMenu;
		break;
	default:
		updateM = 0;
		break;
	}
	if (updateM == 1)
	{
		clearScreen();
		getMenuItem();
	}
}
Example #7
0
static MenuItem *
newMenuItem (Menu *menu, unsigned char *setting, const MenuString *name) {
  if (menu->items.count == menu->items.size) {
    unsigned int newSize = menu->items.size? (menu->items.size << 1): 0X10;
    MenuItem *newArray = realloc(menu->items.array, (newSize * sizeof(*newArray)));

    if (!newArray) {
      logMallocError();
      return NULL;
    }

    menu->items.array = newArray;
    menu->items.size = newSize;
  }

  {
    MenuItem *item = getMenuItem(menu, menu->items.count++);

    item->menu = menu;
    item->setting = setting;

    item->name.label = getLocalText(name->label);
    item->name.comment = getLocalText(name->comment);

    item->methods = NULL;
    item->test = NULL;
    item->changed = NULL;

    item->minimum = 0;
    item->maximum = 0;
    item->divisor = 1;

    return item;
  }
}
Example #8
0
//menu
void scrollMenu(int input)
{
	updateM = 1;
	switch(input)
	{
	case KEY_OK:
		goIntoScrollMenu();
		break;
	case KEY_LEFT:
		scrollMenuLeft();
		break;
	case KEY_RIGHT:
		scrollMenuRight();
		break;
	case KEY_ESC:
		stateMenu = klokMenu;
		drawDateTimeComplete();
		updateM = 0;
		break;
	default:
		updateM = 0;
		break;
	}
	if (updateM == 1)
	{
		clearScreen();
		getMenuItem();
	}
}
Example #9
0
void setupMenu(int input)
{
	updateM = 1;
	switch(input)
	{
	case KEY_OK:
		saveEEPROM();
		dateTimeInit();
		stateMenu = klokMenu;
		break;
	case KEY_UP:
		changeUtcUp();
		break;
	case KEY_DOWN:
		changeUtcDown();
		break;
	default:
		updateM = 0;
		break;
	}
	if (updateM == 1)
	{
		clearScreen();
		getMenuItem();
	}
};
Example #10
0
int StGLButton::computeWidth(const StString& theText) {
    StGLMenuItem* anItem = getMenuItem();
    if(anItem == NULL) {
        return 0;
    }

    return anItem->computeTextWidth(theText) + myRoot->scale(8) + anItem->getMargins().left + anItem->getMargins().right;
}
Example #11
0
static int
testMenuItem (Menu *menu, unsigned int index, int all) {
  MenuItem *item = getMenuItem(menu, index);

  if (!item) return 0;
  if (all) return 1;
  if (!item->test) return 1;
  return item->test();
}
void PlaylistMenuUserInterface::processSelection(U32 index)     
{
   string playlistName = getMenuItem(index)->getPrompt();
   if(playlistName == NO_PLAYLIST)
      playlistName = "";

   setPlaylist(playlistName);             // Different implementations when hosting vs. when playing
   getUIManager()->reactivatePrevUI();    // To hosting menu
}
void GameParamUserInterface::updateMenuItems(const GameType *gameType)
{
   TNLAssert(gameType, "Missing game type!");

   string filename = mLevelFilename;
   // Grab the level filename from the menuitem if it has been built already.
   // This let's us persist a changed filename without having to leave the menu first
   if(getMenuItemCount() > 0)
      filename = getMenuItem(1)->getValue();

   clearMenuItems();

   // Note that on some gametypes instructions[1] is NULL
   string instructs = string(gameType->getInstructionString()[0]) + 
                             (gameType->getInstructionString()[1] ?  string(" ") + gameType->getInstructionString()[1] : "");

   addMenuItem(new ToggleMenuItem("Game Type:",       
                                  getGameTypes(),
                                  getGameTypes().getIndex(gameType->getGameTypeName()),
                                  true,
                                  changeGameTypeCallback,
                                  instructs));


   addMenuItem(new TextEntryMenuItem("Filename:",                         // name
                                     filename,                            // val
                                     EditorUserInterface::UnnamedFile,    // empty val
                                     "File where this level is stored",   // help
                                     MAX_FILE_NAME_LEN));

   const Vector<string> *keys = gameType->getGameParameterMenuKeys();

   for(S32 i = 0; i < keys->size(); i++)
   {
      MenuItemMap::iterator iter = mMenuItemMap.find(keys->get(i));

      boost::shared_ptr<MenuItem> menuItem;

      if(iter != mMenuItemMap.end())      // What is this supposed to do?  I can't seem to make this condition occur.
         menuItem = iter->second;
      else                 // Item not found
      {
         menuItem = gameType->getMenuItem(keys->get(i));
         TNLAssert(menuItem, "Failed to make a new menu item!");

         mMenuItemMap.insert(pair<string, boost::shared_ptr<MenuItem> >(keys->get(i), menuItem));
      }

      addWrappedMenuItem(menuItem);
   }
}
Example #14
0
static void
setAdvancedSubmenu (Menu *submenu) {
  Menu *parent = getMenuParent(submenu);

  if (parent) {
    unsigned int size = getMenuSize(parent);

    if (size) {
      MenuItem *item = getMenuItem(parent, size-1);

      if (item) setMenuItemTester(item, testAdvancedSubmenu);
    }
  }
}
Example #15
0
void Server::connected()
{
    this->appendText("Connected.");
    menuItem->setForeground(QBrush((QColor(255,255,255))));
    for(int c = 0; c < menuItem->rowCount(); c++) {
        QStandardItem *channelMenuItem = getMenuItem()->child(c);
        QVariant channelData = channelMenuItem->data(Qt::UserRole);
        Channel *channel = channelData.value<Channel*>();
        if (PreferencesHelper::sharedInstance()->getShouldJoinOnConnect(channel->getName(), this->getHost()))
        {
            channel->join();
        }
    }

    resetTimer();
}
Example #16
0
void alarmeringMenu(int input)
{
	alarmInput(input);
	switch(input)
	{
		case KEY_ESC:
			updateM = 1;
			stateMenu = scrollMenu;
		break;
		default:
			updateM = 0;
		break;
	}
	
	clearScreen();
	getMenuItem();
	
}
Example #17
0
bool StGLButton::stglInit() {
    const int aWidth = myWidth;
    if(!StGLMenu::stglInit()) {
        return false;
    }

    myWidth = aWidth;
    StGLMenuItem* anItem = getMenuItem();
    if(anItem == NULL) {
        return true;
    }

    anItem->changeRectPx().left()   = 0;
    anItem->changeRectPx().right()  = myWidth;
    anItem->changeRectPx().bottom() = anItem->changeRectPx().top() + myItemHeight;
    anItem->setTextWidth(myWidth - anItem->getMargins().left - anItem->getMargins().right);
    changeRectPx().right()  = getRectPx().left() + myWidth;
    changeRectPx().bottom() = getRectPx().top()  + myItemHeight;
    return true;
}
Example #18
0
void initMenu(void)
{
	int isClear;
	scrollMenuIndex = alarmeringEnum;

	printf("checking memory for timezone\n");
	isClear = readEEPROM();
	if(isClear == 0)
	{
		printf("Timezone found\n");
		stateMenu = klokMenu;
		dateTimeInit();
	}else
	{
		printf("No Timezone found on EEPROM\n");
		stateMenu = setupMenu;
	}
	clearScreen();
	getMenuItem();
	initAudioMenu();
}
Example #19
0
//klok
void klokMenu(int input)
{
	updateM = 1;
	switch(input)
	{
	case KEY_OK:
		stateMenu = scrollMenu;
		clearScreen();
		break;
	case KEY_UP:
		changeUtcUp();
		break;
	case KEY_DOWN:
		changeUtcDown();
		break;
	default:
		updateM = 0;
		break;
	}
	if (updateM == 1)
	{
		getMenuItem();
	}
};
Example #20
0
void StGLButton::setLabel(const StString& theLabel) {
    StGLMenuItem* anItem = getMenuItem();
    if(anItem != NULL) {
        anItem->setText(theLabel);
    }
}
Example #21
0
static MenuItem *
getSelectedMenuItem (Menu *menu) {
  return getMenuItem(menu, menu->items.index);
}
Example #22
0
void StGLButton::setFocus(const bool theValue) {
    StGLMenuItem* anItem = getMenuItem();
    if(anItem != NULL) {
        anItem->setFocus(theValue);
    }
}
Example #23
0
void refresh()
{
	if(stateMenu == klokMenu){
		getMenuItem();
	}
}