1 |
|
#include "wmfinalpage.h" |
2 |
|
#include "ui_wmfinalpage.h" |
3 |
|
|
4 |
< |
WmFinalPage::WmFinalPage(QString AppDir, QString wmLocation, Logger *myLogger, QList<std::shared_ptr<WmPage> > &pages, QWidget *parent) : |
4 |
> |
WmFinalPage::WmFinalPage(QString AppDir, QString wmLocation, QList<std::shared_ptr<WmPage> > &pages, QWidget *parent) : |
5 |
|
QWizardPage(parent), ui(new Ui::wmfinalpage), pages(pages) |
6 |
|
{ |
7 |
|
ui->setupUi(this); |
8 |
|
this->wmLocation=wmLocation; |
9 |
– |
this->myLogger=myLogger; |
9 |
|
|
10 |
|
this->oniSplitCommands = new QStringList(); |
11 |
< |
this->myConverter = new Converter(AppDir, this->myLogger,this->oniSplitCommands); |
11 |
> |
this->myConverter = new Converter(AppDir, this->oniSplitCommands); |
12 |
|
|
13 |
|
ui->lbComplete->setText("<html>The wizard is now complete. The window messages have been converted. " |
14 |
|
"You can view all converted files clicking <a href=' '>here.</a><br />" |
53 |
|
{ |
54 |
|
typeNode = rootNode.append_child("OPge"); |
55 |
|
typeNode.append_attribute("id").set_value(++globalSectionCounter); |
56 |
< |
typeNode.append_child("LevelNumber").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(field("leLevelId").toString())); |
57 |
< |
typeNode.append_child("Pages").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(QString("#") + QString::number(++globalSectionCounter))); |
56 |
> |
typeNode.append_child("LevelNumber").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(field("leLevelId").toString())); |
57 |
> |
typeNode.append_child("Pages").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(QString("#") + QString::number(++globalSectionCounter))); |
58 |
|
pugi::xml_node igpaNode = rootNode.append_child("IGPA"); |
59 |
|
igpaNode.append_attribute("id").set_value(globalSectionCounter); |
60 |
|
pugi::xml_node pagesNode = igpaNode.append_child("Pages"); |
61 |
|
currentIGPGId = globalSectionCounter; |
62 |
|
for(int i=0; i<this->pages.size(); i++){ |
63 |
< |
pagesNode.append_child("Link").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
63 |
> |
pagesNode.append_child("Link").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
64 |
|
} |
65 |
|
break; |
66 |
|
} |
67 |
|
case WINDOW_TYPE::DIARY: |
68 |
|
typeNode = rootNode.append_child("DPge"); |
69 |
|
typeNode.append_attribute("id").set_value(++globalSectionCounter); |
70 |
< |
typeNode.append_child("LevelNumber").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(field("leLevelId").toString())); |
71 |
< |
typeNode.append_child("PageNumber").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(field("lePageNumber").toString())); |
72 |
< |
typeNode.append_child("IsLearnedMove").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(QString::number(static_cast<int>(field("cbIsLearnedMove").toBool())))); |
70 |
> |
typeNode.append_child("LevelNumber").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(field("leLevelId").toString())); |
71 |
> |
typeNode.append_child("PageNumber").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(field("lePageNumber").toString())); |
72 |
> |
typeNode.append_child("IsLearnedMove").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(QString::number(static_cast<int>(field("cbIsLearnedMove").toBool())))); |
73 |
|
currentIGPGId = globalSectionCounter; |
74 |
< |
typeNode.append_child("Page").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
74 |
> |
typeNode.append_child("Page").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
75 |
|
break; |
76 |
|
case WINDOW_TYPE::HELP: |
77 |
|
typeNode = rootNode.append_child("HPge"); |
78 |
|
typeNode.append_attribute("id").set_value(++globalSectionCounter); |
79 |
|
currentIGPGId = globalSectionCounter; |
80 |
< |
typeNode.append_child("Page").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
80 |
> |
typeNode.append_child("Page").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
81 |
|
break; |
82 |
|
case WINDOW_TYPE::TEXT_CONSOLE: |
83 |
|
{ |
84 |
|
typeNode = rootNode.append_child("TxtC"); |
85 |
|
typeNode.append_attribute("id").set_value(++globalSectionCounter); |
86 |
< |
typeNode.append_child("Pages").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
86 |
> |
typeNode.append_child("Pages").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
87 |
|
pugi::xml_node igpaNode = rootNode.append_child("IGPA"); |
88 |
|
igpaNode.append_attribute("id").set_value(globalSectionCounter); |
89 |
|
currentIGPGId = globalSectionCounter; |
90 |
|
pugi::xml_node pagesNode = igpaNode.append_child("Pages"); |
91 |
|
for(int i=0; i<this->pages.size(); i++){ |
92 |
< |
pagesNode.append_child("Link").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
92 |
> |
pagesNode.append_child("Link").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
93 |
|
} |
94 |
|
break; |
95 |
|
} |
96 |
|
case WINDOW_TYPE::WEAPON: |
97 |
|
typeNode = rootNode.append_child("WPge"); |
98 |
|
typeNode.append_attribute("id").set_value(++globalSectionCounter); |
99 |
< |
typeNode.append_child("WeaponClass").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(field("leWeaponClassName").toString())); |
99 |
> |
typeNode.append_child("WeaponClass").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(field("leWeaponClassName").toString())); |
100 |
|
currentIGPGId = globalSectionCounter; |
101 |
< |
typeNode.append_child("Page").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
101 |
> |
typeNode.append_child("Page").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
102 |
|
break; |
103 |
|
case WINDOW_TYPE::ITEM: |
104 |
|
typeNode = rootNode.append_child("IPge"); |
105 |
|
typeNode.append_attribute("id").set_value(++globalSectionCounter); |
106 |
< |
typeNode.append_child("PageNumber").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(field("lePageNumber").toString())); |
106 |
> |
typeNode.append_child("PageNumber").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(field("lePageNumber").toString())); |
107 |
|
currentIGPGId = globalSectionCounter; |
108 |
< |
typeNode.append_child("Page").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
108 |
> |
typeNode.append_child("Page").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
109 |
|
break; |
110 |
|
case WINDOW_TYPE::ENUM_END: |
111 |
< |
UtilVago::showAndLogErrorPopUp(this->myLogger, "An error ocurred: WmFinalPage::startProcessing invalid WINDOW_TYPE"); |
111 |
> |
UtilVago::showAndLogErrorPopUp("An error ocurred: WmFinalPage::startProcessing invalid WINDOW_TYPE"); |
112 |
|
break; |
113 |
|
} |
114 |
|
|
130 |
|
imageTXMPName = "TXMP" + QFileInfo(imageLocation).baseName(); |
131 |
|
|
132 |
|
this->oniSplitCommands->clear(); |
133 |
< |
this->oniSplitCommands->append("-create:txmp " + Util::insertQuotes(this->wmLocation) + " -format:bgr32 " + Util::insertQuotes(imageLocation)); |
133 |
> |
this->oniSplitCommands->append("-create:txmp " + Util::String::insertQuotes(this->wmLocation) + " -format:bgr32 " + Util::String::insertQuotes(imageLocation)); |
134 |
|
|
135 |
|
this->myConverter->start(); // finally process the onisplit commands |
136 |
|
this->myConverter->wait(); // wait for it to complete |
150 |
|
|
151 |
|
currentIGSAId = globalSectionCounter; |
152 |
|
|
153 |
< |
igpgNode.append_child("Image").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(imageTXMPName)); |
154 |
< |
igpgNode.append_child("Text1").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
155 |
< |
igpgNode.append_child("Text2").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
153 |
> |
igpgNode.append_child("Image").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(imageTXMPName)); |
154 |
> |
igpgNode.append_child("Text1").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
155 |
> |
igpgNode.append_child("Text2").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
156 |
|
|
157 |
|
// IGSA |
158 |
|
|
164 |
|
currentIGSTId = globalSectionCounter; |
165 |
|
|
166 |
|
for(int i=0; i<mainTextNumberOfRows; i++){ |
167 |
< |
igsaMainTextStringsNode.append_child("Link").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
167 |
> |
igsaMainTextStringsNode.append_child("Link").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
168 |
|
} |
169 |
|
|
170 |
|
////// Footer |
172 |
|
igsaFooterTextNode.append_attribute("id").set_value(++currentIGSAId); |
173 |
|
pugi::xml_node igsaFooterTextStringsNode = igsaFooterTextNode.append_child("Strings"); |
174 |
|
for(int i=0; i<footerTextNumberOfRows; i++){ |
175 |
< |
igsaFooterTextStringsNode.append_child("Link").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("#" + QString::number(++globalSectionCounter))); |
175 |
> |
igsaFooterTextStringsNode.append_child("Link").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("#" + QString::number(++globalSectionCounter))); |
176 |
|
} |
177 |
|
|
178 |
|
// IGSt |
200 |
|
igstMainTextNode.append_attribute("id").set_value(++currentIGSTId); |
201 |
|
|
202 |
|
pugi::xml_node igstMainTextFontNode = igstMainTextNode.append_child("Font"); |
203 |
< |
igstMainTextFontNode.append_child("Family").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr("TSFF" + format.font().family())); |
204 |
< |
igstMainTextFontNode.append_child("Style").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(style)); |
205 |
< |
igstMainTextFontNode.append_child("Color").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(colorRGB)); |
206 |
< |
igstMainTextFontNode.append_child("Size").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(QString::number(format.font().pointSize()))); |
203 |
> |
igstMainTextFontNode.append_child("Family").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR("TSFF" + format.font().family())); |
204 |
> |
igstMainTextFontNode.append_child("Style").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(style)); |
205 |
> |
igstMainTextFontNode.append_child("Color").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(colorRGB)); |
206 |
> |
igstMainTextFontNode.append_child("Size").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(QString::number(format.font().pointSize()))); |
207 |
|
igstMainTextFontNode.append_child("Flags").append_child(pugi::xml_node_type::node_pcdata).set_value("Family Style Color Size"); |
208 |
|
|
209 |
< |
igstMainTextNode.append_child("Text").append_child(pugi::xml_node_type::node_pcdata).set_value(Util::qStrToCstr(currentCursor.selection().toPlainText())); |
209 |
> |
QString currentRowText = currentCursor.selection().toPlainText(); |
210 |
> |
|
211 |
> |
pugi::xml_node currentIGStNode = igstMainTextNode.append_child("Text"); |
212 |
> |
|
213 |
> |
if(!currentRowText.trimmed().isEmpty()){ |
214 |
> |
currentIGStNode.append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_CSTR(currentRowText)); |
215 |
> |
} |
216 |
> |
else{ |
217 |
> |
// Empty paragraph use OniSplit correct representation (<Text xml:space="preserve"> </Text>) |
218 |
> |
currentIGStNode.append_child(pugi::xml_node_type::node_pcdata).set_value(" "); |
219 |
> |
currentIGStNode.append_attribute("xml:space").set_value("preserve"); |
220 |
> |
} |
221 |
|
} |
222 |
|
|
223 |
|
}; |
229 |
|
setIGStXmlSection(footerText, footerTextNumberOfRows); |
230 |
|
} |
231 |
|
|
232 |
< |
if(!doc.save_file(Util::qStrToCstr(filePath))){ |
233 |
< |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't create " + filePath + " file!"); |
232 |
> |
if(!doc.save_file(QSTR_TO_CSTR(filePath))){ |
233 |
> |
UtilVago::showAndLogErrorPopUpLogButton("Couldn't create " + filePath + " file!"); |
234 |
|
return; |
235 |
|
} |
236 |
|
|
237 |
|
// Convert XML file to Oni |
238 |
|
this->oniSplitCommands->clear(); |
239 |
< |
this->oniSplitCommands->append("-create " + Util::insertQuotes(this->wmLocation) + " " + Util::insertQuotes(filePath)); |
239 |
> |
this->oniSplitCommands->append("-create " + Util::String::insertQuotes(this->wmLocation) + " " + Util::String::insertQuotes(filePath)); |
240 |
|
|
241 |
|
this->myConverter->start(); // finally process the onisplit commands |
242 |
|
this->myConverter->wait(); // wait for it to complete |