Skip to content

Commit

Permalink
13.3.4 download metainfo before using, update metainfo independently
Browse files Browse the repository at this point in the history
  • Loading branch information
Fsu0413 committed Mar 4, 2023
1 parent 0358944 commit 7022b88
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 73 deletions.
4 changes: 2 additions & 2 deletions RMEssentials.pri
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
CONFIG += warn_on c++17
win32: CONFIG += skip_target_version_ext

VERSION = 13.1.21
RMEVERSION = 20230121
VERSION = 13.3.4
RMEVERSION = 20230304
DEFINES += "RMEVERSION=\\\"$$RMEVERSION\\\"" "RMEVERSIONNUMBER=\\\"$$VERSION\\\"" QT_DISABLE_DEPRECATED_BEFORE=0x70000

DEFINES += QT_NO_CAST_FROM_ASCII
Expand Down
28 changes: 18 additions & 10 deletions src/rmessentials/src/download.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "download.h"
#include "main.h"

#include <RMEss/RmeDownloader>
#include <RMEss/RmeUncompresser>
Expand All @@ -14,6 +15,7 @@
#include <QJsonObject>
#include <QJsonValue>
#include <QListWidget>
#include <QMessageBox>
#include <QProgressBar>
#include <QPushButton>
#include <QShowEvent>
Expand Down Expand Up @@ -212,17 +214,17 @@ void DownloadDialog::startDownloadSong(DownloadMode mode)
= { QStringLiteral(".mp3"),
QStringLiteral("_ipad.jpg"),
QStringLiteral("_thumb.jpg"), // do not use .png here
QStringLiteral("_4k_ez.imd.json"),
QStringLiteral("_4k_nm.imd.json"),
QStringLiteral("_4k_hd.imd.json"),
QStringLiteral("_4k_ez.rmp"),
QStringLiteral("_4k_nm.rmp"),
QStringLiteral("_4k_hd.rmp"),

QStringLiteral("_5k_ez.imd.json"),
QStringLiteral("_5k_nm.imd.json"),
QStringLiteral("_5k_hd.imd.json"),
QStringLiteral("_5k_ez.rmp"),
QStringLiteral("_5k_nm.rmp"),
QStringLiteral("_5k_hd.rmp"),

QStringLiteral("_6k_ez.imd.json"),
QStringLiteral("_6k_nm.imd.json"),
QStringLiteral("_6k_hd.imd.json"),
QStringLiteral("_6k_ez.rmp"),
QStringLiteral("_6k_nm.rmp"),
QStringLiteral("_6k_hd.rmp"),
#if 0
QStringLiteral("_Papa_Easy.mde"),
QStringLiteral("_Papa_Normal.mde"),
Expand Down Expand Up @@ -395,7 +397,7 @@ void DownloadDialog::downloadList()
RmeDownloader *downloader = new RmeDownloader;
downloader->setDownloadPath(RmeDownloader::binDownloadPath());
#ifdef RME_USE_QUAZIP
static const QString TableCom = QStringLiteral("http://res.ds.qq.com/Table/AlphaTest/17/TableCom.zip");
QString TableCom = QString(QStringLiteral("http://res.ds.qq.com/Table/BetaTest/%1/TableCom.zip")).arg(currentNum());
downloader << TableCom;
#endif

Expand Down Expand Up @@ -624,6 +626,12 @@ void DownloadDialog::loadPaths()

appendLog(tr("All files loaded"));

// 2023.3.4 add message box for warning:
// currently we are downloading encrypted chart.
QMessageBox::information(this, tr("RMEssentials"),
tr("Currently RM official provides only encrypted chart on file server.<br />"
"This program currently does not support decryption currently."));

emit busy(false);
}

Expand Down
48 changes: 43 additions & 5 deletions src/rmessentials/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
#endif
#endif

Q_GLOBAL_STATIC(QString, num)

