pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3697 - trunk/pingus/src


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3697 - trunk/pingus/src
Date: Sat, 5 Jul 2008 23:19:49 +0200

Author: grumbel
Date: 2008-07-05 23:19:49 +0200 (Sat, 05 Jul 2008)
New Revision: 3697

Removed:
   trunk/pingus/src/console.cpp
   trunk/pingus/src/console.hpp
Modified:
   trunk/pingus/src/global_event.cpp
   trunk/pingus/src/pingus_main.cpp
Log:
Removed console

Deleted: trunk/pingus/src/console.cpp
===================================================================
--- trunk/pingus/src/console.cpp        2008-07-05 21:13:45 UTC (rev 3696)
+++ trunk/pingus/src/console.cpp        2008-07-05 21:19:49 UTC (rev 3697)
@@ -1,248 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2000 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 <config.h>
-#include <assert.h>
-#include "fonts.hpp"
-#include "console.hpp"
-#include "math.hpp"
-
-using std::ostream;
-
-// Globale console
-Console console;
-
-ConsoleBuffer::ConsoleBuffer () : buffer(NUM_LINES)
-{
-  // Set the output buffer
-  setp (char_buffer, char_buffer + CONSOLE_BUFFER_SIZE - 1);
-
-  // Switch of input buffer
-  setg(0, 0, 0);
-}
-
-ConsoleBuffer::~ConsoleBuffer ()
-{
-  sync ();
-}
-
-int
-ConsoleBuffer::overflow (int c)
-{
-  std::string str = fill_buffer(true);
-
-  str += c;
-  buffer.push_back(str);
-  buffer.pop_front();
-
-  setp (char_buffer, char_buffer + CONSOLE_BUFFER_SIZE - 1);
-  return 0;
-}
-
-int
-ConsoleBuffer::sync ()
-{
-  std::string str = fill_buffer(false);
-
-  if (!str.empty())
-    {
-      buffer.push_back(str);
-      buffer.pop_front();
-    }
-
-  setp(char_buffer, char_buffer + CONSOLE_BUFFER_SIZE - 1);
-  return 0;
-}
-
-std::string
-ConsoleBuffer::fill_buffer (bool append)
-{
-  std::string str;
-  if (append)
-    {
-      str = *(--buffer.end());
-      buffer.pop_back();
-      buffer.push_front("");
-    }
-
-  for (char* c = pbase (); c != pptr (); ++c)
-    {
-      if (*c != '\n')
-       str += *c;
-      else
-       {
-         if (str.size() > MAX_LINE_LENGTH)
-           {
-             std::string::size_type pos = str.rfind(' ');
-             if (pos == std::string::npos)
-               pos = MAX_LINE_LENGTH;
-
-             buffer.push_back(str.substr(0, pos));
-             buffer.pop_front();
-
-             str = str.substr(pos, str.size());
-           }
-
-          buffer.push_back(str);
-          buffer.pop_front();
-          str = "";
-       }
-    }
-
-  return str;
-}
-
-const std::list<std::string>&
-ConsoleBuffer::get_buffer () {
-  return buffer;
-}
-
-Console::Console() : ostream (&streambuf) // std:: is missing here since Win32 
doesn't like it
-{
-  is_init = false;
-  visible = false;
-  current_pos = 0;
-  number_of_lines = 12;
-
-  *this << "================================" << std::endl;
-  *this << "Welcome to Pingus " << VERSION << std::endl;
-  *this << "================================" << std::endl;
-  newline ();
-  *this << "This is the output and debug console, you can toggle it with F1" 
<< std::endl;
-  newline ();
-}
-
-Console::~Console()
-{
-}
-
-// We are not initialising the console in the constructor, 'cause
-// that doesn't work (ClanLib hasn't init the display at that point) void
-void
-Console::init()
-{
-  // std::cout << "Console: Init..." << std::endl;
-  font = Fonts::courier_small;
-
-  //  (*this) << "Pingus Output Console (hide/show it with F1)\n"
-  //     << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
-
-  is_init = true;
-}
-
-// Unload any ClanLib objects that might linger around after we
-// destroy the graphics context
-void
-Console::deinit()
-{
-  font = Font();
-}
-
-void
-Console::draw()
-{
-  assert(is_init);
-
-  /** Callculate the position of the first line on the screen */
-  int start_y_pos =
-    Display::get_height() - (font.get_height() * (number_of_lines + 3));
-
-  // The background of the console
-  Display::fill_rect(Rect(0, start_y_pos - 15, Display::get_width(), 
Display::get_height()),
-                     Color(0, 50, 0, 128));
-  Display::fill_rect(Rect(0, start_y_pos - 15 - 4, Display::get_width(), 
start_y_pos - 15),
-                     Color(0, 150, 0, 128));
-
-  const std::list<std::string>& buffer = streambuf.get_buffer ();
-
-  unsigned int window_start = Math::max(0, int(buffer.size() - number_of_lines 
- current_pos));
-
-  std::list<std::string>::const_iterator it = buffer.begin();
-
-  // move iterator to the first line to be displayed
-  for (unsigned int i = 0; i < window_start; ++i)
-    ++it;
-
-  for (unsigned int i = 0;
-       i < number_of_lines && i + window_start < buffer.size();
-       ++it, ++i)
-    {
-      font.draw(10,
-                start_y_pos + (i * (font.get_height() + 2)),
-                it->c_str()
-                );
-    }
-}
-
-void
-Console::increase_lines()
-{
-  ++number_of_lines;
-}
-
-void
-Console::decrease_lines()
-{
-  if (number_of_lines > 0)
-    --number_of_lines;
-}
-
-void
-Console::scroll_up()
-{
-  if (current_pos + number_of_lines < streambuf.get_buffer().size())
-    ++current_pos;
-}
-
-void
-Console::scroll_down()
-{
-  if (current_pos)
-    --current_pos;
-}
-
-void
-Console::set_lines(int a)
-{
-  number_of_lines = a;
-}
-
-int
-Console::get_lines()
-{
-  return number_of_lines;
-}
-
-void
-Console::puts(const std::string& str)
-{
-  (*this) << str.c_str() << std::endl;
-}
-
-void
-Console::newline()
-{
-  (*this) << std::endl;
-}
-
-void
-Console::on_event()
-{
-  draw();
-}
-
-
-/* EOF */

