From 90c7bc237c9cf964c16f0cb48c308a92a8193a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 2 Sep 2022 02:11:49 +0200 Subject: Use global Window object. This makes it easier to control initialization and maintain RAII. --- c/ext.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'c/ext.cpp') diff --git a/c/ext.cpp b/c/ext.cpp index 694581d..77028d1 100644 --- a/c/ext.cpp +++ b/c/ext.cpp @@ -3,15 +3,14 @@ #include #include "data.h" +#include "main.h" -extern CfgA& g_cfg; -extern FileView g_fvElv; -extern FileView g_fvDlv; +extern Window* g_window; bool OpenOnline(int iEp) { - wchar_t url[sizeof(g_cfg.url)+4]; - Swprintf(url, L"%s%d", g_cfg.url, iEp); + wchar_t url[sizeof(g_window->cfg.url)+4]; + Swprintf(url, L"%s%d", g_window->cfg.url, iEp); INT_PTR r = reinterpret_cast( ShellExecuteW(nullptr, L"open", url, nullptr, nullptr, SW_SHOWNORMAL)); if (r <= 32) @@ -21,7 +20,7 @@ bool OpenOnline(int iEp) bool OpenWiki(int iEp) { - const DlvDataA& d = g_fvDlv.At(iEp-1); + const DlvDataA& d = g_window->fvDlv.At(iEp-1); wchar_t url[sizeof(d.wiki)+35]; Swprintf(url, L"https://www.detectiveconanworld.com%s", d.wiki); INT_PTR r = reinterpret_cast( @@ -114,7 +113,7 @@ static bool FindMatchingFile(wchar_t (&file)[MAX_PATH], const wchar_t* const roo bool OpenLocally(int iEp) { wchar_t file[MAX_PATH]; - if (FindMatchingFile(file, g_cfg.root, g_fvElv.At(iEp-1).siEp)) { + if (FindMatchingFile(file, g_window->cfg.root, g_window->fvElv.At(iEp-1).siEp)) { INT_PTR r = reinterpret_cast( ShellExecuteW(nullptr, L"open", file, nullptr, nullptr, SW_SHOWNORMAL)); if (r <= 32) -- cgit v1.2.3