[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.4,1.5 action_butt
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.4,1.5 action_button.hxx,1.4,1.5 button_panel.cxx,1.7,1.8 button_panel.hxx,1.5,1.6 client.cxx,1.7,1.8 client.hxx,1.6,1.7 game_session.cxx,1.2,1.3 game_session.hxx,1.3,1.4 multiplayer_client_child.cxx,1.5,1.6 pingus_main.cxx,1.8,1.9 playfield.cxx,1.7,1.8 playfield.hxx,1.5,1.6 screen.hxx,1.4,1.5 screen_manager.cxx,1.3,1.4 screen_manager.hxx,1.4,1.5 theme.cxx,1.2,1.3 |
Date: |
2 Aug 2002 11:25:49 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv29308
Modified Files:
action_button.cxx action_button.hxx button_panel.cxx
button_panel.hxx client.cxx client.hxx game_session.cxx
game_session.hxx multiplayer_client_child.cxx pingus_main.cxx
playfield.cxx playfield.hxx screen.hxx screen_manager.cxx
screen_manager.hxx theme.cxx
Log Message:
even more gui/input cleanup, client still broken, but already half working
Index: action_button.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_button.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- action_button.cxx 29 Jul 2002 22:17:53 -0000 1.4
+++ action_button.cxx 2 Aug 2002 11:25:46 -0000 1.5
@@ -21,6 +21,7 @@
#include <ClanLib/Display/Display/display.h>
#include <ClanLib/Display/Font/font.h>
#include <ClanLib/Display/Input/mouse.h>
+
#include "globals.hxx"
#include "pingus_resource.hxx"
#include "action_button.hxx"
@@ -120,10 +121,10 @@
VerticalActionButton::~VerticalActionButton() {}
bool
-VerticalActionButton::mouse_over(const CL_Vector& pos)
+VerticalActionButton::mouse_over(int x, int y)
{
- if (pos.x > x_pos && pos.x < x_pos + 60
- && pos.y > y_pos && pos.y <= y_pos + 35)
+ if (x > x_pos && x < x_pos + 60
+ && y > y_pos && y <= y_pos + 35)
{
return true;
}
@@ -247,10 +248,10 @@
}
bool
-ForwardButton::mouse_over(const CL_Vector& pos)
+ForwardButton::mouse_over(int x, int y)
{
- if (pos.x > x_pos && pos.x < x_pos + int(surface.get_width())
- && pos.y > y_pos && pos.y < y_pos + int(surface.get_height()))
+ if (x > x_pos && x < x_pos + int(surface.get_width())
+ && y > y_pos && y < y_pos + int(surface.get_height()))
{
return true;
} else {
@@ -280,10 +281,10 @@
}
bool
-PauseButton::mouse_over(const CL_Vector& pos)
+PauseButton::mouse_over (int x, int y)
{
- if (pos.x > x_pos && pos.x < x_pos + int(surface.get_width())
- && pos.y > y_pos && pos.y < y_pos + int(surface.get_height()))
+ if (x > x_pos && x < x_pos + int(surface.get_width())
+ && y > y_pos && y < y_pos + int(surface.get_height()))
{
return true;
} else {
Index: action_button.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_button.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- action_button.hxx 29 Jul 2002 22:17:53 -0000 1.4
+++ action_button.hxx 2 Aug 2002 11:25:46 -0000 1.5
@@ -48,7 +48,7 @@
virtual ~Button();
virtual void draw() = 0;
- virtual bool mouse_over(const CL_Vector& pos) = 0;
+ virtual bool mouse_over (int x, int y) = 0;
};
// ----------------- snip --------------------
@@ -89,7 +89,7 @@
virtual ~ForwardButton();
void draw();
- bool mouse_over(const CL_Vector& pos);
+ bool mouse_over (int x, int y);
};
// ----------------- snip --------------------
@@ -107,7 +107,7 @@
virtual ~PauseButton();
void draw();
- bool mouse_over(const CL_Vector& pos);
+ bool mouse_over (int x, int y);
};
// ----------------- snip --------------------
@@ -148,7 +148,7 @@
/// Returns true if the button is pressed.
bool is_pressed();
- virtual bool mouse_over(const CL_Vector& pos) = 0;
+ virtual bool mouse_over(int x, int y) = 0;
void set_action_holder(ActionHolder* h);
};
@@ -166,7 +166,7 @@
virtual ~VerticalActionButton();
void draw();
- bool mouse_over(const CL_Vector& pos);
+ bool mouse_over (int x, int y);
};
// ----------------- snip --------------------
Index: button_panel.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- button_panel.cxx 29 Jul 2002 22:17:53 -0000 1.7
+++ button_panel.cxx 2 Aug 2002 11:25:46 -0000 1.8
@@ -22,7 +22,6 @@
#include <ClanLib/Display/Display/display.h>
#include "globals.hxx"
#include "button_panel.hxx"
-#include "controller.hxx"
#include "client.hxx"
#include "server.hxx"
#include "world.hxx"
@@ -32,12 +31,10 @@
CL_Surface ButtonPanel::button_cap;
-ButtonPanel::ButtonPanel(PLF* plf, Controller* arg_controller,
- int arg_x_pos, int arg_y_pos)
+ButtonPanel::ButtonPanel(PLF* plf, int arg_x_pos, int arg_y_pos)
: armageddon_pressed(false),
left_pressed(0),
last_press(0),
- controller (arg_controller),
x_pos (arg_x_pos),
y_pos (arg_y_pos)
{
@@ -59,7 +56,7 @@
{
a_buttons.push_back(new VerticalActionButton (x_pos, i * 38 + y_pos,
buttons_data[i].name,
- controller->get_owner ()));
+ 0));
//FIXMEcontroller->get_owner ()));
}
armageddon = new ArmageddonButton(CL_Display::get_width() - 40,
CL_Display::get_height() - 62);
@@ -164,7 +161,7 @@
{
for(AButtonIter button = a_buttons.begin(); button != a_buttons.end();
button++)
{
- if ((*button)->mouse_over(controller->get_pos ()))
+ if ((*button)->mouse_over(x, y))
pressed_button = button;
}
@@ -185,12 +182,12 @@
return;
}
- if (pause->mouse_over(controller->get_pos ()))
+ if (pause->mouse_over(x, y))
{
client->set_pause(!client->get_pause());
return;
}
- else if (forward->mouse_over(controller->get_pos ()))
+ else if (forward->mouse_over(x, y))
{
client->set_fast_forward(!client->get_fast_forward());
return;
@@ -202,7 +199,7 @@
{
for(AButtonIter button = a_buttons.begin(); button != a_buttons.end();
button++)
{
- if ((*button)->mouse_over(CL_Vector (x, y)))
+ if ((*button)->mouse_over(x, y))
return true;
}
return false;
Index: button_panel.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- button_panel.hxx 29 Jul 2002 11:57:38 -0000 1.5
+++ button_panel.hxx 2 Aug 2002 11:25:46 -0000 1.6
@@ -29,7 +29,6 @@
class CL_Key;
class Client;
class PLF;
-class Controller;
class ButtonPanel : public GUI::Component
{
@@ -53,11 +52,10 @@
unsigned int last_press;
static CL_Surface button_cap;
- Controller* controller;
int x_pos, y_pos;
public:
- ButtonPanel(PLF* plf, Controller*, int arg_x_pos, int arg_y_pos);
+ ButtonPanel(PLF* plf, int arg_x_pos, int arg_y_pos);
virtual ~ButtonPanel();
void on_button_press(int x, int y);
Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- client.cxx 29 Jul 2002 11:57:38 -0000 1.7
+++ client.cxx 2 Aug 2002 11:25:46 -0000 1.8
@@ -40,90 +40,35 @@
#include "cursor.hxx"
#include "server.hxx"
#include "button_panel.hxx"
+#include "screen_manager.hxx"
// GUI
-#include "gui/root_gui_manager.hxx"
#include "gui/surface_button.hxx"
-// Input Header files
-#include "input/event.hxx"
-#include "input/button_event.hxx"
-#include "input/axis_event.hxx"
-#include "input/pointer_event.hxx"
-#include "input/controller.hxx"
-
-Client::Client(Controller* arg_controller, Server * s)
+Client::Client(Server * s)
: server (s),
fast_forward (false),
pause (false),
skip_frame (0),
do_replay (false),
is_finished (false),
- grabbed_gui_obj (0),
- current_gui_obj (0),
button_panel (0),
pcounter (0),
playfield (0),
time_display (0),
small_map (0),
- hurry_up (0),
- controller (arg_controller),
- cursor (new Cursor ("cursors/animcross", "core", controller))
-{
- //player = 0;
-
- Display::add_flip_screen_hook(cursor);
- //Display::add_flip_screen_hook(new Cursor ("cursors/cursor", "core",
boost::shared_ptr<Controller>(new MouseController ())));
-
- std::cout << "Creating controller" << std::endl;
- input_controller = new Input::Controller ("../doc/mycontroller.xml");
- std::cout << "Creating controller done" << std::endl;
- std::cout << "Creating guix" << std::endl;
- gui_manager = new GUI::RootGUIManager (input_controller);
- gui_manager->add (new GUI::SurfaceButton (400, 200,
- ResDescriptor ("editor/button",
"core", ResDescriptor::RD_RESOURCE),
- ResDescriptor
("editor/button_pressed", "core", ResDescriptor::RD_RESOURCE),
- ResDescriptor ("editor/actions",
"core", ResDescriptor::RD_RESOURCE)));
-}
-
-Client::~Client()
-{
- //std::cout << "Client:~Client" << std::endl;
- Display::remove_flip_screen_hook(cursor);
- deinit_display();
-
- delete playfield;
- delete button_panel;
- delete pcounter;
- delete small_map;
- delete time_display;
- delete hurry_up;
- delete cursor;
-}
-
-void
-Client::display()
+ hurry_up (0)
+ //cursor (new Cursor ("cursors/animcross", "core", controller))
{
- fast_forward = false;
- pause = false;
- do_replay = false;
- is_finished = false;
- skip_frame = 0;
-
- play_level(server->get_plf ());
-
- //FadeOut::random();
-
- if (verbose) std::cout << "Displaying results..." << CL_System::get_time()
<< std::flush;
- PingusLevelResult r(server->get_world(), controller);
- r.draw();
+ //Display::add_flip_screen_hook(cursor);
- if (verbose) std::cout << "finished " << CL_System::get_time() << std::endl;
-}
+ gui_manager->add (new GUI::SurfaceButton
+ (400, 200,
+ ResDescriptor ("editor/button", "core",
ResDescriptor::RD_RESOURCE),
+ ResDescriptor ("editor/button_pressed", "core",
ResDescriptor::RD_RESOURCE),
+ ResDescriptor ("editor/actions", "core",
ResDescriptor::RD_RESOURCE)));
+
-void
-Client::init_display()
-{
Timer timer;
timer.start();
@@ -131,23 +76,25 @@
Display::set_cursor(CL_MouseCursorProvider::load("Cursors/cursor",
PingusResource::get("game")));
- Display::show_cursor();
- button_panel = new ButtonPanel(plf, controller, 2,
CL_Display::get_height()/2);
- pcounter = new PingusCounter(); playfield = new Playfield(this, plf,
server->get_world(), controller);
- pcounter = new PingusCounter();
+ button_panel = new ButtonPanel(server->get_plf (), 2,
CL_Display::get_height()/2);
+ playfield = new Playfield(this, server->get_plf (), server->get_world());
+ hurry_up = new HurryUp();
+ pcounter = new PingusCounter();
small_map = new SmallMap();
time_display = new TimeDisplay();
- hurry_up = new HurryUp();
- button_panel->set_server(server);
- time_display->set_server(server);
button_panel->set_client(this);
+ button_panel->set_server(server);
+ hurry_up->set_client(this);
pcounter->set_client(this);
small_map->set_client(this);
- hurry_up->set_client(this);
+ time_display->set_server(server);
- playfield->set_clip_rect(0, 0,
+ gui_manager->add (small_map);
+ gui_manager->add (button_panel);
+
+ /*playfield->set_clip_rect(0, 0,
CL_Display::get_width(),
CL_Display::get_height());
@@ -155,126 +102,83 @@
playfield->set_buttons(button_panel);
playfield->set_server(server);
playfield->set_client(this);
-
+ */
// Adding all GuiObj's to the screen
- obj.push_back(playfield);
- obj.push_back(pcounter);
- obj.push_back(time_display);
- obj.push_back(hurry_up);
-
- gui_manager->add (small_map);
- gui_manager->add (button_panel);
-
+ //obj.push_back(playfield);
+ //obj.push_back(pcounter);
+ //obj.push_back(time_display);
+ //obj.push_back(hurry_up);
if (verbose) std::cout << "done " << timer.stop() << std::endl;
}
-void
-Client::deinit_display()
+Client::~Client()
{
- Display::hide_cursor();
-}
+ //Display::remove_flip_screen_hook(cursor);
-void
-Client::resize_display()
-{
+ //delete playfield;
+ //delete button_panel;
+ //delete pcounter;
+ //delete small_map;
+ //delete time_display;
+ //delete hurry_up;
+ // delete cursor;
}
void
-Client::play_level(PLF* arg_plf)
+Client::update (float delta)
{
- Timer timer;
-
- plf = arg_plf;
-
- timer.start();
- //std::cout << "Client::play_level(), Reading PLF..." << std::flush;
-
- register_event_handler();
-
- init_display();
+ std::cout << "Client::update (float delta)" << std::endl;
+ //cursor->update (delta);
+ //process input events
+ //process_events ();
- if (verbose)
- std::cout << "Client: Entering main_loop. Startup time: "
- << CL_System::get_time() << " msec." << std::endl;
+ // Let the window move its content
+#if 0
+ for(GuiObjIter i = obj.begin (); i != obj.end (); ++i)
+ (*i)->updateX();
- // Clear both buffers
- CL_Display::clear_display();
- Display::flip_display();
- CL_Display::clear_display();
-
- PingusSound::play_music(path_manager.complete ("music/" +
plf->get_music().res_name));
+ 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();
- /** Main game loop */
- DeltaManager delta;
- float wannabe_delta = 0.0333f;
+ /*float wannabe_delta = 0.0333f;
unsigned int frames = 1;
bool auto_frame_skip = false;
- float current_delta;
- // FIXME: using this twice will crash with an X Error
- //CL_MouseCursor::hide ();
- while (!server->is_finished())
- {
- CL_System::keep_alive ();
- CL_System::sleep (0);
- // Update 30 times a second
- current_delta = delta.get ();
- if (current_delta > wannabe_delta)
+ float current_delta;*/
+
+ if (server->is_finished())
+ {
+ std::cout << "Client: update(): Server is finished" << std::endl;
+ ScreenManager::instance ()->pop_screen ();
+ }
+
+ /*
+ CL_System::keep_alive ();
+ CL_System::sleep (0);
+
+ if (current_delta > wannabe_delta)
+ {
+ update (delta.getset ());
+ ++frames;
+ if (frames % int(frame_skip) == 0)
{
- update (delta.getset ());
- ++frames;
- if (frames % int(frame_skip) == 0)
+ if (!auto_frame_skip)
{
- if (!auto_frame_skip)
- {
- draw ();
- }
+ draw ();
}
}
else
{
CL_System::sleep (int(1000 * (wannabe_delta - delta.get ())));
}
- }
- // FIXME: using this twice will crash with an X Error
- //CL_MouseCursor::show ();
-
- unregister_event_handler();
-}
-
-void
-Client::draw ()
-{
- for(GuiObjIter i = obj.begin (); i != obj.end (); ++i)
- (*i)->draw_clipped();
-
- gui_manager->draw ();
-
- Display::flip_display();
-}
-
-void
-Client::update (float delta)
-{
- cursor->update (delta);
- input_controller->update (delta);
- gui_manager->update (delta);
-
- // process input events
- process_events ();
-
- // Let the window move its content
- for(GuiObjIter i = obj.begin (); i != obj.end (); ++i)
- (*i)->updateX();
-
- for(GuiObjIter i = obj.begin (); i != obj.end (); ++i)
- (*i)->update(delta);
-
- // Let the server process a game loop
- server->update(delta);
- send_next_event();
+ }*/
}
+#if 0
void
Client::process_events ()
{
@@ -390,7 +294,7 @@
Client::send_next_event()
{
}
-
+#endif
void
Client::set_fast_forward(bool value)
{
@@ -450,51 +354,11 @@
server->set_finished();
}
+#if 0
void
Client::register_event_handler()
{
if (verbose > 1) std::cout << "Client: register_event_handler()" <<
std::endl;
-
- slot_left_pressed = controller->left->signal_pressed.connect (this,
&Client::on_left_pressed);
- slot_left_released = controller->left->signal_released.connect (this,
&Client::on_left_released);
- slot_middle_pressed = controller->middle->signal_pressed.connect (this,
&Client::on_middle_pressed);
- slot_right_pressed = controller->right->signal_pressed.connect (this,
&Client::on_right_pressed);
- slot_right_released = controller->right->signal_released.connect (this,
&Client::on_right_released);
- slot_abort_pressed = controller->abort->signal_pressed.connect (this,
&Client::on_abort_pressed);
- slot_pause_pressed = controller->pause->signal_pressed.connect (this,
&Client::on_pause_pressed);
- slot_fast_forward_pressed = controller->fast_forward->signal_pressed.connect
(this, &Client::on_fast_forward_pressed);
- slot_scroll_left_pressed = controller->scroll_left->signal_pressed.connect
(this, &Client::on_scroll_left_pressed);
- slot_scroll_right_pressed = controller->scroll_right->signal_pressed.connect
(this, &Client::on_scroll_right_pressed);
-
- slot_next_action_pressed = controller->next_action->signal_pressed.connect
(this, &Client::on_next_action_pressed);
- slot_previous_action_pressed =
controller->previous_action->signal_pressed.connect (this,
&Client::on_previous_action_pressed);
-
- enabled = true;
-}
-
-void
-Client::unregister_event_handler()
-{
- if (verbose > 1) std::cout << "Client: unregister_event_handler()" <<
std::endl;
- //CL_Input::chain_button_release.remove(this);
- //CL_Input::chain_button_press.remove(this);
-
- // Disconnect segfaults
- CL_Input::sig_button_press ().disconnect (on_button_press_slot);
- CL_Input::sig_button_release ().disconnect (on_button_release_slot);
-
- enabled = false;
-}
-
-void
-Client::disable_event_handler()
-{
- enabled = false;
-}
-
-void
-Client::enable_event_handler()
-{
enabled = true;
}
@@ -521,26 +385,6 @@
}
void
-Client::on_button_release(CL_InputDevice *device, const CL_Key &key)
-{
- if (!enabled)
- return;
-
- if (device == CL_Input::keyboards[0])
- {
- on_keyboard_button_release(key);
- }
- else if (device == CL_Input::pointers[0])
- {
- on_mouse_button_release(key);
- }
- else
- {
- if (verbose > 1) std::cout << "Unknown device released: device=" <<
device << "; key.id=" << key.id << std::endl;
- }
-}
-
-void
Client::on_keyboard_button_press(const CL_Key& /*key*/)
{
if (CL_Keyboard::get_keycode(CL_KEY_LSHIFT)
@@ -782,16 +626,50 @@
std::cout << "Action previous pressed" << std::endl;
button_panel->previous_action();
}
+#endif
-GuiObj*
-Client::get_gui_object (int x, int y)
+void
+Client::draw ()
{
- for(GuiObjRIter i = obj.rbegin (); i != obj.rend (); ++i)
- {
- if ((*i)->mouse_over (x, y))
- return *i;
- }
- return 0;
+ GUIScreen::draw ();
+}
+
+void
+Client::update (const GameDelta& delta)
+{
+ std::cout << "Client:update ()" << std::endl;
+ update (delta.get_time ());
+ GUIScreen::update (delta);
+}
+
+void
+Client::on_startup ()
+{
+ std::cout << "Client::on_startup ()" << std::endl;
+
+ /** Hide the system cursor and show the software one */
+ Display::show_cursor();
+ // FIXME: using this twice will crash with an X Error
+ //CL_MouseCursor::hide ();
+
+ fast_forward = false;
+ pause = false;
+ do_replay = false;
+ is_finished = false;
+ skip_frame = 0;
+
+ PingusSound::play_music(path_manager.complete ("music/" + server->get_plf
()->get_music().res_name));
+
+ if (verbose)
+ std::cout << "Client: Entering main_loop. Startup time: "
+ << CL_System::get_time() << " msec." << std::endl;
+}
+
+void
+Client::on_shutdown ()
+{
+ std::cout << "Client::on_shutdown ()" << std::endl;
+ Display::hide_cursor();
}
/* EOF */
Index: client.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- client.hxx 1 Aug 2002 21:46:26 -0000 1.6
+++ client.hxx 2 Aug 2002 11:25:46 -0000 1.7
@@ -44,7 +44,6 @@
class ButtonPanel;
class Controller;
class Cursor;
-class GuiObj;
class HurryUp;
class PLF;
class PingusCounter;
@@ -57,8 +56,6 @@
class Client : public GUIScreen
{
private:
-
- PLF* plf;
Result result;
Server* server;
@@ -68,18 +65,6 @@
bool do_replay;
bool is_finished;
- std::vector<GuiObj*> obj;
- typedef std::vector<GuiObj*>::iterator GuiObjIter;
- typedef std::vector<GuiObj*>::reverse_iterator GuiObjRIter;
-
- GUI::RootGUIManager* gui_manager;
-
- /** The object that got a mouse_down() */
- GuiObj* grabbed_gui_obj;
-
- /** The object which is currently under the cursor */
- GuiObj* current_gui_obj;
-
ButtonPanel* button_panel;
PingusCounter* pcounter;
Playfield* playfield;
@@ -87,55 +72,20 @@
SmallMap* small_map;
HurryUp* hurry_up;
- Controller* controller;
- Input::Controller* input_controller;
- Cursor* cursor;
-
- CL_Slot on_button_press_slot;
- CL_Slot on_button_release_slot;
-
- // Slots for controller handling
- CL_Slot slot_left_pressed;
- CL_Slot slot_left_released;
- CL_Slot slot_middle_pressed;
- CL_Slot slot_right_pressed;
- CL_Slot slot_right_released;
- CL_Slot slot_abort_pressed;
- CL_Slot slot_pause_pressed;
- CL_Slot slot_fast_forward_pressed;
- CL_Slot slot_scroll_left_pressed;
- CL_Slot slot_scroll_right_pressed;
- CL_Slot slot_next_action_pressed;
- CL_Slot slot_previous_action_pressed;
-
+#if 0
void process_button_event (Input::ButtonEvent*);
void process_pointer_event (Input::PointerEvent*);
void process_axis_event (Input::AxisEvent*);
-
- /** Return the GuiObj under the given coordinates */
- GuiObj* get_gui_object (int x, int y);
+#endif
bool enabled;
public:
- Client(Controller* arg_controller, Server * s);
+ Client(Server * s);
virtual ~Client();
Server* get_server() { return server; }
Playfield* get_playfield() { return playfield; }
- /** Display the game and enter the main game loop */
- void display();
- void send_next_event();
-
- void play_level(PLF*);
-
- /// FIXME: Document me... or rewrite me
- void init_display();
- /// FIXME: Document me... or rewrite me
- void deinit_display();
- ///
- void resize_display();
-
void set_fast_forward(bool value);
bool get_fast_forward();
@@ -148,43 +98,24 @@
void set_finished();
Result get_result();
- /** Draw all gui elements, etc. */
- void draw ();
-
/** Update all parts of the world */
void update (float delta);
- void process_events ();
+ //void process_events ();
ButtonPanel* get_button_panel () { return button_panel; }
- virtual void on_button_press(CL_InputDevice *device, const CL_Key &key);
- virtual void on_button_release(CL_InputDevice *device, const CL_Key &key);
+ void on_button_press(int x, int y);
+ void on_button_release(int x, int y);
- void on_mouse_button_press(const CL_Key &key);
+ void on_butmouse_button_press(const CL_Key &key);
void on_mouse_button_release(const CL_Key &key);
-
- void on_keyboard_button_press(const CL_Key &key);
- void on_keyboard_button_release(const CL_Key &key);
- void on_left_pressed (const CL_Vector& pos);
- void on_left_released (const CL_Vector& pos);
- void on_middle_pressed (const CL_Vector& pos);
- void on_right_pressed (const CL_Vector& pos);
- void on_right_released (const CL_Vector& pos);
- void on_abort_pressed (const CL_Vector& pos);
- void on_pause_pressed (const CL_Vector& pos);
- void on_fast_forward_pressed (const CL_Vector& pos);
- void on_scroll_left_pressed (const CL_Vector& pos);
- void on_scroll_right_pressed (const CL_Vector& pos);
- void on_next_action_pressed (const CL_Vector& pos);
- void on_previous_action_pressed (const CL_Vector& pos);
-
- void register_event_handler();
- void unregister_event_handler();
-
- void disable_event_handler();
- void enable_event_handler();
+ // Overloaded GUIScreen stuff
+ void draw ();
+ void update (const GameDelta& delta);
+ void on_startup ();
+ void on_shutdown ();
};
#endif
Index: game_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- game_session.cxx 13 Jun 2002 14:25:12 -0000 1.2
+++ game_session.cxx 2 Aug 2002 11:25:46 -0000 1.3
@@ -23,15 +23,15 @@
#include "game_session.hxx"
#include "game_session_result.hxx"
#include "plf.hxx"
+#include "screen_manager.hxx"
using boost::shared_ptr;
PingusGameSession::PingusGameSession (std::string arg_filename)
: filename (arg_filename),
- controller (new MouseController ()),
plf(PLF::create (filename)),
server (new TrueServer (plf)),
- client (new Client(controller, server))
+ client (new Client(server))
{
}
@@ -40,21 +40,24 @@
delete client;
delete server;
delete plf;
- delete controller;
-}
-
-void
-PingusGameSession::start ()
-{
- std::cout << "PingusGameSession: Giving control to the client..." <<
std::endl;
- client->display();
- std::cout << "PingusGameSession: Got control back from the client." <<
std::endl;
}
PingusGameSessionResult
PingusGameSession::get_result ()
{
return PingusGameSessionResult ();
+}
+
+void
+PingusGameSession::draw ()
+{
+ client->draw ();
+}
+
+void
+PingusGameSession::update (const GameDelta& delta)
+{
+ client->update (delta);
}
/* EOF */
Index: game_session.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- game_session.hxx 24 Jun 2002 22:52:54 -0000 1.3
+++ game_session.hxx 2 Aug 2002 11:25:46 -0000 1.4
@@ -21,23 +21,21 @@
#define HEADER_PINGUS_GAME_SESSION_HXX
#include <string>
+#include "screen.hxx"
class Client;
class Server;
class PLF;
-class Controller;
class PingusGameSessionResult;
/** You can use this class to start up a game session, which consist
of a single level. */
-class PingusGameSession
+class PingusGameSession : public Screen
{
private:
/// The filename of the level
std::string filename;
- Controller* controller;
-
/// The level data
PLF* plf;
@@ -58,13 +56,18 @@
PingusGameSession (std::string arg_filename);
/** Clean up */
- ~PingusGameSession ();
-
- /** Start a game session, create Server/Client objects as needed */
- void start ();
+ virtual ~PingusGameSession ();
/** Get the results of the last gaming session */
PingusGameSessionResult get_result ();
+
+ // Overloaded Screen functions
+ /** Draw this screen */
+ void draw ();
+
+ /** Pass a delta to the screen */
+ void update (const GameDelta& delta);
+
};
#endif
Index: multiplayer_client_child.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/multiplayer_client_child.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- multiplayer_client_child.cxx 29 Jul 2002 11:57:38 -0000 1.5
+++ multiplayer_client_child.cxx 2 Aug 2002 11:25:46 -0000 1.6
@@ -30,7 +30,7 @@
: Controllable (arg_controller),
server (s),
cursor (new Cursor ("cursors/cross", "core", controller)),
- button_panel (new ButtonPanel (s->get_plf (), controller, arg_rect.x1,
arg_rect.y1)),
+ button_panel (new ButtonPanel (s->get_plf (), arg_rect.x1, arg_rect.y1)),
capture_rect ("cursors/capgood", "core"),
playfield (new PlayfieldView (server->get_world (), arg_rect)),
counterbar (new PingusCounterBar (server, PingusCounterBar::VERTICAL,
Index: pingus_main.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_main.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- pingus_main.cxx 1 Aug 2002 21:40:01 -0000 1.8
+++ pingus_main.cxx 2 Aug 2002 11:25:46 -0000 1.9
@@ -827,6 +827,7 @@
successfull = false;
}
}
+#if 0
if (successfull)
{
if (start_editor) {
@@ -837,6 +838,7 @@
game.start ();
}
}
+#endif
}
Index: playfield.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- playfield.cxx 28 Jun 2002 15:12:22 -0000 1.7
+++ playfield.cxx 2 Aug 2002 11:25:47 -0000 1.8
@@ -19,7 +19,6 @@
#include <stdio.h>
#include <ClanLib/Display/Display/display.h>
-#include "controller.hxx"
#include "globals.hxx"
#include "playfield.hxx"
#include "plf.hxx"
@@ -31,9 +30,8 @@
using boost::shared_ptr;
-Playfield::Playfield(Client* client, PLF* level_data, World* w,
- Controller* arg_controller)
- : current_view(0), controller (arg_controller)
+Playfield::Playfield(Client* client, PLF* level_data, World* w)
+ : current_view(0)
{
world = w;
mouse_scrolling = false;
@@ -164,6 +162,7 @@
Playfield::process_input_interactive()
{
// FIXME: This should be replaced with something getting relative mouse co's
+#if 0
if (auto_scrolling)
{
scroll_speed = 30;
@@ -186,6 +185,7 @@
view[current_view]->set_y_offset(view[current_view]->get_y_offset() -
scroll_speed);
}
}
+#endif
}
///
@@ -199,6 +199,7 @@
void
Playfield::update(float /*delta*/)
{
+#if 0
for(unsigned int i=0; i < view.size(); ++i)
{
if (view[i]->is_current() && !mouse_scrolling)
@@ -210,6 +211,7 @@
break;
}
}
+#endif
}
bool
@@ -256,18 +258,22 @@
if (verbose) std::cout << "Started scrolling..." << std::flush;
mouse_scrolling = true;
+#if 0
scroll_center_x = controller->get_x();
scroll_center_y = controller->get_y();
+#endif
}
void
Playfield::do_scrolling()
{
+#if 0
if (mouse_scrolling)
{
view[current_view]->shift_x_offset((scroll_center_x -
controller->get_x()) / 5);
view[current_view]->shift_y_offset((scroll_center_y -
controller->get_y()) / 5);
}
+#endif
}
void
Index: playfield.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- playfield.hxx 24 Jun 2002 22:52:56 -0000 1.5
+++ playfield.hxx 2 Aug 2002 11:25:47 -0000 1.6
@@ -22,7 +22,7 @@
#include "view.hxx"
#include "client.hxx"
-#include "gui_obj.hxx"
+#include "gui/component.hxx"
class Pingu;
class World;
@@ -32,7 +32,7 @@
class Controller;
/** This class encapsulates all the different Views */
-class Playfield : public GuiObj
+class Playfield : public GUI::Component
{
private:
friend class Client;
@@ -68,11 +68,9 @@
std::vector<Rect> clipping_rectangles;
- Controller* controller;
public:
- Playfield(Client*, PLF* plf, World*,
- Controller*);
- ~Playfield();
+ Playfield(Client*, PLF* plf, World*);
+ virtual ~Playfield();
int get_x_offset();
int get_y_offset();
Index: screen.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/screen.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- screen.hxx 1 Aug 2002 21:40:01 -0000 1.4
+++ screen.hxx 2 Aug 2002 11:25:47 -0000 1.5
@@ -35,6 +35,13 @@
/** Pass a delta to the screen */
virtual void update (const GameDelta& delta) =0;
+
+ /** Called once the screen gets activated and becomes the current
+ screen */
+ virtual void on_startup () {}
+
+ /** Called once the screen gets replaced */
+ virtual void on_shutdown () {}
};
#endif
Index: screen_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/screen_manager.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- screen_manager.cxx 1 Aug 2002 21:40:01 -0000 1.3
+++ screen_manager.cxx 2 Aug 2002 11:25:47 -0000 1.4
@@ -30,6 +30,7 @@
ScreenManager::ScreenManager ()
{
+ last_screen = 0;
push_screen (PingusMenuManager::instance (), false);
}
@@ -56,15 +57,29 @@
continue;
}
- GameDelta delta (time_delta, input_controller.get_events ());
+ // Let ClanLib fetch events
+ CL_System::keep_alive ();
+ // Get new events from ClanLib
input_controller.update (time_delta);
- CL_System::keep_alive ();
- current_screen->draw ();
+ // Fill the delta with values
+ GameDelta delta (time_delta, input_controller.get_events ());
+
+ last_screen = current_screen;
+ // Most likly the screen will get changed in this update call
current_screen->update (delta);
+ if (last_screen != current_screen)
+ {
+ last_screen = current_screen;
+ continue;
+ }
+
+ current_screen->draw ();
+
Display::flip_display ();
+
// Stupid hack to make this thing take less CPU
CL_System::sleep (0);
}
@@ -82,6 +97,7 @@
void
ScreenManager::push_screen (Screen* screen, bool delete_screen)
{
+ screen->on_startup ();
screens.push_back (std::pair<Screen*, bool> (screen, delete_screen));
}
@@ -91,6 +107,8 @@
Screen* current_screen = screens.back ().first;
bool delete_screen = screens.back ().second;
+ current_screen->on_shutdown ();
+
if (delete_screen)
delete current_screen;
@@ -103,8 +121,12 @@
Screen* current_screen = screens.back ().first;
bool delete_c_screen = screens.back ().second;
+ current_screen->on_shutdown ();
+
if (delete_c_screen)
- delete current_screen;
+ {
+ delete current_screen;
+ }
screens.back () = std::pair<Screen*, bool>(screen, delete_screen);
}
Index: screen_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/screen_manager.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- screen_manager.hxx 1 Aug 2002 21:40:01 -0000 1.4
+++ screen_manager.hxx 2 Aug 2002 11:25:47 -0000 1.5
@@ -34,6 +34,9 @@
or replaced) */
std::vector<std::pair<Screen*, bool> > screens;
+ /** the screen that was used in the last update() */
+ Screen* last_screen;
+
ScreenManager ();
public:
~ScreenManager ();
Index: theme.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/theme.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- theme.cxx 13 Jun 2002 14:25:12 -0000 1.2
+++ theme.cxx 2 Aug 2002 11:25:47 -0000 1.3
@@ -33,6 +33,7 @@
#include "theme.hxx"
#include "plf_plf.hxx"
#include "xml_plf.hxx"
+#include "screen_manager.hxx"
Theme::Theme(std::string filename)
: filename (filename)
@@ -260,9 +261,10 @@
try
{
- PingusGameSession game(path_manager.complete("levels/" +
plt.get_levels()[current_level]));
-
- game.start();
+ assert (!"Theme::play unimplemented");
+
+ ScreenManager::instance()->push_screen
+ (new PingusGameSession(path_manager.complete("levels/" +
plt.get_levels()[current_level])));
if (current_level == accessible_levels)
++accessible_levels;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.4,1.5 action_button.hxx,1.4,1.5 button_panel.cxx,1.7,1.8 button_panel.hxx,1.5,1.6 client.cxx,1.7,1.8 client.hxx,1.6,1.7 game_session.cxx,1.2,1.3 game_session.hxx,1.3,1.4 multiplayer_client_child.cxx,1.5,1.6 pingus_main.cxx,1.8,1.9 playfield.cxx,1.7,1.8 playfield.hxx,1.5,1.6 screen.hxx,1.4,1.5 screen_manager.cxx,1.3,1.4 screen_manager.hxx,1.4,1.5 theme.cxx,1.2,1.3,
grumbel <=