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

« back to all changes in this revision

Viewing changes to src/worldmap/PingusWorldMapGraph.hh

  • 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: PingusWorldMapGraph.hh,v 1.14 2002/01/15 10:48:53 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
 
#ifndef PINGUSWORLDMAPGRAPH_HH
21
 
#define PINGUSWORLDMAPGRAPH_HH
22
 
 
23
 
#include <string>
24
 
 
25
 
#include "../PLF.hh"
26
 
#include "../Sprite.hh"
27
 
#include "../ResDescriptor.hh"
28
 
#include "../Position.hh"
29
 
#include "../XMLhelper.hh"
30
 
 
31
 
//#include "../generic/Graph.hh"
32
 
 
33
 
/** An object on the worldmap */
34
 
class PingusWorldMapNode
35
 
{
36
 
public:
37
 
  int id;
38
 
  bool accessible;
39
 
  CL_Vector pos;
40
 
  std::list<int> links;
41
 
  
42
 
  PingusWorldMapNode () {}
43
 
  virtual ~PingusWorldMapNode () {}
44
 
 
45
 
  virtual void on_click () =0;
46
 
  virtual void mark (bool value) {}
47
 
  virtual void draw (CL_Vector offset) {}
48
 
  virtual std::map<std::string, std::string> get_string () =0;
49
 
};
50
 
 
51
 
/** A wrap object which brings you to the next worldmap */
52
 
class PingusWorldMapTubeNode
53
 
  : public PingusWorldMapNode
54
 
{
55
 
public:
56
 
  std::string worldmap_name;
57
 
  Sprite tube;
58
 
  int link_node;
59
 
public:  
60
 
  PingusWorldMapTubeNode ();
61
 
  void on_click ();
62
 
  void draw (CL_Vector offset);
63
 
  std::map<std::string, std::string> get_string ();
64
 
};
65
 
 
66
 
/** The entrance to a level */
67
 
class PingusWorldMapLevelNode
68
 
  : public PingusWorldMapNode
69
 
{
70
 
private:
71
 
  Sprite green_dot;
72
 
  Sprite red_dot;
73
 
  Sprite dot_border;
74
 
  Sprite green_flag;
75
 
 
76
 
  boost::shared_ptr<PLF> plf;
77
 
 
78
 
public:
79
 
  std::string levelname;
80
 
  bool finished;
81
 
  boost::shared_ptr<PLF> get_plf ();
82
 
 
83
 
  PingusWorldMapLevelNode () 
84
 
    : green_dot ("worldmap/dot_green", "core"),
85
 
      red_dot ("worldmap/dot_red", "core"),
86
 
      dot_border ("Game/dot_border", "game"),
87
 
      green_flag ("worldmap/flaggreen", "core")
88
 
  {
89
 
    accessible = false;
90
 
    finished = false;
91
 
 
92
 
    green_flag.set_align (-24, -36);
93
 
    green_dot.set_align_center ();
94
 
    red_dot.set_align_center ();
95
 
    dot_border.set_align_center ();
96
 
  }
97
 
 
98
 
  void on_click ();
99
 
  void mark (bool value);
100
 
  void draw (CL_Vector offset);
101
 
  std::map<std::string, std::string> get_string ();
102
 
};
103
 
 
104
 
class PingusWorldMapGraph
105
 
{
106
 
private:
107
 
  //Graph<PingusWorldMapNode>* graph;
108
 
  ResDescriptor bg_desc;
109
 
  std::string music;
110
 
  xmlDocPtr doc;
111
 
  
112
 
public:
113
 
  std::list<boost::shared_ptr<PingusWorldMapNode> >   nodes;
114
 
  typedef std::list<boost::shared_ptr<PingusWorldMapNode> >::iterator iterator;
115
 
 
116
 
  PingusWorldMapGraph ();
117
 
  ~PingusWorldMapGraph ();
118
 
 
119
 
  ResDescriptor              get_background ();
120
 
  //Graph<PingusWorldMapNode>* get_graph ();
121
 
  std::string get_music ();
122
 
  
123
 
  void draw (const CL_Vector&);
124
 
 
125
 
  /// Some functions to parse the data out of an xml file
126
 
  //@{ 
127
 
  void parse_file (std::string filename);
128
 
private:
129
 
  void parse_node_list (xmlNodePtr);
130
 
  void parse_node (xmlNodePtr);
131
 
  void parse_tube (xmlNodePtr);
132
 
  void parse_music (xmlNodePtr);
133
 
  void parse_background (xmlNodePtr);
134
 
  //@}
135
 
};
136
 
 
137
 
#endif
138
 
 
139
 
/* EOF */