QTfrontend/ui/page/pageeditteam.cpp
author sheepluva
Wed, 31 Jul 2019 23:14:27 +0200
branchui-scaling
changeset 15304 c4fd2813b127
parent 15293 3053d07a7840
permissions -rw-r--r--
merge 1.0.0 beta 1 into ui-scaling branch
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
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 10108
diff changeset
     3
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
5078
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
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 9998
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
5078
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>
7260
c3584a3ab730 BindsModel
unc0rr
parents: 7258
diff changeset
    29
#include <QStandardItemModel>
c3584a3ab730 BindsModel
unc0rr
parents: 7258
diff changeset
    30
#include <QDebug>
14860
e239378a9400 Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents: 14857
diff changeset
    31
#include <QRegExp>
e239378a9400 Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents: 14857
diff changeset
    32
#include <QRegExpValidator>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    33
#include "SquareLabel.h"
5252
ded882439548 file association for mac!
koda
parents: 5238
diff changeset
    34
#include "HWApplication.h"
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
    35
#include "keybinder.h"
14860
e239378a9400 Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents: 14857
diff changeset
    36
#include "hwconsts.h"
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
    37
12684
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
    38
#include "physfs.h"
6930
d187ea93fc4f renaming HWDataManager -> DataManager
sheepluva
parents: 6700
diff changeset
    39
#include "DataManager.h"
8374
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
    40
#include "hatbutton.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    41
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
    42
#include "pageeditteam.h"
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
    43
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
    44
