virtual void Render() { GG::Clr base_color = Alive() ? m_wound_color : m_dead_color; // Always draw the red background, health will cover it GG::FlatRectangle(ClientUpperLeft(), ClientLowerRight(), base_color, m_hovered ? GG::CLR_WHITE : GG::CLR_BLACK, 1); if( m_sizer.Get( TOGGLE_BAR_HEALTH_SMOOTH ) ) { // Use a smooth colour change based health display. if (Alive()) { double health_percentage = 1.0 * m_participant.current_health / m_participant.max_health; GG::Clr mixed_color(interpolate(health_percentage, m_health_color.r, m_wound_color.r), interpolate(health_percentage, m_health_color.g, m_wound_color.g), interpolate(health_percentage, m_health_color.b, m_wound_color.b), interpolate(health_percentage, m_health_color.a, m_wound_color.a)); GG::FlatRectangle(ClientUpperLeft(), ClientLowerRight(), mixed_color, GG::CLR_ZERO, 1); } } else { if(Alive()) { GG::Y health_height( (m_participant.current_health / m_participant.max_health) * Value(ClientHeight()) ); GG::FlatRectangle(GG::Pt(ClientUpperLeft().x, ClientLowerRight().y - health_height), ClientLowerRight(), m_health_color, GG::CLR_ZERO, 1); } } }
virtual void Render() { // Draw the axes outside th3e client area GG::Pt begin(ClientUpperLeft().x - AXIS_WIDTH/2, ClientLowerRight().y + AXIS_HEIGHT/2); GG::Pt x_end(ClientLowerRight().x, begin.y); GG::Pt y_end(begin.x, ClientUpperLeft().y); DrawArrow(begin, x_end); DrawArrow(begin, y_end); }
void About::DoLayout() { const GG::X BUTTONS_HORIZONTAL_SPACING(5); const GG::Y CONTENT_GROUPS_VERTICAL_SPACING(5); const GG::Pt BORDERS_SIZE { GG::X {5}, GG::Y {5} }; const GG::Pt BUTTON_SIZE { std::max({ m_vision->MinUsableSize().x, m_license->MinUsableSize().x, m_done->MinUsableSize().x }), std::max({ m_vision->MinUsableSize().y, m_license->MinUsableSize().y, m_done->MinUsableSize().y }), }; auto const window_lr = ScreenToClient(ClientLowerRight()); auto const content_lr = window_lr - BORDERS_SIZE; auto const content_ul = BORDERS_SIZE; GG::Pt draw_point = content_lr; for (auto& button : { m_done, m_vision, m_license }) { GG::Pt button_ul = draw_point - BUTTON_SIZE; button->SizeMove(button_ul, draw_point); draw_point.x -= BUTTON_SIZE.x + BUTTONS_HORIZONTAL_SPACING; } draw_point.x = content_lr.x; draw_point.y -= BUTTON_SIZE.y + CONTENT_GROUPS_VERTICAL_SPACING; m_info->SizeMove(content_ul, draw_point); }
void About::DoLayout(void) { GG::X HORIZONTAL_SPACING(5); GG::Y VERTICAL_SPACING(5); GG::X BUTTON_WIDTH(95); GG::Y BUTTON_HEIGHT(20); GG::Pt buttons_lr = ScreenToClient(ClientLowerRight()) - GG::Pt(HORIZONTAL_SPACING, VERTICAL_SPACING); GG::Pt buttons_ul = buttons_lr - GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); m_done_btn->SizeMove(buttons_ul, buttons_lr); buttons_lr.x -= BUTTON_WIDTH + HORIZONTAL_SPACING; buttons_ul.x -= BUTTON_WIDTH + HORIZONTAL_SPACING; m_vision->SizeMove(buttons_ul, buttons_lr); buttons_lr.x -= BUTTON_WIDTH + HORIZONTAL_SPACING; buttons_ul.x -= BUTTON_WIDTH + HORIZONTAL_SPACING; m_license->SizeMove(buttons_ul, buttons_lr); GG::Pt text_area_lr = ScreenToClient(ClientLowerRight()) - GG::Pt(HORIZONTAL_SPACING, VERTICAL_SPACING + BUTTON_HEIGHT + VERTICAL_SPACING); m_info->SizeMove(GG::Pt(HORIZONTAL_SPACING, VERTICAL_SPACING), text_area_lr); }
void CUIWnd::Render() { GG::Pt ul = UpperLeft(); GG::Pt lr = LowerRight(); GG::Pt cl_ul = ClientUpperLeft(); GG::Pt cl_lr = ClientLowerRight(); if (!m_minimized) { AngledCornerRectangle(ul, lr, ClientUI::WndColor(), ClientUI::WndOuterBorderColor(), OUTER_EDGE_ANGLE_OFFSET, 1, false, !m_resizable); // show notched bottom-right corner if not resizable, pointed corner if resizable // use GL to draw the lines glDisable(GL_TEXTURE_2D); // draw inner border, including extra resize-tab lines glBegin(GL_LINE_STRIP); glColor(ClientUI::WndInnerBorderColor()); glVertex(cl_ul.x, cl_ul.y); glVertex(cl_lr.x, cl_ul.y); if (m_resizable) { glVertex(cl_lr.x, cl_lr.y - INNER_BORDER_ANGLE_OFFSET); glVertex(cl_lr.x - INNER_BORDER_ANGLE_OFFSET, cl_lr.y); } else { glVertex(cl_lr.x, cl_lr.y); } glVertex(cl_ul.x, cl_lr.y); glVertex(cl_ul.x, cl_ul.y); glEnd(); if (m_resizable) { glBegin(GL_LINES); // draw the extra lines of the resize tab GG::Clr tab_lines_colour = m_mouse_in_resize_tab ? ClientUI::WndInnerBorderColor() : ClientUI::WndOuterBorderColor(); glColor(tab_lines_colour); glVertex(cl_lr.x, cl_lr.y - RESIZE_HASHMARK1_OFFSET); glVertex(cl_lr.x - RESIZE_HASHMARK1_OFFSET, cl_lr.y); glVertex(cl_lr.x, cl_lr.y - RESIZE_HASHMARK2_OFFSET); glVertex(cl_lr.x - RESIZE_HASHMARK2_OFFSET, cl_lr.y); glEnd(); } glEnable(GL_TEXTURE_2D); } else { GG::FlatRectangle(ul, lr, ClientUI::WndColor(), ClientUI::WndOuterBorderColor(), 1); } GG::BeginScissorClipping(ul, lr); glColor(ClientUI::TextColor()); boost::shared_ptr<GG::Font> font = ClientUI::GetTitleFont(); font->RenderText(GG::Pt(ul.x + BORDER_LEFT, ul.y + TITLE_OFFSET), Name()); GG::EndScissorClipping(); }
void MultiMeterStatusBar::Render() { GG::Clr DARY_GREY = GG::Clr(44, 44, 44, 255); GG::Clr HALF_GREY = GG::Clr(128, 128, 128, 128); GG::Pt ul = UpperLeft(); GG::Pt lr = LowerRight(); // outline of whole control GG::FlatRectangle(ul, lr, ClientUI::WndColor(), ClientUI::WndOuterBorderColor(), 1); const GG::X BAR_LEFT = ClientUpperLeft().x + EDGE_PAD - 1; const GG::X BAR_RIGHT = ClientLowerRight().x - EDGE_PAD + 1; const GG::X BAR_MAX_LENGTH = BAR_RIGHT - BAR_LEFT; const GG::Y TOP = ClientUpperLeft().y + EDGE_PAD - 1; GG::Y y = TOP; for (unsigned int i = 0; i < m_initial_values.size(); ++i) { // bar grey backgrounds GG::FlatRectangle(GG::Pt(BAR_LEFT, y), GG::Pt(BAR_RIGHT, y + BAR_HEIGHT), DARY_GREY, DARY_GREY, 0); y += BAR_HEIGHT + BAR_PAD; } // Find the largest value to be displayed to determine the scale factor double largest_value = 0; for (unsigned int i = 0; i < m_initial_values.size(); ++i) { if ((m_initial_values[i] != Meter::INVALID_VALUE) && (m_initial_values[i] > largest_value)) largest_value = m_initial_values[i]; if ((m_projected_values[i] != Meter::INVALID_VALUE) && (m_projected_values[i] > largest_value)) largest_value = m_projected_values[i]; if ((m_target_max_values[i] != Meter::INVALID_VALUE) && (m_target_max_values[i] > largest_value)) largest_value = m_target_max_values[i]; } double num_full_increments = std::ceil(largest_value / MULTI_METER_STATUS_BAR_DISPLAYED_METER_RANGE_INCREMENT); double MULTI_METER_STATUS_BAR_DISPLAYED_METER_RANGE = num_full_increments * MULTI_METER_STATUS_BAR_DISPLAYED_METER_RANGE_INCREMENT; // lines for 20, 40, 60, 80 etc. int num_segments = num_full_increments * 5; GG::GL2DVertexBuffer bar_verts; bar_verts.reserve(num_segments - 1); for (int ii_div_line = 1; ii_div_line <= (num_segments -1); ++ii_div_line) { bar_verts.store(BAR_LEFT + ii_div_line*BAR_MAX_LENGTH/num_segments, TOP); bar_verts.store(BAR_LEFT + ii_div_line*BAR_MAX_LENGTH/num_segments, y - BAR_PAD); } bar_verts.activate(); glColor(HALF_GREY); glDisable(GL_TEXTURE_2D); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); glEnableClientState(GL_VERTEX_ARRAY); glDrawArrays(GL_LINES, 0, bar_verts.size()); glPopClientAttrib(); glEnable(GL_TEXTURE_2D); // current, initial, and target/max horizontal bars for each pair of MeterType y = TOP; for (unsigned int i = 0; i < m_initial_values.size(); ++i) { GG::Clr clr; const GG::Y BAR_TOP = y; const GG::Y BAR_BOTTOM = BAR_TOP + BAR_HEIGHT; const bool SHOW_INITIAL = (m_initial_values[i] != Meter::INVALID_VALUE); const bool SHOW_PROJECTED = (m_projected_values[i] != Meter::INVALID_VALUE); const bool SHOW_TARGET_MAX = (m_target_max_values[i] != Meter::INVALID_VALUE); const GG::X INITIAL_RIGHT(BAR_LEFT + BAR_MAX_LENGTH * m_initial_values[i] / MULTI_METER_STATUS_BAR_DISPLAYED_METER_RANGE); const GG::Y INITIAL_TOP(BAR_TOP); if (SHOW_INITIAL) { // initial value const GG::X INITIAL_RIGHT(BAR_LEFT + BAR_MAX_LENGTH * m_initial_values[i] / MULTI_METER_STATUS_BAR_DISPLAYED_METER_RANGE); const GG::Y INITIAL_TOP(BAR_TOP); glColor(m_bar_colours[i]); m_bar_shading_texture->OrthoBlit(GG::Pt(BAR_LEFT, INITIAL_TOP), GG::Pt(INITIAL_RIGHT, BAR_BOTTOM)); // black border GG::FlatRectangle(GG::Pt(BAR_LEFT, INITIAL_TOP), GG::Pt(INITIAL_RIGHT, BAR_BOTTOM), GG::CLR_ZERO, GG::CLR_BLACK, 1); } const GG::X PROJECTED_RIGHT(BAR_LEFT + BAR_MAX_LENGTH * m_projected_values[i] / MULTI_METER_STATUS_BAR_DISPLAYED_METER_RANGE); const GG::Y PROJECTED_TOP(INITIAL_TOP); if (SHOW_PROJECTED) { // projected colour bar with black border if (PROJECTED_RIGHT > INITIAL_RIGHT) { GG::FlatRectangle(GG::Pt(INITIAL_RIGHT - 1, PROJECTED_TOP), GG::Pt(PROJECTED_RIGHT, BAR_BOTTOM), ClientUI::StatIncrColor(), GG::CLR_BLACK, 1); } else if (PROJECTED_RIGHT < INITIAL_RIGHT) { GG::FlatRectangle(GG::Pt(PROJECTED_RIGHT - 1, PROJECTED_TOP), GG::Pt(INITIAL_RIGHT, BAR_BOTTOM), ClientUI::StatDecrColor(), GG::CLR_BLACK, 1); } } const GG::X TARGET_MAX_RIGHT(BAR_LEFT + BAR_MAX_LENGTH * m_target_max_values[i] / MULTI_METER_STATUS_BAR_DISPLAYED_METER_RANGE); if (SHOW_TARGET_MAX && TARGET_MAX_RIGHT > BAR_LEFT) { // max / target value //glColor(DarkColor(m_bar_colours[i])); //m_bar_shading_texture->OrthoBlit(GG::Pt(BAR_LEFT, BAR_TOP), GG::Pt(TARGET_MAX_RIGHT, BAR_BOTTOM)); // black border GG::FlatRectangle(GG::Pt(BAR_LEFT, BAR_TOP), GG::Pt(TARGET_MAX_RIGHT, BAR_BOTTOM), GG::CLR_ZERO, m_bar_colours[i], 1); } // move down position of next bar, if any y += BAR_HEIGHT + BAR_PAD; } }
// Overrides virtual void Render() { if ( m_type != HEADER ) { GG::FlatRectangle ( ClientUpperLeft(), ClientLowerRight() - GG::Pt ( GG::X ( SAVE_FILE_CELL_MARGIN ), GG::Y0 ), GG::CLR_ZERO, ClientUI::WndOuterBorderColor(), 1u ); } }