author | Tero Marttila <terom@fixme.fi> |
Tue, 20 Jan 2009 23:30:18 +0200 | |
changeset 408 | e6cfc44266af |
parent 394 | 82def222fe7d |
child 409 | 1a03ff151abc |
permissions | -rw-r--r-- |
25 | 1 |
|
2 |
#include "Graphics.hh" |
|
86 | 3 |
#include "GameState.hh" |
108 | 4 |
#include <cmath> |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
5 |
#include <sstream> |
25 | 6 |
|
393
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
7 |
/* |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
8 |
* XXX: until we figure out a better way to layout stuff |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
9 |
*/ |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
10 |
static PixelArea getMessageViewArea (PixelCoordinate resolution) { |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
11 |
return PixelArea( |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
12 |
400, |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
13 |
resolution.y - 100, |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
14 |
resolution.x, |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
15 |
resolution.y |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
16 |
); |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
17 |
} |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
18 |
|
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
394
diff
changeset
|
19 |
Graphics::Graphics (Engine &engine, GameState &state, const GraphicsConfiguration &config) : |
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
394
diff
changeset
|
20 |
CL_DisplayWindow(GRAPHICS_WINDOW_TITLE, config.resolution.x, config.resolution.y, config.fullscreen, true), |
25 | 21 |
engine(engine), |
22 |
state(state), |
|
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
394
diff
changeset
|
23 |
resolution(config.resolution), |
394
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
24 |
fullscreen_resolution(0, 0), window_resolution(0, 0), |
25 | 25 |
update_timer(GRAPHICS_UPDATE_INTERVAL_MS), |
235 | 26 |
input(get_ic()->get_keyboard()), |
393
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
27 |
simple_font("Font2", engine.getResourceManager()), |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
28 |
message_view(getMessageViewArea(resolution)) |
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:
230
diff
changeset
|
29 |
{ |
86 | 30 |
|
25 | 31 |
// connect timer signal |
205 | 32 |
slots.connect(update_timer.sig_tick(), this, &Graphics::on_update); |
394
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
33 |
slots.connect(this->sig_resize(), this, &Graphics::on_window_resize); |
25 | 34 |
|
35 |
// enable |
|
205 | 36 |
update_timer.start(); |
393
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
37 |
|
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
38 |
// push something to message_view |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
39 |
message_view.add_message(CL_Color::white, "Hello World"); |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
40 |
|
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
41 |
// GameState events.... |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
42 |
state.setEventHandler(this); |
394
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
43 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
44 |
// set correct resolution |
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
394
diff
changeset
|
45 |
if (config.fullscreen) { |
394
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
46 |
fullscreen_resolution = resolution; |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
47 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
48 |
} else { |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
49 |
CL_DisplayMode best_mode = getBestMode(); |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
50 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
51 |
fullscreen_resolution = PixelCoordinate(best_mode.get_resolution().width, best_mode.get_resolution().height); |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
52 |
window_resolution = resolution; |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
53 |
} |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
54 |
|
25 | 55 |
} |
56 |
||
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
57 |
const std::vector<CL_DisplayMode> & Graphics::getDisplayModes (void) { |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
58 |
return CL_DisplayMode::get_display_modes(); |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
59 |
} |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
60 |
|
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
|
61 |
const CL_DisplayMode Graphics::getBestMode (void) { |
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 |
const std::vector<CL_DisplayMode> &modes = Graphics::getDisplayModes(); |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
63 |
|
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
64 |
const CL_DisplayMode *best_mode = NULL; |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
65 |
|
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
66 |
for (std::vector<CL_DisplayMode>::const_iterator it = modes.begin(); it != modes.end(); it++) |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
67 |
if (best_mode == NULL || ( |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
68 |
it->get_resolution().width * it->get_resolution().height > |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
69 |
best_mode->get_resolution().width * best_mode->get_resolution().height |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
70 |
)) |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
71 |
best_mode = &*it; |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
72 |
|
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
73 |
if (best_mode == NULL) |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
74 |
throw Error("No available video modes!"); |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
75 |
|
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
76 |
return *best_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
|
77 |
} |
6c4dc68360eb
remove unused graphics_default, and default to the highest resolution available in fullscreen mode
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
78 |
|
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
79 |
void Graphics::check_input (void) { |
25 | 80 |
LocalPlayer *player; |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
81 |
PlayerInput input_mask; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
82 |
TimeMS input_dt; |
25 | 83 |
|
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:
230
diff
changeset
|
84 |
// update gui flags |
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
85 |
handle_input(input.readGuiInput()); |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
86 |
|
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
87 |
// stop here if we don't have a local player |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
88 |
if ((player = state.getLocalPlayer()) == NULL) |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
89 |
return; |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
90 |
|
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
91 |
// build input_mask |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
92 |
input.readPlayerInput(input_mask, input_dt); |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
93 |
|
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
94 |
// apply input if there was any |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
95 |
if (input_mask) |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
96 |
player->handleInput(input_mask, input_dt); |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
97 |
} |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
98 |
|
394
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
99 |
void Graphics::toggle_fullscreen (void) { |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
100 |
if (is_fullscreen()) { |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
101 |
// remember current fullscreen resolution |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
102 |
fullscreen_resolution = resolution; |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
103 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
104 |
// enter windowed mode |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
105 |
set_windowed(); |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
106 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
107 |
/* |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
108 |
// do we have a window-mode resolution stored? |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
109 |
if (window_resolution.x && window_resolution.y) |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
110 |
set_size(window_resolution.x, window_resolution.y); |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
111 |
*/ |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
112 |
} else { |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
113 |
// remember current window resolution |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
114 |
window_resolution = resolution; |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
115 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
116 |
// enter fullscreen mode |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
117 |
set_fullscreen(fullscreen_resolution.x, fullscreen_resolution.y); |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
118 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
119 |
// update resolution |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
120 |
resolution = fullscreen_resolution; |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
121 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
122 |
// log |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
123 |
message_view.add_message(CL_Color::yellow, CL_String::format("[ Enter fullscreen mode with %1 x %2 resolution ]", |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
124 |
(int) resolution.x, (int) resolution.y)); |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
125 |
} |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
126 |
} |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
127 |
|
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
128 |
void Graphics::handle_input (GuiInput flags) { |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
129 |
// update flags |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
130 |
this->flags = flags; |
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:
230
diff
changeset
|
131 |
|
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
132 |
// quit? |
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
133 |
if (flags & GUI_INPUT_QUIT) { |
108 | 134 |
engine.stop(); |
25 | 135 |
|
108 | 136 |
return; |
25 | 137 |
} |
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
138 |
|
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
139 |
// dump player debug info on stderr |
393
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
140 |
if ((flags & GUI_INPUT_DEBUG_PLAYER) && state.getLocalPlayer()) { |
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
141 |
state.getLocalPlayer()->printDebugInfo(); |
393
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
142 |
|
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
143 |
message_view.add_message(CL_Color::green, "..."); |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
144 |
} |
25 | 145 |
|
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
146 |
// toggle fullscreen? |
394
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
147 |
if (flags & GUI_INPUT_TOGGLE_FULLSCREEN) |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
148 |
toggle_fullscreen(); |
25 | 149 |
} |
150 |
||
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
151 |
static PixelDimension value_between (PixelDimension low, PixelDimension value, PixelDimension high) { |
316
d909a7e36f8d
value_between now puts small map in the center, or at least should
nireco
parents:
315
diff
changeset
|
152 |
if (high < low) |
d909a7e36f8d
value_between now puts small map in the center, or at least should
nireco
parents:
315
diff
changeset
|
153 |
return (high + low) / 2; |
d909a7e36f8d
value_between now puts small map in the center, or at least should
nireco
parents:
315
diff
changeset
|
154 |
|
d909a7e36f8d
value_between now puts small map in the center, or at least should
nireco
parents:
315
diff
changeset
|
155 |
else if (value < low) |
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
156 |
return low; |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
157 |
|
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
158 |
else if (value > high) |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
159 |
return high; |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
160 |
|
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
161 |
else |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
162 |
return value; |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
163 |
} |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
164 |
|
25 | 165 |
void Graphics::do_redraw (void) { |
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:
230
diff
changeset
|
166 |
CL_GraphicContext *gc = get_gc(); |
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
167 |
LocalPlayer *player; |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
168 |
|
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
169 |
// calculate camera |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
170 |
PixelCoordinate camera(0, 0); |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
171 |
|
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
172 |
// ...to track our local player |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
173 |
if ((player = state.getLocalPlayer()) != NULL) { |
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
174 |
// try and center the screen on the player |
318 | 175 |
PixelCoordinate target = player->getCoordinate() - PixelCoordinate(resolution.x / 2, (resolution.y - 100) / 2); |
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
176 |
|
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
177 |
// ...but keep the world in view |
408
e6cfc44266af
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents:
394
diff
changeset
|
178 |
PixelCoordinate max = state.terrain.getDimensions() - resolution + PixelCoordinate(0, 100); |
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
179 |
|
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
180 |
// ...by limiting the value to 0...max |
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
181 |
camera = PixelCoordinate( |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
182 |
value_between(0, target.x, max.x), |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
183 |
value_between(0, target.y, max.y) |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
184 |
); |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
185 |
} |
25 | 186 |
|
312 | 187 |
// Black background |
248 | 188 |
gc->clear(CL_Color::black); |
25 | 189 |
|
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:
230
diff
changeset
|
190 |
// Draw the game |
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
191 |
state.draw(this, camera, flags & GUI_INPUT_DISPLAY_WEAPON); |
393
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
192 |
|
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
193 |
// draw player info box |
312 | 194 |
if (player != NULL) { |
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
195 |
draw_player_info(gc, player); |
312 | 196 |
} |
393
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
197 |
|
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
198 |
// draw messages |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
199 |
message_view.draw(this); |
312 | 200 |
|
184 | 201 |
// Flip window buffer, sync |
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:
230
diff
changeset
|
202 |
flip(1); |
25 | 203 |
} |
204 |
||
205 | 205 |
void Graphics::on_update (TimeMS tick_length) { |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
206 |
(void) tick_length; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
207 |
|
25 | 208 |
// check keyboard input |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
209 |
check_input(); |
25 | 210 |
|
211 |
// redraw display |
|
212 |
do_redraw(); |
|
213 |
} |
|
315 | 214 |
|
215 |
void Graphics::draw_player_info(CL_GraphicContext *gc, Player *p) { |
|
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
216 |
int box_top = resolution.y - 100; |
315 | 217 |
int box_left = 0; |
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
218 |
int box_right = resolution.x; |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
219 |
int box_bottom = resolution.y; |
318 | 220 |
int bar_length = 3; // *100 |
315 | 221 |
|
222 |
// draw status info at bottom of display |
|
223 |
gc->fill_rect( |
|
224 |
CL_Rect( |
|
225 |
box_left, |
|
226 |
box_top, |
|
227 |
box_right, |
|
228 |
box_bottom |
|
229 |
), |
|
230 |
CL_Gradient( |
|
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
231 |
CL_Color(0, 0, 0), |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
232 |
CL_Color(50, 50, 50), |
315 | 233 |
CL_Color(50, 50, 50, 150), |
234 |
CL_Color(100, 100, 100, 200) |
|
235 |
) |
|
236 |
); |
|
318 | 237 |
|
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
238 |
// Health |
315 | 239 |
gc->draw_rect( |
240 |
CL_Rect( |
|
241 |
box_left + 9, |
|
242 |
box_top + 9, |
|
318 | 243 |
box_left + 11 + 100 * bar_length, |
315 | 244 |
box_top + 31 |
245 |
), |
|
246 |
CL_Color(150, 150, 150) |
|
247 |
); |
|
248 |
||
249 |
gc->fill_rect( |
|
250 |
CL_Rect( |
|
251 |
box_left + 10, |
|
252 |
box_top + 10, |
|
318 | 253 |
box_left + 10 + (int) (p->getHealthPercent() * bar_length), |
315 | 254 |
box_top + 30 |
255 |
), |
|
256 |
CL_Gradient( |
|
257 |
CL_Color(200, 0, 0), |
|
258 |
CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0), |
|
259 |
CL_Color(200, 0, 0), |
|
260 |
CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0) |
|
261 |
) |
|
262 |
); |
|
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
263 |
|
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
264 |
// stats - kills |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
265 |
std::stringstream sskills; |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
266 |
sskills << "Kills: " << p->getKills(); |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
267 |
getSimpleFont().draw( |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
268 |
box_left + 20 + 100 * bar_length, |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
269 |
box_top + 10, |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
270 |
sskills.str(), |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
271 |
get_gc() |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
272 |
); |
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
273 |
|
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
274 |
// stats - deaths |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
275 |
std::stringstream ssdeaths; |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
276 |
ssdeaths << "Deaths: " << p->getDeaths(); |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
277 |
getSimpleFont().draw( |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
278 |
box_left + 20 + 100 * bar_length, |
326 | 279 |
box_top + 30, |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
280 |
ssdeaths.str(), |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
281 |
get_gc() |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
282 |
); |
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
283 |
|
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
284 |
// stats - ratio |
326 | 285 |
std::stringstream ssratio; |
286 |
ssratio << "Ratio: " << (p->getKills()+1) / (p->getDeaths()+1); |
|
287 |
getSimpleFont().draw( |
|
288 |
box_left + 20 + 100 * bar_length, |
|
289 |
box_top + 50, |
|
290 |
ssratio.str(), |
|
291 |
get_gc() |
|
292 |
); |
|
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
293 |
|
318 | 294 |
|
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
295 |
// Weapon clip / reloading |
318 | 296 |
gc->draw_rect( |
297 |
CL_Rect( |
|
298 |
box_left + 9, |
|
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
299 |
box_top + 69, |
318 | 300 |
box_left + 11 + 100 * bar_length, |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
301 |
box_top + 91 |
318 | 302 |
), |
303 |
CL_Color(150, 150, 150) |
|
304 |
); |
|
305 |
||
306 |
gc->fill_rect( |
|
307 |
CL_Rect( |
|
308 |
box_left + 10, |
|
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
309 |
box_top + 70, |
354 | 310 |
box_left + 10 + (100 - (int) (p->getCurrentWeapon()->getReloadTimer() * 100 / p->getCurrentWeapon()->getReloadTime())) * bar_length, |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
311 |
box_top + 90 |
318 | 312 |
), |
313 |
CL_Gradient( |
|
314 |
CL_Color(100, 100, 0), |
|
315 |
CL_Color(100, 100, 0), |
|
316 |
CL_Color(100, 100, 0), |
|
317 |
CL_Color(100, 100, 100) |
|
318 |
) |
|
319 |
); |
|
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
320 |
|
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
321 |
// current weapon name |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
322 |
getSimpleFont().draw( |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
323 |
box_left + 20 + 100 * bar_length, |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
324 |
box_top + 70, |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
325 |
p->getCurrentWeapon()->getName(), |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
326 |
get_gc() |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
327 |
); |
393
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
328 |
|
315 | 329 |
} |
330 |
||
394
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
331 |
void Graphics::on_window_resize (int new_x, int new_y) { |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
332 |
// ignore resize in fullscreen mode |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
333 |
if (is_fullscreen()) |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
334 |
return; |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
335 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
336 |
// update resolution |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
337 |
resolution = PixelCoordinate(new_x, new_y); |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
338 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
339 |
// resize components |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
340 |
message_view.on_resize(getMessageViewArea(resolution)); |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
341 |
|
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
342 |
// log message |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
343 |
message_view.add_message(CL_Color::yellow, CL_String::format("[ Resized window to %1 x %2 ]", new_x, new_y)); |
82def222fe7d
try and implement resize in a sane way, but changeing from windowed mode to fullscreen mode is now kind of weird
Tero Marttila <terom@fixme.fi>
parents:
393
diff
changeset
|
344 |
} |
393
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
345 |
|
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
346 |
void Graphics::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
|
347 |
message_view.add_message(CL_Color::white, " *** Player joined"); |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
348 |
} |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
349 |
|
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
350 |
void Graphics::on_player_left (Player *p) { |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
351 |
message_view.add_message(CL_Color::white, " *** Player left"); |
5dd4d782cf3a
a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents:
392
diff
changeset
|
352 |
} |