Descent3/manage/powerpage.h

61 lines
2.2 KiB
C
Raw Normal View History

2024-04-16 03:43:29 +00:00
#ifndef POWERPAGE_H
#define POWERPAGE_H
#include "manage.h"
2024-04-19 12:57:55 +00:00
#include "cfile.h"
2024-04-16 03:43:29 +00:00
#include "pstypes.h"
#include "powerup.h"
2024-04-16 18:56:40 +00:00
typedef struct {
powerup powerup_struct;
char image_name[PAGENAME_LEN];
char sound_name[MAX_POWERUP_SOUNDS][PAGENAME_LEN];
2024-04-16 03:43:29 +00:00
} mngs_power_page;
// Powerup page functions
//---------------------------------------------------------------
// Given an open file pointer and a power_page struct, writes that power page out
2024-04-16 18:56:40 +00:00
void mng_WritePowerPage(CFILE *outfile, mngs_power_page *powpage);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Reads a powerup page from an open file. Returns 0 on error.
int mng_ReadPowerPage(CFILE *infile, mngs_power_page *powpage);
2024-04-16 03:43:29 +00:00
// Given a power handle, searches the table file and replaces the powerup with the same name
// If local=1, then does it to the users local copy
// Returns 0 on error, else 1 if all is good
2024-04-16 18:56:40 +00:00
int mng_ReplacePowPage(char *name, int handle, int local);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Given a powerup name, finds it in the table file and deletes it
2024-04-16 03:43:29 +00:00
// If local is 1, deletes from the local table file
2024-04-16 18:56:40 +00:00
int mng_DeletePowPage(char *name, int local);
2024-04-16 03:43:29 +00:00
// Reads in the powpage named "name" into powpage struct
// Returns 0 on error or couldn't find, else 1 if all is good
2024-04-16 18:56:40 +00:00
int mng_FindSpecificPowPage(char *name, mngs_power_page *powpage, int offset = 0);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Given a power page, allocs a powerup and calls AssignPowPageToPowerup to actually
2024-04-16 03:43:29 +00:00
// load bitmaps and values. Rturns powerup handle on success, -1 if fail
2024-04-16 18:56:40 +00:00
int mng_SetAndLoadPowerup(mngs_power_page *powpage);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Given a powpage and a powerup handle, attempts to make powerup n correspond to
// to the powpage.
2024-04-16 03:43:29 +00:00
// Returns 1 on success, 0 otherwise
2024-04-16 18:56:40 +00:00
int mng_AssignPowPageToPowerup(mngs_power_page *powpage, int n);
2024-04-16 03:43:29 +00:00
// Copies values from a powerup into a power_page
2024-04-16 18:56:40 +00:00
void mng_AssignPowerupToPowPage(int n, mngs_power_page *powpage);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Reads in a power page from the local table file, superseding any powerup
2024-04-16 03:43:29 +00:00
// already in RAM with that same name
void mng_LoadLocalPowerupPage(CFILE *);
// Reads in a page off the net
2024-04-16 18:56:40 +00:00
void mng_LoadNetPowerupPage(CFILE *);
2024-04-16 03:43:29 +00:00
// First searches through the powerup index to see if the powerup is already
2024-04-16 18:56:40 +00:00
// loaded. If not, searches in the table file and loads it.
2024-04-16 03:43:29 +00:00
// Returns index of powerup if found, -1 if not
2024-04-16 18:56:40 +00:00
int mng_GetGuaranteedPowerupPage(char *name, CFILE *infile = NULL);
2024-04-16 03:43:29 +00:00
#endif