-
Notifications
You must be signed in to change notification settings - Fork 4
/
fileinformation.cpp
78 lines (66 loc) · 2.88 KB
/
fileinformation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <QPushButton>
#include "fileinformation.h"
#include "tibiahandler.h"
extern TibiaHandler g_tibiaHandler;
FileInformation::FileInformation( QWidget *parent ) : QDialog( parent ), ui( new Ui::FileInformationClass )
{
ui->setupUi(this);
ui->buttonBox->button( QDialogButtonBox::Apply )->setIcon( QIcon( ":/TibiaEditor/Resources/apply.png" ) );
updateInformation();
QObject::connect( ui->buttonBox, SIGNAL( clicked( QAbstractButton * ) ), this, SLOT( onButtonClicked( QAbstractButton * ) ) );
}
FileInformation::~FileInformation( void )
{
delete ui;
}
void FileInformation::updateInformation( void )
{
ItemFile *itemFile = g_tibiaHandler.getItemFile();
if( itemFile && itemFile->isLoaded() ) {
ui->editItemSignature->setValue( (double)itemFile->getSignature() );
ui->editItems->setText( QString::number( itemFile->getItemCount() ) );
ui->editOutfits->setText( QString::number( itemFile->getOutfitCount() ) );
ui->editEffects->setText( QString::number( itemFile->getEffectCount() ) );
ui->editProjectiles->setText( QString::number( itemFile->getProjectileCount() ) );
} else
ui->itemGroup->setShown( false );
SpriteFile *spriteFile = g_tibiaHandler.getSpriteFile();
if( spriteFile && spriteFile->isLoaded() ) {
ui->editSpriteSignature->setValue( (double)spriteFile->getSignature() );
ui->editSprites->setText( QString::number( spriteFile->getCount()-1 ) );
} else
ui->spriteGroup->setShown( false );
PictureFile *pictureFile = g_tibiaHandler.getPictureFile();
if( pictureFile && pictureFile->isLoaded() ) {
ui->editPictureSignature->setValue( (double)pictureFile->getSignature() );
ui->editPictures->setText( QString::number( pictureFile->getCount() ) );
} else
ui->pictureGroup->setShown( false );
}
void FileInformation::onButtonClicked( QAbstractButton *button )
{
switch( ui->buttonBox->buttonRole( button ) ) {
case QDialogButtonBox::ApplyRole: {
ItemFile *itemFile = g_tibiaHandler.getItemFile();
if( itemFile && itemFile->isLoaded() )
itemFile->setSignature( (quint32)ui->editItemSignature->value() );
SpriteFile *spriteFile = g_tibiaHandler.getSpriteFile();
if( spriteFile && spriteFile->isLoaded() )
spriteFile->setSignature( (quint32)ui->editSpriteSignature->value() );
PictureFile *pictureFile = g_tibiaHandler.getPictureFile();
if( pictureFile && pictureFile->isLoaded() )
pictureFile->setSignature( (quint32)ui->editPictureSignature->value() );
g_tibiaHandler.getOutputWidget()->addLine( QColor( Qt::darkGreen ), tr( "File Properties Changed." ) );
close();
}
break;
case QDialogButtonBox::RejectRole:
close();
break;
case QDialogButtonBox::ResetRole:
updateInformation();
break;
default:
break;
}
}