Deleted: trunk/pingus/src/console.hpp
===================================================================
--- trunk/pingus/src/console.hpp        2008-07-05 21:13:45 UTC (rev 3696)
+++ trunk/pingus/src/console.hpp        2008-07-05 21:19:49 UTC (rev 3697)
@@ -1,117 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2000 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_CONSOLE_HPP
-#define HEADER_PINGUS_CONSOLE_HPP
-
-#include <string>
-#include <iostream>
-#include "display/display.hpp"
-#include "font.hpp"
-
-class ConsoleBuffer :
-  public std::streambuf
-{
-private:
-
-  enum { CONSOLE_BUFFER_SIZE = 200 };
-  enum { NUM_LINES           = 100 };
-  enum { MAX_LINE_LENGTH     = 130  }; // FIXME: this should be dynamic 
arcording to the current screen size
-
-  std::list<std::string> buffer;
-  char char_buffer[CONSOLE_BUFFER_SIZE];
-
-public:
-  ConsoleBuffer ();
-  virtual ~ConsoleBuffer ();
-  int overflow (int c);
-  int sync ();
-  const std::list<std::string>& get_buffer ();
-
-private:
-  /// helper function used by overflow and sync
-  std::string fill_buffer (bool append);
-
-  ConsoleBuffer (const ConsoleBuffer&);
-  ConsoleBuffer& operator= (const ConsoleBuffer&);
-};
-
-/** A "Quake" like console, but it can just handle output, you can't
-    type anything. */
-class Console :
-  public std::ostream,
-  public DisplayHook
-{
-private:
-  ConsoleBuffer streambuf;
-
-public:
-  Font font;
-  bool is_init;
-  unsigned int current_pos;
-
-  /** number of lines which will get displayed on the screen */
-  unsigned int number_of_lines;
-  void draw();
-public:
-  Console ();
-  virtual ~Console();
-
-       /** Load any gfx or objects that we might need */
-  void init();
-
-       /** Unload all gfx and objects */
-       void deinit();
-
-  virtual void on_event();
-
-  /** Sets the number of lines, which are displayed
-      @param lines The number of lines which are displayed */
-  void set_lines(int lines);
-
-  /// Returns the height in number of lines, {\em not} in pixels.
-  int  get_lines();
-
-  /** Increase the number of lines, which are displayed */
-  void increase_lines();
-
-  /** Decrease the number of lines, which are displayed */
-  void decrease_lines();
-
-  /** Scroll up */
-  void scroll_up();
-
-  /** Scroll up */
-  void scroll_down();
-
-  /** Scroll down or up n lines, depending on the sign */
-  void scroll (int n);
-
-  void puts(const std::string&);
-  void newline();
-
-private:
-  Console (const Console&);
-  Console& operator= (const Console&);
-};
-
-/** The globale console object to which you can send messages */
-extern Console console;
-
-
-#endif
-
-/* EOF */

