LRESULT CALLBACK TextDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static TCHAR szSaveText[DYNAMIC_TEXT_SIZE]={0}; switch (message) { case WM_INITDIALOG: // Save current dynamic text so that we can temporarily modify // the dynamic text during font adjustment _tcsncpy(szSaveText, g_szAppText, NUMELMS(szSaveText)); SendMessage(GetDlgItem(hWnd, IDC_EDIT_TEXT), EM_LIMITTEXT, DYNAMIC_TEXT_SIZE, 0L); SetWindowText(GetDlgItem(hWnd, IDC_EDIT_TEXT), g_szAppText); return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: { TCHAR szText[DYNAMIC_TEXT_SIZE]; GetWindowText(GetDlgItem(hWnd, IDC_EDIT_TEXT), szText, DYNAMIC_TEXT_SIZE); _tcsncpy(g_szAppText, szText, NUMELMS(g_szAppText)); BlendApplicationText(ghApp, g_szAppText); EndDialog(hWnd, TRUE); return TRUE; } break; case IDCANCEL: // Restore the original text in case it was modified // and previewed while adjusting the font _tcsncpy(g_szAppText, szSaveText, NUMELMS(g_szAppText)); BlendApplicationText(ghApp, g_szAppText); EndDialog(hWnd, TRUE); break; case IDC_SET_FONT: { TCHAR szTempText[DYNAMIC_TEXT_SIZE]={0}; // Change the current font g_hFont = UserSelectFont(); // Start displaying the text that is currently in the edit box GetWindowText(GetDlgItem(hWnd, IDC_EDIT_TEXT), szTempText, DYNAMIC_TEXT_SIZE); BlendApplicationText(ghApp, szTempText); } break; } break; } return FALSE; }
LRESULT CALLBACK WndMainProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_PAINT: OnPaint(hWnd); break; case WM_DISPLAYCHANGE: if (pWC) pWC->DisplayModeChanged(); break; // Resize the video when the window changes case WM_MOVE: case WM_SIZE: if (hWnd == ghApp) MoveVideoWindow(); break; // Enforce a minimum size case WM_GETMINMAXINFO: { LPMINMAXINFO lpmm = (LPMINMAXINFO) lParam; if (lpmm) { lpmm->ptMinTrackSize.x = MINIMUM_VIDEO_WIDTH; lpmm->ptMinTrackSize.y = MINIMUM_VIDEO_HEIGHT; } } break; case WM_KEYDOWN: switch(toupper((int) wParam)) { case VK_ESCAPE: case VK_F12: CloseClip(); break; } break; case WM_COMMAND: switch(wParam) { // Menus case ID_FILE_OPENCLIP: // If we have ANY file open, close it and shut down DirectShow CloseClip(); OpenClip(); // Open the new clip break; case ID_FILE_INITCLIP: OpenClip(); break; case ID_FILE_EXIT: CloseClip(); PostQuitMessage(0); break; case ID_FILE_CLOSE: CloseClip(); break; case ID_DISABLE: FlipFlag(MARK_DISABLE); DisableTicker(g_dwTickerFlags); break; case ID_SLIDE: FlipFlag(MARK_SLIDE); SlideTicker(g_dwTickerFlags); break; case ID_TICKER_STATIC_IMAGE: g_dwTickerFlags |= MARK_STATIC_IMAGE; g_dwTickerFlags &= ~(MARK_DYNAMIC_TEXT); BlendApplicationImage(ghApp); CheckMenuItem(ghMenu, ID_TICKER_STATIC_IMAGE, MF_CHECKED); CheckMenuItem(ghMenu, ID_TICKER_DYNAMIC_TEXT, MF_UNCHECKED); break; case ID_TICKER_DYNAMIC_TEXT: g_dwTickerFlags |= MARK_DYNAMIC_TEXT; g_dwTickerFlags &= ~(MARK_STATIC_IMAGE); BlendApplicationText(ghApp, g_szAppText); CheckMenuItem(ghMenu, ID_TICKER_STATIC_IMAGE, MF_UNCHECKED); CheckMenuItem(ghMenu, ID_TICKER_DYNAMIC_TEXT, MF_CHECKED); break; case ID_SET_FONT: g_hFont = UserSelectFont(); // Change the current font PostMessage(ghApp, WM_COMMAND, ID_TICKER_DYNAMIC_TEXT, 0); break; case ID_SET_TEXT: DialogBox(ghInst, MAKEINTRESOURCE(IDD_DIALOG_TEXT), ghApp, (DLGPROC) TextDlgProc); break; case ID_HELP_ABOUT: DialogBox(ghInst, MAKEINTRESOURCE(IDD_HELP_ABOUT), ghApp, (DLGPROC) AboutDlgProc); break; } // Menus break; case WM_GRAPHNOTIFY: HandleGraphEvent(); break; case WM_CLOSE: SendMessage(ghApp, WM_COMMAND, ID_FILE_EXIT, 0); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } // Window msgs handling return DefWindowProc(hWnd, message, wParam, lParam); }
/* * MenuCommand: A menu item has been selected. */ void MenuCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { // Set last action time to now, to prevent keypress from being interpreted as a game action. KeySetLastNorepeatTime(); // See if module wants to handle menu selection if (ModuleEvent(EVENT_MENUITEM, id) == False) return; /* Handle menu selections */ switch (id) { case ID_GAME_EXIT: if (connection != CON_NONE && !AreYouSure(hInst, hMain, NO_BUTTON, IDS_LOGOFF)) break; MainQuit(hwnd); break; case ID_GAME_PRINTMAP: if (state == STATE_GAME) PrintMap(FALSE); break; case ID_GAME_CONNECT: OfflineConnect(); break; case ID_GAME_DISCONNECT: if (!AreYouSure(hInst, hMain, NO_BUTTON, IDS_LOGOFF)) break; Logoff(); MainSetState(STATE_OFFLINE); break; case ID_GAME_SETTINGS: if (DialogBox(hInst, MAKEINTRESOURCE(IDD_SETTINGS), hMain, PreferencesDialogProc) == IDOK) { ModuleEvent(EVENT_CONFIGCHANGED); MenuDisplaySettings(hMain); } break; case ID_CONFIGMENU: ConfigMenuLaunch(); break; case ID_GAME_PASSWORD: PerformAction(A_CHANGEPASSWORD, NULL); break; case ID_OPTIONS_TIMEOUT: UserSetTimeout(); break; case ID_OPTIONS_MUSIC: config.play_music = !config.play_music; CheckMenuItem(menu, ID_OPTIONS_MUSIC, config.play_music ? MF_CHECKED : MF_UNCHECKED); UserToggleMusic(config.play_music); break; case ID_OPTIONS_SOUND: config.play_sound = !config.play_sound; CheckMenuItem(menu, ID_OPTIONS_SOUND, config.play_sound ? MF_CHECKED : MF_UNCHECKED); if (!config.play_sound) SoundStopAll(); break; case ID_OPTIONS_SAVENOW: SaveSettings(); break; case ID_OPTIONS_SAVEEXIT: config.save_settings = !config.save_settings; CheckMenuItem(menu, ID_OPTIONS_SAVEEXIT, config.save_settings ? MF_CHECKED : MF_UNCHECKED); break; case ID_OPTIONS_AREA: // due to issues with certain D3D drivers, this no longer immediately updates the config // it now sets a temporary variable that will update the config on shutdown // this means a shutdown and restart are necessary for window size changes MessageBox(hMain, "You must shutdown and restart Meridian 59 for these changes to take effect", "Direct3D", MB_OK); // config.large_area = !config.large_area; gLargeArea = !gLargeArea; CheckMenuItem(menu, ID_OPTIONS_AREA, gLargeArea ? MF_CHECKED : MF_UNCHECKED); /* if (state == STATE_GAME) // Send ourselves a resize message ResizeAll(); RedrawAll();*/ break; case ID_OPTIONS_FONT_MAP_TITLE: UserSelectFont(FONT_MAP_TITLE); break; case ID_OPTIONS_FONT_MAP_LABEL: UserSelectFont(FONT_MAP_LABEL); break; case ID_OPTIONS_FONT_MAP_TEXT: UserSelectFont(FONT_MAP_TEXT); break; case ID_FONT_GAMETEXT: UserSelectFont(FONT_EDIT); break; case ID_FONT_LIST: UserSelectFont(FONT_LIST); break; case ID_FONT_MAIL: UserSelectFont(FONT_MAIL); break; case ID_FONT_TITLES: UserSelectFont(FONT_TITLES); break; case ID_FONT_STATISTICS: UserSelectFont(FONT_STATS); break; case ID_FONT_INPUT: UserSelectFont(FONT_INPUT); break; case ID_FONT_LABELS: UserSelectFont(FONT_LABELS); break; case ID_FONT_DEFAULTS: FontsRestoreDefaults(); break; case ID_COLOR_MAIN: UserSelectColors(COLOR_FGD, COLOR_BGD); break; case ID_COLOR_LIST: UserSelectColors(COLOR_LISTFGD, COLOR_LISTBGD); break; case ID_COLOR_LISTSEL: UserSelectColors(COLOR_LISTSELFGD, COLOR_LISTSELBGD); break; case ID_COLOR_MAGIC: UserSelectColor(COLOR_ITEM_MAGIC_FG); break; case ID_COLOR_HIGHLIGHT: UserSelectColor(COLOR_HIGHLITE); break; case ID_COLOR_MAIL: UserSelectColors(COLOR_MAILFGD, COLOR_MAILBGD); break; case ID_COLOR_TEXT: UserSelectColors(COLOR_MAINEDITFGD, COLOR_MAINEDITBGD); break; case ID_COLOR_EDIT: UserSelectColors(COLOR_EDITFGD, COLOR_EDITBGD); break; case ID_COLOR_SYSMSG: UserSelectColor(COLOR_SYSMSGFGD); case ID_COLOR_QUESTHEADER: UserSelectColor(COLOR_QUEST_HEADER); break; break; case ID_COLOR_STATS: UserSelectColors(COLOR_STATSFGD, COLOR_STATSBGD); break; case ID_COLOR_BAR1: UserSelectColor(COLOR_BAR1); break; case ID_COLOR_BAR2: UserSelectColor(COLOR_BAR2); break; case ID_COLOR_BAR3: UserSelectColor(COLOR_BAR3); break; case ID_COLOR_BAR4: UserSelectColor(COLOR_BAR4); break; case ID_COLOR_INVNUM: UserSelectColors(COLOR_INVNUMFGD, COLOR_INVNUMBGD); break; case ID_COLOR_DEFAULTS: ColorsRestoreDefaults(); break; case ID_HELP_CONTENTS: StartHelp(); break; case ID_HOMEPAGE: WebLaunchBrowser(GetString(hInst, IDS_HOMEPAGEURL)); break; case ID_FORUM: WebLaunchBrowser(GetString(hInst, IDS_FORUMURL)); break; case ID_WIKI: WebLaunchBrowser(GetString(hInst, IDS_WIKIURL)); break; case ID_HELP_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), hMain, AboutDialogProc); break; } }