예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="openrenderer"></param>
        public void PostLoadFile(string filename = "", bool openrenderer = false)
        {
            #region SetupFile
            // Backgroundwork Start
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            switch (Path.GetExtension(filename))
            {
            case ".w2scene":
            case ".w2quest":
            case ".w2phase":
            {
                //this.flowDiagram = new frmChunkFlowDiagram();
                //this.flowDiagram.OnOutput += MainController.LogString;
                //this.flowDiagram.File = this.File;
                //this.flowDiagram.DockAreas = DockAreas.Document;
                //this.flowDiagram.OnSelectChunk += this.frmCR2WDocument_OnSelectChunk;
                //this.flowDiagram.Show(this.FormPanel, DockState.Document);
                break;
            }

            case ".journal":
            {
                this.JournalEditor = new frmJournalEditor
                {
                    File      = this.File,
                    DockAreas = DockAreas.Document
                };
                this.JournalEditor.Show(this.FormPanel, DockState.Document);
                break;
            }

            case ".xbm":
            {
                this.ImageViewer = new frmImagePreview
                {
                    DockAreas = DockAreas.Document
                };
                this.ImageViewer.Show(this.FormPanel, DockState.Document);
                CR2WExportWrapper imagechunk = this.File?.chunks?.FirstOrDefault(_ => _.data.REDType.Contains("CBitmapTexture"));
                this.ImageViewer.SetImage(imagechunk);
                break;
            }

            case ".redswf":
            {
                CR2WExportWrapper imagechunk = this.File?.chunks?.FirstOrDefault(_ => _.data is CBitmapTexture);
                if (imagechunk != null)
                {
                    this.ImageViewer = new frmImagePreview
                    {
                        DockAreas = DockAreas.Document
                    };
                    this.ImageViewer.Show(this.FormPanel, DockState.Document);
                    this.ImageViewer.SetImage(imagechunk);
                }
                break;
            }

            case ".w2mesh":
            {
                if (openrenderer)
                {
                    try
                    {
                        // add all dependencies

                        MockKernel.Get().Window.PauseMonitoring();
                        WccHelper.AddAllImports(filename, true, false);
                        MockKernel.Get().Window.ResumeMonitoring();

                        this.RenderViewer = new Render.frmRender
                        {
                            LoadDocument = LoadDocumentAndGetFile,
                            MeshFile     = this.File,
                            DockAreas    = DockAreas.Document,
                            renderHelper = new Render.RenderHelper(MainController.Get().ActiveMod, MainController.Get().Logger)
                        };
                        this.RenderViewer.Show(this.FormPanel, DockState.Document);
                    }
                    catch (Exception ex)
                    {
                        MainController.LogString(ex.ToString(), Logtype.Error);
                    }
                }
                break;
            }

            default:
            {
                break;
            }
            }


            var output = new StringBuilder();

            if (this.File.UnknownTypes.Any())
            {
                //ShowConsole();
                //ShowOutput();

                output.Append(this.FileName + ": contains " + this.File.UnknownTypes.Count + " unknown type(s):\n");
                foreach (var unk in this.File.UnknownTypes)
                {
                    output.Append("\"" + unk + "\", \n");
                }

                output.Append("-------\n\n");
            }

            var hasUnknownBytes = false;

            foreach (var t in this.File.chunks.Where(t => t.unknownBytes?.Bytes != null && t.unknownBytes.Bytes.Length > 0))
            {
                output.Append(t.REDName + " contains " + t.unknownBytes.Bytes.Length + " unknown bytes. \n");
                hasUnknownBytes = true;
            }

            if (hasUnknownBytes)
            {
                output.Append("-------\n\n");
            }

            //output.Append($"CR2WFile {filename} loaded in: {stopwatch.Elapsed}\n\n");
            stopwatch.Stop();

            MainController.LogString(output.ToString(), Logtype.Important);
            #endregion

            CR2WFile LoadDocumentAndGetFile(string path)
            {
                throw new NotImplementedException();
                //foreach (var t in MockKernel.Get().GetMainViewModel().OpenDocuments.Where(_ => _.File is CR2WFile).Where(t => t.FileName == path))
                //    return t.File as CR2WFile;

                ////var activedoc = vm.OpenDocuments.FirstOrDefault(d => d.IsActivated);
                //var doc2 = LoadDocument(path) as frmCR2WDocument;
                ////activedoc.Activate();
                //return doc2?.File;
            }
        }
예제 #2
0
 public void ApplyCustomTheme()
 {
     this.txOutput.BackColor = MainController.Get().GetTheme().ColorPalette.ToolWindowTabSelectedInactive.Background;
     this.txOutput.ForeColor = MainController.Get().GetTheme().ColorPalette.CommandBarMenuDefault.Text;
 }
예제 #3
0
        private void LoadGameStrings()
        {
            stringsManager.Load(comboBoxLanguage.SelectedItem.ToString(), Path.GetDirectoryName(MainController.Get().Configuration.ExecutablePath));

            foreach (var line in stringsManager.Lines)
            {
                strings.Add(new List <string> {
                    line.Value[0].str_id.ToString(), "0", line.Value[0].str
                });
            }
            FillListView(strings);
            toolStripStatusLabelStringsCount.Text = "Strings Loaded: " + strings.Count.ToString();

            if (guiStrings.Count == 0)
            {
                return;
            }

            var matchedStringsCounter = 0;

            foreach (ListViewItem item in listViewStrings.Items)
            {
                if (guiStrings.Contains(item.Text))
                {
                    item.ForeColor = Color.Blue;
                    ++matchedStringsCounter;
                }
                if (matchedStringsCounter == guiStrings.Count)
                {
                    return;
                }
            }
        }
예제 #4
0
        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;
            }

            // get configs
            var config   = MainController.Get().Configuration;
            var uiconfig = UIController.Get().Configuration;

            // Apply Theme
            bool applyTheme = uiconfig.ColorTheme != (EColorThemes)comboBoxTheme.SelectedItem;

            // save settings
            config.ExecutablePath        = txExecutablePath.Text;
            config.WccLite               = txWCC_Lite.Text;
            config.TextLanguage          = txTextLanguage.Text;
            config.VoiceLanguage         = txVoiceLanguage.Text;
            config.UncookExtension       = (EUncookExtension)comboBoxExtension.SelectedItem;
            config.IsWelcomeFormDisabled = checkBoxDisableWelcomeForm.Checked;


            uiconfig.ColorTheme = (EColorThemes)comboBoxTheme.SelectedItem;

            // save configs
            config.Save();
            uiconfig.Save();

            MainController.Get().UpdateWccHelper(config.WccLite);


            if (applyTheme)
            {
                UIController.Get().Window.GlobalApplyTheme();
            }

            /// debug console enabling
            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 useful 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)
            {
                MessageBox.Show(exception.ToString());
            }

            // patch wcc_lite
            try
            {
                using (var fs = new FileStream(txWCC_Lite.Text, FileMode.Open))
                    using (var bw = new BinaryWriter(fs))
                    {
                        var shawcc = SHA256.Create().ComputeHash(fs).Aggregate("", (c, n) => c += n.ToString("x2"));
                        switch (shawcc)
                        {
                        case wcc_sha256:
                        {
                            if (MessageBox.Show(@"wcc_lite is a great tool by CD Projekt red but
due to some internal problems they didn't really have time to properly develop it.
Due to this the tool takes an age to start up since it is searching for a CD Projekt red mssql server.
WolvenKit can patch this with a method figured out by blobbins on the witcher 3 forums.
Would you like to perform this patch?", "wcc_lite faster patch", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                                DialogResult.Yes)
                            {
                                //We perform the patch
                                bw.BaseStream.Seek(0x00713CD0, SeekOrigin.Begin);
                                bw.Write(new byte[0xDD].Select(x => x = 0x90).ToArray());
                            }

                            //Recompute hash
                            fs.Seek(0, SeekOrigin.Begin);
                            shawcc = SHA256.Create().ComputeHash(fs).Aggregate("", (c, n) => c += n.ToString("x2"));
                            if (shawcc == wcc_sha256_patched)
                            {
                                MessageBox.Show("Succesfully patched!", "Patch completed", MessageBoxButtons.OK,
                                                MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show("Failed to patch! Please reinstall wcc_lite and try again",
                                                "Patch completed", MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                            }

                            break;
                        }

                        case wcc_sha256_patched2:
                        case wcc_sha256_patched:
                        {
                            //Do nothing we are cool.
                            break;
                        }

                        default:
                        {
                            DialogResult = DialogResult.None;
                            txExecutablePath.Focus();
                            MessageBox.Show("Invalid wcc_lite.exe path you seem to have on older version",
                                            "failed to save.");
                            return;
                        }
                        }
                    }
            }
            catch (UnauthorizedAccessException)
            {
                //wcc_lite is installed to C:\\Program files
                MessageBox.Show("Please restart WolvenKit as administrator. Couldn't access " + txWCC_Lite.Text,
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                // Exit with error code 0 so we don't raise a windows error and the user can restart it so we have access to the files.
                Environment.Exit(0);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }
        }
예제 #5
0
 public frmPackSettings()
 {
     InitializeComponent();
     if (MainController.Get().Window.ActiveMod.Files.Any(x => x.EndsWith(".xbm")))
     {
         texturecachecCHB.Checked = true;
     }
     if (MainController.Get().Window.ActiveMod.Files.Any(x => x.EndsWith(".ws")))
     {
         scriptsCHB.Checked = true;
     }
     if (MainController.Get().Window.ActiveMod.Files.Any(x => x.EndsWith(".wem") || x.EndsWith(".bnk")))
     {
         soundCHB.Checked = true;
     }
     if (Directory.Exists((MainController.Get().Window.ActiveMod.ProjectDirectory + "\\strings")) && Directory.GetFiles((MainController.Get().Window.ActiveMod.ProjectDirectory + "\\strings")).Any(x => x.EndsWith(".w3strings")))
     {
         stringsCHB.Checked = true;
     }
     if (MainController.Get().Window.ActiveMod.Files.Any(x => x.EndsWith(".apx") || x.EndsWith(".apb")))
     {
         collisionCacheCHB.Checked = true;
     }
 }