void EditorInputCenter::draw_path(DrawingContext& context) { if (!edited_path) return; if (!marked_object) return; if (!marked_object->is_valid()) return; if (!edited_path->is_valid()) return; for(auto i = edited_path->nodes.begin(); i != edited_path->nodes.end(); ++i) { auto j = i+1; Path::Node* node1 = &(*i); Path::Node* node2; if (j == edited_path->nodes.end()) { if (edited_path->mode == Path::CIRCULAR || edited_path->mode == Path::UNORDERED) { //loop to the first node node2 = &(*edited_path->nodes.begin()); } else { continue; } } else { node2 = &(*j); } auto cam_translation = Editor::current()->currentsector->camera->get_translation(); context.draw_line(node1->position - cam_translation, node2->position - cam_translation, Color(1, 0, 0), LAYER_GUI - 21); } }
void SmallMap::draw(DrawingContext& gc) { // FIXME: This is potentially dangerous, since we don't know how // long 'gc' will be alive. Should use a DrawingContext for caching. gc_ptr = &gc; World* const& world = server->get_world(); Vector2i of = playfield->get_pos(); Rect view_rect; if (world->get_width() > gc.get_width()) { int rwidth = int(gc.get_width() * rect.get_width() / world->get_width()); view_rect.left = rect.left + (of.x * rect.get_width() / world->get_width()) - rwidth/2; view_rect.right = view_rect.left + rwidth; } else { view_rect.left = rect.left; view_rect.right = rect.left + rect.get_width(); } if (world->get_height() > gc.get_height()) { int rheight = int(gc.get_height() * rect.get_height() / world->get_height()); view_rect.top = rect.top + (of.y * rect.get_height() / world->get_height()) - rheight/2; view_rect.bottom = view_rect.top + rheight; } else { view_rect.top = rect.top; view_rect.bottom = rect.top + rect.get_height(); } gc.draw(image->get_surface(), Vector2i(rect.left, rect.top)); gc.draw_rect(view_rect, Color(0, 255, 0)); server->get_world()->draw_smallmap(this); // Draw Pingus PinguHolder* pingus = world->get_pingus(); for(PinguIter i = pingus->begin(); i != pingus->end(); ++i) { int x = static_cast<int>(static_cast<float>(rect.left) + ((*i)->get_x() * static_cast<float>(rect.get_width()) / static_cast<float>(world->get_width()))); int y = static_cast<int>(static_cast<float>(rect.top) + ((*i)->get_y() * static_cast<float>(rect.get_height()) / static_cast<float>(world->get_height()))); gc.draw_line(Vector2i(x, y), Vector2i(x, y-2), Color(255, 255, 0)); } gc_ptr = 0; }
void Playfield::draw(DrawingContext& gc) { scene_context->clear(); scene_context->set_cliprect(rect); //scene_context->light().fill_screen(Color(50, 50, 50)); state.push(*scene_context); cap.set_pingu(current_pingu); cap.draw(*scene_context); world->draw(*scene_context); // Draw the scrolling band if (mouse_scrolling && !drag_drop_scrolling) { gc.draw_line(mouse_pos.x, mouse_pos.y, scroll_center.x, scroll_center.y-15, Color(0, 255, 0)); gc.draw_line(mouse_pos.x, mouse_pos.y, scroll_center.x, scroll_center.y, Color(255, 0, 0)); gc.draw_line(mouse_pos.x, mouse_pos.y, scroll_center.x, scroll_center.y+15, Color(0, 0, 255)); gc.draw_line(mouse_pos.x, mouse_pos.y, scroll_center.x + 15, scroll_center.y, Color(0, 255, 255)); gc.draw_line(mouse_pos.x, mouse_pos.y, scroll_center.x - 15, scroll_center.y, Color(255, 255, 0)); } state.pop(*scene_context); gc.draw(new SceneContextDrawingRequest(scene_context, Vector3f(0,0,-10000))); }
void EditorInputCenter::draw_tile_grid(DrawingContext& context) { auto editor = Editor::current(); if ( !editor->layerselect.selected_tilemap ) { return; } auto current_tm = dynamic_cast<TileMap*>(editor->layerselect.selected_tilemap); if ( current_tm == NULL ) return; int tm_width = current_tm->get_width(); int tm_height = current_tm->get_height(); Rectf draw_rect = Rectf(editor->currentsector->camera->get_translation(), editor->currentsector->camera->get_translation() + Vector(SCREEN_WIDTH, SCREEN_HEIGHT)); Vector start = sp_to_tp( Vector(draw_rect.p1.x, draw_rect.p1.y) ); Vector end = sp_to_tp( Vector(draw_rect.p2.x, draw_rect.p2.y) ); start.x = std::max(0.0f, start.x); start.y = std::max(0.0f, start.y); end.x = std::min(float(tm_width-1), end.x); end.y = std::min(float(tm_height-1), end.y); Vector line_start, line_end; for (int i = start.x; i <= end.x; i++) { line_start = tile_screen_pos( Vector(i, 0) ); line_end = tile_screen_pos( Vector(i, tm_height) ); context.draw_line(line_start, line_end, Color(1, 1, 1, 0.7), current_tm->get_layer()); } for (int i = start.y; i <= end.y; i++) { line_start = tile_screen_pos( Vector(0, i) ); line_end = tile_screen_pos( Vector(tm_width, i) ); context.draw_line(line_start, line_end, Color(1, 1, 1, 0.7), current_tm->get_layer()); } start = tile_screen_pos( Vector(0, 0) ); end = tile_screen_pos( Vector(tm_width, tm_height) ); context.draw_line(start, Vector(start.x, end.y), Color(1, 0, 1), current_tm->get_layer()); context.draw_line(start, Vector(end.x, start.y), Color(1, 0, 1), current_tm->get_layer()); context.draw_line(Vector(start.x, end.y), end, Color(1, 0, 1), current_tm->get_layer()); context.draw_line(Vector(end.x, start.y), end, Color(1, 0, 1), current_tm->get_layer()); }
void PathDrawable::draw (DrawingContext& gc) { Path::iterator prev = path.begin(); for(Path::iterator next = prev + 1; next != path.end(); ++next) { gc.draw_line(Vector2i(static_cast<int>(prev->x), static_cast<int>(prev->y)), Vector2i(static_cast<int>(next->x), static_cast<int>(next->y)), Color(255, 255, 255)); prev = next; } }
void Playfield::draw(DrawingContext& gc) { scene_context->clear(); state.push(*scene_context); capture_rectangle.set_pingu(current_pingu); capture_rectangle.draw(*scene_context); server->get_world()->draw(*scene_context); state.pop(*scene_context); gc.draw(new SceneContextDrawingRequest(scene_context.get(), Vector2i(0,0), -10000)); gc.push_modelview(); gc.translate(rect.left, rect.top); // Draw the scrolling band if (mouse_scrolling && !globals::drag_drop_scrolling) { gc.draw_line(mouse_pos, scroll_center - Vector2i(0, 15), Color(0, 255, 0)); gc.draw_line(mouse_pos, scroll_center + Vector2i(0, 15), Color(0, 0, 255)); gc.draw_line(mouse_pos, scroll_center + Vector2i(15, 0), Color(0, 255, 255)); gc.draw_line(mouse_pos, scroll_center - Vector2i(15, 0), Color(255, 255, 0)); gc.draw_line(mouse_pos, scroll_center, Color(255, 0, 0)); } gc.pop_modelview(); }