aboutsummaryrefslogtreecommitdiff
path: root/c/main.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-17 03:15:37 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-17 03:15:37 +0200
commit2e8afa446f2444a8be5e6180bf90cfa48b6e02f0 (patch)
tree2ad81de172861419f16da8d4dd53074f80bd455d /c/main.cpp
parentbd857d24443b8c8f5d2f58047c3f8ac5f058acea (diff)
downloadEpisodeBrowser-2e8afa446f2444a8be5e6180bf90cfa48b6e02f0.tar.gz
Add CfgA.
Diffstat (limited to 'c/main.cpp')
-rw-r--r--c/main.cpp57
1 files changed, 21 insertions, 36 deletions
diff --git a/c/main.cpp b/c/main.cpp
index 9a4bcf2..1b818c0 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -51,10 +51,8 @@ EpisodeListView* g_elv;
/* Layout handlers. */
DlvDragger g_dragDlv;
-/* View settings. */
-int g_bViewWatched = 1;
-int g_bViewTVOriginal = 1;
-char g_limitScreenwriter[64];
+/* File views. */
+FileView<CfgA> g_fvCfg{L"cfg.dat", 1};
/* Optional Windows functions. */
BOOL (*IsThemeActive)();
@@ -217,21 +215,6 @@ void InitializeMainWindow(const HWND hWnd)
g_dlv = new DataListView(hWnd);
g_elv = new EpisodeListView(hWnd);
- /* Get saved view settings. */
- Pl("cfg","get_view_watched",&g_bViewWatched);
- Pl("cfg","get_view_tv_original",&g_bViewTVOriginal);
- {
- Mark m;
- char* s;
- if (Pl("cfg","get_limit_screenwriter",&s))
- Strcpy(g_limitScreenwriter, s);
- }
- {
- int dlvHeight = 0;
- Pl("cfg","get_dlv_height",&dlvHeight);
- g_dlv->SetHeight(dlvHeight);
- }
-
/* The global main window handle must only be set AFTER
* successful initialization. */
g_hWnd = hWnd;
@@ -246,9 +229,12 @@ 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_bViewWatched? MF_CHECKED: MF_UNCHECKED);
- CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, g_bViewTVOriginal? MF_CHECKED: MF_UNCHECKED);
- CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, g_limitScreenwriter[0]? MF_UNCHECKED: MF_CHECKED);
+ 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);
return 0;
case WM_CLOSE:
@@ -340,13 +326,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_bViewWatched?
+ /*IDM_VIEW_WATCHED*/(g_fvCfg->bViewWatched?
L"Click to hide watched episodes.":
L"Click to show watched episodes."),
- /*IDM_VIEW_TV_ORIGINAL*/(g_bViewTVOriginal?
+ /*IDM_VIEW_TV_ORIGINAL*/(g_fvCfg->bViewTVOriginal?
L"Click to hide TV original episodes.":
L"Click to show TV original episodes."),
- /*IDM_VIEW_OTHERS*/(g_limitScreenwriter?
+ /*IDM_VIEW_OTHERS*/(g_fvCfg->limitScreenwriter?
L"Click to hide episodes by other screenwriters.":
L"Click to show episodes by other screenwriters.")
};
@@ -429,9 +415,9 @@ void HandleMainMenu(const HWND hWnd, const WORD command)
break;
case IDM_VIEW_WATCHED:
- CheckMenuItem(GetMenu(hWnd), IDM_VIEW_WATCHED, g_bViewWatched? MF_UNCHECKED: MF_CHECKED);
- g_bViewWatched = !g_bViewWatched;
- Pl("cfg","set_view_watched",g_bViewWatched);
+ CheckMenuItem(GetMenu(hWnd), IDM_VIEW_WATCHED,
+ g_fvCfg->bViewWatched? MF_UNCHECKED: MF_CHECKED);
+ g_fvCfg->bViewWatched = !g_fvCfg->bViewWatched;
g_elv->Update();
g_elv->EnsureFocusVisible();
/* TODO: Remember last valid focus. In case of
@@ -439,28 +425,27 @@ void HandleMainMenu(const HWND hWnd, const WORD command)
break;
case IDM_VIEW_TV_ORIGINAL:
- CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, g_bViewTVOriginal? MF_UNCHECKED: MF_CHECKED);
- g_bViewTVOriginal = !g_bViewTVOriginal;
- Pl("cfg","set_view_tv_original",g_bViewTVOriginal);
+ CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL,
+ g_fvCfg->bViewTVOriginal? MF_UNCHECKED: MF_CHECKED);
+ g_fvCfg->bViewTVOriginal = !g_fvCfg->bViewTVOriginal;
g_elv->Update();
g_elv->EnsureFocusVisible();
break;
case IDM_VIEW_OTHERS:
- if (g_limitScreenwriter[0]) { /* Show episodes by all screenwriters. */
+ if (g_fvCfg->limitScreenwriter[0]) { /* Show episodes by all screenwriters. */
CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, MF_CHECKED);
- g_limitScreenwriter[0] = 0;
+ g_fvCfg->limitScreenwriter[0] = 0;
} else { /* Hide episodes by other screenwriters than current. */
Mark m;
- char* s;
+ WcharPtr s;
LVITEM lvi = {LVIF_PARAM, -1};
if (g_elv->FindNextItem(&lvi, LVNI_FOCUSED)
&& Pl("episode_data","episode_datum",lvi.lParam,"Screenwriter",&s)) {
- Strcpy(g_limitScreenwriter, s);
+ Wcscpy(g_fvCfg->limitScreenwriter, s);
CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, MF_UNCHECKED);
}
}
- Pl("cfg","set_limit_screenwriter",g_limitScreenwriter);
g_elv->Update();
g_elv->EnsureFocusVisible();
break;