/// Renders the inventory GUI Bible page to the provided screen. /// @param[in,out] renderer - The renderer to use for rendering. void InventoryBiblePage::Render(GRAPHICS::Renderer& renderer) const { // RENDER A RECTANGLE FOR THE PAGE'S BACKGROUND. // It is offset from the top of the screen by the amount of the // GUI stuff that should always be displayed above it. Otherwise, // it should cover the remainder of the screen. const float TOP_SCREEN_OFFSET_IN_PIXELS = static_cast<float>(2 * GRAPHICS::GUI::Glyph::HEIGHT_IN_PIXELS); const float SCREEN_LEFT_POSITION_IN_PIXELS = 0.0f; const float BACKGROUND_HEIGHT_IN_PIXELS = renderer.Screen.HeightInPixels<float>() - TOP_SCREEN_OFFSET_IN_PIXELS; MATH::FloatRectangle background_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( SCREEN_LEFT_POSITION_IN_PIXELS, TOP_SCREEN_OFFSET_IN_PIXELS, renderer.Screen.WidthInPixels<float>(), BACKGROUND_HEIGHT_IN_PIXELS); renderer.RenderScreenRectangle( background_rectangle, BACKGROUND_COLOR); // RENDER THE BOX FOR THE MAIN BIBLE VERSE DISPLAY. const BIBLE::BibleVerse* const selected_bible_verse = BibleVerseListBox.GetSelectedVerse(); // The exact positioning/size of this box is tentative. const float BIBLE_VERSE_TEXT_BOX_SINGLE_SIDE_PADDING_IN_PIXELS = 4.0f; float bible_verse_text_box_left_screen_position_in_pixels = background_rectangle.GetLeftXPosition() + BIBLE_VERSE_TEXT_BOX_SINGLE_SIDE_PADDING_IN_PIXELS; float bible_verse_text_box_top_screen_position_in_pixels = background_rectangle.GetTopYPosition() + BIBLE_VERSE_TEXT_BOX_SINGLE_SIDE_PADDING_IN_PIXELS; float bible_verse_text_box_width_in_pixels = background_rectangle.GetWidth() / 2.0f; const float BIBLE_VERSE_TEXT_BOX_BOTH_SIDES_PADDING_IN_PIXELS = 2.0f * BIBLE_VERSE_TEXT_BOX_SINGLE_SIDE_PADDING_IN_PIXELS; float bible_verse_text_box_height_in_pixels = background_rectangle.GetHeight() - BIBLE_VERSE_TEXT_BOX_BOTH_SIDES_PADDING_IN_PIXELS; MATH::FloatRectangle bible_verse_text_box_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( bible_verse_text_box_left_screen_position_in_pixels, bible_verse_text_box_top_screen_position_in_pixels, bible_verse_text_box_width_in_pixels, bible_verse_text_box_height_in_pixels); BibleVerseTextBox.Render( selected_bible_verse, bible_verse_text_box_rectangle, renderer); // RENDER THE BOX FOR THE LIST OF ALL BIBLE VERSES. // The exact positioning/size of this box is tentative. float bible_verse_list_box_left_screen_position_in_pixels = (bible_verse_text_box_rectangle.GetRightXPosition() + BIBLE_VERSE_TEXT_BOX_SINGLE_SIDE_PADDING_IN_PIXELS); float bible_verse_list_box_top_screen_position_in_pixels = bible_verse_text_box_rectangle.GetTopYPosition(); // Take up the remaining width (minus padding on the right). float bible_verse_list_box_width_in_pixels = background_rectangle.GetWidth() - bible_verse_list_box_left_screen_position_in_pixels - BIBLE_VERSE_TEXT_BOX_SINGLE_SIDE_PADDING_IN_PIXELS; float bible_verse_list_box_height_in_pixels = bible_verse_text_box_rectangle.GetHeight(); MATH::FloatRectangle bible_verse_list_box_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( bible_verse_list_box_left_screen_position_in_pixels, bible_verse_list_box_top_screen_position_in_pixels, bible_verse_list_box_width_in_pixels, bible_verse_list_box_height_in_pixels); BibleVerseListBox.Render( bible_verse_list_box_rectangle, renderer); }
/// Renders the page of the inventory for the food tab. /// This page allows browsing food in the inventory. /// @param[in,out] renderer - The renderer to use for rendering. void InventoryGui::RenderFoodPage(GRAPHICS::Renderer& renderer) const { // RENDER A RECTANGLE FOR THE PAGE'S BACKGROUND. // It is offset from the top of the screen by the amount of the // GUI stuff that should always be displayed above it. Otherwise, // it should cover the remainder of the screen. const float TOP_SCREEN_OFFSET_IN_PIXELS = static_cast<float>(2 * GRAPHICS::GUI::Glyph::HEIGHT_IN_PIXELS); const float SCREEN_LEFT_POSITION_IN_PIXELS = 0.0f; const float BACKGROUND_HEIGHT_IN_PIXELS = renderer.Screen.HeightInPixels<float>() - TOP_SCREEN_OFFSET_IN_PIXELS; MATH::FloatRectangle background_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( SCREEN_LEFT_POSITION_IN_PIXELS, TOP_SCREEN_OFFSET_IN_PIXELS, renderer.Screen.WidthInPixels<float>(), BACKGROUND_HEIGHT_IN_PIXELS); renderer.RenderScreenRectangle( background_rectangle, FOOD_TAB_COLOR); }
/// Renders a tab that is part of the inventory GUI. /// @param[in] tab_text - The text to display on the tab. /// @param[in] left_top_screen_position_in_pixels - The left-top screen position of the tab. /// @param[in] background_color - The background color of the tab. /// @param[in,out] renderer - The renderer to use for rendering. void InventoryGui::RenderTab( const std::string& tab_text, const MATH::Vector2f& left_top_screen_position_in_pixels, const GRAPHICS::Color& background_color, GRAPHICS::Renderer& renderer) const { // RENDER A BACKGROUND RECTANGLE FOR THE TAB. unsigned int tab_text_width_in_pixels = GRAPHICS::GUI::Glyph::WIDTH_IN_PIXELS * tab_text.length(); MATH::FloatRectangle tab_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( left_top_screen_position_in_pixels.X, left_top_screen_position_in_pixels.Y, static_cast<float>(tab_text_width_in_pixels), static_cast<float>(GRAPHICS::GUI::Glyph::HEIGHT_IN_PIXELS)); renderer.RenderScreenRectangle( tab_rectangle, background_color); // RENDER THE TEXT FOR THE TAB. renderer.RenderText(tab_text, left_top_screen_position_in_pixels, GRAPHICS::Color::BLACK); }
/// Renders the inventory GUI to the provided screen. /// @param[in,out] renderer - The renderer to use for rendering. void InventoryGui::Render(GRAPHICS::Renderer& renderer) const { // RENDER A RECTANGLE FOR THE BACKGROUND. // It is offset from the top of the screen by the amount of the // top row of the HUD that is always displayed. Otherwise, // it should cover the remainder of the screen. const float TOP_SCREEN_OFFSET_IN_PIXELS = static_cast<float>(GRAPHICS::GUI::Glyph::HEIGHT_IN_PIXELS); const float SCREEN_LEFT_POSITION_IN_PIXELS = 0.0f; const float BACKGROUND_HEIGHT_IN_PIXELS = renderer.Screen.HeightInPixels<float>() - TOP_SCREEN_OFFSET_IN_PIXELS; MATH::FloatRectangle background_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( SCREEN_LEFT_POSITION_IN_PIXELS, TOP_SCREEN_OFFSET_IN_PIXELS, renderer.Screen.WidthInPixels<float>(), BACKGROUND_HEIGHT_IN_PIXELS); // The background color is currently arbitrary. GRAPHICS::Color background_color; background_color.Red = GRAPHICS::Color::MAX_COLOR_COMPONENT; background_color.Green = GRAPHICS::Color::MAX_COLOR_COMPONENT; background_color.Blue = GRAPHICS::Color::MAX_COLOR_COMPONENT; renderer.RenderScreenRectangle( background_rectangle, background_color); // RENDER A TAB FOR THE BIBLE PORTION OF THE GUI. // It should be positioned near the top-left of the GUI. float bible_tab_left_screen_position_in_pixels = background_rectangle.GetLeftXPosition(); float bible_tab_top_screen_position_in_pixels = background_rectangle.GetTopYPosition(); MATH::Vector2f bible_tab_left_top_screen_position_in_pixels( bible_tab_left_screen_position_in_pixels, bible_tab_top_screen_position_in_pixels); RenderTab( "Bible", bible_tab_left_top_screen_position_in_pixels, InventoryBiblePage::BACKGROUND_COLOR, renderer); // RENDER A TAB FOR THE ANIMAL PORTION OF THE GUI. const std::string ANIMALS_TAB_STRING = "Animals"; unsigned int animals_tab_text_width_in_pixels = GRAPHICS::GUI::Glyph::WIDTH_IN_PIXELS * ANIMALS_TAB_STRING.length(); unsigned int animals_tab_text_half_width_in_pixels = animals_tab_text_width_in_pixels / 2; float animals_tab_left_screen_position_in_pixels = background_rectangle.GetCenterXPosition() - animals_tab_text_half_width_in_pixels; float animals_tab_top_screen_position_in_pixels = background_rectangle.GetTopYPosition(); MATH::Vector2f animals_tab_left_top_screen_position_in_pixels( animals_tab_left_screen_position_in_pixels, animals_tab_top_screen_position_in_pixels); RenderTab( ANIMALS_TAB_STRING, animals_tab_left_top_screen_position_in_pixels, ANIMALS_TAB_COLOR, renderer); // RENDER A TAB FOR THE FOOD PORTION OF THE GUI. const std::string FOOD_TAB_STRING = "Food"; unsigned int food_tab_text_width_in_pixels = GRAPHICS::GUI::Glyph::WIDTH_IN_PIXELS * FOOD_TAB_STRING.length(); float food_tab_left_screen_position_in_pixels = background_rectangle.GetRightXPosition() - food_tab_text_width_in_pixels; float food_tab_top_screen_position_in_pixels = background_rectangle.GetTopYPosition(); MATH::Vector2f food_tab_left_top_screen_position_in_pixels( food_tab_left_screen_position_in_pixels, food_tab_top_screen_position_in_pixels); RenderTab( FOOD_TAB_STRING, food_tab_left_top_screen_position_in_pixels, FOOD_TAB_COLOR, renderer); // RENDER THE CURRENTLY DISPLAYED PAGE. switch (CurrentTab) { case TabType::BIBLE: BiblePage.Render(renderer); break; case TabType::ANIMALS: RenderAnimalsPage(renderer); break; case TabType::FOOD: RenderFoodPage(renderer); break; } }
/// Renders the credits screen. /// @param[in,out] renderer - The renderer to use for rendering. void CreditsScreen::Render(GRAPHICS::Renderer& renderer) const { // CALCULATE THE OFFSET OF THE TOP OF THE CREDITS BASED ON THE ELAPSED TIME. // This helps implement scrolling of the credits text upward. const float SCROLL_RATE_IN_PIXELS_PER_SECOND = -4.0f; float elapsed_time_in_seconds = ElapsedTime.asSeconds(); float credits_text_top_offset_in_pixels = SCROLL_RATE_IN_PIXELS_PER_SECOND * elapsed_time_in_seconds; // RENDER TEXT INDICATING THE PURPOSE OF THIS SCREEN. const GRAPHICS::Color CREDITS_TEXT_COLOR = GRAPHICS::Color::WHITE; MATH::FloatRectangle screen_rectangle = renderer.Screen->GetBoundingRectangle<float>(); float screen_left_x_position = screen_rectangle.GetLeftXPosition(); float screen_top_y_position = screen_rectangle.GetTopYPosition(); float screen_width_in_pixels = screen_rectangle.GetWidth(); float screen_height_in_pixels = screen_rectangle.GetHeight(); const float SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS = static_cast<float>(GRAPHICS::GUI::Glyph::DEFAULT_HEIGHT_IN_PIXELS); float credits_text_start_top_y_position = screen_top_y_position + credits_text_top_offset_in_pixels; MATH::FloatRectangle credits_title_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, credits_text_start_top_y_position, screen_width_in_pixels, SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); renderer.RenderCenteredText( "CREDITS", RESOURCES::AssetId::FONT_TEXTURE, credits_title_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER TEXT CREDITING GOD. const std::string GOD_CREDIT_TEXT = R"(Him by whom "all things were created" and "all things consist" - from Colossians 1:16-17 (KJV))"; // Some additional spacing is added to help offset this credit text from previous text. float start_of_credits_top_y_position_in_pixels = 2 * SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS + credits_text_start_top_y_position; // This text takes multiple lines to render using the current font. const unsigned int GOD_CREDIT_TEXT_LINE_COUNT = 4; const float GOD_CREDIT_TEXT_HEIGHT_IN_PIXELS = static_cast<float>(GOD_CREDIT_TEXT_LINE_COUNT * SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); MATH::FloatRectangle current_credit_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, start_of_credits_top_y_position_in_pixels, screen_width_in_pixels, GOD_CREDIT_TEXT_HEIGHT_IN_PIXELS); renderer.RenderCenteredText( GOD_CREDIT_TEXT, RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER ADDITIONAL CREDITS FOR INDIVIDUAL PEOPLE. // Some additional spacing is added to help offset this credit text from other text. const float SPACING_BEFORE_REMAINING_CREDITS = (2 * SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); float current_credits_text_top_y_position_in_pixels = start_of_credits_top_y_position_in_pixels + GOD_CREDIT_TEXT_HEIGHT_IN_PIXELS + SPACING_BEFORE_REMAINING_CREDITS; current_credit_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, current_credits_text_top_y_position_in_pixels, screen_width_in_pixels, SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); renderer.RenderCenteredText( "Programming - Jacob Pike", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); const MATH::Vector2f MOVE_DOWN_SINGLE_LINE(0, SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Graphics - Jacob Pike", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Music - Chad Pike", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER ADDITIONAL CREDITS FOR SOUND EFFECTS. current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "ANIMAL SOUNDS", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "soundbible.com", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "BuffBill84", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Mike Koenig", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "snottyboy", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "NPS", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "fws.gov", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "BlastwaveFx.com", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Daniel Simion", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Caroline Ford", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "JimBob", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "J Dawg", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "wrzesien", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER ADDITIONAL CREDITS FOR DEVELOPMENT TOOLS. current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "DEVELOPMENT TOOLS", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Visual Studio 2017", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Git/GitHub", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Microsoft Paint", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Bfxr", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Doxygen", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "SFML", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Catch", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER ADDITIONAL CREDITS FOR OTHER RESOURCES. current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "OTHER RESOURCES", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "KJV Bible", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER SOME HELP TEXT TO INFORM PLAYERS HOW TO RETURN TO THE TITLE SCREEN. const float SCREEN_Y_POSITION_ONE_LINE_BEFORE_BOTTOM = screen_height_in_pixels - SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS; MATH::FloatRectangle help_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, SCREEN_Y_POSITION_ONE_LINE_BEFORE_BOTTOM, screen_width_in_pixels, SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); // A black rectangle is rendered behind the text to avoid having the text overlap // with other text from the credits and make things hard to read. renderer.RenderScreenRectangle(help_text_screen_rectangle, GRAPHICS::Color::BLACK); renderer.RenderText( "[ESC] to title", RESOURCES::AssetId::FONT_TEXTURE, help_text_screen_rectangle, CREDITS_TEXT_COLOR); }