2 #include "Utils/Logger.hpp" 5 #include <tinyfiledialogs/tinyfiledialogs.h> 11 #pragma warning(disable : 4996) 24 lWillBeGraphicMode = tinyfd_inputBox(
"tinyfd_query",
nullptr,
nullptr);
31 strcat(lBuffer, tinyfd_version);
35 strcat(lBuffer,
"\ngraphic mode: ");
41 strcat(lBuffer, tinyfd_response);
42 strcat(lBuffer,
"\n");
43 strcat(lBuffer, tinyfd_needs + 78);
44 strcpy(lString,
"hello");
45 tinyfd_messageBox(lString, lBuffer,
"ok",
"info", 0);
47 tinyfd_notifyPopup(
"the title",
"the message\n\tfrom outer-space",
"info");
51 InputDialog::InputDialog(std::string _description)
53 if (_description.empty())
55 LOG(INFO) <<
"No description passed!\n Better don't enter anything? ;)";
58 description = _description;
59 title =
"Give me some input";
63 std::string InputDialog::run()
65 userInput = std::string(tinyfd_inputBox(
66 title.c_str(), description.c_str(),
nullptr));
71 ErrorDialog::ErrorDialog(std::string _message)
75 LOG(INFO) <<
"No message passed!";
83 std::string ErrorDialog::run()
95 QuestionDialog::QuestionDialog(std::string _question) :
98 if (_question.empty())
100 LOG(INFO) <<
"No question passed!\n Dialog is useless.";
103 question = _question;
108 bool QuestionDialog::getBResult()
110 if (result.compare(
"Yes") == 0)
114 if (result.compare(
"No") == 0)
118 LOG(INFO) <<
"Invalid answer.";
125 std::string QuestionDialog::run()
128 if (lWillBeGraphicMode && !tinyfd_forceConsole)
130 lIntValue = tinyfd_messageBox(title.c_str(),
132 "yesno",
"question", 1);
133 tinyfd_forceConsole = !lIntValue;
137 case 0: result =
"No";
break;
138 case 1: result =
"Yes";
break;
149 FilesystemDialog::FilesystemDialog(std::string _startFolder)
151 if (_startFolder.empty())
153 LOG(INFO) <<
"No start folder passed!\nSetting to c:/.";
158 startFolder = _startFolder;
164 ChooseFolderDialog::ChooseFolderDialog(std::string _startFolder) :
167 title =
"Choose folder..";
171 std::string ChooseFolderDialog::run()
173 lTheSelectFolderName = tinyfd_selectFolderDialog(
174 "let us just select a directory",
nullptr);
175 result = std::string(lTheSelectFolderName);
180 SaveFileDialog::SaveFileDialog(std::string _startFolder, std::string _data) :
188 std::string SaveFileDialog::run()
190 lTheSaveFileName = tinyfd_saveFileDialog(
197 result = std::string(lTheSaveFileName);
200 lIn = fopen(lTheSaveFileName,
"w");
205 "Can not open this file in write mode",
211 fputs(data.c_str(), lIn);
218 LoadFileDialog::LoadFileDialog(std::string _startFolder) :
225 std::string LoadFileDialog::run()
227 lTheOpenFileName = tinyfd_openFileDialog(
235 result = std::string(lTheOpenFileName);
237 lIn = fopen(lTheOpenFileName,
"r");
242 "Can not open this file in write mode",
249 fgets(lBuffer,
sizeof(lBuffer), lIn);