1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
#include "CUIStyle.h"
#include "CUIControls.h"
#include "CUISlider.h"
#include "../util/i18n.h"
std::string CUIStyle::Translate(const std::string& text) const
{
if (text == "New")
return UserString("COLOR_DLG_NEW");
else if (text == "Old")
return UserString("COLOR_DLG_OLD");
else if (text == "R:")
return UserString("COLOR_DLG_RED");
else if (text == "G:")
return UserString("COLOR_DLG_GREEN");
else if (text == "B:")
return UserString("COLOR_DLG_BLUE");
else if (text == "H:")
return UserString("COLOR_DLG_HUE");
else if (text == "S:")
return UserString("COLOR_DLG_SATURATION");
else if (text == "V:")
return UserString("COLOR_DLG_VALUE");
else if (text == "A:")
return UserString("COLOR_DLG_ALPHA");
else if (text == "Ok")
return UserString("OK");
else if (text == "Cancel")
return UserString("CANCEL");
else if (text == "File(s):")
return UserString("FILE_DLG_FILES");
else if (text == "Type(s):")
return UserString("FILE_DLG_FILE_TYPES");
else if (text == "%1% exists.\nOk to overwrite it?")
return UserString("FILE_DLG_OVERWRITE_PROMPT");
else if (text == "\"%1%\"\nis a directory.")
return UserString("FILE_DLG_FILENAME_IS_A_DIRECTORY");
else if (text == "File \"%1%\"\ndoes not exist.")
return UserString("FILE_DLG_FILE_DOES_NOT_EXIST");
else if (text == "Device is not ready.")
return UserString("FILE_DLG_DEVICE_IS_NOT_READY");
else if (text == "Save")
return UserString("SAVE");
else if (text == "Open")
return UserString("OPEN");
return UserString("ERROR");
}
std::shared_ptr<GG::Button> CUIStyle::NewButton(std::string str, const std::shared_ptr<GG::Font>& font,
GG::Clr color, GG::Clr text_color,
GG::Flags<GG::WndFlag> flags) const
{ return GG::Wnd::Create<CUIButton>(std::move(str)); }
std::shared_ptr<GG::DropDownList> CUIStyle::NewDropDownList(std::size_t num_shown_elements, GG::Clr color) const
{ return GG::Wnd::Create<CUIDropDownList>(num_shown_elements); }
std::shared_ptr<GG::Edit> CUIStyle::NewEdit(std::string str, const std::shared_ptr<GG::Font>& font,
GG::Clr color, GG::Clr text_color,
GG::Clr interior) const
{ return GG::Wnd::Create<CUIEdit>(std::move(str)); }
std::shared_ptr<GG::ListBox> CUIStyle::NewListBox(GG::Clr color, GG::Clr interior) const
{ return GG::Wnd::Create<CUIListBox>(); }
std::shared_ptr<GG::Scroll> CUIStyle::NewScroll(GG::Orientation orientation, GG::Clr color, GG::Clr interior) const
{ return GG::Wnd::Create<CUIScroll>(orientation); }
std::shared_ptr<GG::Slider<int>> CUIStyle::NewIntSlider(int min, int max, GG::Orientation orientation,
GG::Clr color, int tab_width, int line_width) const
{ return GG::Wnd::Create<CUISlider<int>>(min, max, orientation); }
std::shared_ptr<GG::TabBar> CUIStyle::NewTabBar(const std::shared_ptr<GG::Font>& font, GG::Clr color,
GG::Clr text_color) const
{ return GG::Wnd::Create<CUITabBar>(font, color, text_color); }
std::shared_ptr<GG::Button> CUIStyle::NewScrollUpButton(GG::Clr color) const
{ return nullptr; }
std::shared_ptr<GG::Button> CUIStyle::NewScrollDownButton(GG::Clr color) const
{ return NewScrollUpButton(color); }
std::shared_ptr<GG::Button> CUIStyle::NewVScrollTabButton(GG::Clr color) const
{
return GG::Wnd::Create<CUIScroll::ScrollTab>(GG::Orientation::VERTICAL, 1,
(color == GG::CLR_ZERO) ? ClientUI::CtrlColor() : color,
ClientUI::CtrlBorderColor());
}
std::shared_ptr<GG::Button> CUIStyle::NewScrollLeftButton(GG::Clr color) const
{ return NewScrollUpButton(color); }
std::shared_ptr<GG::Button> CUIStyle::NewScrollRightButton(GG::Clr color) const
{ return NewScrollUpButton(color); }
std::shared_ptr<GG::Button> CUIStyle::NewHScrollTabButton(GG::Clr color) const
{
return GG::Wnd::Create<CUIScroll::ScrollTab>(GG::Orientation::HORIZONTAL, 1,
(color == GG::CLR_ZERO) ? ClientUI::CtrlColor() : color,
ClientUI::CtrlBorderColor());
}
std::shared_ptr<GG::Button> CUIStyle::NewVSliderTabButton(GG::Clr color) const
{ return GG::Wnd::Create<CUIScroll::ScrollTab>(GG::Orientation::VERTICAL, 0, ClientUI::CtrlColor(), ClientUI::CtrlBorderColor()); }
std::shared_ptr<GG::Button> CUIStyle::NewHSliderTabButton(GG::Clr color) const
{ return GG::Wnd::Create<CUIScroll::ScrollTab>(GG::Orientation::HORIZONTAL, 0, ClientUI::CtrlColor(), ClientUI::CtrlBorderColor()); }
std::shared_ptr<GG::Button> CUIStyle::NewSpinIncrButton(
const std::shared_ptr<GG::Font>& font, GG::Clr color) const
{ return GG::Wnd::Create<CUIArrowButton>(ShapeOrientation::UP, false, GG::INTERACTIVE | GG::REPEAT_BUTTON_DOWN); }
std::shared_ptr<GG::Button> CUIStyle::NewSpinDecrButton(
const std::shared_ptr<GG::Font>& font, GG::Clr color) const
{ return GG::Wnd::Create<CUIArrowButton>(ShapeOrientation::DOWN, false, GG::INTERACTIVE | GG::REPEAT_BUTTON_DOWN); }
std::shared_ptr<GG::StateButton> CUIStyle::NewTabBarTab(
std::string str, const std::shared_ptr<GG::Font>& font,
GG::Flags<GG::TextFormat> format, GG::Clr color,
GG::Clr text_color) const
{
auto retval = GG::Wnd::Create<CUIStateButton>(std::move(str), format, std::make_shared<CUITabRepresenter>());
retval->SetColor(ClientUI::WndColor());
retval->GetLabel()->SetTextColor(DarkenClr(ClientUI::TextColor()));
retval->Resize(retval->MinUsableSize() + GG::Pt(GG::X(12), GG::Y0));
return retval;
}
std::shared_ptr<GG::Button> CUIStyle::NewTabBarLeftButton(
const std::shared_ptr<GG::Font>& font,
GG::Clr color, GG::Clr text_color) const
{ return GG::Wnd::Create<CUIArrowButton>(ShapeOrientation::LEFT, true, GG::INTERACTIVE); }
std::shared_ptr<GG::Button> CUIStyle::NewTabBarRightButton(
const std::shared_ptr<GG::Font>& font,
GG::Clr color, GG::Clr text_color) const
{ return GG::Wnd::Create<CUIArrowButton>(ShapeOrientation::RIGHT, true, GG::INTERACTIVE); }
|