pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src client.cxx,1.9,1.10 client.hxx,1.7,1.


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src client.cxx,1.9,1.10 client.hxx,1.7,1.8 game_session.cxx,1.3,1.4 game_session.hxx,1.4,1.5 gui_screen.cxx,1.1,1.2 gui_screen.hxx,1.1,1.2 playfield.cxx,1.9,1.10 view.cxx,1.5,1.6 view.hxx,1.4,1.5
Date: 2 Aug 2002 13:17:44 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv786

Modified Files:
        client.cxx client.hxx game_session.cxx game_session.hxx 
        gui_screen.cxx gui_screen.hxx playfield.cxx view.cxx view.hxx 
Log Message:
A few more events are now handled in the client

Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- client.cxx  2 Aug 2002 11:53:52 -0000       1.9
+++ client.cxx  2 Aug 2002 13:17:42 -0000       1.10
@@ -118,21 +118,7 @@
 void 
 Client::update (float delta)
 {
-  std::cout << "Client::update (float delta)" << std::endl;
-  //cursor->update (delta);
-  //process input events
-  //process_events ();
-
-  // Let the window move its content
-#if 0
-  for(GuiObjIter i = obj.begin (); i != obj.end (); ++i)
-    (*i)->updateX();
-  
-  for(GuiObjIter i = obj.begin (); i != obj.end (); ++i)
-    (*i)->update(delta);
-#endif 
   // Let the server process a game loop
-  server->update(delta);
   //send_next_event();
 
   /*float wannabe_delta = 0.0333f;
@@ -482,141 +468,31 @@
       if (verbose > 1) std::cout << "Client: Got unknown button: ID=" << 
key.id << " ASCII=" << char(key.ascii) << std::endl;
     }
 }
+#endif
 
 void
-Client::on_mouse_button_press(const CL_Key& key)
-{
-  // button_panel->on_button_press(key);
-  //small_map->on_button_press(key);
-
-  switch(key.id)
-    {
-    case CL_MOUSE_LEFTBUTTON:
-      playfield->on_button_press(key);
-      break;
-    case CL_MOUSE_MIDDLEBUTTON:
-      break;
-    case CL_MOUSE_RIGHTBUTTON:
-      playfield->enable_scroll_mode();
-      break;
-    default:
-      if (verbose > 1) std::cout << "Client: Unknown mouse button released: " 
<< key.id << std::endl;
-    }
-}
-
-void
-Client::on_mouse_button_release(const CL_Key& key)
-{
-  //button_panel->on_button_release(key);
-  //small_map->on_button_release(key);
-
-  switch(key.id)
-    {
-    case CL_MOUSE_LEFTBUTTON:
-      break;
-    case CL_MOUSE_MIDDLEBUTTON:
-      break;
-    case CL_MOUSE_RIGHTBUTTON:
-      playfield->disable_scroll_mode();
-      break;
-    default:
-      if (verbose > 1) std::cout << "Client: Unknown mouse button released: " 
<< key.id << std::endl;
-    }
-  return;
-}
-
-void
-Client:: on_left_pressed (const CL_Vector& pos)
-{
-  CL_Key key;
-  
-  key.id = CL_MOUSE_LEFTBUTTON;
-  key.x = pos.x;
-  key.y = pos.y;
-  
-  //button_panel->on_button_press(key);
-  //small_map->on_button_press(key);
-  playfield->on_button_press(key);
-}
-
-void
-Client:: on_left_released (const CL_Vector& pos)
-{
-  CL_Key key;
-  
-  key.id = CL_MOUSE_LEFTBUTTON;
-  key.x = pos.x;
-  key.y = pos.y;
-  
-  //button_panel->on_button_release(key);
-  //small_map->on_button_release(key);
-}
-
-
-void
-Client:: on_middle_pressed (const CL_Vector& /*pos*/)
-{
-  std::cout << "Middle Pressed" << std::endl;
-}
-
-void
-Client:: on_right_pressed (const CL_Vector& /*pos*/)
-{
-  //std::cout << "Right Pressed" << std::endl;
-  playfield->enable_scroll_mode();
-}
-
-void 
-Client::on_right_released (const CL_Vector& /*pos*/)
-{
-  //std::cout << "Right released" << std::endl;
-  playfield->disable_scroll_mode();
-}
-
-void
-Client:: on_abort_pressed (const CL_Vector& /*pos*/)
+Client:: on_escape_press ()
 {
   server->set_finished();
 }
 
 void
