14#ifndef DL_DISABLE_RENDER
52 ret->_txtTitle = txt_title;
55 ret->_btnClose = btn_close;
66 ret->_coor = _coor->
Clone();
67 ret->_bg = _bg->
Clone();
68 ret->_btn = _btn->
Clone();
69 ret->_btnClose = _btnClose->
Clone();
71 for (
size_t i = 0; i < _allBtn.size(); ++i)
73 ret->_allBtn[i] = _allBtn[i]->Clone();
86 void Set(std::string_view title, std::string_view info, std::vector<std::string_view> all_btn)
90 _txt->
SetString(std::string{
"\t" } + std::string{ info });
95 _numBtn = all_btn.size();
96 if (_numBtn > _allBtn.size())
98 _allBtn.resize(_numBtn);
108 for (std::size_t i = 0; i < _numBtn; ++i)
110 _allBtn[i]->SetString(all_btn[i]);
117 Float w = w_btn * _numBtn + _dxBtn * (1 + _numBtn);
124 Float h = h_title + h_txt * 1 + h_btn * 1;
138 Float sx_btn = (w_btn * _numBtn + _dxBtn * (_numBtn - 1)) * -0.5_f + w_btn * 0.5_f;
139 for (std::size_t i = 0; i < _numBtn; ++i)
141 _allBtn[i]->GetCoor()->SetPosition({ sx_btn + i * (w_btn + _dxBtn), size_half[1] });
150 void Set(std::string_view str)
152 std::string_view str_title =
lang(
"msg_box", std::string{ str } +
"_title");
153 std::string_view str_info =
lang(
"msg_box", std::string{ str } +
"_info");
154 std::vector<std::string_view> all_btn;
157 std::string str_name = fmt::format(
"{}_{}", str, i);
159 if (!str.has_value())
163 all_btn.push_back(str.value());
166 Set(str_title, str_info, all_btn);
172 for (
size_t i = 0; i < _numBtn; ++i)
174 _allBtn[i]->Update();
209 for (
size_t i = 0; i < _numBtn; ++i)
211 if (_allBtn[i]->IsClick())
231 if (pos[1] < _txtTitle->
GetSize()[1])
243 for (
auto& iter : _allBtn)
256 for (
auto& iter : _allBtn)
277 std::vector<UI::ButtonSprite*> _allBtn;
282 std::optional<Position> _posPick;
293 for (
size_t i = 0; i < _allBtn.size(); ++i)
295 _allBtn[i]->GetCoor()->SetParent(_coor);
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为不自动换行
bool SetString(std::string_view str)
设置内容
void SetPositionAlign(const Position &pos={}, const Align::Direction2 &dir=Align::LT)
设置Coor位置,来整体对齐
void SetOrder(float order)
设置绘制顺序
void SetCenter(const Position &pos={})
设置Coor位置,并根据整体大小居中
void SetSize(const Size &size)
void SetOrder(float order)
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
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< Size::value_type, N > toSizeNeg2Zero(const std::array< T, N > &a)
转换到Size,出现负数时转为0
constexpr std::array< Point::value_type, N > toPoint(const std::array< T, N > &a)
转换到Point,已知长度
constexpr std::array< Position::value_type, N > toPosition(const std::array< T, N > &a)
转换到Position,已知长度