Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct IDialogItem
- {
- virtual ~IDialogItem() {}
- virtual void Render() {}
- };
- class Dialog
- {
- public:
- Dialog(const std::string& title) : mTitle(title) {}
- void Add(IDialogItem* pItem)
- {
- mItems.push_back(std::unique_ptr<IDialogItem>(pItem));
- }
- void Render() {
- ImGui::SetNextWindowPos(ImVec2(Speed::DX9::screenWidth * 0.5f, Speed::DX9::screenHeight * 0.5f), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
- ImGui::Begin(mTitle.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse);
- for (auto& item : mItems)
- {
- item->Render();
- }
- ImGui::End();
- }
- private:
- std::string mTitle;
- std::vector<std::unique_ptr<IDialogItem>> mItems;
- };
- class IGText : public IDialogItem
- {
- public:
- IGText(const std::string& text) : mText(text) {}
- void Render() {
- ColoredChat::TextWithColors("%s", mText.c_str());
- }
- private:
- std::string mText;
- };
- class IGBulletText : public IDialogItem
- {
- public:
- IGBulletText(const std::string& text) : mText(text) {}
- void Render() {
- ColoredChat::TextWithColors("%s", mText.c_str());
- }
- private:
- std::string mText;
- };
- class IGSameLine : public IDialogItem
- {
- public:
- void Render() {
- ImGui::SameLine();
- }
- };
- class IGButton : public IDialogItem
- {
- public:
- IGButton(const std::string& text, bool* pClicked) : mpClicked(pClicked), mText(text) {}
- void Render() {
- *mpClicked = ImGui::Button(mText.c_str());
- }
- private:
- std::string mText;
- bool* mpClicked;
- };
- class DialogBuilder
- {
- public:
- DialogBuilder(const std::string title) : mDialog(title) {}
- DialogBuilder& Text(const std::string& text) {
- mDialog.Add(new IGText(text));
- return *this;
- }
- DialogBuilder& BulletText(const std::string& text) {
- mDialog.Add(new IGBulletText(text));
- return *this;
- }
- DialogBuilder& SameLine() {
- mDialog.Add(new IGSameLine());
- return *this;
- }
- DialogBuilder& Button(const std::string& text, bool& clicked) {
- mDialog.Add(new IGButton(text, &clicked));
- return *this;
- }
- Dialog& Get() {
- return mDialog;
- }
- private:
- Dialog mDialog;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement