Adonthell  0.4
mapview Class Reference

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

#include <mapview.h>

Inheritance diagram for mapview:
Collaboration diagram for mapview:

Public Member Functions

 mapview ()
 Default constructor. More...
 
 ~mapview ()
 Destructor. More...
 
void attach_map (landmap *m)
 Attach/Detach a map. More...
 
void detach_map ()
 Stops displaying a map. More...
 
s_int8 set_pos (u_int16 sm, u_int16 x, u_int16 y, s_int16 ox=0, s_int16 oy=0)
 Position settings. More...
 
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. More...
 
u_int16 currentsubmap ()
 Position information. More...
 
u_int16 posx () const
 Returns the X position of the mapview. More...
 
u_int16 posy () const
 Returns the Y position of the mapview. More...
 
u_int16 offx () const
 Returns the X offset of the mapview. More...
 
u_int16 offy () const
 Returns the Y offset of the mapview. More...
 
bool can_scroll_right ()
 Basic movment. More...
 
bool can_scroll_left ()
 Returns whether it is possible to scroll to left. More...
 
bool can_scroll_up ()
 Returns whether it is possible to scroll to up. More...
 
bool can_scroll_down ()
 Returns whether it is possible to scroll to down. More...
 
void scroll_right ()
 Scrolls 1 pixel to right, if possible. More...
 
void scroll_left ()
 Scrolls 1 pixel to left, if possible. More...
 
void scroll_down ()
 Scrolls 1 pixel to down, if possible. More...
 
void scroll_up ()
 Scrolls 1 pixel to up, if possible. More...
 
s_int8 get_state (igzstream &file)
 State saving/loading. More...
 
s_int8 put_state (ogzstream &file)
 Saves the mapview's state into an opened file. More...
 
void resize (u_int16 l, u_int16 h)
 Resize the mapview. More...
 
void set_schedule (string file, PyObject *args=NULL)
 Assign a schedule to the mapview. More...
 
string schedule_file ()
 Returns the name of the mapview's current schedule. More...
 
bool update ()
 Updates the mapview's state and launchs his schedule. More...
 
void draw (s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const
 Draw the object on the screen. More...
 
- Public Member Functions inherited from drawable
 drawable ()
 Default constructor. More...
 
virtual ~drawable ()
 Destructor. More...
 
u_int16 length () const
 Returns the length of the drawable. More...
 
u_int16 height () const
 Returns the height of the drawable. More...
 
virtual bool input_update ()
 Virtual input update function, provided for objects which doesn't need one. More...
 

Additional Inherited Members

- Protected Member Functions inherited from drawable
void set_length (u_int16 l)
 Sets the length of the drawable. More...
 
void set_height (u_int16 h)
 Sets the height of the drawable. More...
 

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 48 of file mapview.h.

Constructor & Destructor Documentation

◆ mapview()

mapview::mapview ( )

Default constructor.

Definition at line 33 of file mapview.cc.

◆ ~mapview()

mapview::~mapview ( )

Destructor.

Definition at line 44 of file mapview.cc.

Member Function Documentation

◆ attach_map()

void mapview::attach_map ( landmap m)

Attach/Detach a map.

Sets which map this mapview will display.

Parameters
mpointer to the map that will be displayed by the mapview.

Definition at line 50 of file mapview.cc.

◆ detach_map()

void mapview::detach_map ( )

Stops displaying a map.

Definition at line 57 of file mapview.cc.

◆ set_pos()

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
smsubmap.
xX position.
yY position.
oxX offset.
oyY offset.
See also
center_on ()

Definition at line 64 of file mapview.cc.

◆ center_on()

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
smsubmap.
xX position.
yY position.
oxX offset.
oyY offset.

Definition at line 94 of file mapview.cc.

◆ currentsubmap()

u_int16 mapview::currentsubmap ( )
inline

Position information.

Returns the submap this mapview is displaying.

Returns
current submap this mapview is displaying.

Definition at line 141 of file mapview.h.

◆ posx()

u_int16 mapview::posx ( ) const
inline

Returns the X position of the mapview.

Returns
X position of the mapview.

Definition at line 152 of file mapview.h.

◆ posy()

u_int16 mapview::posy ( ) const
inline

Returns the Y position of the mapview.

Returns
Y position of the mapview.

Definition at line 163 of file mapview.h.

◆ offx()

u_int16 mapview::offx ( ) const
inline

Returns the X offset of the mapview.

Returns
X offset of the mapview.

Definition at line 174 of file mapview.h.

◆ offy()

u_int16 mapview::offy ( ) const
inline

Returns the Y offset of the mapview.

Returns
Y offset of the mapview.

Definition at line 185 of file mapview.h.

◆ can_scroll_right()

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 206 of file mapview.h.

◆ can_scroll_left()

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 219 of file mapview.h.

◆ can_scroll_up()

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 231 of file mapview.h.

◆ can_scroll_down()

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 243 of file mapview.h.

◆ scroll_right()

void mapview::scroll_right ( )

Scrolls 1 pixel to right, if possible.

Definition at line 111 of file mapview.cc.

◆ scroll_left()

void mapview::scroll_left ( )

Scrolls 1 pixel to left, if possible.

Definition at line 124 of file mapview.cc.

◆ scroll_down()

void mapview::scroll_down ( )

Scrolls 1 pixel to down, if possible.

Definition at line 137 of file mapview.cc.

◆ scroll_up()

void mapview::scroll_up ( )

Scrolls 1 pixel to up, if possible.

Definition at line 150 of file mapview.cc.

◆ get_state()

s_int8 mapview::get_state ( igzstream file)

State saving/loading.

Restore the mapview's state from an opened file.

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

Definition at line 172 of file mapview.cc.

◆ put_state()

s_int8 mapview::put_state ( ogzstream file)

Saves the mapview's state into an opened file.

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

Definition at line 205 of file mapview.cc.

◆ resize()

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

Resize the mapview.

The parameters are given in pixels.

Parameters
lnew length.
hnew height.

Definition at line 163 of file mapview.cc.

◆ set_schedule()

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
filename of the schedule to use.
argsPython 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 234 of file mapview.cc.

◆ schedule_file()

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 331 of file mapview.h.

◆ update()

bool mapview::update ( )
virtual

Updates the mapview's state and launchs his schedule.

Reimplemented from drawable.

Reimplemented in win_object< mapview >.

Definition at line 267 of file mapview.cc.

◆ draw()

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
xX position where to draw.
yY position where to draw.
da_optoptional drawing_area to use during the drawing operation.
targetpointer to the surface where to draw the drawable. If NULL, draw on the screen.

Implements drawable.

Definition at line 274 of file mapview.cc.


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