5 * Created by Alyssa Milburn on Sat Jan 12 2008.
6 * Copyright (c) 2008 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #include "Blackboard.h"
24 Blackboard::Blackboard(unsigned char family
, unsigned char genus
, unsigned short species
, unsigned int plane
,
25 std::string spritefile
, unsigned int firstimage
, unsigned int imagecount
, unsigned int tx
,
26 unsigned int ty
, unsigned int bgcolour
, unsigned int ckcolour
, unsigned int alcolour
) :
27 CompoundAgent(family
, genus
, species
, plane
, spritefile
, firstimage
, imagecount
) {
28 textx
= tx
; texty
= ty
;
29 backgroundcolour
= bgcolour
; chalkcolour
= ckcolour
; aliascolour
= alcolour
;
31 if (engine
.version
== 1)
32 strings
.resize(16, std::pair
<unsigned int, std::string
>(0, std::string()));
34 strings
.resize(48, std::pair
<unsigned int, std::string
>(0, std::string()));
36 // add the part responsible for text; id #10 keeps it safely out of the way
37 BlackboardPart
*p
= new BlackboardPart(this, 10);
41 Blackboard::Blackboard(std::string spritefile
, unsigned int firstimage
, unsigned int imagecount
,
42 unsigned int tx
, unsigned int ty
, unsigned int bgcolour
, unsigned int ckcolour
,
43 unsigned int alcolour
) : CompoundAgent(spritefile
, firstimage
, imagecount
) {
44 textx
= tx
; texty
= ty
;
45 backgroundcolour
= bgcolour
; chalkcolour
= ckcolour
; aliascolour
= alcolour
;
47 if (engine
.version
== 1)
48 strings
.resize(16, std::pair
<unsigned int, std::string
>(0, std::string()));
50 strings
.resize(48, std::pair
<unsigned int, std::string
>(0, std::string()));
52 BlackboardPart
*p
= new BlackboardPart(this, 10);
56 void Blackboard::addBlackboardString(unsigned int n
, unsigned int id
, std::string text
) {
57 strings
[n
] = std::pair
<unsigned int, std::string
>(id
, text
);
60 void Blackboard::renderText(class Surface
*renderer
, int xoffset
, int yoffset
) {
61 // TODO: check var[0] is valid
63 // TODO: is +1 really the right fix here?
64 renderer
->renderText(xoffset
+ textx
+ 1, yoffset
+ texty
+ 1, strings
[var
[0].getInt()].second
, chalkcolour
, backgroundcolour
);
67 BlackboardPart::BlackboardPart(Blackboard
*p
, unsigned int _id
) : CompoundPart(p
, _id
, 0, 0, 1) {
68 // TODO: think about plane
71 void BlackboardPart::partRender(class Surface
*renderer
, int xoffset
, int yoffset
) {
72 dynamic_cast<Blackboard
*>(parent
)->renderText(renderer
, xoffset
, yoffset
);