void editor_logic(al_defs *al) { char name[255]; ask_for_level(al, name); if(!check_if_level_exists(name)) { unsigned int x,y; ask_for_dimensions(al, &x, &y); make_blank_level(name, x, y); edit_level(al, name); }else{ edit_or_remove(al, name); } }
void edit_or_remove(al_defs *al, char name[255]) { draw_background(al); al_draw_text(al->menu_font, al_map_rgb(150,150,150), al->width/2, 120, ALLEGRO_ALIGN_CENTRE, "Press E to edit, R to remove"); al_flip_display(); ALLEGRO_EVENT ev; bool quit=false; while(!quit) { al_wait_for_event(al->queue, &ev); if(ev.type==ALLEGRO_EVENT_KEY_DOWN) { switch(ev.keyboard.keycode){ case ALLEGRO_KEY_E: quit=true; edit_level(al, name); break; case ALLEGRO_KEY_R: quit=true; remove_level(name); } } } }
int main(int argc, char **argv) { FILE *faili; int c; printf("\n"); printf(" Lvledit for Triplane Copyright (c) 1996 Dodekaedron Software Creations, Inc."); printf("\n\r\n\r"); if (argc != 2) { printf("Usage: LVLEDIT level_filename\n"); exit(1); } printf("Loading directory structure\n\r"); dksinit("fokker.dks"); strcpy(filename, argv[1]); if ((faili = fopen(filename, "rb")) == NULL) { printf("Creating new level.\n\r"); strcpy(leveldata.pb_name, "MAISDT"); for (c = 0; c < MAX_STRUCTURES; c++) { leveldata.struct_x[c] = 0; leveldata.struct_y[c] = 0; leveldata.struct_hit[c] = 0; leveldata.pd_name[c][0] = 0; leveldata.struct_owner[c] = 4; leveldata.struct_type[c] = 0; } for (c = 0; c < 4; c++) { leveldata.airfield_x[c] = 0; leveldata.airfield_y[c] = 0; leveldata.airfield_lenght[c] = 110; leveldata.plane_direction[c] = 0; } } else { printf("Loading existing level.\n\r"); fread(&leveldata, sizeof(leveldata), 1, faili); fclose(faili); for (c = 0; c < MAX_STRUCTURES; c++) { if (leveldata.struct_x[c]) { struct_picture[c] = new Bitmap(leveldata.pd_name[c]); struct_picture[c]->info(&picture_width[c], &picture_height[c]); } } } printf("Loading font \"FROST\"\n\r"); fontti = new Font("G2FONT"); printf("Loading cursor\n\r"); hiirik = new Bitmap("FONTT1"); hiirikursori = hiirik; if (leveldata.pb_name[0]) { printf("Loading background picture\n\r"); pb_picture = new Bitmap(leveldata.pb_name); } printf("Loading background papers\n\r"); lappu1 = new Bitmap("LAPPU1"); lappu2 = new Bitmap("LAPPU2"); init_vga("PALET5"); edit_level(); swap_byte_order(); faili = fopen(filename, "wb"); fwrite(&leveldata, sizeof(leveldata), 1, faili); fclose(faili); swap_byte_order(); delete pb_picture; delete lappu1; delete lappu2; delete hiirik; delete fontti; for (c = 0; c < MAX_STRUCTURES; c++) if (leveldata.struct_x[c]) delete struct_picture[c]; return 0; }