QLayout * PageEditTeam::bodyLayoutDefinition()
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    45
{
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
    46
    QGridLayout * pageLayout = new QGridLayout();
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
    47
    tbw = new QTabWidget();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    48
    QWidget * page1 = new QWidget(this);
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
    49
    binder = new KeyBinder(this, tr("Select an action to choose a custom key bind for this team"), tr("Use my default"), tr("Reset all binds"));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
    50
    connect(binder, SIGNAL(resetAllBinds()), this, SLOT(resetAllBinds()));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    51
    tbw->addTab(page1, tr("General"));
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
    52
    tbw->addTab(binder, tr("Custom Controls"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    53
    pageLayout->addWidget(tbw, 0, 0, 1, 3);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
    54
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    55
    QHBoxLayout * page1Layout = new QHBoxLayout(page1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    56
    page1Layout->setAlignment(Qt::AlignTop);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    57
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    58
// ====== Page 1 ======
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    59
    QVBoxLayout * vbox1 = new QVBoxLayout();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    60
    QVBoxLayout * vbox2 = new QVBoxLayout();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    61
    page1Layout->addLayout(vbox1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    62
    page1Layout->addLayout(vbox2);
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
    GBoxHedgehogs = new QGroupBox(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    65
    GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    66
    GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    67
    QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    68
6953
4c2dd25630a7 * make HatModel update automatically (also renamed class and files)
sheepluva
parents: 6952
diff changeset
    69
8374
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
    70
    GBHLayout->addWidget(new QLabel(tr("Hat")), 0, 0);
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
    71
    GBHLayout->addWidget(new QLabel(tr("Name")), 0, 1);
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
    72
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
    73
    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
    74
    {
8374
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
    75
        HHHats[i] = new HatButton(GBoxHedgehogs);
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
    76
        GBHLayout->addWidget(HHHats[i], i + 1, 0);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    77
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    78
        HHNameEdit[i] = new QLineEdit(GBoxHedgehogs);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    79
        HHNameEdit[i]->setMaxLength(64);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    80
        HHNameEdit[i]->setMinimumWidth(120);
8374
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
    81
        HHNameEdit[i]->setFixedHeight(36);
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
    82
        HHNameEdit[i]->setWhatsThis(tr("This hedgehog's name"));
13227
26c739440bef Some padding tweaks in options and team editor pages. Fixes insane width of context menu of hog name line edit
Wuzzy <Wuzzy2@mail.ru>
parents: 12686
diff changeset
    83
        HHNameEdit[i]->setStyleSheet("QLineEdit { padding: 6px; }");
12249
d23695f96290 Move random team button of of team members box
Wuzzy <almikes@aol.com>
parents: 12248
diff changeset
    84
        GBHLayout->addWidget(HHNameEdit[i], i + 1, 1, 1, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    85
12248
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
    86
        btnRandomHogName[i] = addButton(":/res/dice.png", GBHLayout, i + 1, 5, 1, 1, true);
8374
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
    87
        btnRandomHogName[i]->setFixedHeight(HHNameEdit[i]->height());
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
    88
        btnRandomHogName[i]->setWhatsThis(tr("Randomize this hedgehog's name"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    89
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    90
12248
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
    91
    btnRandomHats = new QPushButton();
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
    92
    btnRandomHats->setText(tr("Random Hats"));
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
    93
    btnRandomHats->setStyleSheet("padding: 6px 10px;");
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
    94
    GBHLayout->addWidget(btnRandomHats, 9, 1, 1, 1, Qt::AlignCenter);
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
    95
    btnRandomHats->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
    96
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
    97
    btnRandomNames = new QPushButton();
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
    98
    btnRandomNames->setText(tr("Random Names"));
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
    99
    btnRandomNames->setStyleSheet("padding: 6px 10px;");
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   100
    GBHLayout->addWidget(btnRandomNames, 9, 2, 1, 1, Qt::AlignCenter);
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   101
    btnRandomNames->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   102
12249
d23695f96290 Move random team button of of team members box
Wuzzy <almikes@aol.com>
parents: 12248
diff changeset
   103
    vbox1->addWidget(GBoxHedgehogs);
d23695f96290 Move random team button of of team members box
Wuzzy <almikes@aol.com>
parents: 12248
diff changeset
   104
8374
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
   105
    btnRandomTeam = new QPushButton();
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
   106
    btnRandomTeam->setText(tr("Random Team"));
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
   107
    btnRandomTeam->setStyleSheet("padding: 6px 10px;");
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
   108
    btnRandomTeam->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
12249
d23695f96290 Move random team button of of team members box
Wuzzy <almikes@aol.com>
parents: 12248
diff changeset
   109
    vbox1->addWidget(btnRandomTeam, 0, Qt::AlignCenter);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   110
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   111
    GBoxTeam = new QGroupBox(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   112
    GBoxTeam->setTitle(QGroupBox::tr("Team Settings"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   113
    GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   114
    QGridLayout * GBTLayout = new QGridLayout(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   115
    QLabel * tmpLabel = new QLabel(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   116
    tmpLabel->setText(QLabel::tr("Name"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   117
    GBTLayout->addWidget(tmpLabel, 0, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   118
    tmpLabel = new QLabel(GBoxTeam);
11808
ffe6e1344ebd Team editor: Make bot icons and graves more visible in closed drop-down lists, smaller botlevel images
Wuzzy <almikes@aol.com>
parents: 11672
diff changeset
   119
    tmpLabel->setText(QLabel::tr("Player"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   120
    GBTLayout->addWidget(tmpLabel, 1, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   121
    tmpLabel = new QLabel(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   122
    tmpLabel->setText(QLabel::tr("Grave"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   123
    GBTLayout->addWidget(tmpLabel, 2, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   124
    tmpLabel = new QLabel(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   125
    tmpLabel->setText(QLabel::tr("Flag"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   126
    GBTLayout->addWidget(tmpLabel, 3, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   127
    tmpLabel = new QLabel(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   128
    tmpLabel->setText(QLabel::tr("Voice"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   129
    GBTLayout->addWidget(tmpLabel, 4, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   130
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   131
    TeamNameEdit = new QLineEdit(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   132
    TeamNameEdit->setMaxLength(64);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   133
    TeamNameEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
13227
26c739440bef Some padding tweaks in options and team editor pages. Fixes insane width of context menu of hog name line edit
Wuzzy <Wuzzy2@mail.ru>
parents: 12686
diff changeset
   134
    TeamNameEdit->setStyleSheet("QLineEdit { padding: 6px; }");
14860
e239378a9400 Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents: 14857
diff changeset
   135
    QRegExp rx(*cSafeFileNameRegExp);
e239378a9400 Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents: 14857
diff changeset
   136
    QRegExpValidator * val = new QRegExpValidator(rx, TeamNameEdit);
e239378a9400 Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents: 14857
diff changeset
   137
    TeamNameEdit->setValidator(val);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   138
    GBTLayout->addWidget(TeamNameEdit, 0, 1, 1, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   139
    vbox2->addWidget(GBoxTeam);
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
    CBTeamLvl = new QComboBox(GBoxTeam);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   142
    CBTeamLvl->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
11808
ffe6e1344ebd Team editor: Make bot icons and graves more visible in closed drop-down lists, smaller botlevel images
Wuzzy <almikes@aol.com>
parents: 11672
diff changeset
   143
    CBTeamLvl->setIconSize(QSize(32, 32));
ffe6e1344ebd Team editor: Make bot icons and graves more visible in closed drop-down lists, smaller botlevel images
Wuzzy <almikes@aol.com>
parents: 11672
diff changeset
   144
    CBTeamLvl->addItem(QIcon(":/res/botlevels/small0.png"), QComboBox::tr("Human"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   145
    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
   146
        CBTeamLvl->addItem(
11808
ffe6e1344ebd Team editor: Make bot icons and graves more visible in closed drop-down lists, smaller botlevel images
Wuzzy <almikes@aol.com>
parents: 11672
diff changeset
   147
            QIcon(QString(":/res/botlevels/small%1.png").arg(6 - i)),
ffe6e1344ebd Team editor: Make bot icons and graves more visible in closed drop-down lists, smaller botlevel images
Wuzzy <almikes@aol.com>
parents: 11672
diff changeset
   148
            QComboBox::tr("Computer (Level %1)").arg(i)
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   149
        );
11808
ffe6e1344ebd Team editor: Make bot icons and graves more visible in closed drop-down lists, smaller botlevel images
Wuzzy <almikes@aol.com>
parents: 11672
diff changeset
   150
    CBTeamLvl->setFixedHeight(38);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   151
    GBTLayout->addWidget(CBTeamLvl, 1, 1, 1, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   152
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   153
    CBGrave = new QComboBox(GBoxTeam);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   154
    CBGrave->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   155
    CBGrave->setMaxCount(65535);
11672
98545abbedb3 Increase size of drop-down lists in team editor
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   156
    CBGrave->setMaxVisibleItems(20);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   157
    CBGrave->setIconSize(QSize(32, 32));
11808
ffe6e1344ebd Team editor: Make bot icons and graves more visible in closed drop-down lists, smaller botlevel images
Wuzzy <almikes@aol.com>
parents: 11672
diff changeset
   158
    CBGrave->setFixedHeight(44);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   159
    GBTLayout->addWidget(CBGrave, 2, 1, 1, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   160
12250
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   161
    // Player flags, combobox to select flag
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   162
    CBFlag = new QComboBox(GBoxTeam);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   163
    CBFlag->setMaxCount(65535);
11672
98545abbedb3 Increase size of drop-down lists in team editor
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   164
    CBFlag->setMaxVisibleItems(50);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   165
    CBFlag->setIconSize(QSize(22, 15));
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   166
    CBFlag->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   167
    GBTLayout->addWidget(CBFlag, 3, 1, 1, 2);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   168
12250
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   169
    // CPU level flag. Static image, only displayed when computer player is selected
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   170
    QImage imgBotlevels = QImage("physfs://Graphics/botlevels.png");
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   171
15293
3053d07a7840 Fix bad pixel offsets in CPU flag preview
Wuzzy <Wuzzy2@mail.ru>
parents: 15111
diff changeset
   172
    int botlevelOffsetsX[5]= { 17, 13, 9, 5, 0 };
3053d07a7840 Fix bad pixel offsets in CPU flag preview
Wuzzy <Wuzzy2@mail.ru>
parents: 15111
diff changeset
   173
    int botlevelOffsetsY[5]= { 11, 9, 4, 2, 0 };
12250
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   174
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   175
    for(int i=0; i<5; i++) {
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   176
        QImage imgCPU = QImage("physfs://Graphics/Flags/cpu.png");
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   177
        QPainter painter(&imgCPU);
15293
3053d07a7840 Fix bad pixel offsets in CPU flag preview
Wuzzy <Wuzzy2@mail.ru>
parents: 15111
diff changeset
   178
        painter.drawImage(botlevelOffsetsX[i], botlevelOffsetsY[i], imgBotlevels, botlevelOffsetsX[i], botlevelOffsetsY[i]);
12250
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   179
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   180
        pixCPU[i] = QPixmap::fromImage(imgCPU);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   181
    }
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   182
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   183
    QHBoxLayout* hboxCPU = new QHBoxLayout();
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   184
    hboxCPU->setContentsMargins(0, 0, 0, 0);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   185
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   186
    hboxCPUWidget = new QWidget();
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   187
    hboxCPUWidget->setLayout(hboxCPU);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   188
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   189
    CPUFlag = new QLabel();
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   190
    CPUFlag->setPixmap(pixCPU[0]);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   191
    CPUFlag->setFixedHeight(38);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   192
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   193
    hboxCPU->addWidget(CPUFlag);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   194
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   195
    CPUFlagLabel = new QLabel("CPU");
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   196
    CPUFlagLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   197
    hboxCPU->addWidget(CPUFlagLabel);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   198
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   199
    hboxCPUWidget->setHidden(true);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   200
    GBTLayout->addWidget(hboxCPUWidget, 3, 1, 1, 1);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   201
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   202
    btnRandomTeamName = addButton(":/res/dice.png", GBTLayout, 0, 3, 1, 1, true);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   203
    btnRandomTeamName->setWhatsThis(tr("Randomize the team name"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   204
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   205
    btnRandomGrave = addButton(":/res/dice.png", GBTLayout, 2, 3, 1, 1, true);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   206
    btnRandomGrave->setWhatsThis(tr("Randomize the grave"));
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   207
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   208
    btnRandomFlag = addButton(":/res/dice.png", GBTLayout, 3, 3, 1, 1, true);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   209
    btnRandomFlag->setWhatsThis(tr("Randomize the flag"));
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   210
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
   211
    CBVoicepack = new QComboBox(GBoxTeam);
11672
98545abbedb3 Increase size of drop-down lists in team editor
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   212
    CBVoicepack->setMaxVisibleItems(50);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   213
    CBVoicepack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
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
   214
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   215
    GBTLayout->addWidget(CBVoicepack, 4, 1, 1, 1);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   216
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   217
    btnTestSound = addSoundlessButton(":/res/PlaySound.png", GBTLayout, 4, 2, 1, 1, true);
12123
4027903ff3e7 updates to polish translation by alzen, also add two unlocalised string he found in the gui
nemo
parents: 11809
diff changeset
   218
    btnTestSound->setWhatsThis(tr("Play a random example of this voice"));
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
   219
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   220
    btnRandomVoice = addButton(":/res/dice.png", GBTLayout, 4, 3, 1, 1, true);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   221
    btnRandomVoice->setWhatsThis(tr("Randomize the voice"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   222
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   223
    GBoxFort = new QGroupBox(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   224
    GBoxFort->setTitle(QGroupBox::tr("Fort"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   225
    QGridLayout * GBFLayout = new QGridLayout(GBoxFort);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   226
    CBFort = new QComboBox(GBoxFort);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   227
    CBFort->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
11808
ffe6e1344ebd Team editor: Make bot icons and graves more visible in closed drop-down lists, smaller botlevel images
Wuzzy <almikes@aol.com>
parents: 11672
diff changeset
   228
    CBFort->setMaxVisibleItems(25);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   229
    CBFort->setMaxCount(65535);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   230
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   231
    GBFLayout->addWidget(CBFort, 0, 0);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   232
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   233
    btnRandomFort = addButton(":/res/dice.png", GBFLayout, 0, 2, 1, 1, true);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   234
    btnRandomFort->setWhatsThis(tr("Randomize the fort"));
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   235
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   236
    FortPreview = new SquareLabel(GBoxFort);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   237
    FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   238
    FortPreview->setMinimumSize(128, 128);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   239
    FortPreview->setPixmap(QPixmap());
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   240
    // 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
   241
    //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true);
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   242
    GBFLayout->addWidget(FortPreview, 1, 0, 1, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   243
    vbox2->addWidget(GBoxFort);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
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
    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
   246
    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
   247
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
   248
    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
   249
}
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
   250
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
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
   252
{
6525
6c97379c584b [GCI] backz task: unify the back button functionality, avoid using the save button
m4tx
parents: 6212
diff changeset
   253
    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
   254
}
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
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
   256
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
   257
{
8384
a6e7a95f3b2e GCI2012: Abstract Page Load
dag10
parents: 8374
diff changeset
   258
    connect(this, SIGNAL(pageLeave()), 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
   259
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
   260
    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
   261
    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
   262
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
   263
    connect(signalMapper1, SIGNAL(mapped(int)), this, SLOT(fixHHname(int)));
12244
45c83c88ac4b Refactor team name generator
Wuzzy <almikes@aol.com>
parents: 12242
diff changeset
   264
    connect(signalMapper2, SIGNAL(mapped(int)), this, SLOT(setRandomHogName(int)));
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
   265
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
   266
    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
   267
    {
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
   268
        connect(HHNameEdit[i], SIGNAL(editingFinished()), signalMapper1, SLOT(map()));
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   269
        signalMapper1->setMapping(HHNameEdit[i], i);
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
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
   271
        connect(btnRandomHogName[i], SIGNAL(clicked()), signalMapper2, SLOT(map()));
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   272
        signalMapper2->setMapping(btnRandomHogName[i], i);
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
   273
    }
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
   274
12244
45c83c88ac4b Refactor team name generator
Wuzzy <almikes@aol.com>
parents: 12242
diff changeset
   275
    connect(btnRandomTeam, SIGNAL(clicked()), this, SLOT(setRandomTeam()));
12248
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   276
    connect(btnRandomNames, SIGNAL(clicked()), this, SLOT(setRandomHogNames()));
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   277
    connect(btnRandomHats, SIGNAL(clicked()), this, SLOT(setRandomHats()));
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   278
12250
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   279
    connect(CBTeamLvl, SIGNAL(currentIndexChanged(const int)), this, SLOT(CBTeamLvl_activated(const int)));
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   280
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   281
    connect(btnRandomTeamName, SIGNAL(clicked()), this, SLOT(setRandomTeamName()));
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   282
    connect(btnRandomGrave, SIGNAL(clicked()), this, SLOT(setRandomGrave()));
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   283
    connect(btnRandomFlag, SIGNAL(clicked()), this, SLOT(setRandomFlag()));
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   284
    connect(btnRandomVoice, SIGNAL(clicked()), this, SLOT(setRandomVoice()));
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   285
    connect(btnRandomFort, SIGNAL(clicked()), this, SLOT(setRandomFort()));
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   286
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
   287
    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
   288
12684
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   289
    connect(CBFort, SIGNAL(currentIndexChanged(const int)), this, SLOT(CBFort_activated(const int)));
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
   290
}
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
   291
6165
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   292
PageEditTeam::PageEditTeam(QWidget* parent) :
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   293
    AbstractPage(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
   294
{
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
   295
    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
   296
9511
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   297
    m_playerHash = "0000000000000000000000000000000000000000";
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   298
    m_loaded = false;
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   299
}
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   300
9511
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   301
void PageEditTeam::lazyLoad()
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   302
{
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   303
    if(m_loaded) return;
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   304
    m_loaded = true;
9738
18bb6d1fc9d9 Load hats into the model lazily
unc0rr
parents: 9511
diff changeset
   305
    qDebug("[LAZINESS] PageEditTeam::lazyLoad()");
18bb6d1fc9d9 Load hats into the model lazily
unc0rr
parents: 9511
diff changeset
   306
18bb6d1fc9d9 Load hats into the model lazily
unc0rr
parents: 9511
diff changeset
   307
    HatModel * hatsModel = DataManager::instance().hatModel();
18bb6d1fc9d9 Load hats into the model lazily
unc0rr
parents: 9511
diff changeset
   308
    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
18bb6d1fc9d9 Load hats into the model lazily
unc0rr
parents: 9511
diff changeset
   309
        HHHats[i]->setModel(hatsModel);
18bb6d1fc9d9 Load hats into the model lazily
unc0rr
parents: 9511
diff changeset
   310
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
   311
9511
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   312
    QRegExp pngSuffix("\\.png$");
6930
d187ea93fc4f renaming HWDataManager -> DataManager
sheepluva
parents: 6700
diff changeset
   313
    DataManager & dataMgr = DataManager::instance();
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
   314
    QStringList list;
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   315
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
   316
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   317
    // voicepacks
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   318
    list = dataMgr.entryList("Sounds/voices",
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   319
                             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
   320
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   321
    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
   322
12685
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   323
    QIcon dlcIcon;
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   324
    dlcIcon.addFile(":/res/dlcMarker.png", QSize(), QIcon::Normal, QIcon::On);
12686
d5e09024d722 Change DLC icon (thanks, nemo!)
Wuzzy <almikes@aol.com>
parents: 12685
diff changeset
   325
    dlcIcon.addFile(":/res/dlcMarkerSelected.png", QSize(), QIcon::Selected, QIcon::On);
12685
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   326
    QPixmap emptySpace = QPixmap(7, 15);
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   327
    emptySpace.fill(QColor(0, 0, 0, 0));
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   328
    QIcon notDlcIcon = QIcon(emptySpace);
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
   329
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   330
    // forts
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   331
    list = dataMgr.entryList("Forts", QDir::Files, QStringList("*L.png"));
12684
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   332
    foreach (QString file, list)
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   333
    {
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   334
        QString fortPath = PHYSFS_getRealDir(QString("Forts/%1").arg(file).toLocal8Bit().data());
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   335
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   336
        QString fort = file.replace(QRegExp("L\\.png$"), "");
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   337
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   338
        bool isDLC = !fortPath.startsWith(datadir->absolutePath());
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   339
        if (isDLC)
12685
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   340
        {
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   341
            CBFort->addItem(dlcIcon, fort, fort);
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   342
        }
12684
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   343
        else
12685
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   344
        {
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   345
            CBFort->addItem(notDlcIcon, fort, fort);
ad1fd7ae479d Mark custom maps/forts/scripts with circle icon instead of icon
Wuzzy <almikes@aol.com>
parents: 12684
diff changeset
   346
        }
12684
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   347
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   348
    }
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
   349
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   350
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   351
    // graves
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   352
    list =
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   353
        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
   354
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   355
    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
   356
    {
8049
133e22b5c410 Get rid of DataManager::findFileForRead
unc0rr
parents: 7794
diff changeset
   357
        QPixmap pix("physfs://Graphics/Graves/" + file);
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   358
        if ((pix.height() > 32) || pix.width() > 32)
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   359
            pix = pix.copy(0, 0, 32, 32);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   360
        QIcon icon(pix);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   361
9511
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   362
        QString grave = file.remove(pngSuffix);
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   363
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
   364
        CBGrave->addItem(icon, grave);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   365
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   366
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   367
    // flags
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   368
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   369
    list =
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   370
        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
   371
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   372
    // skip cpu and hedgewars flags
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   373
    int idx = list.indexOf("cpu.png");
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   374
    if (idx >= 0)
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   375
        list.removeAt(idx);
7495
2592240b7b62 Add bot level to CPU flag
nemo
parents: 7260
diff changeset
   376
    idx = list.indexOf("cpu_plain.png");
2592240b7b62 Add bot level to CPU flag
nemo
parents: 7260
diff changeset
   377
    if (idx >= 0)
2592240b7b62 Add bot level to CPU flag
nemo
parents: 7260
diff changeset
   378
        list.removeAt(idx);
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   379
    idx = list.indexOf("hedgewars.png");
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   380
    if (idx >= 0)
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   381
        list.removeAt(idx);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   382
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   383
    // add the default flag
8049
133e22b5c410 Get rid of DataManager::findFileForRead
unc0rr
parents: 7794
diff changeset
   384
    QPixmap hwFlag("physfs://Graphics/Flags/hedgewars.png");
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   385
    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
   386
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   387
    // add seperator after
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   388
    CBFlag->insertSeparator(1);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   389
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   390
    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
   391
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
   392
    // add all country flags
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   393
    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
   394
    {
8049
133e22b5c410 Get rid of DataManager::findFileForRead
unc0rr
parents: 7794
diff changeset
   395
        QIcon icon(QPixmap("physfs://Graphics/Flags/" + file));
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   396
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   397
        QString flag = QString(file).remove(pngSuffix);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   398
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   399
        bool isCountryFlag = !file.startsWith("cm_");
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   400
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   401
        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
   402
        {
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   403
            CBFlag->insertItem(insertAt, icon, flag.replace("_", " "), flag);
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   404
            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
   405
        }
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   406
        else // append community flags at end
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   407
            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
   408
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   409
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   410
    // add separator between country flags and community flags
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   411
    CBFlag->insertSeparator(insertAt);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   412
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   413
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
   414
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
   415
{
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
   416
    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
   417
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
   418
    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
   419
        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
   420
}
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
   421
12684
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   422
void PageEditTeam::CBFort_activated(const int index)
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   423
{
12684
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   424
    QString fortName = CBFort->itemData(index).toString();
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   425
    QPixmap pix("physfs://Forts/" + fortName + "L.png");
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   426
    FortPreview->setPixmap(pix);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   427
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   428
12250
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   429
void PageEditTeam::CBTeamLvl_activated(const int index)
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   430
{
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   431
    CBFlag->setHidden(index != 0);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   432
    btnRandomFlag->setHidden(index != 0);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   433
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   434
    if(index > 0) 
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   435
    {
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   436
        int cpuLevel = 6 - index;
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   437
        CPUFlag->setPixmap(pixCPU[cpuLevel - 1]);
12474
42da9d8d82ab Provide translator context for a few less obvious engine strings
Wuzzy <almikes@aol.com>
parents: 12296
diff changeset
   438
        //: Name of a flag for computer-controlled enemies. %1 is replaced with the computer level
12250
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   439
        CPUFlagLabel->setText(tr("CPU %1").arg(cpuLevel));
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   440
    }
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   441
    hboxCPUWidget->setHidden(index == 0);
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   442
}
05f1935175da Team editor: Disable flag widget when selecting CPU team
Wuzzy <almikes@aol.com>
parents: 12249
diff changeset
   443
15111
33eca3f0a9aa PageEditTeam: Disable sound test button when frontend sounds are disabled
Wuzzy <Wuzzy2@mail.ru>
parents: 14955
diff changeset
   444
void PageEditTeam::frontendSoundsToggled(bool value)
33eca3f0a9aa PageEditTeam: Disable sound test button when frontend sounds are disabled
Wuzzy <Wuzzy2@mail.ru>
parents: 14955
diff changeset
   445
{
33eca3f0a9aa PageEditTeam: Disable sound test button when frontend sounds are disabled
Wuzzy <Wuzzy2@mail.ru>
parents: 14955
diff changeset
   446
    btnTestSound->setEnabled(value);
33eca3f0a9aa PageEditTeam: Disable sound test button when frontend sounds are disabled
Wuzzy <Wuzzy2@mail.ru>
parents: 14955
diff changeset
   447
}
33eca3f0a9aa PageEditTeam: Disable sound test button when frontend sounds are disabled
Wuzzy <Wuzzy2@mail.ru>
parents: 14955
diff changeset
   448
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   449
void PageEditTeam::testSound()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   450
{
6930
d187ea93fc4f renaming HWDataManager -> DataManager
sheepluva
parents: 6700
diff changeset
   451
    DataManager & dataMgr = DataManager::instance();
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
   452
6165
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   453
    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
   454
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6195
diff changeset
   455
    QStringList list = dataMgr.entryList(
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   456
                           voiceDir,
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   457
                           QDir::Files,
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   458
                           QStringList() <<
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   459
                           "Illgetyou.ogg" <<
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   460
                           "Incoming.ogg" <<
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   461
                           "Stupid.ogg" <<
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   462
                           "Coward.ogg" <<
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   463
                           "Firstblood.ogg"
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6525
diff changeset
   464
                       );
6165
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6060
diff changeset
   465
6167
728cabee2c9f simplified some stuff I wrote
sheepluva
parents: 6165
diff changeset
   466
    if (!list.isEmpty())
8913
19a6e59e4441 Fix issue 603
unc0rr
parents: 8434
diff changeset
   467
        SDLInteraction::instance().playSoundFile("/" + voiceDir + "/" +
8049
133e22b5c410 Get rid of DataManager::findFileForRead
unc0rr
parents: 7794
diff changeset
   468
                                    list[rand() % list.size()]);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   469
}
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   470
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   471
void PageEditTeam::createTeam(const QString & name, const QString & playerHash)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   472
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   473
    m_playerHash = playerHash;
9511
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   474
    lazyLoad();
12669
bc34fc75670e Fix old team name not being removed after renaming team in frontend
Wuzzy <almikes@aol.com>
parents: 12505
diff changeset
   475
    OldTeamName = name;
9511
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   476
14955
0ec0ed2d9045 Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents: 14920
diff changeset
   477
    // Mostly create a default team, with some important exceptions:
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   478
    HWTeam newTeam(name);
12242
09010333c947 Randomize forts and graves in new teams
Wuzzy <almikes@aol.com>
parents: 12123
diff changeset
   479
    // Randomize grave to make it less likely that default teams have equal graves (important for resurrector)
12296
62975c0a89c6 Only select from default graves and forts for new themes
Wuzzy <almikes@aol.com>
parents: 12250
diff changeset
   480
    HWNamegen::teamRandomGrave(newTeam, false);
12242
09010333c947 Randomize forts and graves in new teams
Wuzzy <almikes@aol.com>
parents: 12123
diff changeset
   481
    // Randomize fort for greater variety in fort mode with default teams
12296
62975c0a89c6 Only select from default graves and forts for new themes
Wuzzy <almikes@aol.com>
parents: 12250
diff changeset
   482
    HWNamegen::teamRandomFort(newTeam, false);
14955
0ec0ed2d9045 Frontend: Select appropriate localized Default voicepack for new teams
Wuzzy <Wuzzy2@mail.ru>
parents: 14920
diff changeset
   483
    HWNamegen::teamLocalizedDefaultVoice(newTeam);
12296
62975c0a89c6 Only select from default graves and forts for new themes
Wuzzy <almikes@aol.com>
parents: 12250
diff changeset
   484
    // DLC forts and graves intentionally filtered out to prevent desyncs and missing grave error
62975c0a89c6 Only select from default graves and forts for new themes
Wuzzy <almikes@aol.com>
parents: 12250
diff changeset
   485
    // TODO: Remove DLC filter as soon it is not needed anymore
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   486
    loadTeam(newTeam);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   487
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   488
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   489
void PageEditTeam::editTeam(const QString & name, const QString & playerHash)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   490
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   491
    m_playerHash = playerHash;
9511
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   492
    lazyLoad();
12669
bc34fc75670e Fix old team name not being removed after renaming team in frontend
Wuzzy <almikes@aol.com>
parents: 12505
diff changeset
   493
    OldTeamName = name;
9511
1be565d7b4b7 Fill PageEditTeam containers only when it is actually required:
unc0rr
parents: 9080
diff changeset
   494
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   495
    HWTeam team(name);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   496
    team.loadFromFile();
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   497
    loadTeam(team);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   498
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   499
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   500
void PageEditTeam::deleteTeam(const QString & name)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   501
{
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7781
diff changeset
   502
    QMessageBox reallyDeleteMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7781
diff changeset
   503
    reallyDeleteMsg.setIcon(QMessageBox::Question);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7781
diff changeset
   504
    reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Teams - Are you sure?"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7781
diff changeset
   505
    reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the team '%1'?").arg(name));
14857
b9437746bffb Frontend: Force plain text mode for many message windows
Wuzzy <Wuzzy2@mail.ru>
parents: 13227
diff changeset
   506
    reallyDeleteMsg.setTextFormat(Qt::PlainText);
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7781
diff changeset
   507
    reallyDeleteMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7781
diff changeset
   508
    reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   509
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7781
diff changeset
   510
    if (reallyDeleteMsg.exec() == QMessageBox::Ok)
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   511
        HWTeam(name).deleteFile();
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   512
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   513
12244
45c83c88ac4b Refactor team name generator
Wuzzy <almikes@aol.com>
parents: 12242
diff changeset
   514
void PageEditTeam::setRandomTeam()
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   515
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   516
    HWTeam team = data();
12505
82c75a317d48 Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents: 12502
diff changeset
   517
    HWNamegen::teamRandomEverything(team);
12248
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   518
    loadTeam(team);
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   519
}
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   520
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   521
void PageEditTeam::setRandomHogNames()
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   522
{
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   523
    HWTeam team = data();
12505
82c75a317d48 Randomized teams now can have any random hats (not just from types.ini)
Wuzzy <almikes@aol.com>
parents: 12502
diff changeset
   524
    HWNamegen::teamRandomHogNames(team);
12248
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   525
    loadTeam(team);
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   526
}
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   527
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   528
void PageEditTeam::setRandomHats()
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   529
{
07f67ee424dc Add buttons to randomize hats and hog names only
Wuzzy <almikes@aol.com>
parents: 12245
diff changeset
   530
    HWTeam team = data();
12502
f4b0e164a0d5 Chance that clicking the random hats button produces a set of equal hats
Wuzzy <almikes@aol.com>
parents: 12474
diff changeset
   531
    HWNamegen::teamRandomHats(team);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   532
    loadTeam(team);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   533
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   534
12244
45c83c88ac4b Refactor team name generator
Wuzzy <almikes@aol.com>
parents: 12242
diff changeset
   535
void PageEditTeam::setRandomHogName(int hh_index)
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   536
{
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   537
    HWTeam team = data();
12244
45c83c88ac4b Refactor team name generator
Wuzzy <almikes@aol.com>
parents: 12242
diff changeset
   538
    HWNamegen::teamRandomHogName(team,hh_index);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   539
    loadTeam(team);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   540
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   541
12245
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   542
void PageEditTeam::setRandomTeamName()
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   543
{
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   544
    HWTeam team = data();
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   545
    HWNamegen::teamRandomTeamName(team);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   546
    loadTeam(team);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   547
}
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   548
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   549
void PageEditTeam::setRandomGrave()
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   550
{
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   551
    HWTeam team = data();
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   552
    HWNamegen::teamRandomGrave(team);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   553
    loadTeam(team);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   554
}
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   555
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   556
void PageEditTeam::setRandomFlag()
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   557
{
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   558
    HWTeam team = data();
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   559
    HWNamegen::teamRandomFlag(team);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   560
    loadTeam(team);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   561
}
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   562
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   563
void PageEditTeam::setRandomVoice()
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   564
{
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   565
    HWTeam team = data();
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   566
    HWNamegen::teamRandomVoice(team);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   567
    loadTeam(team);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   568
}
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   569
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   570
void PageEditTeam::setRandomFort()
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   571
{
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   572
    HWTeam team = data();
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   573
    HWNamegen::teamRandomFort(team);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   574
    loadTeam(team);
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   575
}
5206f9a803d1 Allow to randomize team name, flag, grave, voice and fort seperately
Wuzzy <almikes@aol.com>
parents: 12244
diff changeset
   576
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   577
void PageEditTeam::loadTeam(const HWTeam & team)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   578
{
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   579
    tbw->setCurrentIndex(0);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   580
    binder->resetInterface();
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8385
diff changeset
   581
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   582
    TeamNameEdit->setText(team.name());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   583
    CBTeamLvl->setCurrentIndex(team.difficulty());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   584
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   585
    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   586
    {
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   587
        HWHog hh = team.hedgehog(i);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   588
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   589
        HHNameEdit[i]->setText(hh.Name);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   590
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   591
        if (hh.Hat.startsWith("Reserved"))
6195
6c9ada03602d * fixing my hat preview bug nemo pointed out (thanks!)
sheepluva
parents: 6167
diff changeset
   592
            hh.Hat = "Reserved "+hh.Hat.remove(0,40);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   593
8374
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
   594
        HHHats[i]->setCurrentHat(hh.Hat);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   595
    }
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   596
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   597
    CBGrave->setCurrentIndex(CBGrave->findText(team.grave()));
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   598
    CBFlag->setCurrentIndex(CBFlag->findData(team.flag()));
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   599
12684
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   600
    CBFort->setCurrentIndex(CBFort->findData(team.fort()));
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   601
    CBVoicepack->setCurrentIndex(CBVoicepack->findText(team.voicepack()));
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   602
7260
c3584a3ab730 BindsModel
unc0rr
parents: 7258
diff changeset
   603
    QStandardItemModel * binds = DataManager::instance().bindsModel();
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   604
    for(int i = 0; i < BINDS_NUMBER; i++)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   605
    {
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   606
        if (team.keyBind(i).isEmpty()) continue;
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8385
diff changeset
   607
7260
c3584a3ab730 BindsModel
unc0rr
parents: 7258
diff changeset
   608
        QModelIndexList mdl = binds->match(binds->index(0, 0), Qt::UserRole + 1, team.keyBind(i), 1, Qt::MatchExactly);
c3584a3ab730 BindsModel
unc0rr
parents: 7258
diff changeset
   609
c3584a3ab730 BindsModel
unc0rr
parents: 7258
diff changeset
   610
        if(mdl.size() == 1)
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   611
            binder->setBindIndex(i, mdl[0].row());
7260
c3584a3ab730 BindsModel
unc0rr
parents: 7258
diff changeset
   612
        else
c3584a3ab730 BindsModel
unc0rr
parents: 7258
diff changeset
   613
            qDebug() << "Binds: cannot find" << team.keyBind(i);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   614
    }
14920
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14860
diff changeset
   615
    binder->checkConflicts();
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   616
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   617
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   618
HWTeam PageEditTeam::data()
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   619
{
12669
bc34fc75670e Fix old team name not being removed after renaming team in frontend
Wuzzy <almikes@aol.com>
parents: 12505
diff changeset
   620
    HWTeam team(OldTeamName);
bc34fc75670e Fix old team name not being removed after renaming team in frontend
Wuzzy <almikes@aol.com>
parents: 12505
diff changeset
   621
    team.setName(TeamNameEdit->text());
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   622
    team.setDifficulty(CBTeamLvl->currentIndex());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   623
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   624
    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   625
    {
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   626
        HWHog hh;
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   627
        hh.Name = HHNameEdit[i]->text();
8374
3a1708759c4f Hat selection reworked
dag10
parents: 8346
diff changeset
   628
        hh.Hat = HHHats[i]->currentHat();
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   629
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   630
        if (hh.Hat.startsWith("Reserved"))
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   631
            hh.Hat = "Reserved"+m_playerHash+hh.Hat.remove(0,9);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   632
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   633
        team.setHedgehog(i,hh);
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   634
    }
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   635
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   636
    team.setGrave(CBGrave->currentText());
12684
5f68b259305c Mark custom forts with asterisk in team editor
Wuzzy <almikes@aol.com>
parents: 12670
diff changeset
   637
    team.setFort(CBFort->itemData(CBFort->currentIndex()).toString());
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   638
    team.setVoicepack(CBVoicepack->currentText());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   639
    team.setFlag(CBFlag->itemData(CBFlag->currentIndex()).toString());
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   640
7260
c3584a3ab730 BindsModel
unc0rr
parents: 7258
diff changeset
   641
    QStandardItemModel * binds = DataManager::instance().bindsModel();
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   642
    for(int i = 0; i < BINDS_NUMBER; i++)
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   643
    {
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   644
        team.bindKey(i, binds->index(binder->bindIndex(i), 0).data(Qt::UserRole + 1).toString());
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   645
    }
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   646
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   647
    return team;
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   648
}
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   649
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   650
void PageEditTeam::saveTeam()
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   651
{
12670
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   652
    HWTeam team = data();
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   653
    if(!team.wouldOverwriteOtherFile())
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   654
    {
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   655
        team.saveToFile();
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   656
    }
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   657
    else
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   658
    {
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   659
        // Name already used -> look for an appropriate name:
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   660
        int i=2;
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   661
        QString origName = team.name();
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   662
        QString newName;
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   663
        while(team.wouldOverwriteOtherFile())
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   664
        {
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   665
            newName = tr("%1 (%2)").arg(origName).arg(i++);
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   666
            team.setName(newName);
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   667
            if(i > 1000)
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   668
                break;
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   669
        }
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   670
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   671
        QMessageBox teamNameFixedMsg(this);
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   672
        teamNameFixedMsg.setIcon(QMessageBox::Warning);
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   673
        teamNameFixedMsg.setWindowTitle(QMessageBox::tr("Teams - Name already taken"));
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   674
        teamNameFixedMsg.setText(QMessageBox::tr("The team name '%1' is already taken, so your team has been renamed to '%2'.").arg(origName).arg(team.name()));
14857
b9437746bffb Frontend: Force plain text mode for many message windows
Wuzzy <Wuzzy2@mail.ru>
parents: 13227
diff changeset
   675
        teamNameFixedMsg.setTextFormat(Qt::PlainText);
12670
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   676
        teamNameFixedMsg.setWindowModality(Qt::WindowModal);
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   677
        teamNameFixedMsg.setStandardButtons(QMessageBox::Ok);
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   678
        teamNameFixedMsg.exec();
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   679
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   680
        team.saveToFile();
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 12669
diff changeset
   681
    }
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 5907
diff changeset
   682
}
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   683
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   684
// When the "Use default for all binds" is pressed...
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   685
void PageEditTeam::resetAllBinds()
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   686
{
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   687
    for (int i = 0; i < BINDS_NUMBER; i++)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   688
        binder->setBindIndex(i, 0);
14920
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14860
diff changeset
   689
    binder->checkConflicts();
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents: 8049
diff changeset
   690
}