author | nemo |
Mon, 24 Oct 2022 10:06:52 -0400 | |
branch | 1.0.0 |
changeset 15885 | ed84eb580643 |
parent 14804 | d7b40d61729f |
permissions | -rw-r--r-- |
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 | 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:
10017
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 |
*/ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6586
diff
changeset
|
18 |
|
5078
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:
5763
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 <QLabel> |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
23 |
#include <QTime> |
9832
b1038b4373cc
Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents:
9212
diff
changeset
|
24 |
#include <QSettings> |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
25 |
|
5204 | 26 |
#include "pagemain.h" |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
27 |
#include "hwconsts.h" |
5205
78138ae93820
some headers cleanup and rename of stats and playrecord pages for consistency
koda
parents:
5204
diff
changeset
|
28 |
#include "hwform.h" |
9832
b1038b4373cc
Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents:
9212
diff
changeset
|
29 |
#include "DataManager.h" |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
30 |
|
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:
5763
diff
changeset
|
31 |
QLayout * PageMain::bodyLayoutDefinition() |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
32 |
{ |
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:
5763
diff
changeset
|
33 |
QGridLayout * pageLayout = new QGridLayout(); |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
34 |
//pageLayout->setColumnStretch(0, 1); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
35 |
//pageLayout->setColumnStretch(1, 2); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
36 |
//pageLayout->setColumnStretch(2, 1); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
37 |
|
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
38 |
//QPushButton* btnLogo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
39 |
//pageLayout->setAlignment(btnLogo, Qt::AlignHCenter); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
40 |
pageLayout->setRowStretch(0, 1); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
41 |
pageLayout->setRowStretch(1, 1); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
42 |
pageLayout->setRowStretch(2, 0); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
43 |
pageLayout->setRowStretch(3, 1); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
44 |
pageLayout->setRowStretch(4, 1); |
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:
5763
diff
changeset
|
45 |
|
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
46 |
BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true); |
6478 | 47 |
BtnSinglePlayer->setWhatsThis(tr("Play a game on a single computer")); |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
48 |
pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
49 |
|
8318 | 50 |
//BtnNet = addButton(":/res/NetworkPlay.png", (QBoxLayout*)netLayout, 1, true); |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
51 |
BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true); |
6478 | 52 |
BtnNet->setWhatsThis(tr("Play a game across a network")); |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
53 |
pageLayout->setAlignment(BtnNet, Qt::AlignHCenter); |
8434 | 54 |
|
8318 | 55 |
originalNetworkIcon = BtnNet->icon(); |
56 |
disabledNetworkIcon = QIcon(":/res/NetworkPlayDisabled.png"); |
|
57 |
||
58 |
//QWidget *netLayoutWidget = new QWidget(); |
|
59 |
QVBoxLayout *netLayout = new QVBoxLayout(BtnNet); |
|
60 |
//pageLayout->addWidget(netLayoutWidget, 2, 2, 1, 2); |
|
61 |
//netLayoutWidget->setStyleSheet("background: green;"); |
|
62 |
//netLayoutWidget->setFixedSize(314, 260); |
|
63 |
netLayout->setSpacing(20); |
|
64 |
netLayout->setAlignment(Qt::AlignHCenter); |
|
65 |
||
8693
ab42f868b1c3
*sigh* hopefully there aren't any more of these. add missing tr() to button text
nemo
parents:
8676
diff
changeset
|
66 |
BtnNetLocal = addButton(tr("Play local network game"), (QBoxLayout*)netLayout, 0, false); |
8318 | 67 |
BtnNetLocal->setWhatsThis(tr("Play a game across a local area network")); |
68 |
BtnNetLocal->setFixedSize(BtnNet->width() - 50, 60); |
|
69 |
BtnNetLocal->setVisible(false); |
|
70 |
||
8693
ab42f868b1c3
*sigh* hopefully there aren't any more of these. add missing tr() to button text
nemo
parents:
8676
diff
changeset
|
71 |
BtnNetOfficial = addButton(tr("Play official network game"), (QBoxLayout*)netLayout, 0, false); |
8318 | 72 |
BtnNetOfficial->setWhatsThis(tr("Play a game on an official server")); |
73 |
BtnNetOfficial->setFixedSize(BtnNet->width() - 50, 60); |
|
74 |
BtnNetOfficial->setVisible(false); |
|
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
75 |
|
6169 | 76 |
// button order matters for overlapping (what's on top and what isn't) |
14804
d7b40d61729f
Add extra button in main menu for opening credits page
Wuzzy <Wuzzy2@mail.ru>
parents:
13818
diff
changeset
|
77 |
BtnTitle = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); |
d7b40d61729f
Add extra button in main menu for opening credits page
Wuzzy <Wuzzy2@mail.ru>
parents:
13818
diff
changeset
|
78 |
BtnTitle ->setObjectName("infoButton"); |
d7b40d61729f
Add extra button in main menu for opening credits page
Wuzzy <Wuzzy2@mail.ru>
parents:
13818
diff
changeset
|
79 |
BtnTitle->setWhatsThis(tr("Read about who is behind the Hedgewars Project")); |
d7b40d61729f
Add extra button in main menu for opening credits page
Wuzzy <Wuzzy2@mail.ru>
parents:
13818
diff
changeset
|
80 |
pageLayout->setAlignment(BtnTitle, Qt::AlignHCenter); |
d7b40d61729f
Add extra button in main menu for opening credits page
Wuzzy <Wuzzy2@mail.ru>
parents:
13818
diff
changeset
|
81 |
|
d7b40d61729f
Add extra button in main menu for opening credits page
Wuzzy <Wuzzy2@mail.ru>
parents:
13818
diff
changeset
|
82 |
BtnInfo = addButton(":/res/AboutIcon.png", pageLayout, 0, 0, 1, 1, true); |
6478 | 83 |
BtnInfo->setWhatsThis(tr("Read about who is behind the Hedgewars Project")); |
14804
d7b40d61729f
Add extra button in main menu for opening credits page
Wuzzy <Wuzzy2@mail.ru>
parents:
13818
diff
changeset
|
84 |
pageLayout->setAlignment(BtnInfo, Qt::AlignLeft | Qt::AlignTop); |
6169 | 85 |
|
8676 | 86 |
BtnFeedback = addButton(tr("Feedback"), pageLayout, 4, 0, 1, 4, false); |
8622
2045bdf1b11b
Resolves issue 528. Fixed platform-specific order of buttons on seed prompt and new room prompt. Fixed height of back button on all pages -- now aligns to bottom. On pagemain, feedback and dlc buttons no longer fixed size.
dag10
parents:
8435
diff
changeset
|
87 |
BtnFeedback->setStyleSheet("padding: 5px 10px"); |
6759 | 88 |
BtnFeedback->setWhatsThis(tr("Leave a feedback here reporting issues, suggesting features or just saying how you like Hedgewars")); |
6582 | 89 |
pageLayout->setAlignment(BtnFeedback, Qt::AlignHCenter); |
90 |
||
91 |
BtnDataDownload = addButton(tr("Downloadable Content"), pageLayout, 5, 0, 1, 4, false); |
|
8622
2045bdf1b11b
Resolves issue 528. Fixed platform-specific order of buttons on seed prompt and new room prompt. Fixed height of back button on all pages -- now aligns to bottom. On pagemain, feedback and dlc buttons no longer fixed size.
dag10
parents:
8435
diff
changeset
|
92 |
BtnDataDownload->setStyleSheet("padding: 5px 10px"); |
6478 | 93 |
BtnDataDownload->setWhatsThis(tr("Access the user created content downloadable from our website")); |
5763
d7a887c7e2d0
Add a crappy button to encourage artists to make another one. Restore Info page.
nemo
parents:
5646
diff
changeset
|
94 |
pageLayout->setAlignment(BtnDataDownload, Qt::AlignHCenter); |
d7a887c7e2d0
Add a crappy button to encourage artists to make another one. Restore Info page.
nemo
parents:
5646
diff
changeset
|
95 |
|
6583 | 96 |
// disable exit button sound |
97 |
btnBack->isSoundEnabled = false; |
|
98 |
||
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:
5763
diff
changeset
|
99 |
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:
5763
diff
changeset
|
100 |
} |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
5763
diff
changeset
|
101 |
|
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:
5763
diff
changeset
|
102 |
QLayout * PageMain::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:
5763
diff
changeset
|
103 |
{ |
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:
5763
diff
changeset
|
104 |
QHBoxLayout * bottomLayout = new QHBoxLayout(); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
5763
diff
changeset
|
105 |
|
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
106 |
mainNote = new QLabel(this); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
107 |
mainNote->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
108 |
mainNote->setWordWrap(true); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6586
diff
changeset
|
109 |
|
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:
5763
diff
changeset
|
110 |
bottomLayout->addWidget(mainNote, 0); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
5763
diff
changeset
|
111 |
bottomLayout->setStretch(0,1); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
5763
diff
changeset
|
112 |
|
6699
83dd3447a212
exploit the new setWhatsThis feature in our desktop frontend
koda
parents:
6616
diff
changeset
|
113 |
btnBack->setWhatsThis(tr("Exit game")); |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
6952
diff
changeset
|
114 |
|
7617 | 115 |
#ifdef VIDEOREC |
11818
b421923c2577
Neatly align all the bottom buttons on the same height
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
116 |
BtnVideos = addButton(":/res/Videos.png", bottomLayout, 1, true, Qt::AlignBottom); |
7620 | 117 |
BtnVideos->setWhatsThis(tr("Manage videos recorded from game")); |
7617 | 118 |
#endif |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
6952
diff
changeset
|
119 |
|
13818
a8fd5490932f
Add help button in main menu (opens Hedgewars Wiki in browser)
Wuzzy <Wuzzy2@mail.ru>
parents:
13304
diff
changeset
|
120 |
BtnHelp = addButton(":/res/Help.png", bottomLayout, 2, true, Qt::AlignBottom); |
a8fd5490932f
Add help button in main menu (opens Hedgewars Wiki in browser)
Wuzzy <Wuzzy2@mail.ru>
parents:
13304
diff
changeset
|
121 |
BtnHelp->setWhatsThis(tr("Open the Hedgewars online game manual in your web browser")); |
a8fd5490932f
Add help button in main menu (opens Hedgewars Wiki in browser)
Wuzzy <Wuzzy2@mail.ru>
parents:
13304
diff
changeset
|
122 |
|
a8fd5490932f
Add help button in main menu (opens Hedgewars Wiki in browser)
Wuzzy <Wuzzy2@mail.ru>
parents:
13304
diff
changeset
|
123 |
BtnSetup = addButton(":/res/Settings.png", bottomLayout, 3, true, Qt::AlignBottom); |
6699
83dd3447a212
exploit the new setWhatsThis feature in our desktop frontend
koda
parents:
6616
diff
changeset
|
124 |
BtnSetup->setWhatsThis(tr("Edit game preferences")); |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
6952
diff
changeset
|
125 |
|
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:
5763
diff
changeset
|
126 |
return bottomLayout; |
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:
5763
diff
changeset
|
127 |
} |
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:
5763
diff
changeset
|
128 |
|
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:
5763
diff
changeset
|
129 |
void PageMain::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:
5763
diff
changeset
|
130 |
{ |
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
131 |
#ifndef QT_DEBUG |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
132 |
connect(this, SIGNAL(pageEnter()), this, SLOT(updateTip())); |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
133 |
#endif |
8435 | 134 |
connect(BtnNet, SIGNAL(clicked()), this, SLOT(toggleNetworkChoice())); |
8977 | 135 |
//connect(BtnNetLocal, SIGNAL(clicked()), this, SLOT(toggleNetworkChoice())); |
136 |
//connect(BtnNetOfficial, SIGNAL(clicked()), this, SLOT(toggleNetworkChoice())); |
|
8435 | 137 |
// TODO: add signal-forwarding required by (currently missing) encapsulation |
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:
5763
diff
changeset
|
138 |
} |
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:
5763
diff
changeset
|
139 |
|
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:
5763
diff
changeset
|
140 |
PageMain::PageMain(QWidget* parent) : AbstractPage(parent) |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
5763
diff
changeset
|
141 |
{ |
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:
5763
diff
changeset
|
142 |
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:
5763
diff
changeset
|
143 |
|
8635 | 144 |
if(frontendEffects) |
145 |
setAttribute(Qt::WA_NoSystemBackground, true); |
|
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
146 |
mainNote->setOpenExternalLinks(true); |
9212 | 147 |
#ifdef QT_DEBUG |
8729 | 148 |
setDefaultDescription(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game, while some features might be broken or incomplete!")); |
8635 | 149 |
#else |
9123 | 150 |
setDefaultDescription(QLabel::tr("Tip: %1").arg(randomTip())); |
8635 | 151 |
#endif |
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:
5763
diff
changeset
|
152 |
} |
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:
5763
diff
changeset
|
153 |
|
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
154 |
void PageMain::updateTip() |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
155 |
{ |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
156 |
setDefaultDescription(QLabel::tr("Tip: %1").arg(randomTip())); |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
157 |
} |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
158 |
|
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
159 |
QString PageMain::randomTip() |
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:
5763
diff
changeset
|
160 |
{ |
8361 | 161 |
#ifdef _WIN32 |
162 |
int platform = 1; |
|
163 |
#elif defined __APPLE__ |
|
164 |
int platform = 2; |
|
165 |
#else |
|
166 |
int platform = 3; |
|
167 |
#endif |
|
9852 | 168 |
if(!Tips.length()) |
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
169 |
{ |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
170 |
DataManager & dataMgr = DataManager::instance(); |
9832
b1038b4373cc
Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents:
9212
diff
changeset
|
171 |
|
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
172 |
// get locale |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
173 |
QSettings settings(dataMgr.settingsFileName(), |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
174 |
QSettings::IniFormat); |
9832
b1038b4373cc
Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents:
9212
diff
changeset
|
175 |
|
13274
e381f5260b45
Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
11818
diff
changeset
|
176 |
QString loc = QLocale().name(); |
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
177 |
|
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
178 |
QString tipFile = QString("physfs://Locale/tips_" + loc + ".xml"); |
9832
b1038b4373cc
Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents:
9212
diff
changeset
|
179 |
|
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
180 |
// if file is non-existant try with language only |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
181 |
if (!QFile::exists(tipFile)) |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
182 |
tipFile = QString("physfs://Locale/tips_" + loc.remove(QRegExp("_.*$")) + ".xml"); |
9832
b1038b4373cc
Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents:
9212
diff
changeset
|
183 |
|
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
184 |
// fallback if file for current locale is non-existant |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
185 |
if (!QFile::exists(tipFile)) |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
186 |
tipFile = QString("physfs://Locale/tips_en.xml"); |
9832
b1038b4373cc
Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents:
9212
diff
changeset
|
187 |
|
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
188 |
QFile file(tipFile); |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
189 |
file.open(QIODevice::ReadOnly); |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
190 |
QTextStream in(&file); |
9846 | 191 |
in.setCodec("UTF-8"); |
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
192 |
QString line = in.readLine(); |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
193 |
int tip_platform = 0; |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
194 |
while (!line.isNull()) { |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
195 |
if(line.contains("<windows-only>", Qt::CaseSensitive)) |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
196 |
tip_platform = 1; |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
197 |
if(line.contains("<mac-only>", Qt::CaseSensitive)) |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
198 |
tip_platform = 2; |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
199 |
if(line.contains("<linux-only>", Qt::CaseSensitive)) |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
200 |
tip_platform = 3; |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
201 |
if(line.contains("</windows-only>", Qt::CaseSensitive) || |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
202 |
line.contains("</mac-only>", Qt::CaseSensitive) || |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
203 |
line.contains("</linux-only>", Qt::CaseSensitive)) { |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
204 |
tip_platform = 0; |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
205 |
} |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
206 |
QStringList split_string = line.split(QRegExp("</?tip>")); |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
207 |
if((tip_platform == platform || tip_platform == 0) && split_string.size() != 1) |
9835 | 208 |
Tips << split_string[1]; |
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
209 |
line = in.readLine(); |
8361 | 210 |
} |
9833
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
211 |
// The following tip will require links to app store entries first. |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
212 |
//Tips << tr("Want to play Hedgewars any time? Grab the Mobile version for %1 and %2.", "Tips").arg("").arg(""); |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
213 |
// the ios version is located here: http://itunes.apple.com/us/app/hedgewars/id391234866 |
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
214 |
|
1957c7f92460
Pick random tip from the tip file each time front page is viewed.
nemo
parents:
9832
diff
changeset
|
215 |
file.close(); |
8361 | 216 |
} |
10017 | 217 |
|
9852 | 218 |
if(Tips.length()) |
219 |
return Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()]; |
|
220 |
else |
|
221 |
return QString(); |
|
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
222 |
} |
8318 | 223 |
|
224 |
void PageMain::toggleNetworkChoice() |
|
225 |
{ |
|
226 |
bool visible = BtnNetLocal->isVisible(); |
|
227 |
BtnNetLocal->setVisible(!visible); |
|
228 |
BtnNetOfficial->setVisible(!visible); |
|
229 |
if (visible) BtnNet->setIcon(originalNetworkIcon); |
|
230 |
else BtnNet->setIcon(disabledNetworkIcon); |
|
231 |
} |
|
8982 | 232 |
|
233 |
void PageMain::resetNetworkChoice() |
|
234 |
{ |
|
235 |
BtnNetLocal->setVisible(false); |
|
236 |
BtnNetOfficial->setVisible(false); |
|
237 |
BtnNet->setIcon(originalNetworkIcon); |
|
238 |
} |