本文整理汇总了C++中CVideo::getSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ CVideo::getSurface方法的具体用法?C++ CVideo::getSurface怎么用?C++ CVideo::getSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVideo
的用法示例。
在下文中一共展示了CVideo::getSurface方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: the_end
void the_end(CVideo &video, std::string text, unsigned int duration)
{
//
// Some sane defaults.
//
if(text.empty())
text = _("The End");
if(!duration)
duration = 3500;
SDL_Rect area = screen_area();
sdl::fill_rect(video.getSurface(),&area,0);
update_whole_screen();
video.flip();
const size_t font_size = font::SIZE_XLARGE;
area = font::text_area(text,font_size);
area.x = screen_area().w/2 - area.w/2;
area.y = screen_area().h/2 - area.h/2;
for(size_t n = 0; n < 255; n += 5) {
if(n)
sdl::fill_rect(video.getSurface(),&area,0);
const SDL_Color col = create_color(n, n, n, n);
font::draw_text(&video,area,font_size,col,text,area.x,area.y);
update_rect(area);
events::pump();
events::raise_process_event();
events::raise_draw_event();
video.flip();
CVideo::delay(10);
}
//
// Delay after the end of fading.
// Rounded to multiples of 10.
//
unsigned int count = duration/10;
while(count) {
events::pump();
events::raise_process_event();
events::raise_draw_event();
video.flip();
CVideo::delay(10);
--count;
}
}
示例2: set_resolution
bool set_resolution(CVideo& video
, const unsigned width, const unsigned height)
{
SDL_Rect rect;
SDL_GetClipRect(video.getSurface(), &rect);
if(rect.w == width && rect.h == height) {
return true;
}
const int flags = fullscreen() ? FULL_SCREEN : 0;
int bpp = video.bppForMode(width, height, flags);
if(bpp != 0) {
video.setMode(width, height, bpp, flags);
if(disp) {
disp->redraw_everything();
}
} else {
// grzywacz: is this even true?
gui2::show_transient_message(video,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."));
return false;
}
const std::string postfix = fullscreen() ? "resolution" : "windowsize";
preferences::set('x' + postfix, lexical_cast<std::string>(width));
preferences::set('y' + postfix, lexical_cast<std::string>(height));
return true;
}
示例3: draw_cursor
void textbox::draw_cursor(int pos, CVideo &video) const
{
if(show_cursor_ && editable_) {
SDL_Rect rect = {location().x + pos, location().y, 1, location().h };
surface const frame_buffer = video.getSurface();
SDL_FillRect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
}
}
示例4: draw_cursor
void textbox::draw_cursor(int pos, CVideo &video) const
{
if(show_cursor_ && editable_ && enabled()) {
SDL_Rect rect = create_rect(location().x + pos
, location().y
, 1
, location().h);
surface frame_buffer = video.getSurface();
sdl_fill_rect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
}
}
示例5: show_about
/**
* Show credits with list of contributors.
*
* Names of people are shown scrolling up like in movie-credits.\n
* Uses map from wesnoth or campaign as background.
*/
void show_about(CVideo &video, const std::string &campaign)
{
boost::scoped_ptr<cursor::setter> cur(new cursor::setter(cursor::WAIT));
surface& screen = video.getSurface();
if (screen == nullptr) return;
// If the title is multi-line, we need to split it accordingly or we
// get slight scrolling glitches in the credits screen.
std::vector<std::string> text = about::get_text(campaign, true);
SDL_Rect screen_rect = sdl::create_rect(0, 0, screen->w, screen->h);
const surface_restorer restorer(&video, screen_rect);
cur.reset();
std::vector<std::string> image_list;
if(campaign.size() && !images[campaign].empty()){
image_list = utils::parenthetical_split(images[campaign], ',');
} else{
image_list = utils::parenthetical_split(images_default, ',');
}
surface map_image, map_image_scaled;
if(!image_list.empty()) {
map_image = image::get_image(image_list[0]);
} else {
image_list.push_back("");
}
if(!map_image){
image_list[0]=game_config::images::game_title_background;
map_image=image::get_image(image_list[0]);
}
gui::button close(video,_("Close"));
close.set_location((screen->w/2)-(close.width()/2), screen->h - 30);
const int def_size = font::SIZE_XLARGE;
const SDL_Color def_color = font::NORMAL_COLOR;
//substitute in the correct control characters for '+' and '-'
std::string before_header(2, ' ');
before_header[0] = font::LARGE_TEXT;
for(unsigned i = 0; i < text.size(); ++i) {
std::string &s = text[i];
if (s.empty()) continue;
char &first = s[0];
if (first == '-')
first = font::SMALL_TEXT;
else if (first == '+') {
first = font::LARGE_TEXT;
text.insert(text.begin() + i, before_header);
++i;
}
}
text.insert(text.begin(), 10, before_header);
int startline = 0;
//TODO: use values proportional to screen ?
// distance from top of map image to top of scrolling text
const int top_margin = 60;
// distance from bottom of scrolling text to bottom of map image
const int bottom_margin = 40;
// distance from left of scrolling text to the frame border
const int text_left_padding = screen->w/32;
int offset = 0;
bool is_new_line = true;
int first_line_height = 0;
SDL_Rect frame_area;
// we use a dialog to contains the text. Strange idea but at least the style
// will be consistent with the titlescreen
gui::dialog_frame f(video, "", gui::dialog_frame::titlescreen_style, false);
// the text area's dimensions
SDL_Rect text_rect = { 0, 0, 0, 0 };
// we'll retain a copy to prevent SDL_blit to change its w and h
SDL_Rect text_rect_blit;
surface text_surf;
CKey key;
bool last_escape;
int image_count = 0;
int scroll_speed = 4; // scroll_speed*50 = speed of scroll in pixel per second
// Initially redraw all
//.........这里部分代码省略.........