-Client:: on_pause_pressed (const CL_Vector& /*pos*/)
+Client:: on_pause_press ()
 {
   set_pause (!get_pause ());
 }
 
 void 
-Client::on_fast_forward_pressed (const CL_Vector& /*pos*/)
+Client::on_fast_forward_press ()
 {
   set_fast_forward(!get_fast_forward());
 }
 
-void
-Client::on_scroll_left_pressed (const CL_Vector& /*pos*/)
-{
-  std::cout << "Scroll left pressed" << std::endl;
-}
-
-void
-Client::on_scroll_right_pressed (const CL_Vector& /*pos*/)
-{
-  std::cout << "Scroll right pressed" << std::endl;
-}
-
 void 
-Client::on_next_action_pressed (const CL_Vector& /*pos*/)
-{
-  std::cout << "Action next pressed" << std::endl;
-  button_panel->next_action();
-}
-
-void 
-Client::on_previous_action_pressed (const CL_Vector& /*pos*/)
+Client::on_armageddon_press ()
 {
-  std::cout << "Action previous pressed" << std::endl;
-  button_panel->previous_action();
+  server->send_event("armageddon");
 }
-#endif
 
 void
 Client::draw ()
@@ -627,7 +503,6 @@
 void
 Client::update (const GameDelta& delta)
 {
-  std::cout << "Client:update ()" << std::endl;
   update (delta.get_time ());
   GUIScreen::update (delta);
 }

Index: client.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- client.hxx  2 Aug 2002 11:25:46 -0000       1.7
+++ client.hxx  2 Aug 2002 13:17:42 -0000       1.8
@@ -116,6 +116,11 @@
   void update (const GameDelta& delta);
   void on_startup ();
   void on_shutdown ();
+
+  void on_pause_press ();
+  void on_fast_forward_press ();
+  void on_armageddon_press ();
+  void on_escape_press ();
 };
 
 #endif

Index: game_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- game_session.cxx    2 Aug 2002 11:25:46 -0000       1.3
+++ game_session.cxx    2 Aug 2002 13:17:42 -0000       1.4
@@ -57,7 +57,17 @@
 void
 PingusGameSession::update (const GameDelta& delta)
 {
+  server->update (delta.get_time ());
   client->update (delta);
 }
+
+void
+PingusGameSession::on_pause_press () { client->on_pause_press (); }
+void
+PingusGameSession::on_fast_forward_press () {client->on_fast_forward_press (); 
}
+void
+PingusGameSession::on_armageddon_press () {client->on_armageddon_press (); }
+void
+PingusGameSession::on_escape_press () { client->on_escape_press (); }
 
 /* EOF */

Index: game_session.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- game_session.hxx    2 Aug 2002 11:25:46 -0000       1.4
+++ game_session.hxx    2 Aug 2002 13:17:42 -0000       1.5
@@ -68,6 +68,10 @@
   /** Pass a delta to the screen */
   void update (const GameDelta& delta);
 
+  void on_pause_press ();
+  void on_fast_forward_press ();
+  void on_armageddon_press ();
+  void on_escape_press ();
 };
 
 #endif

Index: gui_screen.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui_screen.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gui_screen.cxx      1 Aug 2002 21:40:01 -0000       1.1
+++ gui_screen.cxx      2 Aug 2002 13:17:42 -0000       1.2
@@ -17,7 +17,9 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <iostream>
 #include "gui/gui_manager.hxx"
+#include "input/button_event.hxx"
 #include "gui_screen.hxx"
 
 using namespace GUI;
