mapview Class Reference

Allows you to display a landmap on a specified area of a surface. More...

#include <mapview.h>

Inheritance diagram for mapview:

Inheritance graph
[legend]
Collaboration diagram for mapview:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 mapview ()
 Default constructor.
 ~mapview ()
 Destructor.
void resize (u_int16 l, u_int16 h)
 Resize the mapview.
void set_schedule (string file, PyObject *args=NULL)
 Assign a schedule to the mapview.
string schedule_file ()
 Returns the name of the mapview's current schedule.
bool update ()
 Updates the mapview's state and launchs his schedule.
void draw (s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const
 Draw the object on the screen.
void attach_map (landmap *m)
 Attach/Detach a map.
void detach_map ()
 Stops displaying a map.
s_int8 set_pos (u_int16 sm, u_int16 x, u_int16 y, s_int16 ox=0, s_int16 oy=0)
 Position settings.
s_int8 center_on (u_int16 sm, u_int16 x, u_int16 y, s_int16 ox=0, s_int16 oy=0)
 Sets the position of the center of the mapview on the map.
u_int16 currentsubmap ()
 Position information.
u_int16 posx () const
 Returns the X position of the mapview.
u_int16 posy () const
 Returns the Y position of the mapview.
u_int16 offx () const
 Returns the X offset of the mapview.
u_int16 offy () const
 Returns the Y offset of the mapview.
bool can_scroll_right ()
 Basic movment.
bool can_scroll_left ()
 Returns whether it is possible to scroll to left.
bool can_scroll_up ()
 Returns whether it is possible to scroll to up.
bool can_scroll_down ()
 Returns whether it is possible to scroll to down.
void scroll_right ()
 Scrolls 1 pixel to right, if possible.
void scroll_left ()
 Scrolls 1 pixel to left, if possible.
void scroll_down ()
 Scrolls 1 pixel to down, if possible.
void scroll_up ()
 Scrolls 1 pixel to up, if possible.
s_int8 get_state (igzstream &file)
 State saving/loading.
s_int8 put_state (ogzstream &file)
 Saves the mapview's state into an opened file.


Detailed Description

Allows you to display a landmap on a specified area of a surface.

This class just acts as a "camera" which takes snapshots of a landmap. It's size can be specified, a schedule can be set to update it's movment. Nothing prevents you from having several mapviews on the same map that displays each a different (or similar) part of the landmap.

Definition at line 44 of file mapview.h.


Constructor & Destructor Documentation

mapview::mapview (  ) 

Default constructor.

Definition at line 29 of file mapview.cc.

mapview::~mapview (  ) 

Destructor.

Definition at line 40 of file mapview.cc.


Member Function Documentation

void mapview::attach_map ( landmap m  ) 

Attach/Detach a map.

Sets which map this mapview will display.

Parameters:
m pointer to the map that will be displayed by the mapview.

Definition at line 46 of file mapview.cc.

void mapview::detach_map (  ) 

Stops displaying a map.

Definition at line 53 of file mapview.cc.

s_int8 mapview::set_pos ( u_int16  sm,
u_int16  x,
u_int16  y,
s_int16  ox = 0,
s_int16  oy = 0 
)

Position settings.

Sets the position of the top-left corner of the mapview on the map.

You'll probably don't want to use this method. To center the mapview on a precise position, see center_on () instead.

Parameters:
sm submap.
x X position.
y Y position.
ox X offset.
oy Y offset.
See also:
center_on ()

Definition at line 60 of file mapview.cc.

s_int8 mapview::center_on ( u_int16  sm,
u_int16  x,
u_int16  y,
s_int16  ox = 0,
s_int16  oy = 0 
)

Sets the position of the center of the mapview on the map.

Parameters:
sm submap.
x X position.
y Y position.
ox X offset.
oy Y offset.

Definition at line 90 of file mapview.cc.

u_int16 mapview::currentsubmap (  )  [inline]

Position information.

Returns the submap this mapview is displaying.

Returns:
current submap this mapview is displaying.

Definition at line 137 of file mapview.h.

u_int16 mapview::posx (  )  const [inline]

Returns the X position of the mapview.

Returns:
X position of the mapview.

Definition at line 148 of file mapview.h.

u_int16 mapview::posy (  )  const [inline]

Returns the Y position of the mapview.

Returns:
Y position of the mapview.

Definition at line 159 of file mapview.h.

u_int16 mapview::offx (  )  const [inline]

Returns the X offset of the mapview.

Returns:
X offset of the mapview.

Definition at line 170 of file mapview.h.

u_int16 mapview::offy (  )  const [inline]

Returns the Y offset of the mapview.

Returns:
Y offset of the mapview.

Definition at line 181 of file mapview.h.

bool mapview::can_scroll_right (  )  [inline]

Basic movment.

Returns whether it is possible to scroll to right. A scrolling is impossible if the mapview is at the map limits.

Returns:
true if a right scrolling is possible, false otherwise.

Definition at line 202 of file mapview.h.

bool mapview::can_scroll_left (  )  [inline]

Returns whether it is possible to scroll to left.

A scrolling is impossible if the mapview is at the map limits.

Returns:
true if a left scrolling is possible, false otherwise.

Definition at line 215 of file mapview.h.

bool mapview::can_scroll_up (  )  [inline]

Returns whether it is possible to scroll to up.

A scrolling is impossible if the mapview is at the map limits.

Returns:
true if a up scrolling is possible, false otherwise.

Definition at line 227 of file mapview.h.

bool mapview::can_scroll_down (  )  [inline]

Returns whether it is possible to scroll to down.

A scrolling is impossible if the mapview is at the map limits.

Returns:
true if a down scrolling is possible, false otherwise.

Definition at line 239 of file mapview.h.

void mapview::scroll_right (  ) 

Scrolls 1 pixel to right, if possible.

Definition at line 107 of file mapview.cc.

void mapview::scroll_left (  ) 

Scrolls 1 pixel to left, if possible.

Definition at line 120 of file mapview.cc.

void mapview::scroll_down (  ) 

Scrolls 1 pixel to down, if possible.

Definition at line 133 of file mapview.cc.

void mapview::scroll_up (  ) 

Scrolls 1 pixel to up, if possible.

Definition at line 146 of file mapview.cc.

s_int8 mapview::get_state ( igzstream file  ) 

State saving/loading.

Restore the mapview's state from an opened file.

Parameters:
file the opened file from which to load the state.
Returns:
0 in case of success, error code otherwise.

Definition at line 168 of file mapview.cc.

s_int8 mapview::put_state ( ogzstream file  ) 

Saves the mapview's state into an opened file.

Parameters:
file the opened file where to the state.
Returns:
0 in case of success, error code otherwise.

Definition at line 201 of file mapview.cc.

void mapview::resize ( u_int16  l,
u_int16  h 
)

Resize the mapview.

The parameters are given in pixels.

Parameters:
l new length.
h new height.

Definition at line 159 of file mapview.cc.

void mapview::set_schedule ( string  file,
PyObject *  args = NULL 
)

Assign a schedule to the mapview.

The schedule's filename will be "scripts/schedules/mapviews/<file>.py".

Parameters:
file name of the schedule to use.
args Python tuple containing extra arguments passed to the class constructor.
Warning:
the args tuple argument MUST ONLY contain strings or integers, as it will be saved with the mapcharacter state by python::put_tuple ().

Definition at line 230 of file mapview.cc.

string mapview::schedule_file (  )  [inline]

Returns the name of the mapview's current schedule.

Returns:
name of the mapview's current schedule.

Definition at line 327 of file mapview.h.

bool mapview::update (  )  [virtual]

Updates the mapview's state and launchs his schedule.

Reimplemented from drawable.

Definition at line 263 of file mapview.cc.

void mapview::draw ( s_int16  x,
s_int16  y,
const drawing_area da_opt = NULL,
surface target = NULL 
) const [virtual]

Draw the object on the screen.

Parameters:
x X position where to draw.
y Y position where to draw.
da_opt optional drawing_area to use during the drawing operation.
target pointer to the surface where to draw the drawable. If NULL, draw on the screen.

Implements drawable.

Definition at line 270 of file mapview.cc.


The documentation for this class was generated from the following files:

Generated on Tue Aug 11 15:32:10 2009 for Adonthell by  doxygen 1.5.9