/* Sheet_HandleCommand: Handles all commands routed to property sheet (mostly menuitem stuff). */ bool Sheet_HandleCommand(HWND sheet, WORD code, WORD id, HWND control) { bool ret = true; Player *p = propdata.p; switch (id) { case ID_FILE_REOPEN: FileOpen(sheet, false, 0); break; case ID_TS_FILE_OPEN: FileOpen(sheet, true, -1); break; case ID_TS_FILE_NEW: case ID_TS_FILE_CLOSE: FileClose(sheet, control); break; case ID_TS_APP_EXIT: if (scen.needsave()) { int sel = MessageBox(sheet, "Do you want to save your changes?", "Save", MB_YESNOCANCEL); if (sel == IDYES) FileSave(sheet, false, true); else if (sel == IDCANCEL) break; //stop closing } DestroyWindow(sheet); break; case ID_TS_FILE_SAVE: FileSave(sheet, false, true); break; case ID_TS_FILE_SAVE_AS: FileSave(sheet, true, true); break; case ID_TS_FILE_SAVE_AS2: FileSave(sheet, true, false); case ID_FILE_DUMP: if (!scen.exFile("dump", -1)) { MessageBox(sheet, "Dump failed.", "Scenario Dump", MB_ICONWARNING); } else { SetWindowText(propdata.statusbar, "Per files saved to disk"); } break; case IDC_U_CLEARAICPVC: scen.clearaicpvc(); SetWindowText(propdata.statusbar, "Removed All AI, City Plan and VC files"); SendMessage(PropSheet_GetCurrentPageHwnd(sheet), AOKTS_Loading, 0, 0); break; case IDC_U_RANDOMIZE_ROT: scen.randomize_unit_frames(); SetWindowText(propdata.statusbar, "Randomized unit frames and rotations"); break; case ID_UNITS_TERRAIN_ELEV: scen.set_unit_z_to_map_elev(); SetWindowText(propdata.statusbar, "Unit z positions set to terrain elevation"); break; case ID_UNITS_DELETE_ALL: scen.delete_player_units(propdata.pindex); SetWindowText(propdata.statusbar, "Player's units deleted"); SendMessage(propdata.mapview, MAP_Reset, 0, 0); break; case ID_MAP_WATER_CLIFF_INVISIBLE: scen.water_cliffs_visibility(FALSE); SetWindowText(propdata.statusbar, "Water cliffs are now invisible"); break; case ID_MAP_WATER_CLIFF_VISIBLE: scen.water_cliffs_visibility(TRUE); SetWindowText(propdata.statusbar, "Water cliffs are now visible"); break; case ID_TRIGGERS_SORT_CONDS_EFFECTS: scen.sort_conds_effects(); SetWindowText(propdata.statusbar, "Trigger contitions and effects sorted alphanumerically"); break; case ID_TRIGGERS_NOINSTRUCTIONSSOUND: scen.instructions_sound_text_set(); SetWindowText(propdata.statusbar, "Sound text set to null"); break; case ID_TRIGGERS_NOINSTRUCTIONSSOUNDID: scen.instructions_sound_id_set(-1); SetWindowText(propdata.statusbar, "Sound ID set to -1 for all display instructions effects"); break; case ID_TRIGGERS_ZEROINSTRUCTIONSSOUNDID: scen.instructions_sound_id_set(0); SetWindowText(propdata.statusbar, "Sound ID set to 0 for all display instructions effects"); break; case ID_TRIGGERS_NOPANEL: scen.instructions_panel_set(-1); SetWindowText(propdata.statusbar, "Panel ID removed from all display instructions effects"); break; case ID_TRIGGERS_ZEROPANEL: scen.instructions_panel_set(0); SetWindowText(propdata.statusbar, "Panel ID set to 0 for all display instructions effects"); break; case ID_TRIGGERS_ZERODI: scen.instructions_string_zero(); SetWindowText(propdata.statusbar, "String ID set to 0 for all display instructions effects"); break; case ID_TRIGGERS_RESETDI: scen.instructions_string_reset(); SetWindowText(propdata.statusbar, "String ID set to -1 for all display instructions effects"); break; case ID_TRIGGERS_HIDENAMES: scen.remove_trigger_names(); SetWindowText(propdata.statusbar, "Trigger names removed"); break; case ID_TRIGGERS_COPY_SCRAWL: { std::ostringstream ss; scen.accept(TrigScrawlVisitor(ss)); std::string scrawl = std::string(""); scrawl.append(ss.str()); const char* output = scrawl.c_str(); const size_t len = strlen(output) + 1; HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len); memcpy(GlobalLock(hMem), output, len); GlobalUnlock(hMem); OpenClipboard(0); EmptyClipboard(); SetClipboardData(CF_TEXT, hMem); CloseClipboard(); SetWindowText(propdata.statusbar, "Copied trigger scrawl"); } break; case ID_TRIGGERS_SAVE_PSEUDONYMS: scen.save_pseudonyms(); SetWindowText(propdata.statusbar, "Pseudonyms saved"); break; case ID_TRIGGERS_PREFIX_DISPLAY_ORDER: scen.prefix_display_order(); SetWindowText(propdata.statusbar, "Prefixing display order to trigger names"); break; case ID_TRIGGERS_REMOVE_DISPLAY_ORDER_PREFIX: scen.remove_display_order_prefix(); SetWindowText(propdata.statusbar, "Prefixing display order to trigger names"); break; case ID_TRIGGERS_HIDE_DESCRIPTIONS: scen.remove_trigger_descriptions(); SetWindowText(propdata.statusbar, "Trigger descriptions removed"); break; case ID_TRIGGERS_SWAP_NAMES_DESCRIPTIONS: scen.swap_trigger_names_descriptions(); SetWindowText(propdata.statusbar, "Trigger names swapped with descriptions"); break; case ID_TRIGGERS_FIXTRIGGEROUTLIERS: scen.fix_trigger_outliers(); SetWindowText(propdata.statusbar, "Triggers outside of map have been put within the boundaries"); break; case ID_FILE_TRIGWRITE: OnFileTrigWrite(sheet); break; case ID_FILE_TRIGREAD: OnFileTrigRead(sheet); break; case IDC_P_TOUP: if (MessageBox(sheet, "Normally, you will be asked to do this later when you save the scenario to a different format.\nThis menu for fixing broken scenarios. Are you sure you want to do this?", "Convert", MB_YESNOCANCEL) == IDYES) { scen.hd_to_up(); SetWindowText(propdata.statusbar, "Trigger effects converted from AoHD to UserPatch"); } break; case IDC_P_TOHD: if (MessageBox(sheet, "Normally, you will be asked to do this later when you save the scenario to a different format.\nThis menu for fixing broken scenarios. Are you sure you want to do this?", "Convert", MB_YESNOCANCEL) == IDYES) { scen.up_to_hd(); SetWindowText(propdata.statusbar, "Trigger effects converted from UserPatch to AoHD"); } break; case IDC_P_TOAOFE: if (MessageBox(sheet, "Normally, you will be asked to do this later when you save the scenario to a different format.\nThis menu for fixing broken scenarios. Are you sure you want to do this?", "Convert", MB_YESNOCANCEL) == IDYES) { scen.up_to_aofe(); SetWindowText(propdata.statusbar, "Trigger effects converted from UserPatch to AoFE"); } break; case IDC_P_TO1C: if (MessageBox(sheet, "Normally, you will be asked to do this later when you save the scenario to a different format.\nThis menu for fixing broken scenarios. Are you sure you want to do this?", "Convert", MB_YESNOCANCEL) == IDYES) { scen.up_to_10c(); SetWindowText(propdata.statusbar, "Trigger effects converted from UserPatch to 1.0c"); } break; case ID_FILE_RECENT1: case ID_FILE_RECENT2: case ID_FILE_RECENT3: case ID_FILE_RECENT4: FileOpen(sheet, false, id - ID_FILE_RECENT1); break; case IDCANCEL: case IDOK: assert(true); break; case ID_VIEW_STATISTICS: DialogBoxParam(aokts, MAKEINTRESOURCE(IDD_STATS), sheet, StatsDialogProc, 0); break; case ID_VIEW_STAT_BAR: if (GetMenuState(GetMenu(sheet), ID_VIEW_STAT_BAR, MF_BYCOMMAND) & MF_CHECKED) { ShowWindow(propdata.statusbar, SW_HIDE); CheckMenuItem(GetMenu(sheet), ID_VIEW_STAT_BAR, MF_BYCOMMAND); } else { ShowWindow(propdata.statusbar, SW_SHOW); CheckMenuItem(GetMenu(sheet), ID_VIEW_STAT_BAR, MF_BYCOMMAND | MF_CHECKED); } break; case ID_VIEW_MAP: if (GetMenuState(GetMenu(sheet), ID_VIEW_MAP, MF_BYCOMMAND) & MF_CHECKED) { // hide window ShowWindow(propdata.mapview, SW_HIDE); // clear check CheckMenuItem(GetMenu(sheet), ID_VIEW_MAP, MF_BYCOMMAND); } else { ShowWindow(propdata.mapview, SW_SHOW); CheckMenuItem(GetMenu(sheet), ID_VIEW_MAP, MF_BYCOMMAND | MF_CHECKED); } break; case ID_DRAW_TERRAIN: if (GetMenuState(GetMenu(sheet), ID_DRAW_TERRAIN, MF_BYCOMMAND) & MF_CHECKED) { setts.drawterrain = false; // clear check CheckMenuItem(GetMenu(sheet), ID_DRAW_TERRAIN, MF_BYCOMMAND); } else { setts.drawterrain = true; // clear check CheckMenuItem(GetMenu(sheet), ID_DRAW_TERRAIN, MF_BYCOMMAND | MF_CHECKED); } SendMessage(propdata.mapview, MAP_Reset, 0, 0); break; case ID_DRAW_ELEVATION: if (GetMenuState(GetMenu(sheet), ID_DRAW_ELEVATION, MF_BYCOMMAND) & MF_CHECKED) { setts.drawelevation = false; // clear check CheckMenuItem(GetMenu(sheet), ID_DRAW_ELEVATION, MF_BYCOMMAND); } else { setts.drawelevation = true; // clear check CheckMenuItem(GetMenu(sheet), ID_DRAW_ELEVATION, MF_BYCOMMAND | MF_CHECKED); } SendMessage(propdata.mapview, MAP_Reset, 0, 0); break; case ID_DRAW_TRIGGERS: if (GetMenuState(GetMenu(sheet), ID_DRAW_TRIGGERS, MF_BYCOMMAND) & MF_CHECKED) { setts.drawconds = false; setts.draweffects = false; setts.drawlocations = false; } else { setts.drawconds = true; setts.draweffects = true; setts.drawlocations = true; } SetDrawTriggerCheckboxes(sheet); SendMessage(propdata.mapview, MAP_Reset, 0, 0); break; case ID_DRAW_CONDITIONS: if (GetMenuState(GetMenu(sheet), ID_DRAW_CONDITIONS, MF_BYCOMMAND) & MF_CHECKED) { setts.drawconds = false; } else { setts.drawconds = true; } SetDrawTriggerCheckboxes(sheet); SendMessage(propdata.mapview, MAP_Reset, 0, 0); break; case ID_DRAW_EFFECTS: if (GetMenuState(GetMenu(sheet), ID_DRAW_EFFECTS, MF_BYCOMMAND) & MF_CHECKED) { setts.draweffects = false; } else { setts.draweffects = true; } SetDrawTriggerCheckboxes(sheet); SendMessage(propdata.mapview, MAP_Reset, 0, 0); break; case ID_DRAW_LOCATIONS: if (GetMenuState(GetMenu(sheet), ID_DRAW_LOCATIONS, MF_BYCOMMAND) & MF_CHECKED) { setts.drawlocations = false; } else { setts.drawlocations = true; } SetDrawTriggerCheckboxes(sheet); SendMessage(propdata.mapview, MAP_Reset, 0, 0); break; case ID_EDIT_ALL: if (GetMenuState(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND) & MF_CHECKED) { setts.editall = false; // clear check CheckMenuItem(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND); } else { setts.editall = true; CheckMenuItem(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND | MF_CHECKED); } break; case ID_TOOLS_COMPRESS: OnCompressOrDecompress(sheet, true); break; case ID_TOOLS_DECOMPRESS: OnCompressOrDecompress(sheet, false); break; case ID_TS_HELP: WinHelp(sheet, "ts.hlp", HELP_CONTENTS, 0); break; case ID_TS_APP_ABOUT: DialogBoxParam(aokts, (LPCSTR)IDD_ABOUT, sheet, DefaultDialogProc, 0L); break; default: ret = false; } return ret; }
/* Sheet_HandleCommand: Handles all commands routed to property sheet (mostly menuitem stuff). */ bool Sheet_HandleCommand(HWND sheet, WORD code, WORD id, HWND control) { bool ret = true; switch (id) { case ID_FILE_REOPEN: FileOpen(sheet, false, 0); break; case ID_TS_FILE_OPEN: FileOpen(sheet, true, -1); break; case ID_TS_FILE_NEW: case ID_TS_FILE_CLOSE: FileClose(sheet, control); break; case ID_TS_APP_EXIT: if (scen.needsave()) { int sel = MessageBox(sheet, "Do you want to save your changes?", "Save", MB_YESNOCANCEL); if (sel == IDYES) FileSave(sheet, false, true); else if (sel == IDCANCEL) break; //stop closing } DestroyWindow(sheet); break; case ID_TS_FILE_SAVE: FileSave(sheet, false, true); break; case ID_TS_FILE_SAVE_AS: FileSave(sheet, true, true); break; case ID_TS_FILE_SAVE_AS2: FileSave(sheet, true, false); case ID_FILE_DUMP: if (!scen.exFile("dump", -1)) { MessageBox(sheet, "Dump failed.", "Scenario Dump", MB_ICONWARNING); } else { SetWindowText(propdata.statusbar, "Per files saved to disk"); } break; case IDC_U_RANDOMIZE_ROT: scen.randomize_unit_frames(); SetWindowText(propdata.statusbar, "Randomized unit frames and rotations"); break; case ID_UNITS_TERRAIN_ELEV: scen.set_unit_z_to_map_elev(); SetWindowText(propdata.statusbar, "Unit z positions set to terrain elevation"); break; case ID_UNITS_DELETE_ALL: scen.delete_player_units(propdata.pindex); SetWindowText(propdata.statusbar, "Player's units deleted"); SendMessage(propdata.mapview, MAP_Reset, 0, 0); break; case ID_MAP_WATER_CLIFF_INVISIBLE: scen.water_cliffs_visibility(FALSE); SetWindowText(propdata.statusbar, "Water cliffs are now invisible"); break; case ID_MAP_WATER_CLIFF_VISIBLE: scen.water_cliffs_visibility(TRUE); SetWindowText(propdata.statusbar, "Water cliffs are now visible"); break; case ID_TRIGGERS_SORT_CONDS_EFFECTS: scen.sort_conds_effects(); SetWindowText(propdata.statusbar, "Trigger contitions and effects sorted alphanumerically"); break; case ID_TRIGGERS_NOINSTRUCTIONSSOUND: scen.instructions_sound_text_set(); SetWindowText(propdata.statusbar, "Sound text set to null"); break; case ID_TRIGGERS_NOINSTRUCTIONSSOUNDID: scen.instructions_sound_id_set(-1); SetWindowText(propdata.statusbar, "Sound ID set to -1 for all display instructions effects"); break; case ID_TRIGGERS_ZEROINSTRUCTIONSSOUNDID: scen.instructions_sound_id_set(0); SetWindowText(propdata.statusbar, "Sound ID set to 0 for all display instructions effects"); break; case ID_TRIGGERS_NOPANEL: scen.instructions_panel_set(-1); SetWindowText(propdata.statusbar, "Panel ID removed from all display instructions effects"); break; case ID_TRIGGERS_ZEROPANEL: scen.instructions_panel_set(0); SetWindowText(propdata.statusbar, "Panel ID set to 0 for all display instructions effects"); break; case ID_TRIGGERS_ZERODI: scen.instructions_string_zero(); SetWindowText(propdata.statusbar, "String ID set to 0 for all display instructions effects"); break; case ID_TRIGGERS_RESETDI: scen.instructions_string_reset(); SetWindowText(propdata.statusbar, "String ID set to -1 for all display instructions effects"); break; case ID_TRIGGERS_HIDENAMES: scen.remove_trigger_names(); SetWindowText(propdata.statusbar, "Trigger names removed"); break; case ID_TRIGGERS_SAVE_PSEUDONYMS: scen.save_pseudonyms(); SetWindowText(propdata.statusbar, "Pseudonyms saved"); break; case ID_TRIGGERS_HIDE_DESCRIPTIONS: scen.remove_trigger_descriptions(); SetWindowText(propdata.statusbar, "Trigger descriptions removed"); break; case ID_TRIGGERS_SWAP_NAMES_DESCRIPTIONS: scen.swap_trigger_names_descriptions(); SetWindowText(propdata.statusbar, "Trigger names swapped with descriptions"); break; case ID_TRIGGERS_FIXTRIGGEROUTLIERS: scen.fix_trigger_outliers(); SetWindowText(propdata.statusbar, "Triggers outside of map have been put within the boundaries"); break; case ID_FILE_TRIGWRITE: OnFileTrigWrite(sheet); break; case ID_FILE_TRIGREAD: OnFileTrigRead(sheet); break; case IDC_P_TOUP: scen.hd_to_up(); SetWindowText(propdata.statusbar, "Trigger effects converted from AoHD to UserPatch"); break; case IDC_P_TOHD: scen.up_to_hd(); SetWindowText(propdata.statusbar, "Trigger effects converted from UserPatch to AoHD"); break; case IDC_P_TOAOFE: scen.up_to_aofe(); SetWindowText(propdata.statusbar, "Trigger effects converted from UserPatch to AoFE"); break; case IDC_P_TO1C: scen.up_to_10c(); SetWindowText(propdata.statusbar, "Trigger effects converted from UserPatch to 1.0c"); break; case ID_FILE_RECENT1: case ID_FILE_RECENT2: case ID_FILE_RECENT3: case ID_FILE_RECENT4: FileOpen(sheet, false, id - ID_FILE_RECENT1); break; case IDCANCEL: case IDOK: assert(true); break; case ID_VIEW_STATISTICS: DialogBoxParam(aokts, MAKEINTRESOURCE(IDD_STATS), sheet, StatsDialogProc, 0); break; case ID_VIEW_STAT_BAR: if (GetMenuState(GetMenu(sheet), ID_VIEW_STAT_BAR, MF_BYCOMMAND) & MF_CHECKED) { ShowWindow(propdata.statusbar, SW_HIDE); CheckMenuItem(GetMenu(sheet), ID_VIEW_STAT_BAR, MF_BYCOMMAND); } else { ShowWindow(propdata.statusbar, SW_SHOW); CheckMenuItem(GetMenu(sheet), ID_VIEW_STAT_BAR, MF_BYCOMMAND | MF_CHECKED); } break; case ID_VIEW_MAP: if (GetMenuState(GetMenu(sheet), ID_VIEW_MAP, MF_BYCOMMAND) & MF_CHECKED) { // hide window ShowWindow(propdata.mapview, SW_HIDE); // clear check CheckMenuItem(GetMenu(sheet), ID_VIEW_MAP, MF_BYCOMMAND); } else { ShowWindow(propdata.mapview, SW_SHOW); CheckMenuItem(GetMenu(sheet), ID_VIEW_MAP, MF_BYCOMMAND | MF_CHECKED); } break; case ID_DRAW_TERRAIN: if (GetMenuState(GetMenu(sheet), ID_DRAW_TERRAIN, MF_BYCOMMAND) & MF_CHECKED) { setts.drawterrain = false; // clear check CheckMenuItem(GetMenu(sheet), ID_DRAW_TERRAIN, MF_BYCOMMAND); } else { setts.drawterrain = true; // clear check CheckMenuItem(GetMenu(sheet), ID_DRAW_TERRAIN, MF_BYCOMMAND | MF_CHECKED); } SendMessage(propdata.mapview, MAP_Reset, 0, 0); break; case ID_DRAW_ELEVATION: if (GetMenuState(GetMenu(sheet), ID_DRAW_ELEVATION, MF_BYCOMMAND) & MF_CHECKED) { setts.drawelevation = false; // clear check CheckMenuItem(GetMenu(sheet), ID_DRAW_ELEVATION, MF_BYCOMMAND); } else { setts.drawelevation = true; // clear check CheckMenuItem(GetMenu(sheet), ID_DRAW_ELEVATION, MF_BYCOMMAND | MF_CHECKED); } SendMessage(propdata.mapview, MAP_Reset, 0, 0); break; case ID_EDIT_ALL: if (GetMenuState(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND) & MF_CHECKED) { setts.editall = false; // clear check CheckMenuItem(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND); } else { setts.editall = true; CheckMenuItem(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND | MF_CHECKED); } break; case ID_TOOLS_COMPRESS: OnCompressOrDecompress(sheet, true); break; case ID_TOOLS_DECOMPRESS: OnCompressOrDecompress(sheet, false); break; case ID_TS_HELP: WinHelp(sheet, "ts.hlp", HELP_CONTENTS, 0); break; case ID_TS_APP_ABOUT: DialogBoxParam(aokts, (LPCSTR)IDD_ABOUT, sheet, DefaultDialogProc, 0L); break; default: ret = false; } return ret; }