ff7tk  0.02
Toolkit for making FF7 Tools
mainwindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // copyright 2012 - 2016 Chris Rizzitello <sithlord48@gmail.com> //
3 // //
4 // This file is part of FF7tk //
5 // //
6 // FF7tk is free software: you can redistribute it and/or modify //
7 // it under the terms of the GNU General Public License as published by //
8 // the Free Software Foundation, either version 3 of the License, or //
9 // (at your option) any later version. //
10 // //
11 // FF7tk is distributed in the hope that it will be useful, //
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
14 // GNU General Public License for more details. //
15 /****************************************************************************/
16 /****************************************************************************/
17 // This Demo Program Just Shows Widgets For Easier Testing //
18 #include "mainwindow.h"
19 #include "ui_mainwindow.h"
20 #include "QFileDialog"
21 MainWindow::MainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::MainWindow)
22 {
23  ui->setupUi(this);
24 
25  hideAllBoxes();
26  ui->sb_scale->setValue(qApp->desktop()->logicalDpiX()/96);
27  scale = qApp->desktop()->logicalDpiX()/96;
28 
29  ListPHS = new PhsListWidget(scale,0);
30  QHBoxLayout *listLayout = new QHBoxLayout;
31  listLayout->addWidget(ListPHS);
32  ui->phsListBox->setLayout(listLayout);
33 
34  ListMenu = new MenuListWidget(scale,0);
35  QHBoxLayout *list2Layout = new QHBoxLayout;
36  list2Layout->addWidget(ListMenu);
37  ui->menuListBox->setLayout(list2Layout);
38 
40  QHBoxLayout *options_layout = new QHBoxLayout();
41  options_layout->addWidget(optionsWidget);
42  ui->dialog_preview_box->setLayout(options_layout);
43 
45  QHBoxLayout *materia_editor_layout= new QHBoxLayout();
46  materia_editor_layout->addWidget(materia_editor);
47  ui->editor_box->setLayout(materia_editor_layout);
48 
50  QHBoxLayout * char_editor_layout = new QHBoxLayout();
51  char_editor_layout->addWidget(char_editor);
52  ui->charEditor_box->setLayout(char_editor_layout);
53 
54  item_list = new ItemList(scale);
55  QHBoxLayout *item_list_layout = new QHBoxLayout;
56  item_list_layout->addWidget(item_list);
57  ui->itemList_box->setLayout(item_list_layout);
58 
59  locViewer = new LocationViewer(scale,this);
60  QHBoxLayout *locLayout = new QHBoxLayout();
61  locLayout->addWidget(locViewer);
62  ui->innerLocBox->setLayout(locLayout);
63 
65  QHBoxLayout *ChocoboManagerLayout = new QHBoxLayout();
66  ChocoboManagerLayout->addWidget(chocoboManager);
67  ui->ChocoboManagerBox->setLayout(ChocoboManagerLayout);
68  chocoboManager->setHoverStyle(QString("rgba(%1,%2,%3,128);").arg(QString::number(this->palette().highlight().color().red()),QString::number(this->palette().highlight().color().green()),QString::number(this->palette().highlight().color().blue())));
69 
71  QVBoxLayout *AchievementLayout = new QVBoxLayout();
72  AchievementLayout->addWidget(achievementEditor);
73  ui->achievementEditor_Frame->setLayout(AchievementLayout);
74 
76  QVBoxLayout *charManagerLayout =new QVBoxLayout;
77  charManagerLayout->addWidget(charManager);
78  ui->CharManager_Box->setLayout(charManagerLayout);
79 
80  lgpFile=0;
81 }
82 
84 
86 {
87  hideAllBoxes();
88  switch(index)
89  {
90  case 1:ui->dialog_preview_box->setVisible(1); break;
91  case 2:ui->materia_editor_box->setVisible(1); break;
92  case 3:ui->item_list_box->setVisible(1);break;
93  case 4:ui->char_editor_box->setVisible(1); break;
94  case 5:ui->metadata_box->setVisible(1);break;
95  case 6:ui->slotSelect_Box->setVisible(1);break;
96  case 7:ui->phsListBox->setVisible(1);break;
97  case 8:ui->menuListBox->setVisible(1);break;
98  case 9:ui->lgp_Box->setVisible(1);break;
99  case 10:ui->locListBox->setVisible(1);break;
100  case 11:ui->ChocoboManagerBox->setVisible(1);break;
101  case 12:ui->AchievementEditor_Box->setVisible(1);break;
102  case 13:ui->CharManager_Box->setVisible(1);break;
103  };
104  this->adjustSize();
105 }
106 
111 
113 {
114  QByteArray temp;
115  temp.fill(0x00,132);
116  FF7CHAR c_data;
117  memcpy(&c_data,temp,132);
118  char_editor->setChar(c_data,QString("Cloud"));
119 }
120 
121 
123 {
124  FF7Save *ff7save = new FF7Save();
125  metadataCreator = new MetadataCreator(this,ff7save);
126  metadataCreator->exec();
127 }
128 
130 {
131  FF7Save *ff7save = new FF7Save();
132  QString fileFilter("Multi Slot Save Types (*.ff7 *.vmp *.vgs *.mem *.gme *.mcr *.mcd *.mci *.mc *.ddf *.ps *.psm *.VM1 *.bin *.psv);;PC FF7 SaveGame (*.ff7);;MC SaveGame (*.mcr *.mcd *.mci *.mc *.ddf *.ps *.psm *.VM1 *.bin);;PSP SaveGame (*.vmp);;VGS SaveGame(*.vgs *.mem);;Dex-Drive SaveGame(*.gme)");
133  QString filename = QFileDialog::getOpenFileName(this,"Select A Save To Preview",QDir::homePath(),fileFilter);
134  if(!filename.isEmpty())
135  {
136  if(ff7save->loadFile(filename))
137  {
138  SlotSelect *slotSelect = new SlotSelect(scale,ff7save,ui->cbShowLoad->isChecked());
139  if (slotSelect->exec()== -1){on_btn_slotSelect_clicked();}
140  else{return;}
141  }
142  else {QMessageBox::critical(this,QString(tr("File Error")),QString(tr("Error Loading File: %1")).arg(filename));}
143  }
144 }
145 
147 {
148  ui->listLgpFile->clear();
149  QString fileName = QFileDialog::getOpenFileName(this,"Select Lgp Archive",QDir::homePath(),"Lgp Archive(*.lgp)");
150  if(fileName.isEmpty()){return;}
151  else
152  {
153  lgpFile = new Lgp(fileName);
154  if(!lgpFile->open()){QMessageBox::information(this,"Error","Failed To Open Lgp Archive");}
155  else
156  {
157  ui->listLgpFile->addItems(lgpFile->fileList());
158  ui->lblLgpCompany->setText(QString("Company: %1").arg(lgpFile->companyName()));
159  ui->lblLgpProduct->setText(QString("Product: %1").arg(lgpFile->productName()));
160  QString title = fileName;
161  title.remove(0,fileName.lastIndexOf("/")+1);
162  title.append(QString (" (%1 files)").arg(lgpFile->fileList().count()));
163  ui->groupLgpView->setTitle(title);
164  ui->groupLgpView->setVisible(true);
165  }
166  }
167 }
169 {
170  QString extPath = QFileDialog::getExistingDirectory(this,"Select Path To Extract Files",QDir::homePath());
171  if(extPath.isEmpty()){return;}
172  else
173  {
174  for(int i=0;i<ui->listLgpFile->count();i++)
175  {
176  QString fileName = extPath;
177  fileName.append(QString("/%1").arg(lgpFile->fileList().at(i)));
178  QFile file(fileName);
179  if(!file.open(QFile::WriteOnly)){return;}
180  else
181  {
182  file.write(lgpFile->fileData(lgpFile->fileList().at(i)));
183  file.close();
184  }
185  }
186  QMessageBox::information(this,"Lgp Utility",QString("Extracted %1 File(s).").arg(lgpFile->fileList().count()));
187  }
188 }
190 {
191  ui->dialog_preview_box->setVisible(0);
192  ui->materia_editor_box->setVisible(0);
193  ui->char_editor_box->setVisible(0);
194  ui->item_list_box->setVisible(0);
195  ui->metadata_box->setVisible(0);
196  ui->slotSelect_Box->setVisible(0);
197  ui->phsListBox->setVisible(0);
198  ui->menuListBox->setVisible(0);
199  ui->lgp_Box->setVisible(0);
200  ui->groupLgpView->setVisible(0);
201  ui->locListBox->setVisible(0);
202  ui->ChocoboManagerBox->setVisible(0);
203  ui->AchievementEditor_Box->setVisible(0);
204  ui->CharManager_Box->setVisible(0);
205 }
206 
208 {
209  QString fileFilter("*.dat (*.dat);");
210  QString filename = QFileDialog::getOpenFileName(this,"Select An Achievement File To Preview",QDir::homePath(),fileFilter);
211  achievementEditor->openFile(filename);
212 }
213 
215 {
216  QString fileName=QFileDialog::getSaveFileName(this,"Select File to Save",QDir::home().absolutePath(),"*.dat (*.dat);");
217  if(!fileName.isEmpty()){achievementEditor->saveFile(fileName);}
218 }
219 
222 
A QWidget editor for achievements.dat file from 2012 and 2013 release of Final Fantasy 7...
ItemList * item_list
Definition: mainwindow.h:84
void setEditable(bool)
LocationViewer * locViewer
Definition: mainwindow.h:90
void on_cb_materia_editor_setEditable_toggled(bool checked)
Definition: mainwindow.cpp:108
void on_cb_charEditor_clicked(bool checked)
Definition: mainwindow.cpp:109
QStringList fileList() const
Returns a list of file paths sorted by file position.
Definition: Lgp.cpp:190
void on_checkBox_3_clicked(bool checked)
Definition: mainwindow.cpp:223
void setStarsSize(int)
void on_btn_loadAchievement_clicked()
Definition: mainwindow.cpp:207
Definition: mainwindow.h:43
Widget to allow editing of a character using FF7Char for data.
Definition: CharEditor.h:37
bool openFile(QString fileName="")
open a file.
void setAdvancedMode(bool)
void setAdvancedMode(bool advancedMode)
CharManager * charManager
Definition: mainwindow.h:94
Easily manage the who can be in the phs.
Definition: PhsListWidget.h:31
Set Saves Location or View Field Locations and Toggle the items picked up from them.
void on_btn_slotSelect_clicked()
Definition: mainwindow.cpp:129
OptionsWidget * optionsWidget
Definition: mainwindow.h:91
const QString & companyName()
Returns the company name (like "SQUARESOFT") or a null string if there is an error.
Definition: Lgp.cpp:350
qreal scale
Definition: mainwindow.h:81
void on_pushButton_clicked()
Definition: mainwindow.cpp:112
void setEditableComboBoxes(bool)
bool saveFile(QString fileName="")
saves a file.
Character Info in the save game.
void on_cbEditableMateriaCombos_clicked(bool checked)
Definition: mainwindow.cpp:224
void on_sb_materia_editor_setStarSize_valueChanged(int arg1)
Definition: mainwindow.cpp:107
void on_lineEdit_editingFinished()
Definition: mainwindow.cpp:220
void setEditableItemCombo(bool)
Definition: ItemList.cpp:267
void on_checkBox_2_toggled(bool checked)
Definition: mainwindow.cpp:221
bool loadFile(const QString &fileName)
attempt to load fileName as ff7save
Definition: FF7Save.cpp:50
MenuListWidget * ListMenu
Definition: mainwindow.h:88
void on_checkBox_4_clicked(bool checked)
Definition: mainwindow.cpp:225
void on_btnExtractLgp_clicked()
Definition: mainwindow.cpp:168
const QString & productName()
Returns the product name (like "FINAL FANTASY7") or a null string if there is an error.
Definition: Lgp.cpp:387
Ui::MainWindow * ui
Definition: mainwindow.h:80
void on_checkBox_toggled(bool checked)
Definition: mainwindow.cpp:110
edit saves from Final Fantasy 7
Definition: FF7Save.h:58
easily manage the menus in Final Fantasy 7
void setEditable(bool)
MainWindow(QWidget *parent=0)
Definition: mainwindow.cpp:21
Definition: Lgp.h:55
void setHoverStyle(QString backgroundColor)
ChocoboManager * chocoboManager
Definition: mainwindow.h:92
void on_btn_showmetaData_clicked()
Definition: mainwindow.cpp:122
void hideAllBoxes(void)
Definition: mainwindow.cpp:189
AchievementEditor * achievementEditor
Definition: mainwindow.h:93
QByteArray fileData(const QString &filePath)
Returns the data for the file named filePath.
Definition: Archive.cpp:65
MetadataCreator * metadataCreator
Definition: mainwindow.h:85
void setSelected(QString)
CharEditor * char_editor
Definition: mainwindow.h:83
Display a preview of the contents of a PSX memory card file or FF7 PC save.
Definition: SlotSelect.h:38
MateriaEditor * materia_editor
Definition: mainwindow.h:82
void setChar(FF7CHAR Chardata, QString Processed_Name="")
void on_btn_saveAchievement_clicked()
Definition: mainwindow.cpp:214
void on_combo_widget_currentIndexChanged(int index)
Definition: mainwindow.cpp:85
A Single widget to allow you to set all the options for the game will save emit a signal when any opt...
Definition: OptionsWidget.h:31
PhsListWidget * ListPHS
Definition: mainwindow.h:87
void on_btn_lgpSelect_clicked()
Definition: mainwindow.cpp:146
Lgp * lgpFile
Definition: mainwindow.h:89
virtual bool open()
Opens the archive, returning true if successful; otherwise false.
Definition: Archive.cpp:128
void setEditableMateriaCombo(bool enabled)