ff7tk  0.02
Toolkit for making FF7 Tools
AchievementEditor.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // copyright 2013 -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 #include "AchievementEditor.h"
17 
18 AchievementEditor::AchievementEditor(qreal Scale,QWidget *parent) :
19  QWidget(parent)
20 {
21  scale = Scale;
22  initDisplay();
23  initConnect();
24 }
26 {
27  connect(achievementList,SIGNAL(clicked(QModelIndex)),this,SLOT(itemToggled(QModelIndex)));
28 }
30 {
31  disconnect(achievementList,SIGNAL(clicked(QModelIndex)),this,SLOT(itemToggled(QModelIndex)));
32 }
34 {
35  achievementList = new QListWidget;
36  achievementList->setIconSize(QSize(24*scale,24*scale));
37  //achievementList->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
38 
39  QGridLayout * layout = new QGridLayout;
40  for(int i=63;i>27;--i)
41  {
42  QPixmap pix(QString(":/achievements/%1").arg(QString::number(i)));
43  QListWidgetItem *newItem =new QListWidgetItem(QIcon(pix),achievements.name(i),0,0);
44  newItem->setCheckState(Qt::Unchecked);
45  achievementList->addItem(newItem);
46  }
47  layout->addWidget(achievementList);
48  this->setLayout(layout);
49  this->setFixedWidth(achievementList->width());
50 
51 }
52 bool AchievementEditor::openFile(QString fileName)
53 {
54  bool open = achievements.openFile(fileName);
56  for(int i=0;i<36;++i)
57  {
58  if(achievements.achievmentUnlocked(63-i)){achievementList->item(i)->setCheckState(Qt::Checked);}
59  else{achievementList->item(i)->setCheckState(Qt::Unchecked);}
60  }
61  initConnect();
62  return open;
63 }
64 void AchievementEditor::itemToggled(QModelIndex index)
65 {
66  if(achievementList->item(index.row())->checkState() ==Qt::Checked)
67  {
68  achievements.setAchievementUnlocked(63- index.row(),true);
69  }
70  else{achievements.setAchievementUnlocked(63- index.row(),false);}
71 }
72 bool AchievementEditor::saveFile(QString fileName)
73 {
74  return achievements.saveFile(fileName);
75 }
bool saveFile(QString fileName="")
Attempt to save a file.
qreal scale
Scale value for hidpi systems.
bool openFile(QString fileName="")
open a file.
QString name(int bit)
Translate name for Achievement bit.
bool saveFile(QString fileName="")
saves a file.
bool achievmentUnlocked(int bit)
is Achievement @ bit unlocked?
AchievementEditor(qreal Scale=1, QWidget *parent=0)
create a new AchievementEditor
void setAchievementUnlocked(int bit, bool unlocked)
set Achievement @ bit to unlocked
FF7Achievements achievements
data class for widget
bool openFile(QString fileName="")
Attempt to Open a file.
QListWidget * achievementList
QListWidget that will contain the list of achievements.
void itemToggled(QModelIndex index)
an item has been toggled
void initConnect(void)
Connect objects.
void initDisplay(void)
create this items widgets
void initDisconnect(void)
Disconnect object.