1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "ultima/nuvie/core/nuvie_defs.h"
24
25 #include "ultima/nuvie/conf/configuration.h"
26 #include "ultima/nuvie/gui/widgets/console.h"
27 #include "ultima/nuvie/files/nuvie_io_file.h"
28 #include "ultima/nuvie/files/u6_shape.h"
29 #include "ultima/nuvie/screen/dither.h"
30 #include "ultima/nuvie/core/game.h"
31
32 #include "ultima/nuvie/actors/actor_manager.h"
33 #include "ultima/nuvie/actors/actor.h"
34
35 #include "ultima/nuvie/portraits/portrait.h"
36 #include "ultima/nuvie/portraits/portrait_u6.h"
37 #include "ultima/nuvie/portraits/portrait_md.h"
38 #include "ultima/nuvie/portraits/portrait_se.h"
39
40 #include "ultima/nuvie/files/u6_lzw.h"
41 #include "ultima/nuvie/misc/u6_misc.h"
42 #include "ultima/nuvie/files/u6_lib_n.h"
43
44 #include "ultima/nuvie/core/u6_objects.h"
45
46 namespace Ultima {
47 namespace Nuvie {
48
newPortrait(nuvie_game_t gametype,Configuration * cfg)49 Portrait *newPortrait(nuvie_game_t gametype, Configuration *cfg) {
50 // Correct portrait class for each game
51 switch (gametype) {
52 case NUVIE_GAME_U6 :
53 return (Portrait *) new PortraitU6(cfg);
54 break;
55 case NUVIE_GAME_MD :
56 return (Portrait *) new PortraitMD(cfg);
57 break;
58 case NUVIE_GAME_SE :
59 return (Portrait *) new PortraitSE(cfg);
60 break;
61 }
62 return NULL;
63 }
64
65
Portrait(Configuration * cfg)66 Portrait::Portrait(Configuration *cfg) {
67 config = cfg;
68 avatar_portrait_num = 0;
69 width = 0;
70 height = 0;
71 }
72
get_avatar_portrait_num()73 uint8 Portrait::get_avatar_portrait_num() {
74 return get_portrait_num(Game::get_game()->get_actor_manager()->get_avatar());
75 }
76
77
get_wou_portrait_data(U6Lib_n * lib,uint8 num)78 unsigned char *Portrait::get_wou_portrait_data(U6Lib_n *lib, uint8 num) {
79 // MD/SE
80 U6Shape *shp;
81 unsigned char *shp_data;
82 NuvieIOBuffer shp_buf;
83 U6Lib_n shp_lib;
84 unsigned char *new_portrait;
85 uint16 portrait_w;
86 uint16 portrait_h;
87
88 shp_data = lib->get_item(num, NULL);
89 shp_buf.open(shp_data, lib->get_item_size(num), NUVIE_BUF_NOCOPY);
90
91 if (shp_buf.get_size() == 0) { // no portrait at that index
92 free(shp_data);
93 return (NULL);
94 }
95 shp = new U6Shape();
96 shp_lib.open(&shp_buf, 4, NUVIE_GAME_SE);
97 shp->load(&shp_lib, 0);
98 shp->get_size(&portrait_w, &portrait_h);
99 new_portrait = (unsigned char *)malloc(portrait_w * portrait_h);
100 memcpy(new_portrait, shp->get_data(), portrait_w * portrait_h);
101 //new_portrait=shp->get_data(); // probably need to copy here
102
103 delete shp;
104 shp_lib.close();
105 free(shp_data);
106
107 return new_portrait;
108 }
109
110 } // End of namespace Nuvie
111 } // End of namespace Ultima
112