pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3688 - in trunk/pingus: . src src/editor src/screen src/wo


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3688 - in trunk/pingus: . src src/editor src/screen src/worldmap
Date: Sat, 5 Jul 2008 07:37:37 +0200

Author: grumbel
Date: 2008-07-05 07:37:29 +0200 (Sat, 05 Jul 2008)
New Revision: 3688

Removed:
   trunk/pingus/src/screen/screen_ptr.cpp
   trunk/pingus/src/screen/screen_ptr.hpp
Modified:
   trunk/pingus/SConstruct
   trunk/pingus/src/demo_session.cpp
   trunk/pingus/src/editor/editor_screen.cpp
   trunk/pingus/src/game_session.cpp
   trunk/pingus/src/global_event.cpp
   trunk/pingus/src/level_menu.cpp
   trunk/pingus/src/pingus_main.cpp
   trunk/pingus/src/pingus_menu.cpp
   trunk/pingus/src/result_screen.cpp
   trunk/pingus/src/screen/screen_manager.cpp
   trunk/pingus/src/screen/screen_manager.hpp
   trunk/pingus/src/start_screen.cpp
   trunk/pingus/src/worldmap/level_dot.cpp
   trunk/pingus/src/worldmap/worldmap.cpp
   trunk/pingus/src/worldmap/worldmap_screen.cpp
Log:
Replaced ScreenPtr with boost::shared_ptr<Screen>

Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct     2008-07-05 05:22:56 UTC (rev 3687)
+++ trunk/pingus/SConstruct     2008-07-05 05:37:29 UTC (rev 3688)
@@ -137,7 +137,6 @@
 'src/screen/gui_screen.cpp', 
 'src/screen/screen.cpp', 
 'src/screen/screen_manager.cpp', 
-'src/screen/screen_ptr.cpp', 
 
 'src/line_iterator.cpp',
 'src/level_menu.cpp',

Modified: trunk/pingus/src/demo_session.cpp
===================================================================
--- trunk/pingus/src/demo_session.cpp   2008-07-05 05:22:56 UTC (rev 3687)
+++ trunk/pingus/src/demo_session.cpp   2008-07-05 05:37:29 UTC (rev 3688)
@@ -222,7 +222,7 @@
 void
 DemoSession::restart()
 {
-  ScreenManager::instance()->replace_screen(new DemoSession(pathname), true);
+  ScreenManager::instance()->replace_screen(new DemoSession(pathname));
 }
 
 /* EOF */

Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp   2008-07-05 05:22:56 UTC (rev 
3687)
+++ trunk/pingus/src/editor/editor_screen.cpp   2008-07-05 05:37:29 UTC (rev 
3688)
@@ -327,7 +327,7 @@
       return;
     }
   PingusLevel level(tmp);
-  ScreenManager::instance()->push_screen(new GameSession(level, false), true);
+  ScreenManager::instance()->push_screen(new GameSession(level, false));
 }
 
 void

Modified: trunk/pingus/src/game_session.cpp
===================================================================
--- trunk/pingus/src/game_session.cpp   2008-07-05 05:22:56 UTC (rev 3687)
+++ trunk/pingus/src/game_session.cpp   2008-07-05 05:37:29 UTC (rev 3688)
@@ -119,7 +119,7 @@
       }
 
       if (show_result_screen)
-        ScreenManager::instance()->replace_screen(new ResultScreen(result), 
true);
+        ScreenManager::instance()->replace_screen(new ResultScreen(result));
       else
         ScreenManager::instance()->pop_screen();
 

Modified: trunk/pingus/src/global_event.cpp
===================================================================
--- trunk/pingus/src/global_event.cpp   2008-07-05 05:22:56 UTC (rev 3687)
+++ trunk/pingus/src/global_event.cpp   2008-07-05 05:37:29 UTC (rev 3688)
@@ -63,13 +63,13 @@
       case SDLK_F5:
         if (maintainer_mode)
           if 
(!dynamic_cast<OptionMenu*>(ScreenManager::instance()->get_screen()))
-            ScreenManager::instance()->push_screen(new OptionMenu(), true);
+            ScreenManager::instance()->push_screen(new OptionMenu());
         break;
 
       case SDLK_F6:
         if (maintainer_mode)
           if 
