From 4acf60c1c7efefd23d269413cda98da949a245f7 Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Sat, 24 Mar 2012 17:19:30 +0800 Subject: [PATCH] Draw in response to EVENT_UI_DIALOG_DRAW, uncomment medlisp_update_screen call. You can now see what you're doing --- CHANGELOG.txt | 1 + arch/include/event.h | 1 + editor/centers.c | 11 ++++--- editor/eswitch.c | 36 +++++++++++--------- editor/med.c | 78 +++++++++++++++++++++++--------------------- editor/meddraw.c | 5 --- editor/medrobot.c | 67 ++++++++++++++++++++----------------- editor/medwall.c | 68 ++++++++++++++++++++------------------ ui/dialog.c | 9 ++--- 9 files changed, 148 insertions(+), 128 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 861588000..b131438c0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ D2X-Rebirth Changelog -------- arch/ogl/gr.c, arch/sdl/gr.c, ui/menubar.c: Draw the editor menubar properly - by drawing in response to EVENT_WINDOW_DRAW and initialising the screen canvas properly. The latter fixes a lot of other editor drawing issues as well 2d/bitmap.c, arch/include/window.h, arch/sdl/gr.c, arch/sdl/window.c, include/gr.h: Update the canvas data pointers for all windows after changing the screen mode, so the main menu draws properly after leaving the editor +arch/include/event.h, editor/centers.c, editor/eswitch.c, editor/med.c, editor/meddraw.c, editor/medrobot.c, editor/medwall.c, ui/dialog.c: Draw in response to EVENT_UI_DIALOG_DRAW, uncomment medlisp_update_screen call. You can now see what you're doing! 20120319 -------- diff --git a/arch/include/event.h b/arch/include/event.h index 7ad4848bc..0d3539748 100644 --- a/arch/include/event.h +++ b/arch/include/event.h @@ -46,6 +46,7 @@ typedef enum event_type EVENT_NEWMENU_CHANGED, // an item had its value/text changed EVENT_NEWMENU_SELECTED, // user chose something - pressed enter/clicked on it + EVENT_UI_DIALOG_DRAW, // draw after the dialog stuff is drawn (e.g. spinning robots) EVENT_UI_GADGET_PRESSED, // user 'pressed' a gadget EVENT_UI_LISTBOX_MOVED, EVENT_UI_LISTBOX_SELECTED, diff --git a/editor/centers.c b/editor/centers.c index a9abac8b5..1c5de7aa5 100644 --- a/editor/centers.c +++ b/editor/centers.c @@ -126,7 +126,6 @@ int centers_dialog_handler(UI_DIALOG *dlg, d_event *event, centers_dialog *c) int i; // int robot_flags; int keypress = 0; - int redraw_window; int rval = 0; Assert(MainWindow != NULL); @@ -161,7 +160,6 @@ int centers_dialog_handler(UI_DIALOG *dlg, d_event *event, centers_dialog *c) // update the corresponding center. //------------------------------------------------------------ - redraw_window=0; for ( i=0; i < MAX_CENTER_TYPES; i++ ) { if ( GADGET_PRESSED(c->centerFlag[i]) ) @@ -171,7 +169,7 @@ int centers_dialog_handler(UI_DIALOG *dlg, d_event *event, centers_dialog *c) else if (Curseg2p->special != i) { fuelcen_delete(Cursegp); - redraw_window = 1; + Update_flags |= UF_WORLD_CHANGED; fuelcen_activate( Cursegp, i ); } rval = 1; @@ -194,7 +192,8 @@ int centers_dialog_handler(UI_DIALOG *dlg, d_event *event, centers_dialog *c) // If anything changes in the ui system, redraw all the text that // identifies this wall. //------------------------------------------------------------ - if (redraw_window || (c->old_seg_num != Cursegp-Segments ) ) { + if (event->type == EVENT_UI_DIALOG_DRAW) + { // int i; // char temp_text[CENTER_STRING_LENGTH]; @@ -207,9 +206,11 @@ int centers_dialog_handler(UI_DIALOG *dlg, d_event *event, centers_dialog *c) // Assert(Curseg2p->special < MAX_CENTER_TYPES); // strncpy(temp_text, Center_names[Curseg2p->special], strlen(Center_names[Curseg2p->special])); // ui_dprintf_at( dlg, 12, 23, " Type: %s", temp_text ); - Update_flags |= UF_WORLD_CHANGED; } + if (c->old_seg_num != Cursegp-Segments) + Update_flags |= UF_WORLD_CHANGED; + if (event->type == EVENT_WINDOW_CLOSE) { d_free(c); diff --git a/editor/eswitch.c b/editor/eswitch.c index 5492f8340..431a39df7 100644 --- a/editor/eswitch.c +++ b/editor/eswitch.c @@ -446,35 +446,41 @@ int trigger_dialog_handler(UI_DIALOG *dlg, d_event *event, trigger_dialog *t) //------------------------------------------------------------ // Draw the wall in the little 64x64 box //------------------------------------------------------------ - gr_set_current_canvas( t->wallViewBox->canvas ); + if (event->type == EVENT_UI_DIALOG_DRAW) + { + gr_set_current_canvas( t->wallViewBox->canvas ); - if ((Markedsegp->sides[Markedside].wall_num == -1) || (Walls[Markedsegp->sides[Markedside].wall_num].trigger) == -1) - gr_clear_canvas( CBLACK ); - else { - if (Markedsegp->sides[Markedside].tmap_num2 > 0) { - gr_ubitmap(0,0, texmerge_get_cached_bitmap( Markedsegp->sides[Markedside].tmap_num, Markedsegp->sides[Markedside].tmap_num2)); - } else { - if (Markedsegp->sides[Markedside].tmap_num > 0) { - PIGGY_PAGE_IN(Textures[Markedsegp->sides[Markedside].tmap_num]); - gr_ubitmap(0,0, &GameBitmaps[Textures[Markedsegp->sides[Markedside].tmap_num].index]); - } else - gr_clear_canvas( CGREY ); + if ((Markedsegp->sides[Markedside].wall_num == -1) || (Walls[Markedsegp->sides[Markedside].wall_num].trigger) == -1) + gr_clear_canvas( CBLACK ); + else { + if (Markedsegp->sides[Markedside].tmap_num2 > 0) { + gr_ubitmap(0,0, texmerge_get_cached_bitmap( Markedsegp->sides[Markedside].tmap_num, Markedsegp->sides[Markedside].tmap_num2)); + } else { + if (Markedsegp->sides[Markedside].tmap_num > 0) { + PIGGY_PAGE_IN(Textures[Markedsegp->sides[Markedside].tmap_num]); + gr_ubitmap(0,0, &GameBitmaps[Textures[Markedsegp->sides[Markedside].tmap_num].index]); + } else + gr_clear_canvas( CGREY ); + } } - } + } //------------------------------------------------------------ // If anything changes in the ui system, redraw all the text that // identifies this robot. //------------------------------------------------------------ - if (ui_button_any_drawn || (t->old_trigger_num != trigger_num) ) { + if (event->type == EVENT_UI_DIALOG_DRAW) + { if ( Markedsegp->sides[Markedside].wall_num > -1 ) { ui_dprintf_at( MainWindow, 12, 6, "Trigger: %d ", trigger_num); } else { ui_dprintf_at( MainWindow, 12, 6, "Trigger: none "); } - Update_flags |= UF_WORLD_CHANGED; } + if (ui_button_any_drawn || (t->old_trigger_num != trigger_num) ) + Update_flags |= UF_WORLD_CHANGED; + if (event->type == EVENT_WINDOW_CLOSE) { d_free(t); diff --git a/editor/med.c b/editor/med.c index 0f4d3c592..56a211f09 100644 --- a/editor/med.c +++ b/editor/med.c @@ -164,7 +164,7 @@ void print_diagnostic( char message[DIAGNOSTIC_MESSAGE_MAX] ) { gr_rect( 4+w, 583, 799, 599 ); } -static char status_line[DIAGNOSTIC_MESSAGE_MAX]; +static char status_line[DIAGNOSTIC_MESSAGE_MAX] = ""; struct tm Editor_status_last_time; @@ -176,8 +176,6 @@ void editor_status( const char *format, ... ) vsprintf(status_line, format, ap); va_end(ap); - print_status_bar(status_line); - Editor_status_last_time = Editor_time_of_day; } @@ -199,13 +197,11 @@ void clear_editor_status(void) if (cur_time > erase_time) { int i; - char message[DIAGNOSTIC_MESSAGE_MAX]; for (i=0; i=0); - - if (Gameview_lockstep) { - static segment *old_cursegp=NULL; - static int old_curside=-1; - - if (old_cursegp!=Cursegp || old_curside!=Curside) { - SetPlayerFromCursegMinusOne(); - old_cursegp = Cursegp; - old_curside = Curside; - } - } - - if ( event_get_idle_seconds() > COMPRESS_INTERVAL ) + if (event->type == EVENT_UI_DIALOG_DRAW) { - med_compress_mine(); - event_reset_idle_seconds(); + medlisp_update_screen(); + print_status_bar(status_line); + return 1; + } + + //do editor stuff + if (event->type == EVENT_IDLE) + { + check_wall_validity(); + Assert(Num_walls>=0); + + if (Gameview_lockstep) { + static segment *old_cursegp=NULL; + static int old_curside=-1; + + if (old_cursegp!=Cursegp || old_curside!=Curside) { + SetPlayerFromCursegMinusOne(); + old_cursegp = Cursegp; + old_curside = Curside; + } + } + + if ( event_get_idle_seconds() > COMPRESS_INTERVAL ) + { + med_compress_mine(); + event_reset_idle_seconds(); + } + + // Commented out because it occupies about 25% of time in twirling the mine. + // Removes some Asserts.... + // med_check_all_vertices(); + clear_editor_status(); // if enough time elapsed, clear editor status message + TimedAutosave(mine_filename); + set_editor_time_of_day(); } -// Commented out because it occupies about 25% of time in twirling the mine. -// Removes some Asserts.... -// med_check_all_vertices(); - clear_editor_status(); // if enough time elapsed, clear editor status message - TimedAutosave(mine_filename); - set_editor_time_of_day(); gr_set_current_canvas( GameViewBox->canvas ); // Remove keys used for slew @@ -1236,7 +1238,9 @@ int editor_handler(UI_DIALOG *dlg, d_event *event, void *data) current_view = new_cv; } - calc_frame_time(); + if (event->type == EVENT_UI_DIALOG_DRAW) + calc_frame_time(); + if (slew_frame(0)) { //do movement and check keys Update_flags |= UF_GAME_VIEW_CHANGED; if (Gameview_lockstep) { diff --git a/editor/meddraw.c b/editor/meddraw.c index 10e209fc3..646501506 100644 --- a/editor/meddraw.c +++ b/editor/meddraw.c @@ -800,8 +800,6 @@ void draw_world(grs_canvas *screen_canvas,editor_view *v,segment *mine_ptr,int d gr_set_current_canvas(screen_canvas); #endif - mouse_toggle_cursor(0); - //g3_set_points(Segment_points,Vertices); viewer_position = v->ev_matrix.fvec; @@ -906,9 +904,6 @@ void draw_world(grs_canvas *screen_canvas,editor_view *v,segment *mine_ptr,int d // } #endif - - mouse_toggle_cursor(1); - } //find the segments that render at a given screen x,y diff --git a/editor/medrobot.c b/editor/medrobot.c index 508aa440e..2bbba2abd 100644 --- a/editor/medrobot.c +++ b/editor/medrobot.c @@ -582,46 +582,50 @@ int robot_dialog_handler(UI_DIALOG *dlg, d_event *event, robot_dialog *r) } } - //------------------------------------------------------------ - // A simple frame time counter for spinning the objects... - //------------------------------------------------------------ - Temp = timer_query(); - DeltaTime = Temp - r->time; - r->time = Temp; - //------------------------------------------------------------ // Redraw the object in the little 64x64 box //------------------------------------------------------------ - if (Cur_object_index > -1 ) { - object *obj = &Objects[Cur_object_index]; + if (event->type == EVENT_UI_DIALOG_DRAW) + { + // A simple frame time counter for spinning the objects... + Temp = timer_query(); + DeltaTime = Temp - r->time; + r->time = Temp; - gr_set_current_canvas( r->robotViewBox->canvas ); - draw_object_picture(obj->id, &r->angles, obj->type ); - r->angles.h += fixmul(0x1000, DeltaTime ); - } else { - // no object, so just blank out - gr_set_current_canvas( r->robotViewBox->canvas ); - gr_clear_canvas( CGREY ); + if (Cur_object_index > -1 ) { + object *obj = &Objects[Cur_object_index]; -// LocalObjectSelectNextInMine(); + gr_set_current_canvas( r->robotViewBox->canvas ); + draw_object_picture(obj->id, &r->angles, obj->type ); + r->angles.h += fixmul(0x1000, DeltaTime ); + } else { + // no object, so just blank out + gr_set_current_canvas( r->robotViewBox->canvas ); + gr_clear_canvas( CGREY ); + + // LocalObjectSelectNextInMine(); + } } //------------------------------------------------------------ // Redraw the contained object in the other little box //------------------------------------------------------------ - if ((Cur_object_index > -1 ) && (Cur_goody_count > 0)) { - gr_set_current_canvas( r->containsViewBox->canvas ); - if ( Cur_goody_id > -1 ) - draw_object_picture(Cur_goody_id, &r->goody_angles, Cur_goody_type); - else + if (event->type == EVENT_UI_DIALOG_DRAW) + { + if ((Cur_object_index > -1 ) && (Cur_goody_count > 0)) { + gr_set_current_canvas( r->containsViewBox->canvas ); + if ( Cur_goody_id > -1 ) + draw_object_picture(Cur_goody_id, &r->goody_angles, Cur_goody_type); + else + gr_clear_canvas( CGREY ); + r->goody_angles.h += fixmul(0x1000, DeltaTime ); + } else { + // no object, so just blank out + gr_set_current_canvas( r->containsViewBox->canvas ); gr_clear_canvas( CGREY ); - r->goody_angles.h += fixmul(0x1000, DeltaTime ); - } else { - // no object, so just blank out - gr_set_current_canvas( r->containsViewBox->canvas ); - gr_clear_canvas( CGREY ); -// LocalObjectSelectNextInMine(); + // LocalObjectSelectNextInMine(); + } } //------------------------------------------------------------ @@ -629,7 +633,8 @@ int robot_dialog_handler(UI_DIALOG *dlg, d_event *event, robot_dialog *r) // identifies this robot. //------------------------------------------------------------ - if (ui_button_any_drawn || (r->old_object != Cur_object_index) ) { + if (event->type == EVENT_UI_DIALOG_DRAW) + { int i; char type_text[STRING_LENGTH+1],id_text[STRING_LENGTH+1]; @@ -691,9 +696,11 @@ int robot_dialog_handler(UI_DIALOG *dlg, d_event *event, robot_dialog *r) ui_dprintf_at( MainWindow, 12, 22, " Type: ? " ); ui_dprintf_at( MainWindow, 12, 38, " Name: ________" ); } - Update_flags |= UF_WORLD_CHANGED; } + if (ui_button_any_drawn || (r->old_object != Cur_object_index) ) + Update_flags |= UF_WORLD_CHANGED; + if (event->type == EVENT_WINDOW_CLOSE) { d_free(r); diff --git a/editor/medwall.c b/editor/medwall.c index 889b29964..352b55f17 100644 --- a/editor/medwall.c +++ b/editor/medwall.c @@ -507,47 +507,49 @@ int wall_dialog_handler(UI_DIALOG *dlg, d_event *event, wall_dialog *wd) wd->doorFlag[i]->status = 1; // Tells ui to redraw button } - //------------------------------------------------------------ - // A simple frame time counter for animating the walls... - //------------------------------------------------------------ - Temp = timer_query(); - DeltaTime = Temp - wd->time; - //------------------------------------------------------------ // Draw the wall in the little 64x64 box //------------------------------------------------------------ - gr_set_current_canvas( wd->wallViewBox->canvas ); - if (Cursegp->sides[Curside].wall_num != -1) { - type = Walls[Cursegp->sides[Curside].wall_num].type; - if ((type == WALL_DOOR) || (type == WALL_BLASTABLE)) { - if (DeltaTime > ((F1_0*200)/1000)) { - wd->framenum++; - wd->time = Temp; - } - if (wd->framenum >= WallAnims[Walls[Cursegp->sides[Curside].wall_num].clip_num].num_frames) - wd->framenum=0; - PIGGY_PAGE_IN(Textures[WallAnims[Walls[Cursegp->sides[Curside].wall_num].clip_num].frames[wd->framenum]]); - gr_ubitmap(0,0, &GameBitmaps[Textures[WallAnims[Walls[Cursegp->sides[Curside].wall_num].clip_num].frames[wd->framenum]].index]); - } else { - if (type == WALL_OPEN) - gr_clear_canvas( CBLACK ); - else { - if (Cursegp->sides[Curside].tmap_num2 > 0) - gr_ubitmap(0,0, texmerge_get_cached_bitmap( Cursegp->sides[Curside].tmap_num, Cursegp->sides[Curside].tmap_num2)); - else { - PIGGY_PAGE_IN(Textures[Cursegp->sides[Curside].tmap_num]); - gr_ubitmap(0,0, &GameBitmaps[Textures[Cursegp->sides[Curside].tmap_num].index]); + if (event->type == EVENT_UI_DIALOG_DRAW) + { + // A simple frame time counter for animating the walls... + Temp = timer_query(); + DeltaTime = Temp - wd->time; + + gr_set_current_canvas( wd->wallViewBox->canvas ); + if (Cursegp->sides[Curside].wall_num != -1) { + type = Walls[Cursegp->sides[Curside].wall_num].type; + if ((type == WALL_DOOR) || (type == WALL_BLASTABLE)) { + if (DeltaTime > ((F1_0*200)/1000)) { + wd->framenum++; + wd->time = Temp; + } + if (wd->framenum >= WallAnims[Walls[Cursegp->sides[Curside].wall_num].clip_num].num_frames) + wd->framenum=0; + PIGGY_PAGE_IN(Textures[WallAnims[Walls[Cursegp->sides[Curside].wall_num].clip_num].frames[wd->framenum]]); + gr_ubitmap(0,0, &GameBitmaps[Textures[WallAnims[Walls[Cursegp->sides[Curside].wall_num].clip_num].frames[wd->framenum]].index]); + } else { + if (type == WALL_OPEN) + gr_clear_canvas( CBLACK ); + else { + if (Cursegp->sides[Curside].tmap_num2 > 0) + gr_ubitmap(0,0, texmerge_get_cached_bitmap( Cursegp->sides[Curside].tmap_num, Cursegp->sides[Curside].tmap_num2)); + else { + PIGGY_PAGE_IN(Textures[Cursegp->sides[Curside].tmap_num]); + gr_ubitmap(0,0, &GameBitmaps[Textures[Cursegp->sides[Curside].tmap_num].index]); + } } } - } - } else - gr_clear_canvas( CGREY ); + } else + gr_clear_canvas( CGREY ); + } //------------------------------------------------------------ // If anything changes in the ui system, redraw all the text that // identifies this wall. //------------------------------------------------------------ - if (ui_button_any_drawn || (wd->old_wall_num != Cursegp->sides[Curside].wall_num) ) { + if (event->type == EVENT_UI_DIALOG_DRAW) + { if ( Cursegp->sides[Curside].wall_num > -1 ) { ui_dprintf_at( MainWindow, 12, 6, "Wall: %d ", Cursegp->sides[Curside].wall_num); switch (Walls[Cursegp->sides[Curside].wall_num].type) { @@ -585,9 +587,11 @@ int wall_dialog_handler(UI_DIALOG *dlg, d_event *event, wall_dialog *wd) ui_dprintf_at( MainWindow, 12, 40, " Clip: none "); ui_dprintf_at( MainWindow, 12, 57, " Trigger: none "); } - Update_flags |= UF_WORLD_CHANGED; } + if (ui_button_any_drawn || (wd->old_wall_num != Cursegp->sides[Curside].wall_num) ) + Update_flags |= UF_WORLD_CHANGED; + if (event->type == EVENT_WINDOW_CLOSE) { d_free(wd); diff --git a/ui/dialog.c b/ui/dialog.c index 15b0236de..7e8b0daff 100644 --- a/ui/dialog.c +++ b/ui/dialog.c @@ -176,8 +176,12 @@ int ui_dialog_handler(window *wind, d_event *event, UI_DIALOG *dlg) break; case EVENT_WINDOW_DRAW: - return ui_dialog_draw(dlg); + { + d_event event2 = { EVENT_UI_DIALOG_DRAW }; + rval = ui_dialog_draw(dlg); + window_send_event(wind, &event2); break; + } case EVENT_WINDOW_CLOSE: //ui_close_dialog(dlg); // need to hide this function and make it not call window_close first @@ -606,8 +610,5 @@ void ui_dprintf_at( UI_DIALOG * dlg, short x, short y, char * format, ... ) ui_dialog_set_current_canvas( dlg ); - mouse_toggle_cursor(0); gr_string( x, y, buffer ); - mouse_toggle_cursor(1); - }