[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r4173 - in branches/pingus-hanusz/src: . components
From: |
grumbel |
Subject: |
[Pingus-CVS] r4173 - in branches/pingus-hanusz/src: . components |
Date: |
Sat, 2 Jul 2011 07:02:42 +0200 |
Author: grumbel
Date: 2011-07-02 07:02:42 +0200 (Sat, 02 Jul 2011)
New Revision: 4173
Modified:
branches/pingus-hanusz/src/client.cpp
branches/pingus-hanusz/src/client.hpp
branches/pingus-hanusz/src/components/action_button.cpp
branches/pingus-hanusz/src/components/action_button.hpp
branches/pingus-hanusz/src/game_session.cpp
branches/pingus-hanusz/src/goal_manager.cpp
branches/pingus-hanusz/src/goal_manager.hpp
branches/pingus-hanusz/src/result.hpp
branches/pingus-hanusz/src/result_screen.cpp
branches/pingus-hanusz/src/server.hpp
branches/pingus-hanusz/src/statistics.cpp
branches/pingus-hanusz/src/true_server.cpp
branches/pingus-hanusz/src/true_server.hpp
Log:
Added Exit button, fixed bug that recorded success and failure as aborted
Modified: branches/pingus-hanusz/src/client.cpp
===================================================================
--- branches/pingus-hanusz/src/client.cpp 2011-06-24 20:24:41 UTC (rev
4172)
+++ branches/pingus-hanusz/src/client.cpp 2011-07-02 05:02:42 UTC (rev
4173)
@@ -75,6 +75,7 @@
#if defined(PINGUS_MODE_NEUTRAL) || defined(PINGUS_MODE_EVIL) ||
defined(PINGUS_MODE_NICE)
gui_manager->add(new ForwardButton (server, Display::get_width() - 40 * 1,
Display::get_height() - 62), true);
gui_manager->add(new PauseButton (server, Display::get_width() - 40 * 2,
Display::get_height() - 62), true);
+ gui_manager->add(new ExitButton(server, 0, 0), true);
#else
gui_manager->add(new ArmageddonButton(server, Display::get_width() - 40,
Display::get_height() - 62), true);
@@ -199,13 +200,6 @@
return do_replay;
}
-void
-Client::do_restart()
-{
- do_replay = true;
- server->set_finished();
-}
-
bool
Client::finished()
{
@@ -216,7 +210,7 @@
Client::set_finished()
{
is_finished = true;
- server->set_finished();
+ server->set_finished(false);
}
void
@@ -224,7 +218,7 @@
{
if (maintainer_mode)
{
- server->set_finished();
+ server->set_finished(true);
}
}
Modified: branches/pingus-hanusz/src/client.hpp
===================================================================
--- branches/pingus-hanusz/src/client.hpp 2011-06-24 20:24:41 UTC (rev
4172)
+++ branches/pingus-hanusz/src/client.hpp 2011-07-02 05:02:42 UTC (rev
4173)
@@ -70,7 +70,6 @@
Playfield* get_playfield() { return playfield; }
bool replay();
- void do_restart();
bool finished();
void set_finished();
Modified: branches/pingus-hanusz/src/components/action_button.cpp
===================================================================
--- branches/pingus-hanusz/src/components/action_button.cpp 2011-06-24
20:24:41 UTC (rev 4172)
+++ branches/pingus-hanusz/src/components/action_button.cpp 2011-07-02
05:02:42 UTC (rev 4173)
@@ -17,6 +17,8 @@
// 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 "../globals.hpp"
#include "../cheat.hpp"
#include "../resource.hpp"
@@ -227,7 +229,43 @@
}
}
+
+ExitButton::ExitButton (TrueServer* s, int x, int y)
+ : server (s),
+ x_pos(x), y_pos(y),
+ background (Resource::load_sprite("core/buttons/buttonbackgroundhl")),
+ backgroundhl(Resource::load_sprite("core/buttons/buttonbackground"))
+{
+ //surface = Resource::load_sprite("core/buttons/pause");
+}
+ExitButton::~ExitButton () {}
+
+void
+ExitButton::draw (DrawingContext& gc)
+{
+ gc.draw(backgroundhl, Vector2i(x_pos, y_pos));
+ gc.print_center(Fonts::pingus_small, x_pos + background.get_width()/2, y_pos
+ 5, "Exit");
+}
+
+bool
+ExitButton::is_at (int x, int y)
+{
+ if (x > x_pos && x < x_pos + int(background.get_width())
+ && y > y_pos && y < y_pos + int(background.get_height()))
+ {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void
+ExitButton::on_primary_button_click (int x, int y)
+{
+ server->set_finished(true);
+}
+
ForwardButton::ForwardButton (TrueServer* s, int x, int y)
: server (s),
x_pos (x), y_pos (y),
Modified: branches/pingus-hanusz/src/components/action_button.hpp
===================================================================
--- branches/pingus-hanusz/src/components/action_button.hpp 2011-06-24
20:24:41 UTC (rev 4172)
+++ branches/pingus-hanusz/src/components/action_button.hpp 2011-07-02
05:02:42 UTC (rev 4173)
@@ -91,6 +91,33 @@
ForwardButton& operator= (const ForwardButton&);
};
+/** Fast Forward button, press it to let the game run faster, press it
+ again to return to normal speed
+
+ \sa Client */
+class ExitButton : public GUI::Component
+{
+private:
+ TrueServer* server;
+ int x_pos;
+ int y_pos;
+
+ Sprite background;
+ Sprite backgroundhl;
+ friend class ButtonPanel;
+public:
+ ExitButton(TrueServer*, int x, int y);
+ virtual ~ExitButton();
+
+ void draw(DrawingContext& gc);
+ bool is_at (int x, int y);
+ void on_primary_button_click (int x, int y);
+
+private:
+ ExitButton (const ExitButton&);
+ ExitButton& operator= (const ExitButton&);
+};
+
// ----------------- snip --------------------
/** Pause button, press it to pause the game, press it again to
Modified: branches/pingus-hanusz/src/game_session.cpp
===================================================================
--- branches/pingus-hanusz/src/game_session.cpp 2011-06-24 20:24:41 UTC (rev
4172)
+++ branches/pingus-hanusz/src/game_session.cpp 2011-07-02 05:02:42 UTC (rev
4173)
@@ -32,6 +32,7 @@
#include "globals.hpp"
#include "debug.hpp"
#include "statistics.hpp"
+#include "goal_manager.hpp"
PingusGameSession::PingusGameSession (const PingusLevel& arg_plf, bool
arg_show_result_screen)
: plf(arg_plf),
@@ -114,6 +115,7 @@
result.used_time = server->get_time();
result.aborted = server->was_aborted();
+ result.exited = server->get_goal_manager()->get_always_fail();
{ // Write the savegame
Savegame savegame(result.plf.get_resname(),
Modified: branches/pingus-hanusz/src/goal_manager.cpp
===================================================================
--- branches/pingus-hanusz/src/goal_manager.cpp 2011-06-24 20:24:41 UTC (rev
4172)
+++ branches/pingus-hanusz/src/goal_manager.cpp 2011-07-02 05:02:42 UTC (rev
4173)
@@ -26,7 +26,7 @@
#include "screen/screen_manager.hpp"
GoalManager::GoalManager(Server* s)
- : server(s), goal(GT_NONE), exit_time(0)
+ : server(s), goal(GT_NONE), exit_time(0), m_always_fail(false)
{
}
@@ -88,8 +88,10 @@
}
void
-GoalManager::set_abort_goal()
+GoalManager::set_abort_goal(bool always_fail)
{
+ m_always_fail = always_fail;
+
if (exit_time == 0)
{
goal = GT_GAME_ABORTED;
Modified: branches/pingus-hanusz/src/goal_manager.hpp
===================================================================
--- branches/pingus-hanusz/src/goal_manager.hpp 2011-06-24 20:24:41 UTC (rev
4172)
+++ branches/pingus-hanusz/src/goal_manager.hpp 2011-07-02 05:02:42 UTC (rev
4173)
@@ -46,6 +46,8 @@
/** time at which is_finished() will return true */
int exit_time;
+ bool m_always_fail;
+
public:
GoalManager(Server* plf);
@@ -53,13 +55,15 @@
bool is_finished();
/** Abort the level */
- void set_abort_goal();
+ void set_abort_goal(bool always_fail = false);
- GoalType get_goal() const { return GT_GLOBAL_TIME_LIMIT; }
+ GoalType get_goal() const { return goal; }
/** Check for goal conditions and set finished accordingly */
void update();
+ bool get_always_fail() const { return m_always_fail; }
+
private:
GoalManager (const GoalManager&);
GoalManager& operator= (const GoalManager&);
Modified: branches/pingus-hanusz/src/result.hpp
===================================================================
--- branches/pingus-hanusz/src/result.hpp 2011-06-24 20:24:41 UTC (rev
4172)
+++ branches/pingus-hanusz/src/result.hpp 2011-07-02 05:02:42 UTC (rev
4173)
@@ -51,11 +51,13 @@
/** Set when the global time limit is reached */
bool aborted;
+ bool exited;
+
bool success() const {
#ifdef PINGUS_MODE_EVIL
- return (killed >= needed);
+ return (killed >= needed) && !aborted && !exited;
#else
- return (saved >= needed);
+ return (saved >= needed) && !aborted && !exited;
#endif
}
};
Modified: branches/pingus-hanusz/src/result_screen.cpp
===================================================================
--- branches/pingus-hanusz/src/result_screen.cpp 2011-06-24 20:24:41 UTC
(rev 4172)
+++ branches/pingus-hanusz/src/result_screen.cpp 2011-07-02 05:02:42 UTC
(rev 4173)
@@ -191,7 +191,11 @@
}
std::string message;
- if (result.success())
+ if (result.exited)
+ {
+ message = _("The level was aborted.");
+ }
+ else if (result.success())
{
#ifdef PINGUS_MODE_EVIL
if (result.killed == result.total)
@@ -278,6 +282,8 @@
int right_x = Display::get_width()/2 + 100;
int y = Display::get_height()/2 + 10;
+ if (!result.exited)
+ {
#ifdef PINGUS_MODE_EVIL
gc.print_left(Fonts::chalk_normal, left_x, y, _("Killed: "));
gc.print_right(Fonts::chalk_normal, right_x, y,
StringUtil::to_string(result.killed)
@@ -305,6 +311,7 @@
gc.print_left(Fonts::chalk_normal, left_x, (y+=30), _("Time left: "));
gc.print_right(Fonts::chalk_normal, right_x, y, time_str);
+ }
SDL_Delay(10);
}
Modified: branches/pingus-hanusz/src/server.hpp
===================================================================
--- branches/pingus-hanusz/src/server.hpp 2011-06-24 20:24:41 UTC (rev
4172)
+++ branches/pingus-hanusz/src/server.hpp 2011-07-02 05:02:42 UTC (rev
4173)
@@ -56,6 +56,7 @@
World* get_world();
ActionHolder* get_action_holder();
+ GoalManager* get_goal_manager() { return goal_manager; }
/** @return true if the server is finished and the game can be
exited */
@@ -63,7 +64,7 @@
/** set the server into the finshed state, this is used when you
press ESCAPE inside a game */
- virtual void set_finished() =0;
+ virtual void set_finished(bool always_fail) =0;
/* Event handling stuff */
void send_armageddon_event();
Modified: branches/pingus-hanusz/src/statistics.cpp
===================================================================
--- branches/pingus-hanusz/src/statistics.cpp 2011-06-24 20:24:41 UTC (rev
4172)
+++ branches/pingus-hanusz/src/statistics.cpp 2011-07-02 05:02:42 UTC (rev
4173)
@@ -18,6 +18,7 @@
#include "statistics.hpp"
#include <stdexcept>
+#include <iostream>
Statistics* Statistics::s_instance = 0;
@@ -110,7 +111,9 @@
<< result.killed << ";"
<< result.used_time << ";"
<< actions_used << ";"
- << (result.aborted ? "aborted" :
(result.success()?"success":"failure")) << std::endl;
+ << (result.exited ? "exited" :
+ (result.aborted ? "aborted" :
+ (result.success()?"success":"failure"))) << std::endl;
}
}
Modified: branches/pingus-hanusz/src/true_server.cpp
===================================================================
--- branches/pingus-hanusz/src/true_server.cpp 2011-06-24 20:24:41 UTC (rev
4172)
+++ branches/pingus-hanusz/src/true_server.cpp 2011-07-02 05:02:42 UTC (rev
4173)
@@ -76,9 +76,9 @@
}
void
-TrueServer::set_finished ()
+TrueServer::set_finished (bool always_fail)
{
- goal_manager->set_abort_goal();
+ goal_manager->set_abort_goal(always_fail);
set_pause(false);
}
Modified: branches/pingus-hanusz/src/true_server.hpp
===================================================================
--- branches/pingus-hanusz/src/true_server.hpp 2011-06-24 20:24:41 UTC (rev
4172)
+++ branches/pingus-hanusz/src/true_server.hpp 2011-07-02 05:02:42 UTC (rev
4173)
@@ -46,7 +46,7 @@
/** set the server into the finshed state, this is used when you
press ESCAPE inside a game */
- void set_finished();
+ void set_finished(bool always_fail);
private:
TrueServer (const TrueServer&);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r4173 - in branches/pingus-hanusz/src: . components,
grumbel <=