void player_dead_message(void) { if (Player_exploded) { if ( Players[Player_num].lives < 2 ) { int x, y, w, h, aw; gr_set_curfont( HUGE_FONT ); gr_get_string_size( TXT_GAME_OVER, &w, &h, &aw ); w += 20; h += 8; x = (grd_curcanv->cv_bitmap.bm_w - w ) / 2; y = (grd_curcanv->cv_bitmap.bm_h - h ) / 2; gr_settransblend(14, GR_BLEND_NORMAL); gr_setcolor( BM_XRGB(0,0,0) ); gr_rect( x, y, x+w, y+h ); gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL); gr_string(0x8000, (GHEIGHT - h)/2 + h/8, TXT_GAME_OVER ); } gr_set_curfont( GAME_FONT ); if (HUD_color == -1) HUD_color = BM_XRGB(0,28,0); gr_set_fontcolor( HUD_color, -1); gr_string(0x8000, GHEIGHT-LINE_SPACING, TXT_PRESS_ANY_KEY); } }
void player_dead_message(void) { if (!(Game_mode & GM_CAPTURE)) { if (Player_exploded) { if ( Players[Player_num].lives < 2 ) { int x, y, w, h, aw; gr_set_curfont( HUGE_FONT ); gr_get_string_size( TXT_GAME_OVER, &w, &h, &aw ); w += 20; h += 8; x = (grd_curcanv->cv_bitmap.bm_w - w ) / 2; y = (grd_curcanv->cv_bitmap.bm_h - h ) / 2; gr_settransblend(14, GR_BLEND_NORMAL); gr_setcolor( BM_XRGB(0,0,0) ); gr_rect( x, y, x+w, y+h ); gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL); gr_printf(0x8000, (GHEIGHT - h)/2 + h/8, TXT_GAME_OVER ); } gr_set_curfont( GAME_FONT ); if (HUD_color == -1) HUD_color = BM_XRGB(0,28,0); gr_set_fontcolor( HUD_color, -1); gr_printf(0x8000, GHEIGHT-LINE_SPACING, TXT_PRESS_ANY_KEY); } } extern int player_spawn_timer; if (Game_mode & GM_CAPTURE) { if (Player_exploded) { if ( Players[Player_num].lives < 2 ) { int x, y, w, h, aw; gr_set_curfont( HUGE_FONT ); gr_get_string_size( TXT_GAME_OVER, &w, &h, &aw ); w += 20; h += 8; x = (grd_curcanv->cv_bitmap.bm_w - w ) / 2; y = (grd_curcanv->cv_bitmap.bm_h - h ) / 2; gr_settransblend(14, GR_BLEND_NORMAL); gr_setcolor( BM_XRGB(0,0,0) ); gr_rect( x, y, x+w, y+h ); gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL); gr_printf(0x8000, (GHEIGHT - h)/2 + h/8, TXT_GAME_OVER ); } gr_set_curfont( GAME_FONT ); if (HUD_color == -1) HUD_color = BM_XRGB(0,28,0); gr_set_fontcolor( HUD_color, -1); if (((player_spawn_timer + Netgame.RespawnTime*5) > f2i(Players[Player_num].time_level)) && force_respawn == 0) gr_printf(0x8000, GHEIGHT-LINE_SPACING, "You must wait %d seconds to respawn.", (player_spawn_timer + (Netgame.RespawnTime*5)) - f2i(Players[Player_num].time_level)); if (((player_spawn_timer + Netgame.RespawnTime*5) > f2i(Players[Player_num].time_level)) && force_respawn == 1) gr_printf(0x8000, GHEIGHT-LINE_SPACING, "You will respawn in %d seconds.", (player_spawn_timer + (Netgame.RespawnTime*5)) - f2i(Players[Player_num].time_level)); if ((player_spawn_timer + Netgame.RespawnTime*5) <= f2i(Players[Player_num].time_level)) gr_printf(0x8000, GHEIGHT-LINE_SPACING, "Press any key or button to respawn."); } } }
// ---------------------------------------------------------------------------- // Writes a message on the HUD and checks its timer. void HUD_render_message_frame() { int i,j,y; HUD_toolong = 0; if (( HUD_nmessages < 0 ) || (HUD_nmessages > HUD_MAX_NUM_STOR)) Int3(); // Get Rob! if (HUD_nmessages < 1 ) return; for (i = 0; i < HUD_nmessages; i++) { HUD_messages[i].time -= FrameTime; // message expired - remove if (HUD_messages[i].time <= 0) { for (j = i; j < HUD_nmessages; j++) { if (j+1 < HUD_nmessages) memcpy(&HUD_messages[j], &HUD_messages[j+1], sizeof(struct hudmsg)); else memset(&HUD_messages[j], 0, sizeof(struct hudmsg)); } HUD_nmessages--; } } // display last $HUD_MAX_NUM_DISP messages on the list if (HUD_nmessages > 0 ) { int startmsg = ((HUD_nmessages-HUD_MAX_NUM_DISP<0)?0:HUD_nmessages-HUD_MAX_NUM_DISP); if (HUD_color == -1) HUD_color = BM_XRGB(0,28,0); gr_set_curfont( GAME_FONT ); y = FSPACY(1); if (Guided_missile[Player_num] && Guided_missile[Player_num]->type==OBJ_WEAPON && Guided_missile[Player_num]->id==GUIDEDMISS_ID && Guided_missile[Player_num]->signature==Guided_missile_sig[Player_num] && PlayerCfg.GuidedInBigWindow) y+=LINE_SPACING; for (i=startmsg; i<HUD_nmessages; i++ ) { gr_set_fontcolor( HUD_color, -1); if (i == startmsg && strlen(HUD_messages[i].message) > 38) HUD_toolong = 1; gr_printf(0x8000,y, &HUD_messages[i].message[0] ); y += LINE_SPACING; } } gr_set_curfont( GAME_FONT ); }
// ---------------------------------------------------------------------------- // Writes a message on the HUD and checks its timer. void HUD_render_message_frame() { int i,j,y; HUD_toolong = 0; if (( HUD_nmessages < 0 ) || (HUD_nmessages > HUD_MAX_NUM_STOR)) Int3(); // Get Rob! if (HUD_nmessages < 1 ) return; for (i = 0; i < HUD_nmessages; i++) { HUD_messages[i].time -= FrameTime; // message expired - remove if (HUD_messages[i].time <= 0) { for (j = i; j < HUD_nmessages; j++) { if (j+1 < HUD_nmessages) memcpy(&HUD_messages[j], &HUD_messages[j+1], sizeof(struct hudmsg)); else memset(&HUD_messages[j], 0, sizeof(struct hudmsg)); } HUD_nmessages--; } } // display last $HUD_MAX_NUM_DISP messages on the list if (HUD_nmessages > 0 ) { int startmsg = ((HUD_nmessages-HUD_MAX_NUM_DISP<0)?0:HUD_nmessages-HUD_MAX_NUM_DISP); if (HUD_color == -1) HUD_color = BM_XRGB(0,28,0); gr_set_curfont( GAME_FONT ); y = FSPACY(1); for (i=startmsg; i<HUD_nmessages; i++ ) { gr_set_fontcolor( HUD_color, -1); if (i == startmsg && strlen(HUD_messages[i].message) > 38) HUD_toolong = 1; gr_string(0x8000,y, &HUD_messages[i].message[0] ); y += LINE_SPACING; } } gr_set_curfont( GAME_FONT ); }
void game_draw_multi_message() { if ( (Game_mode&GM_MULTI) && (multi_sending_message[Player_num])) { gr_set_curfont(GAME_FONT); gr_set_fontcolor(BM_XRGB(0,63,0),-1); gr_printf(0x8000, (LINE_SPACING*5)+FSPACY(1), "%s: %s_", TXT_MESSAGE, Network_message ); } if ( (Game_mode&GM_MULTI) && (multi_defining_message)) { gr_set_curfont(GAME_FONT); gr_set_fontcolor(BM_XRGB(0,63,0),-1); gr_printf(0x8000, (LINE_SPACING*5)+FSPACY(1), "%s #%d: %s_", TXT_MACRO, multi_defining_message, Network_message ); } }
void texpage_init( UI_WINDOW * win ) { int i; ui_add_gadget_button( win, TMAPCURBOX_X + 00, TMAPCURBOX_Y - 24, 30, 20, "<<", texpage_goto_prev ); ui_add_gadget_button( win, TMAPCURBOX_X + 32, TMAPCURBOX_Y - 24, 30, 20, ">>", texpage_goto_next ); ui_add_gadget_button( win, TMAPCURBOX_X + 00, TMAPCURBOX_Y - 48, 15, 20, "T", texpage_goto_first ); ui_add_gadget_button( win, TMAPCURBOX_X + 17, TMAPCURBOX_Y - 48, 15, 20, "M", texpage_goto_metals ); ui_add_gadget_button( win, TMAPCURBOX_X + 34, TMAPCURBOX_Y - 48, 15, 20, "L", texpage_goto_lights ); ui_add_gadget_button( win, TMAPCURBOX_X + 51, TMAPCURBOX_Y - 48, 15, 20, "E", texpage_goto_effects ); for (i=0;i<TMAPS_PER_PAGE;i++) TmapBox[i] = ui_add_gadget_userbox( win, TMAPBOX_X + (i/3)*(2+TMAPBOX_W), TMAPBOX_Y + (i%3)*(2+TMAPBOX_H), TMAPBOX_W, TMAPBOX_H); TmapCurrent = ui_add_gadget_userbox( win, TMAPCURBOX_X, TMAPCURBOX_Y, 64, 64 ); TmapnameCanvas = gr_create_sub_canvas(&grd_curscreen->sc_canvas, TMAPCURBOX_X , TMAPCURBOX_Y + TMAPBOX_H + 10, 100, 20); gr_set_current_canvas( TmapnameCanvas ); gr_set_curfont( ui_small_font ); gr_set_fontcolor( CBLACK, CWHITE ); texpage_redraw(); // Don't reset the current tmap every time we go back to the editor. // CurrentTmap = TexturePage*TMAPS_PER_PAGE; // CurrentTexture = TmapList[CurrentTmap]; texpage_show_current(); }
//print to canvas & double height grs_canvas *print_to_canvas(char *s,grs_font *font, int fc, int bc) { int y; ubyte *data; int rs; grs_canvas *temp_canv,*save_canv; save_canv = grd_curcanv; temp_canv = gr_create_canvas(font->ft_w*strlen(s),font->ft_h*2); gr_set_current_canvas(temp_canv); gr_set_curfont(font); gr_clear_canvas(255); //trans color gr_set_fontcolor(fc,bc); gr_printf(0,0,s); //now double it, since we're drawing to 400-line modex screen data = temp_canv->cv_bitmap.bm_data; rs = temp_canv->cv_bitmap.bm_rowsize; for (y=temp_canv->cv_bitmap.bm_h/2;y--;) { memcpy(data+(rs*y*2),data+(rs*y),temp_canv->cv_bitmap.bm_w); memcpy(data+(rs*(y*2+1)),data+(rs*y),temp_canv->cv_bitmap.bm_w); } gr_set_current_canvas(save_canv); return temp_canv; }
void autodemo_menu_check(int nitems, newmenu_item * items, int *last_key, int citem ) { int curtime; nitems = nitems; items=items; citem = citem; //draw copyright message if ( Menu_draw_copyright ) { Menu_draw_copyright = 0; gr_set_current_canvas(NULL); gr_set_curfont(GAME_FONT); gr_set_fontcolor(BM_XRGB(6,6,6),-1); gr_printf(0x8000,grd_curcanv->cv_bitmap.bm_h-GAME_FONT->ft_h-2,TXT_COPYRIGHT); } // Don't allow them to hit ESC in the main menu. if (*last_key==KEY_ESC) *last_key = 0; if ( do_auto_demo ) { curtime = timer_get_approx_seconds(); //if ( ((keyd_time_when_last_pressed+i2f(20)) < curtime) && ((last_joy_time+i2f(20)) < curtime) && (!speedtest_on) ) { if ( ((keyd_time_when_last_pressed+i2f(45)) < curtime) && (!speedtest_on) ) { keyd_time_when_last_pressed = curtime; // Reset timer so that disk won't thrash if no demos. newdemo_start_playback(NULL); // Randomly pick a file if (Newdemo_state == ND_STATE_PLAYBACK) { Function_mode = FMODE_GAME; *last_key = -2; } } } }
void title_save_game() { grs_canvas * save_canv; grs_canvas * save_canv_data; grs_font * save_font; ubyte palette[768]; if ( Next_level_num == 0 ) return; save_canv = grd_curcanv; save_font = grd_curcanv->cv_font; save_canv_data = gr_create_canvas( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h ); gr_set_current_canvas(save_canv_data); gr_ubitmap(0,0,&save_canv->cv_bitmap); gr_set_current_canvas(save_canv); gr_clear_canvas(gr_find_closest_color_current( 0, 0, 0)); gr_palette_read( palette ); gr_palette_load( gr_palette ); #ifndef SHAREWARE state_save_all(1); #endif gr_palette_clear(); gr_set_current_canvas(save_canv); gr_ubitmap(0,0,&save_canv_data->cv_bitmap); gr_palette_load( palette ); gr_set_curfont(save_font); }
void show_framerate() { static int fps_count = 0, fps_rate = 0; int y = GHEIGHT; static fix64 fps_time = 0; gr_set_curfont(GAME_FONT); gr_set_fontcolor(BM_XRGB(0,31,0),-1); if (PlayerCfg.CockpitMode[1] == CM_FULL_SCREEN) { if ((Game_mode & GM_MULTI) || (Newdemo_state == ND_STATE_PLAYBACK && Newdemo_game_mode & GM_MULTI)) y -= LINE_SPACING * 10; else y -= LINE_SPACING * 4; } else if (PlayerCfg.CockpitMode[1] == CM_STATUS_BAR) { if ((Game_mode & GM_MULTI) || (Newdemo_state == ND_STATE_PLAYBACK && Newdemo_game_mode & GM_MULTI)) y -= LINE_SPACING * 6; else y -= LINE_SPACING * 1; } else { if ((Game_mode & GM_MULTI) || (Newdemo_state == ND_STATE_PLAYBACK && Newdemo_game_mode & GM_MULTI)) y -= LINE_SPACING * 7; else y -= LINE_SPACING * 2; } fps_count++; if (timer_query() >= fps_time + F1_0) { fps_rate = fps_count; fps_count = 0; fps_time = timer_query(); } gr_printf(SWIDTH-(GameArg.SysMaxFPS>999?FSPACX(43):FSPACX(37)),y,"FPS: %i",fps_rate); }
void render_countdown_gauge() { if (!Endlevel_sequence && Control_center_destroyed && (Countdown_seconds_left>-1) && (Countdown_seconds_left<127)) { gr_set_curfont(GAME_FONT); gr_set_fontcolor(BM_XRGB(0,63,0),-1); gr_printf(0x8000, (LINE_SPACING*6)+FSPACY(1), "T-%d s", Countdown_seconds_left ); } }
void game_draw_hud_stuff() { #ifdef CROSSHAIR if ( Viewer->type == OBJ_PLAYER ) laser_do_crosshair(Viewer); #endif #ifndef NDEBUG draw_window_label(); #endif #ifdef NETWORK game_draw_multi_message(); #endif if ((Newdemo_state == ND_STATE_PLAYBACK) || (Newdemo_state == ND_STATE_RECORDING)) { char message[128]; int y; if (Newdemo_state == ND_STATE_PLAYBACK) { if (Newdemo_show_percentage) { sprintf(message, "%s (%d%%%% %s)", TXT_DEMO_PLAYBACK, newdemo_get_percent_done(), TXT_DONE); } else { sprintf (message, " "); } } else { extern int Newdemo_num_written; sprintf (message, "%s (%dK)", TXT_DEMO_RECORDING, (Newdemo_num_written / 1024)); } gr_set_curfont( GAME_FONT ); gr_set_fontcolor( BM_XRGB(27,0,0), -1 ); y = GHEIGHT-(LINE_SPACING*2); if (PlayerCfg.CockpitMode[1] == CM_FULL_COCKPIT) y = grd_curcanv->cv_bitmap.bm_h / 1.2 ; if (PlayerCfg.CockpitMode[1] != CM_REAR_VIEW) gr_string(0x8000, y, message ); } render_countdown_gauge(); if (GameCfg.FPSIndicator && PlayerCfg.CockpitMode[1] != CM_REAR_VIEW) show_framerate(); if (Newdemo_state == ND_STATE_PLAYBACK) Game_mode = Newdemo_game_mode; draw_hud(); if (Newdemo_state == ND_STATE_PLAYBACK) Game_mode = GM_NORMAL; if ( Player_is_dead ) player_dead_message(); }
static void con_draw(void) { int i = 0, y = 0, done = 0; if (con_size <= 0) return; gr_set_current_canvas(NULL); gr_set_curfont(GAME_FONT); gr_setcolor(BM_XRGB(0,0,0)); gr_settransblend(7, GR_BLEND_NORMAL); gr_rect(0,0,SWIDTH,(LINE_SPACING*(con_size))+FSPACY(1)); gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL); y=FSPACY(1)+(LINE_SPACING*con_size); i+=con_scroll_offset; { cxx_con_interactive_print(&y); if (y<=0) done=1; } while (!done) { int w,h,aw; switch (con_buffer[CON_LINES_MAX-1-i].priority) { case CON_CRITICAL: gr_set_fontcolor(BM_XRGB(28,0,0),-1); break; case CON_URGENT: gr_set_fontcolor(BM_XRGB(54,54,0),-1); break; case CON_DEBUG: case CON_VERBOSE: gr_set_fontcolor(BM_XRGB(14,14,14),-1); break; case CON_HUD: gr_set_fontcolor(BM_XRGB(0,28,0),-1); break; default: gr_set_fontcolor(BM_XRGB(255,255,255),-1); break; } gr_get_string_size(con_buffer[CON_LINES_MAX-1-i].line,&w,&h,&aw); y-=h+FSPACY(1); gr_string(FSPACX(1),y,con_buffer[CON_LINES_MAX-1-i].line); i++; if (y<=0 || CON_LINES_MAX-1-i <= 0 || i < 0) done=1; } gr_setcolor(BM_XRGB(0,0,0)); gr_rect(0,0,SWIDTH,LINE_SPACING); gr_set_fontcolor(BM_XRGB(255,255,255),-1); gr_printf(FSPACX(1),FSPACY(1),"%s LOG", DESCENT_VERSION); gr_string(SWIDTH-FSPACX(110),FSPACY(1),"PAGE-UP/DOWN TO SCROLL"); }
void print_status_bar( char message[DIAGNOSTIC_MESSAGE_MAX] ) { int w,h,aw; gr_set_current_canvas( NULL ); gr_set_curfont(editor_font); gr_set_fontcolor( CBLACK, CGREY ); gr_get_string_size( message, &w, &h, &aw ); gr_string( 4, 583, message ); gr_set_fontcolor( CBLACK, CWHITE ); gr_setcolor( CGREY ); gr_rect( 4+w, 583, 799, 599 ); }
void player_dead_message(void) { if (Player_exploded) { // gr_set_curfont( Gamefonts[GFONT_SMALL] ); gr_set_curfont( GAME_FONT ); if (HUD_color == -1) HUD_color = BM_XRGB(0,28,0); gr_set_fontcolor( HUD_color, -1); gr_printf(0x8000, grd_curcanv->cv_bitmap.bm_h-(GAME_FONT->ft_h+3), TXT_PRESS_ANY_KEY);//was -8 // gr_set_curfont( GAME_FONT ); } }
void name_frame(automap *am) { char name_level[128]; if (Current_level_num > 0) sprintf(name_level, "%s %i: ",TXT_LEVEL, Current_level_num); else name_level[0] = 0; strcat(name_level, Current_level_name); gr_set_curfont(GAME_FONT); gr_set_fontcolor(am->green_31,-1); gr_printf((SWIDTH/64),(SHEIGHT/48),"%s", name_level); }
void editor_sub_status( const char *format, ... ) { int w,h,aw; va_list ap; va_start(ap, format); vsprintf(sub_status_line, format, ap); va_end(ap); gr_set_current_canvas( NULL ); gr_set_curfont(editor_font); gr_set_fontcolor( BM_XRGB(0,0,31), CGREY ); gr_get_string_size( sub_status_line, &w, &h, &aw ); gr_string( 500, 583, sub_status_line ); gr_set_fontcolor( CBLACK, CWHITE ); gr_setcolor( CGREY ); gr_rect( 500+w, 583, 799, 599 ); }
static void con_draw(void) { int i = 0, y = 0; if (con_size <= 0) return; gr_set_default_canvas(); auto &canvas = *grd_curcanv; auto &game_font = *GAME_FONT; gr_set_curfont(canvas, GAME_FONT); const uint8_t color = BM_XRGB(0, 0, 0); gr_settransblend(canvas, 7, GR_BLEND_NORMAL); const auto &&fspacy1 = FSPACY(1); const auto &&line_spacing = LINE_SPACING(*canvas.cv_font, *GAME_FONT); y = fspacy1 + (line_spacing * con_size); gr_rect(canvas, 0, 0, SWIDTH, y, color); gr_settransblend(canvas, GR_FADE_OFF, GR_BLEND_NORMAL); i+=con_scroll_offset; gr_set_fontcolor(canvas, BM_XRGB(255, 255, 255), -1); y = cli_draw(y, line_spacing); const auto &&fspacx = FSPACX(); const auto &&fspacx1 = fspacx(1); for (;;) { auto &b = con_buffer[CON_LINES_MAX - 1 - i]; gr_set_fontcolor(canvas, get_console_color_by_priority(b.priority), -1); int w,h; gr_get_string_size(game_font, b.line, &w, &h, nullptr); y -= h + fspacy1; gr_string(canvas, game_font, fspacx1, y, b.line, w, h); i++; if (y<=0 || CON_LINES_MAX-1-i <= 0 || i < 0) break; } gr_rect(canvas, 0, 0, SWIDTH, line_spacing, color); gr_set_fontcolor(canvas, BM_XRGB(255, 255, 255),-1); gr_printf(canvas, game_font, fspacx1, fspacy1, "%s LOG", DESCENT_VERSION); gr_string(canvas, game_font, SWIDTH - fspacx(110), fspacy1, "PAGE-UP/DOWN TO SCROLL"); }
//show a message in a nice little box void show_boxed_message(char *msg, int RenderFlag) { int w,h,aw; int x,y; gr_set_current_canvas(NULL); gr_set_curfont( MEDIUM1_FONT ); gr_set_fontcolor(BM_XRGB(31, 31, 31), -1); gr_get_string_size(msg,&w,&h,&aw); x = (SWIDTH-w)/2; y = (SHEIGHT-h)/2; nm_draw_background(x-BORDERX,y-BORDERY,x+w+BORDERX,y+h+BORDERY); gr_printf( 0x8000, y, msg ); // If we haven't drawn behind it, need to flip if (!RenderFlag) gr_flip(); }
void name_frame(automap *am) { char name_level_left[128],name_level_right[128]; int wr,h,aw; if (Current_level_num > 0) sprintf(name_level_left, "%s %i",TXT_LEVEL, Current_level_num); else sprintf(name_level_left, "Secret Level %i",-Current_level_num); if (PLAYING_BUILTIN_MISSION && Current_level_num > 0) sprintf(name_level_right,"%s %d: ",system_name[(Current_level_num-1)/4],((Current_level_num-1)%4)+1); else strcpy(name_level_right, " "); strcat(name_level_right, Current_level_name); gr_set_curfont(GAME_FONT); gr_set_fontcolor(am->green_31,-1); gr_printf((SWIDTH/64),(SHEIGHT/48),"%s", name_level_left); gr_get_string_size(name_level_right,&wr,&h,&aw); gr_printf(grd_curcanv->cv_bitmap.bm_w-wr-(SWIDTH/64),(SHEIGHT/48),"%s", name_level_right); }
void draw_window_label() { if ( Show_view_text_timer > 0 ) { char *viewer_name,*control_name; Show_view_text_timer -= FrameTime; switch( Viewer->type ) { case OBJ_FIREBALL: viewer_name = "Fireball"; break; case OBJ_ROBOT: viewer_name = "Robot"; break; case OBJ_HOSTAGE: viewer_name = "Hostage"; break; case OBJ_PLAYER: viewer_name = "Player"; break; case OBJ_WEAPON: viewer_name = "Weapon"; break; case OBJ_CAMERA: viewer_name = "Camera"; break; case OBJ_POWERUP: viewer_name = "Powerup"; break; case OBJ_DEBRIS: viewer_name = "Debris"; break; case OBJ_CNTRLCEN: viewer_name = "Control Center"; break; default: viewer_name = "Unknown"; break; } switch ( Viewer->control_type) { case CT_NONE: control_name = "Stopped"; break; case CT_AI: control_name = "AI"; break; case CT_FLYING: control_name = "Flying"; break; case CT_SLEW: control_name = "Slew"; break; case CT_FLYTHROUGH: control_name = "Flythrough"; break; case CT_MORPH: control_name = "Morphing"; break; default: control_name = "Unknown"; break; } gr_set_curfont( GAME_FONT ); gr_set_fontcolor( BM_XRGB(31, 0, 0), -1 ); gr_printf( 0x8000, (SHEIGHT/10), "%s View - %s",viewer_name,control_name ); } }
void game_draw_hud_stuff() { #ifdef CROSSHAIR if ( Viewer->type == OBJ_PLAYER ) laser_do_crosshair(Viewer); #endif #ifndef NDEBUG draw_window_label(); #endif #ifdef NETWORK game_draw_multi_message(); #endif if ((Newdemo_state == ND_STATE_PLAYBACK) || (Newdemo_state == ND_STATE_RECORDING)) { char message[128]; int y; if (Newdemo_state == ND_STATE_PLAYBACK) { if (Newdemo_show_percentage) { sprintf(message, "%s (%d%%%% %s)", TXT_DEMO_PLAYBACK, newdemo_get_percent_done(), TXT_DONE); } else { sprintf (message, " "); } } else { extern int Newdemo_num_written; sprintf (message, "%s (%dK)", TXT_DEMO_RECORDING, (Newdemo_num_written / 1024)); } gr_set_curfont( GAME_FONT ); gr_set_fontcolor( BM_XRGB(27,0,0), -1 ); y = GHEIGHT-(LINE_SPACING*2); if (PlayerCfg.CockpitMode[1] == CM_FULL_COCKPIT) y = grd_curcanv->cv_bitmap.bm_h / 1.2 ; if (PlayerCfg.CockpitMode[1] != CM_REAR_VIEW) gr_printf(0x8000, y, message ); } render_countdown_gauge(); render_spec_status(); // jinx 02-01-13 spec // this should be made part of hud code some day if (( Player_num > -1 && Viewer->type==OBJ_PLAYER && Viewer->id==Player_num && PlayerCfg.CockpitMode[1] != CM_REAR_VIEW) || ((Players[Player_num].spec_flags & PLAYER_FLAGS_SPECTATING) && in_free)) { int x = FSPACX(1); int y = grd_curcanv->cv_bitmap.bm_h; gr_set_curfont( GAME_FONT ); gr_set_fontcolor( BM_XRGB(0, 31, 0), -1 ); if ((Cruise_speed > 0) || ((Players[Player_num].spec_flags & PLAYER_FLAGS_SPECTATING) && in_free)) { if (PlayerCfg.CockpitMode[1]==CM_FULL_SCREEN) { if (Game_mode & GM_MULTI) y -= LINE_SPACING * 10; else y -= LINE_SPACING * 6; } else if (PlayerCfg.CockpitMode[1] == CM_STATUS_BAR) { if (Game_mode & GM_MULTI) y -= LINE_SPACING * 6; else y -= LINE_SPACING * 1; } else { if (Game_mode & GM_MULTI) y -= LINE_SPACING * 7; else y -= LINE_SPACING * 2; } if (Players[Player_num].spec_flags & PLAYER_FLAGS_SPECTATING) gr_printf( x, y, "Free Fly Speed %2d%%", 100 + f2i((Cruise_speed))); // f2i(100 + (Cruise_speed / SPEC_SPEED_MOD))); else gr_printf( x, y, "%s %2d%%", TXT_CRUISE, f2i(Cruise_speed) ); } } if (GameCfg.FPSIndicator && PlayerCfg.CockpitMode[1] != CM_REAR_VIEW) show_framerate(); if (Newdemo_state == ND_STATE_PLAYBACK) Game_mode = Newdemo_game_mode; draw_hud(); if (Newdemo_state == ND_STATE_PLAYBACK) Game_mode = GM_NORMAL; if ( Player_is_dead ) player_dead_message(); }
void show_netplayerinfo() { int x=0, y=0, i=0, color=0; gr_set_current_canvas(NULL); gr_set_curfont(GAME_FONT); gr_set_fontcolor(255,-1); x=(SWIDTH/2)-FSPACX(120); y=(SHEIGHT/2)-FSPACY(84); gr_settransblend(14, GR_BLEND_NORMAL); gr_setcolor( BM_XRGB(0,0,0) ); gr_rect((SWIDTH/2)-FSPACX(120),(SHEIGHT/2)-FSPACY(84),(SWIDTH/2)+FSPACX(120),(SHEIGHT/2)+FSPACY(84)); gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL); // general game information y+=LINE_SPACING; gr_printf(0x8000,y,"%s",Netgame.game_name); #ifndef SHAREWARE y+=LINE_SPACING; gr_printf(0x8000,y,"%s - lvl: %i",Netgame.mission_title,Netgame.levelnum); #endif x+=FSPACX(8); y+=LINE_SPACING*2; gr_printf(x,y,"game mode: %s",GMNames[Netgame.gamemode]); y+=LINE_SPACING; gr_printf(x,y,"difficulty: %s",MENU_DIFFICULTY_TEXT(Netgame.difficulty)); y+=LINE_SPACING; gr_printf(x,y,"level time: %i:%02i:%02i",Players[Player_num].hours_level,f2i(Players[Player_num].time_level) / 60 % 60,f2i(Players[Player_num].time_level) % 60); y+=LINE_SPACING; gr_printf(x,y,"total time: %i:%02i:%02i",Players[Player_num].hours_total,f2i(Players[Player_num].time_total) / 60 % 60,f2i(Players[Player_num].time_total) % 60); y+=LINE_SPACING; if (Netgame.KillGoal) gr_printf(x,y,"Kill goal: %d",Netgame.KillGoal*5); // player information (name, kills, ping, game efficiency) y+=LINE_SPACING*2; gr_printf(x,y,"player"); if (Game_mode & GM_MULTI_COOP) gr_printf(x+FSPACX(8)*7,y,"score"); else { gr_printf(x+FSPACX(8)*7,y,"kills"); gr_printf(x+FSPACX(8)*12,y,"deaths"); } gr_printf(x+FSPACX(8)*18,y,"ping"); gr_printf(x+FSPACX(8)*23,y,"efficiency"); // process players table for (i=0; i<MAX_PLAYERS; i++) { if (!Players[i].connected) continue; y+=LINE_SPACING; if (Game_mode & GM_TEAM) color=get_team(i); else color=i; gr_set_fontcolor(BM_XRGB(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 ); gr_printf(x,y,"%s\n",Players[i].callsign); if (Game_mode & GM_MULTI_COOP) gr_printf(x+FSPACX(8)*7,y,"%-6d",Players[i].score); else { gr_printf(x+FSPACX(8)*7,y,"%-6d",Players[i].net_kills_total); gr_printf(x+FSPACX(8)*12,y,"%-6d",Players[i].net_killed_total); } gr_printf(x+FSPACX(8)*18,y,"%-6d",Netgame.players[i].ping); if (i != Player_num) gr_printf(x+FSPACX(8)*23,y,"%d/%d",kill_matrix[Player_num][i],kill_matrix[i][Player_num]); } y+=LINE_SPACING*2+(LINE_SPACING*(MAX_PLAYERS-N_players)); // printf team scores if (Game_mode & GM_TEAM) { gr_set_fontcolor(255,-1); gr_printf(x,y,"team"); gr_printf(x+FSPACX(8)*8,y,"score"); y+=LINE_SPACING; gr_set_fontcolor(BM_XRGB(player_rgb[get_team(0)].r,player_rgb[get_team(0)].g,player_rgb[get_team(0)].b),-1 ); gr_printf(x,y,"%s:",Netgame.team_name[0]); gr_printf(x+FSPACX(8)*8,y,"%i",team_kills[0]); y+=LINE_SPACING; gr_set_fontcolor(BM_XRGB(player_rgb[get_team(1)].r,player_rgb[get_team(1)].g,player_rgb[get_team(1)].b),-1 ); gr_printf(x,y,"%s:",Netgame.team_name[1]); gr_printf(x+FSPACX(8)*8,y,"%i",team_kills[1]); y+=LINE_SPACING*2; } }
void draw_automap(automap *am) { int i; int color; object * objp; g3s_point sphere_point; if ( am->leave_mode==0 && am->controls.automap_state && (timer_query()-am->entry_time)>LEAVE_TIME) am->leave_mode = 1; gr_set_current_canvas(NULL); show_fullscr(&am->automap_background); gr_set_curfont(HUGE_FONT); gr_set_fontcolor(BM_XRGB(20, 20, 20), -1); gr_string((SWIDTH/8), (SHEIGHT/16), TXT_AUTOMAP); gr_set_curfont(GAME_FONT); gr_set_fontcolor(BM_XRGB(20, 20, 20), -1); gr_string((SWIDTH/10.666), (SHEIGHT/1.126), TXT_TURN_SHIP); gr_printf((SWIDTH/10.666), (SHEIGHT/1.083), "F9/F10 Changes viewing distance"); gr_string((SWIDTH/10.666), (SHEIGHT/1.043), TXT_AUTOMAP_MARKER); gr_set_current_canvas(&am->automap_view); gr_clear_canvas(BM_XRGB(0,0,0)); g3_start_frame(); render_start_frame(); if (!PlayerCfg.AutomapFreeFlight) vm_vec_scale_add(&am->view_position,&am->view_target,&am->viewMatrix.fvec,-am->viewDist); g3_set_view_matrix(&am->view_position,&am->viewMatrix,am->zoom); draw_all_edges(am); selected_player_rgb = player_rgb; // Draw player... #ifdef NETWORK if(Netgame.BlackAndWhitePyros) selected_player_rgb = player_rgb_alt; if (Game_mode & GM_TEAM) color = get_team(Player_num); else #endif color = Player_num; // Note link to above if! gr_setcolor(BM_XRGB(selected_player_rgb[color].r,selected_player_rgb[color].g,selected_player_rgb[color].b)); draw_player(&Objects[Players[Player_num].objnum]); DrawMarkers(am); // 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(BM_XRGB(selected_player_rgb[color].r,selected_player_rgb[color].g,selected_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(am->hostage_color); 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(BM_XRGB(63, 5, 5)); break; case POW_KEY_BLUE: gr_setcolor(BM_XRGB(5, 5, 63)); break; case POW_KEY_GOLD: gr_setcolor(BM_XRGB(63, 63, 10)); break; default: Error("Illegal key type: %i", objp->id); } g3_rotate_point(&sphere_point,&objp->pos); g3_draw_sphere(&sphere_point,objp->size*4); } } break; } } g3_end_frame(); name_frame(am); if (HighlightMarker>-1 && MarkerMessage[HighlightMarker][0]!=0) { char msg[10+MARKER_MESSAGE_LEN+1]; sprintf(msg,"Marker %d: %s",HighlightMarker+1,MarkerMessage[(Player_num*2)+HighlightMarker]); gr_printf((SWIDTH/64),(SHEIGHT/18),"%s", msg); } if ((PlayerCfg.MouseControlStyle == MOUSE_CONTROL_FLIGHT_SIM) && PlayerCfg.MouseFSIndicator) show_mousefs_indicator(am->controls.raw_mouse_axis[0], am->controls.raw_mouse_axis[1], am->controls.raw_mouse_axis[2], GWIDTH-(GHEIGHT/8), GHEIGHT-(GHEIGHT/8), GHEIGHT/5); am->t2 = timer_query(); while (am->t2 - am->t1 < F1_0 / (GameCfg.VSync?MAXIMUM_FPS:GameArg.SysMaxFPS)) // ogl is fast enough that the automap can read the input too fast and you start to turn really slow. So delay a bit (and free up some cpu :) { if (GameArg.SysUseNiceFPS && !GameCfg.VSync) timer_delay(f1_0 / GameArg.SysMaxFPS - (am->t2 - am->t1)); timer_update(); am->t2 = timer_query(); } if (am->pause_game) { FrameTime=am->t2-am->t1; calc_d_tick(); } am->t1 = am->t2; }
int piggy_init() { int sbytes = 0; char temp_name_read[16]; char temp_name[16]; grs_bitmap temp_bitmap; digi_sound temp_sound; DiskBitmapHeader bmh; DiskSoundHeader sndh; int header_size, N_bitmaps, N_sounds; int i,size, length, x, y; char * filename; int read_sounds = 1; int Pigdata_start; hashtable_init( &AllBitmapsNames, MAX_BITMAP_FILES ); hashtable_init( &AllDigiSndNames, MAX_SOUND_FILES ); if ( FindArg( "-nosound" ) || (digi_driver_board<1) ) { read_sounds = 0; mprintf(( 0, "Not loading sound data!!!!!\n" )); } for (i=0; i<MAX_SOUND_FILES; i++ ) { GameSounds[i].length = 0; GameSounds[i].data = NULL; SoundOffset[i] = 0; } for (i=0; i<MAX_BITMAP_FILES; i++ ) { GameBitmapXlat[i] = i; GameBitmaps[i].bm_flags = BM_FLAG_PAGED_OUT; } if ( !bogus_bitmap_initialized ) { int i; ubyte c; bogus_bitmap_initialized = 1; memset( &bogus_bitmap, 0, sizeof(grs_bitmap) ); bogus_bitmap.bm_w = bogus_bitmap.bm_h = bogus_bitmap.bm_rowsize = 64; bogus_bitmap.bm_data = bogus_data; c = gr_find_closest_color( 0, 0, 63 ); for (i=0; i<4096; i++ ) bogus_data[i] = c; c = gr_find_closest_color( 63, 0, 0 ); // Make a big red X ! for (i=0; i<64; i++ ) { bogus_data[i*64+i] = c; bogus_data[i*64+(63-i)] = c; } piggy_register_bitmap( &bogus_bitmap, "bogus", 1 ); bogus_sound.length = 64*64; bogus_sound.data = bogus_data; GameBitmapOffset[0] = 0; } filename = "DESCENT.PIG"; if ( FindArg( "-bigpig" )) BigPig = 1; if ( FindArg( "-lowmem" )) piggy_low_memory = 1; if ( FindArg( "-nolowmem" )) piggy_low_memory = 0; if (piggy_low_memory) digi_lomem = 1; if ( (i=FindArg( "-piggy" )) ) { filename = Args[i+1]; mprintf( (0, "Using alternate pigfile, '%s'\n", filename )); } Piggy_fp = cfopen( filename, "rb" ); if (Piggy_fp==NULL) return 0; cfread( &Pigdata_start, sizeof(int), 1, Piggy_fp ); #ifdef EDITOR if ( FindArg("-nobm") ) #endif { bm_read_all( Piggy_fp ); // Note connection to above if!!! cfread( GameBitmapXlat, sizeof(ushort)*MAX_BITMAP_FILES, 1, Piggy_fp ); } cfseek( Piggy_fp, Pigdata_start, SEEK_SET ); size = cfilelength(Piggy_fp) - Pigdata_start; length = size; mprintf( (0, "\nReading data (%d KB) ", size/1024 )); cfread( &N_bitmaps, sizeof(int), 1, Piggy_fp ); size -= sizeof(int); cfread( &N_sounds, sizeof(int), 1, Piggy_fp ); size -= sizeof(int); header_size = (N_bitmaps*sizeof(DiskBitmapHeader)) + (N_sounds*sizeof(DiskSoundHeader)); x = 60; y = 189 * f2fl(Scale_y); gr_set_curfont( Gamefonts[GFONT_SMALL] ); gr_set_fontcolor(gr_find_closest_color_current( 20, 20, 20 ),-1 ); gr_scale_printf( 0x8000, y-10*f2fl(Scale_y), Scale_factor, Scale_factor, "%s...", TXT_LOADING_DATA ); #ifdef OGLES showRenderBuffer(); #endif for (i=0; i<N_bitmaps; i++ ) { cfread( &bmh, sizeof(DiskBitmapHeader), 1, Piggy_fp ); //size -= sizeof(DiskBitmapHeader); memcpy( temp_name_read, bmh.name, 8 ); temp_name_read[8] = 0; if ( bmh.dflags & DBM_FLAG_ABM ) sprintf( temp_name, "%s#%d", temp_name_read, bmh.dflags & 63 ); else strcpy( temp_name, temp_name_read ); memset( &temp_bitmap, 0, sizeof(grs_bitmap) ); if ( bmh.dflags & DBM_FLAG_LARGE ) temp_bitmap.bm_w = temp_bitmap.bm_rowsize = bmh.width+256; else temp_bitmap.bm_w = temp_bitmap.bm_rowsize = bmh.width; temp_bitmap.bm_h = bmh.height; temp_bitmap.bm_flags = BM_FLAG_PAGED_OUT; temp_bitmap.avg_color = bmh.avg_color; temp_bitmap.bm_data = Piggy_bitmap_cache_data; #ifdef OGLES temp_bitmap.bm_ogles_tex_id = 0; #endif GameBitmapFlags[i+1] = 0; if ( bmh.flags & BM_FLAG_TRANSPARENT ) GameBitmapFlags[i+1] |= BM_FLAG_TRANSPARENT; if ( bmh.flags & BM_FLAG_SUPER_TRANSPARENT ) GameBitmapFlags[i+1] |= BM_FLAG_SUPER_TRANSPARENT; if ( bmh.flags & BM_FLAG_NO_LIGHTING ) GameBitmapFlags[i+1] |= BM_FLAG_NO_LIGHTING; if ( bmh.flags & BM_FLAG_RLE ) GameBitmapFlags[i+1] |= BM_FLAG_RLE; GameBitmapOffset[i+1] = bmh.offset + header_size + (sizeof(int)*2) + Pigdata_start; Assert( (i+1) == Num_bitmap_files ); piggy_register_bitmap( &temp_bitmap, temp_name, 1 ); } for (i=0; i<N_sounds; i++ ) { cfread( &sndh, sizeof(DiskSoundHeader), 1, Piggy_fp ); //size -= sizeof(DiskSoundHeader); temp_sound.length = sndh.length; temp_sound.data = (ubyte *)(sndh.offset + header_size + (sizeof(int)*2)+Pigdata_start); SoundOffset[Num_sound_files] = sndh.offset + header_size + (sizeof(int)*2)+Pigdata_start; memcpy( temp_name_read, sndh.name, 8 ); temp_name_read[8] = 0; piggy_register_sound( &temp_sound, temp_name_read, 1 ); sbytes += sndh.length; //mprintf(( 0, "%d bytes of sound\n", sbytes )); } SoundBits = malloc( sbytes + 16 ); if ( SoundBits == NULL ) Error( "Not enough memory to load DESCENT.PIG sounds\n" ); #ifdef EDITOR Piggy_bitmap_cache_size = size - header_size - sbytes + 16; Assert( Piggy_bitmap_cache_size > 0 ); #else Piggy_bitmap_cache_size = PIGGY_BUFFER_SIZE; #endif BitmapBits = malloc( Piggy_bitmap_cache_size ); if ( BitmapBits == NULL ) Error( "Not enough memory to load DESCENT.PIG bitmaps\n" ); Piggy_bitmap_cache_data = BitmapBits; Piggy_bitmap_cache_next = 0; mprintf(( 0, "\nBitmaps: %d KB Sounds: %d KB\n", Piggy_bitmap_cache_size/1024, sbytes/1024 )); atexit(piggy_close_file); // mprintf( (0, "<<<<Paging in all piggy bitmaps...>>>>>" )); // for (i=0; i < Num_bitmap_files; i++ ) { // bitmap_index bi; // bi.index = i; // PIGGY_PAGE_IN( bi ); // } // mprintf( (0, "\n (USed %d / %d KB)\n", Piggy_bitmap_cache_next/1024, (size - header_size - sbytes + 16)/1024 )); // key_getch(); return 0; }
//setup the editors windows, canvases, gadgets, etc. void init_editor_screen() { // grs_bitmap * bmp; if (editor_screen_open) return; grd_curscreen->sc_canvas.cv_font = editor_font; //create canvas for game on the editor screen initializing = 1; gr_set_current_canvas(Canv_editor); Canv_editor->cv_font = editor_font; gr_init_sub_canvas(Canv_editor_game,Canv_editor,GAMEVIEW_X,GAMEVIEW_Y,GAMEVIEW_W,GAMEVIEW_H); //Editor renders into full (320x200) game screen init_info = 1; //do other editor screen setup // Since the palette might have changed, find some good colors... CBLACK = gr_find_closest_color( 1, 1, 1 ); CGREY = gr_find_closest_color( 28, 28, 28 ); CWHITE = gr_find_closest_color( 38, 38, 38 ); CBRIGHT = gr_find_closest_color( 60, 60, 60 ); CRED = gr_find_closest_color( 63, 0, 0 ); gr_set_curfont(editor_font); gr_set_fontcolor( CBLACK, CWHITE ); EditorWindow = ui_create_dialog( 0 , 0, ED_SCREEN_W, ED_SCREEN_H, DF_FILLED, editor_handler, NULL ); LargeViewBox = ui_add_gadget_userbox( EditorWindow,LVIEW_X,LVIEW_Y,LVIEW_W,LVIEW_H); #if ORTHO_VIEWS TopViewBox = ui_add_gadget_userbox( EditorWindow,TVIEW_X,TVIEW_Y,TVIEW_W,TVIEW_H); FrontViewBox = ui_add_gadget_userbox( EditorWindow,FVIEW_X,FVIEW_Y,FVIEW_W,FVIEW_H); RightViewBox = ui_add_gadget_userbox( EditorWindow,RVIEW_X,RVIEW_Y,RVIEW_W,RVIEW_H); #endif ui_gadget_calc_keys(EditorWindow); //make tab work for all windows GameViewBox = ui_add_gadget_userbox( EditorWindow, GAMEVIEW_X, GAMEVIEW_Y, GAMEVIEW_W, GAMEVIEW_H ); // GroupViewBox = ui_add_gadget_userbox( EditorWindow,GVIEW_X,GVIEW_Y,GVIEW_W,GVIEW_H); // GameViewBox->when_tab = GameViewBox->when_btab = (UI_GADGET *) LargeViewBox; // LargeViewBox->when_tab = LargeViewBox->when_btab = (UI_GADGET *) GameViewBox; // ui_gadget_calc_keys(EditorWindow); //make tab work for all windows ViewIcon = ui_add_gadget_icon( EditorWindow, "Lock\nview", 455,25+530, 40, 22, KEY_V+KEY_CTRLED, ToggleLockViewToCursegp ); AllIcon = ui_add_gadget_icon( EditorWindow, "Draw\nall", 500,25+530, 40, 22, -1, ToggleDrawAllSegments ); AxesIcon = ui_add_gadget_icon( EditorWindow, "Coord\naxes",545,25+530, 40, 22, KEY_D+KEY_CTRLED, ToggleCoordAxes ); //-NOLIGHTICON- LightIcon = ui_add_gadget_icon( EditorWindow, "Light\ning", 590,25+530, 40, 22, KEY_L+KEY_SHIFTED,ToggleLighting ); ChaseIcon = ui_add_gadget_icon( EditorWindow, "Chase\nmode",635,25+530, 40, 22, -1, ToggleChaseMode ); OutlineIcon = ui_add_gadget_icon( EditorWindow, "Out\nline", 680,25+530, 40, 22, KEY_O+KEY_CTRLED, ToggleOutlineMode ); LockIcon = ui_add_gadget_icon( EditorWindow, "Lock\nstep", 725,25+530, 40, 22, KEY_L+KEY_CTRLED, ToggleLockstep ); meddraw_init_views(LargeViewBox->canvas); //ui_add_gadget_button( EditorWindow, 460, 510, 50, 25, "Quit", ExitEditor ); //ui_add_gadget_button( EditorWindow, 520, 510, 50, 25, "Lisp", CallLisp ); //ui_add_gadget_button( EditorWindow, 580, 510, 50, 25, "Mine", MineMenu ); //ui_add_gadget_button( EditorWindow, 640, 510, 50, 25, "Help", DoHelp ); //ui_add_gadget_button( EditorWindow, 460, 540, 50, 25, "Macro", MacroMenu ); //ui_add_gadget_button( EditorWindow, 520, 540, 50, 25, "About", ShowAbout ); //ui_add_gadget_button( EditorWindow, 640, 540, 50, 25, "Shell", DosShell ); ui_pad_activate( EditorWindow, PAD_X, PAD_Y ); Pad_info = info_window_create(); ui_add_gadget_button( EditorWindow, PAD_X+6, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "<<", med_keypad_goto_prev ); ui_add_gadget_button( EditorWindow, PAD_X+PAD_WIDTH1+6, PAD_Y+(30*5)+22, PAD_WIDTH, 20, ">>", med_keypad_goto_next ); { int i; i = 0; ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "SR", med_keypad_goto_0 ); i++; ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "SS", med_keypad_goto_1 ); i++; ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "CF", med_keypad_goto_2 ); i++; ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "TM", med_keypad_goto_3 ); i++; ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "OP", med_keypad_goto_4 ); i++; ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "OR", med_keypad_goto_5 ); i++; ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "GE", med_keypad_goto_6 ); i++; ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "LI", med_keypad_goto_7 ); i++; ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "TT", med_keypad_goto_8 ); } gr_set_curfont(editor_font); menubar_show(); // INIT TEXTURE STUFF texpage_init( EditorWindow ); objpage_init( EditorWindow ); EditorWindow->keyboard_focus_gadget = (UI_GADGET *)LargeViewBox; // BigCanvas[0]->cv_font = grd_curscreen->sc_canvas.cv_font; // BigCanvas[1]->cv_font = grd_curscreen->sc_canvas.cv_font; // BigCanvasFirstTime = 1; Update_flags = UF_ALL; initializing = 0; editor_screen_open = 1; }
void init_editor() { void med_show_warning(char *s); // first, make sure we can find the files we need PHYSFSX_addRelToSearchPath("editor/data", 1); // look in source directory first (for work in progress) PHYSFSX_addRelToSearchPath("editor", 1); // then in editor directory PHYSFSX_addRelToSearchPath("editor.zip", 1); // then in a zip file PHYSFSX_addRelToSearchPath("editor.dxa", 1); // or addon pack ui_init(); init_med_functions(); // Must be called before medlisp_init ui_pad_read( 0, "segmove.pad" ); ui_pad_read( 1, "segsize.pad" ); ui_pad_read( 2, "curve.pad" ); ui_pad_read( 3, "texture.pad" ); ui_pad_read( 4, "object.pad" ); ui_pad_read( 5, "objmov.pad" ); ui_pad_read( 6, "group.pad" ); ui_pad_read( 7, "lighting.pad" ); ui_pad_read( 8, "test.pad" ); medkey_init(); game_flush_inputs(); editor_font = gr_init_font( "pc8x16.fnt" ); menubar_init( "MED.MNU" ); Draw_all_segments = 1; // Say draw all segments, not just connected ones if (!Cursegp) Cursegp = &Segments[0]; init_autosave(); // atexit(close_editor); Clear_window = 1; // do full window clear. InitCurve(); restore_effect_bitmap_icons(); if (!set_screen_mode(SCREEN_EDITOR)) { set_screen_mode(SCREEN_MENU); show_menus(); //force back into menu return; } load_palette(Current_level_palette,1,0); //Editor renders into full (320x200) game screen game_init_render_buffers(320, 200); gr_init_sub_canvas( &_canv_editor, &grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT ); Canv_editor = &_canv_editor; gr_set_current_canvas( Canv_editor ); init_editor_screen(); // load the main editor dialog gr_set_current_canvas( NULL ); gr_set_curfont(editor_font); set_warn_func(med_show_warning); // _MARK_("start of editor");//Nuked to compile -KRB //@@ //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); init_player_object(); Update_flags = UF_ALL; //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 ); } gr_set_current_canvas( GameViewBox->canvas ); gr_set_curfont(editor_font); //gr_setcolor( CBLACK ); //gr_deaccent_canvas(); //gr_grey_canvas(); gr_set_curfont(editor_font); FNTScaleX = FNTScaleY = 1; // No font scaling! ui_pad_goto(padnum); ModeFlag = 0; gamestate_restore_check(); }
// Handler for the main editor dialog int editor_handler(UI_DIALOG *dlg, d_event *event, void *data) { editor_view *new_cv; int keypress = 0; int rval = 0; if (event->type == EVENT_KEY_COMMAND) keypress = event_key_get(event); else if (event->type == EVENT_WINDOW_CLOSE) { close_editor(); EditorWindow = NULL; return 0; } // Update the windows if (event->type == EVENT_UI_DIALOG_DRAW) { gr_set_curfont(editor_font); // Draw status box gr_set_current_canvas( NULL ); gr_setcolor( CGREY ); gr_rect(STATUS_X,STATUS_Y,STATUS_X+STATUS_W-1,STATUS_Y+STATUS_H-1); //0, 582, 799, 599 ); medlisp_update_screen(); calc_frame_time(); texpage_do(event); objpage_do(event); ui_pad_draw(EditorWindow, PAD_X, PAD_Y); print_status_bar(status_line); TimedAutosave(mine_filename); // shows the time, hence here set_editor_time_of_day(); return 1; } if ((selected_gadget == (UI_GADGET *)GameViewBox && !render_3d_in_big_window) || (selected_gadget == (UI_GADGET *)LargeViewBox && render_3d_in_big_window)) switch (event->type) { case EVENT_MOUSE_BUTTON_UP: case EVENT_MOUSE_BUTTON_DOWN: break; case EVENT_MOUSE_MOVED: if (!keyd_pressed[ KEY_LCTRL ] && !keyd_pressed[ KEY_RCTRL ]) break; case EVENT_JOYSTICK_BUTTON_UP: case EVENT_JOYSTICK_BUTTON_DOWN: case EVENT_JOYSTICK_MOVED: case EVENT_KEY_COMMAND: case EVENT_KEY_RELEASE: case EVENT_IDLE: kconfig_read_controls(event, 1); 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; } rval = 1; } break; default: break; } //do non-essential stuff in idle event 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 } gr_set_current_canvas( GameViewBox->canvas ); // Remove keys used for slew switch(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: keypress = 0; } if ((keypress&0xff)==KEY_LSHIFT) keypress=0; if ((keypress&0xff)==KEY_RSHIFT) keypress=0; if ((keypress&0xff)==KEY_LCTRL) keypress=0; if ((keypress&0xff)==KEY_RCTRL) keypress=0; // if ((keypress&0xff)==KEY_LALT) keypress=0; // if ((keypress&0xff)==KEY_RALT) keypress=0; //=================== DO FUNCTIONS ==================== if ( KeyFunction[ keypress ] != NULL ) { KeyFunction[keypress](); keypress = 0; rval = 1; } switch (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(); rval = 1; break; case KEY_F1: render_3d_in_big_window = !render_3d_in_big_window; Update_flags |= UF_ALL; rval = 1; break; default: if (!rval) { char kdesc[100]; GetKeyDescription( kdesc, keypress ); editor_status_fmt("Error: %s isn't bound to anything.", kdesc ); } } //================================================================ if (ModeFlag) { ui_close_dialog(EditorWindow); return 0; } // if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)GameViewBox) current_view=NULL; // if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)GroupViewBox) current_view=NULL; new_cv = current_view; #if ORTHO_VIEWS if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)LargeViewBox) new_cv=&LargeView; if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)TopViewBox) new_cv=&TopView; if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)FrontViewBox) new_cv=&FrontView; if (EditorWindow->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; } // DO TEXTURE STUFF if (texpage_do(event)) rval = 1; if (objpage_do(event)) rval = 1; // Process selection of Cursegp using mouse. if (GADGET_PRESSED(LargeViewBox) && !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 ((event->type == EVENT_UI_USERBOX_DRAGGED) && (ui_event_get_gadget(event) == (UI_GADGET *)GameViewBox)) { int x, y; x = GameViewBox->b1_drag_x2; y = GameViewBox->b1_drag_y2; gr_set_current_canvas( GameViewBox->canvas ); gr_setcolor( 15 ); gr_rect( x-1, y-1, x+1, y+1 ); } // 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 ((GADGET_PRESSED(GameViewBox) && !render_3d_in_big_window) || (GADGET_PRESSED(LargeViewBox) && 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_fmt("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] ) { 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 (event->type == EVENT_MOUSE_MOVED && (keyd_pressed[ KEY_LCTRL ] || keyd_pressed[ KEY_RCTRL ])) { int dx, dy, dz; event_mouse_get_delta(event, &dx, &dy, &dz); if ((dx != 0) && (dy != 0)) { vms_matrix MouseRotMat,tempm; GetMouseRotation( dx, 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 rval = 1; } } if (event->type == EVENT_MOUSE_MOVED) { int dx, dy, dz; event_mouse_get_delta(event, &dx, &dy, &dz); if (dz != 0) { current_view->ev_dist += dz*10000; current_view->ev_changed = 1; } } return rval; }
int piggy_init() { int sbytes = 0; char temp_name_read[16]; char temp_name[16]; grs_bitmap temp_bitmap; digi_sound temp_sound; DiskBitmapHeader bmh; DiskSoundHeader sndh; int header_size, N_bitmaps, N_sounds; int i,size, length; char * filename; int read_sounds = 1; int Pigdata_start; hashtable_init( &AllBitmapsNames, MAX_BITMAP_FILES ); // hashtable_init( &AllDigiSndNames, MAX_SOUND_FILES ); if (GameBitmaps == NULL) { GameBitmaps = (grs_bitmap *)mymalloc(sizeof(grs_bitmap) * MAX_BITMAP_FILES); if (GameBitmaps == NULL) Error("Cannot allocate space for game bitmaps in piggy.c"); } if (AllBitmaps == NULL) { AllBitmaps = (BitmapFile *)mymalloc(sizeof(BitmapFile) * MAX_BITMAP_FILES); if (AllBitmaps == NULL) Error("Cannot allocate space for bitmap filenames in piggy.c"); } #if 0 if (AllSounds == NULL) { AllSounds = (SoundFile *)mymalloc(sizeof(SoundFile) * MAX_SOUND_FILES); if (AllSounds == NULL) Error("Cannot allocate space for sound filenames in piggy.c"); } if ( FindArg( "-nosound" ) || (digi_driver_board<1) ) { read_sounds = 0; mprintf(( 0, "Not loading sound data!!!!!\n" )); } for (i=0; i<MAX_SOUND_FILES; i++ ) { GameSounds[i].length = 0; GameSounds[i].data = NULL; SoundOffset[i] = 0; } #endif for (i=0; i<MAX_BITMAP_FILES; i++ ) GameBitmapXlat[i] = i; if ( !bogus_bitmap_initialized ) { int i; ubyte c; bogus_bitmap_initialized = 1; memset( &bogus_bitmap, 0, sizeof(grs_bitmap) ); bogus_bitmap.bm_w = bogus_bitmap.bm_h = bogus_bitmap.bm_rowsize = 64; bogus_bitmap.bm_data = bogus_data; c = gr_find_closest_color( 0, 0, 63 ); for (i=0; i<4096; i++ ) bogus_data[i] = c; c = gr_find_closest_color( 63, 0, 0 ); // Make a big red X ! for (i=0; i<64; i++ ) { bogus_data[i*64+i] = c; bogus_data[i*64+(63-i)] = c; } piggy_register_bitmap( &bogus_bitmap, "bogus", 1 ); bogus_sound.length = 64*64; bogus_sound.data = bogus_data; GameBitmapOffset[0] = 0; } filename = ":Data:DESCENT.PIG"; if ( FindArg( "-bigpig" )) BigPig = 1; if ( FindArg( "-lowmem" )) piggy_low_memory = 1; if ( FindArg( "-nolowmem" )) piggy_low_memory = 0; if (use_alt_textures) piggy_low_memory = 1; //MWA if (piggy_low_memory) //MWA digi_lomem = 1; if ( (i=FindArg( "-piggy" )) ) { filename = Args[i+1]; mprintf( (0, "Using alternate pigfile, '%s'\n", filename )); } Piggy_fp = cfopen( filename, "rb" ); if (Piggy_fp==NULL) return 0; Pigdata_start = read_int_swap(Piggy_fp); #ifdef EDITOR if ( FindArg("-nobm") ) #endif { bm_read_all( Piggy_fp ); // Note connection to above if!!! for (i = 0; i < MAX_BITMAP_FILES; i++) GameBitmapXlat[i] = read_short_swap(Piggy_fp); digi_load_sounds(); } cfseek( Piggy_fp, Pigdata_start, SEEK_SET ); size = cfilelength(Piggy_fp) - Pigdata_start; length = size; mprintf( (0, "\nReading data (%d KB) ", size/1024 )); N_bitmaps = read_int_swap(Piggy_fp); size -= sizeof(int); N_sounds = read_int_swap(Piggy_fp); size -= sizeof(int); // header_size = (N_bitmaps*sizeof(DiskBitmapHeader)) + (N_sounds*sizeof(DiskSoundHeader)); header_size = ((N_bitmaps*17) + (N_sounds*20)); gr_set_curfont( Gamefonts[GFONT_SMALL] ); gr_set_fontcolor(gr_find_closest_color_current( 20, 20, 20 ),-1 ); gr_printf( 0x8000, grd_curcanv->cv_bitmap.bm_h - 25, "%s...", TXT_LOADING_DATA ); bitblt_to_screen(); // put a couple of event loop calls here. This should take care of TM driver!!! process_one_event(); process_one_event(); process_one_event(); process_one_event(); for (i=0; i<N_bitmaps; i++ ) { cfread(bmh.name, 8, 1, Piggy_fp); bmh.dflags = read_byte(Piggy_fp); bmh.width = read_byte(Piggy_fp); bmh.height = read_byte(Piggy_fp); bmh.flags = read_byte(Piggy_fp); bmh.avg_color = read_byte(Piggy_fp); bmh.offset = read_int_swap(Piggy_fp); //size -= sizeof(DiskBitmapHeader); memcpy( temp_name_read, bmh.name, 8 ); temp_name_read[8] = 0; if ( bmh.dflags & DBM_FLAG_ABM ) sprintf( temp_name, "%s#%d", temp_name_read, bmh.dflags & 63 ); else strcpy( temp_name, temp_name_read ); memset( &temp_bitmap, 0, sizeof(grs_bitmap) ); if ( bmh.dflags & DBM_FLAG_LARGE ) temp_bitmap.bm_w = temp_bitmap.bm_rowsize = bmh.width+256; else temp_bitmap.bm_w = temp_bitmap.bm_rowsize = bmh.width; temp_bitmap.bm_h = bmh.height; temp_bitmap.bm_flags = BM_FLAG_PAGED_OUT; temp_bitmap.avg_color = bmh.avg_color; temp_bitmap.bm_data = Piggy_bitmap_cache_data; // HACK HACK HACK!!!!! if (!strnicmp(bmh.name, "cockpit", 7) || !strnicmp(bmh.name, "status", 6) || !strnicmp(bmh.name, "rearview", 8)) { temp_bitmap.bm_w = temp_bitmap.bm_rowsize = 640; } if (!strnicmp(bmh.name, "cockpit", 7) || !strnicmp(bmh.name, "rearview", 8)) temp_bitmap.bm_h = 480; GameBitmapFlags[i+1] = 0; if ( bmh.flags & BM_FLAG_TRANSPARENT ) GameBitmapFlags[i+1] |= BM_FLAG_TRANSPARENT; if ( bmh.flags & BM_FLAG_SUPER_TRANSPARENT ) GameBitmapFlags[i+1] |= BM_FLAG_SUPER_TRANSPARENT; if ( bmh.flags & BM_FLAG_NO_LIGHTING ) GameBitmapFlags[i+1] |= BM_FLAG_NO_LIGHTING; if ( bmh.flags & BM_FLAG_RLE ) GameBitmapFlags[i+1] |= BM_FLAG_RLE; GameBitmapOffset[i+1] = bmh.offset + header_size + (sizeof(int)*2) + Pigdata_start; Assert( (i+1) == Num_bitmap_files ); piggy_register_bitmap( &temp_bitmap, temp_name, 1 ); } #if 0 for (i=0; i<N_sounds; i++ ) { cfread(sndh.name, 8, 1, Piggy_fp); sndh.length = read_int_swap(Piggy_fp); sndh.data_length = read_int_swap(Piggy_fp); sndh.offset = read_int_swap(Piggy_fp); //size -= sizeof(DiskSoundHeader); temp_sound.length = sndh.length; temp_sound.data = (ubyte *)(sndh.offset + header_size + (sizeof(int)*2)+Pigdata_start); SoundOffset[Num_sound_files] = sndh.offset + header_size + (sizeof(int)*2)+Pigdata_start; memcpy( temp_name_read, sndh.name, 8 ); temp_name_read[8] = 0; piggy_register_sound( &temp_sound, temp_name_read, 1 ); sbytes += sndh.length; //mprintf(( 0, "%d bytes of sound\n", sbytes )); } SoundBits = mymalloc( sbytes + 16 ); if ( SoundBits == NULL ) Error( "Not enough memory to load DESCENT.PIG sounds\n" ); #endif #ifdef EDITOR Piggy_bitmap_cache_size = size - header_size - sbytes + 16; Assert( Piggy_bitmap_cache_size > 0 ); #else if (!piggy_low_memory) Piggy_bitmap_cache_size = PIGGY_BUFFER_SIZE; else Piggy_bitmap_cache_size = LOW_PIGGY_BUFFER_SIZE; #endif BitmapBits = mymalloc( Piggy_bitmap_cache_size ); if ( BitmapBits == NULL ) Error( "Not enough memory to load DESCENT.PIG bitmaps\n" ); Piggy_bitmap_cache_data = BitmapBits; Piggy_bitmap_cache_next = 0; mprintf(( 0, "\nBitmaps: %d KB Sounds: %d KB\n", Piggy_bitmap_cache_size/1024, sbytes/1024 )); atexit(piggy_close_file); // mprintf( (0, "<<<<Paging in all piggy bitmaps...>>>>>" )); // for (i=0; i < Num_bitmap_files; i++ ) { // bitmap_index bi; // bi.index = i; // PIGGY_PAGE_IN( bi ); // } // mprintf( (0, "\n (USed %d / %d KB)\n", Piggy_bitmap_cache_next/1024, (size - header_size - sbytes + 16)/1024 )); // key_getch(); return 0; }
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 }