From c60fdf109150312c1ba5e749aff6196f098b2752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 17 Aug 2022 14:43:52 +0200 Subject: Add FileView::Initialized constructor. --- c/main.cpp | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'c/main.cpp') diff --git a/c/main.cpp b/c/main.cpp index 1b818c0..7f7ea9b 100644 --- a/c/main.cpp +++ b/c/main.cpp @@ -52,7 +52,8 @@ EpisodeListView* g_elv; DlvDragger g_dragDlv; /* File views. */ -FileView g_fvCfg{L"cfg.dat", 1}; +FileView g_fvCfg = FileView::Initialized(L"cfg.dat", 1); +CfgA& g_cfg = g_fvCfg.At(0); /* Optional Windows functions. */ BOOL (*IsThemeActive)(); @@ -229,12 +230,9 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, SetFocus(g_elv->hWnd); /* Set menu item checkmarks according to saved settings. */ - CheckMenuItem(GetMenu(hWnd), IDM_VIEW_WATCHED, - g_fvCfg->bViewWatched? MF_CHECKED: MF_UNCHECKED); - CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, - g_fvCfg->bViewTVOriginal? MF_CHECKED: MF_UNCHECKED); - CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, - g_fvCfg->limitScreenwriter[0]? MF_UNCHECKED: MF_CHECKED); + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_WATCHED, g_cfg.bViewWatched? MF_CHECKED: MF_UNCHECKED); + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, g_cfg.bViewTVOriginal? MF_CHECKED: MF_UNCHECKED); + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, g_cfg.limitScreenwriter[0]? MF_UNCHECKED: MF_CHECKED); return 0; case WM_CLOSE: @@ -326,13 +324,13 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, /*IDM_FILE_FETCH_DATA*/L"Fetch episode data from the web (may take a few seconds).", /*IDM_FILE_FETCH_SCREENWRITERS*/L"Fetch screenwriters from the web (may take a minute).", /*IDM_FILE_ABOUT*/L"Show information about Episode Browser.", - /*IDM_VIEW_WATCHED*/(g_fvCfg->bViewWatched? + /*IDM_VIEW_WATCHED*/(g_cfg.bViewWatched? L"Click to hide watched episodes.": L"Click to show watched episodes."), - /*IDM_VIEW_TV_ORIGINAL*/(g_fvCfg->bViewTVOriginal? + /*IDM_VIEW_TV_ORIGINAL*/(g_cfg.bViewTVOriginal? L"Click to hide TV original episodes.": L"Click to show TV original episodes."), - /*IDM_VIEW_OTHERS*/(g_fvCfg->limitScreenwriter? + /*IDM_VIEW_OTHERS*/(g_cfg.limitScreenwriter? L"Click to hide episodes by other screenwriters.": L"Click to show episodes by other screenwriters.") }; @@ -415,9 +413,8 @@ void HandleMainMenu(const HWND hWnd, const WORD command) break; case IDM_VIEW_WATCHED: - CheckMenuItem(GetMenu(hWnd), IDM_VIEW_WATCHED, - g_fvCfg->bViewWatched? MF_UNCHECKED: MF_CHECKED); - g_fvCfg->bViewWatched = !g_fvCfg->bViewWatched; + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_WATCHED, g_cfg.bViewWatched? MF_UNCHECKED: MF_CHECKED); + g_cfg.bViewWatched = !g_cfg.bViewWatched; g_elv->Update(); g_elv->EnsureFocusVisible(); /* TODO: Remember last valid focus. In case of @@ -425,24 +422,23 @@ void HandleMainMenu(const HWND hWnd, const WORD command) break; case IDM_VIEW_TV_ORIGINAL: - CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, - g_fvCfg->bViewTVOriginal? MF_UNCHECKED: MF_CHECKED); - g_fvCfg->bViewTVOriginal = !g_fvCfg->bViewTVOriginal; + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, g_cfg.bViewTVOriginal? MF_UNCHECKED: MF_CHECKED); + g_cfg.bViewTVOriginal = !g_cfg.bViewTVOriginal; g_elv->Update(); g_elv->EnsureFocusVisible(); break; case IDM_VIEW_OTHERS: - if (g_fvCfg->limitScreenwriter[0]) { /* Show episodes by all screenwriters. */ + if (g_cfg.limitScreenwriter[0]) { /* Show episodes by all screenwriters. */ CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, MF_CHECKED); - g_fvCfg->limitScreenwriter[0] = 0; + g_cfg.limitScreenwriter[0] = 0; } else { /* Hide episodes by other screenwriters than current. */ Mark m; WcharPtr s; LVITEM lvi = {LVIF_PARAM, -1}; if (g_elv->FindNextItem(&lvi, LVNI_FOCUSED) && Pl("episode_data","episode_datum",lvi.lParam,"Screenwriter",&s)) { - Wcscpy(g_fvCfg->limitScreenwriter, s); + Wcscpy(g_cfg.limitScreenwriter, s); CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, MF_UNCHECKED); } } -- cgit v1.2.3