source/MainGUI.cpp
/**
 * Slot which is emitted when a player joins the game.
 * Will play a sound if a VIP joins. A player is considered VIP if he is admin or on the friendlist.
 * Also requests additional player information from the statspage.
 *
 * @param playername The name of player.
 */
Slot which is emitted when a player joins the game.
Will play a sound if a VIP joins. A player is considered VIP if he is admin or on the friendlist.
Also requests additional player information from the statspage.

@param playername The name of player.
Slot which is emitted when a player joins the game . Will play a sound if a VIP joins . A player is considered VIP if he is admin or on the friendlist . Also requests additional player information from the statspage . @param playername The name of player .
void MainGUI::playerJoined (const ColoredMessage& playername)
{
    addMessage(ColoredMessage("[GAMEINFO] ", ColoredMessage::GAMEINFO), true, true, false);
    addMessage(ColoredMessage(playername), true, false, false);
    addMessage(ColoredMessage(" has joined the game.", ColoredMessage::GAMEINFO), true, false, true);
    if (playername.getColorType() == ColoredMessage::CUSTOM)
    {
        return;
    }
    if (gproxy->getUsername() != playername.getMessage() && isAdmin(playername.getMessage()))
    {
        QMediaPlayer* soundEffectTmp = new QMediaPlayer(qApp);
        soundEffectTmp->setMedia(QUrl::fromLocalFile("sounds/vip_joins.wav"));
        soundEffectTmp->play();
        soundEffectTmp->deleteLater();
    }
    else
    {
        for (int i = 0; i < widget.friendList->count(); i++)
        {
            if (widget.friendList->item(i)->text() == playername.getMessage())
            {
                QMediaPlayer* soundEffectTmp = new QMediaPlayer(qApp);
                soundEffectTmp->setMedia(QUrl::fromLocalFile("sounds/vip_joins.wav"));
                soundEffectTmp->play();
                soundEffectTmp->deleteLater();
                break;
            }
        }
    }
}
void MainGUI :: playerJoined ( const ColoredMessage & playername ) { addMessage ( ColoredMessage ( " " , ColoredMessage :: GAMEINFO ) , true , true , false ) ; addMessage ( ColoredMessage ( playername ) , true , false , false ) ; addMessage ( ColoredMessage ( " " , ColoredMessage :: GAMEINFO ) , true , false , true ) ; if ( playername . getColorType ( ) == ColoredMessage :: CUSTOM ) { return ; } if ( gproxy -> getUsername ( ) != playername . getMessage ( ) && isAdmin ( playername . getMessage ( ) ) ) { QMediaPlayer * soundEffectTmp = new QMediaPlayer ( qApp ) ; soundEffectTmp -> setMedia ( QUrl :: fromLocalFile ( " " ) ) ; soundEffectTmp -> play ( ) ; soundEffectTmp -> deleteLater ( ) ; } else { for ( int i = 0 ; i < widget . friendList -> count ( ) ; i ++ ) { if ( widget . friendList -> item ( i ) -> text ( ) == playername . getMessage ( ) ) { QMediaPlayer * soundEffectTmp = new QMediaPlayer ( qApp ) ; soundEffectTmp -> setMedia ( QUrl :: fromLocalFile ( " " ) ) ; soundEffectTmp -> play ( ) ; soundEffectTmp -> deleteLater ( ) ; break ; } } } }
Slot which is emitted when a player joins the game.
Slot which is emitted when a player joins the game .
// If the player has a colored name (hostbot), return. //statspage->getPlayerInformation(playername.getMessage()); //this works, as in the full audio is played and then it gets deleted (at least on windows 10 2018-04-05) // If the player is a friend -> play sound. //this works, as in the full audio is played and then it gets deleted (at least on windows 10 2018-04-05)