From e12dafae0488d82d05be9dfde3d99f9e3cbb0ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 28 May 2022 20:50:33 +0200 Subject: Add option to show/hide other screenwriters. --- c/defs.h | 2 ++ c/episodelistview.c | 27 +++++++++++++++++------- c/main.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++--- c/resource.h | 1 + c/resource.rc | 1 + 5 files changed, 81 insertions(+), 10 deletions(-) (limited to 'c') diff --git a/c/defs.h b/c/defs.h index 7f22389..6cb5c25 100644 --- a/c/defs.h +++ b/c/defs.h @@ -43,6 +43,8 @@ void DlvShowEpisode(int); #define Qn(q) PL_next_solution(q) #define Qc(q) PL_cut_query(q) #define T(a) PL_new_term_refs(a) +#define A(s) PL_new_atom(s) +#define PA(t,x) if (!PL_put_atom(t,x)) #define PI(t,x) if (!PL_put_integer(t,x)) #define GI(t,x) if (!PL_get_integer(t,x)) #define GAC(t,x) if (!PL_get_atom_chars(t,x)) diff --git a/c/episodelistview.c b/c/episodelistview.c index 42c207d..c432497 100644 --- a/c/episodelistview.c +++ b/c/episodelistview.c @@ -364,26 +364,39 @@ ElvUpdate() GI(t,&cEp) return; for (iEp = 1, iItem = 0; iEp <= cEp; iEp++) { + extern char SzLimitScreenwriter[]; extern int BViewTVOriginal, BViewWatched; - if (!BViewWatched) { + if (SzLimitScreenwriter[0]) { + atom_t a1, a2; term_t t; - t = T(1); + t = T(3); + a1 = A("Screenwriter"); + a2 = A(SzLimitScreenwriter); PI(t,iEp) goto a; - P("track_episodes","watched",1,t) goto a; - continue; + PA(t+1,a1) goto a; + PA(t+2,a2) goto a; + P("episode_data","episode_datum",3,t) continue; } - a: if (!BViewTVOriginal) { + a: if (!BViewWatched) { term_t t; t = T(1); PI(t,iEp) goto b; - P("episode_data","tv_original",1,t) goto b; + P("track_episodes","watched",1,t) goto b; + continue; + } + + b: if (!BViewTVOriginal) { + term_t t; + t = T(1); + PI(t,iEp) goto c; + P("episode_data","tv_original",1,t) goto c; continue; } /* Format episode number string. */ - b: _stprintf_s(tszEpisode, sizeof(tszEpisode), TEXT("%d"), iEp); + c: _stprintf_s(tszEpisode, sizeof(tszEpisode), TEXT("%d"), iEp); /* Insert item. */ lviEpisode.iItem = iItem++; diff --git a/c/main.c b/c/main.c index f312206..1ce77d9 100644 --- a/c/main.c +++ b/c/main.c @@ -6,6 +6,7 @@ #include "resource.h" #include "defs.h" +char SzLimitScreenwriter[64] = {0}; HFONT HfNormal; HFONT HfBold; HMENU HPopupMenu; @@ -127,7 +128,7 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) term_t t; t = T(1); P("cfg","get_view_watched",1,t) goto s; - GI(t,&BViewWatched); + GI(t,&BViewWatched) goto s; CheckMenuItem(GetMenu(hWnd), IDM_VIEW_WATCHED, BViewWatched? MF_CHECKED: MF_UNCHECKED); } @@ -135,11 +136,22 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) term_t t; t = T(1); P("cfg","get_view_tv_original",1,t) goto t; - GI(t,&BViewTVOriginal); + GI(t,&BViewTVOriginal) goto t; CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, BViewTVOriginal? MF_CHECKED: MF_UNCHECKED); } - t: SetupFonts(); + t: { + char *sz; + term_t t; + t = T(1); + P("cfg","get_limit_screenwriter",1,t) goto u; + GAC(t,&sz) goto u; + strcpy_s(SzLimitScreenwriter, + sizeof(SzLimitScreenwriter), sz); + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, + SzLimitScreenwriter[0]? MF_UNCHECKED: MF_CHECKED); + } + u: SetupFonts(); DlvCreate(); ElvCreate(); UpdateTheme(); @@ -270,6 +282,48 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ListView_EnsureVisible(HElv, iEpFocus, TRUE); break; } + case IDM_VIEW_OTHERS: /* Show/hide other screenwriters. */ + { + atom_t a; + int iEpFocus; + term_t t; + extern HWND HElv; + if (SzLimitScreenwriter[0]) { + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, + MF_CHECKED); + SzLimitScreenwriter[0] = 0; + } else { + atom_t a; + char *sz; + LVITEM lvi; + term_t t; + iEpFocus = ListView_GetNextItem(HElv, -1, LVNI_FOCUSED); + if (iEpFocus == -1) break; + lvi.iItem = iEpFocus; + lvi.mask = LVIF_PARAM; + if (!ListView_GetItem(HElv, &lvi)) break; + t = T(3); + a = A("Screenwriter"); + PI(t,lvi.lParam) break; + PA(t+1,a) break; + P("episode_data","episode_datum",3,t) break; + GAC(t+2,&sz) break; + strcpy_s(SzLimitScreenwriter, + sizeof(SzLimitScreenwriter), sz); + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, + MF_UNCHECKED); + } + OutputDebugStringA(SzLimitScreenwriter); + ElvUpdate(); + t = T(1); + a = A(SzLimitScreenwriter); + PA(t,a) break; + P("cfg","set_limit_screenwriter",1,t); + iEpFocus = ListView_GetNextItem(HElv, -1, LVNI_FOCUSED); + if (iEpFocus == -1) break; + ListView_EnsureVisible(HElv, iEpFocus, TRUE); + break; + } case IDM_WATCH: case IDM_TOGGLE: case IDM_FORGET: diff --git a/c/resource.h b/c/resource.h index 9c3bf2a..375de8b 100644 --- a/c/resource.h +++ b/c/resource.h @@ -16,6 +16,7 @@ #define IDM_FILE_ABOUT 411 #define IDM_VIEW_WATCHED 421 #define IDM_VIEW_TV_ORIGINAL 422 +#define IDM_VIEW_OTHERS 423 #define IDM_WATCH 501 #define IDM_TOGGLE 502 #define IDM_FORGET 503 diff --git a/c/resource.rc b/c/resource.rc index 2742c58..1811634 100644 --- a/c/resource.rc +++ b/c/resource.rc @@ -17,6 +17,7 @@ BEGIN BEGIN MENUITEM "&Watched", IDM_VIEW_WATCHED, CHECKED MENUITEM "&TV Originals", IDM_VIEW_TV_ORIGINAL, CHECKED + MENUITEM "Other &Screenwriters", IDM_VIEW_OTHERS, CHECKED END POPUP "&Help" BEGIN -- cgit v1.2.3