#ifndef MESSAGE_DIALOG_H
#define MESSAGE_DIALOG_H

#include <QtGui>
#include "ui_messageDialog.h"
#include "softProj\settings.h"
#include <cassert>

///Shows dialog with important game messages. */
class MessageDialog : public QDialog {
	Q_OBJECT

private:
	Ui::MessageDialog ui_;
signals:
	void submitSignal();
private slots:
	void submitButtonClickedSlot(bool checked) {
		emit submitSignal();
	}
public:
	MessageDialog(QWidget * parent) : QDialog(parent) {
		ui_.setupUi(this);

		bool ok = QObject::connect(ui_.submitButton, SIGNAL(clicked(bool)), this, SLOT(submitButtonClickedSlot(bool)));

		assert(ok && "Signals not connected");
	}

	void setTitle(const std::wstring & value) {
		ui_.titleLabel->setText(QString::fromUtf16(value.c_str()));
	} /**<Sets message box title. */

	void setTitle(const std::string & value) {
		ui_.titleLabel->setText(QString::fromUtf8(value.c_str()));
	} /**<Sets message box title. */

	void setTitle(const QString & value) {
		ui_.titleLabel->setText(value);
	} /**<Sets message box title. */

	void setMessage(const std::wstring & value) {
		ui_.descriptionLabel->setText(QString::fromUtf16(value.c_str()));
	} /**<Sets message string. */

	void setMessage(const std::string & value) {
		ui_.descriptionLabel->setText(QString::fromUtf8(value.c_str()));
	} /**<Sets message string. */

	void setMessage(const QString & value) {
		ui_.descriptionLabel->setText(value);
	} /**<Sets message string. */


	void setSuccess(bool success) {
		if (success) {
			ui_.mainFrame->setProperty("mode", "success");
		}
		else {
			ui_.mainFrame->setProperty("mode", "failure");
		}

		ui_.mainFrame->setStyleSheet(ui_.mainFrame->styleSheet());
	}

	void setReasonByKey(const std::string & reason) {
		if (reason != "") {
			ui_.reasonLabel->setText(Settings::instance().getGameNameQString(reason));	
			ui_.reasonLabel->setVisible(true);
		}
		else {
			ui_.reasonLabel->setVisible(false);
		}
	}

	void setReason(const std::wstring & reason) {
		if (reason != L"") {
			ui_.reasonLabel->setText(QString::fromUtf16(reason.c_str()));	
			ui_.reasonLabel->setVisible(true);
		}
		else {
			ui_.reasonLabel->setVisible(false);
		}
	}

	void setIcon(const std::string & iconKey) {
		ui_.imageButton->setIcon(Settings::instance().getGameIcon(iconKey));
	}
};

#endif