QTfrontend/pages.cpp
branchexperimental3D
changeset 4812 f924be23ffb4
parent 4345 2c93d6a10869
parent 4600 5a3b1dbdd4c9
child 4818 202eef454354
equal deleted inserted replaced
4347:0ddb100fea61 4812:f924be23ffb4
    38 #include <QAction>
    38 #include <QAction>
    39 #include <QMenu>
    39 #include <QMenu>
    40 #include <QDataWidgetMapper>
    40 #include <QDataWidgetMapper>
    41 #include <QTime>
    41 #include <QTime>
    42 #include <QSlider>
    42 #include <QSlider>
       
    43 #include <QFileDialog>
    43 
    44 
    44 #include "ammoSchemeModel.h"
    45 #include "ammoSchemeModel.h"
    45 #include "pages.h"
    46 #include "pages.h"
    46 #include "sdlkeys.h"
    47 #include "sdlkeys.h"
    47 #include "hwconsts.h"
    48 #include "hwconsts.h"
    61 #include "hats.h"
    62 #include "hats.h"
    62 #include "misc.h"
    63 #include "misc.h"
    63 #include "togglebutton.h"
    64 #include "togglebutton.h"
    64 #include "hwform.h"
    65 #include "hwform.h"
    65 #include "SDLs.h"
    66 #include "SDLs.h"
       
    67 #include "drawmapwidget.h"
    66 
    68 
    67 PageMain::PageMain(QWidget* parent) :
    69 PageMain::PageMain(QWidget* parent) :
    68   AbstractPage(parent)
    70   AbstractPage(parent)
    69 {
    71 {
    70     if(frontendEffects) setAttribute(Qt::WA_NoSystemBackground, true);
    72     if(frontendEffects) setAttribute(Qt::WA_NoSystemBackground, true);
   438 PageMultiplayer::PageMultiplayer(QWidget* parent) :
   440 PageMultiplayer::PageMultiplayer(QWidget* parent) :
   439   AbstractPage(parent)
   441   AbstractPage(parent)
   440 {
   442 {
   441     QGridLayout * pageLayout = new QGridLayout(this);
   443     QGridLayout * pageLayout = new QGridLayout(this);
   442 
   444 
   443     BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true);
   445     BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true);
   444 
   446 
   445     gameCFG = new GameCFGWidget(this);
   447     gameCFG = new GameCFGWidget(this);
   446     pageLayout->addWidget(gameCFG, 0, 0, 1, 2);
   448     pageLayout->addWidget(gameCFG, 0, 0, 1, 2);
   447 
   449 
   448     pageLayout->setRowStretch(1, 1);
   450     QPushButton * btnSetup = new QPushButton(this);
       
   451     btnSetup->setText(QPushButton::tr("Setup"));
       
   452     connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked()));
       
   453     pageLayout->addWidget(btnSetup, 1, 0, 1, 2);
       
   454 
       
   455     pageLayout->setRowStretch(2, 1);
   449 
   456 
   450     teamsSelect = new TeamSelWidget(this);
   457     teamsSelect = new TeamSelWidget(this);
   451     pageLayout->addWidget(teamsSelect, 0, 2, 2, 2);
   458     pageLayout->addWidget(teamsSelect, 0, 2, 3, 2);
   452 
   459 
   453     BtnStartMPGame = addButton(tr("Start"), pageLayout, 2, 3);
   460     BtnStartMPGame = addButton(tr("Start"), pageLayout, 3, 3);
   454 }
   461 }
   455 
   462 
   456 PageOptions::PageOptions(QWidget* parent) :
   463 PageOptions::PageOptions(QWidget* parent) :
   457   AbstractPage(parent)
   464   AbstractPage(parent)
   458 {
   465 {
   520 
   527 
   521             gbTBLayout->addWidget(teamsBox, 0, 0);
   528             gbTBLayout->addWidget(teamsBox, 0, 0);
   522         }
   529         }
   523 
   530 
   524         {
   531         {
   525             // TODO: This box should contain controls for all schemes: game modes and weapons
       
   526 
       
   527             IconedGroupBox* groupWeapons = new IconedGroupBox(this);
   532             IconedGroupBox* groupWeapons = new IconedGroupBox(this);
       
   533             
   528             //groupWeapons->setContentTopPadding(0);
   534             //groupWeapons->setContentTopPadding(0);
   529             //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   535             //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   530             groupWeapons->setIcon(QIcon(":/res/weaponsicon.png"));
   536             groupWeapons->setIcon(QIcon(":/res/weaponsicon.png"));
   531             groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
   537             groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
   532             groupWeapons->setTitle(QGroupBox::tr("Weapons"));
   538             groupWeapons->setTitle(QGroupBox::tr("Schemes and Weapons"));
   533             QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons);
   539             QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons);
   534 
   540 
       
   541             QLabel* SchemeLabel = new QLabel(groupWeapons);
       
   542             SchemeLabel->setText(QLabel::tr("Game scheme"));
       
   543             WeaponsLayout->addWidget(SchemeLabel, 1, 0);
       
   544 
       
   545             SchemesName = new QComboBox(groupWeapons);
       
   546             WeaponsLayout->addWidget(SchemesName, 1, 1);
       
   547 
       
   548             SchemeNew = new QPushButton(groupWeapons);
       
   549             SchemeNew->setToolTip(tr("New scheme"));
       
   550             SchemeNew->setIconSize(pmNew.size());
       
   551             SchemeNew->setIcon(pmNew);
       
   552             SchemeNew->setMaximumWidth(pmNew.width() + 6);
       
   553             WeaponsLayout->addWidget(SchemeNew, 1, 2);
       
   554 
       
   555             SchemeEdit = new QPushButton(groupWeapons);
       
   556             SchemeEdit->setToolTip(tr("Edit scheme"));
       
   557             SchemeEdit->setIconSize(pmEdit.size());
       
   558             SchemeEdit->setIcon(pmEdit);
       
   559             SchemeEdit->setMaximumWidth(pmEdit.width() + 6);
       
   560             WeaponsLayout->addWidget(SchemeEdit, 1, 3);
       
   561 
       
   562             SchemeDelete = new QPushButton(groupWeapons);
       
   563             SchemeDelete->setToolTip(tr("Delete scheme"));
       
   564             SchemeDelete->setIconSize(pmDelete.size());
       
   565             SchemeDelete->setIcon(pmDelete);
       
   566             SchemeDelete->setMaximumWidth(pmDelete.width() + 6);
       
   567             WeaponsLayout->addWidget(SchemeDelete, 1, 4);
       
   568 
       
   569             QLabel* WeaponLabel = new QLabel(groupWeapons);
       
   570             WeaponLabel->setText(QLabel::tr("Weapons"));
       
   571             WeaponsLayout->addWidget(WeaponLabel, 2, 0);
       
   572 
   535             WeaponsName = new QComboBox(groupWeapons);
   573             WeaponsName = new QComboBox(groupWeapons);
   536             WeaponsLayout->addWidget(WeaponsName, 0, 0);
   574             WeaponsLayout->addWidget(WeaponsName, 2, 1);
   537 
   575 
   538             WeaponsButt = new QPushButton(groupWeapons);
   576             WeaponNew = new QPushButton(groupWeapons);
   539             WeaponsButt->setToolTip(tr("New weapon scheme"));
   577             WeaponNew->setToolTip(tr("New weapon set"));
   540             WeaponsButt->setIconSize(pmNew.size());
   578             WeaponNew->setIconSize(pmNew.size());
   541             WeaponsButt->setIcon(pmNew);
   579             WeaponNew->setIcon(pmNew);
   542             WeaponsButt->setMaximumWidth(pmNew.width() + 6);
   580             WeaponNew->setMaximumWidth(pmNew.width() + 6);
   543             WeaponsLayout->addWidget(WeaponsButt, 0, 1);
   581             WeaponsLayout->addWidget(WeaponNew, 2, 2);
   544 
   582 
   545             WeaponEdit = new QPushButton(groupWeapons);
   583             WeaponEdit = new QPushButton(groupWeapons);
   546             WeaponEdit->setToolTip(tr("Edit weapon scheme"));
   584             WeaponEdit->setToolTip(tr("Edit weapon set"));
   547             WeaponEdit->setIconSize(pmEdit.size());
   585             WeaponEdit->setIconSize(pmEdit.size());
   548             WeaponEdit->setIcon(pmEdit);
   586             WeaponEdit->setIcon(pmEdit);
   549             WeaponEdit->setMaximumWidth(pmEdit.width() + 6);
   587             WeaponEdit->setMaximumWidth(pmEdit.width() + 6);
   550             WeaponsLayout->addWidget(WeaponEdit, 0, 2);
   588             WeaponsLayout->addWidget(WeaponEdit, 2, 3);
   551 
   589 
   552             WeaponDelete = new QPushButton(groupWeapons);
   590             WeaponDelete = new QPushButton(groupWeapons);
   553             WeaponDelete->setToolTip(tr("Delete weapon scheme"));
   591             WeaponDelete->setToolTip(tr("Delete weapon set"));
   554             WeaponDelete->setIconSize(pmDelete.size());
   592             WeaponDelete->setIconSize(pmDelete.size());
   555             WeaponDelete->setIcon(pmDelete);
   593             WeaponDelete->setIcon(pmDelete);
   556             WeaponDelete->setMaximumWidth(pmDelete.width() + 6);
   594             WeaponDelete->setMaximumWidth(pmDelete.width() + 6);
   557             WeaponDelete->setEnabled(false);
   595             WeaponsLayout->addWidget(WeaponDelete, 2, 4);
   558             WeaponDelete->setVisible(false); // hide for now
       
   559             WeaponsLayout->addWidget(WeaponDelete, 0, 3);
       
   560 
   596 
   561             WeaponTooltip = new QCheckBox(this);
   597             WeaponTooltip = new QCheckBox(this);
   562             WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips"));
   598             WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips"));
   563             WeaponsLayout->addWidget(WeaponTooltip, 1, 0, 1, 3);
   599             WeaponsLayout->addWidget(WeaponTooltip, 3, 0, 1, 4);
   564 
   600 
   565             gbTBLayout->addWidget(groupWeapons, 1, 0);
   601             gbTBLayout->addWidget(groupWeapons, 1, 0);
   566         }
   602         }
   567 
   603 
   568         {
   604         {
   940     pageLayout->setColumnStretch(1, 50);
   976     pageLayout->setColumnStretch(1, 50);
   941 
   977 
   942     // chatwidget
   978     // chatwidget
   943     pChatWidget = new HWChatWidget(this, gameSettings, sdli, true);
   979     pChatWidget = new HWChatWidget(this, gameSettings, sdli, true);
   944     pChatWidget->setShowReady(true); // show status bulbs by default
   980     pChatWidget->setShowReady(true); // show status bulbs by default
   945     pageLayout->addWidget(pChatWidget, 1, 0, 1, 2);
   981     pageLayout->addWidget(pChatWidget, 2, 0, 1, 2);
   946     pageLayout->setRowStretch(1, 100);
   982     pageLayout->setRowStretch(1, 100);
   947 
   983 
   948     pGameCFG = new GameCFGWidget(this);
   984     pGameCFG = new GameCFGWidget(this);
   949     pageLayout->addWidget(pGameCFG, 0, 0);
   985     pageLayout->addWidget(pGameCFG, 0, 0);
   950 
   986 
       
   987     QPushButton * btnSetup = new QPushButton(this);
       
   988     btnSetup->setText(QPushButton::tr("Setup"));
       
   989     connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked()));
       
   990     pageLayout->addWidget(btnSetup, 1, 0);
       
   991 
   951     pNetTeamsWidget = new TeamSelWidget(this);
   992     pNetTeamsWidget = new TeamSelWidget(this);
   952     pNetTeamsWidget->setAcceptOuter(true);
   993     pNetTeamsWidget->setAcceptOuter(true);
   953     pageLayout->addWidget(pNetTeamsWidget, 0, 1);
   994     pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1);
   954 
   995 
   955 
   996 
   956     QHBoxLayout * bottomLayout = new QHBoxLayout;
   997     QHBoxLayout * bottomLayout = new QHBoxLayout;
   957     pageLayout->addLayout(bottomLayout, 3, 0, 1, 2);
   998     pageLayout->addLayout(bottomLayout, 4, 0, 1, 2);
   958 
   999 
   959     BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true);
  1000     BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true);
   960 
  1001 
   961     BtnGo = new QPushButton(this);
  1002     BtnGo = new QPushButton(this);
   962     BtnGo->setToolTip(QPushButton::tr("Ready"));
  1003     BtnGo->setToolTip(QPushButton::tr("Ready"));
  1033     topLine->addStretch();
  1074     topLine->addStretch();
  1034 
  1075 
  1035 
  1076 
  1036     BtnCampaignPage = addButton(":/res/Campaign.png", middleLine, 0, true);
  1077     BtnCampaignPage = addButton(":/res/Campaign.png", middleLine, 0, true);
  1037     BtnCampaignPage->setToolTip(tr("Campaign Mode (...). IN DEVELOPMENT"));
  1078     BtnCampaignPage->setToolTip(tr("Campaign Mode (...). IN DEVELOPMENT"));
  1038     BtnCampaignPage->setVisible(false);
  1079     //BtnCampaignPage->setVisible(false);
  1039 
  1080 
  1040     BtnTrainPage = addButton(":/res/Trainings.png", middleLine, 1, true);
  1081     BtnTrainPage = addButton(":/res/Trainings.png", middleLine, 1, true);
  1041     BtnTrainPage->setToolTip(tr("Training Mode (Practice your skills in a range of training missions). IN DEVELOPMENT"));
  1082     BtnTrainPage->setToolTip(tr("Training Mode (Practice your skills in a range of training missions). IN DEVELOPMENT"));
  1042 
  1083 
  1043     BtnBack = addButton(":/res/Exit.png", bottomLine, 0, true);
  1084     BtnBack = addButton(":/res/Exit.png", bottomLine, 0, true);
  1067     tmpdir.cd(datadir->absolutePath());
  1108     tmpdir.cd(datadir->absolutePath());
  1068     tmpdir.cd("Missions/Training");
  1109     tmpdir.cd("Missions/Training");
  1069     tmpdir.setFilter(QDir::Files);
  1110     tmpdir.setFilter(QDir::Files);
  1070     CBSelect->addItems(tmpdir.entryList(QStringList("*.lua")).replaceInStrings(QRegExp("^(.*)\\.lua"), "\\1"));
  1111     CBSelect->addItems(tmpdir.entryList(QStringList("*.lua")).replaceInStrings(QRegExp("^(.*)\\.lua"), "\\1"));
  1071     for(int i = 0; i < CBSelect->count(); i++)
  1112     for(int i = 0; i < CBSelect->count(); i++)
       
  1113     {
  1072         CBSelect->setItemData(i, CBSelect->itemText(i));
  1114         CBSelect->setItemData(i, CBSelect->itemText(i));
       
  1115         CBSelect->setItemText(i, CBSelect->itemText(i).replace("_", " "));
       
  1116     }
  1073 
  1117 
  1074     pageLayout->addWidget(CBSelect, 1, 1);
  1118     pageLayout->addWidget(CBSelect, 1, 1);
  1075     
  1119     
  1076     BtnStartTrain = new QPushButton(this);
  1120     BtnStartTrain = new QPushButton(this);
  1077     BtnStartTrain->setFont(*font14);
  1121     BtnStartTrain->setFont(*font14);
  1108   AbstractPage(parent)
  1152   AbstractPage(parent)
  1109 {
  1153 {
  1110     QGridLayout * pageLayout = new QGridLayout(this);
  1154     QGridLayout * pageLayout = new QGridLayout(this);
  1111 
  1155 
  1112     pWeapons = new SelWeaponWidget(cAmmoNumber, this);
  1156     pWeapons = new SelWeaponWidget(cAmmoNumber, this);
  1113     pageLayout->addWidget(pWeapons, 0, 0, 1, 4);
  1157     pageLayout->addWidget(pWeapons, 0, 0, 1, 5);
  1114 
  1158 
  1115     BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true);
  1159     BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, 2, 1, true);
  1116     BtnDefault = addButton(tr("Default"), pageLayout, 1, 1);
  1160     BtnDefault = addButton(tr("Default"), pageLayout, 1, 3);
  1117     BtnDelete = addButton(tr("Delete"), pageLayout, 1, 2);
  1161     BtnNew = addButton(tr("New"), pageLayout, 1, 2);
  1118     BtnSave = addButton(":/res/Save.png", pageLayout, 1, 3, true);
  1162     BtnCopy = addButton(tr("Copy"), pageLayout, 2, 2);
       
  1163     BtnDelete = addButton(tr("Delete"), pageLayout, 2, 3);
       
  1164     BtnSave = addButton(":/res/Save.png", pageLayout, 1, 4, 2, 1, true);
  1119     BtnSave->setStyleSheet("QPushButton{margin: 24px 0px 0px 0px;}");
  1165     BtnSave->setStyleSheet("QPushButton{margin: 24px 0px 0px 0px;}");
  1120     BtnBack->setFixedHeight(BtnSave->height());
  1166     BtnBack->setFixedHeight(BtnSave->height());
  1121     BtnBack->setStyleSheet("QPushButton{margin-top: 31px;}");
  1167     BtnBack->setStyleSheet("QPushButton{margin-top: 31px;}");
  1122 
  1168 
       
  1169     selectWeaponSet = new QComboBox(this);
       
  1170     pageLayout->addWidget(selectWeaponSet, 1, 1, 2, 1);
       
  1171 
  1123     connect(BtnDefault, SIGNAL(clicked()), pWeapons, SLOT(setDefault()));
  1172     connect(BtnDefault, SIGNAL(clicked()), pWeapons, SLOT(setDefault()));
  1124     connect(BtnSave, SIGNAL(clicked()), pWeapons, SLOT(save()));
  1173     connect(BtnSave, SIGNAL(clicked()), pWeapons, SLOT(save()));
       
  1174     connect(BtnNew, SIGNAL(clicked()), pWeapons, SLOT(newWeaponsName()));
       
  1175     connect(BtnCopy, SIGNAL(clicked()), pWeapons, SLOT(copy()));
       
  1176     connect(selectWeaponSet, SIGNAL(currentIndexChanged(const QString&)), pWeapons, SLOT(setWeaponsName(const QString&)));
  1125 }
  1177 }
  1126 
  1178 
  1127 PageInGame::PageInGame(QWidget* parent) :
  1179 PageInGame::PageInGame(QWidget* parent) :
  1128   AbstractPage(parent)
  1180   AbstractPage(parent)
  1129 {
  1181 {
  1500     gb->setLayout(gl);
  1552     gb->setLayout(gl);
  1501     QSizePolicy sp;
  1553     QSizePolicy sp;
  1502     sp.setVerticalPolicy(QSizePolicy::MinimumExpanding);
  1554     sp.setVerticalPolicy(QSizePolicy::MinimumExpanding);
  1503     sp.setHorizontalPolicy(QSizePolicy::Expanding);
  1555     sp.setHorizontalPolicy(QSizePolicy::Expanding);
  1504 
  1556 
  1505     pageLayout->addWidget(gb, 1,0,13,4);
  1557     pageLayout->addWidget(gb, 1,0,13,5);
  1506 
  1558 
  1507     gbGameModes = new QGroupBox(QGroupBox::tr("Game Modifiers"), gb);
  1559     gbGameModes = new QGroupBox(QGroupBox::tr("Game Modifiers"), gb);
  1508     gbBasicSettings = new QGroupBox(QGroupBox::tr("Basic Settings"), gb);
  1560     gbBasicSettings = new QGroupBox(QGroupBox::tr("Basic Settings"), gb);
  1509 
  1561 
  1510     gbGameModes->setStyleSheet(".QGroupBox {"
  1562     gbGameModes->setStyleSheet(".QGroupBox {"
  1703     SB_HealthDecrease->setValue(5);
  1755     SB_HealthDecrease->setValue(5);
  1704     SB_HealthDecrease->setSingleStep(1);
  1756     SB_HealthDecrease->setSingleStep(1);
  1705     glBSLayout->addWidget(SB_HealthDecrease,5,2,1,1);
  1757     glBSLayout->addWidget(SB_HealthDecrease,5,2,1,1);
  1706 
  1758 
  1707     l = new QLabel(gbBasicSettings);
  1759     l = new QLabel(gbBasicSettings);
       
  1760     l->setText(QLabel::tr("% Rope Length"));
       
  1761     l->setWordWrap(true);
       
  1762     glBSLayout->addWidget(l,6,0,1,1);
       
  1763     l = new QLabel(gbBasicSettings);
       
  1764     l->setFixedSize(32,32);
       
  1765     l->setPixmap(QPixmap(":/res/iconRope.png"));
       
  1766     glBSLayout->addWidget(l,6,1,1,1);
       
  1767     SB_RopeModifier = new QSpinBox(gbBasicSettings);
       
  1768     SB_RopeModifier->setRange(25, 999);
       
  1769     SB_RopeModifier->setValue(100);
       
  1770     SB_RopeModifier->setSingleStep(25);
       
  1771     glBSLayout->addWidget(SB_RopeModifier,6,2,1,1);
       
  1772 
       
  1773     l = new QLabel(gbBasicSettings);
  1708     l->setText(QLabel::tr("Crate Drops"));
  1774     l->setText(QLabel::tr("Crate Drops"));
  1709     l->setWordWrap(true);
  1775     l->setWordWrap(true);
  1710     glBSLayout->addWidget(l,6,0,1,1);
  1776     glBSLayout->addWidget(l,7,0,1,1);
  1711     l = new QLabel(gbBasicSettings);
  1777     l = new QLabel(gbBasicSettings);
  1712     l->setFixedSize(32,32);
  1778     l->setFixedSize(32,32);
  1713     l->setPixmap(QPixmap(":/res/iconBox.png"));
  1779     l->setPixmap(QPixmap(":/res/iconBox.png"));
  1714     glBSLayout->addWidget(l,6,1,1,1);
  1780     glBSLayout->addWidget(l,7,1,1,1);
  1715     SB_CaseProb = new FreqSpinBox(gbBasicSettings);
  1781     SB_CaseProb = new FreqSpinBox(gbBasicSettings);
  1716     SB_CaseProb->setRange(0, 9);
  1782     SB_CaseProb->setRange(0, 9);
  1717     SB_CaseProb->setValue(5);
  1783     SB_CaseProb->setValue(5);
  1718     glBSLayout->addWidget(SB_CaseProb,6,2,1,1);
  1784     glBSLayout->addWidget(SB_CaseProb,7,2,1,1);
  1719 
  1785 
  1720     l = new QLabel(gbBasicSettings);
  1786     l = new QLabel(gbBasicSettings);
  1721     l->setText(QLabel::tr("% Health Crates"));
  1787     l->setText(QLabel::tr("% Health Crates"));
  1722     l->setWordWrap(true);
  1788     l->setWordWrap(true);
  1723     glBSLayout->addWidget(l,7,0,1,1);
  1789     glBSLayout->addWidget(l,8,0,1,1);
  1724     l = new QLabel(gbBasicSettings);
  1790     l = new QLabel(gbBasicSettings);
  1725     l->setFixedSize(32,32);
  1791     l->setFixedSize(32,32);
  1726     l->setPixmap(QPixmap(":/res/iconHealth.png")); // TODO: icon
  1792     l->setPixmap(QPixmap(":/res/iconHealth.png")); // TODO: icon
  1727     glBSLayout->addWidget(l,7,1,1,1);
  1793     glBSLayout->addWidget(l,8,1,1,1);
  1728     SB_HealthCrates = new QSpinBox(gbBasicSettings);
  1794     SB_HealthCrates = new QSpinBox(gbBasicSettings);
  1729     SB_HealthCrates->setRange(0, 100);
  1795     SB_HealthCrates->setRange(0, 100);
  1730     SB_HealthCrates->setValue(35);
  1796     SB_HealthCrates->setValue(35);
  1731     SB_HealthCrates->setSingleStep(5);
  1797     SB_HealthCrates->setSingleStep(5);
  1732     glBSLayout->addWidget(SB_HealthCrates,7,2,1,1);
  1798     glBSLayout->addWidget(SB_HealthCrates,8,2,1,1);
  1733 
  1799 
  1734     l = new QLabel(gbBasicSettings);
  1800     l = new QLabel(gbBasicSettings);
  1735     l->setText(QLabel::tr("Health in Crates"));
  1801     l->setText(QLabel::tr("Health in Crates"));
  1736     l->setWordWrap(true);
  1802     l->setWordWrap(true);
  1737     glBSLayout->addWidget(l,8,0,1,1);
  1803     glBSLayout->addWidget(l,9,0,1,1);
  1738     l = new QLabel(gbBasicSettings);
  1804     l = new QLabel(gbBasicSettings);
  1739     l->setFixedSize(32,32);
  1805     l->setFixedSize(32,32);
  1740     l->setPixmap(QPixmap(":/res/iconHealth.png")); // TODO: icon
  1806     l->setPixmap(QPixmap(":/res/iconHealth.png")); // TODO: icon
  1741     glBSLayout->addWidget(l,8,1,1,1);
  1807     glBSLayout->addWidget(l,9,1,1,1);
  1742     SB_CrateHealth = new QSpinBox(gbBasicSettings);
  1808     SB_CrateHealth = new QSpinBox(gbBasicSettings);
  1743     SB_CrateHealth->setRange(0, 200);
  1809     SB_CrateHealth->setRange(0, 200);
  1744     SB_CrateHealth->setValue(25);
  1810     SB_CrateHealth->setValue(25);
  1745     SB_CrateHealth->setSingleStep(5);
  1811     SB_CrateHealth->setSingleStep(5);
  1746     glBSLayout->addWidget(SB_CrateHealth,8,2,1,1);
  1812     glBSLayout->addWidget(SB_CrateHealth,9,2,1,1);
  1747 
  1813 
  1748     l = new QLabel(gbBasicSettings);
  1814     l = new QLabel(gbBasicSettings);
  1749     l->setText(QLabel::tr("Mines Time"));
  1815     l->setText(QLabel::tr("Mines Time"));
  1750     l->setWordWrap(true);
  1816     l->setWordWrap(true);
  1751     glBSLayout->addWidget(l,9,0,1,1);
  1817     glBSLayout->addWidget(l,10,0,1,1);
  1752     l = new QLabel(gbBasicSettings);
  1818     l = new QLabel(gbBasicSettings);
  1753     l->setFixedSize(32,32);
  1819     l->setFixedSize(32,32);
  1754     l->setPixmap(QPixmap(":/res/iconTime.png")); // TODO: icon
  1820     l->setPixmap(QPixmap(":/res/iconTime.png")); // TODO: icon
  1755     glBSLayout->addWidget(l,9,1,1,1);
  1821     glBSLayout->addWidget(l,10,1,1,1);
  1756     SB_MinesTime = new QSpinBox(gbBasicSettings);
  1822     SB_MinesTime = new QSpinBox(gbBasicSettings);
  1757     SB_MinesTime->setRange(-1, 5);
  1823     SB_MinesTime->setRange(-1, 5);
  1758     SB_MinesTime->setValue(3);
  1824     SB_MinesTime->setValue(3);
  1759     SB_MinesTime->setSingleStep(1);
  1825     SB_MinesTime->setSingleStep(1);
  1760     SB_MinesTime->setSpecialValueText(tr("Random"));
  1826     SB_MinesTime->setSpecialValueText(tr("Random"));
  1761     SB_MinesTime->setSuffix(" "+ tr("Seconds"));
  1827     SB_MinesTime->setSuffix(" "+ tr("Seconds"));
  1762     glBSLayout->addWidget(SB_MinesTime,9,2,1,1);
  1828     glBSLayout->addWidget(SB_MinesTime,10,2,1,1);
  1763 
  1829 
  1764     l = new QLabel(gbBasicSettings);
  1830     l = new QLabel(gbBasicSettings);
  1765     l->setText(QLabel::tr("Mines"));
  1831     l->setText(QLabel::tr("Mines"));
  1766     l->setWordWrap(true);
  1832     l->setWordWrap(true);
  1767     glBSLayout->addWidget(l,10,0,1,1);
  1833     glBSLayout->addWidget(l,11,0,1,1);
  1768     l = new QLabel(gbBasicSettings);
  1834     l = new QLabel(gbBasicSettings);
  1769     l->setFixedSize(32,32);
  1835     l->setFixedSize(32,32);
  1770     l->setPixmap(QPixmap(":/res/iconMine.png")); // TODO: icon
  1836     l->setPixmap(QPixmap(":/res/iconMine.png")); // TODO: icon
  1771     glBSLayout->addWidget(l,10,1,1,1);
  1837     glBSLayout->addWidget(l,11,1,1,1);
  1772     SB_Mines = new QSpinBox(gbBasicSettings);
  1838     SB_Mines = new QSpinBox(gbBasicSettings);
  1773     SB_Mines->setRange(0, 80);
  1839     SB_Mines->setRange(0, 80);
  1774     SB_Mines->setValue(0);
  1840     SB_Mines->setValue(0);
  1775     SB_Mines->setSingleStep(5);
  1841     SB_Mines->setSingleStep(5);
  1776     glBSLayout->addWidget(SB_Mines,10,2,1,1);
  1842     glBSLayout->addWidget(SB_Mines,11,2,1,1);
  1777 
  1843 
  1778     l = new QLabel(gbBasicSettings);
  1844     l = new QLabel(gbBasicSettings);
  1779     l->setText(QLabel::tr("% Dud Mines"));
  1845     l->setText(QLabel::tr("% Dud Mines"));
  1780     l->setWordWrap(true);
  1846     l->setWordWrap(true);
  1781     glBSLayout->addWidget(l,11,0,1,1);
  1847     glBSLayout->addWidget(l,12,0,1,1);
  1782     l = new QLabel(gbBasicSettings);
  1848     l = new QLabel(gbBasicSettings);
  1783     l->setFixedSize(32,32);
  1849     l->setFixedSize(32,32);
  1784     l->setPixmap(QPixmap(":/res/iconDud.png"));
  1850     l->setPixmap(QPixmap(":/res/iconDud.png"));
  1785     glBSLayout->addWidget(l,11,1,1,1);
  1851     glBSLayout->addWidget(l,12,1,1,1);
  1786     SB_MineDuds = new QSpinBox(gbBasicSettings);
  1852     SB_MineDuds = new QSpinBox(gbBasicSettings);
  1787     SB_MineDuds->setRange(0, 100);
  1853     SB_MineDuds->setRange(0, 100);
  1788     SB_MineDuds->setValue(0);
  1854     SB_MineDuds->setValue(0);
  1789     SB_MineDuds->setSingleStep(5);
  1855     SB_MineDuds->setSingleStep(5);
  1790     glBSLayout->addWidget(SB_MineDuds,11,2,1,1);
  1856     glBSLayout->addWidget(SB_MineDuds,12,2,1,1);
  1791 
  1857 
  1792 
  1858 
  1793     l = new QLabel(gbBasicSettings);
  1859     l = new QLabel(gbBasicSettings);
  1794     l->setText(QLabel::tr("Explosives"));
  1860     l->setText(QLabel::tr("Explosives"));
  1795     l->setWordWrap(true);
  1861     l->setWordWrap(true);
  1796     glBSLayout->addWidget(l,12,0,1,1);
  1862     glBSLayout->addWidget(l,13,0,1,1);
  1797     l = new QLabel(gbBasicSettings);
  1863     l = new QLabel(gbBasicSettings);
  1798     l->setFixedSize(32,32);
  1864     l->setFixedSize(32,32);
  1799     l->setPixmap(QPixmap(":/res/iconDamage.png"));
  1865     l->setPixmap(QPixmap(":/res/iconDamage.png"));
  1800     glBSLayout->addWidget(l,12,1,1,1);
  1866     glBSLayout->addWidget(l,13,1,1,1);
  1801     SB_Explosives = new QSpinBox(gbBasicSettings);
  1867     SB_Explosives = new QSpinBox(gbBasicSettings);
  1802     SB_Explosives->setRange(0, 40);
  1868     SB_Explosives->setRange(0, 40);
  1803     SB_Explosives->setValue(0);
  1869     SB_Explosives->setValue(0);
  1804     SB_Explosives->setSingleStep(1);
  1870     SB_Explosives->setSingleStep(1);
  1805     glBSLayout->addWidget(SB_Explosives,12,2,1,1);
  1871     glBSLayout->addWidget(SB_Explosives,13,2,1,1);
  1806 
       
  1807 
  1872 
  1808     l = new QLabel(gbBasicSettings);
  1873     l = new QLabel(gbBasicSettings);
  1809     l->setText(QLabel::tr("Scheme Name:"));
  1874     l->setText(QLabel::tr("Scheme Name:"));
  1810 
  1875 
  1811     LE_name = new QLineEdit(this);
  1876     LE_name = new QLineEdit(this);
  1814     gl->addWidget(l,14,0,1,1);
  1879     gl->addWidget(l,14,0,1,1);
  1815 
  1880 
  1816     mapper = new QDataWidgetMapper(this);
  1881     mapper = new QDataWidgetMapper(this);
  1817 
  1882 
  1818     BtnBack = addButton(":/res/Exit.png", pageLayout, 15, 0, true);
  1883     BtnBack = addButton(":/res/Exit.png", pageLayout, 15, 0, true);
  1819     BtnNew = addButton(tr("New"), pageLayout, 15, 2);
  1884     BtnCopy = addButton(tr("Copy"), pageLayout, 15, 2);
  1820     BtnDelete = addButton(tr("Delete"), pageLayout, 15, 3);
  1885     BtnNew = addButton(tr("New"), pageLayout, 15, 3);
       
  1886     BtnDelete = addButton(tr("Delete"), pageLayout, 15, 4);
  1821 
  1887 
  1822     selectScheme = new QComboBox(this);
  1888     selectScheme = new QComboBox(this);
  1823     pageLayout->addWidget(selectScheme, 15, 1);
  1889     pageLayout->addWidget(selectScheme, 15, 1);
  1824 
  1890 
       
  1891     connect(BtnCopy, SIGNAL(clicked()), this, SLOT(copyRow()));
  1825     connect(BtnNew, SIGNAL(clicked()), this, SLOT(newRow()));
  1892     connect(BtnNew, SIGNAL(clicked()), this, SLOT(newRow()));
  1826     connect(BtnDelete, SIGNAL(clicked()), this, SLOT(deleteRow()));
  1893     connect(BtnDelete, SIGNAL(clicked()), this, SLOT(deleteRow()));
  1827     connect(selectScheme, SIGNAL(currentIndexChanged(int)), mapper, SLOT(setCurrentIndex(int)));
  1894     connect(selectScheme, SIGNAL(currentIndexChanged(int)), mapper, SLOT(setCurrentIndex(int)));
  1828     connect(selectScheme, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeSelected(int)));
  1895     connect(selectScheme, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeSelected(int)));
  1829 }
  1896 }
  1868     mapper->addMapping(SB_Explosives, 32);
  1935     mapper->addMapping(SB_Explosives, 32);
  1869     mapper->addMapping(SB_HealthCrates, 33);
  1936     mapper->addMapping(SB_HealthCrates, 33);
  1870     mapper->addMapping(SB_CrateHealth, 34);
  1937     mapper->addMapping(SB_CrateHealth, 34);
  1871     mapper->addMapping(SB_WaterRise, 35);
  1938     mapper->addMapping(SB_WaterRise, 35);
  1872     mapper->addMapping(SB_HealthDecrease, 36);
  1939     mapper->addMapping(SB_HealthDecrease, 36);
       
  1940     mapper->addMapping(SB_RopeModifier, 37);
  1873 
  1941 
  1874     mapper->toFirst();
  1942     mapper->toFirst();
  1875 }
  1943 }
  1876 
  1944 
  1877 void PageScheme::newRow()
  1945 void PageScheme::newRow()
  1878 {
  1946 {
  1879     QAbstractItemModel * model = mapper->model();
  1947     QAbstractItemModel * model = mapper->model();
  1880     model->insertRow(model->rowCount());
  1948     model->insertRow(-1);
  1881     selectScheme->setCurrentIndex(model->rowCount() - 1);
  1949     selectScheme->setCurrentIndex(model->rowCount() - 1);
  1882 }
  1950 }
  1883 
  1951 
       
  1952 void PageScheme::copyRow()
       
  1953 {
       
  1954     QAbstractItemModel * model = mapper->model();
       
  1955     model->insertRow(selectScheme->currentIndex());
       
  1956     selectScheme->setCurrentIndex(model->rowCount() - 1);
       
  1957 }
       
  1958 
  1884 void PageScheme::deleteRow()
  1959 void PageScheme::deleteRow()
  1885 {
  1960 {
  1886     QAbstractItemModel * model = mapper->model();
  1961     QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Schemes"), QMessageBox::tr("Really delete this game scheme?"), QMessageBox::Ok | QMessageBox::Cancel);
  1887     model->removeRow(selectScheme->currentIndex());
  1962 
       
  1963     if (reallyDelete.exec() == QMessageBox::Ok) {
       
  1964         QAbstractItemModel * model = mapper->model();
       
  1965         model->removeRow(selectScheme->currentIndex());
       
  1966     }
  1888 }
  1967 }
  1889 
  1968 
  1890 void PageScheme::schemeSelected(int n)
  1969 void PageScheme::schemeSelected(int n)
  1891 {
  1970 {
  1892     int c = ((AmmoSchemeModel*)mapper->model())->numberOfDefaultSchemes;
  1971     int c = ((AmmoSchemeModel*)mapper->model())->numberOfDefaultSchemes;
  1991     // hack: temporary deactivated - requires server modifications that aren't backward compatible (yet)
  2070     // hack: temporary deactivated - requires server modifications that aren't backward compatible (yet)
  1992     //BtnOfficialServer->setEnabled(false);
  2071     //BtnOfficialServer->setEnabled(false);
  1993 
  2072 
  1994     BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true);
  2073     BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true);
  1995 }
  2074 }
       
  2075 
       
  2076 /////////////////////////////////////////////////
       
  2077 
       
  2078 PageDrawMap::PageDrawMap(QWidget* parent) : AbstractPage(parent)
       
  2079 {
       
  2080     QGridLayout * pageLayout = new QGridLayout(this);
       
  2081 
       
  2082     QPushButton * pbUndo = addButton(tr("Undo"), pageLayout, 0, 0);
       
  2083     QPushButton * pbClear = addButton(tr("Clear"), pageLayout, 1, 0);
       
  2084     QPushButton * pbLoad = addButton(tr("Load"), pageLayout, 2, 0);
       
  2085     QPushButton * pbSave = addButton(tr("Save"), pageLayout, 3, 0);
       
  2086 
       
  2087     BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true);
       
  2088 
       
  2089     drawMapWidget = new DrawMapWidget(this);
       
  2090     pageLayout->addWidget(drawMapWidget, 0, 1, 5, 1);
       
  2091 
       
  2092     connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo()));
       
  2093     connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear()));
       
  2094     connect(pbLoad, SIGNAL(clicked()), this, SLOT(load()));
       
  2095     connect(pbSave, SIGNAL(clicked()), this, SLOT(save()));
       
  2096 }
       
  2097 
       
  2098 void PageDrawMap::load()
       
  2099 {
       
  2100     QString fileName = QFileDialog::getOpenFileName(this, tr("Load drawn map"), ".", tr("Drawn Maps (*.hwmap);;All files (*.*)"));
       
  2101 
       
  2102     if(!fileName.isEmpty())
       
  2103         drawMapWidget->load(fileName);
       
  2104 }
       
  2105 
       
  2106 void PageDrawMap::save()
       
  2107 {
       
  2108     QString fileName = QFileDialog::getSaveFileName(this, tr("Save drawn map"), ".", tr("Drawn Maps (*.hwmap);;All files (*.*)"));
       
  2109 
       
  2110     if(!fileName.isEmpty())
       
  2111         drawMapWidget->save(fileName);
       
  2112 }