void g1_net_window_class::receive_event(i4_event * ev) { if (ev->type()==i4_event::OBJECT_MESSAGE) { CAST_PTR(oev, i4_object_message_event_class, ev); if (oev->object==this) { if (oev->sub_type==(w32)poll_id) { poll(); i4_object_message_event_class poll(this, poll_id); poll_event_id=i4_time_dev.request_event(this, &poll, poll_delay); } else { object_message(oev->sub_type); } } else { object_message(-1); i4_parent_window_class::receive_event(ev); } } else { i4_parent_window_class::receive_event(ev); } }
/* fs_dlist_proc: * Dialog procedure for the file selector disk list. */ int fs_dlist_proc(int msg, DIALOG *d, int c) { DIALOG *parent = (DIALOG *)d->dp3; char *s = (char *)parent[FS_EDIT].dp; int ret, i, temp; if(msg == MSG_START) { d->d1 = d->d2 = 0; temp = utoupper(ugetc(s)); if(((temp >= 'A') && (temp <= 'Z')) && (ugetat(s, 1) == DEVICE_SEPARATOR)) { temp -= 'A'; for(i=0; i<temp; i++) if(_al_drive_exists(i)) d->d1++; } } ret = jwin_droplist_proc(msg, d, c); if(ret & D_CLOSE) { temp = 'A' + get_x_drive(d->d1+1); if((temp < 'A') || (temp > 'Z')) temp = 'C'; s += usetc(s, temp); s += usetc(s, DEVICE_SEPARATOR); s += usetc(s, OTHER_PATH_SEPARATOR); usetc(s, 0); object_message(parent +FS_FILES, MSG_START, 0); object_message(parent +FS_FILES, MSG_DRAW, 0); object_message(parent +FS_EDIT, MSG_START, 0); object_message(parent +FS_EDIT, MSG_DRAW, 0); return ret - D_CLOSE + D_O_K; } return ret; }
static int quality_cb(void *dp3, int d2) { (void)dp3; settings_dialog[QUALITY_TEXT].d1 = d2 + 1; object_message(&settings_dialog[QUALITY_TEXT], MSG_DRAW, 0); return D_O_K; }
// Allegro doesn't offer an easy way for two DIALOGs in the same place // both to handle only a subset of mouse input... void forwardMouseWheel(DIALOG* d, int c) { for(DIALOG* d2=d; d2->proc; d2++) { if((d2->flags&D_WANTWHEEL)!=0 && dialogUnderMouse(d2)) { object_message(d2, MSG_WHEEL, c); break; } } }
int d_abitmap_push_proc (int msg, DIALOG *d, int c) { int ret = D_O_K; d->flags |= D_EXIT; ret |= d_abitmap_button_proc (msg, d, c); if (ret & D_CLOSE) { ret &= ~D_CLOSE; scare_mouse_area (d->x, d->y, d->x + d->w, d->y + d->h); object_message (d, MSG_DRAW, 0); unscare_mouse (); if (d->dp3) ret |= ((int (*)(DIALOG *)) d->dp3) (d); } return ret; }
static int preview_proc(int msg, DIALOG *d, int c) { BITMAP *bmp; static int quality = 75, flags = JPG_SAMPLING_444; int new_quality, new_flags = 0; int size; (void)c; new_quality = settings_dialog[QUALITY_SLIDER].d2 + 1; if (settings_dialog[SS_444_RADIO].flags & D_SELECTED) new_flags = JPG_SAMPLING_444; if (settings_dialog[SS_422_RADIO].flags & D_SELECTED) new_flags = JPG_SAMPLING_422; if (settings_dialog[SS_411_RADIO].flags & D_SELECTED) new_flags = JPG_SAMPLING_411; if (settings_dialog[GREYSCALE_CHECK].flags & D_SELECTED) new_flags |= JPG_GREYSCALE; if (settings_dialog[OPTIMIZE_CHECK].flags & D_SELECTED) new_flags |= JPG_OPTIMIZE; switch (msg) { case MSG_START: d->dp2 = (void *)create_bitmap(d->w, d->h); bmp = (BITMAP *)d->dp; d->dp3 = malloc(ESTIMATED_MAX_JPG_SIZE(bmp)); clear_to_color((BITMAP *)d->dp2, gui_mg_color); d->d2 = 20; sprintf(size_string, "Size: ?"); break; case MSG_END: destroy_bitmap((BITMAP *)d->dp2); free(d->dp3); break; case MSG_DRAW: clear_to_color((BITMAP *)d->dp2, gui_mg_color); bmp = (BITMAP *)d->dp; bmp = create_sub_bitmap(bmp, MAX(0, (bmp->w - d->w) / 2), MAX(0, (bmp->h - d->h) / 2), d->w, d->h); if (!bmp) goto preview_error; size = ESTIMATED_MAX_JPG_SIZE(bmp); if (save_memory_jpg_ex(d->dp3, &size, bmp, NULL, quality, flags, NULL)) goto preview_error; size = ESTIMATED_MAX_JPG_SIZE(bmp); destroy_bitmap(bmp); bmp = load_memory_jpg(d->dp3, size, NULL); if (!bmp) goto preview_error; blit(bmp, (BITMAP *)d->dp2, 0, 0, 0, 0, bmp->w, bmp->h); rect(screen, d->x - 1, d->y - 1, d->x + d->w, d->y + d->h, gui_fg_color); blit((BITMAP *)d->dp2, screen, 0, 0, d->x, d->y, d->w, d->h); destroy_bitmap(bmp); object_message(&settings_dialog[QUALITY_TEXT], MSG_DRAW, 0); break; case MSG_IDLE: if (d->d2 > 0) { d->d2--; if (d->d2 == 0) { quality = new_quality; flags = new_flags; bmp = (BITMAP *)d->dp; size = ESTIMATED_MAX_JPG_SIZE(bmp); if (save_memory_jpg_ex(d->dp3, &size, bmp, NULL, quality, flags, NULL)) goto preview_error; sprintf(size_string, "Size: %dx%d, %.1f Kbytes ", bmp->w, bmp->h, (double)size / 1024.0); object_message(&settings_dialog[SIZE_TEXT], MSG_DRAW, 0); return D_REDRAWME; } } if ((new_quality != quality) || (new_flags != flags)) { quality = new_quality; flags = new_flags; d->d2 = 20; if (flags & JPG_GREYSCALE) { settings_dialog[SS_444_RADIO].flags |= D_DISABLED; settings_dialog[SS_422_RADIO].flags |= D_DISABLED; settings_dialog[SS_411_RADIO].flags |= D_DISABLED; } else { settings_dialog[SS_444_RADIO].flags &= ~D_DISABLED; settings_dialog[SS_422_RADIO].flags &= ~D_DISABLED; settings_dialog[SS_411_RADIO].flags &= ~D_DISABLED; } settings_dialog[SS_444_RADIO].fg = (flags & JPG_GREYSCALE ? gui_mg_color : gui_fg_color); settings_dialog[SS_422_RADIO].fg = (flags & JPG_GREYSCALE ? gui_mg_color : gui_fg_color); settings_dialog[SS_411_RADIO].fg = (flags & JPG_GREYSCALE ? gui_mg_color : gui_fg_color); object_message(&settings_dialog[SS_444_RADIO], MSG_DRAW, 0); object_message(&settings_dialog[SS_422_RADIO], MSG_DRAW, 0); object_message(&settings_dialog[SS_411_RADIO], MSG_DRAW, 0); return D_REDRAWME; } break; } return D_O_K; preview_error: line((BITMAP *)d->dp2, 0, 0, d->w - 1, d->h - 1, 0); line((BITMAP *)d->dp2, d->w - 1, 0, 0, d->h - 1, 0); blit((BITMAP *)d->dp2, screen, 0, 0, d->x, d->y, d->w, d->h); return D_O_K; }
/* fs_flist_proc: * Dialog procedure for the file selector list. */ static int fs_flist_proc(int msg, DIALOG *d, int c) { static int recurse_flag = 0; char *s = (char *) file_selector[FS_EDIT].dp; char tmp[32]; /* of s (in bytes) */ int size = (file_selector[FS_EDIT].d1 + 1) * uwidth_max(U_CURRENT); int sel = d->d1; int i, ret; int ch, count; if(msg == MSG_START) { if(!flist) { flist = (FLIST *) zc_malloc(sizeof(FLIST)); if(!flist) { *allegro_errno = ENOMEM; return D_CLOSE; } } else { for(i=0; i<flist->size; i++) if(flist->name[i]) zc_free(flist->name[i]); } flist->size = 0; replace_filename(flist->dir, s, uconvert_ascii("*.*", tmp), sizeof(flist->dir)); /* The semantics of the attributes passed to file_select_ex() is * different from that of for_each_file_ex() in one case: when * the 'd' attribute is not mentioned in the set of characters, * the other attributes are not taken into account for directories, * i.e the directories are all included. So we can't filter with * for_each_file_ex() in that case. */ if(attrb_state[ATTRB_DIREC] == ATTRB_ABSENT) /* accept all dirs */ for_each_file_ex(flist->dir, 0 , FA_LABEL, fs_flist_putter, (void *)1UL /* check */); else /* don't check */ for_each_file_ex(flist->dir, build_attrb_flag(ATTRB_SET), build_attrb_flag(ATTRB_UNSET) | FA_LABEL, fs_flist_putter, (void *)0UL); usetc(get_filename(flist->dir), 0); d->d1 = d->d2 = 0; sel = 0; } if(msg == MSG_END) { if(flist) { for(i=0; i<flist->size; i++) if(flist->name[i]) zc_free(flist->name[i]); zc_free(flist); flist = NULL; } } recurse_flag++; ret = jwin_abclist_proc(msg,d,c); /* call the parent procedure */ recurse_flag--; if(((sel != d->d1) || (ret == D_CLOSE)) && (recurse_flag == 0)) { replace_filename(s, flist->dir, flist->name[d->d1], size); /* check if we want to `cd ..' */ if((!ustrncmp(flist->name[d->d1], uconvert_ascii("..", tmp), 2)) && (ret == D_CLOSE)) { /* let's remember the previous directory */ usetc(updir, 0); i = ustrlen(flist->dir); count = 0; while(i>0) { ch = ugetat(flist->dir, i); if((ch == '/') || (ch == OTHER_PATH_SEPARATOR)) { if(++count == 2) break; } uinsert(updir, 0, ch); i--; } /* ok, we have the dirname in updir */ } else { usetc(updir, 0); } object_message(file_selector+FS_EDIT, MSG_START, 0); object_message(file_selector+FS_EDIT, MSG_DRAW, 0); if(ret == D_CLOSE) return object_message(file_selector+FS_EDIT, MSG_KEY, 0); } return ret; }
/* fs_edit_proc: * Dialog procedure for the file selector editable string. */ static int fs_edit_proc(int msg, DIALOG *d, int c) { char *s = (char *) d->dp; int size = (d->d1 + 1) * uwidth_max(U_CURRENT); /* of s (in bytes) */ int list_size; int found = 0; char b[1024], tmp[16]; int ch, attr; int i; if(msg == MSG_START) { canonicalize_filename(b, s, sizeof(b)); ustrzcpy(s, size, b); } if(msg == MSG_KEY) { if((!ugetc(s)) || (ugetat(s, -1) == DEVICE_SEPARATOR)) ustrzcat(s, size, uconvert_ascii("./", tmp)); canonicalize_filename(b, s, sizeof(b)); ustrzcpy(s, size - ucwidth(OTHER_PATH_SEPARATOR), b); ch = ugetat(s, -1); if((ch != '/') && (ch != OTHER_PATH_SEPARATOR)) { if(file_exists(s, FA_RDONLY | FA_HIDDEN | FA_DIREC, &attr)) { if(attr & FA_DIREC) put_backslash(s); else return D_CLOSE; } else return D_CLOSE; } object_message(file_selector+FS_FILES, MSG_START, 0); /* did we `cd ..' ? */ if(ustrlen(updir)) { /* now we have to find a directory name equal to updir */ for(i = 0; i<flist->size; i++) { if(!ustrcmp(updir, flist->name[i])) /* we got it ! */ { file_selector[FS_FILES].d1 = i; /* we have to know the number of visible lines in the filelist */ /* -1 to avoid an off-by-one problem */ list_size = (file_selector[FS_FILES].h-4) / text_height(font) - 1; if(i>list_size) file_selector[FS_FILES].d2 = i-list_size; else file_selector[FS_FILES].d2 = 0; found = 1; break; /* ok, our work is done... */ } } /* by some strange reason, we didn't find the old directory... */ if(!found) { file_selector[FS_FILES].d1 = 0; file_selector[FS_FILES].d2 = 0; } } /* and continue... */ object_message(file_selector+FS_FILES, MSG_DRAW, 0); object_message(d, MSG_START, 0); object_message(d, MSG_DRAW, 0); return D_O_K; } int allegro_lfn = ALLEGRO_LFN; //removes compiler warning if(msg == MSG_UCHAR) { if((c >= 'a') && (c <= 'z')) { if(!allegro_lfn) c = utoupper(c); } else if(c == '/') { c = OTHER_PATH_SEPARATOR; } else if(allegro_lfn) { if((c > 127) || (c < 32)) return D_O_K; } else { if((c != OTHER_PATH_SEPARATOR) && (c != '_') && (c != DEVICE_SEPARATOR) && (c != '.') && ((c < 'A') || (c > 'Z')) && ((c < '0') || (c > '9'))) return D_O_K; } } // return _gui_edit_proc(msg, d, c); return jwin_edit_proc(msg, d, c); }
/* d_editbox_proc: * A text box object. The dp field points to a char * which is the text * to be displayed in the text box. If the text is long, there will be * a vertical scrollbar on the right hand side of the object which can * be used to scroll through the text. The default is to print the text * with word wrapping, but if the D_SELECTED flag is set, the text will * be printed with character wrapping. The d1 field is used internally * to store the number of lines of text, and d2 is used to store how far * it has scrolled through the text. */ int d_editbox_proc(int msg, DIALOG *d, int c) { EditboxModel *model= (EditboxModel *)d->dp; int ret = D_O_K; static clock_t ticks; bool dontredraw=false; switch(msg) { case MSG_START: { model->getSelection().clearSelection(); model->getView()->initialize(model); break; } case MSG_IDLE: { if ((d->flags & D_GOTFOCUS)&&(clock()>ticks)) { d->flags |= D_DIRTY; ticks=clock()+(CLOCKS_PER_SEC/2); model->getCursor().invertVisibility(); } break; } case MSG_DRAW: { model->getView()->draw(); break; } case MSG_WANTFOCUS: { ret = D_WANTFOCUS; break; } case MSG_CHAR: { //handle selecting (bah) switch(c>>8) { case KEY_LEFT: case KEY_RIGHT: case KEY_UP: case KEY_DOWN: case KEY_HOME: case KEY_END: case KEY_PGUP: case KEY_PGDN: if (key[KEY_LSHIFT]||key[KEY_RSHIFT]) { model->getSelection().ensureSelecting(model->getCursor()); } else { model->getSelection().clearSelection(); } } //normal event handling switch(c>>8) { case KEY_LEFT: model->getCursor()--; ret = D_USED_CHAR; break; case KEY_RIGHT: model->getCursor()++; ret = D_USED_CHAR; break; case KEY_UP: model->getView()->lineUp(); ret = D_USED_CHAR; break; case KEY_DOWN: model->getView()->lineDown(); ret = D_USED_CHAR; break; case KEY_HOME: model->getView()->lineHome(); ret = D_USED_CHAR; break; case KEY_END: model->getView()->lineEnd(); ret = D_USED_CHAR; break; case KEY_PGDN: model->getView()->pageDown(); ret = D_USED_CHAR; break; case KEY_PGUP: model->getView()->pageUp(); ret = D_USED_CHAR; break; case KEY_ENTER: case KEY_ENTER_PAD: model->clear(); model->getCursor().insertNewline(); ret = D_USED_CHAR; break; case KEY_TAB: { model->clear(); int ch = Unicode::getCharAtOffset(uconvert_ascii("\t",NULL),0); model->getCursor().insertChar(ch); ret = D_USED_CHAR; break; } case KEY_DEL: case KEY_DEL_PAD: if(model->getSelection().hasSelection()) model->clear(); else model->getCursor().deleteChar(); ret = D_USED_CHAR; break; case KEY_BACKSPACE: if(model->getSelection().hasSelection()) model->clear(); else if(model->getCursor().getPosition() != 0) { model->getCursor()--; model->getCursor().deleteChar(); } ret = D_USED_CHAR; break; case KEY_C: if (key[KEY_LCONTROL]||key[KEY_RCONTROL]) { model->copy(); ret = D_USED_CHAR; break; } ret = D_O_K; break; case KEY_X: if (key[KEY_LCONTROL]||key[KEY_RCONTROL]) { model->cut(); ret = D_USED_CHAR; break; } ret = D_O_K; break; case KEY_V: if(key[KEY_LCONTROL]||key[KEY_RCONTROL]) { model->clear(); model->paste(); ret = D_USED_CHAR; break; } ret = D_O_K; break; case KEY_ESC: return D_EXIT; case KEY_F1: model->doHelp(); ret = D_USED_CHAR; dontredraw=true; break; } //selection post-processing if (key[KEY_LSHIFT]||key[KEY_RSHIFT]) { switch(c>>8) { case KEY_LEFT: case KEY_RIGHT: case KEY_UP: case KEY_DOWN: case KEY_HOME: case KEY_END: case KEY_PGUP: case KEY_PGDN: model->getSelection().adjustSelection(model->getCursor()); } } break; } case MSG_UCHAR: { ret = D_USED_CHAR; if ((c >= ' ') && (uisok(c))) { model->clear(); model->getCursor().insertChar(c); } } break; case MSG_CLICK: { bool redraw = model->getView()->mouseClick(gui_mouse_x(), gui_mouse_y()); if(model->getCursor().isVisible()) model->getCursor().invertVisibility(); if(redraw) { object_message(d, MSG_DRAW, 0); } while(gui_mouse_b()) { if(model->getView()->mouseDrag(gui_mouse_x(), gui_mouse_y())) { scare_mouse(); object_message(d, MSG_DRAW, 0); unscare_mouse(); } } model->getView()->mouseRelease(gui_mouse_x(), gui_mouse_y()); if(!model->getCursor().isVisible()) model->getCursor().invertVisibility(); d->flags |= D_DIRTY; break; } case MSG_WHEEL: { if(c>0) model->getView()->scrollUp(); else model->getView()->scrollDown(); d->flags |= D_DIRTY; break; } } if(ret == D_USED_CHAR && !dontredraw) { //redraw if(!model->getCursor().isVisible()) model->getCursor().invertVisibility(); ticks=clock()+(CLOCKS_PER_SEC/2); model->getView()->ensureCursorOnScreen(); d->flags |= D_DIRTY; } return ret; }
void initialize() { char buf[1024]; int i; // Do the libxml binary compatibility check initXML(); // Initialise Allegro allegro_init(); install_keyboard(); install_mouse(); install_timer(); set_config_file("rpgedit.cfg"); int grph_drv = (get_config_int("video", "fullscreen", 1)) ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED; int screen_w = get_config_int("video", "width", 800); int screen_h = get_config_int("video", "height", 600); if (get_config_int("tile_zoom", "grid", 1)) { showTileGrid = true; } set_color_conversion( (COLORCONV_TOTAL & ~( COLORCONV_32A_TO_8 | COLORCONV_32A_TO_15 | COLORCONV_32A_TO_16 | COLORCONV_32A_TO_24 )) ); int colordepth = 0; if (grph_drv == GFX_AUTODETECT_WINDOWED) { colordepth = desktop_color_depth(); } if (colordepth == 0) { colordepth = 16; } set_color_depth(colordepth); if (set_gfx_mode(grph_drv, screen_w, screen_h, 0, 0) != 0) { set_color_depth(15); if (set_gfx_mode(grph_drv, screen_w, screen_h, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set graphic mode\n%s\n", allegro_error); exit(1); } } buffer = create_bitmap(SCREEN_W, SCREEN_H); // Initialize GUI look and feel stuff agup_init(aphoton_theme); gui_fg_color = agup_fg_color; gui_bg_color = agup_bg_color; gui_shadow_box_proc = d_agup_shadow_box_proc; gui_button_proc = d_agup_button_proc; gui_edit_proc = d_agup_edit_proc; gui_text_list_proc = d_agup_text_list_proc; engine_data = load_datafile("gui.dat"); DATAFILE* font_data = find_datafile_object(engine_data, "SmallFont"); if (font_data) font = (FONT*)font_data->dat; engine_font = font; DATAFILE* mouse_pointer = find_datafile_object(engine_data, "_MS_STD_BMP"); if (mouse_pointer) set_mouse_sprite((BITMAP*)mouse_pointer->dat); DATAFILE* logo = find_datafile_object(engine_data, "MoonlightLogo"); if (logo) about_dlg[1].dp = (BITMAP*)logo->dat; else console.log(CON_QUIT, CON_ALWAYS, "Error loading MoonlightLogo"); console.log(CON_LOG, CON_ALWAYS, "Loading module \"data\"..."); module = new Module("data"); // Lua initialisation console.log(CON_LOG, CON_ALWAYS, "Initialising scripting environment..."); initScripting(); D_AUTOTEXT_STATUS.dp2 = status_message; D_AUTOTEXT_MAPINFO.dp2 = status_mapinfo; set_dialog_color(main_dlg, agup_fg_color, agup_bg_color); set_dialog_color(newmap_dlg, agup_fg_color, agup_bg_color); set_dialog_color(import_tileset_dlg, agup_fg_color, agup_bg_color); set_dialog_color(export_tileset_dlg, agup_fg_color, agup_bg_color); set_dialog_color(resizemap_dlg, agup_fg_color, agup_bg_color); set_dialog_color(about_dlg, agup_fg_color, agup_bg_color); // Position the dialogs on the screen int margin = 6; int zoom_w = get_config_int("tile_zoom", "zoom_width", 120) - 1; int zoom_h = get_config_int("tile_zoom", "zoom_height", 120) - 1; int x, y, w, h; // Main (back + menu) set_dialog_size(&main_dlg[0], -2, -2, SCREEN_W + 4, SCREEN_H + 4); set_dialog_size(&main_dlg[1], 0, 0, SCREEN_W, 15); // Status bars set_dialog_size(&main_dlg[6], 0, SCREEN_H - 17, SCREEN_W - 256, 17); set_dialog_size(&main_dlg[7], SCREEN_W - 256, SCREEN_H - 17, 256, 17); set_dialog_size(&main_dlg[8], 3, SCREEN_H - 14, SCREEN_W - 262, 11); set_dialog_size(&main_dlg[9], SCREEN_W - 253, SCREEN_H - 14, 250, 11); // Edit tile area w = zoom_w + 4; h = zoom_h + 4; x = margin; y = main_dlg[6].y - margin - h; set_dialog_size(&edit_tile_layer[0], x, y, w, h); set_dialog_size(&edit_tile_layer[1], x + 2, y + 2, w - 4, h - 4); set_dialog_size(&edit_tile_layer[2], x + margin + w, y + h - 14, 50, 14); // Color sliders x += w + margin; w = 128; set_dialog_size(&edit_tile_layer[8], x, y, 16, 8); set_dialog_size(&edit_tile_layer[9], x, y + 16, 16, 8); set_dialog_size(&edit_tile_layer[10], x, y + 32, 16, 8); set_dialog_size(&edit_tile_layer[11], x, y + 48 + 8, 16, 8); set_dialog_size(&edit_tile_layer[12], x, y + 64 + 8, 16, 8); set_dialog_size(&edit_tile_layer[3], x + 16, y, w, 8); set_dialog_size(&edit_tile_layer[4], x + 16, y + 16, w, 8); set_dialog_size(&edit_tile_layer[5], x + 16, y + 32, w, 8); set_dialog_size(&edit_tile_layer[6], x + 16, y + 48 + 8, w, 8); set_dialog_size(&edit_tile_layer[7], x + 16, y + 64 + 8, w, 8); set_dialog_size(&edit_tile_layer[13], x + 16 + w + 4, y - 1, 11, 10); set_dialog_size(&edit_tile_layer[14], x + 16 + w + 4, y + 16 - 1, 11, 10); set_dialog_size(&edit_tile_layer[15], x + 16 + w + 4, y + 32 - 1, 11, 10); set_dialog_size(&edit_tile_layer[20], x + 16 + w + 18, y + 4, 18, 32); // Select tile area x = edit_tile_layer[20].x + edit_tile_layer[20].w + margin; w = SCREEN_W - x - margin; set_dialog_size(&edit_tile_layer[16], x, y, 104, h); set_dialog_size(&edit_tile_layer[17], x + 104, y, w - 104, h); set_dialog_size(&edit_tile_layer[18], x + 104 + 2, y + 2, w - 104 - 4 - 11, h - 4); set_dialog_size(&edit_tile_layer[19], x + w - 14, y, 14, h); // Obstacle edit stuff w = 24; h = 24; x = margin; y = main_dlg[6].y - margin - h; for (i = 0; i < 5; i++) { set_dialog_size(&edit_obstacle_layer[i], x + i*(w+margin), y, w, h); set_dialog_size(&edit_obstacle_layer[i+5], x + i*(w+margin) + 2, y + 2, w - 4, h - 4); } // Edit map area x = margin; y = 16 + margin; w = SCREEN_W - 2 * margin; h = edit_obstacle_layer[0].y - margin - y; set_dialog_size(&main_dlg[2], x, y, w, h); set_dialog_size(&main_dlg[3], x + 2, y + 2, w - 15, h - 15); set_dialog_size(&main_dlg[4], x + w - 14, y, 14, h - 11); set_dialog_size(&main_dlg[5], x, y + h - 14, w - 11, 14); set_dialog_size(&main_dlg[10], x + w - 12, y + h - 12, 10, 10); // Edit objects area w = 160; h = 120; x = margin; y = main_dlg[6].y - margin - h; set_dialog_size(&edit_objects_layer[0], x, y, w, h); set_dialog_size(&edit_objects_layer[1], w + margin * 2, main_dlg[6].y - margin - 14, 97, 14); // Initialize map and tile stuff tileRepository = new TileRepository(); // Import tilesets specified in rpgedit.cfg i = 1; while (i > 0) { uszprintf(buf, sizeof buf, "tileset%d", i); const char* filename = get_config_string(buf, "filename", NULL); int tile_w = get_config_int(buf, "tile_w", 16); int tile_h = get_config_int(buf, "tile_h", 16); int tile_spacing = get_config_int(buf, "tile_spacing", 0); if (filename) { if (tile_w > 0 && tile_h > 0 && tile_spacing >= 0) { import_tile_bitmap(filename, tile_w, tile_h, tile_spacing); } else { allegro_message("Error, incorrect parameters for automatic tile import (%s)!", filename); // Print warning in log file } i++; } else { i = -1; } } currentMap = new SquareMap(TILES_W, TILES_H); ustrcpy(map_filename, "untitled.tmx"); // Load map specified in rpgedit.cfg const char* filename = get_config_string("startup", "load_map", NULL); if (filename) { if (!currentMap->loadMap(filename)) { ustrcpy(map_filename, filename); object_message(&D_MAP, MSG_NEW_MAP, 0); set_map_changed(false); } else { console.log(CON_LOG, CON_ALWAYS, "Error while loading default map (%s)!\n", filename); } } update_window_title(); map_edit_mode = EM_TILE; menu_item_edit_objects(); //activate_mode(edit_objects_layer); }