Originally posted by GalacticEmperor
Yah, but this way we get smaller file sizes, you can see the stats without them being stuck in an ANI, and it's much easier to do the interface for new ships.
ANIs are (I think) encoded so that each frame has a repeat count (I think it's RLE....little hazy on it). So you'd only be storing - for the simplest possible implementation - about 4 or 5 PCX images (for a ship with 3 weapons boxes to display). It's not that big a difference - certainly not icompared to the 3-8MB loadout animations from FS2.
Here it is - I think - from MissionWeaponsChoice in missionUI
// ---------------------------------------------------------------------------------
// wl_render_overhead_view()
//
void wl_render_overhead_view(float frametime)
{
char name[NAME_LENGTH + CALLSIGN_LEN];
wl_ship_class_info *wl_ship;
int ship_class;
if ( Selected_wl_slot == -1 ) {
return;
}
ship_class = Wss_slots[Selected_wl_slot].ship_class;
// check if ship class has changed and maybe play sound
if (Last_wl_ship_class != ship_class) {
if (Last_wl_ship_class != -1) {
gamesnd_play_iface(SND_ICON_DROP);
}
Last_wl_ship_class = ship_class;
}
wl_ship = &Wl_ships[ship_class];
if ( wl_ship->anim_instance == NULL ) {
if ( wl_ship->overhead_bitmap < 0 ) {
// load the bitmap
if (gr_screen.res == GR_640)
{
// lo-res
wl_ship->overhead_bitmap = bm_load(Ship_info[ship_class].overhead_filename);
} else {
// high-res
char filename[NAME_LENGTH+2] = "2_";
strcat(filename, Ship_info[ship_class].overhead_filename);
wl_ship->overhead_bitmap = bm_load(filename);
}
if ( wl_ship->overhead_bitmap < 0 ) {
Int3(); // bad things happened
return;
}
}
gr_set_bitmap(wl_ship->overhead_bitmap);
gr_bitmap(Wl_overhead_coords[gr_screen.res][0], Wl_overhead_coords[gr_screen.res][1]);
}
ss_return_name(Selected_wl_slot/4, Selected_wl_slot%4, name);
gr_set_color_fast(&Color_normal);
gr_string(Wl_ship_name_coords[gr_screen.res][0], Wl_ship_name_coords[gr_screen.res][1], name);
}
Ok..I don;t really have the foggiest how C++ or the *.ani format works (

). But I'd guess...
1/ Check for a PCX extension when loding the filename
(I'm assuming that the normal loadout would be a pcx file - so it'd be more efficient to ONLY proceed if no PCX is there, rather than check for a - in the majority of cases - non-existent ani).
Would prob. need to do this AFTER the res is detected, for reasons of sanity.
2/ If a PCX, set some little variable as so, and parse it normally. If not a PCX, check for ani file. If no ani - > goto the failure condition. Otherwise 'flag' it as so
3/ Use an if statement to decide how to show the image.... pcx as given, ANI -> parse through all frames in standard 15FPS, then stop at the last frame. ... the last frame should be the exact equivalent of a static (PCX) loadout image.
3/ is iffy, cos I don;t know how anis are handled.... I'm assuming a bit of the code form the weapons ani viewer can be used, though.
// Load in a specific weapon animation. The data is loaded as a memory-mapped file since these animations
// can be large.
void wl_load_anim(int weapon_class)
{
char animation_filename[CF_MAX_FILENAME_LENGTH+4];
wl_icon_info *icon;
icon = &Wl_icons[weapon_class];
Assert( icon->anim == NULL );
// 1024x768 SUPPORT
// If we are in 1024x768, we first want to append "2_" in front of the filename
if (gr_screen.res == GR_1024) {
Assert(strlen(Weapon_info[weapon_class].anim_filename) <= 30);
strcpy(animation_filename, "2_");
strcat(animation_filename, Weapon_info[weapon_class].anim_filename);
// now check if file exists
// GRR must add a .ANI at the end for detection
strcat(animation_filename,".ani");
icon->anim = anim_load(animation_filename, 1);
if (icon->anim == NULL) {
mprintf(("Weapon ANI: Can not find %s, using lowres version instead.\n",animation_filename));
strcpy(animation_filename, Weapon_info[weapon_class].anim_filename);
icon->anim = anim_load(animation_filename, 1);
}
/*
if (!cf_exist(animation_filename, CF_TYPE_INTERFACE)) {
// file does not exist, use original low res version
mprintf(("Weapon ANI: Can not find %s, using lowres version instead.\n",animation_filename));
strcpy(animation_filename, Weapon_info[weapon_class].anim_filename);
} else {
animation_filename[strlen(animation_filename) - 4] = '\0';
mprintf(("Weapon ANI: Found hires version of %s\n",animation_filename));
}
*/
} else {
strcpy(animation_filename, Weapon_info[weapon_class].anim_filename);
// load the compressed ship animation into memory
// NOTE: if last parm of load_anim is 1, the anim file is mapped to memory
icon->anim = anim_load(animation_filename, 1);
}
if ( icon->anim == NULL ) {
Int3(); // couldn't load anim filename.. get Alan
}
}
(hey, i'm also named alan..... thank god that ain't me, eh)
This seems to be one of the relevant bits of code... there's also the load all animations one underneath, which may be to do with a sort of precaching thing(?) - I honestly don't know.
EDIT - haha! could this be it?
void wl_start_slot_animation(int n)
{
#ifndef DEMO // not for FS2_DEMO
// don't use ani's
// fallback code in wl_render_overhead_view() will
// use the .pcx files
// should prolly scrub out the 1e06 lines of dead code this leaves
return;
/*
int ship_class;
wl_ship_class_info *wl_ship;
anim_play_struct aps;
if ( n < 0 ) {
return;
}
ship_class = Wss_slots[n].ship_class;
if ( ship_class < 0 ) {
Int3();
return;
}
wl_ship = &Wl_ships[ship_class];
// maybe this animation is already playing?
if ( wl_ship->anim_instance ) {
anim_stop_playing(wl_ship->anim_instance);
wl_ship->anim_instance = NULL;
}
// maybe we have to load this animation
if ( wl_ship->anim == NULL ) {
wl_ship->anim = anim_load(Ship_info[ship_class].overhead_filename, 1);
if ( wl_ship->anim == NULL ) {
Int3(); // couldn't load anim filename.. get Alan
return;
}
}
anim_play_init(&aps, wl_ship->anim, Wl_overhead_coords[gr_screen.res][0], Wl_overhead_coords[gr_screen.res][1]);
aps.screen_id = ON_WEAPON_SELECT;
aps.framerate_independent = 1;
aps.skip_frames = 0;
wl_ship->anim_instance = anim_play(&aps);
*/
#endif
}
Could maybe just call this (uncommented, of course) function in the
wl_render_overhead_view operation? witha few modifications.......hi-res support, I guess.
EDIT - added ALL the code

Just for reference (may doodle a bit of this when I'm in uni if time permits)
Here's an example of the anis from FS1 -
http://www.3dap.com/hlp/hosted/reciprocity/aldostuff/loadfighter01.aniThis is displayed, then a pcx view ala FS2. I'm not sure when it's actually put on screen (i.e. if it's 'under' the ani). Or even if that matters.
A paltry 81kb(!)... i'm wondering if the last bit of code may be all thats necessarry, as I'm reading it as showing the pcx if all else fails.... although that may not be as efficient(?). Also no hi-res support AFAIK.
EDIT2; Incidentally, has anyone changed the ani code for the weapons / ships loadout so that the 2nd loop point isn't hardcoded at (IIRC) frame 50? (it seems to be, anyway - not checked yet). If the ani classes / library (or whatever the C/C++ term is....escapes me at the mo) has a suitable method for getting it (the loop point), this is seemingly fairly/very easy IMO.