Skip to content

Commit aeabec3

Browse files
author
roseclarkh
committed
add game have/miss export(OrochiZ @ PPXClub)
git-svn-id: https://mameplus.svn.sourceforge.net/svnroot/mameplus/trunk/mamepgui@5166 e0215e0a-1e64-f442-9f1d-d2f61a7f4648
1 parent 96be4b4 commit aeabec3

File tree

5 files changed

+143
-37
lines changed

5 files changed

+143
-37
lines changed

Diff for: gamelist.cpp

+69-33
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,8 @@ void GameListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
991991
return;
992992
}
993993

994+
bool isLView = gameList->listMode == "LargeIcons";
995+
994996
QString gameName = gameList->getViewString(index, COL_NAME);
995997
GameInfo *gameInfo = gameList->getGameInfo(index, gameName);
996998

@@ -1037,7 +1039,14 @@ void GameListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
10371039
const bool isLargeIcon = pmIcon.width() > 16;
10381040
const bool isZooming = win->actionRowDelegate->isChecked();
10391041

1040-
if (isLargeIcon)
1042+
if(isLView)
1043+
{
1044+
if (currentGame == gameName)
1045+
pmFinal.load(isDarkBg ? ":/res/mamegui/deco-darkbg.png" : ":/res/mamegui/deco-brightbg.png");
1046+
else
1047+
pmFinal = pmIcon = pmIcon.scaled(QSize(32, 32), Qt::KeepAspectRatio, Qt::SmoothTransformation);
1048+
}
1049+
else if (isLargeIcon)
10411050
{
10421051
if (currentGame == gameName && isZooming)
10431052
pmFinal.load(isDarkBg ? ":/res/mamegui/deco-darkbg.png" : ":/res/mamegui/deco-brightbg.png");
@@ -1051,7 +1060,12 @@ void GameListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
10511060
QPainter p;
10521061
p.begin(&pmFinal);
10531062

1054-
if (currentGame == gameName && isLargeIcon && isZooming)
1063+
if(isLView)
1064+
{
1065+
if(currentGame == gameName)
1066+
p.drawPixmap(3, 3, 32, 32, pmIcon);
1067+
}
1068+
else if (currentGame == gameName && isLargeIcon && isZooming)
10551069
p.drawPixmap(3, 3, 32, 32, pmIcon);
10561070

10571071
// paint the unavailable icon on top of original icon
@@ -1066,31 +1080,54 @@ void GameListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
10661080

10671081
p.end();
10681082

1069-
//save it for zooming
1070-
int icoSize, decoSize;
10711083

1072-
if (pmFinal.width() > 16)
1084+
if(isLView)
10731085
{
1074-
icoSize = 32;
1075-
decoSize = 38;
1076-
10771086
gameList->pmDeco = pmFinal;
1087+
1088+
rectDeco.setTop(rectDeco.top() + 16);
1089+
rectText.setTop(rectDeco.top() + 20);
1090+
rectText.setLeft(rectDeco.left() - 32);
1091+
rectText.setWidth(72);
1092+
rectText.setHeight(32);
1093+
drawDisplay(painter, option, rectText, gameList->getViewString(index, COL_DESC));
1094+
drawDecoration(painter, option, rectDeco, pmFinal);
10781095
}
10791096
else
10801097
{
1081-
icoSize = decoSize = 16;
1098+
//save it for zooming
1099+
int icoSize, decoSize;
10821100

1083-
if (currentGame == gameName)
1084-
gameList->pmDeco = QPixmap();
1085-
}
1101+
if (pmFinal.width() > 16)
1102+
{
1103+
icoSize = 32;
1104+
decoSize = 38;
10861105

1087-
rectDeco.setLeft(rectDeco.left() + cloneOffset);
1088-
rectDeco.setWidth(icoSize + 6);
1106+
gameList->pmDeco = pmFinal;
1107+
}
1108+
else
1109+
{
1110+
icoSize = decoSize = 16;
1111+
1112+
if (currentGame == gameName)
1113+
gameList->pmDeco = QPixmap();
1114+
}
1115+
1116+
rectDeco.setLeft(rectDeco.left() + cloneOffset);
1117+
rectDeco.setWidth(icoSize + 6);
1118+
1119+
if (currentGame == gameName && isLargeIcon && isZooming)
1120+
rectText.setLeft(rectText.left() + decoSize);
1121+
else
1122+
rectText.setLeft(rectText.left() + decoSize + cloneOffset + 6);
1123+
drawDisplay(painter, option, rectText, gameList->getViewString(index, COL_DESC));
1124+
1125+
//paint item icon
1126+
if (currentGame != gameName || !isZooming ||
1127+
(currentGame == gameName && !isLargeIcon))
1128+
drawDecoration(painter, option, rectDeco, pmFinal);
1129+
}
10891130

