~ubuntu-branches/ubuntu/precise/pingus/precise

« back to all changes in this revision

Viewing changes to src/Story.cc

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Goulais
  • Date: 2004-08-09 10:26:00 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040809102600-lg2q9lfars0q1p42
Tags: 0.6.0-8
Applied patch from Andreas Jochens (Closes: #263992)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  $Id: Story.cc,v 1.12 2001/07/27 19:35:36 grumbel Exp $
2
 
//
3
 
//  Pingus - A free Lemmings clone
4
 
//  Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
5
 
//
6
 
//  This program is free software; you can redistribute it and/or
7
 
//  modify it under the terms of the GNU General Public License
8
 
//  as published by the Free Software Foundation; either version 2
9
 
//  of the License, or (at your option) any later version.
10
 
//
11
 
//  This program is distributed in the hope that it will be useful,
12
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
//  GNU General Public License for more details.
15
 
//
16
 
//  You should have received a copy of the GNU General Public License
17
 
//  along with this program; if not, write to the Free Software
18
 
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
 
 
20
 
#include <vector>
21
 
#include <string>
22
 
 
23
 
#include "worldmap/PingusWorldMapManager.hh"
24
 
#include "Display.hh"
25
 
#include "DeltaManager.hh"
26
 
#include "LayerManager.hh"
27
 
#include "PingusResource.hh"
28
 
#include "PingusMenuManager.hh"
29
 
#include "Story.hh"
30
 
 
31
 
Story::Story(PingusMenuManager* manager)
32
 
  : PingusSubMenu (manager)
33
 
{
34
 
  is_init = false;
35
 
}
36
 
 
37
 
Story::~Story()
38
 
{
39
 
  
40
 
}
41
 
 
42
 
void
43
 
Story::init()
44
 
{
45
 
  small_font = PingusResource::load_font("Fonts/pingus_small", "fonts");
46
 
  large_font = PingusResource::load_font("Fonts/pingus", "fonts");
47
 
  background = PingusResource::load_surface("Textures/stones", "textures");  
48
 
  story = PingusResource::load_surface("Story/story1", "story");
49
 
 
50
 
  is_init = true;
51
 
}
52
 
 
53
 
void 
54
 
Story::update (float delta)
55
 
{
56
 
}
57
 
 
58
 
void 
59
 
Story::draw()
60
 
{
61
 
  CL_Display::fill_rect (0,0,
62
 
                         CL_Display::get_width (),
63
 
                         CL_Display::get_height (),
64
 
                         0,0,0,0.5);
65
 
 
66
 
  story.put_screen(CL_Display::get_width()/2 - (story.get_width()/2),
67
 
                    50);
68
 
  CL_Display::fill_rect(CL_Display::get_width()/2 - (story.get_width()/2) + 25,
69
 
                        50 + story.get_height() + 25,
70
 
                        CL_Display::get_width()/2 + (story.get_width()/2) - 25,
71
 
                        CL_Display::get_height() - 25,
72
 
                        0.0, 0.0, 0.0, 0.5);
73
 
 
74
 
  small_font->print_left(125, 80 + story.get_height() + 25 + (1 * small_font->get_height()), "Insert extremly interesting story here...");
75
 
  small_font->print_left(125, 80 + story.get_height() + 25 + (2 * small_font->get_height()), "...");
76
 
  small_font->print_left(125, 80 + story.get_height() + 25 + (3 * small_font->get_height()), "...");
77
 
  small_font->print_left(125, 80 + story.get_height() + 25 + (4 * small_font->get_height()), "...");
78
 
  small_font->print_left(125, 80 + story.get_height() + 25 + (5 * small_font->get_height()), "...");
79
 
  small_font->print_left(125, 80 + story.get_height() + 25 + (6 * small_font->get_height()), "...");
80
 
}
81
 
 
82
 
void
83
 
Story::display_string(std::string current_line)
84
 
{
85
 
  /*  while ((pos = str.find("\n")) != string::npos) 
86
 
    {
87
 
      tmp_string = str.substr(0, pos);
88
 
      small_font->print_left(current_line + tmp_string);
89
 
      current_pos++;
90
 
      current_line = "";
91
 
      str = str.substr(pos+1);
92
 
    }
93
 
  */
94
 
  /*
95
 
  std::string tmp_string;
96
 
  std::vector<std::string> output_buffer;
97
 
 
98
 
  // FIXME: This could be optimized if xterm would be a fixed font...
99
 
  while(small_font->get_text_width(current_line.c_str()) > (CL_Display::get_width() - 100))
100
 
    {
101
 
      int pos;
102
 
      for (pos = current_line.size();
103
 
           small_font->get_text_width(current_line.substr(0, pos).c_str())
104
 
             > (CL_Display::get_width() - 100);
105
 
           pos--);
106
 
      
107
 
      tmp_string = current_line.substr(0, pos);
108
 
      
109
 
      output_buffer.push_back(tmp_string);
110
 
      current_line = current_line.substr(pos);
111
 
    }
112
 
  
113
 
  int x_pos = 100;
114
 
  int y_pos = 200;
115
 
  int j=0;
116
 
  for(std::vector<std::string>::iterator i = output_buffer.begin();
117
 
      i != output_buffer.end();
118
 
      i++)
119
 
    {
120
 
      small_font->print_left(x_pos, y_pos + j*small_font->get_height(), 
121
 
                             i->c_str());
122
 
    }*/
123
 
}
124
 
 
125
 
void 
126
 
Story::on_button_press (CL_InputDevice* device,const CL_Key& key)
127
 
{
128
 
  manager->disable_events ();
129
 
  // FIXME: This looks ugly... 
130
 
  PingusWorldMapManager worldmap_manager;
131
 
  worldmap_manager.display();
132
 
  manager->enable_events ();
133
 
  manager->set_menu (&manager->mainmenu);
134
 
}
135
 
 
136
 
/* EOF */