37 d_length = d_height = currentsubmap_ = posx_ = posy_ = 0;
47 Py_XDECREF (schedule_args);
100 if (tpy < 0) tpy = 0;
108 return set_pos (sm, npx, npy, nox, noy);
195 PyObject * args = NULL;
214 currentsubmap_ >> file;
239 Py_XDECREF (schedule_args);
240 schedule_args = NULL;
245 schedule_args = args;
247 u_int16 argssize = args == NULL ? 1 : PyTuple_Size (args) + 1;
250 theargs = PyTuple_New (argssize);
255 for (
u_int16 i = 1; i < argssize; i++)
257 PyObject * intref = PyTuple_GetItem (args, i - 1);
259 PyTuple_SetItem (theargs, i, intref);
261 schedule.
create_instance (
"schedules.mapviews." + file, file, theargs);
264 schedule_file_ = file;
279 static list <mapsquare_tile>::iterator it;
280 static list <mapsquare_char>::iterator itc;
281 static list <mapcharacter *>::iterator itb;
285 static list <mapsquare_tile> critical_draw;
286 static list <mapsquare_char> characters_draw;
287 static list <mapcharacter *> bubbles_draw;
292 static SDL_Rect trect;
301 l = m_map->submap[currentsubmap_];
307 ie = i0 + d_length + (offx_ != 0) < l->
area_length () ? i0 + d_length + (offx_ !=
309 je = j0 + d_height + (offy_ != 0) < l->
area_height () ? j0 + d_height + (offy_ !=
323 for (it = l->area[i0][j0].tiles.begin ();
324 it != l->area[i0][j0].tiles.end () && *(it->base_tile) < *it; it++)
325 if (it->x > it->base_tile->x && it->y > it->base_tile->y)
326 critical_draw.push_back (*(it->base_tile));
328 for (itc = l->area[i0][j0].mapchars.begin ();
329 itc != l->area[i0][j0].mapchars.end (); itc++)
330 if (itc->x > itc->base_tile->x && itc->y > itc->base_tile->y)
331 characters_draw.push_back (*itc);
336 for (it = l->area[i][j0].tiles.begin ();
337 it != l->area[i][j0].tiles.end (); it++)
338 if (it->x == it->base_tile->x && it->y > it->base_tile->y)
339 critical_draw.push_back (*(it->base_tile));
341 for (itc = l->area[i][j0].mapchars.begin ();
342 itc != l->area[i][j0].mapchars.end (); itc++)
343 if (itc->x == itc->base_tile->x && itc->y > itc->base_tile->y)
344 characters_draw.push_back (*itc);
348 for (it = l->area[ie - 1][j0].tiles.begin ();
349 it != l->area[ie - 1][j0].tiles.end (); it++)
350 if (it->x < it->base_tile->x && it->y > it->base_tile->y)
351 critical_draw.push_back (*(it->base_tile));
353 for (itc = l->area[ie - 1][j0].mapchars.begin ();
354 itc != l->area[ie - 1][j0].mapchars.end (); itc++)
355 if (itc->x < itc->base_tile->x && itc->y > itc->base_tile->y)
356 characters_draw.push_back (*itc);
359 critical_draw.sort ();
360 characters_draw.sort ();
362 it = critical_draw.begin ();
363 itc = characters_draw.begin ();
364 while (itc != characters_draw.end () || it != critical_draw.end ())
366 if (itc != characters_draw.end ())
368 if (it != critical_draw.end ())
370 if (it->base_tile->y <= itc->base_tile->y)
372 draw_tile (x, y, &tda, target, it);
377 draw_mapchar (x, y, &tda, target, itc);
378 if (itc->mchar->is_speaking ())
379 bubbles_draw.push_back (itc->mchar);
385 draw_mapchar (x, y, &tda, target, itc);
386 if (itc->mchar->is_speaking ())
387 bubbles_draw.push_back (itc->mchar);
393 draw_tile (x, y, &tda, target, it);
397 critical_draw.clear ();
398 characters_draw.clear ();
401 for (j = j0; j < je; j++)
404 for (it = l->area[i0][j].tiles.begin ();
405 it != l->area[i0][j].tiles.end () && *(it->base_tile) <= *it;
407 if (it->y == it->base_tile->y && it->x > it->base_tile->x)
408 draw_tile (x, y, &tda, target, it);
410 for (itc = l->area[i0][j].mapchars.begin ();
411 itc != l->area[i0][j].mapchars.end (); itc++)
412 if (itc->y == itc->base_tile->y && itc->x > itc->base_tile->x)
413 characters_draw.push_back (*itc);
416 for (i = i0; i < ie; i++)
418 for (it = l->area[i][j].base_begin;
419 it != l->area[i][j].tiles.end () && *(it->base_tile) < *it;
421 for (; it != l->area[i][j].tiles.end () && *(it->base_tile) == *it;
423 draw_tile (x, y, &tda, target, it);
425 for (itc = l->area[i][j].mapchars.begin ();
426 itc != l->area[i][j].mapchars.end (); itc++)
427 if (*itc == *(itc->base_tile) &&
428 itc->x == itc->mchar->posx () &&
429 itc->y == itc->mchar->posy ())
430 characters_draw.push_back (*itc);
434 for (it = l->area[ie - 1][j].tiles.begin ();
435 it != l->area[ie - 1][j].tiles.end (); it++)
436 if (it->y == it->base_tile->y && it->x < it->base_tile->x)
437 draw_tile (x, y, &tda, target, it);
439 for (itc = l->area[ie - 1][j].mapchars.begin ();
440 itc != l->area[ie - 1][j].mapchars.end (); itc++)
441 if (itc->y == itc->base_tile->y && itc->x < itc->base_tile->x)
442 characters_draw.push_back (*itc);
445 for (itc = characters_draw.begin (); itc != characters_draw.end ();
448 draw_mapchar (x, y, &tda, target, itc);
449 if (itc->mchar->is_speaking ())
450 bubbles_draw.push_back (itc->mchar);
452 characters_draw.clear ();
457 if (!l->area[i0][je - 1].tiles.empty ())
458 for (it = --l->area[i0][je - 1].tiles.end ();
459 it->y < it->base_tile->y; it--)
461 if (it->x > it->base_tile->x && it->y < it->base_tile->y)
462 critical_draw.push_front (*(it->base_tile));
463 if (it == l->area[i0][je - 1].tiles.begin ())
467 for (itc = l->area[i0][je - 1].mapchars.begin ();
468 itc != l->area[i0][je - 1].mapchars.end (); itc++)
469 if (itc->x > itc->base_tile->x && itc->y < itc->base_tile->y)
470 characters_draw.push_back (*itc);
475 if (!l->area[i][je - 1].tiles.empty ())
476 for (it = --l->area[i][je - 1].tiles.end ();
477 it->y < it->base_tile->y; it--)
479 if (it->x == it->base_tile->x && it->y < it->base_tile->y)
480 critical_draw.push_front (*(it->base_tile));
481 if (it == l->area[i][je - 1].tiles.begin ())
485 for (itc = l->area[i][je - 1].mapchars.begin ();
486 itc != l->area[i][je - 1].mapchars.end (); itc++)
488 if (itc->x == itc->base_tile->x && itc->y < itc->base_tile->y)
490 characters_draw.push_back (*itc);
496 if (!l->area[ie - 1][je - 1].tiles.empty ())
497 for (it = --l->area[ie - 1][je - 1].tiles.end ();
498 it->y < it->base_tile->y; it--)
500 if (it->x < it->base_tile->x && it->y < it->base_tile->y)
501 critical_draw.push_front (*(it->base_tile));
502 if (it == l->area[ie - 1][je - 1].tiles.begin ())
506 for (itc = l->area[ie - 1][je - 1].mapchars.begin ();
507 itc != l->area[ie - 1][je - 1].mapchars.end (); itc++)
508 if (itc->x < itc->base_tile->x && itc->y < itc->base_tile->y)
509 characters_draw.push_back (*itc);
513 critical_draw.sort ();
514 characters_draw.sort ();
516 it = critical_draw.begin ();
517 itc = characters_draw.begin ();
518 while (itc != characters_draw.end () || it != critical_draw.end ())
520 if (itc != characters_draw.end ())
522 if (it != critical_draw.end ())
524 if (it->base_tile->y <= itc->base_tile->y)
526 draw_tile (x, y, &tda, target, it);
531 draw_mapchar (x, y, &tda, target, itc);
532 if (itc->mchar->is_speaking ())
533 bubbles_draw.push_back (itc->mchar);
539 draw_mapchar (x, y, &tda, target, itc);
540 if (itc->mchar->is_speaking ())
541 bubbles_draw.push_back (itc->mchar);
547 draw_tile (x, y, &tda, target, it);
552 for (itb = bubbles_draw.begin (); itb != bubbles_draw.end (); itb++)
553 draw_bubble (x, y, &tda, target, itb);
555 critical_draw.clear ();
556 characters_draw.clear ();
557 bubbles_draw.clear ();
568 surface * target, list<mapsquare_tile>::iterator it)
const 570 it->mapobj->draw_from_base
577 surface * target, list<mapsquare_char>::iterator itc)
const 580 ((itc->mchar->posx () - posx_ - itc->mchar->base_x ()) *
MAPSQUARE_SIZE)
581 + itc->mchar->offx () - offx_ + x;
584 ((itc->mchar->posy () - posy_ - itc->mchar->base_y ()) *
MAPSQUARE_SIZE)
585 + itc->mchar->offy () - offy_ + y;
587 itc->mchar->draw (xdraw, ydraw, da_opt, target);
591 surface * target, list<mapcharacter *>::iterator itc)
const 595 + (*itc)->offx () - offx_ + x;
599 + (*itc)->offy () - offy_ + y;
601 (*itc)->draw_bubble (xdraw, ydraw, da_opt, target);
Class to write data from a Gzip compressed file.
void set_length(u_int16 l)
Sets the length of the drawable.
#define s_int32
32 bits long signed integer
u_int16 length() const
Returns the length of the drawable.
Class to read data from a Gzip compressed file.
void clear()
Resets the script to it's post-constructor state.
s_int8 get_state(igzstream &file)
State saving/loading.
bool can_scroll_down()
Returns whether it is possible to scroll to down.
bool can_scroll_up()
Returns whether it is possible to scroll to up.
bool update()
Updates the mapview's state and launchs his schedule.
#define u_int16
16 bits long unsigned integer
void detach_drawing_area()
Detach (if needed) the drawing_area which was attached to this one.
void set_height(u_int16 h)
Sets the height of the drawable.
u_int16 area_height() const
Returns the height of the area.
Class where drawables can actually be drawn to.
void resize(u_int16 nl, u_int16 nh)
Resize the drawing_area.
static void put_tuple(PyObject *tuple, ogzstream &file)
Save a Python tuple into a file.
string schedule_file()
Returns the name of the mapview's current schedule.
void detach_map()
Stops displaying a map.
void assign_drawing_area(const drawing_area *da)
Assign a drawing_area to this drawing_area.
void scroll_left()
Scrolls 1 pixel to left, if possible.
u_int16 area_length() const
Returns the length of the area.
void scroll_down()
Scrolls 1 pixel to down, if possible.
void scroll_up()
Scrolls 1 pixel to up, if possible.
bool can_scroll_right()
Basic movment.
bool create_instance(string file, string classname, PyObject *args=NULL)
Creates an instance of a Python class.
SDL_Rect setup_rects() const
Gets the real parameters of this drawing_area.
static PyObject * get_tuple(igzstream &file)
Loads a Python tuple previously saved with put_tuple ().
void run(PyObject *args=NULL)
Calls the run () method of this object.
Declares the mapview class.
Implements "drawing zones" for drawing operations.
void scroll_right()
Scrolls 1 pixel to right, if possible.
u_int16 offy() const
Returns the Y offset of the mapview.
static PyObject * pass_instance(void *instance, const char *class_name)
Magic function that makes any C object available to Python!
u_int16 height() const
Returns the height of the drawable.
#define s_int16
16 bits long signed integer
Map where the world takes place.
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 set_schedule(string file, PyObject *args=NULL)
Assign a schedule to the mapview.
const u_int16 MAPSQUARE_SIZE
Size of a mapsquare (in pixels).
bool can_scroll_left()
Returns whether it is possible to scroll to left.
void resize(u_int16 l, u_int16 h)
Resize the mapview.
s_int8 set_pos(u_int16 sm, u_int16 x, u_int16 y, s_int16 ox=0, s_int16 oy=0)
Position settings.
void move(s_int16 nx, s_int16 ny)
Move the drawing_area.
void attach_map(landmap *m)
Attach/Detach a map.
mapview()
Default constructor.
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.
#define s_int8
8 bits long signed integer
s_int8 put_state(ogzstream &file)
Saves the mapview's state into an opened file.
u_int16 offx() const
Returns the X offset of the mapview.
Area of mapsquares, for use with landmap.