(!dynamic_cast<AddOnMenu*>(ScreenManager::instance()->get_screen()))
-            ScreenManager::instance()->push_screen(new AddOnMenu(), true);
+            ScreenManager::instance()->push_screen(new AddOnMenu());
         break;
 
       case SDLK_F12:

Modified: trunk/pingus/src/level_menu.cpp
===================================================================
--- trunk/pingus/src/level_menu.cpp     2008-07-05 05:22:56 UTC (rev 3687)
+++ trunk/pingus/src/level_menu.cpp     2008-07-05 05:37:29 UTC (rev 3688)
@@ -330,7 +330,7 @@
       {
         if (levelset->get_level(current_level)->accessible)
           {
-            ScreenManager::instance()->push_screen(new 
StartScreen(levelset->get_level(current_level)->plf), true);
+            ScreenManager::instance()->push_screen(new 
StartScreen(levelset->get_level(current_level)->plf));
           }
       }
   }

Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp    2008-07-05 05:22:56 UTC (rev 3687)
+++ trunk/pingus/src/pingus_main.cpp    2008-07-05 05:37:29 UTC (rev 3688)
@@ -667,7 +667,7 @@
     }
   else if (cmd_options.credits.is_set() && cmd_options.credits.get())
     { // just show the credits screen
-      ScreenManager::instance()->push_screen(new Credits(), true);
+      ScreenManager::instance()->push_screen(new Credits());
     }
   else if (cmd_options.font.is_set() && cmd_options.font.get())
     { // run the Font Test
@@ -678,7 +678,7 @@
       else
         {
           Pathname file(cmd_options.rest.get(), Pathname::SYSTEM_PATH);
-          ScreenManager::instance()->push_screen(new FontTestScreen(file), 
true); 
+          ScreenManager::instance()->push_screen(new FontTestScreen(file)); 
         }
     }
   else if (cmd_options.editor.is_set() && cmd_options.editor.get())
@@ -688,27 +688,26 @@
       if (cmd_options.rest.is_set())
         editor->load(Pathname(cmd_options.rest.get(), Pathname::SYSTEM_PATH));
 
-      ScreenManager::instance()->push_screen (editor, true);
+      ScreenManager::instance()->push_screen(editor);
     }
   else if (cmd_options.rest.is_set())
     { // just start the map that was passed on the command line
       if (StringUtil::has_suffix(cmd_options.rest.get(), ".pingus-demo"))
         { // Demo file
           ScreenManager::instance()->push_screen
-            (new DemoSession(Pathname(cmd_options.rest.get(), 
Pathname::SYSTEM_PATH)), true);
+            (new DemoSession(Pathname(cmd_options.rest.get(), 
Pathname::SYSTEM_PATH)));
         }
       else
         { // Level file
           ScreenManager::instance()->push_screen
             (new 
StartScreen(PLFResMgr::load_plf_from_filename(Pathname(cmd_options.rest.get(),
-                                                                        
Pathname::SYSTEM_PATH))),
-             true);
+                                                                        
Pathname::SYSTEM_PATH))));
         }
     }
   else // start a normal game
     {
       pout(PINGUS_DEBUG_LOADING) << "starting normal game" << std::endl;
-      ScreenManager::instance()->push_screen(new PingusMenuManager(), true);
+      ScreenManager::instance()->push_screen(new PingusMenuManager());
       pout(PINGUS_DEBUG_LOADING) << "done: starting normal game" << std::endl;
     }
 

Modified: trunk/pingus/src/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus_menu.cpp    2008-07-05 05:22:56 UTC (rev 3687)
+++ trunk/pingus/src/pingus_menu.cpp    2008-07-05 05:37:29 UTC (rev 3688)
@@ -75,7 +75,7 @@
 void
 PingusMenu::show_credits()
 {
-  ScreenManager::instance()->push_screen(new Credits(), true);
+  ScreenManager::instance()->push_screen(new Credits());
 }
 
 PingusMenu::~PingusMenu()
@@ -111,7 +111,7 @@
     {
       std::auto_ptr<WorldmapNS::WorldmapScreen> worldmap_screen(new 
WorldmapNS::WorldmapScreen());
       worldmap_screen->load(filename);
-      ScreenManager::instance()->push_screen(worldmap_screen.release(), true);
+      ScreenManager::instance()->push_screen(worldmap_screen.release());
     }
 }
 
