src/Graphics.hh
author Tero Marttila <terom@fixme.fi>
Tue, 13 Jan 2009 23:15:47 +0200
changeset 393 5dd4d782cf3a
parent 392 6c4dc68360eb
child 394 82def222fe7d
permissions -rw-r--r--
a basic implementation of game messages, plus some weird GameStateEvent stuff
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     1
#ifndef GRAPHICS_HH
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     2
#define GRAPHICS_HH
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     3
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 205
diff changeset
     4
#include "GraphicsPointer.hh"
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     5
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     6
#include "GameState.hh"
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 205
diff changeset
     7
#include "Input.hh"
205
905028e58ed1 implement a new tick-timer that doesn't suck
terom
parents: 185
diff changeset
     8
#include "Timer.hh"
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     9
#include "Engine.hh"
266
ad72d0a0cc02 increase the map size and control the camera to always have the screen full of terrain
terom
parents: 235
diff changeset
    10
#include "Config.hh"
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    11
393
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    12
#include "GameMessageView.hh"
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    13
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    14
#include <ClanLib/core.h>
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    15
#include <ClanLib/gl.h>
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    16
#include <ClanLib/display.h>
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    17
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 275
diff changeset
    18
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 275
diff changeset
    19
 * This handles drawing the GameState with an appropriate camera view each frame, loading fonts, and currently,
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 275
diff changeset
    20
 * handling the input from Input to GameState.
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 275
diff changeset
    21
 */
393
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    22
class Graphics : public GameStateEventHandler, public CL_DisplayWindow {
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    23
private:
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    24
    Engine &engine;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    25
    GameState &state;
266
ad72d0a0cc02 increase the map size and control the camera to always have the screen full of terrain
terom
parents: 235
diff changeset
    26
ad72d0a0cc02 increase the map size and control the camera to always have the screen full of terrain
terom
parents: 235
diff changeset
    27
    PixelCoordinate resolution;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    28
    
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    29
    CL_SlotContainer slots;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    30
    
205
905028e58ed1 implement a new tick-timer that doesn't suck
terom
parents: 185
diff changeset
    31
    Timer update_timer;
235
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
    32
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
    33
    Input input;
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 205
diff changeset
    34
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 205
diff changeset
    35
    // current GUI input state
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 205
diff changeset
    36
    GuiInput flags;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    37
    
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 205
diff changeset
    38
    // basic fonts
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 205
diff changeset
    39
    CL_Font simple_font;
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 205
diff changeset
    40
393
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    41
    // view components
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    42
    GameMessageView message_view;
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    43
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    44
public:
389
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    45
    Graphics (Engine &engine, GameState &state, PixelCoordinate resolution, bool fullscreen);
392
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    46
    
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    47
    /**
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    48
     * Returns a CL_Font that can be used for drawing text
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    49
     */
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 205
diff changeset
    50
    CL_Font& getSimpleFont (void) { return simple_font; }
392
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    51
    
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    52
    /**
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    53
     * Returns a vector of CL_DisplayModes that lists possible display modes to use for fullscreen mode.
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    54
     */
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    55
    static const std::vector<CL_DisplayMode> & getDisplayModes (void);
389
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    56
392
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    57
    /**
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    58
     * Returns the "best" CL_DisplayMode to use for fullscreen mode.
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    59
     *
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    60
     * Currently, this just means the largest resolution.
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    61
     */
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    62
    static const CL_DisplayMode getBestMode (void);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    63
    
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    64
private:
389
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    65
    /**
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    66
     * Reads current input events from Input and applies them, using LocalPlayer::handleInput and
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    67
     * Graphics::handle_input.
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    68
     */
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 283
diff changeset
    69
    void check_input (void);
389
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    70
    
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    71
    /**
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    72
     * Handles GuiInput flags read from Input.
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    73
     */
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    74
    void handle_input (GuiInput flags);
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    75
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    76
    void do_redraw (void);
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    77
    
205
905028e58ed1 implement a new tick-timer that doesn't suck
terom
parents: 185
diff changeset
    78
    void on_update (TimeMS tick_length);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    79
    
315
fe9da2d5355e better colors on downbar
nireco
parents: 311
diff changeset
    80
    void draw_player_info(CL_GraphicContext *gc, Player *p);
393
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    81
        
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    82
protected:
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    83
    /* GameStateEventHandler */    
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    84
    virtual void on_player_joined (Player *p);
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 392
diff changeset
    85
    virtual void on_player_left (Player *p);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    86
};
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    87
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    88
#endif /* GRAPHICS_HH */