QTfrontend/ui/widget/qpushbuttonwithsound.cpp
author sheepluva
Thu, 03 May 2012 12:33:08 +0200
changeset 7014 c0b32404ef74
parent 6930 d187ea93fc4f
child 7793 3c21da93db9f
permissions -rw-r--r--
+ display lack of map in a nice way, don't generate bogus preview in the background * improve map selection behavior in online mode, so that players can load a missing map and have it correctly selected after pressing F5 without any rejoin, map-reselection. also doesn't cause "different maps generated" anymore if map is missing, instead the person lacking the map gets "invalid genmap" and drops out of game immediatly

#include <QMessageBox>
#include <QDir>

#include "qpushbuttonwithsound.h"
#include "DataManager.h"
#include "SDLInteraction.h"
#include "hwform.h"
#include "gameuiconfig.h"

QPushButtonWithSound::QPushButtonWithSound(QWidget *parent) :
    QPushButton(parent),
    isSoundEnabled(true)
{
    connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked()));
}

void QPushButtonWithSound::buttonClicked()
{
    if ( !isSoundEnabled || !HWForm::config->isFrontendSoundEnabled())
        return;

    DataManager & dataMgr = DataManager::instance();

    if (this->isEnabled())
        SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead("Sounds/roperelease.ogg"));
}