-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmameopt.h
218 lines (181 loc) · 5.19 KB
/
mameopt.h
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#ifndef _MAMEOPT_H_
#define _MAMEOPT_H_
#include <QtGui>
#include "ui_options.h"
#include "ui_csvcfg.h"
enum
{
MAMEOPT_TYPE_BOOL = 100,
MAMEOPT_TYPE_INT,
MAMEOPT_TYPE_FLOAT,
MAMEOPT_TYPE_STRING,
MAMEOPT_TYPE_STRING_EDITABLE,
MAMEOPT_TYPE_FILE,
MAMEOPT_TYPE_DATFILE,
MAMEOPT_TYPE_CFGFILE,
MAMEOPT_TYPE_EXEFILE,
MAMEOPT_TYPE_DIR,
MAMEOPT_TYPE_DIRS,
MAMEOPT_TYPE_CSV,
MAMEOPT_TYPE_UNKNOWN
//MAMEOPT_TYPE_COLOR,
};
enum
{
OPTLEVEL_GUI = 0,
OPTLEVEL_GLOBAL,
OPTLEVEL_SRC,
OPTLEVEL_BIOS,
OPTLEVEL_CLONEOF,
OPTLEVEL_CURR,
OPTLEVEL_LAST
};
class OptionsUI : public QDialog, public Ui::OptionsUI
{
Q_OBJECT
public:
OptionsUI(QWidget *parent = 0);
QList<QListWidget *> optCtrls;
void init(int, int = -1);
protected:
void showEvent(QShowEvent *);
void closeEvent(QCloseEvent *);
};
//a custom widget shown in the right side of each option item to restore default value
class ResetWidget : public QWidget
{
Q_OBJECT
public:
QWidget *subWidget;
QWidget *subWidget2;
ResetWidget(/*QtProperty *property,*/ QWidget *parent = 0);
void setWidget(QWidget *, QWidget * = NULL, int = 0, int = 0);
void setResetEnabled(bool enabled);
/* void setValueText(const QString &text);
void setValueIcon(const QIcon &icon);*/
void setSpacing(int spacing);
signals:
// void resetProperty(QtProperty *property);
public slots:
void updateSliderLabel(int);
private:
// QtProperty *m_property;
QLabel *_textLabel;
QLabel *_iconLabel;
QSlider *_slider;
QLabel *_sliderLabel;
QToolButton *_btnSetDlg;
QToolButton *_btnReset;
int ctrlSpacing;
int optType;
int sliderOffset;
private slots:
void slotClicked();
};
//for csv options
class CsvCfgUI : public QDialog, public Ui::CsvCfgUI
{
Q_OBJECT
public:
CsvCfgUI(QWidget *parent = 0);
void init(QString, QMap<QString, bool>);
QString getCSV();
};
class OptionDelegate : public QItemDelegate
{
Q_OBJECT
public:
OptionDelegate(QObject *parent = 0);
QSize sizeHint ( const QStyleOptionViewItem & option,
const QModelIndex & index ) const;
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index ) const;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &index) const;
public slots:
void sync();
void saveChange(bool b);
void saveChange(int index);
void saveChange(const QString &);
void setChangesAccepted();
void setCSV();
void setCSVAccepted();
void setDirectories();
void setDirectoriesAccepted();
void setDirectory();
void setFile(QString = "", ResetWidget* = NULL);
void setDatFile();
void setExeFile();
void setCfgFile();
private:
ResetWidget *rWidget;
bool isReset;
QString csvBuf;
};
class MameOption : public QObject
{
public:
QString guiname, defvalue, description, currvalue, max, min,
globalvalue, srcvalue, biosvalue, cloneofvalue;
int type;
bool guivisible, globalvisible, srcvisible, biosvisible, cloneofvisible, gamevisible;
QStringList values;
QStringList guivalues;
MameOption(QObject *parent = 0);
};
class OptInfo : public QObject
{
public:
QListWidget *optCatView;
QTreeView *optView;
QStandardItemModel *optModel;
OptInfo(QListWidget *, QTreeView *, QObject *parent = 0);
};
class OptionUtils : public QObject
{
Q_OBJECT
public:
OptionUtils(QObject *parent = 0);
//init option-related GUI
void init();
QVariant getField(const QModelIndex &, int);
const QString getLongName(QString);
const QString getLongValue(const QString &, const QString &);
const QString getShortValue(const QString &, const QString &);
QColor inheritColor(const QModelIndex &);
bool isChanged(const QModelIndex &);
bool isTitle(const QModelIndex &);
void updateSelectableItems(QString);
void loadDefault(QString);
void saveIniFile(int , const QString &);
public slots:
//core:update mameOpts by loading .ini files of different levels
//gui:determine what to update in the option dialog
//method 0 updates model, method 1 loads ini only
void chainLoadOptions(QListWidgetItem *currItem = 0, int optLevel = -1, QString gameName = "", int method = 0);
void updateHeaderSize(int, int, int);
private:
//option category map, option category as key, names as value list
QMap<QString, QStringList> optCatMap;
QList<OptInfo *> optInfos;
void loadIni(int, const QString &);
void loadTemplate();
QHash<QString, QString> parseIni(QTextStream &in, bool isInitOptCatMap);
void addModelItemTitle(QStandardItemModel*, QString);
void addModelItem(QStandardItemModel*, QString);
void updateModel(const QString&, int);
};
extern OptionUtils *optUtils;
extern QHash<QString, MameOption*> mameOpts;
extern QByteArray option_column_state;
extern QByteArray option_geometry;
extern QString mameIniPath;
extern bool isSDLPort;
extern bool hasLanguage;
extern bool hasIPS;
extern bool hasDevices;
#endif