Skip to content

Commit 86a2ecd

Browse files
committed
Add dialog indication for failed version check
- Resolves #371.
1 parent 8be192f commit 86a2ecd

File tree

6 files changed

+38
-13
lines changed

6 files changed

+38
-13
lines changed

Dn-FamiTracker.rc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,11 +2127,11 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
21272127
BEGIN
21282128
DEFPUSHBUTTON "Update",IDOK,115,175,50,14
21292129
PUSHBUTTON "Cancel",IDCANCEL,170,175,50,14
2130-
LTEXT "A new version of Dn-FamiTracker is now available.",IDC_STATIC,7,7,162,8
2130+
LTEXT "A new version of Dn-FamiTracker has not been found.",IDC_VERSION_STATIC,7,7,174,8
21312131
LTEXT "Version (released on )",IDC_VERSIONDATE_MSG,7,21,213,8
2132-
LTEXT "Release notes:",IDC_STATIC,7,36,49,8
2132+
LTEXT "Release notes:",IDC_VERSION_STATIC2,7,36,213,8
21332133
EDITTEXT IDC_RELEASE_MSG,7,52,213,80,ES_MULTILINE | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP,WS_EX_TRANSPARENT
2134-
LTEXT "Pressing ""Update"" will launch the Github web page for this release.",IDC_STATIC,7,140,213,8
2134+
LTEXT "Pressing ""Update"" will open the GitHub page for the latest release.",IDC_VERSION_STATIC3,7,140,213,8
21352135
CONTROL "Do not remind me again.",IDC_UPDATE_REMIND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,156,213,10
21362136
END
21372137

Source/FamiTracker.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,10 @@ void CFamiTrackerApp::UnregisterSingleInstance()
569569

570570
void CFamiTrackerApp::CheckNewVersion(bool StartUp) // // //
571571
{
572-
//return;
572+
// !! !! This member will be overwritten.
573+
// we do this so the "no new updates" pop-up will only show if the user checks
574+
// also, why do we need to pass this to the version checker thread if we're gonna return it again?
575+
m_bStartUp = StartUp;
573576
m_pVersionChecker = std::make_unique<CVersionChecker>(StartUp); // // //
574577
}
575578

@@ -746,15 +749,21 @@ BOOL CFamiTrackerApp::OnIdle(LONG lCount) // // //
746749
if (CWinApp::OnIdle(lCount))
747750
return TRUE;
748751

749-
if (m_pVersionChecker && m_pVersionChecker->IsReady())
750-
if (auto pChecker = std::move(m_pVersionChecker); auto result = pChecker->GetVersionCheckResult())
751-
{
752+
if (m_pVersionChecker && m_pVersionChecker->IsReady()) {
753+
if (auto pChecker = std::move(m_pVersionChecker); auto result = pChecker->GetVersionCheckResult()) {
752754
m_pVersionURL = result->URL;
753755
m_pVerInfo = result->VerInfo;
754756
m_pVerDesc = result->VerDesc;
755757
m_bStartUp = result->StartUp;
758+
m_bNewVersion = true;
756759
OnVersionCheck();
757760
}
761+
else {
762+
m_bNewVersion = false;
763+
m_pVersionURL = "https://github.com/Dn-Programming-Core-Management/Dn-FamiTracker/releases/latest";
764+
if (!m_bStartUp) OnVersionCheck();
765+
}
766+
}
758767
return FALSE;
759768
}
760769

Source/FamiTracker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class CFamiTrackerApp : public CWinApp
178178
public:
179179
std::unique_ptr<CVersionChecker> m_pVersionChecker; // // //
180180
std::string m_pVersionURL, m_pVerInfo, m_pVerDesc;
181+
bool m_bNewVersion;
181182
bool m_bStartUp;
182183

183184
#ifdef SUPPORT_TRANSLATIONS

Source/VersionChecker.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,8 @@ void CVersionChecker::ThreadFn(bool startup, std::promise<std::optional<stVersio
162162
desc.insert(pos + 1, "\r\n - ");
163163
pos += t.size();
164164
}
165-
int StartUp = 0;
165+
int StartUp = int(startup);
166166
std::string VerInfo = "Version " + verStr + " (released on " + s + ")\n\n";
167-
if (startup)
168-
StartUp = 1;
169167
std::string url = json["html_url"];
170168

171169
p.set_value(stVersionCheckResult{ std::move(StartUp), std::move(VerInfo), std::move(desc), std::move(url) });

Source/VersionCheckerDlg.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,21 @@ END_MESSAGE_MAP()
5858

5959
BOOL CVersionCheckerDlg::OnInitDialog()
6060
{
61-
SetDlgItemText(IDC_VERSIONDATE_MSG, conv::to_t(theApp.m_pVerInfo).data());
62-
SetDlgItemText(IDC_RELEASE_MSG, conv::to_t(theApp.m_pVerDesc).data());
61+
if (theApp.m_bNewVersion) {
62+
SetDlgItemText(IDC_VERSION_STATIC, "A new version of Dn-FamiTracker is now available.");
63+
SetDlgItemText(IDC_VERSIONDATE_MSG, conv::to_t(theApp.m_pVerInfo).data());
64+
SetDlgItemText(IDC_RELEASE_MSG, conv::to_t(theApp.m_pVerDesc).data());
65+
SetDlgItemText(IDC_VERSION_STATIC2, "Release notes:");
66+
SetDlgItemText(IDC_VERSION_STATIC3, "Pressing \"Update\" will open the GitHub page for this release.");
67+
}
68+
else {
69+
SetDlgItemText(IDC_VERSION_STATIC, "A new version of Dn-FamiTracker has not been found.");
70+
SetDlgItemText(IDC_VERSIONDATE_MSG, "You might be on the latest version.");
71+
SetDlgItemText(IDC_VERSION_STATIC2, "If not, go to the latest release to download the latest version.");
72+
SetDlgItemText(IDC_VERSION_STATIC3, "Pressing \"Update\" will open the GitHub page for the latest release.");
73+
SetDlgItemText(IDC_RELEASE_MSG, "");
74+
GetDlgItem(IDC_RELEASE_MSG)->EnableWindow(false);
75+
}
6376
if (theApp.m_bStartUp)
6477
SetDlgItemText(IDC_UPDATE_REMIND, _T("Do not remind me again. (may be re-enabled in config menu)"));
6578
//set visible the message

resource.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,12 @@
678678
#define IDC_OPLL_PATCHBYTE2 1538
679679
#define IDC_OPLL_PATCHNAME2 1539
680680
#define IDC_STATIC_PATCH3 1540
681+
#define IDC_VERSION_STATIC 1540
681682
#define IDC_STATIC_PATCH4 1541
683+
#define IDC_VERSION_STATIC4 1541
684+
#define IDC_VERSION_STATIC3 1541
682685
#define IDC_STATIC_PATCH5 1542
686+
#define IDC_VERSION_STATIC2 1542
683687
#define IDC_STATIC_PATCH6 1543
684688
#define IDC_STATIC_PATCH7 1544
685689
#define IDC_STATIC_PATCH8 1545
@@ -905,7 +909,7 @@
905909
#ifndef APSTUDIO_READONLY_SYMBOLS
906910
#define _APS_NEXT_RESOURCE_VALUE 380
907911
#define _APS_NEXT_COMMAND_VALUE 33215
908-
#define _APS_NEXT_CONTROL_VALUE 1537
912+
#define _APS_NEXT_CONTROL_VALUE 1543
909913
#define _APS_NEXT_SYMED_VALUE 179
910914
#endif
911915
#endif

0 commit comments

Comments
 (0)