1 | #include "bgimagepage3.h"
|
---|
2 | #include "ui_bgimagepage3.h"
|
---|
3 |
|
---|
4 | BGImagePage3::BGImagePage3(QWidget *parent) :
|
---|
5 | QWizardPage(parent),
|
---|
6 | ui(new Ui::BGImagePage3)
|
---|
7 | {
|
---|
8 | ui->setupUi(this);
|
---|
9 |
|
---|
10 | //Register fields
|
---|
11 | registerField("cbCreateTXMB", ui->cbCreateTXMB);
|
---|
12 | registerField("cbCreateTXMP", ui->cbCreateTXMP);
|
---|
13 | registerField("leLevelId", ui->leLevelId);
|
---|
14 | registerField("leImageName", ui->leImageName);
|
---|
15 | registerField("leTXMBName", ui->leTXMBName);
|
---|
16 | }
|
---|
17 |
|
---|
18 | BGImagePage3::~BGImagePage3()
|
---|
19 | {
|
---|
20 | delete ui;
|
---|
21 | }
|
---|
22 |
|
---|
23 | void BGImagePage3::initializePage()
|
---|
24 | {
|
---|
25 | // To the first time the page is displayed and when the wizard is restarted
|
---|
26 | generateImageName();
|
---|
27 | }
|
---|
28 |
|
---|
29 | void BGImagePage3::on_cbCreateTXMP_toggled(bool checked)
|
---|
30 | {
|
---|
31 | if(!checked){
|
---|
32 | ui->cbCreateTXMB->setDisabled(true);
|
---|
33 | ui->cbCreateTXMB->setChecked(false);
|
---|
34 | }
|
---|
35 | else{
|
---|
36 | ui->cbCreateTXMB->setDisabled(false);
|
---|
37 | }
|
---|
38 |
|
---|
39 | }
|
---|
40 |
|
---|
41 | void BGImagePage3::on_cbCreateTXMB_toggled(bool checked)
|
---|
42 | {
|
---|
43 | if(!checked){
|
---|
44 | ui->leTXMBName->setDisabled(true);
|
---|
45 | ui->leTXMBName->clear();
|
---|
46 | }
|
---|
47 | else{
|
---|
48 | ui->leTXMBName->setDisabled(false);
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|
52 | void BGImagePage3::on_leLevelId_textChanged(const QString &arg1)
|
---|
53 | {
|
---|
54 | if(!arg1.isEmpty() && !Util::Validation::isStringInteger(arg1)){
|
---|
55 | Util::Dialogs::showError("Level id must be a number.");
|
---|
56 | ui->leLevelId->clear();
|
---|
57 | return;
|
---|
58 | }
|
---|
59 |
|
---|
60 | if(!arg1.trimmed().isEmpty()){
|
---|
61 | generateImageName();
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | void BGImagePage3::on_cbTargetForImage_currentIndexChanged(const QString)
|
---|
66 | {
|
---|
67 | generateImageName();
|
---|
68 | }
|
---|
69 |
|
---|
70 | void BGImagePage3::generateImageName(){
|
---|
71 |
|
---|
72 | QString type = ui->cbTargetForImage->currentText();
|
---|
73 | QString backgroundName;
|
---|
74 | QString txmbName;
|
---|
75 | QString levelNumber = "00";
|
---|
76 |
|
---|
77 | if(ui->leLevelId->text().length() == 1){
|
---|
78 | levelNumber = ("0" + ui->leLevelId->text());
|
---|
79 | }
|
---|
80 | else if(ui->leLevelId->text().length() > 1){
|
---|
81 | levelNumber = ui->leLevelId->text();
|
---|
82 | }
|
---|
83 |
|
---|
84 | if(type == "Other"){
|
---|
85 | backgroundName = "TXMPother";
|
---|
86 | txmbName = "TXMBother";
|
---|
87 | ui->leLevelId->clear();
|
---|
88 | ui->leLevelId->setEnabled(false);
|
---|
89 | }
|
---|
90 | else if(type == "Intro Screen"){
|
---|
91 | backgroundName = "TXMPlevel" + levelNumber + "_intro_";
|
---|
92 | txmbName = "TXMBintro_splash_screen";
|
---|
93 | ui->leLevelId->setEnabled(true);
|
---|
94 | }
|
---|
95 | else if(type == "Win Screen"){
|
---|
96 | backgroundName = "TXMPlevel" + levelNumber + "_win_";
|
---|
97 | txmbName = "TXMBwin_splash_screen";
|
---|
98 | ui->leLevelId->setEnabled(true);
|
---|
99 | }
|
---|
100 | else if(type == "Loose Screen"){
|
---|
101 | backgroundName = "TXMPfail01_";
|
---|
102 | txmbName = "TXMBfail_splash_screen";
|
---|
103 | ui->leLevelId->clear();
|
---|
104 | ui->leLevelId->setEnabled(false);
|
---|
105 | }
|
---|
106 | else if(type == "Main Menu Screen"){
|
---|
107 | backgroundName = "TXMPOni_startup_";
|
---|
108 | txmbName = "TXMBpict_mainmenu";
|
---|
109 | ui->leLevelId->clear();
|
---|
110 | ui->leLevelId->setEnabled(false);
|
---|
111 | }
|
---|
112 | else if(type == "Options Menu Screen"){
|
---|
113 | backgroundName = "TXMPoptions_";
|
---|
114 | txmbName = "TXMBpict_options_background";
|
---|
115 | ui->leLevelId->clear();
|
---|
116 | ui->leLevelId->setEnabled(false);
|
---|
117 | }
|
---|
118 | else if(type == "Load Level Screen"){
|
---|
119 | backgroundName = "TXMPoni_kanji_";
|
---|
120 | txmbName = "TXMBpict_loadgame_background";
|
---|
121 | ui->leLevelId->clear();
|
---|
122 | ui->leLevelId->setEnabled(false);
|
---|
123 | }
|
---|
124 |
|
---|
125 | ui->leImageName->setText(backgroundName);
|
---|
126 |
|
---|
127 | if(ui->cbCreateTXMB->isChecked()){
|
---|
128 | ui->leTXMBName->setText(txmbName);
|
---|
129 | }
|
---|
130 | }
|
---|
131 |
|
---|
132 |
|
---|
133 | bool BGImagePage3::validatePage(){
|
---|
134 |
|
---|
135 | QStringList namesList;
|
---|
136 |
|
---|
137 | if(ui->leImageName->text().trimmed().isEmpty()){
|
---|
138 | Util::Dialogs::showError("You need to input a name to the image!");
|
---|
139 | return false;
|
---|
140 | }
|
---|
141 |
|
---|
142 | if(ui->cbCreateTXMB->isChecked() && ui->leTXMBName->text().trimmed().isEmpty()){
|
---|
143 | Util::Dialogs::showError("You need to input a name to the TXMB file!");
|
---|
144 | return false;
|
---|
145 | }
|
---|
146 |
|
---|
147 | return true;
|
---|
148 | }
|
---|
149 |
|
---|