Skip to content

Commit d40c502

Browse files
TerminalAppGen3 v0.3.0
1 parent af17e8f commit d40c502

12 files changed

+2673
-73
lines changed

CommandFiles/CommandFileAssets.cpp

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,90 @@ void ColourForegroundSwitch(int* nChoice, std::string* sSettingVariableBack, std
153153
}
154154

155155
return;
156-
}
156+
}
157+
158+
// A switch-case function for the MessageBox command (icon).
159+
int MessageBoxIconSwitch(std::string sIconName) {
160+
// Make argument lowercase
161+
for (int i = 0; i < sIconName.length(); i++) {
162+
sIconName[i] = std::tolower(sIconName[i]);
163+
}
164+
165+
if (sIconName == "error") {
166+
return 16;
167+
}
168+
else if (sIconName == "question") {
169+
return 32;
170+
}
171+
else if (sIconName == "warning") {
172+
return 48;
173+
}
174+
else if (sIconName == "info") {
175+
return 64;
176+
}
177+
else {
178+
colour(RED, sColourGlobalBack);
179+
std::cerr << wordWrap("ERROR - The specified icon argument seems to be incorrect.\nPlease add one from the list of icon options.\nSee 'messagebox -h' for more info.\n");
180+
colour(sColourGlobal, sColourGlobalBack);
181+
return 1;
182+
}
183+
184+
return 1;
185+
}
186+
187+
// A switch-case function for the MessageBox command (buttons)
188+
int MessageBoxButtonSwitch(std::string sButtonName) {
189+
// Make argument lowercase
190+
for (int i = 0; i < sButtonName.length(); i++) {
191+
sButtonName[i] = std::tolower(sButtonName[i]);
192+
}
193+
194+
if (sButtonName == "ok") {
195+
return 0;
196+
}
197+
else if (sButtonName == "okcancel") {
198+
return 1;
199+
}
200+
else if (sButtonName == "abortretryignore") {
201+
return 2;
202+
}
203+
else if (sButtonName == "yesnocancel") {
204+
return 3;
205+
}
206+
else if (sButtonName == "yesno") {
207+
return 4;
208+
}
209+
else if (sButtonName == "retrycancel") {
210+
return 5;
211+
}
212+
else if (sButtonName == "canceltrycontinue") {
213+
return 6;
214+
}
215+
else {
216+
colour(RED, sColourGlobalBack);
217+
std::cerr << wordWrap("ERROR - Your button argument seems to be incorrect.\nPlease make sure it is from the list of button options.\nSee 'messagebox -h' for more info. Using default option...\n");
218+
colour(sColourGlobal, sColourGlobalBack);
219+
220+
return 0;
221+
}
222+
223+
return 0;
224+
}
225+
226+
/* MessageBox Codes */
227+
//////////////////////
228+
/* Message box codes are the following for icons:
229+
[16] Error
230+
[32] Question Mark
231+
[48] Exclamation Mark
232+
[64] Information 'I'
233+
*/
234+
/* Message box codes are the following for buttons:
235+
[0] OK
236+
[1] OK + Cancel
237+
[2] Abort + Retry + Ignore
238+
[3] Yes + No + Cancel
239+
[4] Yes + No
240+
[5] Retry + Cancel
241+
[6] Cancel + Try Again + Continue
242+
*/

0 commit comments

Comments
 (0)