void SliderBox::draw(DrawingContext& gc) { if (globals::developer_mode) gc.draw_rect(rect, Color(0, 255, 255)); if (value == 0) { gc.print_center(Fonts::chalk_normal, Vector2i(rect.left + rect.get_width()/2, rect.top), "off"); } else { for(int i = 0; i < m_steps; ++i) { if (i < value) gc.print_left(Fonts::chalk_normal, Vector2i(rect.left + i*(rect.get_width()-12)/m_steps + 6, rect.top), "|"); //gc.print_left(Fonts::chalk_normal, rect.left + i*(rect.get_width()-12)/20 + 6, rect.top, "l"); } } gc.print_left(Fonts::chalk_normal, Vector2i(rect.left, rect.top), "["); gc.print_right(Fonts::chalk_normal, Vector2i(rect.right, rect.top), "]"); }
void PingusMenu::draw_background(DrawingContext& gc) { background->draw(gc); gc.draw(logo, Vector2i((gc.get_width()/2) - (logo.get_width()/2), gc.get_height()/2 - 280)); gc.print_left(Fonts::pingus_small, Vector2i(gc.get_width()/2 - 400 + 25, gc.get_height()-140), "Pingus " VERSION " - Copyright (C) 1998-2011 Ingo Ruhnke <*****@*****.**>\n" "See the file AUTHORS for a complete list of contributors.\n" "Pingus comes with ABSOLUTELY NO WARRANTY. This is free software, and you are\n" "welcome to redistribute it under certain conditions; see the file COPYING for details.\n"); gc.draw_fillrect(Rect(0, Display::get_height () - 26, Display::get_width (), Display::get_height ()), Color(0, 0, 0, 255)); gc.print_center(Fonts::pingus_small, Vector2i(gc.get_width() / 2, gc.get_height() - Fonts::pingus_small.get_height() - 8), help); if (0) // display hint { gc.print_center(Fonts::pingus_small, Vector2i(gc.get_width() / 2, gc.get_height() - Fonts::pingus_small.get_height()), hint); } }
void StartScreenComponent::draw(DrawingContext& gc) { // Paint the background wood panel for(int y = 0; y < gc.get_height(); y += background.get_height()) for(int x = 0; x < gc.get_width(); x += background.get_width()) gc.draw(background, Vector2i(x, y)); gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2)); int left_x = gc.get_width()/2 - 150; int right_x = gc.get_width()/2 + 150; int y = gc.get_height()/2 + 40; gc.print_center(Fonts::chalk_large, Vector2i(gc.get_width() /2, gc.get_height()/2 - 230), _(plf.get_levelname())); gc.print_left(Fonts::chalk_normal, Vector2i(gc.get_width() /2 - 300, gc.get_height()/2 - 170), format_description(800 - 200)); y += 32; y += 45; gc.print_left (Fonts::chalk_normal, Vector2i(left_x, y), _("Number of Pingus: ")); gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), StringUtil::to_string(plf.get_number_of_pingus())); gc.print_left (Fonts::chalk_normal, Vector2i(left_x, (y += 30)), _("Number to Save: ")); gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), StringUtil::to_string(plf.get_number_to_save())); gc.print_left (Fonts::chalk_normal, Vector2i(left_x, (y += 30)), _("Time: ")); gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), time_str); gc.print_center(Fonts::chalk_small, Vector2i(gc.get_width()/2, gc.get_height()/2 + 215), _("Author: ") + plf.get_author()); if (globals::developer_mode) { gc.print_center(Fonts::chalk_small, Vector2i(gc.get_width()/2, gc.get_height()-50), plf.get_resname()); } }
void AddOnMenu::draw_background(DrawingContext& gc) { // gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0)); gc.draw(background, Vector2i(gc.get_width()/2, gc.get_height()/2)); gc.print_center(Fonts::chalk_large, Vector2i(gc.get_width()/2, 90), "Add-On Menu"); gc.print_left(Fonts::chalk_normal, Vector2i(120, 145), "X-Mas Pingus Sprites"); gc.print_left(Fonts::chalk_small, Vector2i(140, 170), "christmas look for penguins"); gc.print_left(Fonts::chalk_small, Vector2i(140, 190), "Author: John Foo <*****@*****.**>"); gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2, gc.get_height()/2 + 160), "Update Online [ ]"); gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2 + 245 + 30, gc.get_height()/2 + 150 - 20), _("Close")); gc.draw(ok_button, Vector2i(gc.get_width()/2 + 245, gc.get_height()/2 + 150)); gc.draw(ok_button, Vector2i(610, 145)); }
void Inputbox::draw(DrawingContext& gc) { gc.draw_fillrect(rect, Color(255,255,255)); gc.draw_rect(rect, has_focus() ? Color(255,128,0) : Color(0,0,0)); gc.print_left(Fonts::verdana11, Vector2i(rect.left + 5, rect.top + rect.get_height()/2 - Fonts::verdana11.get_height()/2), text); }
void StoryScreenComponent::draw (DrawingContext& gc) { gc.draw(background, Vector2i(gc.get_width()/2, gc.get_height()/2)); gc.print_center(Fonts::chalk_large, Display::get_width()/2, Display::get_height()/2 - 200, story->get_title()); gc.draw(page_surface, Vector2i(gc.get_width()/2, gc.get_height()/2 - 65)); gc.print_left(Fonts::chalk_normal, Display::get_width()/2 - 280, Display::get_height()/2 + 35, display_text); }
void Combobox::draw(DrawingContext &gc) { { // draw the unopened box gc.draw_fillrect(rect, Color(255,255,255)); gc.draw(sprite, Vector2i(rect.right - 12, rect.top)); gc.draw_rect(rect, Color(0,0,0)); if (current_item != -1) { gc.print_left(Fonts::verdana11, Vector2i(rect.left + 5, rect.top + rect.get_height()/2 - Fonts::verdana11.get_height()/2), item_list[current_item].label); } } if (drop_down && !item_list.empty()) { gc.draw_fillrect(list_rect, Color(255,255,255), 90); for (int i = 0; i < int(item_list.size()); ++i) { if (i == hover_item) gc.draw_fillrect(Rect(Vector2i(rect.left, list_rect.top + rect.get_height()*i), Size(rect.get_width(), rect.get_height())), Color(150,200,255), 95); gc.print_left(Fonts::verdana11, Vector2i(list_rect.left + 5, list_rect.top + i * rect.get_height() + rect.get_height()/2 - Fonts::verdana11.get_height()/2), item_list[i].label, 100); } gc.draw_rect(list_rect, Color(0,0,0), 100); } }
void ButtonPanel::draw(DrawingContext& gc) { ActionHolder* aholder = server->get_action_holder(); for(std::vector<ActionButton>::size_type i = 0; i < buttons.size(); ++i) { if (current_button == i) gc.draw(highlight, Vector2i(rect.left, rect.top + 38*i)); else gc.draw(background, Vector2i(rect.left, rect.top + 38*i)); gc.draw(buttons[i].sprite, Vector2i(rect.left + 20, rect.top + 38*i + 16)); if (globals::developer_mode) { std::ostringstream out; std::string str = StringUtil::to_string(aholder->get_available(buttons[i].name)); out << aholder->get_available(buttons[i].name) << " / " << aholder->get_used(buttons[i].name); gc.print_left(Fonts::pingus_small, Vector2i(rect.left + 46, rect.top + 5 + 38*i), out.str()); } else { std::string str = StringUtil::to_string(aholder->get_available(buttons[i].name)); gc.print_center(Fonts::pingus_small, Vector2i(rect.left + 46, rect.top + 5 + 38*i), str); } if (show_tip && tip_button == i) { gc.print_left(Fonts::pingus_small, Vector2i(rect.left + 65, rect.top + 5 + 38*i), ActionName::to_screenname(buttons[i].name)); } } }
void StoryScreenComponent::draw (DrawingContext& gc) { // Paint the background wood panel for(int y = 0; y < gc.get_height(); y += background.get_height()) for(int x = 0; x < gc.get_width(); x += background.get_width()) gc.draw(background, Vector2i(x, y)); gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2)); gc.print_center(Fonts::chalk_large, Vector2i(gc.get_width()/2, gc.get_height()/2 - 200), story->get_title()); gc.draw(page_surface, Vector2i(gc.get_width()/2, gc.get_height()/2 - 65)); gc.print_left(Fonts::chalk_normal, Vector2i(gc.get_width()/2 - 280, gc.get_height()/2 + 35), display_text); }
void ChoiceBox::draw(DrawingContext& gc) { if (globals::developer_mode) gc.draw_rect(rect, Color(0, 255, 255)); if (!choices.empty()) { if (current_choice >= 0 && current_choice < int(choices.size())) { //if (current_choice != 0) gc.print_left(Fonts::chalk_normal, Vector2i(rect.left, rect.top), "<"); //if (current_choice != int(choices.size())-1) gc.print_right(Fonts::chalk_normal, Vector2i(rect.right, rect.top), ">"); gc.print_center(Fonts::chalk_normal, Vector2i(rect.left + rect.get_width()/2, rect.top), choices[current_choice]); } } }
void FileList::draw(DrawingContext& gc) { GUIStyle::draw_lowered_box(gc, rect, Color(255, 255, 255)); int end = (page+1) * items_per_page(); if (end > int(directory.size())) end = static_cast<int>(directory.size()); int x = rect.left; int y = rect.top; for(System::Directory::iterator i = directory.begin() + page * items_per_page(); i != directory.begin() + end; ++i) { if (i->type == System::DE_DIRECTORY) gc.draw(directory_icon, Vector2i(x, y)); else if (i->type == System::DE_FILE) gc.draw(file_icon, Vector2i(x, y)); if ((click_item == -1 && (i - directory.begin()) == current_item) || (i - directory.begin()) == click_item) { if (click_item == current_item) gc.draw_fillrect(Rect(x, y, x + hspace, y + vspace), Color(0, 0, 255)); else gc.draw_rect(Rect(x, y, x + hspace, y + vspace), Color(0, 0, 255)); } gc.print_left(Fonts::verdana11, Vector2i(x + 4, y + 3), ((i->type == System::DE_DIRECTORY) ? "[DIR] " : "[FILE] ") + i->name); y += 20; if (y > rect.bottom - vspace) { y = rect.top; x += hspace; } } }
void OptionMenu::draw_background(DrawingContext& gc) { // Paint the background wood panel for(int y = 0; y < gc.get_height(); y += m_background.get_height()) for(int x = 0; x < gc.get_width(); x += m_background.get_width()) gc.draw(m_background, Vector2i(x, y)); // gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0)); gc.draw(m_blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2)); gc.print_center(Fonts::chalk_large, Vector2i(gc.get_width()/2, gc.get_height()/2 - 240), _("Option Menu")); gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2 + 245 + 30, gc.get_height()/2 + 150 - 20), _("Close")); gc.print_left(Fonts::chalk_normal, Vector2i(gc.get_width()/2 - 320, gc.get_height()/2 + 200), _("Some options require a restart of the game to take effect.")); }
// Draw the background and components void EditorScreen::draw(DrawingContext& gc) { // Black out screen //gc.fill_screen(Color(255,0,255)); // FIXME: Could be removed for added speed gui_manager->draw(gc); if (show_help) { Size size_(640, 400); gc.draw_fillrect(Rect(gc.get_width()/2 - size_.width/2 - 2, gc.get_height()/2 - size_.height/2 - 2, gc.get_width()/2 + size_.width/2 + 2, gc.get_height()/2 + size_.height/2 + 2), Color(0,0,0)); gc.draw_fillrect(Rect(gc.get_width()/2 - size_.width/2, gc.get_height()/2 - size_.height/2, gc.get_width()/2 + size_.width/2, gc.get_height()/2 + size_.height/2), Color(255,255,255)); gc.print_center(Fonts::verdana11, Vector2i(gc.get_width()/2, gc.get_height()/2 - size_.height/2 + 12), _("== Editor Help ==")); int x = gc.get_width()/2 - size_.width/2 + 12; int y = gc.get_height()/2 - size_.height/2 + 36; gc.print_center(Fonts::verdana11, Vector2i(x + 75, y), "A\n" "Shift+A\n" "PageUp, ], w\n" "PageDown, [, s\n" "Shift+PageUp\n" "Shift+PageDown\n" "R\n" "Shift+R\n" "G\n" "Shift+G\n" ); gc.print_left(Fonts::verdana11, Vector2i(x+150, y), _("Select all\n" "Clear Selection\n" "Raise objects\n" "Lower objects\n" "Raise objects to top\n" "Lower objects to bottom\n" "Rotate 90 degree\n" "Rotate 270 degree\n" "Group selected objects\n" "Ungroup selected objects\n")); x = int(gc.get_width()/2 + 12); y = int(gc.get_height()/2) - size_.height/2 + 36; gc.print_center(Fonts::verdana11, Vector2i(x + 50, y), "F\n" "Shift+F\n" "Delete, Backspace\n" "I, K, J, L\n" "Shift+I, K, J, L\n" "B, Shift+B\n" "=, +, -\n"); gc.print_left(Fonts::verdana11, Vector2i(x + 125, y), _("Flip object horizontaly\n" "Flip object vertically\n" "Delete all marked objects\n" "Move objects by one pixel\n" "Move objects by 32 pixel\n" "Toggle background color\n" "Increase/lower repeat\n")); gc.print_left(Fonts::verdana11, Vector2i(gc.get_width()/2 - size_.width/2 + 12, gc.get_height()/2 - 10), _("You should name your level files systematically, i.e. by their theme, " "their number and your nickname:\n\n" " <levelname><number>-<creator>.pingus\n\n" "So if you create your second level with a stone theme, call it: " "stone2-yourname.pingus\n\n" "When you have created a level and want to have it included " "in the game mail it to:\n\n" " [email protected]\n\n" "Only levels published under the GPL are allowed into the game. The editor " "automatically inserts a reference \n" "to the GPL, if you want to have your level under a different license, you " "have to change that reference.\n" )); } }
void ResultScreenComponent::draw(DrawingContext& gc) { // Paint the background wood panel for(int y = 0; y < gc.get_height(); y += background.get_height()) for(int x = 0; x < gc.get_width(); x += background.get_width()) gc.draw(background, Vector2i(x, y)); gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2)); gc.print_center(Fonts::chalk_large, Vector2i(gc.get_width()/2, Display::get_height()/2 - 200), _(result.plf.get_levelname())); if (result.success()) { gc.print_center(Fonts::chalk_large, Vector2i(gc.get_width()/2, Display::get_height()/2 - 140), _("Success!")); /*gc.print_center(Fonts::pingus_small, gc.get_width()/2, gc.get_height()-30, "..:: Press Space to continue ::..");*/ } else { gc.print_center(Fonts::chalk_large, Vector2i(gc.get_width()/2, Display::get_height()/2 - 140), _("Failure!")); /*gc.print_center(Fonts::pingus_normal, gc.get_width()/2, gc.get_height()-30, "..:: Press Space to retry the level ::..");*/ } std::string message; if (result.success()) { if (result.killed == 0 && result.saved == result.total) message = _("Perfect! You saved everyone possible - great!"); else if (result.killed == 0) message = _("No-one got killed, pretty good work."); else if (result.saved == result.needed) message = _("You saved exactly what you needed - you made it, but\n" "maybe you can do better?"); else if (result.killed >= 5) message = _("Not everybody was saved, but still good work!"); else message = _("What can I say, you made it - congratulations!"); } else { if (result.killed == result.total) message = _("You killed everybody, not good."); else if (result.saved == 0) message = _("No-one got saved - I know you can do better."); else if (result.saved > 0) message = _("You didn't save enough, but you saved a few. Next\n" "time you might do better."); else if (result.saved + 1 >= result.needed) message = _("Only one more and you would have made it - try again!"); else if (result.saved + 5 >= result.needed) message = _("Only a handful more and you would have made it - try again!"); else message = _("Better luck next time!"); } gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2, gc.get_height()/2 - 70), message); int left_x = gc.get_width()/2 - 100; int right_x = gc.get_width()/2 + 100; int y = Display::get_height()/2 + 10; gc.print_left(Fonts::chalk_normal, Vector2i(left_x, y), _("Saved: ")); gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), StringUtil::to_string(result.saved) + "/" + StringUtil::to_string(result.needed));; gc.print_left(Fonts::chalk_normal, Vector2i(left_x, (y+=30)), _("Died: ")); gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), StringUtil::to_string(result.killed)); gc.print_left(Fonts::chalk_normal, Vector2i(left_x, (y+=30)), _("Time left: ")); gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), time_str); }