示例#1
0
void PlayersListModel::setFlag(const QString &nickname, StateFlag flagType, bool isSet)
{
    if(flagType == Friend)
    {
        if(isSet)
            m_friendsSet.insert(nickname.toLower());
        else
            m_friendsSet.remove(nickname.toLower());

        saveSet(m_friendsSet, "friends");
    }
    else if(flagType == Ignore)
    {
        if(isSet)
            m_ignoredSet.insert(nickname.toLower());
        else
            m_ignoredSet.remove(nickname.toLower());

        saveSet(m_ignoredSet, "ignore");
    }

    QModelIndex mi = nicknameIndex(nickname);

    if(mi.isValid())
    {
        setData(mi, isSet, flagType);

        if(flagType == Friend || flagType == ServerAdmin
                || flagType == Ignore || flagType == RoomAdmin)
            updateSortData(mi);

        updateIcon(mi);
    }
}
示例#2
0
文件: cmd.c 项目: vscuorzo/mandest
void checkCommands(Uint8 *keys, int *mx, int *my)
{
	int i = 0;
	SDL_Rect dest;

	if(HUD.menu == 0)
	{
		// Pan around map
		if( ((*mx > (screen->clip_rect.x+screen->w-15)) || keys[SDLK_RIGHT]) && (Camera.x + 25*sSpeed + Camera.w) < (map->clip_rect.x+map->w) )
		{
			Camera.x += 25*sSpeed;
		}
		else if( ((*mx < (screen->clip_rect.x+15)) || keys[SDLK_LEFT]) && (Camera.x - 25*sSpeed > map->clip_rect.x) )
		{
			Camera.x -= 25*sSpeed;
		}

		if( ((*my > (screen->clip_rect.y+screen->h-15)) || keys[SDLK_DOWN] ) && (Camera.y + 25*sSpeed + Camera.h) < (map->clip_rect.y+map->h) )
		{
			Camera.y += 25*sSpeed;
		}
		else if( ((*my < (screen->clip_rect.y+15)) || keys[SDLK_UP] ) && ((Camera.y - 25*sSpeed) > map->clip_rect.y) )
		{
			Camera.y -= 25*sSpeed;
		}

		// Save the HUD settings
		if(keys[SDLK_h])
		{
			saveSet();
			fprintf(stderr,"HUD saved to hud.txt\n");
		}

		if(HUD.grabPanel == 0)
		{
			if(SDL_GetMouseState(NULL,NULL)&SDL_BUTTON_LMASK)
			{
				selectEnt(*mx, *my);
			}
			
			if(SDL_GetMouseState(NULL,NULL)&SDL_BUTTON_RMASK)
			{
				if(players[0].sEnt != NULL)
					orderEnt(*mx, *my);
			}
		}

		// HUD
		if(SDL_GetMouseState(NULL,NULL)&SDL_BUTTON_LMASK)
		{
			// ADD Minimap

			// Infobar
			i = -1;
			while(++i<MAX_UNIT_TYPES)
			{
				if( !HUD.aUnits[i].draw )
					continue;

				//fprintf(stderr,"%i\n",bCollide(&HUD.aUnits[i],*mx,*my));
				if(bCollide(&HUD.aUnits[i],*mx,*my))
				{
					HUD.aUnits[i].action(i);
					fprintf(stderr,"unit button pressed\n");
					break;
				}
			}

			i = -1;
			while(++i<MAX_STRUCT_TYPES) 
			{
				if( !HUD.aStructs[i].draw )
					continue;

				if(bCollide(&HUD.aStructs[i],*mx,*my))
				{
					HUD.aStructs[i].action(i);
					fprintf(stderr,"Structure %i button pressed\n",i);
					break;
				}
			}
			
			// Music Player
			i = -1;
			while(++i < 4) 
			{
				if( !HUD.pButtons[i].draw )
					continue;

				if(bCollide(&HUD.pButtons[i],*mx,*my))
				{
					HUD.pButtons[i].action(i);
					fprintf(stderr,"player button pressed\n");
					break;
				}
			}
		}
	}

	// menu
	if(keys[SDLK_ESCAPE])
	{
		HUD.menu = 1;
	}
	if(keys[SDLK_SPACE])
	{
		if(HUD.pButtons[0].tip.info == NULL)
			return;

		dest.x = HUD.pButtons[0].x + 5;
		dest.y = HUD.pButtons[0].y - HUD.pButtons[0].tip.bbox->h;
		dest.w = HUD.pButtons[0].tip.bbox->w;
		dest.h = HUD.pButtons[0].tip.bbox->h;
		SDL_BlitSurface(HUD.pButtons[0].tip.bbox, NULL, screen, &dest);
	}
}