aboutsummaryrefslogtreecommitdiff
path: root/c/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/main.cpp')
-rw-r--r--c/main.cpp178
1 files changed, 67 insertions, 111 deletions
diff --git a/c/main.cpp b/c/main.cpp
index 64e6058..dd18d77 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -133,7 +133,7 @@ int WINAPI WinMain(const HINSTANCE hInstance, const HINSTANCE, char* const, cons
(const TCHAR*)NULL,
WS_CHILD|WS_VISIBLE|SBARS_SIZEGRIP,
0, 0, 0, 0,
- hWnd, (HMENU)ID_STATUS, hInstance, (void*)NULL));
+ hWnd, (HMENU)IDR_STATUS, hInstance, (void*)NULL));
ShowWindow(hWnd, nCmdShow);
@@ -272,7 +272,7 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
break;
case WM_TIMER:
switch (wParam) {
- case IDT_TIMER:
+ case IDR_TIMER:
{
static int i = 0;
@@ -288,7 +288,7 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
} else {
i = 0;
g_bThread = 0;
- prefer(KillTimer(hWnd, IDT_TIMER));
+ prefer(KillTimer(hWnd, IDR_TIMER));
g_pElv->Update();
}
break;
@@ -296,6 +296,11 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
}
break;
case WM_COMMAND:
+ {
+ if (ID_GROUP((LOWORD(wParam))) == IDG_CTX)
+ goto ctx;
+
+ /* Process main menu commands. */
switch (LOWORD(wParam)) {
case IDM_FILE_EXIT:
PostMessage(hWnd, WM_CLOSE, 0, 0);
@@ -310,8 +315,8 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
case IDM_FILE_FETCH_SCREENWRITERS:
if (g_bThread) break;
Pl("episode_data","thread_create","update_screenwriters",&g_aThread);
- t: KillTimer(hWnd, IDT_TIMER);
- if (!prefer(SetTimer(hWnd, IDT_TIMER, 500, (TIMERPROC)NULL))) break;
+ t: KillTimer(hWnd, IDR_TIMER);
+ if (!prefer(SetTimer(hWnd, IDR_TIMER, 500, (TIMERPROC)NULL))) break;
SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), (LPARAM)TEXT("."));
g_bThread = 1;
break;
@@ -365,120 +370,71 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
g_pElv->Update();
g_pElv->EnsureFocusVisible();
break;
- case IDM_WATCH_LOCALLY:
- case IDM_WATCH_ONLINE:
- case IDM_TOGGLE:
- case IDM_FORGET:
- case IDM_LOOKUP:
- case IDM_WIKI:
- case IDM_RATE10:
- case IDM_RATE9:
- case IDM_RATE8:
- case IDM_RATE7:
- case IDM_RATE6:
- case IDM_RATE5:
- case IDM_RATE4:
- case IDM_RATE3:
- case IDM_RATE2:
- case IDM_RATE1:
- case IDM_RATE0:
- {
- int iRating;
- LVITEM lvi;
+ }
+ break;
+
+ /* Process context menu commands. */
+ ctx:
+ int cNotFound = 0;
+ LVITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = -1;
+ while ((lvi.iItem = ListView_GetNextItem(
+ g_pElv->hWnd, lvi.iItem, LVNI_SELECTED)) != -1) {
/* Look through selected items, applying the
* selected command to each one. */
- lvi.mask = LVIF_PARAM;
- lvi.iItem = -1;
- while ((lvi.iItem = ListView_GetNextItem(
- g_pElv->hWnd, lvi.iItem, LVNI_SELECTED)) != -1) {
- if (!ListView_GetItem(g_pElv->hWnd, &lvi)) goto b;
-
- switch (LOWORD(wParam)) {
- case IDM_WATCH_LOCALLY:
- if (!Pl("local_episode","open_episode_locally",lvi.lParam))
- EBMessageBox(TEXT("Local episode could not be opened."),
- TEXT("Error"), MB_ICONWARNING);
- break;
- case IDM_WATCH_ONLINE:
- Pl("local_episode","open_episode_online",lvi.lParam);
- break;
- case IDM_TOGGLE:
- Pl("track_episodes","toggle_episode",lvi.lParam);
- g_pElv->Redraw();
- break;
- case IDM_FORGET:
- Pl("track_episodes","forget_episode",lvi.lParam);
- Pl("track_episodes","update_tracked_episodes");
- g_pElv->Redraw();
- break;
- case IDM_LOOKUP:
- Pl("episode_data","retract_episode",lvi.lParam);
- g_pElv->UpdateItem(&lvi);
- g_pElv->Redraw();
- g_pDlv->ShowEpisode(lvi.lParam);
- break;
- case IDM_WIKI:
- Pl("episode_data","open_episode_wiki",lvi.lParam);
- break;
- case IDM_RATE10:
- iRating = 10;
- goto r;
- case IDM_RATE9:
- iRating = 9;
- goto r;
- case IDM_RATE8:
- iRating = 8;
- goto r;
- case IDM_RATE7:
- iRating = 7;
- goto r;
- case IDM_RATE6:
- iRating = 6;
- goto r;
- case IDM_RATE5:
- iRating = 5;
- goto r;
- case IDM_RATE4:
- iRating = 4;
- goto r;
- case IDM_RATE3:
- iRating = 3;
- goto r;
- case IDM_RATE2:
- iRating = 2;
- goto r;
- case IDM_RATE1:
- iRating = 1;
- goto r;
- case IDM_RATE0:
- iRating = 0;
- r: Pl("episode_data","rate_episode",lvi.lParam,iRating);
- g_pElv->UpdateItem(&lvi);
- break;
- }
+ if (!ListView_GetItem(g_pElv->hWnd, &lvi)) goto b;
+
+ /* Process rate command. */
+ if (ID_SUBGROUP(LOWORD(wParam)) == IDG_CTX_RATE) {
+ Pl("episode_data","rate_episode",lvi.lParam,ID_RATING(LOWORD(wParam)));
+ g_pElv->UpdateItem(&lvi);
+ continue;
}
+
+ /* Process other commands. */
switch (LOWORD(wParam)) {
- case IDM_RATE10:
- case IDM_RATE9:
- case IDM_RATE8:
- case IDM_RATE7:
- case IDM_RATE6:
- case IDM_RATE5:
- case IDM_RATE4:
- case IDM_RATE3:
- case IDM_RATE2:
- case IDM_RATE1:
- case IDM_RATE0:
- g_pElv->Redraw();
- g_pElv->Sort();
- g_pElv->ShowFocus();
+ case IDM_WATCH_LOCALLY:
+ if (!Pl("local_episode","open_episode_locally",lvi.lParam))
+ cNotFound++;
+ break;
+ case IDM_WATCH_ONLINE:
+ Pl("local_episode","open_episode_online",lvi.lParam);
+ break;
+ case IDM_TOGGLE:
+ Pl("track_episodes","toggle_episode",lvi.lParam);
+ break;
+ case IDM_FORGET:
+ Pl("track_episodes","forget_episode",lvi.lParam);
+ Pl("track_episodes","update_tracked_episodes");
+ break;
+ case IDM_LOOKUP:
+ Pl("episode_data","retract_episode",lvi.lParam);
+ g_pElv->UpdateItem(&lvi);
+ g_pDlv->ShowEpisode(lvi.lParam);
+ break;
+ case IDM_WIKI:
+ Pl("episode_data","open_episode_wiki",lvi.lParam);
+ break;
}
- b: break;
- }
}
- break;
+
+ g_pElv->Redraw();
+ if (cNotFound == 1) {
+ EBMessageBox(TEXT("Episode could not be opened locally."),
+ TEXT("Error"), MB_ICONWARNING);
+ } else if (cNotFound) {
+ std::basic_ostringstream<TCHAR> tss;
+ tss << cNotFound << TEXT(" episodes could not be opened locally.");
+ EBMessageBox(tss.str().c_str(), TEXT("Error"), MB_ICONWARNING);
+ } else if (ID_SUBGROUP(LOWORD(wParam)) == IDG_CTX_RATE) {
+ g_pElv->Sort();
+ g_pElv->ShowFocus();
+ }
+ b: break;
+ }
case WM_MENUSELECT:
switch (LOWORD(wParam)) {
#define TIP(s) SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(0,0), (LPARAM)(s));