src/Graphics/GameView.cc
branchnew_graphics
changeset 416 38cba347a3a9
parent 414 cede5463b845
equal deleted inserted replaced
415:c1069d23890b 416:38cba347a3a9
    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 
    21 
    22     // enable GUI input
    22     // enable GUI input
       
    23     slots.connect(graphics->input.gui.sig_input(), this, &GameView::handleInput);
    23     graphics->input.gui.enable();
    24     graphics->input.gui.enable();
    24 }
    25 }
    25 
    26 
    26 void GameView::setPlayer (LocalPlayer *player) {
    27 void GameView::setPlayer (LocalPlayer *player) {
    27     assert(!this->player && player);
    28     assert(!this->player && player);
    31 
    32 
    32     // build the info_view as well
    33     // build the info_view as well
    33     info_view = new PlayerInfoView(getInfoViewArea(), player);
    34     info_view = new PlayerInfoView(getInfoViewArea(), player);
    34 
    35 
    35     // enable player input
    36     // enable player input
       
    37     slots.connect(graphics->input.player.sig_input(), player, &LocalPlayer::handleInput);
    36     graphics->input.player.enable();
    38     graphics->input.player.enable();
    37 }
    39 }
    38 
    40 
    39 void GameView::handleInput (GuiInput flags, TimeMS dt) {
    41 void GameView::handleInput (GuiInput flags, TimeMS dt) {
    40     // ignore timing info
    42     // ignore timing info
    80 }
    82 }
    81 
    83 
    82 void GameView::draw (Display &display) {
    84 void GameView::draw (Display &display) {
    83     CL_GraphicContext *gc = display.get_gc();
    85     CL_GraphicContext *gc = display.get_gc();
    84     
    86     
    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     }
       
    97 
       
    98     // calculate camera
    87     // calculate camera
    99     PixelCoordinate camera(0, 0);
    88     PixelCoordinate camera(0, 0);
   100     
    89     
   101     // ...to track our local player
    90     // ...to track our local player
   102     if (player != NULL) {
    91     if (player != NULL) {