16 if (player) |
16 if (player) |
17 setPlayer(player); |
17 setPlayer(player); |
18 |
18 |
19 // insert message |
19 // insert message |
20 message_view.add_message(CL_Color::white, "Hello World!"); |
20 message_view.add_message(CL_Color::white, "Hello World!"); |
|
21 |
|
22 // enable GUI input |
|
23 graphics->input.gui.enable(); |
21 } |
24 } |
22 |
25 |
23 void GameView::setPlayer (LocalPlayer *player) { |
26 void GameView::setPlayer (LocalPlayer *player) { |
24 assert(!this->player && player); |
27 assert(!this->player && player); |
25 |
28 |
26 // remember it |
29 // remember it |
27 this->player = player; |
30 this->player = player; |
28 |
31 |
29 // build the info_view as well |
32 // build the info_view as well |
30 info_view = new PlayerInfoView(getInfoViewArea(), player); |
33 info_view = new PlayerInfoView(getInfoViewArea(), player); |
|
34 |
|
35 // enable player input |
|
36 graphics->input.player.enable(); |
31 } |
37 } |
|
38 |
|
39 void GameView::handleInput (GuiInput flags, TimeMS dt) { |
|
40 // ignore timing info |
|
41 (void) dt; |
|
42 |
|
43 // update our flags |
|
44 this->flags = flags; |
|
45 |
|
46 // quit? |
|
47 if (flags & GUI_INPUT_QUIT) { |
|
48 graphics->engine.stop(); |
|
49 return; |
|
50 } |
|
51 |
|
52 // dump player debug info on stderr |
|
53 if ((flags & GUI_INPUT_DEBUG_PLAYER) && player) { |
|
54 player->printDebugInfo(); |
|
55 |
|
56 message_view.add_message(CL_Color::green, "..."); |
|
57 } |
|
58 |
|
59 // toggle fullscreen? |
|
60 if (flags & GUI_INPUT_TOGGLE_FULLSCREEN) |
|
61 graphics->display.toggleFullscreen(); |
|
62 } |
|
63 |
32 |
64 |
33 /* |
65 /* |
34 * Helper function for Camera |
66 * Helper function for Camera |
35 */ |
67 */ |
36 static PixelDimension value_between (PixelDimension low, PixelDimension value, PixelDimension high) { |
68 static PixelDimension value_between (PixelDimension low, PixelDimension value, PixelDimension high) { |
47 return value; |
79 return value; |
48 } |
80 } |
49 |
81 |
50 void GameView::draw (Display &display) { |
82 void GameView::draw (Display &display) { |
51 CL_GraphicContext *gc = display.get_gc(); |
83 CL_GraphicContext *gc = display.get_gc(); |
|
84 |
|
85 // XXX: these should not be done from here |
|
86 handleInput(graphics->input.readGuiInput(), 0); |
|
87 |
|
88 // XXX: this should /really/ be somewhere else |
|
89 if (player) { |
|
90 PlayerInput input; |
|
91 TimeMS dt; |
|
92 |
|
93 graphics->input.readPlayerInput(input, dt); |
|
94 |
|
95 player->handleInput(input, dt); |
|
96 } |
52 |
97 |
53 // calculate camera |
98 // calculate camera |
54 PixelCoordinate camera(0, 0); |
99 PixelCoordinate camera(0, 0); |
55 |
100 |
56 // ...to track our local player |
101 // ...to track our local player |