read Blackboard data correctly from the SFC file, and construct a BlackboardPart...
[openc2e.git] / Blackboard.cpp
blob5240fd37c684913c27a4558329843b52a9407a4c
1 /*
2 * Blackboard.cpp
3 * openc2e
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"
21 #include "Engine.h"
22 #include "Backend.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()));
33 else
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);
38 addPart(p);
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()));
49 else
50 strings.resize(48, std::pair<unsigned int, std::string>(0, std::string()));
52 BlackboardPart *p = new BlackboardPart(this, 10);
53 addPart(p);
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);
75 /* vim: set noet: */