@@ -119,13 +119,13 @@
 { // Launch the specified level - don't bother checking for it, it has to exist
   Sound::PingusSound::play_sound ("letsgo");
   ScreenManager::instance()->push_screen
-    (new StartScreen(PLFResMgr::load_plf_from_filename(Pathname(levelfile, 
Pathname::SYSTEM_PATH))), true);
+    (new StartScreen(PLFResMgr::load_plf_from_filename(Pathname(levelfile, 
Pathname::SYSTEM_PATH))));
 }
 
 void PingusMenu::do_edit()
 {      // Launch the level editor
   Sound::PingusSound::stop_music();
-  ScreenManager::instance()->push_screen (new Editor::EditorScreen(), true);
+  ScreenManager::instance()->push_screen (new Editor::EditorScreen());
 }
 
 void
@@ -212,7 +212,7 @@
     }
   else if (button == contrib_button)
     {
-      ScreenManager::instance()->push_screen(new LevelMenu(), true);
+      ScreenManager::instance()->push_screen(new LevelMenu());
     }
 }
 

Modified: trunk/pingus/src/result_screen.cpp
===================================================================
--- trunk/pingus/src/result_screen.cpp  2008-07-05 05:22:56 UTC (rev 3687)
+++ trunk/pingus/src/result_screen.cpp  2008-07-05 05:37:29 UTC (rev 3688)
@@ -283,7 +283,7 @@
 void
 ResultScreen::retry_level()
 {
-  ScreenManager::instance()->replace_screen(new GameSession (result.plf, 
true), true);
+  ScreenManager::instance()->replace_screen(new GameSession (result.plf, 
true));
 }
 
 void

Modified: trunk/pingus/src/screen/screen_manager.cpp
===================================================================
--- trunk/pingus/src/screen/screen_manager.cpp  2008-07-05 05:22:56 UTC (rev 
3687)
+++ trunk/pingus/src/screen/screen_manager.cpp  2008-07-05 05:37:29 UTC (rev 
3688)
@@ -24,7 +24,7 @@
 #include "display/display.hpp"
 #include "screen_manager.hpp"
 #include "../path_manager.hpp"
-#include "screenshot.hpp"
+#include "screen.hpp"
 #include "../display/drawing_context.hpp"
 #include "../input/controller.hpp"
 #include "../input/manager.hpp"
@@ -158,7 +158,7 @@
   delete input_controller;
 }
 
-ScreenPtr&
+ScreenPtr
 ScreenManager::get_current_screen()
 {
   assert(!screens.empty());
@@ -175,14 +175,14 @@
 }
 
 void
-ScreenManager::push_screen (Screen* screen, bool delete_screen)
+ScreenManager::push_screen (Screen* screen)
 {
   if (!screens.empty())
     {
       screens.back ()->on_shutdown ();
     }
 
-  screens.push_back (ScreenPtr(screen, delete_screen));
+  screens.push_back (ScreenPtr(screen));
   screen->on_startup ();
 }
 
@@ -201,15 +201,15 @@
 }
 
 void
-ScreenManager::replace_screen (Screen* screen, bool delete_screen)
+ScreenManager::replace_screen (Screen* screen)
 {
   assert (cached_action == CA_NONE);
   cached_action = CA_REPLACE;
-  replace_screen_arg = ScreenPtr(screen, delete_screen);
+  replace_screen_arg = ScreenPtr(screen);
 }
 
 void
-ScreenManager::real_replace_screen (const ScreenPtr& ptr)
+ScreenManager::real_replace_screen (ScreenPtr ptr)
 {
   cached_action = CA_NONE;
   screens.back ()->on_shutdown ();
@@ -256,7 +256,7 @@
 }
 
 void