MainDialog::MainDialog(QWidget *parent)
: QDialog(parent)
#ifdef Q_OS_ANDROID
, m_receiver(nullptr)
#endif
, m_isPermissionOk(false)
, m_isNumOk(false)
{
setWindowTitle(tr("Rhythm Master Essensials ") + QStringLiteral(RMEVERSION));

Expand Down Expand Up @@ -78,13 +82,16 @@ MainDialog::MainDialog(QWidget *parent)
static const QString whatsnew = QStringLiteral("https://rmessentials.fsu0413.me/whatsnew");
static const QString dlurl = QStringLiteral("https://rmessentials.fsu0413.me/dlurl");
static const QString dlpasswd = QStringLiteral("https://rmessentials.fsu0413.me/dlpasswd");
static const QString num = QStringLiteral("https://rmessentials.fsu0413.me/num");

RmeDownloader *downloader = new RmeDownloader;
downloader << versioninfo << whatsnew << dlurl << dlpasswd;
downloader << num << versioninfo << whatsnew << dlurl << dlpasswd;

downloader->setDownloadPath(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + QStringLiteral("/RMESSENTIALS"));

connect(downloader, &RmeDownloader::allCompleted, this, &MainDialog::checkForUpdate);
connect(downloader, &RmeDownloader::allCompleted, this, &MainDialog::metainfoDownloaded);
connect(downloader, &RmeDownloader::singleFileCompleted, this, &MainDialog::oneMetainfoFileDownloaded);
connect(downloader, &RmeDownloader::singleFileFailed, this, &MainDialog::oneMetainfoFileDownloaded);
connect(downloader, &RmeDownloader::allCompleted, downloader, &RmeDownloader::deleteLater);
connect(downloader, &RmeDownloader::canceled, downloader, &RmeDownloader::deleteLater);
connect(this, &MainDialog::finished, downloader, &RmeDownloader::cancel);
Expand Down Expand Up @@ -155,8 +162,9 @@ void MainDialog::about()
QMessageBox::about(this, tr("About RMEssentials"), aboutContent);
}

void MainDialog::checkForUpdate()
void MainDialog::metainfoDownloaded()
{
// checkForUpdate
#if 1
QFile v(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + QStringLiteral("/RMESSENTIALS/versioninfo"));
#else
Expand Down Expand Up @@ -202,15 +210,40 @@ void MainDialog::checkForUpdate()
}

void MainDialog::permissionCheckOk()
{
m_isPermissionOk = true;
enableButtons();
}

void MainDialog::enableButtons()
{
// ChangeName Dialog and Papa song editor Dialog are currently temporarily disabled due to technical restriction of Rhythm Master Remastered

m_changeNameBtn->setEnabled(false);
m_downloadBtn->setEnabled(true);
m_songEditorBtn->setEnabled(true);
m_downloadBtn->setEnabled(m_isPermissionOk && m_isNumOk);
m_songEditorBtn->setEnabled(m_isPermissionOk);
m_papaSongEditorBtn->setEnabled(false);
}

void MainDialog::oneMetainfoFileDownloaded(const QString &url)
{
if (url.endsWith(QStringLiteral("/num"))) {
QFile vNum(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + QStringLiteral("/RMESSENTIALS/num"));
if (vNum.open(QIODevice::ReadOnly)) {
*num = QString::fromUtf8(vNum.readAll());
} else {
QMessageBox::warning(this, tr("RMEssentials"),
tr("Meta data file download failed and temporary values are used instead.<br / >"
"Restart this program if you'd like to retry."));
*num = QStringLiteral("459");
}

(*num) = (*num).trimmed();
m_isNumOk = true;
enableButtons();
}
}

#ifdef Q_OS_ANDROID

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Expand Down Expand Up @@ -392,3 +425,8 @@ int main(int argc, char *argv[])

return a.exec();
}

QString currentNum()
{
return *num;
}
12 changes: 11 additions & 1 deletion src/rmessentials/src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ private slots:
void showPapaSongClientEditDialog();
void about();

void checkForUpdate();
void metainfoDownloaded();

public slots:
void permissionCheckOk();
void enableButtons();

private slots:
void oneMetainfoFileDownloaded(const QString &url);

#ifdef Q_OS_ANDROID

Expand All @@ -41,6 +46,9 @@ private slots:
void requestForPermission();
void permissionRequestCallback();
#endif
private:
bool m_isPermissionOk;
bool m_isNumOk;

private:
QPushButton *m_changeNameBtn;
Expand All @@ -53,4 +61,6 @@ private slots:
void showEvent(QShowEvent *event) override;
};

extern QString currentNum();

#endif
Loading

0 comments on commit 7022b88

Please sign in to comment.