int DosShell() { int ok, w, h; grs_bitmap * save_bitmap; // Save the current graphics state. w = grd_curscreen->sc_canvas.cv_bitmap.bm_w; h = grd_curscreen->sc_canvas.cv_bitmap.bm_h; save_bitmap = gr_create_bitmap( w, h ); gr_bm_ubitblt(w, h, 0, 0, 0, 0, &(grd_curscreen->sc_canvas.cv_bitmap), save_bitmap ); gr_restore_mode(); printf( "\n\nType EXIT to return to Inferno" ); fflush(stdout); key_close(); ok = spawnl(P_WAIT,getenv("COMSPEC"), NULL ); key_init(); gr_set_mode(grd_curscreen->sc_mode); gr_bm_ubitblt(w, h, 0, 0, 0, 0, save_bitmap, &(grd_curscreen->sc_canvas.cv_bitmap)); gr_free_bitmap( save_bitmap ); //gr_pal_setblock( 0, 256, grd_curscreen->pal ); //gr_use_palette_table(); return 1; }
int DosShell() { int ok, w, h; grs_bitmap * save_bitmap; ok = 1; // Save the current graphics state. w = grd_curscreen->sc_canvas.cv_bitmap.bm_w; h = grd_curscreen->sc_canvas.cv_bitmap.bm_h; save_bitmap = gr_create_bitmap( w, h ); gr_bm_ubitblt(w, h, 0, 0, 0, 0, &(grd_curscreen->sc_canvas.cv_bitmap), save_bitmap ); // gr_set_mode( SM_ORIGINAL ); fflush(stdout); key_close(); #ifdef __MSDOS__ ok = spawnl(P_WAIT,getenv("COMSPEC"), NULL ); #endif key_init(); gr_set_mode(grd_curscreen->sc_mode); gr_bm_ubitblt(w, h, 0, 0, 0, 0, save_bitmap, &(grd_curscreen->sc_canvas.cv_bitmap)); gr_free_bitmap( save_bitmap ); //gr_pal_setblock( 0, 256, grd_curscreen->pal ); //gr_use_palette_table(); return ok; }
void menu_show( MENU * menu ) { int i; ui_mouse_hide(); gr_set_current_canvas(NULL); // Don't save background it if it's already drawn if (!menu->Displayed) { // Save the background gr_bm_ubitblt(menu->w, menu->h, 0, 0, menu->x, menu->y, &(grd_curscreen->sc_canvas.cv_bitmap), menu->Background); // Draw the menu background gr_setcolor( CGREY ); gr_urect( menu->x, menu->y, menu->x + menu->w - 1, menu->y + menu->h - 1 ); if ( menu != &Menu[0] ) { gr_setcolor( CBLACK ); gr_ubox( menu->x, menu->y, menu->x + menu->w - 1, menu->y + menu->h - 1 ); } } // Draw the items for (i=0; i< menu->NumItems; i++ ) item_show( menu, i ); ui_mouse_show(); // Mark as displayed. menu->Displayed = 1; }
void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) { int dx1=dx, dx2=dx+dest->bm_w-1; int dy1=dy, dy2=dy+dest->bm_h-1; int sx1=sx, sx2=sx+src->bm_w-1; int sy1=sy, sy2=sy+src->bm_h-1; if ((dx1 >= dest->bm_w ) || (dx2 < 0)) return; if ((dy1 >= dest->bm_h ) || (dy2 < 0)) return; if ( dx1 < 0 ) { sx1 += -dx1; dx1 = 0; } if ( dy1 < 0 ) { sy1 += -dy1; dy1 = 0; } if ( dx2 >= dest->bm_w ) { dx2 = dest->bm_w-1; } if ( dy2 >= dest->bm_h ) { dy2 = dest->bm_h-1; } if ((sx1 >= src->bm_w ) || (sx2 < 0)) return; if ((sy1 >= src->bm_h ) || (sy2 < 0)) return; if ( sx1 < 0 ) { dx1 += -sx1; sx1 = 0; } if ( sy1 < 0 ) { dy1 += -sy1; sy1 = 0; } if ( sx2 >= src->bm_w ) { sx2 = src->bm_w-1; } if ( sy2 >= src->bm_h ) { sy2 = src->bm_h-1; } // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2) if ( dx2-dx1+1 < w ) w = dx2-dx1+1; if ( dy2-dy1+1 < h ) h = dy2-dy1+1; if ( sx2-sx1+1 < w ) w = sx2-sx1+1; if ( sy2-sy1+1 < h ) h = sy2-sy1+1; gr_bm_ubitblt(w,h, dx1, dy1, sx1, sy1, src, dest ); }
void ui_close_window( UI_WINDOW * wnd ) { ui_mouse_hide(); ui_gadget_delete_all( wnd ); if (W_BACKGROUND) { gr_bm_ubitblt(W_WIDTH, W_HEIGHT, W_X, W_Y, 0, 0, W_BACKGROUND, &(grd_curscreen->sc_canvas.cv_bitmap)); gr_free_bitmap( W_BACKGROUND ); } else { gr_set_current_canvas( NULL ); gr_setcolor( CBLACK ); gr_rect( W_X, W_Y, W_X+W_WIDTH-1, W_Y+W_HEIGHT-1 ); } gr_free_sub_canvas( W_CANVAS ); gr_set_current_canvas( W_OLDCANVAS ); selected_gadget = NULL; remove_window( wnd ); if (CurWindow==wnd) CurWindow = NULL; d_free( wnd ); ui_mouse_show(); }
// Clipped bitmap ... void gr_bitmap( int x, int y, grs_bitmap *bm ) { int dx1=x, dx2=x+bm->bm_w-1; int dy1=y, dy2=y+bm->bm_h-1; #ifndef OGL int sx=0, sy=0; #endif if ((dx1 >= grd_curcanv->cv_bitmap.bm_w ) || (dx2 < 0)) return; if ((dy1 >= grd_curcanv->cv_bitmap.bm_h) || (dy2 < 0)) return; if ( dx1 < 0 ) { #ifndef OGL sx = -dx1; #endif dx1 = 0; } if ( dy1 < 0 ) { #ifndef OGL sy = -dy1; #endif dy1 = 0; } if ( dx2 >= grd_curcanv->cv_bitmap.bm_w ) { dx2 = grd_curcanv->cv_bitmap.bm_w-1; } if ( dy2 >= grd_curcanv->cv_bitmap.bm_h ) { dy2 = grd_curcanv->cv_bitmap.bm_h-1; } // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2) #ifdef OGL ogl_ubitmapm_cs(x, y, 0, 0, bm, -1, F1_0); #else gr_bm_ubitblt(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); #endif }
void ui_mouse_hide() { if (Mouse.hidden==0 ) { Mouse.hidden = 1; if (Mouse.bg_saved==1) { gr_bm_ubitblt( Mouse.background->bm_w, Mouse.background->bm_h, Mouse.bg_x, Mouse.bg_y, 0, 0, Mouse.background,&(grd_curscreen->sc_canvas.cv_bitmap) ); Mouse.bg_saved = 0; } } }
void ui_mouse_show() { if (Mouse.hidden==1 ) { Mouse.hidden = 0; // Save the background under new pointer Mouse.bg_saved=1; Mouse.bg_x = Mouse.x; Mouse.bg_y = Mouse.y; gr_bm_ubitblt( Mouse.background->bm_w, Mouse.background->bm_h, 0, 0, Mouse.bg_x, Mouse.bg_y, &(grd_curscreen->sc_canvas.cv_bitmap),Mouse.background ); // Draw the new pointer gr_bm_ubitbltm( Mouse.pointer->bm_w, Mouse.pointer->bm_h, Mouse.x, Mouse.y, 0, 0, Mouse.pointer, &(grd_curscreen->sc_canvas.cv_bitmap) ); } }
int medlisp_update_screen() { int vn; if (!render_3d_in_big_window) for (vn=0;vn<N_views;vn++) if (Views[vn]->ev_changed || (Update_flags & (UF_WORLD_CHANGED|UF_VIEWPOINT_MOVED|UF_ED_STATE_CHANGED))) { draw_world(Views[vn]->ev_canv,Views[vn],Cursegp,Big_depth); Views[vn]->ev_changed = 0; } if (Update_flags & (UF_WORLD_CHANGED|UF_GAME_VIEW_CHANGED|UF_ED_STATE_CHANGED)) { grs_canvas temp_canvas; grs_canvas *render_canv,*show_canv; if (render_3d_in_big_window) { gr_init_sub_canvas(&temp_canvas,canv_offscreen,0,0, LargeView.ev_canv->cv_bitmap.bm_w,LargeView.ev_canv->cv_bitmap.bm_h); render_canv = &temp_canvas; show_canv = LargeView.ev_canv; } else { render_canv = VR_offscreen_buffer; show_canv = Canv_editor_game; } gr_set_current_canvas(render_canv); render_frame(0); Assert(render_canv->cv_bitmap.bm_w == show_canv->cv_bitmap.bm_w && render_canv->cv_bitmap.bm_h == show_canv->cv_bitmap.bm_h); ui_mouse_hide(); gr_bm_ubitblt(show_canv->cv_bitmap.bm_w,show_canv->cv_bitmap.bm_h, 0,0,0,0,&render_canv->cv_bitmap,&show_canv->cv_bitmap); ui_mouse_show(); } Update_flags=UF_NONE; //clear flags return 1; }
void menu_hide( MENU * menu ) { // Can't hide if it's not already drawn if (!menu->Displayed) return; menu->Active = 0; // Restore the background ui_mouse_hide(); gr_bm_ubitblt(menu->w, menu->h, menu->x, menu->y, 0, 0, menu->Background, &(grd_curscreen->sc_canvas.cv_bitmap)); ui_mouse_show(); // Mark as hidden. menu->Displayed = 0; }
void gr_bitmap( int x, int y, grs_bitmap *bm ) { int dx1=x, dx2=x+bm->bm_w-1; int dy1=y, dy2=y+bm->bm_h-1; int sx=0, sy=0; if ((dx1 >= grd_curcanv->cv_bitmap.bm_w ) || (dx2 < 0)) return; if ((dy1 >= grd_curcanv->cv_bitmap.bm_h) || (dy2 < 0)) return; if ( dx1 < 0 ) { sx = -dx1; dx1 = 0; } if ( dy1 < 0 ) { sy = -dy1; dy1 = 0; } if ( dx2 >= grd_curcanv->cv_bitmap.bm_w ) { dx2 = grd_curcanv->cv_bitmap.bm_w-1; } if ( dy2 >= grd_curcanv->cv_bitmap.bm_h ) { dy2 = grd_curcanv->cv_bitmap.bm_h-1; } // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2) gr_bm_ubitblt(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); }
void ui_mouse_process() { int buttons,w,h; //if (Mouse.hidden==0) // mouse_get_pos( &Mouse.x, &Mouse.y ); //else // mouse_set_pos( Mouse.x, Mouse.y ); Mouse.dx = Mouse.new_dx; Mouse.dy = Mouse.new_dy; buttons = Mouse.new_buttons; Mouse.x += Mouse.dx; Mouse.y += Mouse.dy; w = grd_curscreen->sc_w; h = grd_curscreen->sc_h; if (Mouse.x < 0 ) Mouse.x = 0; if (Mouse.y < 0 ) Mouse.y = 0; // if (Mouse.x > w-Mouse.pointer->bm_w ) Mouse.x = w - Mouse.pointer->bm_w; // if (Mouse.y > h-Mouse.pointer->bm_h ) Mouse.y = h - Mouse.pointer->bm_h; if (Mouse.x > w-3 ) Mouse.x = w - 3; if (Mouse.y > h-3 ) Mouse.y = h - 3; if ( (Mouse.bg_x!=Mouse.x) || (Mouse.bg_y!=Mouse.y) ) Mouse.moved = 1; if ( (Mouse.bg_x!=Mouse.x) || (Mouse.bg_y!=Mouse.y) || (Mouse.bg_saved==0) ) { // Restore the background under old pointer if (Mouse.bg_saved==1) { gr_bm_ubitblt( Mouse.background->bm_w, Mouse.background->bm_h, Mouse.bg_x, Mouse.bg_y, 0, 0, Mouse.background, &(grd_curscreen->sc_canvas.cv_bitmap) ); } Mouse.bg_saved = 0; if (!Mouse.hidden) { // Save the background under new pointer Mouse.bg_saved=1; Mouse.bg_x = Mouse.x; Mouse.bg_y = Mouse.y; gr_bm_ubitblt( Mouse.background->bm_w, Mouse.background->bm_h, 0, 0, Mouse.bg_x, Mouse.bg_y, &(grd_curscreen->sc_canvas.cv_bitmap),Mouse.background ); // Draw the new pointer gr_bm_ubitbltm( Mouse.pointer->bm_w, Mouse.pointer->bm_h, Mouse.x, Mouse.y, 0, 0, Mouse.pointer, &(grd_curscreen->sc_canvas.cv_bitmap) ); } } Mouse.b1_last_status = Mouse.b1_status; Mouse.b2_last_status = Mouse.b2_status; if ( Mouse.backwards== 0 ) { if (buttons & MOUSE_LBTN ) Mouse.b1_status = BUTTON_PRESSED; else Mouse.b1_status = BUTTON_RELEASED; if (buttons & MOUSE_RBTN ) Mouse.b2_status = BUTTON_PRESSED; else Mouse.b2_status = BUTTON_RELEASED; } else { if (buttons & MOUSE_LBTN ) Mouse.b2_status = BUTTON_PRESSED; else Mouse.b2_status = BUTTON_RELEASED; if (buttons & MOUSE_RBTN ) Mouse.b1_status = BUTTON_PRESSED; else Mouse.b1_status = BUTTON_RELEASED; } if ((Mouse.b1_status & BUTTON_PRESSED) && (Mouse.b1_last_status & BUTTON_RELEASED) ) { if ( (TICKER <= Mouse.time_lastpressed+5) ) //&& (Mouse.moved==0) Mouse.b1_status |= BUTTON_DOUBLE_CLICKED; Mouse.moved = 0; Mouse.time_lastpressed = TICKER; Mouse.b1_status |= BUTTON_JUST_PRESSED; } else if ((Mouse.b1_status & BUTTON_RELEASED) && (Mouse.b1_last_status & BUTTON_PRESSED) ) Mouse.b1_status |= BUTTON_JUST_RELEASED; if ((Mouse.b2_status & BUTTON_PRESSED) && (Mouse.b2_last_status & BUTTON_RELEASED) ) Mouse.b2_status |= BUTTON_JUST_PRESSED; else if ((Mouse.b2_status & BUTTON_RELEASED) && (Mouse.b2_last_status & BUTTON_PRESSED) ) Mouse.b2_status |= BUTTON_JUST_RELEASED; }
void draw_automap() { int i; int color; object * objp; vms_vector viewer_position; g3s_point sphere_point; #ifndef AUTOMAP_DIRECT_RENDER #ifndef AUTOMAP_NO_PAGING current_page ^= 1; gr_set_current_canvas(&DrawingPages[current_page]); #else gr_set_current_canvas(&DrawingPages[0]); #endif #endif gr_clear_canvas(0); g3_start_frame(); render_start_frame(); vm_vec_scale_add(&viewer_position,&view_target,&ViewMatrix.fvec,-ViewDist ); g3_set_view_matrix(&viewer_position,&ViewMatrix,Automap_zoom); draw_all_edges(); // Draw player... #ifdef NETWORK if (Game_mode & GM_TEAM) color = get_team(Player_num); else #endif color = Player_num; // Note link to above if! gr_setcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b)); draw_player(&Objects[Players[Player_num].objnum]); // Draw player(s)... #ifdef NETWORK if ( (Game_mode & (GM_TEAM | GM_MULTI_COOP)) || (Netgame.game_flags & NETGAME_FLAG_SHOW_MAP) ) { for (i=0; i<N_players; i++) { if ( (i != Player_num) && ((Game_mode & GM_MULTI_COOP) || (get_team(Player_num) == get_team(i)) || (Netgame.game_flags & NETGAME_FLAG_SHOW_MAP)) ) { if ( Objects[Players[i].objnum].type == OBJ_PLAYER ) { if (Game_mode & GM_TEAM) color = get_team(i); else color = i; gr_setcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b)); draw_player(&Objects[Players[i].objnum]); } } } } #endif objp = &Objects[0]; for (i=0;i<=Highest_object_index;i++,objp++) { switch( objp->type ) { case OBJ_HOSTAGE: gr_setcolor(BM_XRGB(0,31,0)); g3_rotate_point(&sphere_point,&objp->pos); g3_draw_sphere(&sphere_point,objp->size); break; case OBJ_POWERUP: if ( Automap_visited[objp->segnum] ) { if ( (objp->id==POW_KEY_RED) || (objp->id==POW_KEY_BLUE) || (objp->id==POW_KEY_GOLD) ) { switch (objp->id) { case POW_KEY_RED: gr_setcolor(gr_getcolor(63, 5, 5)); break; case POW_KEY_BLUE: gr_setcolor(gr_getcolor(5, 5, 63)); break; case POW_KEY_GOLD: gr_setcolor(gr_getcolor(63, 63, 10)); break; } g3_rotate_point(&sphere_point,&objp->pos); g3_draw_sphere(&sphere_point,objp->size*4); } } break; } } g3_end_frame(); // gr_bitmapm(5,5,&name_canv->cv_bitmap); gr_set_curfont(GAME_FONT); gr_set_fontcolor(BM_XRGB(0,31,0),-1); gr_uprintf(5,5,name_level); #ifdef OGL ogl_swap_buffers(); #else #ifndef AUTOMAP_DIRECT_RENDER #ifndef AUTOMAP_NO_PAGING gr_show_canvas( &Pages[current_page] ); #else gr_bm_ubitblt( DrawingPages[0].cv_bitmap.bm_w, DrawingPages[0].cv_bitmap.bm_h, DrawingPages[0].cv_bitmap.bm_x, DrawingPages[0].cv_bitmap.bm_y, 0, 0, &DrawingPages[0].cv_bitmap, &Pages[0].cv_bitmap ); // int_gr_update(); gr_update(); #endif #else gr_update(); #endif #endif }
// --------------------------------------------------------------------------------------------------- //this function is the editor. called when editor mode selected. runs until //game mode or exit selected void editor(void) { int w,h; grs_bitmap * savedbitmap; editor_view *new_cv; static int padnum=0; vms_matrix MouseRotMat,tempm; //@@short camera_objnum; //a camera for viewing init_editor(); InitCurve(); restore_effect_bitmap_icons(); if (!set_screen_mode(SCREEN_EDITOR)) { set_screen_mode(SCREEN_GAME); Function_mode=FMODE_GAME; //force back into game return; } gr_set_current_canvas( NULL ); gr_set_curfont(editor_font); //Editor renders into full (320x200) game screen set_warn_func(med_show_warning); keyd_repeat = 1; // Allow repeat in editor // _MARK_("start of editor");//Nuked to compile -KRB ui_mouse_hide(); ui_reset_idle_seconds(); //@@ //create a camera for viewing in the editor. copy position from ConsoleObject //@@ camera_objnum = obj_create(OBJ_CAMERA,0,ConsoleObject->segnum,&ConsoleObject->pos,&ConsoleObject->orient,0); //@@ Viewer = &Objects[camera_objnum]; //@@ slew_init(Viewer); //camera is slewing Viewer = ConsoleObject; slew_init(ConsoleObject); Update_flags = UF_ALL; medlisp_update_screen(); //set the wire-frame window to be the current view current_view = &LargeView; if (faded_in==0) { faded_in = 1; //gr_pal_fade_in( grd_curscreen->pal ); } w = GameViewBox->canvas->cv_bitmap.bm_w; h = GameViewBox->canvas->cv_bitmap.bm_h; savedbitmap = gr_create_bitmap(w, h ); gr_bm_ubitblt( w, h, 0, 0, 0, 0, &GameViewBox->canvas->cv_bitmap, savedbitmap ); gr_set_current_canvas( GameViewBox->canvas ); gr_set_curfont(editor_font); //gr_setcolor( CBLACK ); //gr_deaccent_canvas(); //gr_grey_canvas(); ui_mouse_show(); gr_set_curfont(editor_font); ui_pad_goto(padnum); gamestate_restore_check(); while (Function_mode == FMODE_EDITOR) { gr_set_curfont(editor_font); info_display_all(EditorWindow); ModeFlag = 0; // Update the windows // Only update if there is no key waiting and we're not in // fast play mode. if (!key_peekkey()) //-- && (MacroStatus != UI_STATUS_FASTPLAY)) medlisp_update_screen(); //do editor stuff gr_set_curfont(editor_font); ui_mega_process(); last_keypress &= ~KEY_DEBUGGED; // mask off delete key bit which has no function in editor. ui_window_do_gadgets(EditorWindow); do_robot_window(); do_object_window(); do_wall_window(); do_trigger_window(); do_hostage_window(); do_centers_window(); 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; } } // mprintf((0, "%d ", ui_get_idle_seconds() )); if ( ui_get_idle_seconds() > COMPRESS_INTERVAL ) { med_compress_mine(); ui_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(); gr_set_current_canvas( GameViewBox->canvas ); // Remove keys used for slew switch(last_keypress) { case KEY_PAD9: case KEY_PAD7: case KEY_PADPLUS: case KEY_PADMINUS: case KEY_PAD8: case KEY_PAD2: case KEY_LBRACKET: case KEY_RBRACKET: case KEY_PAD1: case KEY_PAD3: case KEY_PAD6: case KEY_PAD4: last_keypress = 0; } if ((last_keypress&0xff)==KEY_LSHIFT) last_keypress=0; if ((last_keypress&0xff)==KEY_RSHIFT) last_keypress=0; if ((last_keypress&0xff)==KEY_LCTRL) last_keypress=0; if ((last_keypress&0xff)==KEY_RCTRL) last_keypress=0; // if ((last_keypress&0xff)==KEY_LALT) last_keypress=0; // if ((last_keypress&0xff)==KEY_RALT) last_keypress=0; if ((last_keypress&0xff)==KEY_LMETA) last_keypress=0; if ((last_keypress&0xff)==KEY_RMETA) last_keypress=0; gr_set_curfont(editor_font); menubar_do( last_keypress ); //=================== DO FUNCTIONS ==================== if ( KeyFunction[ last_keypress ] != NULL ) { KeyFunction[last_keypress](); last_keypress = 0; } switch (last_keypress) { case 0: case KEY_Z: case KEY_G: case KEY_LALT: case KEY_RALT: case KEY_LCTRL: case KEY_RCTRL: case KEY_LSHIFT: case KEY_RSHIFT: case KEY_LAPOSTRO: break; case KEY_SHIFTED + KEY_L: ToggleLighting(); break; case KEY_F1: render_3d_in_big_window = !render_3d_in_big_window; Update_flags |= UF_ALL; break; default: { char kdesc[100]; GetKeyDescription( kdesc, last_keypress ); editor_status("Error: %s isn't bound to anything.", kdesc ); } } //================================================================ if (ModeFlag==1) { close_editor_screen(); Function_mode=FMODE_EXIT; gr_free_bitmap( savedbitmap ); break; } if (ModeFlag==2) //-- && MacroStatus==UI_STATUS_NORMAL ) { close_editor_screen(); Function_mode = FMODE_MENU; set_screen_mode(SCREEN_MENU); //put up menu screen gr_free_bitmap(savedbitmap); break; } if (ModeFlag==3) //-- && MacroStatus==UI_STATUS_NORMAL ) { // med_compress_mine(); //will be called anyways before game. close_editor_screen(); Function_mode=FMODE_GAME; //force back into game set_screen_mode(SCREEN_GAME); //put up game screen gr_free_bitmap( savedbitmap ); break; } // if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)GameViewBox) current_view=NULL; // if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)GroupViewBox) current_view=NULL; new_cv = current_view ; #if ORTHO_VIEWS if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)LargeViewBox) new_cv=&LargeView; if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)TopViewBox) new_cv=&TopView; if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)FrontViewBox) new_cv=&FrontView; if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)RightViewBox) new_cv=&RightView; #endif if (new_cv != current_view ) { current_view->ev_changed = 1; new_cv->ev_changed = 1; current_view = new_cv; } calc_frame_time(); if (slew_frame(0)) { //do movement and check keys Update_flags |= UF_GAME_VIEW_CHANGED; if (Gameview_lockstep) { Cursegp = &Segments[ConsoleObject->segnum]; med_create_new_segment_from_cursegp(); Update_flags |= UF_ED_STATE_CHANGED; } } // DO TEXTURE STUFF texpage_do(); objpage_do(); // Process selection of Cursegp using mouse. if (LargeViewBox->mouse_onme && LargeViewBox->b1_clicked && !render_3d_in_big_window) { int xcrd,ycrd; xcrd = LargeViewBox->b1_drag_x1; ycrd = LargeViewBox->b1_drag_y1; find_segments(xcrd,ycrd,LargeViewBox->canvas,&LargeView,Cursegp,Big_depth); // Sets globals N_found_segs, Found_segs // If shift is down, then add segment to found list if (keyd_pressed[ KEY_LSHIFT ] || keyd_pressed[ KEY_RSHIFT ]) subtract_found_segments_from_selected_list(); else add_found_segments_to_selected_list(); Found_seg_index = 0; if (N_found_segs > 0) { sort_seg_list(N_found_segs,Found_segs,&ConsoleObject->pos); Cursegp = &Segments[Found_segs[0]]; med_create_new_segment_from_cursegp(); if (Lock_view_to_cursegp) set_view_target_from_segment(Cursegp); } Update_flags |= UF_ED_STATE_CHANGED | UF_VIEWPOINT_MOVED; } if (GameViewBox->mouse_onme && GameViewBox->b1_dragging) { int x, y; x = GameViewBox->b1_drag_x2; y = GameViewBox->b1_drag_y2; ui_mouse_hide(); gr_set_current_canvas( GameViewBox->canvas ); gr_setcolor( 15 ); gr_rect( x-1, y-1, x+1, y+1 ); ui_mouse_show(); } // Set current segment and side by clicking on a polygon in game window. // If ctrl pressed, also assign current texture map to that side. //if (GameViewBox->mouse_onme && (GameViewBox->b1_done_dragging || GameViewBox->b1_clicked)) { if ((GameViewBox->mouse_onme && GameViewBox->b1_clicked && !render_3d_in_big_window) || (LargeViewBox->mouse_onme && LargeViewBox->b1_clicked && render_3d_in_big_window)) { int xcrd,ycrd; int seg,side,face,poly,tmap; if (render_3d_in_big_window) { xcrd = LargeViewBox->b1_drag_x1; ycrd = LargeViewBox->b1_drag_y1; } else { xcrd = GameViewBox->b1_drag_x1; ycrd = GameViewBox->b1_drag_y1; } //Int3(); if (find_seg_side_face(xcrd,ycrd,&seg,&side,&face,&poly)) { if (seg<0) { //found an object Cur_object_index = -seg-1; editor_status("Object %d selected.",Cur_object_index); Update_flags |= UF_ED_STATE_CHANGED; } else { // See if either shift key is down and, if so, assign texture map if (keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) { Cursegp = &Segments[seg]; Curside = side; AssignTexture(); med_create_new_segment_from_cursegp(); editor_status("Texture assigned"); } else if (keyd_pressed[KEY_G]) { tmap = Segments[seg].sides[side].tmap_num; texpage_grab_current(tmap); editor_status( "Texture grabbed." ); } else if (keyd_pressed[ KEY_LAPOSTRO] ) { ui_mouse_hide(); move_object_to_mouse_click(); } else { Cursegp = &Segments[seg]; Curside = side; med_create_new_segment_from_cursegp(); editor_status("Curseg and curside selected"); } } Update_flags |= UF_ED_STATE_CHANGED; } else editor_status("Click on non-texture ingored"); } // Allow specification of LargeView using mouse if (keyd_pressed[ KEY_LCTRL ] || keyd_pressed[ KEY_RCTRL ]) { ui_mouse_hide(); if ( (Mouse.dx!=0) && (Mouse.dy!=0) ) { GetMouseRotation( Mouse.dx, Mouse.dy, &MouseRotMat ); vm_matrix_x_matrix(&tempm,&LargeView.ev_matrix,&MouseRotMat); LargeView.ev_matrix = tempm; LargeView.ev_changed = 1; Large_view_index = -1; // say not one of the orthogonal views } } else { ui_mouse_show(); } if ( keyd_pressed[ KEY_Z ] ) { ui_mouse_hide(); if ( Mouse.dy!=0 ) { current_view->ev_dist += Mouse.dy*10000; current_view->ev_changed = 1; } } else { ui_mouse_show(); } vid_update(); } // _MARK_("end of editor");//Nuked to compile -KRB clear_warn_func(med_show_warning); //kill our camera object Viewer = ConsoleObject; //reset viewer //@@obj_delete(camera_objnum); padnum = ui_pad_get_current(); close_editor(); ui_close(); }
UI_WINDOW * ui_open_window( short x, short y, short w, short h, int flags ) { UI_WINDOW * wnd; int sw, sh, req_w, req_h; wnd = (UI_WINDOW *)d_malloc(sizeof(UI_WINDOW)); if (wnd==NULL) Error("Could not create window: Out of memory"); W_NEXT = NULL; W_PREV = NULL; add_window_to_end( wnd ); sw = grd_curscreen->sc_w; sh = grd_curscreen->sc_h; // mouse_set_limits( 0,0, sw-1, sh-1 ); req_w = w; req_h = h; if (flags & WIN_BORDER) { x -= BORDER_WIDTH; y -= BORDER_WIDTH; w += 2*BORDER_WIDTH; h += 2*BORDER_WIDTH; } if ( x < 0 ) x = 0; if ( (x+w-1) >= sw ) x = sw - w; if ( y < 0 ) y = 0; if ( (y+h-1) >= sh ) y = sh - h; W_X = x; W_Y = y; W_WIDTH = w; W_HEIGHT = h; W_OLDCANVAS = grd_curcanv; W_GADGET = NULL; wnd->keyboard_focus_gadget = NULL; ui_mouse_hide(); if (flags & WIN_SAVE_BG) { W_BACKGROUND = gr_create_bitmap( w, h ); gr_bm_ubitblt(w, h, 0, 0, x, y, &(grd_curscreen->sc_canvas.cv_bitmap), W_BACKGROUND ); } else W_BACKGROUND = NULL; if (flags & WIN_BORDER) { W_CANVAS = gr_create_sub_canvas( &(grd_curscreen->sc_canvas), x+BORDER_WIDTH, y+BORDER_WIDTH, req_w, req_h ); gr_set_current_canvas( NULL ); ui_draw_frame( x, y, x+w-1, y+h-1 ); } else W_CANVAS = gr_create_sub_canvas( &(grd_curscreen->sc_canvas), x, y, req_w, req_h ); gr_set_current_canvas( W_CANVAS ); if (flags & WIN_FILLED) ui_draw_box_out( 0, 0, req_w-1, req_h-1 ); gr_set_fontcolor( CBLACK, CWHITE ); selected_gadget = NULL; W_TEXT_X = 0; W_TEXT_Y = 0; return wnd; }
void credits_show() { int i, j, l, done; CFILE * file; char buffer[NUM_LINES][80]; grs_bitmap backdrop; ubyte backdrop_palette[768]; int pcx_error; int buffer_line = 0; fix last_time; fix time_delay = 4180 / f2fl(Scale_y); // ~ F1_0 / 12.9 int first_line_offset,extra_inc=0; int have_bin_file = 0; char * tempp; grs_point scale_pts[] = FULLSCREEN_SCALE_PTS; ubyte *fade_values = malloc(grd_curscreen->sc_h); for (i = 0; i < grd_curscreen->sc_h; ++i) { fade_values[i] = fade_values_200[(int)(((float)i / (float)grd_curscreen->sc_h) * 200)]; } set_screen_mode(SCREEN_MENU); // Clear out all tex buffer lines. for (i=0; i<NUM_LINES; i++ ) buffer[i][0] = 0; have_bin_file = 0; file = cfopen( "credits.tex", "rb" ); if (file == NULL) { file = cfopen("credits.txb", "rb"); if (file == NULL) Error("Missing CREDITS.TEX and CREDITS.TXB file\n"); have_bin_file = 1; } gr_use_palette_table( "credits.256" ); header_font = gr_init_font( "font1-1.fnt" ); title_font = gr_init_font( "font2-3.fnt" ); names_font = gr_init_font( "font2-2.fnt" ); backdrop.bm_data=NULL; pcx_error = pcx_read_bitmap("stars.pcx",&backdrop,BM_LINEAR,backdrop_palette); if (pcx_error != PCX_ERROR_NONE) { cfclose(file); return; } songs_play_song( SONG_CREDITS, 0 ); gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 ); gr_set_current_canvas(NULL); scale_bitmap(&backdrop,scale_pts); gr_palette_fade_in( gr_palette, 32, 0 ); vfx_set_palette_sub( gr_palette ); //gr_clear_canvas(BM_XRGB(0,0,0)); key_flush(); last_time = timer_get_fixed_seconds(); done = 0; first_line_offset = 0; while( 1 ) { int k; do { buffer_line = (buffer_line+1) % NUM_LINES; if (cfgets( buffer[buffer_line], 80, file )) { char *p; if (have_bin_file) { // is this a binary tbl file for (i = 0; i < strlen(buffer[buffer_line]) - 1; i++) { encode_rotate_left(&(buffer[buffer_line][i])); buffer[buffer_line][i] ^= BITMAP_TBL_XOR; encode_rotate_left(&(buffer[buffer_line][i])); } } p = strchr(&buffer[buffer_line][0],'\n'); if (p) *p = '\0'; } else { //fseek( file, 0, SEEK_SET); buffer[buffer_line][0] = 0; done++; } } while (extra_inc--); extra_inc = 0; for (i=0; i<ROW_SPACING; i++ ) { int y; y = first_line_offset - i; #ifndef OGLES gr_set_current_canvas(VR_offscreen_buffer); #endif scale_bitmap(&backdrop, scale_pts); for (j=0; j<NUM_LINES; j++ ) { char *s; l = (buffer_line + j + 1 ) % NUM_LINES; s = buffer[l]; if ( s[0] == '!' ) { s++; } else if ( s[0] == '$' ) { grd_curcanv->cv_font = header_font; s++; } else if ( s[0] == '*' ) { grd_curcanv->cv_font = title_font; s++; } else grd_curcanv->cv_font = names_font; gr_bitblt_fade_table = fade_values; tempp = strchr( s, '\t' ); if ( tempp ) { int w, h, aw; *tempp = 0; gr_get_string_size( s, &w, &h, &aw ); w *= f2fl(Scale_x); h *= f2fl(Scale_y); gr_scale_printf( (160-w)/2, y, Scale_factor, Scale_factor, s ); gr_get_string_size( &tempp[1], &w, &h, &aw ); w *= f2fl(Scale_x); h *= f2fl(Scale_y); gr_scale_printf( 160+((160-w)/2), y, Scale_factor, Scale_factor, &tempp[1] ); *tempp = '\t'; } else { gr_scale_printf( 0x8000, y, Scale_factor, Scale_factor, s ); } gr_bitblt_fade_table = NULL; if (buffer[l][0] == '!') y += ROW_SPACING/2; else y += ROW_SPACING; } #ifdef OGLES showRenderBuffer(); #else gr_bm_ubitblt(grd_curscreen->sc_w, grd_curscreen->sc_h, 0, 0, 0, 0, &(VR_offscreen_buffer->cv_bitmap), &(grd_curscreen->sc_canvas.cv_bitmap) ); #endif while( timer_get_fixed_seconds() < last_time+time_delay ); last_time = timer_get_fixed_seconds(); k = key_inkey(); #ifndef NDEBUG if (k == KEY_BACKSP) { Int3(); k=0; } #endif // { // fix ot = time_delay; // time_delay += (keyd_pressed[KEY_X] - keyd_pressed[KEY_Z])*100; // if (ot!=time_delay) { // mprintf( (0, "[%x] ", time_delay )); // } // } if (k == KEY_PRINT_SCREEN) { save_screen_shot(0); k = 0; } if ((k>0)||(done>NUM_LINES)) { gr_close_font(header_font); gr_close_font(title_font); gr_close_font(names_font); gr_palette_fade_out( gr_palette, 32, 0 ); gr_use_palette_table( "palette.256" ); free(backdrop.bm_data); cfclose(file); songs_play_song( SONG_TITLE, 1 ); return; } } if (buffer[(buffer_line + 1 ) % NUM_LINES][0] == '!') { first_line_offset -= ROW_SPACING-ROW_SPACING/2; if (first_line_offset <= -ROW_SPACING) { first_line_offset += ROW_SPACING; extra_inc++; } } } free(fade_values); }