33 d_length = d_height = currentsubmap_ = posx_ = posy_ = 0;
43 Py_XDECREF (schedule_args);
104 return set_pos (sm, npx, npy, nox, noy);
191 PyObject * args = NULL;
210 currentsubmap_ >> file;
235 Py_XDECREF (schedule_args);
236 schedule_args = NULL;
241 schedule_args = args;
243 u_int16 argssize = args == NULL ? 1 : PyTuple_Size (args) + 1;
246 theargs = PyTuple_New (argssize);
251 for (
u_int16 i = 1; i < argssize; i++)
253 PyObject * intref = PyTuple_GetItem (args, i - 1);
255 PyTuple_SetItem (theargs, i, intref);
257 schedule.
create_instance (
"schedules.mapviews." + file, file, theargs);
260 schedule_file_ = file;
275 static list <mapsquare_tile>::iterator it;
276 static list <mapsquare_char>::iterator itc;
277 static list <mapcharacter *>::iterator itb;
281 static list <mapsquare_tile> critical_draw;
282 static list <mapsquare_char> characters_draw;
283 static list <mapcharacter *> bubbles_draw;
288 static SDL_Rect trect;
297 l = m_map->submap[currentsubmap_];
303 ie = i0 + d_length + (offx_ != 0) < l->
area_length () ? i0 + d_length + (offx_ !=
305 je = j0 + d_height + (offy_ != 0) < l->
area_height () ? j0 + d_height + (offy_ !=
319 for (it = l->area[i0][j0].tiles.begin ();
320 it != l->area[i0][j0].tiles.end () && *(it->base_tile) < *it; it++)
321 if (it->x > it->base_tile->x && it->y > it->base_tile->y)
322 critical_draw.push_back (*(it->base_tile));
324 for (itc = l->area[i0][j0].mapchars.begin ();
325 itc != l->area[i0][j0].mapchars.end (); itc++)
326 if (itc->x > itc->base_tile->x && itc->y > itc->base_tile->y)
327 characters_draw.push_back (*itc);
332 for (it = l->area[i][j0].tiles.begin ();
333 it != l->area[i][j0].tiles.end (); it++)
334 if (it->x == it->base_tile->x && it->y > it->base_tile->y)
335 critical_draw.push_back (*(it->base_tile));
337 for (itc = l->area[i][j0].mapchars.begin ();
338 itc != l->area[i][j0].mapchars.end (); itc++)
339 if (itc->x == itc->base_tile->x && itc->y > itc->base_tile->y)
340 characters_draw.push_back (*itc);
344 for (it = l->area[ie - 1][j0].tiles.begin ();
345 it != l->area[ie - 1][j0].tiles.end (); it++)
346 if (it->x < it->base_tile->x && it->y > it->base_tile->y)
347 critical_draw.push_back (*(it->base_tile));
349 for (itc = l->area[ie - 1][j0].mapchars.begin ();
350 itc != l->area[ie - 1][j0].mapchars.end (); itc++)
351 if (itc->x < itc->base_tile->x && itc->y > itc->base_tile->y)
352 characters_draw.push_back (*itc);
355 critical_draw.sort ();
356 characters_draw.sort ();
358 it = critical_draw.begin ();
359 itc = characters_draw.begin ();
360 while (itc != characters_draw.end () || it != critical_draw.end ())
362 if (itc != characters_draw.end ())
364 if (it != critical_draw.end ())
366 if (it->base_tile->y <= itc->base_tile->y)
368 draw_tile (x, y, &tda, target, it);
373 draw_mapchar (x, y, &tda, target, itc);
374 if (itc->mchar->is_speaking ())
375 bubbles_draw.push_back (itc->mchar);
381 draw_mapchar (x, y, &tda, target, itc);
382 if (itc->mchar->is_speaking ())
383 bubbles_draw.push_back (itc->mchar);
389 draw_tile (x, y, &tda, target, it);
393 critical_draw.clear ();
394 characters_draw.clear ();
397 for (j = j0; j < je; j++)
400 for (it = l->area[i0][j].tiles.begin ();
401 it != l->area[i0][j].tiles.end () && *(it->base_tile) <= *it;
403 if (it->y == it->base_tile->y && it->x > it->base_tile->x)
404 draw_tile (x, y, &tda, target, it);
406 for (itc = l->area[i0][j].mapchars.begin ();
407 itc != l->area[i0][j].mapchars.end (); itc++)
408 if (itc->y == itc->base_tile->y && itc->x > itc->base_tile->x)
409 characters_draw.push_back (*itc);
412 for (i = i0; i < ie; i++)
414 for (it = l->area[i][j].base_begin;
415 it != l->area[i][j].tiles.end () && *(it->base_tile) < *it;
417 for (; it != l->area[i][j].tiles.end () && *(it->base_tile) == *it;
419 draw_tile (x, y, &tda, target, it);
421 for (itc = l->area[i][j].mapchars.begin ();
422 itc != l->area[i][j].mapchars.end (); itc++)
423 if (*itc == *(itc->base_tile) &&
424 itc->x == itc->mchar->posx () &&
425 itc->y == itc->mchar->posy ())
426 characters_draw.push_back (*itc);
430 for (it = l->area[ie - 1][j].tiles.begin ();
431 it != l->area[ie - 1][j].tiles.end (); it++)
432 if (it->y == it->base_tile->y && it->x < it->base_tile->x)
433 draw_tile (x, y, &tda, target, it);
435 for (itc = l->area[ie - 1][j].mapchars.begin ();
436 itc != l->area[ie - 1][j].mapchars.end (); itc++)
437 if (itc->y == itc->base_tile->y && itc->x < itc->base_tile->x)
438 characters_draw.push_back (*itc);
441 for (itc = characters_draw.begin (); itc != characters_draw.end ();
444 draw_mapchar (x, y, &tda, target, itc);
445 if (itc->mchar->is_speaking ())
446 bubbles_draw.push_back (itc->mchar);
448 characters_draw.clear ();
453 if (!l->area[i0][je - 1].tiles.empty ())
454 for (it = --l->area[i0][je - 1].tiles.end ();
455 it->y < it->base_tile->y; it--)
457 if (it->x > it->base_tile->x && it->y < it->base_tile->y)
458 critical_draw.push_front (*(it->base_tile));
459 if (it == l->area[i0][je - 1].tiles.begin ())
463 for (itc = l->area[i0][je - 1].mapchars.begin ();
464 itc != l->area[i0][je - 1].mapchars.end (); itc++)
465 if (itc->x > itc->base_tile->x && itc->y < itc->base_tile->y)
466 characters_draw.push_back (*itc);
471 if (!l->area[i][je - 1].tiles.empty ())
472 for (it = --l->area[i][je - 1].tiles.end ();
473 it->y < it->base_tile->y; it--)
475 if (it->x == it->base_tile->x && it->y < it->base_tile->y)
476 critical_draw.push_front (*(it->base_tile));
477 if (it == l->area[i][je - 1].tiles.begin ())
481 for (itc = l->area[i][je - 1].mapchars.begin ();
482 itc != l->area[i][je - 1].mapchars.end (); itc++)
484 if (itc->x == itc->base_tile->x && itc->y < itc->base_tile->y)
486 characters_draw.push_back (*itc);
492 if (!l->area[ie - 1][je - 1].tiles.empty ())
493 for (it = --l->area[ie - 1][je - 1].tiles.end ();
494 it->y < it->base_tile->y; it--)
496 if (it->x < it->base_tile->x && it->y < it->base_tile->y)
497 critical_draw.push_front (*(it->base_tile));
498 if (it == l->area[ie - 1][je - 1].tiles.begin ())
502 for (itc = l->area[ie - 1][je - 1].mapchars.begin ();
503 itc != l->area[ie - 1][je - 1].mapchars.end (); itc++)
504 if (itc->x < itc->base_tile->x && itc->y < itc->base_tile->y)
505 characters_draw.push_back (*itc);
509 critical_draw.sort ();
510 characters_draw.sort ();
512 it = critical_draw.begin ();
513 itc = characters_draw.begin ();
514 while (itc != characters_draw.end () || it != critical_draw.end ())
516 if (itc != characters_draw.end ())
518 if (it != critical_draw.end ())
520 if (it->base_tile->y <= itc->base_tile->y)
522 draw_tile (x, y, &tda, target, it);
527 draw_mapchar (x, y, &tda, target, itc);
528 if (itc->mchar->is_speaking ())
529 bubbles_draw.push_back (itc->mchar);
535 draw_mapchar (x, y, &tda, target, itc);
536 if (itc->mchar->is_speaking ())
537 bubbles_draw.push_back (itc->mchar);
543 draw_tile (x, y, &tda, target, it);
548 for (itb = bubbles_draw.begin (); itb != bubbles_draw.end (); itb++)
549 draw_bubble (x, y, &tda, target, itb);
551 critical_draw.clear ();
552 characters_draw.clear ();
553 bubbles_draw.clear ();
564 surface * target, list<mapsquare_tile>::iterator it)
const
566 it->mapobj->draw_from_base
573 surface * target, list<mapsquare_char>::iterator itc)
const
576 ((itc->mchar->posx () - posx_ - itc->mchar->base_x ()) *
MAPSQUARE_SIZE)
577 + itc->mchar->offx () - offx_ + x;
580 ((itc->mchar->posy () - posy_ - itc->mchar->base_y ()) *
MAPSQUARE_SIZE)
581 + itc->mchar->offy () - offy_ + y;
583 itc->mchar->draw (xdraw, ydraw, da_opt, target);
587 surface * target, list<mapcharacter *>::iterator itc)
const
591 + (*itc)->offx () - offx_ + x;
595 + (*itc)->offy () - offy_ + y;
597 (*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.