-ScreenManager::fade_over(ScreenPtr& old_screen, ScreenPtr& new_screen)
+ScreenManager::fade_over(ScreenPtr old_screen, ScreenPtr new_screen)
 {
   DeltaManager delta_manager;
   float passed_time = 0;

Modified: trunk/pingus/src/screen/screen_manager.hpp
===================================================================
--- trunk/pingus/src/screen/screen_manager.hpp  2008-07-05 05:22:56 UTC (rev 
3687)
+++ trunk/pingus/src/screen/screen_manager.hpp  2008-07-05 05:37:29 UTC (rev 
3688)
@@ -18,14 +18,16 @@
 #define HEADER_PINGUS_SCREEN_MANAGER_HPP
 
 #include "../pingus.hpp"
+#include "SDL.h"
+#include <boost/smart_ptr.hpp>
 #include <vector>
 
-#include "screen_ptr.hpp"
-
 class Cursor;
 class Size;
 class DrawingContext;
 class Screen;
+
+typedef boost::shared_ptr<Screen> ScreenPtr;
 
 class ScreenManager
 {
@@ -59,10 +61,10 @@
   void display ();
 
   /** Replace the current screen */
-  void replace_screen (Screen*, bool delete_screen = false);
+  void replace_screen (Screen*);
 
   /** Add a screen on top of another screen */
-  void push_screen (Screen*, bool delete_screen = false);
+  void push_screen (Screen*);
 
   /** Remove the current screen and fall back to the last one */
   void pop_screen ();
@@ -74,7 +76,7 @@
   void clear();
 
   /** @return a pointer to the current Screen */
-  ScreenPtr& get_current_screen();
+  ScreenPtr get_current_screen();
 
   /** @return a pointer to the current Screen */
   Screen* get_screen();
@@ -86,7 +88,7 @@
   void real_clear();
 
   /** Replace the current screen */
-  void real_replace_screen (const ScreenPtr&);
+  void real_replace_screen (ScreenPtr);
 
   /** Remove the current screen and fall back to the last one */
   void real_pop_screen ();
@@ -95,7 +97,7 @@
   void real_pop_all_screens();
 
   /** FadeOver test*/
-  void fade_over (ScreenPtr& old_screen, ScreenPtr& new_screen);
+  void fade_over (ScreenPtr old_screen, ScreenPtr new_screen);
 
 public:
   static ScreenManager* instance ();
@@ -105,7 +107,7 @@
   ScreenManager (const ScreenManager&);
   ScreenManager& operator= (const ScreenManager&);
 };
-
+
 #endif
 
 /* EOF */

Deleted: trunk/pingus/src/screen/screen_ptr.cpp
===================================================================
--- trunk/pingus/src/screen/screen_ptr.cpp      2008-07-05 05:22:56 UTC (rev 
3687)
+++ trunk/pingus/src/screen/screen_ptr.cpp      2008-07-05 05:37:29 UTC (rev 
3688)
@@ -1,56 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//  
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//  
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#include <typeinfo>
-#include <iostream>
-#include "screen_ptr.hpp"
-
-
-void
-ScreenPtr::decrease_refcount()
-{
-  //std::cout << "ScreenPtr::decrease_refcount(): " << screen << std::endl;
-
-  if (delete_it)
-    {
-      //std::cout << "*ref_count: " << *ref_count << std::endl;
-
-      *ref_count -= 1;
-
-      if (*ref_count == 0)
-       {
-         //std::cout << "XXXXXXXXXXXXXX ScreenPtr: deleting: "
-          //<< screen << " = " << typeid(*screen).name() << std::endl;
-         delete screen;
-         delete ref_count;
-       }
-    }
-}
-
-void
-ScreenPtr::increase_refcount()
-{
-  //std::cout << "ScreenPtr::increase_refcount(): " << screen << std::endl;
-
-  if (delete_it)
-    {
-      //std::cout << "*ref_count: " << *ref_count << std::endl;
-      *ref_count += 1;
-    }
-}
-
-
-/* EOF */

Deleted: trunk/pingus/src/screen/screen_ptr.hpp
===================================================================
--- trunk/pingus/src/screen/screen_ptr.hpp      2008-07-05 05:22:56 UTC (rev 
3687)
+++ trunk/pingus/src/screen/screen_ptr.hpp      2008-07-05 05:37:29 UTC (rev 
3688)
@@ -1,107 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//  
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//  
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_SCREEN_PTR_HPP
-#define HEADER_PINGUS_SCREEN_PTR_HPP
-
-#include "screen.hpp"
-
-
-/** The ScreenPtr is a simple smart pointer to point at a Screen. It
-    either deletes the pointer or not, depending on the value of
-    delete_it */
-class ScreenPtr
-{
-private:
-  Screen* screen;
-  bool    delete_it;
-  long*   ref_count;
-
-public:
-  ScreenPtr()
-    : screen(0), delete_it(false), ref_count(0)
-  {
-  }
-
-  ScreenPtr(Screen* arg_screen, bool arg_delete_it)
-    : screen(arg_screen), delete_it(arg_delete_it)
-  {
-    if (delete_it)
-      {
-       ref_count = new long;
-       *ref_count = 1;
-      }
-    else
-      {
-       ref_count = 0;
-      }
-  }
-
-  ScreenPtr (const ScreenPtr& ptr)
-    : screen(ptr.screen), delete_it(ptr.delete_it), ref_count(ptr.ref_count)
-  {
-    increase_refcount();
-  }
-
-  bool operator==(const ScreenPtr& ptr)
-  {
-    return screen == ptr.screen;
-  }
-
-  ScreenPtr& operator= (const ScreenPtr& ptr)
-  {
-    if (this != &ptr)
-      {
-       decrease_refcount();
-
-       screen    = ptr.screen;
-       delete_it = ptr.delete_it;
-       ref_count = ptr.ref_count;
-
-       increase_refcount();
-      }
-    return *this;
-  }
-
-  ~ScreenPtr()
-  {
-    decrease_refcount();
-  }
-
-  Screen* operator->()
-  {
-    return screen;
-  }
-
-  const Screen& operator*()
-  {
-    return *screen;
-  }
-
-  Screen* get()
-  {
-    return screen;
-  }
-
-private:
-  void decrease_refcount();
-  void increase_refcount();
-};
-
-
-#endif
-
-/* EOF */

Modified: trunk/pingus/src/start_screen.cpp
===================================================================
--- trunk/pingus/src/start_screen.cpp   2008-07-05 05:22:56 UTC (rev 3687)
+++ trunk/pingus/src/start_screen.cpp   2008-07-05 05:37:29 UTC (rev 3688)
@@ -224,7 +224,7 @@
 StartScreen::start_game()
 {
   GameSession* game_session = new GameSession(plf, true);
-  ScreenManager::instance()->replace_screen(game_session, true);
+  ScreenManager::instance()->replace_screen(game_session);
 }
 
 void

Modified: trunk/pingus/src/worldmap/level_dot.cpp
===================================================================
--- trunk/pingus/src/worldmap/level_dot.cpp     2008-07-05 05:22:56 UTC (rev 
3687)
+++ trunk/pingus/src/worldmap/level_dot.cpp     2008-07-05 05:37:29 UTC (rev 
3688)
@@ -98,8 +98,7 @@
 LevelDot::on_click()
 {
   //std::cout << "Starting level: " << levelname << std::endl;
-  ScreenManager::instance()->push_screen(new StartScreen(plf),
-                                         true);
+  ScreenManager::instance()->push_screen(new StartScreen(plf));
 }
 
 bool

Modified: trunk/pingus/src/worldmap/worldmap.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap.cpp      2008-07-05 05:22:56 UTC (rev 
3687)
+++ trunk/pingus/src/worldmap/worldmap.cpp      2008-07-05 05:37:29 UTC (rev 
3688)
@@ -306,7 +306,7 @@
         {
           if (dot->finished())
             {
-              ScreenManager::instance()->replace_screen(new 
StoryScreen(worldmap.get_end_story()), true);
+              ScreenManager::instance()->replace_screen(new 
StoryScreen(worldmap.get_end_story()));
             }
         }
       else

Modified: trunk/pingus/src/worldmap/worldmap_screen.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap_screen.cpp       2008-07-05 05:22:56 UTC 
(rev 3687)
+++ trunk/pingus/src/worldmap/worldmap_screen.cpp       2008-07-05 05:37:29 UTC 
(rev 3688)
@@ -298,13 +298,13 @@
 void
 WorldmapScreen::show_intro_story()
 {
-  ScreenManager::instance()->push_screen(new 
StoryScreen(worldmap->get_worldmap().get_intro_story()), true);
+  ScreenManager::instance()->push_screen(new 
StoryScreen(worldmap->get_worldmap().get_intro_story()));
 }
 
 void
 WorldmapScreen::show_end_story()
 {
-  ScreenManager::instance()->push_screen(new 
StoryScreen(worldmap->get_worldmap().get_end_story()), true);
+  ScreenManager::instance()->push_screen(new 
StoryScreen(worldmap->get_worldmap().get_end_story()));
 }
 
 } // namespace WorldmapNS





reply via email to

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