int item_new_action_cb(Ihandle* item_new) { if (save_check(item_new)) new_file(item_new); return IUP_DEFAULT; }
int item_open_action_cb(Ihandle* item_open) { if (!save_check(item_open)) return IUP_DEFAULT; return select_file(IupGetDialog(item_open), 1); }
int dropfiles_cb(Ihandle* ih, const char* filename) { if (save_check(ih)) open_file(ih, filename); return IUP_DEFAULT; }
int config_recent_cb(Ihandle* ih) { if (save_check(ih)) { char* filename = IupGetAttribute(ih, "TITLE"); open_file(ih, filename); } return IUP_DEFAULT; }
int item_recent_cb(Ihandle* item_recent) { char* filename; if (!save_check(item_recent)) return IUP_DEFAULT; filename = IupGetAttribute(item_recent, "TITLE"); open_file(item_recent, filename); return IUP_DEFAULT; }
int item_exit_action_cb(Ihandle* item_exit) { Ihandle* dlg = IupGetDialog(item_exit); Ihandle* config = (Ihandle*)IupGetAttribute(dlg, "CONFIG"); if (!save_check(item_exit)) return IUP_IGNORE; /* to abort the CLOSE_CB callback */ IupConfigDialogClosed(config, dlg, "MainWindow"); IupConfigSave(config); IupDestroy(config); return IUP_CLOSE; }
int item_paste_action_cb(Ihandle* item_paste) { if (save_check(item_paste)) { Ihandle* canvas = IupGetDialogChild(item_paste, "CANVAS"); imImage* old_image = (imImage*)IupGetAttribute(canvas, "IMAGE"); Ihandle *clipboard = IupClipboard(); imImage* image = IupGetNativeHandleImage(IupGetAttribute(clipboard, "NATIVEIMAGE")); IupDestroy(clipboard); if (!image) { show_error("Invalid Clipboard Data", 1); return IUP_DEFAULT; } /* we are going to support only RGB images with no alpha */ imImageRemoveAlpha(image); if (image->color_space != IM_RGB) { imImage* new_image = imImageCreateBased(image, -1, -1, IM_RGB, -1); imConvertColorSpace(image, new_image); imImageDestroy(image); image = new_image; } /* create OpenGL compatible data */ imImageGetOpenGLData(image, NULL); imImageSetAttribString(image, "FileFormat", "JPEG"); IupSetAttribute(canvas, "DIRTY", "Yes"); IupSetAttribute(canvas, "IMAGE", (char*)image); IupSetAttribute(canvas, "FILENAME", NULL); IupSetAttribute(IupGetDialog(canvas), "TITLE", "Untitled - Simple Paint"); IupUpdate(canvas); if (old_image) imImageDestroy(old_image); } return IUP_DEFAULT; }
int item_exit_action_cb(Ihandle* item_exit) { Ihandle* dlg = IupGetDialog(item_exit); Ihandle* config = (Ihandle*)IupGetAttribute(dlg, "CONFIG"); Ihandle* canvas = IupGetDialogChild(dlg, "CANVAS"); imImage* image = (imImage*)IupGetAttribute(canvas, "IMAGE"); if (!save_check(item_exit)) return IUP_IGNORE; /* to abort the CLOSE_CB callback */ if (image) imImageDestroy(image); IupConfigDialogClosed(config, dlg, "MainWindow"); IupConfigSave(config); IupDestroy(config); return IUP_CLOSE; }
int item_paste_action_cb(Ihandle* item_paste) { if (save_check(item_paste)) { Ihandle* canvas = IupGetDialogChild(item_paste, "CANVAS"); Ihandle *clipboard = IupClipboard(); imImage* image = IupGetNativeHandleImage(IupGetAttribute(clipboard, "NATIVEIMAGE")); IupDestroy(clipboard); if (!image) { show_error("Invalid Clipboard Data", 1); return IUP_DEFAULT; } set_new_image(canvas, image, NULL, 1); /* set dirty */ } return IUP_DEFAULT; }
int item_open_action_cb(Ihandle* item_open) { Ihandle *filedlg; if (!save_check(item_open)) return IUP_DEFAULT; filedlg = IupFileDlg(); IupSetAttribute(filedlg, "DIALOGTYPE", "OPEN"); IupSetAttribute(filedlg, "EXTFILTER", "Text Files|*.txt|All Files|*.*|"); IupSetAttributeHandle(filedlg, "PARENTDIALOG", IupGetDialog(item_open)); IupPopup(filedlg, IUP_CENTERPARENT, IUP_CENTERPARENT); if (IupGetInt(filedlg, "STATUS") != -1) { char* filename = IupGetAttribute(filedlg, "VALUE"); open_file(item_open, filename); } IupDestroy(filedlg); return IUP_DEFAULT; }
int item_new_action_cb(Ihandle* item_new) { if (save_check(item_new)) { Ihandle* canvas = IupGetDialogChild(item_new, "CANVAS"); Ihandle* config = (Ihandle*)IupGetAttribute(canvas, "CONFIG"); int width = IupConfigGetVariableIntDef(config, "NewImage", "Width", 640); int height = IupConfigGetVariableIntDef(config, "NewImage", "Height", 480); if (IupGetParam("New Image", NULL, NULL, "Width: %i[1,]\nHeight: %i[1,]\n", &width, &height, NULL)) { imImage* image = imImageCreate(width, height, IM_RGB, IM_BYTE); IupConfigSetVariableInt(config, "NewImage", "Width", width); IupConfigSetVariableInt(config, "NewImage", "Height", height); new_file(item_new, image); } } return IUP_DEFAULT; }
/* Write a cell to the database. ** There are three possibilities: ** 1. It was a totally new cell which isn't known by ** the database yet. The key is NULL. ** 2. The cell was read from the database and is ** written back now. We have a key. ** 3. The cell was read from the database but we want ** to store it as a different cell (new name). ** We have a key but it belongs to its present name. ** We need a new key to store it as a new cell. ** ** 1. Ask a new key using dmCreateCellkey(). ** We can write it using that key and from that moment ** on it will be like we had read it previously ** (we have written it using its key). ** 2. We can just write it, using its key. ** (as often as we like). ** 3. We need an extra key to store it as a ** different (new) cell. We ask a key using ** dmCreateCellkey(). Then we can write it using ** this key, but our workspace will still be related ** to the old cell. So after this write we have ** to give our new key back (using check_in). */ wrte_cell () { static char *ask_str[3]; /* static for redraw */ char *strsave (); char hulpstr[DM_MAXNAME + 1]; char rem_path[MAXCHAR]; char qstr[100]; char *newcell; int choice; int exist; DM_CELL * save_key; int isnewname; if (rmode) { ptext ("No write, you are in read only mode!"); return; } save_key = NULL; upd_boundb (); if (xltb == xrtb || ybtb == yttb) { ptext ("Don't you ever try to write an empty cell again!"); return; } ask_str[0] = "-cancel-"; if (!ckey && cirname[0] != '\0') { ask_str[1] = "other name"; ask_str[2] = &cirname[0]; ptext ("Under which name do you wanna write this cell?"); } else { ask_str[1] = "new name"; ask_str[2] = cellstr; ptext ("Do you wanna write this cell under a new name?"); } if ((choice = ask ((ckey || cirname[0] != '\0') ? 3 : 2, ask_str, -1)) == 0) { ptext(""); return; } isnewname = 0; if (choice == 1 || (choice == 2 && !ckey)) { if (choice == 1) { if (ask_name ("cellname: ", hulpstr, TRUE) == -1) return; } else { strcpy (hulpstr, ask_str[2]); } isnewname = 1; if(strcmp(hulpstr,"res") == 0 || strcmp(hulpstr,"cap") == 0 || strcmp(hulpstr,"nenh") == 0 || strcmp(hulpstr,"penh") == 0) { sprintf (qstr, "Name '%s' is a nelsis primitive: really use this name?", hulpstr); ptext (qstr); if (ask (2, yes_no, -1) != 0) { sprintf (qstr, "Cell '%s' was NOT written", hulpstr); ptext (qstr); return; } } if ((newcell = strsave (hulpstr)) == NULL) return; if ((exist = (int) dmGetMetaDesignData (EXISTCELL, dmproject, newcell, LAYOUT)) != 0) { if (exist == 1) { /* cell already exists */ sprintf (qstr, "Cell '%s' already exists: wanna overwrite?", newcell); ptext (qstr); if (ask (2, yes_no, -1) != 0) { sprintf (qstr, "Cell '%s' was not written", newcell); ptext (qstr); return; } } else { sprintf (qstr, "Cell '%s' was not written", newcell); ptext (qstr); return; } } /* ** cell does not yet exist */ save_key = ckey; if (!(ckey = dmCheckOut (dmproject, newcell, WORKING, DONTCARE, LAYOUT, UPDATE))) { ckey = save_key; /* undo */ return; } } else { newcell = cellstr; } #ifndef ANNOTATE if (!(outp_boxfl (ckey) && outp_mcfl (ckey) && outp_term (ckey) && outp_bbox (ckey))) { #else if (!(outp_boxfl (ckey) && outp_mcfl (ckey) && outp_term (ckey) && outp_bbox (ckey) && outp_comment (ckey))) { #endif /* ** Files were not written properly so if a new key ** was obtained to write under a new name, it must ** be checked in using the quit mode. */ if (checked == TRUE) { #ifdef NELSIS_REL4 sprintf (rem_path, "%s/chk_mod.ck", dmproject -> DMPath); #else sprintf (rem_path, "%s/chk_mod.ck", dmproject -> dmpath); #endif unlink (rem_path); checked = FALSE; } if (choice == 1) { dmCheckIn (ckey, QUIT); ckey = save_key; } return; } if (isnewname) { if (save_key != NULL) { /* ** Write existing cell under new name: ** case 3 (see comments above). */ /* PATRICK: now the cell which is being edited is using the last saved name */ if (dmCheckIn (ckey, CONTINUE) == -1) { ptext ("Not accepted! (recursive)"); dmCheckIn (ckey, QUIT); ckey = NULL; return; } if (dmCheckIn (save_key, QUIT) == -1) { ptext ("Not accepted! (recursive)"); save_key = NULL; return; } cellstr = newcell; } else { /* ** Write a totally new cell, hold key: ** case 1 (see comments above). */ if (dmCheckIn (ckey, CONTINUE) == -1) { ptext ("Not accepted! (recursive)"); dmCheckIn (ckey, QUIT); ckey = NULL; return; } ASSERT (cellstr == NULL); cellstr = newcell; } save_check (newcell); } else { /* ** Write existing cell, hold key. */ if (dmCheckIn (ckey, CONTINUE) == -1) ptext ("Not checked in! This should never happen!"); save_check (cellstr); } sprintf (qstr, "Cell '%s' written", newcell); ptext (qstr); dirty = FALSE; } static save_check (cell_name) char *cell_name; { char check_path[MAXCHAR]; char new_path[MAXCHAR]; if (checked == TRUE) { #ifdef NELSIS_REL4 sprintf (check_path, "%s/chk_mod.ck", dmproject -> DMPath); sprintf (new_path, "%s/%s.ck", dmproject -> DMPath, cell_name); #else sprintf (check_path, "%s/chk_mod.ck", dmproject -> dmpath); sprintf (new_path, "%s/%s.ck", dmproject -> dmpath, cell_name); #endif link (check_path, new_path); unlink (check_path); checked = FALSE; } } static DM_STREAM * dm_boxfp; static DM_STREAM * dm_norfp; /* PATRICK: added key as argument instead of global to write routines */ outp_boxfl (key) DM_CELL *key; { int store (); struct obj_node *window; register int lay; if (!(dm_boxfp = dmOpenStream (key, "box", "w"))) { return (FALSE); } if (!(dm_norfp = dmOpenStream (key, "nor", "w"))) { return (FALSE); } gbox.dx = 0L; gbox.dy = 0L; gbox.nx = 0L; gbox.ny = 0L; /* ** We store all trapezoids as polygons ** with either 3 or 4 corner points. */ gnor_ini.elmt = POLY_NOR; gnor_ini.dx = 0L; gnor_ini.dy = 0L; gnor_ini.nx = 0L; gnor_ini.ny = 0L; MALLOC (window, struct obj_node); for (lay = 0; lay < NR_lay; ++lay) { gbox.layer_no = lay; gnor_ini.layer_no = lay; window -> ll_x1 = quad_root[lay] -> quadrant[0] - 1; window -> ll_y1 = quad_root[lay] -> quadrant[1] - 1; window -> ll_x2 = quad_root[lay] -> quadrant[2] + 1; window -> ll_y2 = quad_root[lay] -> quadrant[3] + 1; quad_search (quad_root[lay], window, store); } FREE (window); dmCloseStream (dm_boxfp, COMPLETE); dmCloseStream (dm_norfp, COMPLETE); return (TRUE); } outp_mcfl (key) DM_CELL *key; { DM_STREAM * dmfp; register INST * ip; Coor bxl, bxr, byb, byt; if (!(dmfp = dmOpenStream (key, "mc", "w"))) { return (FALSE); } for (ip = inst_root; ip; ip = ip -> next) { inst_window (ip, &bxl, &bxr, &byb, &byt); gmc.bxl = (long) bxl / QUAD_LAMBDA; gmc.bxr = (long) bxr / QUAD_LAMBDA; gmc.byb = (long) byb / QUAD_LAMBDA; gmc.byt = (long) byt / QUAD_LAMBDA; if (strlen (ip -> inst_name) == 0) strcpy (gmc.inst_name, "."); else strcpy (gmc.inst_name, ip -> inst_name); strcpy (gmc.cell_name, ip -> templ -> cell_name); gmc.imported = ip -> imported; gmc.mtx[0] = (long) ip -> tr[0]; gmc.mtx[1] = (long) ip -> tr[1]; gmc.mtx[2] = (long) ip -> tr[2] / QUAD_LAMBDA; gmc.mtx[3] = (long) ip -> tr[3]; gmc.mtx[4] = (long) ip -> tr[4]; gmc.mtx[5] = (long) ip -> tr[5] / QUAD_LAMBDA; gmc.nx = (long) ip -> nx; gmc.dx = (long) ip -> dx / QUAD_LAMBDA; gmc.ny = (long) ip -> ny; gmc.dy = (long) ip -> dy / QUAD_LAMBDA; dmPutDesignData (dmfp, GEO_MC); } dmCloseStream (dmfp, COMPLETE); return (TRUE); } outp_term (key) DM_CELL *key; { DM_STREAM * dmfp; register int i; register TERM * tp; Coor bxl, bxr, byb, byt; if (!(dmfp = dmOpenStream (key, "term", "w"))) { return (FALSE); } for (i = 0; i < NR_lay; ++i) { gterm.layer_no = i; for (tp = term[i]; tp; tp = tp -> nxttm) { gterm.xl = (long) tp -> xl / QUAD_LAMBDA; gterm.xr = (long) tp -> xr / QUAD_LAMBDA; gterm.yb = (long) tp -> yb / QUAD_LAMBDA; gterm.yt = (long) tp -> yt / QUAD_LAMBDA; strcpy (gterm.term_name, tp -> tmname); gterm.nx = (long) tp -> nx; gterm.dx = (long) tp -> dx / QUAD_LAMBDA; gterm.ny = (long) tp -> ny; gterm.dy = (long) tp -> dy / QUAD_LAMBDA; term_win (tp, &bxl, &bxr, &byb, &byt); gterm.bxl = (long) bxl / QUAD_LAMBDA; gterm.bxr = (long) bxr / QUAD_LAMBDA; gterm.byb = (long) byb / QUAD_LAMBDA; gterm.byt = (long) byt / QUAD_LAMBDA; dmPutDesignData (dmfp, GEO_TERM); } } dmCloseStream (dmfp, COMPLETE); return (TRUE); } outp_bbox (key) DM_CELL *key; { DM_STREAM * dmfp; if (!(dmfp = dmOpenStream (key, "info", "w"))) { return (FALSE); } ginfo.bxl = (long) xltb / QUAD_LAMBDA; ginfo.bxr = (long) xrtb / QUAD_LAMBDA; ginfo.byb = (long) ybtb / QUAD_LAMBDA; ginfo.byt = (long) yttb / QUAD_LAMBDA; dmPutDesignData (dmfp, GEO_INFO); ginfo.bxl = (long) xlmb / QUAD_LAMBDA; ginfo.bxr = (long) xrmb / QUAD_LAMBDA; ginfo.byb = (long) ybmb / QUAD_LAMBDA; ginfo.byt = (long) ytmb / QUAD_LAMBDA; dmPutDesignData (dmfp, GEO_INFO); ginfo.bxl = (long) xlbb / QUAD_LAMBDA; ginfo.bxr = (long) xrbb / QUAD_LAMBDA; ginfo.byb = (long) ybbb / QUAD_LAMBDA; ginfo.byt = (long) ytbb / QUAD_LAMBDA; dmPutDesignData (dmfp, GEO_INFO); /* * patrick: put one more info: the total bounding box WITHOUT * the image */ if(ImageMode == TRUE && xlim != xrim && ybim != ytim) { ginfo.bxl = (long) xlim / QUAD_LAMBDA; ginfo.bxr = (long) xrim / QUAD_LAMBDA; ginfo.byb = (long) ybim / QUAD_LAMBDA; ginfo.byt = (long) ytim / QUAD_LAMBDA; dmPutDesignData (dmfp, GEO_INFO); } dmCloseStream (dmfp, COMPLETE); return (TRUE); } /* ** Store trapezoid p in the data base. ** INPUT: pointer to trapezoid p. */ store (p) struct obj_node *p; { Coor line[8]; int i; if (!p -> leftside && !p -> rightside) { /* ** this is a rectangle */ if (!(p -> ll_x1 % QUAD_LAMBDA || p -> ll_y1 % QUAD_LAMBDA || p -> ll_x2 % QUAD_LAMBDA || p -> ll_y2 % QUAD_LAMBDA)) { gbox.xl = (long) p -> ll_x1 / QUAD_LAMBDA; gbox.xr = (long) p -> ll_x2 / QUAD_LAMBDA; gbox.yb = (long) p -> ll_y1 / QUAD_LAMBDA; gbox.yt = (long) p -> ll_y2 / QUAD_LAMBDA; gbox.bxl = gbox.xl; gbox.bxr = gbox.xr; gbox.byb = gbox.yb; gbox.byt = gbox.yt; dmPutDesignData (dm_boxfp, GEO_BOX); return; } } line[0] = p -> ll_x1; line[1] = p -> ll_y1; line[2] = p -> ll_x2; line[3] = p -> ll_y2; while (line[0] % QUAD_LAMBDA) --line[0]; while (line[1] % QUAD_LAMBDA) --line[1]; while (line[2] % QUAD_LAMBDA) ++line[2]; while (line[3] % QUAD_LAMBDA) ++line[3]; gnor_ini.bxl = (long) line[0] / QUAD_LAMBDA; gnor_ini.byb = (long) line[1] / QUAD_LAMBDA; gnor_ini.bxr = (long) line[2] / QUAD_LAMBDA; gnor_ini.byt = (long) line[3] / QUAD_LAMBDA; gnor_ini.r_bxl = gnor_ini.bxl; gnor_ini.r_byb = gnor_ini.byb; gnor_ini.r_bxr = gnor_ini.bxr; gnor_ini.r_byt = gnor_ini.byt; /* ** Convert trapezoid to polygon. */ if (trap_to_poly (line, p) == -1) { ptext ("Illegal trapezoid!"); return; } if (line[0] == line[2] || line[4] == line[6]) { /* ** trapezoid is a triangle */ gnor_ini.no_xy = 3; if (line[0] == line[2]) { /* ** First two points are identical. ** Eliminate second point and shift others back. */ line[2] = line[4]; line[3] = line[5]; line[4] = line[6]; line[5] = line[7]; } } else { gnor_ini.no_xy = 4; } dmPutDesignData (dm_norfp, GEO_NOR_INI); /* ** Store xy-pairs of polygon. */ for (i = 0; i < (2 * (int) gnor_ini.no_xy); i = i + 2) { gnor_xy.x = (double) line[i] / (double) QUAD_LAMBDA; gnor_xy.y = (double) line[i + 1] / (double) QUAD_LAMBDA; dmPutDesignData (dm_norfp, GEO_NOR_XY); } }
static void save_record_up(RDArsrc *mtnrsrc,mtnstruct *mtn) { save_check(mtnrsrc,mtn,TRUE); }
static void save_record_nup(RDArsrc *mtnrsrc,RDATData *previous) { save_check(mtnrsrc,FALSE,previous); }
static void save_record_nup(RDArsrc *mtnrsrc,RDATData *previous) { readscreen(mtnrsrc,previous); save_check(mtnrsrc,previous,FALSE); }
Boolean handle_menu (short item, HMENU menu) { short i; Boolean to_return = FALSE; short item_hit; Boolean need_redraw = FALSE; item_hit = item; switch (item) { case -1: break; case 1: // open load_scenario(); if (overall_mode == 60) { update_item_menu(); set_up_main_screen(); } break; case 2: // save modify_lists(); save_scenario(); break; case 3: // new scen build_scenario(); if (overall_mode == 60) set_up_main_screen(); break; case 5: // quit if (save_check(869) == FALSE) break; discard_graphics(); PostQuitMessage(0); break; // Scenario Menu case 101: if (change_made == TRUE) { give_error("You need to save the changes made to your scenario before you can add a new town.", "",0); return to_return; } if (scenario.num_towns >= 200) { give_error("You have reached the limit of 200 towns you can have in one scenario.", "",0); return to_return; } if (new_town(scenario.num_towns) == TRUE) set_up_main_screen(); break; case 103: edit_scen_details(); break; case 104: edit_scen_intro(); break; case 105: set_starting_loc(); break; case 106: overall_mode = 47; set_string("Select party starting location.",""); break; case 109: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_special_editing(0,0); break; case 110: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_string_editing(0,0); break; case 111: if (change_made == TRUE) { give_error("You need to save the changes made to your scenario before you can add a new town.", "",0); return to_return; } i = pick_import_town(841,0); if (i >= 0) { import_town(i); change_made = TRUE; redraw_screen(); } break; case 112: edit_save_rects(); break; case 113: edit_horses(); break; case 114: edit_boats(); break; case 115: edit_add_town(); break; case 116: edit_scenario_events(); break; case 117: edit_item_placement(); break; case 118: if (change_made == TRUE) { give_error("You need to save the changes made to your scenario before you can delete a town.", "",0); return to_return; } if (scenario.num_towns == 1) { give_error("You can't delete the last town in a scenario. All scenarios must have at least 1 town.", "",0); return to_return; } if (scenario.num_towns - 1 == cur_town) { give_error("You can't delete the last town in a scenario while you're working on it. Load a different town, and try this again.", "",0); return to_return; } if (scenario.num_towns - 1 == scenario.which_town_start) { give_error("You can't delete the last town in a scenario while it's the town the party starts the scenario in. Change the parties starting point and try this again.", "",0); return to_return; } if (fancy_choice_dialog(865,0) == 1) delete_last_town(); break; case 119: if (fancy_choice_dialog(866,0) == 1) { last_file_printed = 0; start_data_dump(); } break; case 120: if (change_made == TRUE) { give_error("You need to save the changes made to your scenario before you can print the file Scenario Text.", "",0); return to_return; } if (fancy_choice_dialog(871,0) == 1) { last_file_printed = 1; scen_text_dump(); redraw_screen(); } break; case 121: if (fancy_choice_dialog(867,0) == 1) { last_file_printed = 2; start_shopping_data_dump(); } break; case 122: if (fancy_choice_dialog(868,0) == 1) { last_file_printed = 3; start_monst_data_dump(); } break; case 123: if (fancy_choice_dialog(890,0) == 1) { last_file_printed = 4; start_spec_data_dump(); } break; case 124: if (fancy_choice_dialog(878,0) == 1) { last_file_printed = 7; object_scenario_data_dump(); } break; // Town Menu case 201: edit_town_details(); break; case 202: edit_town_wand(); break; case 203: overall_mode = 9; mode_count = 2; set_cursor(5); set_string("Set town boundary","Select upper left corner"); break; case 204: frill_up_terrain(); break; case 205: unfrill_terrain(); break; case 206: edit_town_strs(); break; case 208: if (fancy_choice_dialog(863,0) == 2) // add random break; place_items_in_town(); break; case 209: for (i = 0; i < 64; i++) // set not prop town.preset_items[i].property = 0; fancy_choice_dialog(861,0); draw_terrain(); break; case 210: if (fancy_choice_dialog(862,0) == 2) // clear all items break; for (i = 0; i < 64; i++) town.preset_items[i].item_code = -1; draw_terrain(); break; case 213: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_special_editing(2,0); break; case 214: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_string_editing(2,0); break; case 215: edit_advanced_town(); break; case 216: edit_town_events(); break; case 217: if (fancy_choice_dialog(872,0) == 2) // clear all monsters break; for (i = 0; i < 60; i++) { t_d.creatures[i].number = 0; t_d.creatures[i].start_loc.x = 0; t_d.creatures[i].start_loc.y = 0; t_d.creatures[i].spec_enc_code = 0; t_d.creatures[i].time_flag = 0; t_d.creatures[i].spec1 = -1; t_d.creatures[i].spec2 = -1; } break; case 218: if (fancy_choice_dialog(873,0) == 2) // clear all special encounters break; for (i = 0; i < 50; i++) { town.special_locs[i].x = 100; town.special_locs[i].y = 0; town.spec_id[i] = 255; } break; case 219: if (fancy_choice_dialog(874,0) == 2) // clear all fields break; for (i = 0; i < 50; i++) if ((town.preset_fields[i].field_type >= 0) && (town.preset_fields[i].field_type < 9)) { town.preset_fields[i].field_type = 0; town.preset_fields[i].field_loc.x = 0; town.preset_fields[i].field_loc.y = 0; } break; case 220: if (fancy_choice_dialog(876,0) == 2) // clear all stains break; for (i = 0; i < 50; i++) if ((town.preset_fields[i].field_type > 13) && (town.preset_fields[i].field_type < 22)) { town.preset_fields[i].field_type = 0; town.preset_fields[i].field_loc.x = 0; town.preset_fields[i].field_loc.y = 0; } break; case 221: if (fancy_choice_dialog(877,0) == 1) { // make concise town report last_file_printed = 5; start_town_data_dump(); } break; case 222: start_dialogue_editing(0); break; // Outdoor Menu case 301: outdoor_details(); break; case 302: edit_out_wand(0); break; case 303: edit_out_wand(1); break; case 304: frill_up_terrain(); break; case 305: unfrill_terrain(); break; case 306: edit_out_strs(); break; case 307: if (fancy_choice_dialog(875,0) == 2) // clear all special encounters break; for (i = 0; i < 18; i++) { current_terrain.special_locs[i].x = 100; current_terrain.special_locs[i].y = 0; current_terrain.special_id[i] = 255; } case 311: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_special_editing(1,0); break; case 312: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_string_editing(1,0); break; break; case 313: if (fancy_choice_dialog(879,0) == 1) { last_file_printed = 6; start_outdoor_data_dump(); } break; case 401: start_town_edit(); break; case 402: start_out_edit(); break; case 403: short x, y; location spot_hit; if (editing_town == false) { if (change_made == TRUE) { if (save_check(859) == FALSE) break; } x = pick_out(cur_out); if (x >= 0) { spot_hit.x = x / 100; spot_hit.y = x % 100; load_outdoors(spot_hit,0); augment_terrain(spot_hit); start_out_edit(); } } else { if (change_made == TRUE) { if (save_check(859) == FALSE) break; } x = pick_town_num(855,cur_town); if (x >= 0) { load_town(x); start_town_edit(); } } break; case 404: set_up_main_screen(); start_terrain_editing(); break; case 405: set_up_main_screen(); start_monster_editing(0); break; case 406: start_item_editing(0); break; case 407: set_up_main_screen(); break; case 408: // switch view cur_viewing_mode = 1 - cur_viewing_mode; need_redraw = TRUE; draw_main_screen(); draw_terrain(); break; case 409: // load previous town/outdoor zone if (editing_town == true) { if (cur_town == 0) load_town(scenario.num_towns - 1); else load_town(cur_town - 1); start_town_edit(); } else { if (cur_out.x > 0) { x = cur_out.x - 1; y = cur_out.y; } if ((cur_out.x == 0) && (cur_out.y > 0)) { x = scenario.out_width - 1; y = cur_out.y - 1; } if ((cur_out.x == 0) && (cur_out.y == 0)) { x = scenario.out_width - 1; y = scenario.out_height - 1; } spot_hit.x = x; spot_hit.y = y; load_outdoors(spot_hit,0); augment_terrain(spot_hit); start_out_edit(); } break; case 410: // load next town/outdoor zone if (editing_town == true) { if (cur_town + 1 == scenario.num_towns) load_town(0); else load_town(cur_town + 1); start_town_edit(); } else { if ((cur_out.x < (scenario.out_width - 1)) && (cur_out.y <= (scenario.out_height - 1))) { x = cur_out.x + 1; y = cur_out.y; } if ((cur_out.x == (scenario.out_width - 1)) && (cur_out.y < (scenario.out_height - 1))) { x = 0; y = cur_out.y + 1; } if ((cur_out.x == (scenario.out_width - 1)) && (cur_out.y == (scenario.out_height - 1))) { x = 0; y = 0; } spot_hit.x = x; spot_hit.y = y; load_outdoors(spot_hit,0); augment_terrain(spot_hit); start_out_edit(); } break; case 411: // MENUITEM "Terrain Animations Play", 411 HMENU menu,big_menu; big_menu = GetMenu(mainPtr); menu = GetSubMenu(big_menu,4); if(play_anim == FALSE){ play_anim = TRUE; CheckMenuItem(menu,411,MF_BYCOMMAND | MF_CHECKED); } else{ play_anim = FALSE; CheckMenuItem(menu,411,MF_BYCOMMAND | MF_UNCHECKED); } break; case 412: // load outdoor zone above if (editing_town) break; if (cur_out.y > 0) { x = cur_out.x; y = cur_out.y - 1; } else { x = cur_out.x; y = scenario.out_height - 1; } spot_hit.x = x; spot_hit.y = y; load_outdoors(spot_hit,0); augment_terrain(spot_hit); start_out_edit(); break; case 413: // load outdoor zone below if (editing_town) break; if (cur_out.y == scenario.out_height - 1) { x = cur_out.x; y = 0; } else { x = cur_out.x; y = cur_out.y + 1; } spot_hit.x = x; spot_hit.y = y; load_outdoors(spot_hit,0); augment_terrain(spot_hit); start_out_edit(); break; case 414: // Repeat print of last file printed switch (last_file_printed){ case 0: start_data_dump(); break; case 1: scen_text_dump(); break; case 2: start_shopping_data_dump(); break; case 3: start_monst_data_dump(); break; case 4: start_spec_data_dump(); break; case 5: start_town_data_dump(); break; case 6: start_outdoor_data_dump(); break; case 7: object_scenario_data_dump(); break; } break; // Extra Help case 801: // help file WinHelp(mainPtr,"Scenario Editor.hlp",HELP_CONTENTS,0L); break; case 802: fancy_choice_dialog(986,0); break; // started case 803: fancy_choice_dialog(1000,0); break; // testing case 804: fancy_choice_dialog(1001,0); break; // distributing case 805: fancy_choice_dialog(1062,0); break; default: if ((overall_mode >= 60) || (editing_town == FALSE)) { give_error("You can only place items and individual monsters in town sections, not outdoors.","",0); break; } if ((item_hit >= 600) && (item_hit < 1000)) { item_hit -= 600; if (scen_item_list.scen_items[item_hit].variety == 0) { give_error("This item has its Variety set to No Item. You can only place items with a Variety set to an actual item type.","",0); return to_return; } overall_mode = 4; set_string("Place the item.","Select item location"); mode_count = item_hit; } // skip the type 0 monster, it is non-existent if ((item_hit >= 1001) && (item_hit <= 1255)) { // 1,255? overall_mode = 28; item_hit -= 1000; set_string("Place the monster.","Select monster location"); mode_count = item_hit; } /* if ((item_hit >= 1256) && (item_hit <= 1455)) { item_hit -= 1256; mode_count = item_hit; load_town(item_hit); start_town_edit(); // set_string("Loading the indicated town."," "); } */ break; } if ((item >= 100) && (item < 200) && (item != 118) && (item != 119)) change_made = TRUE; return to_return; }
static void save_record_quit(RDArsrc *mtnrsrc,mtnstruct *mtn) { save_check(mtnrsrc,mtn,FALSE); }
static void save_record_quit(RDArsrc *mtnrsrc,RDATData *previous) { save_check(mtnrsrc,TRUE,previous); }
static void save_record_nup(RDArsrc *mtnrsrc,mtnstruct *mtn) { readscreen(mtnrsrc,mtn); save_check(mtnrsrc,mtn,FALSE); }