51 ret->_txtTitle = txt_title;
54 ret->_btnClose = btn_close;
65 ret->_coor = _coor->
Clone();
66 ret->_bg = _bg->
Clone();
67 ret->_btn = _btn->
Clone();
68 ret->_btnClose = _btnClose->
Clone();
70 for (
size_t i = 0; i < _allBtn.size(); ++i)
72 ret->_allBtn[i] = _allBtn[i]->Clone();
85 void Set(std::string_view title, std::string_view info, std::vector<std::string_view> all_btn)
89 _txt->
SetString(std::string{
"\t" } + std::string{ info });
94 _numBtn = all_btn.size();
95 if (_numBtn > _allBtn.size())
97 _allBtn.resize(_numBtn);
107 for (std::size_t i = 0; i < _numBtn; ++i)
109 _allBtn[i]->SetString(all_btn[i]);
116 Float w = w_btn * _numBtn + _dxBtn * (1 + _numBtn);
123 Float h = h_title + h_txt * 1 + h_btn * 1;
137 Float sx_btn = (w_btn * _numBtn + _dxBtn * (_numBtn - 1)) * -0.5 + w_btn * 0.5;
138 for (std::size_t i = 0; i < _numBtn; ++i)
140 _allBtn[i]->GetCoor()->SetPosition({ sx_btn + i * (w_btn + _dxBtn), size_half[1] });
149 void Set(std::string_view str)
151 std::string_view str_title =
lang(
"msg_box", std::string{ str } +
"_title");
152 std::string_view str_info =
lang(
"msg_box", std::string{ str } +
"_info");
153 std::vector<std::string_view> all_btn;
156 std::string str_name = format(
"{}_{}", str, i);
158 if (!str.has_value())
162 all_btn.push_back(str.value());
165 Set(str_title, str_info, all_btn);
171 for (
size_t i = 0; i < _numBtn; ++i)
173 _allBtn[i]->Update();
208 for (
size_t i = 0; i < _numBtn; ++i)
210 if (_allBtn[i]->IsClick())
230 if (pos[1] < _txtTitle->
GetSize()[1])
242 for (
auto& iter : _allBtn)
255 for (
auto& iter : _allBtn)
276 std::vector<UI::ButtonSprite*> _allBtn;
281 std::optional<Position> _posPick;
292 for (
size_t i = 0; i < _allBtn.size(); ++i)
294 _allBtn[i]->GetCoor()->SetParent(_coor);
void SetOrder(float order)
void SetSize(const Size &size)
void SetParent(Coor *coor)
Position WorldToThis(Position pos) const
将点 从 世界坐标系 转到 自身坐标系
static Coor * Create(Coor *parent=nullptr)
void SetPosition(const Position &pos)
std::optional< std::string_view > GetCheck(std::string_view tag, std::string_view name)
失败返回false
Size GetWindowSize()
返回窗口大小
void SetMaxW(unsigned w)
设置自动换行宽度,0为不自动换行
void SetPositionAlign(const Position &pos={}, const Align::Direction2 &dir={ Align::Direction::BACK, Align::Direction::BACK })
设置Coor位置,来整体对齐
void SetOrder(float order)
设置绘制顺序
void SetCenter(const Position &pos={})
设置Coor位置,并根据整体大小居中
void SetString(std::string_view str)
设置内容
void Set(std::string_view title, std::string_view info, std::vector< std::string_view > all_btn)
设置内容
void SetOrder(float order)
void Set(std::string_view str)
设置内容,以语言文件配置的名称
bool IsClickClose()
是否点击了关闭按钮
size_t GetClick()
返回点击按钮索引,返回-1代表没有点击
static MsgBox * Create(Background *bg, gcText txt_title, gcText txt, UI::ButtonSprite *btn, UI::ButtonSprite *btn_close, Float dx_btn=0.0)
构造
bool IsPickupTitle()
是否选中标题栏
constexpr float OffsetOrder(float order, int u=1, int v=0, int w=0)
偏移order
std::array< unsigned, N > CastU(const std::array< T, N > &a, bool show_log=true)
有符号转无符号,并且判断负数
constexpr size_t NUM_MSG_BOX_BTN
消息框最大按钮数量
constexpr float Z_DEFAULT_UI
std::string_view lang(std::string_view tag, std::string_view name)
返回一个语言配置的字符串,传入 menu、start
constexpr std::array< Point::value_type, N > toPoint(const std::array< T, N > &a)
constexpr std::array< Position::value_type, N > toPosition(const std::array< T, N > &a)