Skip to content

Commit 9ab4cd4

Browse files
committed
show just the cards of original games
1 parent c0e1f87 commit 9ab4cd4

13 files changed

+364
-98
lines changed

src/Data.hpp

Lines changed: 124 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,56 @@ struct ZipData {
8888
* Initializes an empty instance of `ZipData`.
8989
*/
9090
ZipData() {}
91+
92+
/**
93+
* @brief This sets the file name metadata.
94+
* @param fileName TRLE level zip file name.
95+
*/
96+
inline void setFileName(const QString& fileName) {
97+
}
98+
99+
/**
100+
* @brief This sets the file size metadata.
101+
* @param size Size in MiB.
102+
*/
103+
inline void setZise(const float size) {
104+
}
105+
106+
/**
107+
* @brief This sets the file md5sum metadata.
108+
* @param md5sum Checksum of the archive.
109+
*/
110+
inline void setMd5sum(const QString& md5sum) {
111+
}
112+
113+
/**
114+
* @brief This sets the URL for the file.
115+
* @param url String of download address.
116+
*/
117+
inline void setURL(const QString& url) {
118+
}
119+
120+
/**
121+
* @brief This sets the zip file name metadata.
122+
* @param version File version from trcustoms.org
123+
*/
124+
inline void setVersion(const qint64 version) {
125+
}
126+
127+
/**
128+
* @brief This sets the zip file name metadata.
129+
* @param type Level type.
130+
*/
131+
inline void setType(const qint64 type) {
132+
}
133+
134+
/**
135+
* @brief This sets the zip file name metadata.
136+
* @param release date of file release.
137+
*/
138+
inline void setRelease(const QString& release) {
139+
}
140+
91141
/**
92142
* @brief Parameterized constructor for `ZipData`.
93143
*
@@ -126,6 +176,77 @@ struct ZipData {
126176
QString release; ///< The The date of file release from trcustoms.
127177
};
128178

179+
/**
180+
* @struct OriginalGameData
181+
* @brief Represents a Tomb Raider Game Entry Card Info.
182+
*
183+
* This struct is designed to store a Game data record.
184+
* Each record contains basic game data and a cover image displayed as a card in the application.
185+
*/
186+
struct OriginalGameData {
187+
/**
188+
* @brief Default constructor for `OriginalGameData`.
189+
*
190+
* Initializes an empty instance of `OriginalGameData`.
191+
*/
192+
OriginalGameData() {}
193+
194+
/**
195+
* @brief Parameterized constructor for `OriginalGameData`.
196+
*
197+
* This constructor initializes a `OriginalGameData` object with game metadata.
198+
*
199+
* @param id The numeric game datbase ID.
200+
* @param title The TRLE title. Expected to contain a single name.
201+
* @param shortBody some short game info text.
202+
* @param type The TRLE type, represented by a numeric ID.
203+
* @param releaseDate The release date in the format "YYYY-MM-DD" (e.g., "2000-01-01").
204+
* @param m_cover The cover image as a `m_cover`.
205+
*/
206+
OriginalGameData(
207+
qint64 id, const QString& title, const QString& shortBody,
208+
qint64 type, const QString& releaseDate, const QPixmap& cover) :
209+
m_game_id(id), m_title(title), m_shortBody(shortBody), m_type(type),
210+
m_releaseDate(releaseDate) {
211+
// Define target dimensions and maintain aspect ratio
212+
QSize targetSize(640, 480);
213+
QSize newSize = cover.size().scaled(targetSize, Qt::KeepAspectRatio);
214+
215+
// Scale the pixmap
216+
QPixmap scaledPixmap = cover.scaled(
217+
newSize,
218+
Qt::KeepAspectRatio,
219+
Qt::SmoothTransformation);
220+
221+
// Create a centered pixmap with a transparent background
222+
QPixmap centeredPixmap(targetSize);
223+
// Ensure a transparent background
224+
centeredPixmap.fill(Qt::transparent);
225+
226+
// Calculate offsets for centering the scaled image
227+
qint64 xOffset = (targetSize.width() - newSize.width()) / 2;
228+
qint64 yOffset = (targetSize.height() - newSize.height()) / 2;
229+
230+
// Draw the scaled image onto the centered pixmap
231+
QPainter painter(&centeredPixmap);
232+
painter.setRenderHint(QPainter::Antialiasing, true);
233+
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
234+
painter.drawPixmap(xOffset, yOffset, scaledPixmap);
235+
painter.end();
236+
237+
// Store the resulting pixmap in m_picture
238+
m_cover = centeredPixmap;
239+
}
240+
241+
// Data members
242+
qint64 m_game_id; ///< The Game id.
243+
QString m_title; ///< The Game title.
244+
QString m_shortBody; ///< The Game info text.
245+
qint64 m_type; ///< ID of the type of game.
246+
QString m_releaseDate; ///< The release date in "YYYY-MM-DD" format.
247+
QPixmap m_cover; ///< The Game cover image.
248+
};
249+
129250
/**
130251
* @struct ListItemData
131252
* @brief Represents a Tomb Raider Level Entry Card Info.
@@ -175,7 +296,7 @@ struct ListItemData {
175296
QSize newSize = pixmap.size().scaled(targetSize, Qt::KeepAspectRatio);
176297

177298
// Scale the pixmap
178-
QPixmap scaledPixmap = pixmap.scaled(
299+
QPixmap scaledCover = pixmap.scaled(
179300
newSize,
180301
Qt::KeepAspectRatio,
181302
Qt::SmoothTransformation);
@@ -193,7 +314,7 @@ struct ListItemData {
193314
QPainter painter(&centeredPixmap);
194315
painter.setRenderHint(QPainter::Antialiasing, true);
195316
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
196-
painter.drawPixmap(xOffset, yOffset, scaledPixmap);
317+
painter.drawPixmap(xOffset, yOffset, scaledCover);
197318
painter.end();
198319

199320
// Store the resulting pixmap in m_picture
@@ -208,7 +329,7 @@ struct ListItemData {
208329
QString m_releaseDate; ///< The release date in "YYYY-MM-DD" format.
209330
qint64 m_difficulty; ///< ID of the difficulty of the level.
210331
qint64 m_duration; ///< ID of the estimated duration of the level.
211-
QPixmap m_cover; ///< The TRLE cover image pointer.
332+
QPixmap m_cover; ///< The TRLE cover image.
212333
};
213334

214335
/**

src/Model.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Model::Model() {}
1717
Model::~Model() {}
1818

19-
bool Model::setDirectory(const QString& level, const QString& game) {
19+
bool Model::setupDirectories(const QString& level, const QString& game) {
2020
bool status = false;
2121
if (fileManager.setUpCamp(level, game) &&
2222
downloader.setUpCamp(level) &&
@@ -27,7 +27,7 @@ bool Model::setDirectory(const QString& level, const QString& game) {
2727
}
2828

2929
void Model::setup(const QString& level, const QString& game) {
30-
if (setDirectory(level, game) == true) {
30+
if (setupDirectories(level, game) == true) {
3131
QList<int> commonFiles;
3232
checkCommonFiles(&commonFiles);
3333
// Iterate backward to avoid index shifting
@@ -46,7 +46,7 @@ void Model::setup(const QString& level, const QString& game) {
4646
QCoreApplication::processEvents();
4747
} else {
4848
// send signal to gui with error about setup fail
49-
qDebug() << "setDirectory setup failed";
49+
qDebug() << "setupDirectories setup failed";
5050
}
5151
}
5252

src/Model.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Model : public QObject {
7474
void getLevel(int id);
7575
const InfoData getInfo(int id);
7676
const QString getWalkthrough(int id);
77-
bool setDirectory(const QString& level, const QString& game);
77+
bool setupDirectories(const QString& level, const QString& game);
7878
void setup(const QString& level, const QString& game);
7979

8080
signals:

src/TombRaiderLinuxLauncher.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
111111
this, &TombRaiderLinuxLauncher::sortByType);
112112
connect(ui->radioButtonReleaseDate, &QRadioButton::clicked,
113113
this, &TombRaiderLinuxLauncher::sortByReleaseDate);
114+
connect(ui->radioButtonOriginal, &QRadioButton::clicked,
115+
this, &TombRaiderLinuxLauncher::showtOriginal);
114116

115117
connect(ui->comboBoxClass, &QComboBox::currentTextChanged,
116118
this, &TombRaiderLinuxLauncher::filterByClass);
@@ -149,7 +151,7 @@ TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
149151
}
150152

151153
void TombRaiderLinuxLauncher::generateList(const QList<int>& availableGames) {
152-
levelListModel->setLevels();
154+
levelListModel->setLevels(availableGames);
153155
}
154156

155157
void TombRaiderLinuxLauncher::sortByTitle() {
@@ -176,6 +178,10 @@ void TombRaiderLinuxLauncher::sortByReleaseDate() {
176178
levelListModel->sortItems(levelListModel->compareReleaseDates);
177179
}
178180

181+
void TombRaiderLinuxLauncher::showtOriginal() {
182+
levelListModel->showOriginal();
183+
}
184+
179185
void TombRaiderLinuxLauncher::filterByClass(const QString& class_) {
180186
levelListModel->filterClass(class_);
181187
}

src/TombRaiderLinuxLauncher.hpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class TombRaiderLinuxLauncher : public QMainWindow {
131131
void filterByType(const QString& type);
132132
void filterByDifficulty(const QString& difficulty);
133133
void filterByDuration(const QString& duration);
134+
void showtOriginal();
134135
void GlobalSaveClicked();
135136
void GlobalResetClicked();
136137
void LevelSaveClicked();
@@ -160,30 +161,10 @@ class TombRaiderLinuxLauncher : public QMainWindow {
160161
QListWidgetItem*,
161162
QListWidgetItem*)> compare);
162163

163-
QSet<QListWidgetItem*> originalGamesSet_m;
164-
QList<QListWidgetItem*> originalGamesList_m;
165164
LevelListModel *levelListModel;
166165
Controller& controller = Controller::getInstance();
167166
QSettings m_settings;
168167
Ui::TombRaiderLinuxLauncher *ui;
169168
};
170169

171-
struct OriginalGameData {
172-
QMap<int, QString> romanNumerals = {
173-
{0, "null"},
174-
{1, "I"},
175-
{2, "II"},
176-
{3, "III"},
177-
{4, "IV"},
178-
{5, "V"},
179-
{6, "VI"},
180-
{7, "IUB"},
181-
{8, "IIGM"},
182-
{9, "IIILM"},
183-
};
184-
const QString getPicture(int id) {
185-
return QString ("Tomb_Raider_%1.jpg").arg(romanNumerals[id]);
186-
}
187-
};
188-
189170
#endif // SRC_TOMBRAIDERLINUXLAUNCHER_HPP_

src/TombRaiderLinuxLauncher.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@
638638
</font>
639639
</property>
640640
<property name="text">
641-
<string>Origina Games</string>
641+
<string>Core Design Games</string>
642642
</property>
643643
</widget>
644644
</item>

0 commit comments

Comments
 (0)