@@ -44,6 +46,73 @@
 GUIScreen::update (const GameDelta& delta)
 {
   gui_manager->update (delta);
+
+  for (std::list<Input::Event*>::const_iterator i = delta.get_events ().begin 
(); 
+       i != delta.get_events ().end (); ++i)
+    {
+      switch ((*i)->get_type())
+       {
+       case Input::PointerEventType:
+         {
+           // ignored cause this is handled in the gui_manager
+         }
+         break;
+
+       case Input::ButtonEventType:
+         {
+           process_button_event (dynamic_cast<Input::ButtonEvent*>(*i));
+         }
+         break;
+
+       case Input::AxisEventType:
+         {
+           
+         }
+         break;
+
+       case Input::ScrollEventType:
+         {
+           
+         }
+         break;
+
+       default:
+         std::cout << "GUIScreen::update (): unhandled event type: " << 
(*i)->get_type() << std::endl;
+         break;
+       }
+    }
+}
+
+void
+GUIScreen::process_button_event (Input::ButtonEvent* event)
+{
+  if (event->state == Input::pressed) // FIXME: We ignore releases for the 
moment
+    {
+      switch (event->name)
+       {
+       case Input::primary:
+         // ignoring, handled in the gui_manager
+         break; 
+       case Input::secondary:
+         // ignoring, handled in the gui_manager
+         break;
+       case Input::pause:
+         on_pause_press ();
+         break;
+       case Input::fast_forward:
+         on_fast_forward_press ();
+         break;
+       case Input::armageddon:
+         on_armageddon_press ();
+         break;
+       case Input::escape:
+         on_escape_press ();
+         break;
+       default:
+         std::cout << "ButtonEvent: unhandled event: " << event->name << 
std::endl;
+         break;
+       }
+    }
 }
 
 /* EOF */

Index: gui_screen.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui_screen.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gui_screen.hxx      1 Aug 2002 21:40:01 -0000       1.1
+++ gui_screen.hxx      2 Aug 2002 13:17:42 -0000       1.2
@@ -28,6 +28,11 @@
   class GUIManager;
 }
 
+namespace Input
+{
+  class ButtonEvent;
+}
+
 class GUIScreen : public Screen
 {
 protected:
@@ -42,6 +47,14 @@
 
   /** Pass a delta to the screen */
   virtual void update (const GameDelta& delta);
+
+  virtual void on_pause_press () {}
+  virtual void on_fast_forward_press () {}
+  virtual void on_armageddon_press () {}
+  virtual void on_escape_press () {}
+
+private:
+  void process_button_event (Input::ButtonEvent* event);
 };
 
 #endif

Index: playfield.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- playfield.cxx       2 Aug 2002 11:53:52 -0000       1.9
+++ playfield.cxx       2 Aug 2002 13:17:42 -0000       1.10
@@ -178,10 +178,11 @@
 #endif
 
 void
-Playfield::update(float /*delta*/)
+Playfield::update(float delta)
 {
   for(unsigned int i=0; i < view.size(); ++i)
     {
+      view[i]->update (delta);
       if (view[i]->is_current() && !mouse_scrolling)
        { 
          current_view = i;

Index: view.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/view.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- view.cxx    2 Aug 2002 11:53:52 -0000       1.5
+++ view.cxx    2 Aug 2002 13:17:42 -0000       1.6
@@ -57,19 +57,7 @@
 View::draw()
 {
   assert(world);
-  float color;
-
-  if (is_over(mouse_x, mouse_y))
-    {
-      color = 1.0;
-      mouse_over = true;
-    } 
-  else 
-    {
-      color = 0.0;
-      mouse_over = false;
-    }
-
+  
   CL_Display::push_clip_rect();
   CL_Display::set_clip_rect(clip_rect);
 
@@ -84,6 +72,19 @@
                  size);
   
   CL_Display::pop_clip_rect();
+}
+
+void
+View::update (float /*delta */)
+{
+  if (is_over(mouse_x, mouse_y))
+    {
+      mouse_over = true;
+    }
+  else 
+    {
+      mouse_over = false;
+    }
 }
 
 void

Index: view.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/view.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- view.hxx    2 Aug 2002 11:53:52 -0000       1.4
+++ view.hxx    2 Aug 2002 13:17:42 -0000       1.5
@@ -71,6 +71,8 @@
   ~View();
 
   void draw();
+  void update(float);
+
   bool is_over(int x, int y);
   bool is_current();
   int  get_x_offset() const;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]