2 * Copyright (c) 2007-2013, Czirkos Zoltan http://code.google.com/p/gdash/
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef _GD_GAMERENDERER
18 #define _GD_GAMERENDERER
25 #include "cave/cavetypes.hpp"
26 #include "cave/helper/colors.hpp"
36 #define GAME_RENDERER_SCREEN_SIZE_X (20)
37 #define GAME_RENDERER_SCREEN_SIZE_Y (12.5)
39 enum GdStatusBarType
{
40 GD_STATUS_BAR_ORIGINAL
,
44 GD_STATUS_BAR_ATARI_ORIGINAL
,
47 // should be the last from the status bar type
48 GD_STATUS_BAR_MAX
=int(GD_STATUS_BAR_ATARI_ORIGINAL
)
50 const char **gd_status_bar_colors_get_names();
55 /// @brief This class manages drawing the cave and scrolling on the screen; it also
56 /// receives keypresses (controls) from the user and passes it to the game
57 /// controlling class GameControl.
59 /// The GameRenderer class can be used the following way:
60 /// - Creating an object, and assigning it a CellRenderer, a FontManager, a Screen
61 /// for the graphics stuff, and a GameControl object to control the game.
62 /// - The GameRenderer::main_int() function is to be called regurarly, and passed
63 /// the number of milliseconds elapsed (that can be 20 or 40), and the user
65 /// The object will then control the game and also draw it. And that's all.
66 /// Showing the story, scrolling the cave, drawing the status bar, enabling and
67 /// disabling game pause and everything is handled inside.
71 FontManager
&font_manager
;
83 bool show_replay_sign
;
85 int scroll_x
, scroll_y
;
86 int scroll_desired_x
, scroll_desired_y
;
88 // for showing the story
89 std::vector
<std::string
> wrapped_story
;
90 int story_y
, story_max_y
;
91 unsigned linesavailable
;
92 Pixmap
*story_background
;
96 void drawcave(bool force_draw
);
97 static bool cave_scroll(int logical_size
, int physical_size
, int center
, bool exact
, int start
, int to
, int ¤t
, int &desired
, int speed
, int cell_size
);
98 bool scroll(int ms
, bool exact_scroll
);
99 void scroll_to_origin();
102 bool showheader_firstline(bool in_game
);
103 void showheader_uncover();
104 void showheader_game(bool alternate_status_bar
, bool fast_forward
);
105 void showheader_gameover();
106 void showheader_pause();
108 void set_colors_from_cave();
109 void select_status_bar_colors();
111 struct StatusBarColors
{
113 GdColor diamond_needed
;
114 GdColor diamond_value
;
115 GdColor diamond_collected
;
117 GdColor default_color
;
119 StatusBarColors cols
;
124 GameRenderer(Screen
&screen_
, CellRenderer
&cells_
, FontManager
&font_manager_
, GameControl
&game_
);
135 State
main_int(int ms
, GdDirectionEnum player_move
, bool fire
, bool &suicide
, bool &restart
, bool paused
, bool alternate_status
, bool fast_forward
);
138 * Show replay sign means that for non-real-game game types,
139 * the status bar can show the type ("PLAYING REPLAY" or "TESTING CAVE").
140 * By default, it is turned on.
142 void set_show_replay_sign(bool srs
);
145 * The user can request some random colors if he does not like the
146 * ones from the cave. */
147 void set_random_colors();
150 * Call this to redraw everything.