Modified: trunk/pingus/src/global_event.cpp
===================================================================
--- trunk/pingus/src/global_event.cpp   2008-07-05 21:13:45 UTC (rev 3696)
+++ trunk/pingus/src/global_event.cpp   2008-07-05 21:19:49 UTC (rev 3697)
@@ -16,9 +16,9 @@
 
 #include <config.h>
 #include <stdio.h>
+#include <iostream>
 #include <algorithm>
 #include "screenshot.hpp"
-#include "console.hpp"
 #include "fps_counter.hpp"
 #include "screen/screen_manager.hpp"
 #include "option_menu.hpp"
@@ -41,13 +41,6 @@
 
   switch (event.keysym.sym)
     {
-      case SDLK_F1:
-        if (console.is_visible())
-          console.hide();
-        else
-          console.show();
-        break;
-
       case SDLK_F10:
         config_manager.set_print_fps(!config_manager.get_print_fps());
         break;
@@ -75,11 +68,8 @@
       case SDLK_F12:
         {
           std::string filename;
-          std::cout << "GlobalEvent::Making screenshot..." << std::endl;
           filename = Screenshot::make_screenshot();
-          console << "GlobalEvent: Saved screenshot to \"" << filename << "\"" 
<< std::endl;
-          //console << "!\"#$%&'()*+,-./0123456789:;<=>?@";
-          console.newline();
+          std::cout << "GlobalEvent: Saved screenshot to \"" << filename << 
"\"" << std::endl;
         }
         break;
 

Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp    2008-07-05 21:13:45 UTC (rev 3696)
+++ trunk/pingus/src/pingus_main.cpp    2008-07-05 21:19:49 UTC (rev 3697)
@@ -61,7 +61,6 @@
 #include "system.hpp"
 #include "pingus_error.hpp"
 #include "config.hpp"
-#include "console.hpp"
 #include "fps_counter.hpp"
 #include "plf_res_mgr.hpp"
 #include "game_session.hpp"
@@ -727,11 +726,8 @@
 
   // Init error/warning/notice streams
   pout.add(std::cout);
-  pout.add(console);
   pwarn.add(std::cout);
-  pout.add(console);
   perr.add(std::cout);
-  perr.add(console);
 
   try
     {
@@ -808,14 +804,12 @@
   PinguActionFactory::init();
   
   fps_counter.init();
-  console.init();
 }
 
 void
 PingusMain::deinit_pingus()
 {
   fps_counter.deinit();
-  console.deinit();
 
   Fonts::deinit();
   PinguActionFactory::deinit();





reply via email to

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