~ubuntu-branches/ubuntu/precise/pingus/precise

« back to all changes in this revision

Viewing changes to src/gui/gui_manager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-02-28 19:44:25 UTC
  • mfrom: (4.1.4 hardy)
  • Revision ID: james.westby@ubuntu.com-20080228194425-e8ilohlijv02kgcf
Tags: 0.7.2-2
* Fix FTBFS with gcc-4.3 by adding the missing include in
  src/input/evdev_device.cpp (Closes: #462238):
   + debian/patches/20_fix_FTBFS_with_gcc-4.3.
* Rename former patch so that the filename reflects the order in which
  the patches are applied:
   - debian/patches/data_dir.patch
   + debian/patches/10_fix_data_directory.
* Bump Standards-Version from 3.7.2 to 3.7.3, no changes needed.
* Add a dh_desktop call in the arch-dep part of debian/rules.
* Adjust the “missing-dep-for-interpreter guile” override since lintian
  now lists an alternative for that dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  $Id: gui_manager.cpp 3265 2007-09-30 16:07:08Z grumbel $
 
2
//
 
3
//  Pingus - A free Lemmings clone
 
4
//  Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
 
5
//
 
6
//  This program is free software; you can redistribute it and/or
 
7
//  modify it under the terms of the GNU General Public License
 
8
//  as published by the Free Software Foundation; either version 2
 
9
//  of the License, or (at your option) any later version.
 
10
//
 
11
//  This program is distributed in the hope that it will be useful,
 
12
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//  GNU General Public License for more details.
 
15
//
 
16
//  You should have received a copy of the GNU General Public License
 
17
//  along with this program; if not, write to the Free Software
 
18
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
 
 
20
#include <algorithm>
 
21
#include "../debug.hpp"
 
22
#include "../globals.hpp"
 
23
#include "../input/event.hpp"
 
24
#include "display/display.hpp"
 
25
#include "screen/game_delta.hpp"
 
26
#include "gui_manager.hpp"
 
27
 
 
28
using namespace Input;
 
29
 
 
30
namespace GUI { 
 
31
 
 
32
GUIManager::GUIManager ()
 
33
  : GroupComponent(Rect(0, 0, Display::get_width(), Display::get_height()), false),
 
34
    mouse_pos(400,300)
 
35
{
 
36
}
 
37
 
 
38
GUIManager::GUIManager(const Rect& rect)
 
39
  : GroupComponent(rect),
 
40
    mouse_pos(400,300)
 
41
{
 
42
}
 
43
 
 
44
GUIManager::~GUIManager ()
 
45
{
 
46
}
 
47
 
 
48
void
 
49
GUIManager::update(const GameDelta& delta)
 
50
{
 
51
  process_input (delta);
 
52
  GroupComponent::update(delta.get_time());
 
53
}
 
54
 
 
55
void
 
56
GUIManager::process_input(const GameDelta& delta)
 
57
{
 
58
  const std::vector<Input::Event>& events = delta.get_events();
 
59
 
 
60
  for (std::vector<Input::Event>::const_iterator i = events.begin (); i != events.end (); ++i)
 
61
    {
 
62
      switch (i->type)
 
63
        {
 
64
          case Input::POINTER_EVENT_TYPE:
 
65
            mouse_pos.x = int(i->pointer.x);
 
66
            mouse_pos.y = int(i->pointer.y);
 
67
            on_pointer_move(mouse_pos.x, mouse_pos.y);
 
68
            break;
 
69
 
 
70
          case Input::BUTTON_EVENT_TYPE:
 
71
            if (i->button.name == PRIMARY_BUTTON)
 
72
              {
 
73
                if (i->button.state == Input::BUTTON_PRESSED)
 
74
                  on_primary_button_press(mouse_pos.x, mouse_pos.y);
 
75
                else if (i->button.state == Input::BUTTON_RELEASED)
 
76
                  on_primary_button_release(mouse_pos.x, mouse_pos.y);
 
77
              }
 
78
            else if (i->button.name == SECONDARY_BUTTON)
 
79
              {
 
80
                if (i->button.state == Input::BUTTON_PRESSED)
 
81
                  on_secondary_button_press(mouse_pos.x, mouse_pos.y);
 
82
                else if (i->button.state == Input::BUTTON_RELEASED)
 
83
                  on_secondary_button_release(mouse_pos.x, mouse_pos.y);
 
84
              }
 
85
            break;
 
86
 
 
87
          case Input::AXIS_EVENT_TYPE:
 
88
            // AxisEvents can be ignored in the GUI, they are handled elsewhere
 
89
            pout (PINGUS_DEBUG_GUI) << "GUIManager: AxisEvent: " << i->axis.dir << std::endl;
 
90
            break;
 
91
        
 
92
          case Input::KEYBOARD_EVENT_TYPE:
 
93
            on_key_pressed(i->keyboard.key);
 
94
            break;
 
95
 
 
96
          case Input::SCROLLER_EVENT_TYPE:
 
97
            break;
 
98
 
 
99
          default:
 
100
            pwarn (PINGUS_DEBUG_GUI) << "GUIManager: unhandled event type " << i->type << std::endl;
 
101
            break;
 
102
        }
 
103
    }
 
104
}
 
105
 
 
106
} // namespace GUI
 
107
 
 
108
/* EOF */