QTfrontend/ui/page/pageeditteam.cpp
author m4tx
Sun, 11 Dec 2011 23:15:06 +0300
changeset 6525 6c97379c584b
parent 6212 a5d95f32e17f
child 6616 f77bb02b669f
permissions -rw-r--r--
[GCI] backz task: unify the back button functionality, avoid using the save button
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     1
/*
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     3
 * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     4
 *
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     8
 *
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    12
 * GNU General Public License for more details.
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    13
 *
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    17
 */
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    18
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    19
#include <QGridLayout>
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
    20
#include <QHBoxLayout>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    21
#include <QPushButton>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    22
#include <QComboBox>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    23
#include <QLabel>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    24
#include <QLineEdit>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    25
#include <QTabWidget>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    26
#include <QGroupBox>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    27
#include <QToolBox>
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
    28
#include <QMessageBox>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    29
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    30
#include "sdlkeys.h"
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    31
#include "SquareLabel.h"
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    32
#include "hats.h"
5252
ded882439548 file association for mac!
koda
parents: 5238
diff changeset
    33
#include "HWApplication.h"
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
    34
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
    35
#include "HWDataManager.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    36
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
    37
#include "pageeditteam.h"
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
    38
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
    39
QLayout * PageEditTeam::bodyLayoutDefinition()
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    40
{
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
    41
    QGridLayout * pageLayout = new QGridLayout();
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
    42
    QTabWidget * tbw = new QTabWidget();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    43
    QWidget * page1 = new QWidget(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    44
    QWidget * page2 = new QWidget(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    45
    tbw->addTab(page1, tr("General"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    46
    tbw->addTab(page2, tr("Advanced"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    47
    pageLayout->addWidget(tbw, 0, 0, 1, 3);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
    48
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    49
    QHBoxLayout * page1Layout = new QHBoxLayout(page1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    50
    page1Layout->setAlignment(Qt::AlignTop);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    51
    QGridLayout * page2Layout = new QGridLayout(page2);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    52
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    53
// ====== Page 1 ======
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    54
    QVBoxLayout * vbox1 = new QVBoxLayout();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    55
    QVBoxLayout * vbox2 = new QVBoxLayout();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    56
    page1Layout->addLayout(vbox1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    57
    page1Layout->addLayout(vbox2);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    58
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    59
    GBoxHedgehogs = new QGroupBox(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    60
    GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    61
    GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    62
    QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    63
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    64
    HatsModel * hatsModel = new HatsModel(GBoxHedgehogs);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
    65
    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    66
    {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    67
        HHHats[i] = new QComboBox(GBoxHedgehogs);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    68
        HHHats[i]->setModel(hatsModel);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    69
        HHHats[i]->setIconSize(QSize(32, 37));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    70
        //HHHats[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    71
        //HHHats[i]->setModelColumn(1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    72
        //HHHats[i]->setMinimumWidth(132);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    73
        GBHLayout->addWidget(HHHats[i], i, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    74
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    75
        HHNameEdit[i] = new QLineEdit(GBoxHedgehogs);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    76
        HHNameEdit[i]->setMaxLength(64);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    77
        HHNameEdit[i]->setMinimumWidth(120);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    78
        GBHLayout->addWidget(HHNameEdit[i], i, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    79
6200
6a4ace88d85a tweak and document abstract page
sheepluva
parents: 6196
diff changeset
    80
        btnRandomHogName[i] = addButton(":/res/dice.png", GBHLayout, i, 3, 1, 1, true);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    81
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    82
6212
a5d95f32e17f few mini-adjustments
sheepluva
parents: 6200
diff changeset
    83
    btnRandomTeam = addButton(QPushButton::tr("Random Team"), GBHLayout, 9, 0);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    84
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    85
    vbox1->addWidget(GBoxHedgehogs);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    86
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    87
    GBoxTeam = new QGroupBox(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    88
    GBoxTeam->setTitle(QGroupBox::tr("Team Settings"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    89
    GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    90
    QGridLayout * GBTLayout = new QGridLayout(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    91
    QLabel * tmpLabel = new QLabel(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    92
    tmpLabel->setText(QLabel::tr("Name"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    93
    GBTLayout->addWidget(tmpLabel, 0, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    94
    tmpLabel = new QLabel(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    95
    tmpLabel->setText(QLabel::tr("Type"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    96
    GBTLayout->addWidget(tmpLabel, 1, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    97
    tmpLabel = new QLabel(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    98
    tmpLabel->setText(QLabel::tr("Grave"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    99
    GBTLayout->addWidget(tmpLabel, 2, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   100
    tmpLabel = new QLabel(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   101
    tmpLabel->setText(QLabel::tr("Flag"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   102
    GBTLayout->addWidget(tmpLabel, 3, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   103
    tmpLabel = new QLabel(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   104
    tmpLabel->setText(QLabel::tr("Voice"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   105
    GBTLayout->addWidget(tmpLabel, 4, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   106
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   107
    TeamNameEdit = new QLineEdit(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   108
    TeamNameEdit->setMaxLength(64);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   109
    GBTLayout->addWidget(TeamNameEdit, 0, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   110
    vbox2->addWidget(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   111
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   112
    CBTeamLvl = new QComboBox(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   113
    CBTeamLvl->setIconSize(QSize(48, 48));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   114
    CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   115
    for(int i = 5; i > 0; i--)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   116
        CBTeamLvl->addItem(
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   117
                QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)),
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   118
                QString("%1 %2").arg(QComboBox::tr("Level")).arg(i)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   119
                );
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   120
    GBTLayout->addWidget(CBTeamLvl, 1, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   121
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   122
    CBGrave = new QComboBox(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   123
    CBGrave->setMaxCount(65535);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   124
    CBGrave->setIconSize(QSize(32, 32));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   125
    GBTLayout->addWidget(CBGrave, 2, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   126
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   127
    CBFlag = new QComboBox(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   128
    CBFlag->setMaxCount(65535);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   129
    CBFlag->setIconSize(QSize(22, 15));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   130
    GBTLayout->addWidget(CBFlag, 3, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   131
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   132
    QHBoxLayout * hbox = new QHBoxLayout();
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   133
    CBVoicepack = new QComboBox(GBoxTeam);
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5204
diff changeset
   134
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   135
    hbox->addWidget(CBVoicepack, 100);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   136
    btnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   137
    hbox->setStretchFactor(btnTestSound, 1);
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5204
diff changeset
   138
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   139
    GBTLayout->addLayout(hbox, 4, 1);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   140
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   141
    GBoxFort = new QGroupBox(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   142
    GBoxFort->setTitle(QGroupBox::tr("Fort"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   143
    QGridLayout * GBFLayout = new QGridLayout(GBoxFort);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   144
    CBFort = new QComboBox(GBoxFort);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   145
    CBFort->setMaxCount(65535);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   146
    GBFLayout->addWidget(CBFort, 0, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   147
    FortPreview = new SquareLabel(GBoxFort);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   148
    FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   149
    FortPreview->setMinimumSize(128, 128);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   150
    FortPreview->setPixmap(QPixmap());
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   151
    // perhaps due to handling its own paintevents, SquareLabel doesn't play nice with the stars
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   152
    //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   153
    GBFLayout->addWidget(FortPreview, 1, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   154
    vbox2->addWidget(GBoxFort);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   155
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   156
    vbox1->addStretch();
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   157
    vbox2->addStretch();
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   158
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   159
// ====== Page 2 ======
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   160
    GBoxBinds = new QGroupBox(this);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   161
    GBoxBinds->setTitle(QGroupBox::tr("Key binds"));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   162
    QGridLayout * GBBLayout = new QGridLayout(GBoxBinds);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   163
    BindsBox = new QToolBox(GBoxBinds);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   164
    BindsBox->setLineWidth(0);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   165
    GBBLayout->addWidget(BindsBox);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   166
    page2Layout->addWidget(GBoxBinds, 0, 0);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   167
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   168
    quint16 i = 0;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   169
    quint16 num = 0;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   170
    QWidget * curW = NULL;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   171
    QGridLayout * pagelayout = NULL;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   172
    QLabel* l = NULL;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   173
    while (i < BINDS_NUMBER) {
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   174
        if(cbinds[i].category != NULL)
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   175
        {
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   176
            if(curW != NULL)
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   177
            {
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   178
                l = new QLabel(curW);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   179
                l->setText("");
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   180
                pagelayout->addWidget(l, num++, 0, 1, 2);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   181
            }
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   182
            curW = new QWidget(this);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   183
            BindsBox->addItem(curW, HWApplication::translate("binds (categories)", cbinds[i].category));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   184
            pagelayout = new QGridLayout(curW);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   185
            num = 0;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   186
        }
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   187
        if(cbinds[i].description != NULL)
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   188
        {
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   189
            l = new QLabel(curW);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   190
            l->setText((num > 0 ? QString("\n") : QString("")) + HWApplication::translate("binds (descriptions)", cbinds[i].description));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   191
            pagelayout->addWidget(l, num++, 0, 1, 2);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   192
        }
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   193
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   194
        l = new QLabel(curW);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   195
        l->setText(HWApplication::translate("binds", cbinds[i].name));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   196
        l->setAlignment(Qt::AlignRight);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   197
        pagelayout->addWidget(l, num, 0);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   198
        CBBind[i] = new QComboBox(curW);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   199
        for(int j = 0; sdlkeys[j][1][0] != '\0'; j++)
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   200
            CBBind[i]->addItem(HWApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? HWApplication::translate("binds (keys)", sdlkeys[j][1]) : HWApplication::translate("binds (keys)", "Keyboard") + QString(": ") + HWApplication::translate("binds (keys)", sdlkeys[j][1]), sdlkeys[j][0]);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   201
        pagelayout->addWidget(CBBind[i++], num++, 1);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   202
    }
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   203
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   204
    return pageLayout;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   205
}
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   206
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   207
QLayout * PageEditTeam::footerLayoutDefinition()
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   208
{
6525
6c97379c584b [GCI] backz task: unify the back button functionality, avoid using the save button
m4tx
parents: 6212
diff changeset
   209
    return NULL;
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   210
}
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   211
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   212
void PageEditTeam::connectSignals()
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   213
{
6525
6c97379c584b [GCI] backz task: unify the back button functionality, avoid using the save button
m4tx
parents: 6212
diff changeset
   214
    connect(this, SIGNAL(goBack()), this, SLOT(saveTeam()));
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   215
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   216
    signalMapper1 = new QSignalMapper(this);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   217
    signalMapper2 = new QSignalMapper(this);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   218
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   219
    connect(signalMapper1, SIGNAL(mapped(int)), this, SLOT(fixHHname(int)));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   220
    connect(signalMapper2, SIGNAL(mapped(int)), this, SLOT(setRandomName(int)));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   221
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   222
    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   223
    {
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   224
        connect(HHNameEdit[i], SIGNAL(editingFinished()), signalMapper1, SLOT(map()));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   225
            signalMapper1->setMapping(HHNameEdit[i], i);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   226
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   227
        connect(btnRandomHogName[i], SIGNAL(clicked()), signalMapper2, SLOT(map()));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   228
            signalMapper2->setMapping(btnRandomHogName[i], i);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   229
    }
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   230
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   231
    connect(btnRandomTeam, SIGNAL(clicked()), this, SLOT(setRandomNames()));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   232
    
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   233
    connect(btnTestSound, SIGNAL(clicked()), this, SLOT(testSound()));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   234
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   235
    connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &)));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   236
}
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   237
6165
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   238
PageEditTeam::PageEditTeam(QWidget* parent) :
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   239
  AbstractPage(parent)
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   240
{
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   241
    initPage();
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   242
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   243
    QRegExp pngSuffix("\\.png$");
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   244
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   245
    m_playerHash = "0000000000000000000000000000000000000000";
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   246
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   247
    HWDataManager & dataMgr = HWDataManager::instance();
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   248
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   249
    QStringList list;
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   250
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   251
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   252
    // voicepacks
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   253
    list = dataMgr.entryList("Sounds/voices", 
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   254
                             QDir::AllDirs | QDir::NoDotAndDotDot);
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   255
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   256
    CBVoicepack->addItems(list);
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   257
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5204
diff changeset
   258
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   259
    // forts
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   260
    list = dataMgr.entryList("Forts", QDir::Files, QStringList("*L.png"));
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   261
    list.replaceInStrings(QRegExp("L\\.png$"), "");
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   262
    CBFort->addItems(list);
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5204
diff changeset
   263
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   264
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   265
    // graves
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   266
    list =
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   267
        dataMgr.entryList("Graphics/Graves", QDir::Files, QStringList("*.png"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   268
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   269
    foreach (QString file, list)
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   270
    {
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   271
        QPixmap pix(dataMgr.findFileForRead("Graphics/Graves/" + file));
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   272
        if ((pix.height() > 32) || pix.width() > 32)
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   273
            pix = pix.copy(0, 0, 32, 32);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   274
        QIcon icon(pix);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   275
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   276
        QString grave = QString(file).remove(pngSuffix);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   277
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6024
diff changeset
   278
        CBGrave->addItem(icon, grave);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   279
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   280
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   281
    // flags
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   282
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   283
    list =
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   284
        dataMgr.entryList("Graphics/Flags", QDir::Files, QStringList("*.png"));
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5204
diff changeset
   285
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   286
    // skip cpu and hedgewars flags
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   287
    int idx = list.indexOf("cpu.png");
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   288
    if (idx >= 0)
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   289
        list.removeAt(idx);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   290
    idx = list.indexOf("hedgewars.png");
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   291
    if (idx >= 0)
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   292
        list.removeAt(idx);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   293
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   294
    // add the default flag
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   295
    QPixmap hwFlag(dataMgr.findFileForRead("Graphics/Flags/hedgewars.png"));
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   296
    CBFlag->addItem(QIcon(hwFlag.copy(0, 0, 22, 15)), "Hedgewars", "hedgewars");
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   297
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   298
    // add seperator after
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   299
    CBFlag->insertSeparator(1);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   300
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   301
    int insertAt = 2; // insert country flags after Hedgewars flag and seperator
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   302
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5204
diff changeset
   303
    // add all country flags
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   304
    foreach (const QString & file, list)
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5204
diff changeset
   305
    {
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   306
        QIcon icon(QPixmap(dataMgr.findFileForRead("Graphics/Flags/" + file)));
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   307
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   308
        QString flag = QString(file).remove(pngSuffix);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   309
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   310
        bool isCountryFlag = !file.startsWith("cm_");
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   311
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   312
        if (isCountryFlag)
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5204
diff changeset
   313
        {
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   314
            CBFlag->insertItem(insertAt, icon, flag.replace("_", " "), flag);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   315
            insertAt++;
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5204
diff changeset
   316
        }
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   317
        else // append community flags at end
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   318
            CBFlag->addItem(icon, flag.replace("cm_", QComboBox::tr("Community") + ": "), flag);
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5204
diff changeset
   319
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   320
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   321
    // add separator between country flags and community flags
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   322
    CBFlag->insertSeparator(insertAt);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   323
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   324
5907
64ccc6be0ec5 team edit: restore default hedgehog name if name is empty- since empty names are not supported and will lead to errors; also lupdate
sheepluva
parents: 5886
diff changeset
   325
void PageEditTeam::fixHHname(int idx)
64ccc6be0ec5 team edit: restore default hedgehog name if name is empty- since empty names are not supported and will lead to errors; also lupdate
sheepluva
parents: 5886
diff changeset
   326
{
64ccc6be0ec5 team edit: restore default hedgehog name if name is empty- since empty names are not supported and will lead to errors; also lupdate
sheepluva
parents: 5886
diff changeset
   327
    HHNameEdit[idx]->setText(HHNameEdit[idx]->text().trimmed());
64ccc6be0ec5 team edit: restore default hedgehog name if name is empty- since empty names are not supported and will lead to errors; also lupdate
sheepluva
parents: 5886
diff changeset
   328
64ccc6be0ec5 team edit: restore default hedgehog name if name is empty- since empty names are not supported and will lead to errors; also lupdate
sheepluva
parents: 5886
diff changeset
   329
    if (HHNameEdit[idx]->text().isEmpty())
64ccc6be0ec5 team edit: restore default hedgehog name if name is empty- since empty names are not supported and will lead to errors; also lupdate
sheepluva
parents: 5886
diff changeset
   330
        HHNameEdit[idx]->setText(QLineEdit::tr("hedgehog %1").arg(idx+1));
64ccc6be0ec5 team edit: restore default hedgehog name if name is empty- since empty names are not supported and will lead to errors; also lupdate
sheepluva
parents: 5886
diff changeset
   331
}
64ccc6be0ec5 team edit: restore default hedgehog name if name is empty- since empty names are not supported and will lead to errors; also lupdate
sheepluva
parents: 5886
diff changeset
   332
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   333
void PageEditTeam::CBFort_activated(const QString & fortname)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   334
{
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
   335
    HWDataManager & dataMgr = HWDataManager::instance();
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
   336
    QPixmap pix(dataMgr.findFileForRead("Forts/" + fortname + "L.png"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   337
    FortPreview->setPixmap(pix);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   338
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   339
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   340
void PageEditTeam::testSound()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   341
{
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
   342
    HWDataManager & dataMgr = HWDataManager::instance();
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
   343
6165
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   344
    QString voiceDir = QString("Sounds/voices/") + CBVoicepack->currentText();
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   345
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
   346
    QStringList list = dataMgr.entryList(
6165
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   347
            voiceDir,
6167
728cabee2c9f simplified some stuff I wrote
sheepluva
parents: 6165
diff changeset
   348
            QDir::Files,
6165
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   349
            QStringList() <<
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   350
                "Illgetyou.ogg" <<
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   351
                "Incoming.ogg" <<
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   352
                "Stupid.ogg" <<
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   353
                "Coward.ogg" <<
6167
728cabee2c9f simplified some stuff I wrote
sheepluva
parents: 6165
diff changeset
   354
                "Firstblood.ogg"
6165
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   355
            );
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   356
6167
728cabee2c9f simplified some stuff I wrote
sheepluva
parents: 6165
diff changeset
   357
    if (!list.isEmpty())
728cabee2c9f simplified some stuff I wrote
sheepluva
parents: 6165
diff changeset
   358
        SDLInteraction::instance().playSoundFile(
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
   359
            dataMgr.findFileForRead(voiceDir + "/" +
6167
728cabee2c9f simplified some stuff I wrote
sheepluva
parents: 6165
diff changeset
   360
                list[rand() % list.size()])
728cabee2c9f simplified some stuff I wrote
sheepluva
parents: 6165
diff changeset
   361
        );
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   362
}
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   363
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   364
void PageEditTeam::createTeam(const QString & name, const QString & playerHash)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   365
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   366
    m_playerHash = playerHash;
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   367
    HWTeam newTeam(name);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   368
    loadTeam(newTeam);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   369
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   370
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   371
void PageEditTeam::editTeam(const QString & name, const QString & playerHash)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   372
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   373
    m_playerHash = playerHash;
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   374
    HWTeam team(name);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   375
    team.loadFromFile();
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   376
    loadTeam(team);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   377
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   378
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   379
void PageEditTeam::deleteTeam(const QString & name)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   380
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   381
    QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel, this);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   382
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   383
    if (reallyDelete.exec() == QMessageBox::Ok)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   384
        HWTeam(name).deleteFile();
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   385
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   386
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   387
void PageEditTeam::setRandomNames()
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   388
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   389
    HWTeam team = data();
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   390
    HWNamegen::teamRandomNames(team, true);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   391
    loadTeam(team);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   392
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   393
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   394
void PageEditTeam::setRandomName(int hh_index)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   395
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   396
    HWTeam team = data();
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   397
    HWNamegen::teamRandomName(team,hh_index);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   398
    loadTeam(team);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   399
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   400
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   401
void PageEditTeam::loadTeam(const HWTeam & team)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   402
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   403
    TeamNameEdit->setText(team.name());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   404
    CBTeamLvl->setCurrentIndex(team.difficulty());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   405
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   406
    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   407
    {
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   408
        HWHog hh = team.hedgehog(i);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   409
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   410
        HHNameEdit[i]->setText(hh.Name);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   411
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   412
        if (hh.Hat.startsWith("Reserved"))
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   413
            hh.Hat = "Reserved "+hh.Hat.remove(0,40);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   414
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   415
        HHHats[i]->setCurrentIndex(HHHats[i]->findData(hh.Hat, Qt::DisplayRole));
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   416
    }
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   417
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   418
    CBGrave->setCurrentIndex(CBGrave->findText(team.grave()));
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   419
    CBFlag->setCurrentIndex(CBFlag->findData(team.flag()));
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   420
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   421
    CBFort->setCurrentIndex(CBFort->findText(team.fort()));
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   422
    CBVoicepack->setCurrentIndex(CBVoicepack->findText(team.voicepack()));
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   423
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   424
    for(int i = 0; i < BINDS_NUMBER; i++)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   425
    {
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   426
        CBBind[i]->setCurrentIndex(CBBind[i]->findData(team.keyBind(i)));
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   427
    }
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   428
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   429
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   430
HWTeam PageEditTeam::data()
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   431
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   432
    HWTeam team(TeamNameEdit->text());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   433
    team.setDifficulty(CBTeamLvl->currentIndex());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   434
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   435
    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   436
    {
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   437
        HWHog hh;
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   438
        hh.Name = HHNameEdit[i]->text();
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   439
        hh.Hat = HHHats[i]->currentText();
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   440
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   441
        if (hh.Hat.startsWith("Reserved"))
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   442
            hh.Hat = "Reserved"+m_playerHash+hh.Hat.remove(0,9);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   443
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   444
        team.setHedgehog(i,hh);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   445
    }
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   446
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   447
    team.setGrave(CBGrave->currentText());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   448
    team.setFort(CBFort->currentText());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   449
    team.setVoicepack(CBVoicepack->currentText());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   450
    team.setFlag(CBFlag->itemData(CBFlag->currentIndex()).toString());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   451
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   452
    for(int i = 0; i < BINDS_NUMBER; i++)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   453
    {
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   454
        team.bindKey(i,CBBind[i]->itemData(CBBind[i]->currentIndex()).toString());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   455
    }
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   456
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   457
    return team;
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   458
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   459
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   460
void PageEditTeam::saveTeam()
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   461
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   462
    data().saveToFile();
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   463
    emit teamEdited();
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   464
}