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 GalaxySetupWnd::Render() { CUIWnd::Render(); GG::FlatRectangle(GG::Pt(ClientUpperLeft().x + m_preview_ul.x - 2, ClientUpperLeft().y + m_preview_ul.y - 2), GG::Pt(ClientUpperLeft().x + m_preview_ul.x + PREVIEW_SZ.x + 2, ClientUpperLeft().y + m_preview_ul.y + PREVIEW_SZ.y + 2), GG::CLR_BLACK, ClientUI::WndInnerBorderColor(), 1); }
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; } }
void CUIWnd::MinimizeClicked() { if (!m_minimized) { m_minimized = true; m_original_size = Size(); SetMinSize(GG::Pt(MinimizedWidth(), BORDER_TOP)); Resize(GG::Pt(MINIMIZED_WND_WIDTH, BORDER_TOP)); GG::Pt button_ul = GG::Pt(Width() - BUTTON_RIGHT_OFFSET, BUTTON_TOP_OFFSET); if (m_close_button) m_close_button->MoveTo(GG::Pt(button_ul.x, button_ul.y)); if (m_minimize_button) m_minimize_button->MoveTo(GG::Pt(button_ul.x - (m_close_button ? BUTTON_RIGHT_OFFSET : GG::X0), button_ul.y)); Hide(); Show(false); if (m_close_button) m_close_button->Show(); if (m_minimize_button) m_minimize_button->Show(); } else { m_minimized = false; SetMinSize(GG::Pt(MinimizedWidth(), BORDER_TOP + INNER_BORDER_ANGLE_OFFSET + BORDER_BOTTOM + 10)); Resize(GG::Pt(m_original_size)); GG::Pt button_ul = GG::Pt(Width() - BUTTON_RIGHT_OFFSET, BUTTON_TOP_OFFSET) + UpperLeft() - ClientUpperLeft(); if (m_close_button) m_close_button->MoveTo(GG::Pt(button_ul.x, button_ul.y)); if (m_minimize_button) m_minimize_button->MoveTo(GG::Pt(button_ul.x - (m_close_button ? BUTTON_RIGHT_OFFSET : GG::X0), button_ul.y)); Show(); } }
void CUIWnd::InitButtons() { // create the close button GG::Pt button_ul = GG::Pt(Width() - BUTTON_RIGHT_OFFSET, BUTTON_TOP_OFFSET) + UpperLeft() - ClientUpperLeft(); if (m_closable) { m_close_button = new CUI_CloseButton(button_ul.x, button_ul.y); GG::Connect(m_close_button->LeftClickedSignal, &CUIWnd::CloseClicked, this); AttachChild(m_close_button); m_close_button->NonClientChild(true); } // create the minimize button if (m_minimizable) { m_minimize_button = new CUI_MinRestoreButton(button_ul.x - (m_close_button ? BUTTON_RIGHT_OFFSET : GG::X0), button_ul.y); GG::Connect(m_minimize_button->LeftClickedSignal, &CUIWnd::MinimizeClicked, this); AttachChild(m_minimize_button); m_minimize_button->NonClientChild(true); } }
void CUIWnd::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { Wnd::SizeMove(ul, lr); GG::Pt button_ul = GG::Pt(Width() - BUTTON_RIGHT_OFFSET, BUTTON_TOP_OFFSET) + UpperLeft() - ClientUpperLeft(); if (m_close_button) m_close_button->MoveTo(GG::Pt(button_ul.x, button_ul.y)); if (m_minimize_button) m_minimize_button->MoveTo(GG::Pt(button_ul.x - (m_close_button ? BUTTON_RIGHT_OFFSET : GG::X0), button_ul.y)); }
// 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 ); } }