1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#include "ShapeLd.hpp"
#include "Graphfil.hpp"
#include "Appl.hpp"
#include "Clut.hpp"
#include "ShapeDes.hpp"
#include "ConstVal.hpp"
#include <stdio.h>
extern CApplication *gApplication;
extern CSystem *gSystem;
extern CClutManager *gClutManager;
extern tConstValues *gConst;
extern CClutManager *gClutManager;
extern FILE *logFile;
CShapeManager::CShapeManager()
{
}
CShapeManager::~CShapeManager()
{
}
void CShapeManager::LoadShapes()
{
short n;
Graphic_file *plane;
MSG("Opening shape file\n");
plane = read_graphic_file(gSystem->QualifyDataDir(gConst->kFileShapes)); // by LL
if (!plane) gSystem->Error("Cannot find kFileShapes or cannot open it. Perhaps lack of memory?", 0);
MSG("Creating shapes and textures\n");
for (n = 0; n < kNumShapes; n ++) {
shapes[n] = new CMaskedShape(plane->bitmap, &kShapeDescriptor[n][0], plane->width);
}
for (n = 0; n < kNumTextures; n ++) {
for (short m = 0; m < 4; m ++) {
textures[n][m] = new CTexture(plane->bitmap, &kTextureDescriptor[n][0], plane->width, m);
}
}
gClutManager->CalculateCoronas(plane->bitmap, plane->width);
free_graphic_file(plane);
}
void CShapeManager::UnloadShapes()
{
short n;
for (n = 0; n < kNumShapes; n ++) {
delete shapes[n];
}
for (n = 0; n < kNumTextures; n ++) {
for (short m = 0; m < 4; m ++) {
delete textures[n][m];
}
}
}
void CShapeManager::LoadBackground(char *background)
{
MSG("Opening background image\n");
backgroundPicture = read_graphic_file(gSystem->QualifyDataDir(background));
if (!backgroundPicture) gSystem->Error("Cannot open background file. Lack of memory?", 0);
SwapBlackWhite(backgroundPicture);
}
void CShapeManager::UnloadBackground()
{
free_graphic_file(backgroundPicture);
}
CShape* CShapeManager::FindShape(short id, short light)
{
short n;
if (id == -1) return NULL; else {
if (id >= kTextureStart && id <= kTextureEnd) {
for (n = 0; n < kNumTextures && kTextureDescriptor[n][0] != id; n ++) {}
if (n != kNumTextures) return textures[n][light]; else return 0L;
}else{
for (n = 0; n < kNumShapes && kShapeDescriptor[n][0] != id; n ++) {}
if (n != kNumShapes) return shapes[n]; else return 0L;
}
}
}
unsigned char *CShapeManager::GetBackground(short &width, short &height)
{
width = backgroundPicture->width;
height = backgroundPicture->height;
return backgroundPicture->bitmap;
}
|