src/GameMessageView.hh
author Tero Marttila <terom@fixme.fi>
Tue, 13 Jan 2009 23:54:47 +0200
changeset 394 82def222fe7d
parent 393 5dd4d782cf3a
permissions -rw-r--r--
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
#ifndef GRAPHICS_INFO_TEXT_HH
#define GRAPHICS_INFO_TEXT_HH

#include "GraphicsPointer.hh"
#include "Types.hh"

#include <string>
#include <vector>
#include <ClanLib/display.h>

struct GameMessage {
    CL_Color color;
    std::string message;

    GameMessage (CL_Color color, std::string message) : color(color), message(message) { }
    GameMessage (const GameMessage &copy) : color(copy.color), message(copy.message) { }
    GameMessage &operator= (const GameMessage &copy) { color = copy.color; message = copy.message; return *this; }
};

class GameMessageView {
    protected:
        PixelArea area;
        std::vector<GameMessage> messages;

    public:
        /**
         * Define the area where messages are drawn
         */
        GameMessageView (PixelArea area);

        /**
         * Update draw area
         */
        void on_resize (PixelArea new_area) { this->area = new_area; }

        /**
         * Add a message to the list of messages displayed
         */
        void add_message (CL_Color color, std::string message);
        
        /**
         * Draw as many messages as fits
         */
        void draw (Graphics *g);
};

#endif