22 kTerminalWidth(static_cast<int>(gui_list.size() + 2)* kButtonSize)
29 for (
int i = 0; i < gui_list_.size(); ++i)
35 const std::vector<std::string> unnecessary_words = {
"DxlibGui",
" ",
"const",
"*",
"&" };
37 for (
const auto& word : unnecessary_words)
40 if (class_name.find(word) == std::string::npos) {
continue; }
43 class_name.erase(class_name.find(word), word.size());
47 for (
int j = 7; j < class_name.size(); j += 7)
49 class_name.insert(j,
"\n");
53 button_list_.push_back(
54 std::make_shared<SimpleButton>(class_name,
55 kLeftTopX + kButtonSize + i * 100, kLeftTopY + kTerminalHeight / 2, kButtonSize, kButtonSize));
57 button_list_.back()->SetActivateFunction([
this, i]() { gui_list_[i]->SetVisible(
true); });
59 button_list_.back()->SetVisible(
false);
66 for (
auto& button : button_list_)
83 for (
const auto& button : button_list_)
105 bool is_clicked =
false;
108 for (
auto& button : button_list_)
112 button->ClickedAction(state);
130 for (
auto& button : button_list_)
132 button->SetVisible(
true);
140 for (
auto& button : button_list_)
142 button->SetVisible(
false);
151 return cursor_x >= kLeftTopX && cursor_x <= kLeftTopX + kClosedTerminalWidth &&
152 cursor_y >= kLeftTopY && cursor_y <= kLeftTopY + kTerminalHeight;
156 return cursor_x >= kLeftTopX && cursor_x <= kLeftTopX + kTerminalWidth &&
157 cursor_y >= kLeftTopY && cursor_y <= kLeftTopY + kTerminalHeight;
161void DxlibGuiTerminal::DrawClosedTerminal()
const
163 const int closed_box_width = kClosedTerminalWidth - 20;
165 const unsigned int base_color = GetColor(255, 255, 255);
166 const unsigned int frame_color = GetColor(30, 30, 30);
167 const unsigned int alpha = 200;
169 const int frame_width = 1;
171 SetDrawBlendMode(DX_BLENDMODE_ALPHA, alpha);
173 DrawBox(kLeftTopX - frame_width, kLeftTopY - frame_width,
174 kLeftTopX + closed_box_width, kLeftTopY + kTerminalHeight + frame_width, frame_color, TRUE);
176 kLeftTopX + closed_box_width, kLeftTopY - frame_width,
177 kLeftTopX + closed_box_width, kLeftTopY + kTerminalHeight + frame_width,
178 kLeftTopX + kClosedTerminalWidth + frame_width, kLeftTopY + kTerminalHeight / 2,
181 DrawBox(kLeftTopX, kLeftTopY, kLeftTopX + closed_box_width, kLeftTopY + kTerminalHeight, base_color, TRUE);
182 DrawTriangleAA(kLeftTopX + closed_box_width, kLeftTopY, kLeftTopX + closed_box_width, kLeftTopY + kTerminalHeight,
183 kLeftTopX + kClosedTerminalWidth, kLeftTopY + kTerminalHeight / 2, base_color, TRUE);
185 SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
188void DxlibGuiTerminal::DrawTerminal()
const
190 const int closed_box_width = kTerminalWidth - 20;
192 const unsigned int base_color = GetColor(255, 255, 255);
193 const unsigned int frame_color = GetColor(30, 30, 30);
194 const unsigned int alpha = 200;
196 const int frame_width = 1;
198 SetDrawBlendMode(DX_BLENDMODE_ALPHA, alpha);
200 DrawBox(kLeftTopX - frame_width, kLeftTopY - frame_width,
201 kLeftTopX + closed_box_width, kLeftTopY + kTerminalHeight + frame_width, frame_color, TRUE);
203 static_cast<float>(kLeftTopX + closed_box_width),
static_cast<float>(kLeftTopY - frame_width),
204 static_cast<float>(kLeftTopX + closed_box_width),
static_cast<float>(kLeftTopY + kTerminalHeight + frame_width),
205 static_cast<float>(kLeftTopX + kTerminalWidth + frame_width),
static_cast<float>(kLeftTopY + kTerminalHeight / 2),
208 DrawBox(kLeftTopX, kLeftTopY, kLeftTopX + closed_box_width, kLeftTopY + kTerminalHeight, base_color, TRUE);
210 static_cast<float>(kLeftTopX + closed_box_width),
static_cast<float>(kLeftTopY),
211 static_cast<float>(kLeftTopX + closed_box_width),
static_cast<float>(kLeftTopY + kTerminalHeight),
212 static_cast<float>(kLeftTopX + kTerminalWidth),
static_cast<float>(kLeftTopY + kTerminalHeight / 2),
215 SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
218void DxlibGuiTerminal::DrawButtonGuard()
const
220 for (
int i = 0; i < button_list_.size(); ++i)
224 const unsigned int color = GetColor(45, 45, 45);
225 const int alpha = 200;
227 SetDrawBlendMode(DX_BLENDMODE_ALPHA, alpha);
229 DrawBox(button_list_[i]->GetPosMiddleX() - kButtonSize / 2, button_list_[i]->GetPosMiddleY() - kButtonSize / 2,
230 button_list_[i]->GetPosMiddleX() + kButtonSize / 2, button_list_[i]->GetPosMiddleY() + kButtonSize / 2, color, TRUE);
232 SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
bool CursorOnGui(int cursor_x, int cursor_y) const noexcept
GUIの上にカーソルがあるかどうかを返す.
DxlibGuiTerminal()=delete
void Draw() const override
GUIの描画.
void SetVisible(bool visible)
GUIの表示を行うかどうかを設定する.
void Update() override
GUIの更新,毎フレーム実行すること.
bool IsVisible() const
GUIの表示を行うかどうかを返す.
void ClickedAction(const DxlibMouseState &state)
GUIがクリックされたときに実行される関数. CursorOnGuiが true を返すときに呼び出される. 複数のGUIが重なっている場合は,優先度の高いものから順に呼び出される.
std::string GetTypeName(const T &type)
int cursor_y
マウスカーソルのY座標.上端を0とし,下に正の値をとる.
int left_pushing_count
マウスの左ボタンが押されているフレーム数.
int cursor_x
マウスカーソルのX座標.左端を0とし,右に正の値をとる.