private void ExportBytes(CVariable editvar) { var dlg = new SaveFileDialog(); byte[] bytes = null; if (editvar is IByteSource) { bytes = ((IByteSource)editvar).Bytes; } dlg.Filter = string.Join("|", ImportExportUtility.GetPossibleExtensions(bytes, editvar.Name)); dlg.InitialDirectory = MainController.Get().Configuration.InitialExportDirectory; if (dlg.ShowDialog() == DialogResult.OK) { MainController.Get().Configuration.InitialExportDirectory = Path.GetDirectoryName(dlg.FileName); using (var fs = new FileStream(dlg.FileName, FileMode.Create, FileAccess.Write)) { using (var writer = new BinaryWriter(fs)) { bytes = ImportExportUtility.GetExportBytes(bytes, Path.GetExtension(dlg.FileName)); writer.Write(bytes); } } } }
/// <summary> /// Setup the backgroundworker and progress forms (Main thread) /// </summary> /// <param name="args"></param> public void WorkerLoadFileSetup(LoadFileArgs args) { MainController.Get().ProjectStatus = EProjectStatus.Busy; this.Text = Path.GetFileName(args.Filename) + " [" + args.Filename + "]"; if (!backgroundWorker1.IsBusy) { ProgressForm = new frmProgress() { Text = "Loading File...", StartPosition = FormStartPosition.CenterScreen, FormBorderStyle = FormBorderStyle.None }; workerAction = WorkerLoadFile; backgroundWorker1.RunWorkerAsync(args); var dr = ProgressForm.ShowDialog(this); } else { MainController.LogString("The background worker is currently busy.\r\n", Logtype.Error); } MainController.Get().ProjectStatus = EProjectStatus.Ready; }
public void ShowRadishUtility() { if (MainController.Get().ActiveMod == null) { MessageBox.Show(@"Please create a new mod project." , "Missing Mod Project" , System.Windows.Forms.MessageBoxButtons.OK , System.Windows.Forms.MessageBoxIcon.Information); return; } var filedir = new DirectoryInfo(MainController.Get().ActiveMod.FileDirectory); var radishdir = filedir.GetFiles("*.bat", SearchOption.AllDirectories)?.FirstOrDefault(_ => _.Name == "_settings_.bat")?.Directory; if (radishdir == null) { MainController.LogString("ERROR! No radish mod directory found.\r\n", WolvenKit.Common.Services.Logtype.Error); return; } if (RadishUtility == null || RadishUtility.IsDisposed) { RadishUtility = new frmRadish(); RadishUtility.Show(dockPanel, DockState.Document); } RadishUtility.Activate(); }
private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args.Length > 0) { if (File.Exists(args[0])) { switch (Path.GetExtension(args[0])) { case ".w3modproj": { MainController.Get().InitialModProject = args[0]; break; } case ".wkp": { MainController.Get().InitialWKP = args[0]; break; } case ".w2ent": { MainController.Get().InitialFilePath = args[0]; break; } } } } Application.Run(MockKernel.Get().Window); }
private void saveToFileName() { try { using (var mem = new MemoryStream()) { using (var writer = new BinaryWriter(mem)) { File.Write(writer); mem.Seek(0, SeekOrigin.Begin); using (var fs = new FileStream(FileName, FileMode.Create, FileAccess.Write)) { mem.WriteTo(fs); OnFileSaved?.Invoke(this, new FileSavedEventArgs { FileName = FileName, Stream = fs, File = File }); fs.Close(); } } } } catch (Exception e) { MainController.Get().QueueLog("Failed to save the file(s)! They are probably in use.\n" + e.ToString()); } }
private void markAsModDlcFileToolStripMenuItem_Click(object sender, EventArgs e) { if (modFileList.SelectedNode != null) { var filename = modFileList.SelectedNode.FullPath; var fullpath = Path.Combine(ActiveMod.FileDirectory, filename); if (!File.Exists(fullpath)) { return; } var newfullpath = Path.Combine(new[] { ActiveMod.FileDirectory, filename.Split('\\')[0] == "DLC" ? "Mod" : "DLC" }.Concat(filename.Split('\\').Skip(1).ToArray()).ToArray()); if (File.Exists(newfullpath)) { return; } try { Directory.CreateDirectory(Path.GetDirectoryName(newfullpath)); } catch { } File.Move(fullpath, newfullpath); MainController.Get().ProjectStatus = "File moved"; } }
private void copyToolStripMenuItem_Click(object sender, EventArgs e) { if (modFileList.SelectedNode != null) { Clipboard.SetText(MainController.Get().ActiveMod.FileDirectory + "\\" + modFileList.SelectedNode.FullPath); } }
private async Task <int> /*int*/ RunBulkEditInternal(BulkEditOptions opts) { List <string> files = MainController.Get().ActiveMod.Files; foreach (var path in files) { var fullpath = Path.Combine(MainController.Get().ActiveMod.FileDirectory, path); if (opts.ext != null && !Path.GetExtension(fullpath).Contains(opts.ext)) { continue; } CR2WFile cr2w; using (var fs = new FileStream(fullpath, FileMode.Open, FileAccess.Read)) using (var reader = new BinaryReader(fs)) { cr2w = new CR2WFile(reader); fs.Close(); } //EditVariablesInFile(path, cr2w, chunk, var, type, val); await Task.Run(() => EditVariablesInFile(path, cr2w, opts)) .ContinueWith(antecedent => { using (var fs = new FileStream($"{fullpath}", FileMode.Create, FileAccess.ReadWrite)) using (var writer = new BinaryWriter(fs)) { cr2w.Write(writer); } }); } return(0); }
private void addFileToolStripMenuItem_Click(object sender, EventArgs e) { var dlg = new OpenFileDialog() { Title = "Add File to Project" }; dlg.InitialDirectory = MainController.Get().Configuration.InitialFileDirectory; if (dlg.ShowDialog() == DialogResult.OK) { MainController.Get().Configuration.InitialFileDirectory = Path.GetDirectoryName(dlg.FileName); try { FileInfo fi = new FileInfo(dlg.FileName); var newfilepath = Path.Combine(ActiveMod.FileDirectory, fi.Name); if (modFileList.SelectedNode != null) { newfilepath = Path.Combine(ActiveMod.FileDirectory, modFileList.SelectedNode.FullPath); if (File.Exists(newfilepath)) { newfilepath = Path.GetDirectoryName(newfilepath); } newfilepath = Path.Combine(newfilepath, fi.Name); } if (File.Exists(newfilepath)) { newfilepath = $"{newfilepath.TrimEnd(fi.Extension.ToCharArray())} - copy{fi.Extension}"; } fi.CopyTo(newfilepath, false); } catch (Exception) { } } }
public void ApplyCustomTheme() { var theme = MainController.Get().GetTheme(); this.treeView.BackColor = theme.ColorPalette.ToolWindowTabSelectedInactive.Background; this.treeView.AlternateRowBackColor = theme.ColorPalette.OverflowButtonHovered.Background; this.treeView.ForeColor = theme.ColorPalette.CommandBarMenuDefault.Text; HeaderFormatStyle hfs = new HeaderFormatStyle() { Normal = new HeaderStateStyle() { BackColor = theme.ColorPalette.DockTarget.Background, ForeColor = theme.ColorPalette.CommandBarMenuDefault.Text, }, Hot = new HeaderStateStyle() { BackColor = theme.ColorPalette.OverflowButtonHovered.Background, ForeColor = theme.ColorPalette.CommandBarMenuDefault.Text, }, Pressed = new HeaderStateStyle() { BackColor = theme.ColorPalette.CommandBarToolbarButtonPressed.Background, ForeColor = theme.ColorPalette.CommandBarMenuDefault.Text, } }; this.treeView.HeaderFormatStyle = hfs; treeView.UnfocusedSelectedBackColor = theme.ColorPalette.CommandBarToolbarButtonPressed.Background; }
private void ExecuteGame(string args = "") { if (MainController.Get().Configuration == null) { return; } if (Process.GetProcessesByName("Witcher3").Length != 0) { CommonUIFunctions.SendNotification("Game is already running!"); return; } var config = MainController.Get().Configuration; var proc = new ProcessStartInfo(config.ExecutablePath) { Arguments = args == "" ? "-net -debugscripts" : args, UseShellExecute = false, RedirectStandardOutput = true }; AddOutput("Executing " + proc.FileName + " " + proc.Arguments + "\n"); var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var scriptlog = Path.Combine(documents, @"The Witcher 3\scriptslog.txt"); if (File.Exists(scriptlog)) { File.Delete(scriptlog); } Process.Start(proc); }
public frmStringsGuiImporter() { InitializeComponent(); stringsManager = MainController.Get().W3StringManager; comboBoxLanguage.Text = MainController.Get().Configuration.TextLanguage; }
public void ImportBytes(CVariable editvar) { var dlg = new OpenFileDialog() { InitialDirectory = MainController.Get().Configuration.InitialExportDirectory }; if (dlg.ShowDialog() == DialogResult.OK) { MainController.Get().Configuration.InitialExportDirectory = Path.GetDirectoryName(dlg.FileName); using (var fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read)) { using (var reader = new BinaryReader(fs)) { var bytes = ImportExportUtility.GetImportBytes(reader); editvar.SetValue(bytes); MainController.LogString( $"{((CVariable) editvar).GetFullDependencyStringName()} succesfully imported from {dlg.FileName}", Logtype.Success); } } } }
public void ApplyCustomTheme() { var theme = MainController.Get().GetTheme(); MainController.Get().ToolStripExtender.SetStyle(toolStrip1, VisualStudioToolStripExtender.VsVersion.Vs2015, theme); this.treeListView.BackColor = theme.ColorPalette.TabButtonSelectedInactivePressed.Background; toolStripSearchBox.BackColor = theme.ColorPalette.ToolWindowCaptionButtonInactiveHovered.Background; this.treeListView.ForeColor = theme.ColorPalette.CommandBarMenuDefault.Text; HeaderFormatStyle hfs = new HeaderFormatStyle() { Normal = new HeaderStateStyle() { BackColor = theme.ColorPalette.ToolWindowTabSelectedInactive.Background, ForeColor = theme.ColorPalette.CommandBarMenuDefault.Text, }, Hot = new HeaderStateStyle() { BackColor = theme.ColorPalette.OverflowButtonHovered.Background, ForeColor = theme.ColorPalette.CommandBarMenuDefault.Text, }, Pressed = new HeaderStateStyle() { BackColor = theme.ColorPalette.CommandBarToolbarButtonPressed.Background, ForeColor = theme.ColorPalette.CommandBarMenuDefault.Text, } }; this.treeListView.HeaderFormatStyle = hfs; treeListView.UnfocusedSelectedBackColor = theme.ColorPalette.CommandBarToolbarButtonPressed.Background; }
private void btSave_Click(object sender, EventArgs e) { if (!File.Exists(txExecutablePath.Text)) { DialogResult = DialogResult.None; txExecutablePath.Focus(); MessageBox.Show("Invalid witcher3.exe path", "failed to save."); return; } if (!File.Exists(txWCC_Lite.Text)) { DialogResult = DialogResult.None; txWCC_Lite.Focus(); MessageBox.Show("Invalid wcc_lite.exe path", "failed to save."); return; } var config = MainController.Get().Configuration; config.ExecutablePath = txExecutablePath.Text; config.WccLite = txWCC_Lite.Text; config.TextLanguage = txTextLanguage.Text; config.VoiceLanguage = txVoiceLanguage.Text; MainController.Get().ReloadStringManager(); config.Save(); }
public void ApplyCustomTheme() { var theme = MainController.Get().GetTheme(); this.dockPanel.Theme = theme; dockPanel.SaveAsXml(Path.Combine(Path.GetDirectoryName(Configuration.ConfigurationPath), "cr2wdocument_layout.xml")); }
private void dumpChunksToXMLToolStripMenuItem_Click(object sender, EventArgs e) { if (modFileList.SelectedNode != null) { SaveFileDialog sFileDialog = new SaveFileDialog { Filter = "XML File|*.xml", Title = "Save XML File", InitialDirectory = MainController.Get().Configuration.InitialFileDirectory + "\\" + modFileList.SelectedNode.FullPath, OverwritePrompt = true, FileName = ActiveMod.FileDirectory + "\\" + modFileList.SelectedNode.FullPath + ".chunk.xml" }; DialogResult result = sFileDialog.ShowDialog(); if (result == DialogResult.OK) { FileStream writer = new FileStream(sFileDialog.FileName, FileMode.Create); DumpChunkXML(writer); } } void DumpChunkXML(FileStream writer) { try { string filePath = ActiveMod.FileDirectory + "\\" + modFileList.SelectedNode.FullPath; string fileName = writer.Name; using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) using (var reader = new BinaryReader(fs)) { var File = new CR2W.CR2WFile(reader); File.FileName = modFileList.SelectedNode.FullPath; File.SerializeChunksToXml(writer); writer.Flush(); writer.Close(); } //vl: ugly way to suppress ugly xmlns string text = ""; using (StreamReader streamReader = File.OpenText(fileName)) //vl: TODO: what about encoding?? { text = streamReader.ReadToEnd(); text = text.Replace(" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"", ""); } File.WriteAllText(fileName, text); Logger.LogString("Dumping chunks XML successful.", Logtype.Success); } catch (Exception ex) { Logger.LogString(ex.Message, Logtype.Error); Logger.LogString(ex.StackTrace, Logtype.Error); Logger.LogString("Dumping chunks XML failed.", Logtype.Error); } } }
public frmStringsGuiImporter(List <string> guiStrings) { this.guiStrings = guiStrings; InitializeComponent(); stringsManager = MainController.Get().W3StringManager; comboBoxLanguage.Text = MainController.Get().Configuration.TextLanguage; }
public frmSettings() { InitializeComponent(); var config = MainController.Get().Configuration; txExecutablePath.Text = config.ExecutablePath; txTextLanguage.Text = config.TextLanguage; txVoiceLanguage.Text = config.VoiceLanguage; txWCC_Lite.Text = config.WccLite; }
public void ApplyCustomTheme() { var theme = MainController.Get().GetTheme(); MainController.Get().ToolStripExtender.SetStyle(searchstrip, VisualStudioToolStripExtender.VsVersion.Vs2015, theme); this.modFileList.BackColor = theme.ColorPalette.ToolWindowTabSelectedInactive.Background; this.modFileList.ForeColor = theme.ColorPalette.CommandBarMenuDefault.Text; this.searchBox.BackColor = theme.ColorPalette.ToolWindowCaptionButtonInactiveHovered.Background; }
public bool AreHashesDifferent() { if (MainController.Get().ActiveMod == null) { return(false); } var stringsHashPath = MainController.Get().ActiveMod.ProjectDirectory + "\\strings\\hash"; if (!File.Exists(stringsHashPath)) { return(false); } byte[] hash; using (var br = new BinaryReader(File.OpenRead(stringsHashPath))) { hash = br.ReadBytes(32); } ulong hashStringsBytesSum = 0; foreach (var b in hash) { hashStringsBytesSum += b; } var csvHashPath = MainController.Get().ActiveMod.ProjectDirectory + "\\strings\\CSV\\hash"; if (!File.Exists(csvHashPath)) { return(false); } using (var br = new BinaryReader(File.OpenRead(csvHashPath))) { hash = br.ReadBytes(32); } ulong hashCsvBytesSum = 0; foreach (var b in hash) { hashCsvBytesSum += b; } if (hashStringsBytesSum == hashCsvBytesSum) { return(true); } return(false); }
private void loadFile(Stream stream, string filename) { Text = Path.GetFileName(filename) + " [" + filename + "]"; using (var reader = new BinaryReader(stream)) { File = new CR2WFile(reader) { FileName = filename, EditorController = MainController.Get(), LocalizedStringSource = MainController.Get() }; } }
public frmSettings() { InitializeComponent(); var config = MainController.Get().Configuration; txExecutablePath.Text = config.ExecutablePath; txTextLanguage.Text = config.TextLanguage; txVoiceLanguage.Text = config.VoiceLanguage; txWCC_Lite.Text = config.WccLite; exeSearcherSlave.RunWorkerAsync(); btSave.Enabled = (File.Exists(txWCC_Lite.Text) && Path.GetExtension(txWCC_Lite.Text) == ".exe" && txWCC_Lite.Text.Contains("wcc_lite.exe")) && (File.Exists(txExecutablePath.Text) && Path.GetExtension(txExecutablePath.Text) == ".exe" && txExecutablePath.Text.Contains("witcher3.exe")); }
private void buttonOK_Click(object sender, EventArgs e) { MainController.Get().Configuration.IsAutoInstallModsDisabled = !checkBoxInstallMod.Checked; if (modBDL.Checked | modMD.Checked | dlcBDL.Checked | dlcMD.Checked | modTEX.Checked | dlcTEX.Checked | modSND.Checked | dlcSND.Checked | modSCR.Checked | dlcSCR.Checked | modSTR.Checked | modCOL.Checked | dlcCOL.Checked) { DialogResult = System.Windows.Forms.DialogResult.OK; } else { DialogResult = System.Windows.Forms.DialogResult.Cancel; } }
public frmSettings() { InitializeComponent(); var config = MainController.Get().Configuration; txExecutablePath.Text = config.ExecutablePath; txTextLanguage.Text = config.TextLanguage; txVoiceLanguage.Text = config.VoiceLanguage; txWCC_Lite.Text = config.WccLite; comboBoxTheme.Items.AddRange(Enum.GetValues(typeof(EColorThemes)).Cast <object>().ToArray()); comboBoxTheme.SelectedItem = config.ColorTheme; exeSearcherSlave.RunWorkerAsync(); btSave.Enabled = (File.Exists(txWCC_Lite.Text) && Path.GetExtension(txWCC_Lite.Text) == ".exe" && txWCC_Lite.Text.Contains("wcc_lite.exe")) && (File.Exists(txExecutablePath.Text) && Path.GetExtension(txExecutablePath.Text) == ".exe" && txExecutablePath.Text.Contains("witcher3.exe")); }
public void ParseImageAndPreview(CR2WChunk chunk) { var image = chunk.GetVariableByName("image").ToString(); if (!string.IsNullOrEmpty(image)) { try { var files = MainController.Get().ImportFile(image, MainController.Get().TextureManager); entityImage.Image = new DdsImage(files[0]).BitmapImage; entimgbox.Image = new DdsImage(files[1]).BitmapImage; } catch (Exception ex) { } } }
public void ParseImageAndPreview(CJournalCharacter character) { var image = character.Image.REDValue; if (!string.IsNullOrEmpty(image)) { try { var files = MainController.ImportFile(image, MainController.Get().TextureManager); entityImage.Image = ImageUtility.FromBytes(files[0]); entimgbox.Image = ImageUtility.FromBytes(files[1]); } catch { //TODO: Log } } }
public frmUsmPlayer(string path) { InitializeComponent(); if (Directory.Exists(MainController.Get().VLCLibDir)) { this.usmPlayer.VlcLibDirectory = new DirectoryInfo(MainController.Get().VLCLibDir); } else { this.usmPlayer.Enabled = false; this.Shown += new EventHandler(UsmPlayer_CloseOnStart); } Demuxedfiles = new Dictionary <string, byte[]>(); videofile = path; videoConverter.RunWorkerAsync(); Text = @"Video Preview [" + Path.GetFileNameWithoutExtension(path) + @"]"; usmPlayer.EndReached += UsmPlayerOnEndReached; }
public void ParseImageAndPreview(CR2WExportWrapper chunk) { var image = chunk.GetVariableByName("image").ToString(); if (!string.IsNullOrEmpty(image)) { try { var files = MainController.ImportFile(image, MainController.Get().TextureManager); entityImage.Image = ImageUtility.FromBytes(files[0]); entimgbox.Image = ImageUtility.FromBytes(files[1]); } catch { //TODO: Log } } }
private void btSave_Click(object sender, EventArgs e) { if (!File.Exists(txExecutablePath.Text)) { DialogResult = DialogResult.None; txExecutablePath.Focus(); MessageBox.Show("Invalid witcher3.exe path", "failed to save."); return; } if (!File.Exists(txWCC_Lite.Text)) { DialogResult = DialogResult.None; txWCC_Lite.Focus(); MessageBox.Show("Invalid wcc_lite.exe path", "failed to save."); return; } var config = MainController.Get().Configuration; config.ExecutablePath = txExecutablePath.Text; config.WccLite = txWCC_Lite.Text; config.TextLanguage = txTextLanguage.Text; config.VoiceLanguage = txVoiceLanguage.Text; MainController.Get().ReloadStringManager(); config.Save(); try { IniParser ip = new IniParser(Path.Combine(MainController.Get().Configuration.GameRootDir, "bin\\config\\base\\general.ini")); if (!ip.HasSection("General") || ip.GetSetting("General", "DBGConsoleOn", true) != "true") { if (MessageBox.Show( "WolvenKit has detected that your game has the debug console disabled. It is a usefull tool when testing mods. Would you like it to be enabled?", "Debug console enabling", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ip.AddSetting("General", "DBGConsoleOn", "true"); ip.Save(); } } } catch (Exception exception) { Console.WriteLine(exception); } }