add wraparound support to C2 physics
[openc2e.git] / Bubble.h
blob99c67e47c62ae35bc8c687561acfa3c307120883
1 /*
2 * Bubble.h
3 * openc2e
5 * Created by Alyssa Milburn on Sat Apr 26 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 "CompoundAgent.h"
22 #ifndef _C2E_BUBBLE_H
23 #define _C2E_BUBBLE_H
25 class Bubble : public CompoundAgent {
26 friend class BubblePart;
28 protected:
29 class BubblePart *ourPart;
30 unsigned int timeout;
32 void turnIntoSpeech();
34 public:
35 Bubble(unsigned char family, unsigned char genus, unsigned short species, unsigned int plane,
36 std::string spritefile, unsigned int firstimage, unsigned int imagecount,
37 unsigned int tx, unsigned int ty, unsigned int twidth, unsigned int theight,
38 unsigned int bgcolour, unsigned int tcolour);
40 void setText(std::string s);
41 std::string getText();
43 void setEditing(bool e);
45 void setTimeout(unsigned int i);
46 void tick();
48 static Bubble *newBubble(Agent *parent, bool speech, std::string text);
51 class BubblePart : public CompoundPart {
52 friend class Bubble;
54 protected:
55 BubblePart(Bubble *p, unsigned int _id, int x, int y);
57 bool editable;
58 std::string text;
59 unsigned int textwidth, textheight;
60 unsigned int textoffset;
61 unsigned int backgroundcolour, textcolour;
63 void setText(std::string s);
65 public:
66 void partRender(class Surface *renderer, int xoffset, int yoffset);
67 unsigned int getWidth() { return textwidth; }
68 unsigned int getHeight() { return textheight; }
70 bool canGainFocus() { return editable; }
71 void gainFocus();
72 void loseFocus();
73 void handleKey(char c);
74 void handleSpecialKey(char c);
77 #endif
78 /* vim: set noet: */