mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
port DateTime
This commit is contained in:
parent
038f7a9171
commit
b5996f5ab6
@ -78,8 +78,6 @@ int MPRecvTimeout;
|
||||
std::string LANDevice;
|
||||
bool DirectLAN;
|
||||
|
||||
int64_t RTCOffset;
|
||||
|
||||
bool DSBatteryLevelOkay;
|
||||
int DSiBatteryLevel;
|
||||
bool DSiBatteryCharging;
|
||||
|
@ -192,8 +192,6 @@ extern int MPRecvTimeout;
|
||||
extern std::string LANDevice;
|
||||
extern bool DirectLAN;
|
||||
|
||||
extern int64_t RTCOffset;
|
||||
|
||||
extern bool DSBatteryLevelOkay;
|
||||
extern int DSiBatteryLevel;
|
||||
extern bool DSiBatteryCharging;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "types.h"
|
||||
#include "Config.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "DateTimeDialog.h"
|
||||
#include "ui_DateTimeDialog.h"
|
||||
@ -32,8 +33,11 @@ DateTimeDialog::DateTimeDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Da
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
emuInstance = ((MainWindow*)parent)->getEmuInstance();
|
||||
|
||||
auto& cfg = emuInstance->getLocalConfig();
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
customTime = now.addSecs(Config::RTCOffset);
|
||||
customTime = now.addSecs(cfg.GetInt64("RTC.Offset"));
|
||||
|
||||
ui->chkChangeTime->setChecked(false);
|
||||
ui->chkResetTime->setChecked(false);
|
||||
@ -59,13 +63,15 @@ void DateTimeDialog::done(int r)
|
||||
{
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
auto& cfg = emuInstance->getLocalConfig();
|
||||
|
||||
if (ui->chkChangeTime->isChecked())
|
||||
{
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
Config::RTCOffset = now.secsTo(ui->txtNewCustomTime->dateTime());
|
||||
cfg.SetInt64("RTC.Offset", now.secsTo(ui->txtNewCustomTime->dateTime()));
|
||||
}
|
||||
else if (ui->chkResetTime->isChecked())
|
||||
Config::RTCOffset = 0;
|
||||
cfg.SetInt64("RTC.Offset", 0);
|
||||
|
||||
Config::Save();
|
||||
}
|
||||
|
@ -26,6 +26,8 @@
|
||||
namespace Ui {class DateTimeDialog; }
|
||||
class DateTimeDialog;
|
||||
|
||||
class EmuInstance;
|
||||
|
||||
class DateTimeDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -63,6 +65,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::DateTimeDialog* ui;
|
||||
EmuInstance* emuInstance;
|
||||
|
||||
QDateTime customTime;
|
||||
};
|
||||
|
@ -925,7 +925,7 @@ void EmuInstance::setBatteryLevels()
|
||||
void EmuInstance::setDateTime()
|
||||
{
|
||||
QDateTime hosttime = QDateTime::currentDateTime();
|
||||
QDateTime time = hosttime.addSecs(Config::RTCOffset);
|
||||
QDateTime time = hosttime.addSecs(localCfg.GetInt64("RTC.Offset"));
|
||||
|
||||
nds->RTC.SetDateTime(time.date().year(), time.date().month(), time.date().day(),
|
||||
time.time().hour(), time.time().minute(), time.time().second());
|
||||
|
@ -597,8 +597,9 @@ void WriteDateTime(int year, int month, int day, int hour, int minute, int secon
|
||||
{
|
||||
QDateTime hosttime = QDateTime::currentDateTime();
|
||||
QDateTime time = QDateTime(QDate(year, month, day), QTime(hour, minute, second));
|
||||
auto& cfg = testinst->getLocalConfig();
|
||||
|
||||
Config::RTCOffset = hosttime.secsTo(time);
|
||||
cfg.SetInt64("RTC.Offset", hosttime.secsTo(time));
|
||||
Config::Save();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user