Ejemplo n.º 1
0
static void setupMenu(void)
{
    clearMenuItems();
    if (state == STATE_PLAYING) {
        addMenuItem(F("CONTINUE"), onMenuContine);
    }
    addMenuItem(F("RESTART"), onMenuRestart);
    int menuW;
    if (gameMode == GAME_MODE_PUZZLE) {
        if (issue < COUNT_ISSUES - 1) addMenuItem(F("NEXT ISSUE"), onMenuNextIssue);
        if (issue > 0) addMenuItem(F("PREV ISSUE"), onMenuPreviousIssue);
        addMenuItem(F("ISSUES LIST"), onMenuSelectIssue);
        menuW = 77;
    } else {
        addMenuItem(F("BACK TO TITLE"), onMenuBackToTitle);
        menuW = 89;
    }
    int menuH = getMenuItemCount() * 6 - 1;
    int menuY;
    bool flg;
    if (state == STATE_OVER) {
        menuY = 53;
        flg = false;
        state = STATE_RESULT;
    } else {
        menuY = 31 - menuH / 2;
        flg = true;
        state = STATE_MENU;
    }
    setMenuCoords(63 - menuW / 2, menuY, menuW, menuH, flg, flg);
    setMenuItemPos(0);
    playSoundClick();
}
Ejemplo n.º 2
0
// By rebuilding everything every tick, menus can be dynamically updated
void PlayerMenuUserInterface::idle(U32 timeDelta)
{
   clearMenuItems();

   GameConnection *conn = getGame()->getConnectionToServer();
   if(!conn)
      return;

   char c[] = "A";      // Dummy shortcut key
   for(S32 i = 0; i < getGame()->getClientCount(); i++)
   {
      ClientInfo *clientInfo = ((Game *)getGame())->getClientInfo(i);      // Lame!

      strncpy(c, clientInfo->getName().getString(), 1);        // Grab first char of name for a shortcut key

      // Will be used to show admin/player/robot prefix on menu
      PlayerType pt = clientInfo->isRobot() ? PlayerTypeRobot : (clientInfo->isAdmin() ? PlayerTypeAdmin : PlayerTypePlayer);    

      PlayerMenuItem *newItem = new PlayerMenuItem(i, clientInfo->getName().getString(), playerSelectedCallback, 
                                                   InputCodeManager::stringToInputCode(c), pt);
      newItem->setUnselectedColor(getGame()->getTeamColor(clientInfo->getTeamIndex()));

      addMenuItem(newItem);
   }

   sortMenuItems();

   if(action == PlayerActionKick)
      mMenuTitle = "CHOOSE PLAYER TO KICK";
   else if(action == PlayerActionChangeTeam)
      mMenuTitle = "CHOOSE WHOSE TEAM TO CHANGE";
   else
      TNLAssert(false, "Unknown action!");
}
Ejemplo n.º 3
0
void PlaylistMenuUserInterface::onActivate()
{
   Parent::onActivate();
   mMenuTitle = "CHOOSE PLAYLIST";

   // Replace with a getLevelCount() method on Game?
   ClientGame *game = getGame();

   Vector<string> playlists = getPlaylists();

   clearMenuItems();

   // Any items to select from?
   if(playlists.size() > 0)
   {
      char c[2];
      c[1] = 0;   // null termination

      for(S32 i = 0; i < playlists.size(); i++)
      {
         if(playlists[i] == "")   // Skip blanks, but there should be none
            continue;

         string playlistName = playlists[i];
         c[0] = playlistName[0];
         addMenuItem(new MenuItem(i, playlistName, processPlaylistSelectionCallback, "", InputCodeManager::stringToInputCode(c)));
      }

      sortMenuItems();
   }

   addMenuItem(new MenuItem(playlists.size(), NO_PLAYLIST, processPlaylistSelectionCallback, "", InputCodeManager::stringToInputCode("N")));
}
Ejemplo n.º 4
0
	void MenuItemManager::reloadAssemblyData()
	{
		clearMenuItems();

		// Reload MenuItem attribute from editor assembly
		MonoAssembly* editorAssembly = MonoManager::instance().getAssembly(EDITOR_ASSEMBLY);
		mMenuItemAttribute = editorAssembly->getClass(EDITOR_NS, "MenuItem");
		if (mMenuItemAttribute == nullptr)
			BS_EXCEPT(InvalidStateException, "Cannot find MenuItem managed class.");

		mPathField = mMenuItemAttribute->getField("path");
		mShortcutField = mMenuItemAttribute->getField("shortcut");
		mPriorityField = mMenuItemAttribute->getField("priority");
		mSeparatorField = mMenuItemAttribute->getField("separator");

		MainEditorWindow* mainWindow = EditorWindowManager::instance().getMainWindow();

		Vector<String> scriptAssemblyNames = mScriptObjectManager.getScriptAssemblies();
		for (auto& assemblyName : scriptAssemblyNames)
		{
			MonoAssembly* assembly = MonoManager::instance().getAssembly(assemblyName);

			// Find new menu item methods
			const Vector<MonoClass*>& allClasses = assembly->getAllClasses();
			for (auto curClass : allClasses)
			{
				const Vector<MonoMethod*>& methods = curClass->getAllMethods();
				for (auto& curMethod : methods)
				{
					String path;
					ShortcutKey shortcutKey = ShortcutKey::NONE;
					INT32 priority = 0;
					bool separator = false;
					if (parseMenuItemMethod(curMethod, path, shortcutKey, priority, separator))
					{
						std::function<void()> callback = std::bind(&MenuItemManager::menuItemCallback, curMethod);

						if (separator)
						{
							Vector<String> pathElements = StringUtil::split(path, "/");
							String separatorPath;
							if (pathElements.size() > 1)
							{
								const String& lastElem = pathElements[pathElements.size() - 1];
								separatorPath = path;
								separatorPath.erase(path.size() - lastElem.size() - 1, lastElem.size() + 1);
							}

							GUIMenuItem* separatorItem = mainWindow->getMenuBar().addMenuItemSeparator(separatorPath, priority);
							mMenuItems.push_back(separatorItem);
						}

						GUIMenuItem* menuItem = mainWindow->getMenuBar().addMenuItem(path, callback, priority, shortcutKey);
						mMenuItems.push_back(menuItem);
					}
				}
			}
		}
	}
Ejemplo n.º 5
0
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);
   }
}
Ejemplo n.º 6
0
void ItemListSelectUserInterface::onActivate()
{
   Parent::onActivate();

   mNameSoFar = "";
   mStillTypingNameTimer.clear();

   clearMenuItems();    // We'll repopulate below...

   if(mItemSelectedWithMouse)
      onMouseMoved();
   //else
   //   mSelectedIndex = 0;
}
Ejemplo n.º 7
0
void ContextMenu::defaultValues() {
    clearMenuItems();
    contextMenuItems.append(CONTEXT_MENU_DEFAULT_NAME);
    contextMenuActions.append(CONTEXT_MENU_DEFAULT_ACTION);
}