src/Graphics.hh
author Tero Marttila <terom@fixme.fi>
Tue, 13 Jan 2009 21:36:43 +0200
changeset 392 6c4dc68360eb
parent 389 e74c1820fbd2
child 393 5dd4d782cf3a
permissions -rw-r--r--
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
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
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    12
#include <ClanLib/core.h>
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    13
#include <ClanLib/gl.h>
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    14
#include <ClanLib/display.h>
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    15
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 275
diff changeset
    16
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 275
diff changeset
    17
 * 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
    18
 * 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
    19
 */
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
    20
class Graphics : public CL_DisplayWindow {
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    21
private:
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    22
    Engine &engine;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    23
    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
    24
ad72d0a0cc02 increase the map size and control the camera to always have the screen full of terrain
terom
parents: 235
diff changeset
    25
    PixelCoordinate resolution;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    26
    
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    27
    CL_SlotContainer slots;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    28
    
205
905028e58ed1 implement a new tick-timer that doesn't suck
terom
parents: 185
diff changeset
    29
    Timer update_timer;
235
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
    30
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
    31
    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
    32
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
    33
    // 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
    34
    GuiInput flags;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    35
    
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
    36
    // 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
    37
    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
    38
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    39
public:
389
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    40
    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
    41
    
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    42
    /**
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    43
     * 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
    44
     */
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
    45
    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
    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 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
    49
     */
6c4dc68360eb remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents: 389
diff changeset
    50
    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
    51
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
    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 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
    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
     * 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
    56
     */
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
    static const CL_DisplayMode getBestMode (void);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    58
    
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    59
private:
389
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    60
    /**
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    61
     * 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
    62
     * Graphics::handle_input.
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    63
     */
311
440763821484 make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents: 283
diff changeset
    64
    void check_input (void);
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
    /**
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    67
     * Handles GuiInput flags read from Input.
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    68
     */
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    69
    void handle_input (GuiInput flags);
e74c1820fbd2 implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents: 315
diff changeset
    70
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    71
    void do_redraw (void);
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    72
    
205
905028e58ed1 implement a new tick-timer that doesn't suck
terom
parents: 185
diff changeset
    73
    void on_update (TimeMS tick_length);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    74
    
315
fe9da2d5355e better colors on downbar
nireco
parents: 311
diff changeset
    75
    void draw_player_info(CL_GraphicContext *gc, Player *p);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    76
};
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    77
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    78
#endif /* GRAPHICS_HH */