--- a/src/Graphics/GameView.cc Wed Jan 21 23:25:29 2009 +0200
+++ b/src/Graphics/GameView.cc Thu Jan 22 00:02:53 2009 +0200
@@ -18,6 +18,9 @@
// insert message
message_view.add_message(CL_Color::white, "Hello World!");
+
+ // enable GUI input
+ graphics->input.gui.enable();
}
void GameView::setPlayer (LocalPlayer *player) {
@@ -28,8 +31,37 @@
// build the info_view as well
info_view = new PlayerInfoView(getInfoViewArea(), player);
+
+ // enable player input
+ graphics->input.player.enable();
}
+void GameView::handleInput (GuiInput flags, TimeMS dt) {
+ // ignore timing info
+ (void) dt;
+
+ // update our flags
+ this->flags = flags;
+
+ // quit?
+ if (flags & GUI_INPUT_QUIT) {
+ graphics->engine.stop();
+ return;
+ }
+
+ // dump player debug info on stderr
+ if ((flags & GUI_INPUT_DEBUG_PLAYER) && player) {
+ player->printDebugInfo();
+
+ message_view.add_message(CL_Color::green, "...");
+ }
+
+ // toggle fullscreen?
+ if (flags & GUI_INPUT_TOGGLE_FULLSCREEN)
+ graphics->display.toggleFullscreen();
+}
+
+
/*
* Helper function for Camera
*/
@@ -49,6 +81,19 @@
void GameView::draw (Display &display) {
CL_GraphicContext *gc = display.get_gc();
+
+ // XXX: these should not be done from here
+ handleInput(graphics->input.readGuiInput(), 0);
+
+ // XXX: this should /really/ be somewhere else
+ if (player) {
+ PlayerInput input;
+ TimeMS dt;
+
+ graphics->input.readPlayerInput(input, dt);
+
+ player->handleInput(input, dt);
+ }
// calculate camera
PixelCoordinate camera(0, 0);