File: shapeid.cc

package info (click to toggle)
exult 0.98rc1-2
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 6,924 kB
  • ctags: 8,928
  • sloc: cpp: 83,768; sh: 7,643; ansic: 4,328; makefile: 890; yacc: 618; lex: 255; xml: 19
file content (112 lines) | stat: -rw-r--r-- 2,905 bytes parent folder | download
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 *  Copyright (C) 2000-2001  The Exult Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include "gamewin.h"
#include "shapeid.h"
#include "vgafile.h"

Shape_frame *ShapeID::cache_shape()
{
	if (framenum == -1) return 0;

	Game_window *gwin = Game_window::get_game_window();
	if (has_trans != 2) has_trans = 0;

	switch (shapefile) {
	case SF_SHAPES_VGA:
		shape = gwin->get_shape(shapenum, framenum);
		if (has_trans != 2) has_trans = gwin->get_shapes().get_info(shapenum).has_translucency();
		break;
	case SF_GUMPS_VGA:
		shape = gwin->get_gump_shape (shapenum, framenum);
		break;
	case SF_PAPERDOL_VGA:
		shape = gwin->get_paperdoll_shape (shapenum, framenum);
		break;
	case SF_SPRITES_VGA:
		shape = gwin->get_sprite_shape (shapenum, framenum);
		has_trans = 1;
		break;
	case SF_FACES_VGA:
		shape = gwin->get_face (shapenum, framenum);
		break;
	case SF_EXULT_FLX:
		shape = gwin->get_exult_shape(shapenum, framenum);
		break;
	case SF_GAME_FLX:
		shape = gwin->get_gameflx_shape (shapenum, framenum);
		break;
	case SF_BG_SIGUMP_FLX:
		shape = gwin->get_bg_sigump_shape(shapenum, framenum);
		break;
	case SF_BG_SISHAPES_VGA:
		shape = gwin->get_bg_sishape(shapenum, framenum);
		break;
	default:
		std::cerr << "Error! Wrong ShapeFile!" << std::endl;
		return 0;
	} 

	return shape;

}

int ShapeID::get_num_frames() const
{
	Game_window *gwin = Game_window::get_game_window();

	switch (shapefile) {

	case SF_SHAPES_VGA:
		return gwin->get_shape_num_frames(shapenum);

	case SF_GUMPS_VGA:
		return gwin->get_gump_num_frames (shapenum);

	case SF_PAPERDOL_VGA:
		return gwin->get_paperdoll_num_frames (shapenum);

	case SF_SPRITES_VGA:
		return gwin->get_sprite_num_frames (shapenum);

	case SF_FACES_VGA:
		return gwin->get_face_num_frames (shapenum);

	case SF_EXULT_FLX:
		return gwin->get_exult_num_frames(shapenum);

	case SF_GAME_FLX:
		return gwin->get_gameflx_num_frames (shapenum);

	case SF_BG_SIGUMP_FLX:
		return gwin->get_bg_sigump_num_frames(shapenum);

	case SF_BG_SISHAPES_VGA:
		return gwin->get_bg_sishape_num_frames(shapenum);

	default:
		std::cerr << "Error! Wrong ShapeFile!" << std::endl;
		return 0;
	} 

	return 0;
}