void Ide::ExportProject(const String& ep, bool all, bool gui, bool deletedir) { SaveFile(false); ::Workspace wspc; wspc.Scan(main); Index<String> used; HdependClearDependencies(); for(int i = 0; i < wspc.GetCount(); i++) { const Package& p = wspc.GetPackage(i); String pn = wspc[i]; for(int j = 0; j < p.GetCount(); j++) { const Package::File& f = p[j]; if(!f.separator) { String p = SourcePath(pn, f); used.FindAdd(p); Vector<String> d = HdependGetDependencies(p); for(int q = 0; q < d.GetCount(); q++) used.FindAdd(d[q]); for(int q = 0; q < f.depends.GetCount(); q++) used.FindAdd(SourcePath(pn, f.depends[q].text)); } } } if(FileExists(ep)) { if(gui && !PromptYesNo(DeQtf(ep) + " is existing file.&" "Do you want to delete it?")) return; FileDelete(ep); } if(deletedir && DirectoryExists(ep)) { if(gui && !PromptYesNo(DeQtf(ep) + " is existing directory.&" "Do you want to replace it?")) return; DeleteFolderDeep(ep); } Progress pi("Exporting project"); pi.SetTotal(wspc.GetCount()); for(int i = 0; i < wspc.GetCount(); i++) { if(gui && pi.StepCanceled()) return; CopyFolder(AppendFileName(ep, wspc[i]), PackageDirectory(wspc[i]), used, all, true); } Vector<String> upp = GetUppDirs(); for(int i = 0; i < upp.GetCount(); i++) { if(gui && pi.StepCanceled()) return; String d = upp[i]; FindFile ff(AppendFileName(d, "*")); while(ff) { if(ff.IsFile()) { String fn = ff.GetName(); String path = AppendFileName(d, fn); if(all || used.Find(path) >= 0) CopyFile(AppendFileName(ep, fn), path, true); } ff.Next(); } CopyFolder(AppendFileName(ep, wspc[i]), PackageDirectory(wspc[i]), used, all, true); } ExportMakefile(ep); }
int ConvertV1toV2(FILE *in, FILE *out) { int flags = 0, reset; unsigned char buf[0x60]; if (PromptYesNo("Recorded in PAL mode?")) { flags |= 2; } if (PromptYesNo("Recorded in Japan mode?")) { flags |= 4; } fread(buf, 0x60, 1, in); reset = *(int *)(buf + 0x10); *(int *)(buf + 0x14) = reset ? 0 : 0x64; *(int *)(buf + 0x18) = reset ? 0x64 : 0x64+25088; fwrite(buf, 0x60, 1, out); fwrite(&flags, 4, 1, out); CopyRest(in, out); return 1; }
void MapEditor::OnRemoveLevel() { int row = LevelList.GetCurrentRow(); if (row < 0) return; if (!PromptYesNo(t_("Remove the selected level from map?"))) return; if (!PromptYesNo(t_("No undo for this action. Are you sure?"))) return; _map.GetLevels().Remove(row); UpdateLevelList(); }
void WorkspaceWork::DelFile() { if(!filelist.IsCursor() || filelist[fileindex[filelist.GetCursor()]].isdir) return; String file = GetActiveFilePath(); if(IsFolder(file)) { if(!PromptYesNo("Remove the topic group and discard ALL topics?")) return; RemoveFile(); DeleteFolderDeep(file); } else { if(!PromptYesNo("Remove the file from package and discard it ?")) return; RemoveFile(); ::DeleteFile(file); } }
bool GuiPackageResolver(const String& error, const String& path, int line) { prompt: switch(Prompt(Ctrl::GetAppName(), CtrlImg::exclamation(), error + "&while parsing package " + DeQtf(path), "Edit \\& Retry", "Ignore", "Stop")) { case 0: if(!PromptYesNo("Ignoring will damage package. Everything past the " "point of error will be lost.&Do you want to continue ?")) goto prompt; return false; case 1: { TopWindow win; LineEdit edit; edit.Set(LoadFile(path)); edit.SetCursor(edit.GetPos(line)); win.Title(path); win.Add(edit.SizePos()); win.Run(); SaveFile(path, edit.Get()); } return true;; case -1: exit(1); } return false; }
void WorkspaceWork::RemovePackage(String from_package) { String active = UnixPath(GetActivePackage()); if(IsNull(from_package) && !PromptYesNo(NFormat( "Remove package [* \1%s\1] from uses sections of all current packages ?", active))) return; PackageOp(GetActivePackage(), from_package, Null); }
void SelectPackageDlg::DeletePackage() { String n = GetCurrentName(); if(IsNull(n)) return; String pp = GetFileFolder(PackagePath(GetCurrentName())); if(!DirectoryExists(pp)) { Exclamation("Directory does not exist!"); return; } if(!PromptYesNo("Do you really want to delete package [* \1" + GetCurrentName() + "\1]?&&" "[/ Warning:] [* Package will not be removed " "from uses of any other package!]")) return; if(!PromptYesNo("This operation is irreversible.&Do you really want to proceed?")) return; DeleteFolderDeep(pp); Load(); }
///////////////////////////////////////////////////////////////////////////////////// // cancel pdf creation handler void TPdfFrontend::onCancel(void) { if(DocumentList.GetCount() == 0 || PromptYesNo("Annullare la generazione ?")) { // remove pending poststript documents and closes app ClearDocuments(); Break(0); } } // END TPdfFrontend::onCancel()
void LayoutDesigner::RemoveLayout() { if(layouti < 0) return; if(PromptYesNo("Remove current layout ?")) { int i = layouti; SetLayout(-1); layout.Remove(i); SetupLayoutList(); SetLayout(min(i, layout.GetCount() - 1)); Refresh(); } }
void Ide::CleanUppOut() { String out = GetVar("OUTPUT"); if(!PromptYesNo(NFormat("Erase the whole output directory [* \1%s\1]?", out))) return; console.Clear(); PutConsole("UPPOUT cleanup..."); DeleteFolderDeep(out); PutConsole("(done)"); HideBottom(); }
void WorkspaceWork::DeletePackage() { String active = GetActivePackage(); if(package.GetCursor() == 0) { Exclamation("Cannot delete the main package!"); return; } if(IsAux() || !package.IsCursor() || !PromptYesNo("Do you really want to delete package [* \1" + active + "\1]?&&" "[/ Warning:] [* Package will only be removed&" "from packages of current workspace!]")) return; if(!PromptYesNo("This operation is irreversible.&Do you really want to proceed?")) return; if(!DeleteFolderDeep(GetFileFolder(GetActivePackagePath()))) { Exclamation("Deleting directory has failed."); return; } PackageOp(active, Null, Null); }
// app started, must check for update/install requests // returns true if app must continue execution, false otherwise bool Updater::DO_NormalRun(void) { // we now check if we just want to uninstall app // it can be done by command line --UNINSTALL option if(CommandLine().GetCount() && CommandLine()[0] == "--UNINSTALL") return START_Uninstall(); // if app not installed, we shall install it // (if any available version is present on server....) if(!appInstalled) { // fetch available application versions ProductVersions versions = FetchVersions(); // if versions present on server, install latest if(versions.GetCount()) return START_Install(); // otherwise resume execution -- it's an uninstalled run else return true; } // not installing nor uninstalling // we shall check which kind of update is enabled String updateMode; if(!FileExists(AppendFileName(userConfigPath, "UPDATER_MODE"))) { updateMode = "ASK"; SaveFile(AppendFileName(userConfigPath, "UPDATER_MODE"), updateMode); } else updateMode = LoadFile(AppendFileName(userConfigPath, "UPDATER_MODE")); // if updates are disabled, just do nothing if(updateMode == "DISABLED") return true; // if we don't have a new version available, just do nothing ProductVersion maxVer; if( (maxVer = FetchMaxValidVersion(acceptDevelVersions)) <= installedVersion) return true; // if we want manual updates, just ask if(updateMode == "ASK") if(!PromptYesNo(Format(t_("New version '%s' is available&Install it ?"), maxVer.ToString()))) return true; // updater enabled, start it // if update failed, resume normal run, otherwise exit // as the app will be launched again by updater itself return START_Update(); }
// install app // returns true if app must continue execution, false otherwise bool Updater::START_Install(void) { if(confirmInstall && !PromptYesNo(Format(t_("Install '%s' application?"), appName))) { state = InstallAborted; return true; } if(START_Updater("INSTALL")) { state = InstallFailed; return true; } return false; }
// uninstall app // returns true if app must continue execution, false otherwise bool Updater::START_Uninstall(void) { if(confirmUninstall && !PromptYesNo(Format(t_("This will remove '%s' application&Continue ?"), appName))) { state = UninstallAborted; return true; } if(START_Updater("UNINSTALL")) { state = UninstallFailed; return true; } return false; }
void LevelEditor::OnItemRemove() { int layer = LayerList.GetCurrentRow(); if (layer < 0) return; Layer& lay = _level->GetLayers()[layer]; int row = ItemList.GetCurrentRow(); if (row < 0) return; if (!PromptYesNo(t_("Remove the selected item from level?"))) return; lay.GetRooms().Remove(row); UpdateItemList(); }
void IdeIconDes::Save() { if(format == 1) { for(int i = 0; i < GetCount(); i++) { Image m = GetImage(i); Point p = m.Get2ndSpot(); if(m.GetKind() == IMAGE_ALPHA || p.x || p.y) { if(PromptYesNo("Legacy file format does not support images " "with full alpha channel or 2nd hotspot - " "the information would be lost.&" "Do you wish to convert the file to the new format?")) { format = 0; } break; } } } StoreToGlobal(*this, "icondes-ctrl"); Array<ImlImage> m; VectorMap<Size, Image> exp; String folder = GetFileFolder(filename); for(int i = 0; i < GetCount(); i++) { ImlImage& c = m.Add(); c.name = GetName(i); c.image = GetImage(i); c.exp = GetExport(i); if(c.exp) { Size sz = c.image.GetSize(); exp.GetAdd(sz) = c.image; PNGEncoder png; SaveChangedFile(AppendFileName(folder, String().Cat() << "icon" << sz.cx << 'x' << sz.cy << ".png"), png.SaveString(c.image)); } } String d = SaveIml(m, format); if(!SaveChangedFileFinish(filename, d)) return; filetime = FileGetTime(filename); if(exp.GetCount()) SaveChangedFile(AppendFileName(folder, "icon.ico"), WriteIcon(exp.GetValues())); }
void TestLeptonica::onPageLayout() { String fileName; FileSelector fs; Pix source; if(!PromptYesNo( "[= [* Page layout analysis demo]&&" "Please select a 1 bpp scanned image with mixed text and graphics&" "you can take one from TestLeptonica folder if you like&&" "[* CONTINUE ??]]" )) return; fs.ReadOnlyOption(); if(fs.ExecuteOpen("Please select image for page layout analysis:")) { FileIn s; if(!s.Open(~fs)) { PromptOK("Error opening image"); s.Close(); return; } // Loads pixraster from source raster CHECKR(source.Load(s), "Error loading image"); s.Close(); // apply line removal algothithm pixRaster.Clear(); PageLayout(source, pixRaster); // refresh the PixRasterCtrl control with the new image contents pixRasterCtrl.Reload(); pixRasterCtrl.SetPage(0); } }
void SelectPackageDlg::OnNew() { TemplateDlg dlg; LoadFromGlobal(dlg, "NewPackage"); int f = ~filter; dlg.Load(GetUppDirs(), f & MAIN); while(dlg.Run() == IDOK) { String nest = ~dlg.nest; String name = NativePath(String(~dlg.package)); String path = AppendFileName(nest, AppendFileName(name, GetFileName(name) + ".upp")); if(FileExists(path) && !PromptYesNo("Package [* \1" + path + "\1] already exists.&" "Do you wish to recreate the files?")) continue; RealizePath(path); if(!SaveFile(path, Null)) { Exclamation("Error writing the file [* \1" + path + "\1]."); continue; } dlg.Create(); selected = name; Break(IDYES); break; } StoreToGlobal(dlg, "NewPackage"); }
void MapEditor::CalculateAllPrompt() { if (PromptYesNo(t_("Recalculate all mipmaps for levels?"))) for (int i = 0; i < _map.GetLevels().GetCount(); ++i) OnLevelMapCalc( _map.GetLevels()[i], i ); }
void Puzzle::New() { if(PromptYesNo(t_("Start a new game?"))) Generate(); }
// default set of prompts for installer result // just an handy shortcut good for most cases bool Updater::DefaultPrompts(void) { // fine grained behaviour depending on update state switch(GetState()) { case UninstallFailed: Exclamation(Format(t_("Uninstall of '%s' failed&Press OK to quit"), appName)); return false; case UninstallSucceeded: PromptOK(Format(t_("Uninstall of '%s' complete&Press OK to quit"), appName)); return false; case UninstallAborted: return false ; case InstallFailed: switch(installBehaviour) { case AskUser : if(!PromptYesNo(Format(t_("Install of '%s' failed&Run without installing?"), appName))) return false; break; case AbortExecution: Exclamation(Format(t_("Install of '%s' failed"), appName)); return false; case ContinueExecution: Exclamation(Format(t_("Install of '%s' failed&press OK to run uninstalled"), appName)); return true; default: return false; } return true; case InstallSucceeded: return true; case InstallAborted: switch(installBehaviour) { case AskUser : if(!PromptYesNo(Format(t_("Install of '%s' aborted&Run without installing?"), appName))) return false; break; case AbortExecution: Exclamation(Format(t_("Install of '%s' aborted"), appName)); return false; case ContinueExecution: Exclamation(Format(t_("Install of '%s' aborted&press OK to run uninstalled"), appName)); return true; default: return false; } return true; case UpdateFailed: switch(updateBehaviour) { case AskUser: if(!PromptYesNo(Format(t_("Update of '%s' failed&Run current version?"), appName))) return false; break; case AbortExecution: Exclamation(Format(t_("Update of '%s' failed"), appName)); return false; case ContinueExecution: Exclamation(Format(t_("Update of '%s' failed&press OK to run current version"), appName)); return true; default: return true; } return true; case UpdateSucceeded: return true; // here we're on normal run, no install/uninstall/update process happened // we should continue normal execution default: return true; } }
void Ide::SetupFormat() { FormatDlg dlg; dlg.Title("Format setup"); WithSetupFontLayout<ParentCtrl> fnt; WithSetupHlLayout<ParentCtrl> hlt; WithSetupEditorLayout<ParentCtrl> edt; WithSetupIdeLayout<ParentCtrl> ide; WithSetupAssistLayout<ParentCtrl> assist; WithSetupMobilePlatformsLayout<ParentCtrl> mobile; AStyleSetupDialog ast(this); #ifdef PLATFORM_WIN32 ide.console_txt.Hide(); ide.console.Hide(); ide.kde.Hide(); ide.gnome.Hide(); ide.xterm.Hide(); ide.mate.Hide(); #endif ide.kde <<= callback2(SetConsole, &ide.console, "/usr/bin/konsole -e"); ide.gnome <<= callback2(SetConsole, &ide.console, "/usr/bin/gnome-terminal -x"); ide.mate <<= callback2(SetConsole, &ide.console, "/usr/bin/mate-terminal -x"); ide.xterm <<= callback2(SetConsole, &ide.console, "/usr/bin/xterm -e"); edt.lineends .Add(LF, "LF") .Add(CRLF, "CRLF") .Add(DETECT_LF, "Detect with default LF") .Add(DETECT_CRLF, "Detect with default CRLF"); edt.filetabs .Add(AlignedFrame::LEFT, "Left") .Add(AlignedFrame::TOP, "Top") .Add(AlignedFrame::RIGHT, "Right") .Add(AlignedFrame::BOTTOM, "Bottom") .Add(-1, "Off"); edt.tabs_crosses .Add(AlignedFrame::LEFT, "Left") .Add(AlignedFrame::RIGHT, "Right") .Add(-1, "Off"); dlg.Add(fnt, "Fonts"); dlg.Add(hlt, "Syntax highlighting"); dlg.Add(edt, "Editor"); dlg.Add(assist, "Assist"); dlg.Add(ide, "IDE"); dlg.Add(ast, "Code formatting"); dlg.Add(mobile, "Mobile platforms"); dlg.WhenClose = dlg.Acceptor(IDEXIT); FontSelectManager ed, vf, con, f1, f2, tf; ed.Set(fnt.face, fnt.height, fnt.bold, fnt.italic, fnt.naa); vf.Set(fnt.vface, fnt.vheight, fnt.vbold, fnt.vitalic, fnt.vnaa); con.Set(fnt.cface, fnt.cheight, fnt.cbold, fnt.citalic, fnt.cnaa); tf.Set(fnt.tface, fnt.theight, fnt.tbold, fnt.titalic, fnt.tnaa); f1.Set(fnt.face1, fnt.height1, fnt.bold1, fnt.italic1, fnt.naa1); f2.Set(fnt.face2, fnt.height2, fnt.bold2, fnt.italic2, fnt.naa2); ed.Set(editorfont); vf.Set(veditorfont); con.Set(consolefont); tf.Set(tfont); f1.Set(font1); f2.Set(font2); DlCharset(edt.charset); edt.tabsize.MinMax(1, 100).NotNull(); edt.tabsize <<= editortabsize; edt.indent_amount.MinMax(1, 100).NotNull(); edt.indent_amount <<= indent_spaces ? indent_amount : editortabsize; edt.indent_amount.Enable(indent_spaces); CtrlRetriever rtvr; int hs = hilite_scope; rtvr (hlt.hilite_scope, hs) (hlt.hilite_bracket, hilite_bracket) (hlt.hilite_ifdef, hilite_ifdef) (hlt.hilite_if_endif, hilite_if_endif) (hlt.thousands_separator, thousands_separator) (hlt.hline, hline) (edt.indent_spaces, indent_spaces) (edt.no_parenthesis_indent, no_parenthesis_indent) (edt.showtabs, show_tabs) (edt.warnwhitespace, warnwhitespace) (edt.lineends, line_endings) (edt.numbers, line_numbers) (edt.bookmark_pos, bookmark_pos) (edt.bordercolumn, bordercolumn) (edt.bordercolor, bordercolor) (edt.findpicksel, find_pick_sel) (edt.findpicktext, find_pick_text) (edt.deactivate_save, deactivate_save) (edt.filetabs, filetabs) (edt.tabs_icons, tabs_icons) (edt.tabs_crosses, tabs_crosses) (edt.tabs_grouping, tabs_grouping) (edt.tabs_stacking, tabs_stacking) (edt.tabs_serialize, tabs_serialize) (edt.persistent_find_replace, persistent_find_replace) (edt.find_replace_restore_pos, find_replace_restore_pos) (assist.barline, barline) (assist.auto_enclose, auto_enclose) (assist.commentdp, editor.commentdp) (assist.header_guards, header_guards) (assist.insert_include, insert_include) (assist.mark_lines, mark_lines) (assist.qtfsel, qtfsel) (assist.assist, editor.auto_assist) (ide.showtime, showtime) (ide.show_status_bar, show_status_bar) (ide.toolbar_in_row, toolbar_in_row) (ide.splash_screen, splash_screen) (ide.sort, sort) (ide.mute_sounds, mute_sounds) (ide.wrap_console_text, wrap_console_text) (ide.hydra1_threads, hydra1_threads) (ide.gdbSelector, gdbSelector) (ide.chstyle, chstyle) (ide.console, LinuxHostConsole) (ide.output_per_assembly, output_per_assembly) (ast.BracketIndent, astyle_BracketIndent) (ast.NamespaceIndent, astyle_NamespaceIndent) (ast.BlockIndent, astyle_BlockIndent) (ast.CaseIndent, astyle_CaseIndent) (ast.ClassIndent, astyle_ClassIndent) (ast.LabelIndent, astyle_LabelIndent) (ast.SwitchIndent, astyle_SwitchIndent) (ast.PreprocessorIndent, astyle_PreprocessorIndent) (ast.MinInStatementIndentLength, astyle_MinInStatementIndentLength) (ast.MaxInStatementIndentLength, astyle_MaxInStatementIndentLength) (ast.BreakClosingHeaderBracketsMode,astyle_BreakClosingHeaderBracketsMode) (ast.BreakElseIfsMode, astyle_BreakElseIfsMode) (ast.BreakOneLineBlocksMode, astyle_BreakOneLineBlocksMode) (ast.SingleStatementsMode, astyle_SingleStatementsMode) (ast.BreakBlocksMode, astyle_BreakBlocksMode) (ast.BreakClosingHeaderBlocksMode, astyle_BreakClosingHeaderBlocksMode) (ast.BracketFormatMode, astyle_BracketFormatMode) (ast.ParensPaddingMode, astyle_ParensPaddingMode) (ast.ParensUnPaddingMode, astyle_ParensUnPaddingMode) (ast.OperatorPaddingMode, astyle_OperatorPaddingMode) (ast.EmptyLineFill, astyle_EmptyLineFill) (ast.TabSpaceConversionMode, astyle_TabSpaceConversionMode) (ast.TestBox, astyle_TestBox) (mobile.AndroidSDKPath, androidSDKPath) ; hlt.hlstyle.AddColumn("Style"); hlt.hlstyle.AddColumn("Color").Ctrls(HlPusherFactory); hlt.hlstyle.AddColumn("Bold").Ctrls<Option>(); hlt.hlstyle.AddColumn("Italic").Ctrls<Option>(); hlt.hlstyle.AddColumn("Underline").Ctrls<Option>(); hlt.hlstyle.ColumnWidths("211 80 45 45 80"); hlt.hlstyle.EvenRowColor().NoHorzGrid().SetLineCy(EditField::GetStdHeight() + 2); ReadHlStyles(hlt.hlstyle); edt.charset <<= (int)default_charset; edt.tabsize <<= rtvr <<= hlt.hlstyle.WhenCtrlsAction = ed.WhenAction = tf.WhenAction = con.WhenAction = f1.WhenAction = f2.WhenAction = dlg.Breaker(222); ide.showtimeafter <<= Nvl((Date)FileGetTime(ConfigFile("version")), GetSysDate() - 1); hlt.hl_restore <<= dlg.Breaker(333); ide.chstyle.Add(0, "Host platform"); ide.chstyle.Add(1, "Standard"); ide.chstyle.Add(2, "Classic"); ide.chstyle.Add(3, "Host platform, blue bars"); ide.chstyle.Add(4, "Standard, blue bars"); FrameRight<Button> uscBrowse; uscBrowse.SetImage(CtrlImg::right_arrow()); uscBrowse <<= callback1(AddPath, &ide.uscpath); ide.uscpath.AddFrame(uscBrowse); ide.uscpath <<= LoadFile(GetHomeDirFile("usc.path")); FrameRight<Button> androidSDKDownload; androidSDKDownload.SetImage(IdeImg::DownloadBlack()); androidSDKDownload.Tip("Download"); androidSDKDownload <<= callback1(LaunchWebBrowser, AndroidSDK::GetDownloadUrl()); mobile.AndroidSDKPath.AddFrame(androidSDKDownload); FrameRight<Button> androidSDKBrowse; androidSDKBrowse.SetImage(CtrlImg::right_arrow()); androidSDKBrowse.Tip("Select directory"); androidSDKBrowse <<= callback1(InsertPath, &mobile.AndroidSDKPath); mobile.AndroidSDKPath.AddFrame(androidSDKBrowse); mobile.AndroidSDKPath <<= androidSDKPath; for(;;) { int c = dlg.Run(); Upp::SaveFile(GetHomeDirFile("usc.path"), ~ide.uscpath); editorfont = ed.Get(); tfont = tf.Get(); veditorfont = vf.Get(); consolefont = con.Get(); font1 = f1.Get(); font2 = f2.Get(); editortabsize = Nvl((int)~edt.tabsize, 4); rtvr.Retrieve(); console.SetSlots(minmax(hydra1_threads, 1, 256)); hilite_scope = hs; if(indent_spaces) indent_amount = ~edt.indent_amount; else { indent_amount = editortabsize; edt.indent_amount <<= editortabsize; } edt.indent_amount.Enable(indent_spaces); default_charset = (byte)(int)~edt.charset; for(int i = 0; i < CodeEditor::HL_COUNT; i++) editor.SetHlStyle(i, hlt.hlstyle.Get(i, 1), hlt.hlstyle.Get(i, 2), hlt.hlstyle.Get(i, 3), hlt.hlstyle.Get(i, 4)); UpdateFormat(); if(c == IDEXIT) break; if(c == 333 && PromptYesNo("Restore default highlighting colors?")) { editor.DefaultHlStyles(); ReadHlStyles(hlt.hlstyle); } } FileSetTime(ConfigFile("version"), ToTime(~ide.showtimeafter)); FinishConfig(); SaveConfig(); }