~vcs-imports/openc2e/trunk

« back to all changes in this revision

Viewing changes to Bubble.h

  • Committer: fuzzie
  • Date: 2008-04-26 22:14:06 UTC
  • Revision ID: vcs-imports@canonical.com-20080426221406-y1qh3hsm801kt716
add hacky implementation of C1 speech/thought bubbles, unfinished

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Bubble.h
 
3
 *  openc2e
 
4
 *
 
5
 *  Created by Alyssa Milburn on Sat Apr 26 2008.
 
6
 *  Copyright (c) 2008 Alyssa Milburn. All rights reserved.
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
18
 */
 
19
 
 
20
#include "CompoundAgent.h"
 
21
 
 
22
#ifndef _C2E_BUBBLE_H
 
23
#define _C2E_BUBBLE_H
 
24
 
 
25
class Bubble : public CompoundAgent {
 
26
        friend class BubblePart;
 
27
 
 
28
protected:
 
29
        class BubblePart *ourPart;
 
30
        unsigned int timeout;
 
31
 
 
32
        void turnIntoSpeech();
 
33
 
 
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);
 
39
 
 
40
        void setText(std::string s);
 
41
        std::string getText();
 
42
 
 
43
        void setEditing(bool e);
 
44
 
 
45
        void setTimeout(unsigned int i);
 
46
        void tick();
 
47
};
 
48
 
 
49
class BubblePart : public CompoundPart {
 
50
        friend class Bubble;
 
51
 
 
52
protected:
 
53
        BubblePart(Bubble *p, unsigned int _id, int x, int y);
 
54
 
 
55
        bool editable;
 
56
        std::string text;
 
57
        unsigned int textwidth, textheight;
 
58
        unsigned int textoffset;
 
59
        unsigned int backgroundcolour, textcolour;
 
60
 
 
61
        void setText(std::string s);
 
62
 
 
63
public:
 
64
        void partRender(class Surface *renderer, int xoffset, int yoffset);
 
65
        unsigned int getWidth() { return textwidth; }
 
66
        unsigned int getHeight() { return textheight; }
 
67
 
 
68
        bool canGainFocus() { return editable; }
 
69
        void gainFocus();
 
70
        void loseFocus();
 
71
        void handleKey(char c);
 
72
        void handleSpecialKey(char c);
 
73
};
 
74
 
 
75
#endif
 
76
/* vim: set noet: */