1090-
if (currentGame == gameName && isLargeIcon && isZooming)
1091-
rectText.setLeft(rectText.left() + decoSize);
1092-
else
1093-
rectText.setLeft(rectText.left() + decoSize + cloneOffset + 6);
10941131

10951132
//paint item text
10961133
/* QColor foreColor;
@@ -1100,12 +1137,6 @@ void GameListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
11001137
foreColor = QColor((isDarkBg) ? Qt::white : Qt::black);
11011138
painter->setPen(foreColor);
11021139
//*/
1103-
drawDisplay(painter, option, rectText, gameList->getViewString(index, COL_DESC));
1104-
1105-
//paint item icon
1106-
if (currentGame != gameName || !isZooming ||
1107-
(currentGame == gameName && !isLargeIcon))
1108-
drawDecoration(painter, option, rectDeco, pmFinal);
11091140

11101141
return;
11111142
}
@@ -1320,8 +1351,8 @@ void Gamelist::restoreGameSelection()
13201351
void Gamelist::centerGameSelection(QModelIndex index)
13211352
{
13221353
bool isLView = false;
1323-
// if (win->actionLargeIcons->isChecked())
1324-
// isLView = true;
1354+
if (win->actionLargeIcons->isChecked())
1355+
isLView = true;
13251356

13261357
//fixme: time consuming?
13271358
if (isLView)
@@ -1470,11 +1501,11 @@ void Gamelist::init(bool toggleState, int initMethod)
14701501
{
14711502
listMode = "Details";
14721503
}
1473-
// else if (win->actionLargeIcons->isChecked())
1474-
// {
1475-
// listMode = "LargeIcons";
1476-
// isLView = true;
1477-
// }
1504+
else if (win->actionLargeIcons->isChecked())
1505+
{
1506+
listMode = "LargeIcons";
1507+
isLView = true;
1508+
}
14781509
else
14791510
listMode = "Grouped";
14801511

@@ -1496,6 +1527,11 @@ void Gamelist::init(bool toggleState, int initMethod)
14961527
win->layMainView->addWidget(win->lvGameList);
14971528
win->lvGameList->show();
14981529
win->lvGameList->setModel(gameListPModel);
1530+
1531+
if (defaultGameListDelegate == NULL)
1532+
defaultGameListDelegate = win->lvGameList->itemDelegate();
1533+
1534+
win->lvGameList->setItemDelegate(&gamelistDelegate);
14991535
}
15001536
else
15011537
{
@@ -1813,8 +1849,8 @@ void Gamelist::loadMMO(int msgCat)
18131849
void Gamelist::initMenus()
18141850
{
18151851
bool isLView = false;
1816-
// if (win->actionLargeIcons->isChecked())
1817-
// isLView = true;
1852+
if (win->actionLargeIcons->isChecked())
1853+
isLView = true;
18181854

18191855
colSortActionGroup = new QActionGroup(win->menuArrangeIcons);
18201856

Diff for: lang/mamepgui_zh_CN.ts

+10
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,16 @@ p, li { white-space: pre-wrap; }
698698
<source>Export All Set Issues...</source>
699699
<translation>导出全部有问题的ROM档...</translation>
700700
</message>
701+
<message>
702+
<location filename="../mainwindow.ui" line="354"/>
703+
<source>Export &amp;Have List...</source>
704+
<translation>导出拥有游戏列表(&amp;H)...</translation>
705+
</message>
706+
<message>
707+
<location filename="../mainwindow.ui" line="359"/>
708+
<source>Export &amp;Miss List...</source>
709+
<translation>导出缺失游戏列表(&amp;M)...</translation>
710+
</message>
701711
<message>
702712
<location filename="../mainwindow.ui" line="712"/>
703713
<source>Hide &amp;Mechanical</source>

Diff for: mainwindow.cpp

+48-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ bool isUME = false;
4848

4949
QStringList validGuiSettings;
5050

51-
#define MPGUI_VER "1.6.0b1"
51+
#define MPGUI_VER "1.6.0b2"
5252

5353
void MainWindow::log(QString message)
5454
{
@@ -214,9 +214,10 @@ MainWindow::MainWindow(QWidget *parent) :
214214

215215
lvGameList = new QListView(centralwidget);
216216
lvGameList->setMovement(QListView::Static);
217-
lvGameList->setResizeMode(QListView::Adjust);
217+
//lvGameList->setResizeMode(QListView::Adjust);
218218
lvGameList->setViewMode(QListView::IconMode);
219-
// lvGameList->setGridSize(QSize(96, 64));
219+
lvGameList->setIconSize(QSize(48, 48));
220+
lvGameList->setGridSize(QSize(72, 80));
220221
lvGameList->setUniformItemSizes(true);
221222
lvGameList->setWordWrap(true);
222223
// lvGameList->setTextElideMode(Qt::TextDontClip | Qt::TextWordWrap);
@@ -559,7 +560,7 @@ void MainWindow::init()
559560

560561
// Actions
561562
connect(actionVerticalTabs, SIGNAL(toggled(bool)), this, SLOT(setDockOptions()));
562-
// connect(actionLargeIcons, SIGNAL(toggled(bool)), gameList, SLOT(init(bool)));
563+
connect(actionLargeIcons, SIGNAL(toggled(bool)), gameList, SLOT(init(bool)));
563564
connect(actionDetails, SIGNAL(toggled(bool)), gameList, SLOT(init(bool)));
564565
connect(actionGrouped, SIGNAL(toggled(bool)), gameList, SLOT(init(bool)));
565566

@@ -905,6 +906,49 @@ void MainWindow::on_actionAbout_triggered()
905906
aboutUI->exec();
906907
}
907908

909+
void MainWindow::on_actionHaveList_triggered()
910+
{
911+
exportGameList(true);
912+
}
913+
914+
void MainWindow::on_actionMissList_triggered()
915+
{
916+
exportGameList(false);
917+
}
918+
919+
void MainWindow::exportGameList(bool have)
920+
{
921+
QString filter = "";
922+
filter.append(tr("Txt files") + " (*.txt)");
923+
filter.append(";;");
924+
filter.append(tr("All Files (*)"));
925+
926+
QFileInfo mamebin(mame_binary);
927+
928+
QString fileName = QFileDialog::getSaveFileName
929+
(0, tr("File name:"), mamebin.absolutePath(), filter);
930+
931+
if (fileName.isEmpty())
932+
return;
933+
934+
QFile fileinfo(fileName);
935+
fileinfo.open(QIODevice::WriteOnly | QFile::Text);
936+
QTextStream outinfo(&fileinfo);
937+
outinfo.setCodec("UTF-8");
938+
939+
QStringList Available;
940+
foreach (QString gameName, pMameDat->games.keys())
941+
{
942+
GameInfo *gameInfo = pMameDat->games[gameName];
943+
if (!gameInfo->isDevice && gameInfo->devices.isEmpty() && (have ? gameInfo->available : !gameInfo->available))
944+
Available.append(gameName);
945+
}
946+
Available.sort();
947+
outinfo << Available.join("\n");
948+
fileinfo.close();
949+
win->poplog("Finished.");
950+
}
951+
908952
void MainWindow::toggleGameListColumn()
909953
{
910954
int col = colToggleActions.indexOf((QAction *)sender());

Diff for: mainwindow.h

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public slots:
8888
void on_actionFAQ_triggered();
8989
void on_actionBoard_triggered();
9090
void on_actionAbout_triggered();
91+
void on_actionHaveList_triggered();
92+
void on_actionMissList_triggered();
9193

9294
void on_actionPlay_triggered();
9395
void on_actionCommandLine_triggered();
@@ -142,6 +144,7 @@ public slots:
142144
void setTransparentStyle(QWidget * w);
143145
QList<QTabBar *> getSSTabBars();
144146
void exportFixDat(int);
147+
void exportGameList(bool);
145148
};
146149

147150
#define MAMEPLUS_SIG 0x52111314

Diff for: mainwindow.ui

+13
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
<addaction name="actionFixDatIncomplete"/>
7878
<addaction name="actionFixDatMissing"/>
7979
<addaction name="actionFixDatComplete"/>
80+
<addaction name="separator"/>
81+
<addaction name="actionHaveList"/>
82+
<addaction name="actionMissList"/>
8083
</widget>
8184
<addaction name="actionPlay"/>
8285
<addaction name="menuPlayWith"/>
@@ -346,6 +349,16 @@
346349
<string>&amp;About</string>
347350
</property>
348351
</action>
352+
<action name="actionHaveList">
353+
<property name="text">
354+
<string>Export &amp;Have List...</string>
355+
</property>
356+
</action>
357+
<action name="actionMissList">
358+
<property name="text">
359+
<string>Export &amp;Miss List...</string>
360+
</property>
361+
</action>
349362
<action name="actionDetails">
350363
<property name="checkable">
351364
<bool>true</bool>

0 commit comments

Comments
 (0)