本文整理汇总了C++中window::get_canvas方法的典型用法代码示例。如果您正苦于以下问题:C++ window::get_canvas方法的具体用法?C++ window::get_canvas怎么用?C++ window::get_canvas使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类window
的用法示例。
在下文中一共展示了window::get_canvas方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_callback
void outro::draw_callback(window& window)
{
if(SDL_GetTicks() < next_draw_) {
return;
}
/* If we've faded fully in...
*
* NOTE: we want fading to take around half a second. Given this function runs about every 3 frames, we
* limit ourselves to a reasonable 10 fade steps with an alpha difference (rounded up) of 25.5 each cycle.
* The actual calculation for alpha is done in the window definition in WFL.
*/
if(fading_in_ && fade_step_ > 10) {
// Schedule the fadeout after the provided delay.
if(timer_id_ == 0) {
timer_id_ = add_timer(duration_, [this](size_t) { fading_in_ = false; });
}
return;
}
// If we've faded fully out...
if(!fading_in_ && fade_step_ < 0) {
window.close();
return;
}
canvas& window_canvas = window.get_canvas(0);
window_canvas.set_variable("fade_step", wfl::variant(fade_step_));
window_canvas.set_is_dirty(true);
window.set_is_dirty(true);
if(fading_in_) {
fade_step_ ++;
} else {
fade_step_ --;
}
set_next_draw();
}
示例2: pre_show
void title_screen::pre_show(window& win)
{
win.set_click_dismiss(false);
win.set_enter_disabled(true);
win.set_escape_disabled(true);
// Each time the dialog shows, we set this to false
redraw_background_ = false;
#ifdef DEBUG_TOOLTIP
win.connect_signal<event::SDL_MOUSE_MOTION>(
std::bind(debug_tooltip, std::ref(win), _3, _5),
event::dispatcher::front_child);
#endif
win.connect_signal<event::SDL_VIDEO_RESIZE>(std::bind(&title_screen::on_resize, this, std::ref(win)));
//
// General hotkeys
//
win.register_hotkey(hotkey::TITLE_SCREEN__RELOAD_WML, [](event::dispatcher& w, hotkey::HOTKEY_COMMAND) {
dynamic_cast<window&>(w).set_retval(RELOAD_GAME_DATA);
return true;
});
win.register_hotkey(hotkey::HOTKEY_FULLSCREEN, std::bind(fullscreen, std::ref(win.video())));
win.register_hotkey(hotkey::LUA_CONSOLE, std::bind(&launch_lua_console, std::ref(win)));
//
// Background and logo images
//
if(game_config::images::game_title.empty()) {
ERR_CF << "No title image defined" << std::endl;
}
win.get_canvas()[0].set_variable("title_image", variant(game_config::images::game_title));
if(game_config::images::game_title_background.empty()) {
ERR_CF << "No title background image defined" << std::endl;
}
win.get_canvas()[0].set_variable("background_image", variant(game_config::images::game_title_background));
find_widget<image>(&win, "logo-bg", false).set_image(game_config::images::game_logo_background);
find_widget<image>(&win, "logo", false).set_image(game_config::images::game_logo);
//
// Version string
//
const std::string version_string = formatter() << ("Version") << " " << game_config::revision;
if(label* version_label = find_widget<label>(&win, "revision_number", false, false)) {
version_label->set_label(version_string);
}
win.get_canvas()[0].set_variable("revision_number", variant(version_string));
//
// Tip-of-the-day browser
//
multi_page& tip_pages = find_widget<multi_page>(&win, "tips", false);
std::vector<game_tip> tips(settings::get_tips());
if(tips.empty()) {
WRN_CF << "There are no tips of day available." << std::endl;
}
for(const auto& tip : tips) {
string_map widget;
std::map<std::string, string_map> page;
widget["use_markup"] = "true";
widget["label"] = tip.text();
page.emplace("tip", widget);
widget["label"] = tip.source();
page.emplace("source", widget);
tip_pages.add_page(page);
}
update_tip(win, true);
register_button(win, "next_tip", hotkey::TITLE_SCREEN__NEXT_TIP,
std::bind(&title_screen::update_tip, this, std::ref(win), true));
register_button(win, "previous_tip", hotkey::TITLE_SCREEN__PREVIOUS_TIP,
std::bind(&title_screen::update_tip, this, std::ref(win), false));
//
// Help
//
register_button(win, "help", hotkey::HOTKEY_HELP, [this](window&) {
help::help_manager help_manager(&game_config_manager::get()->game_config());
help::show_help(game_.video());
});
//
// About
//
//.........这里部分代码省略.........