示例#1
0
文件: Program.cs 项目: q4a/Wolven-kit
        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);
        }
示例#2
0
 public static MockKernel Get()
 {
     if (kernel == null)
     {
         kernel        = new MockKernel();
         kernel.Window = new frmMain();
     }
     return(kernel);
 }
示例#3
0
        public void ShowOutput()
        {
            if (Output == null || Output.IsDisposed)
            {
                GetOutput();
                Output.Show(MockKernel.Get().Window.GetDockPanel(), WeifenLuo.WinFormsUI.Docking.DockState.DockBottom);
            }

            Output.Activate();
        }
示例#4
0
        public void ShowConsole()
        {
            if (Console == null || Console.IsDisposed)
            {
                GetConsole();
                Console.Show(MockKernel.Get().Window.GetDockPanel(), WeifenLuo.WinFormsUI.Docking.DockState.DockBottom);
            }

            Console.Activate();
        }
示例#5
0
        public frmModExplorer()
        {
            // initialize Viewmodel
            vm = MockKernel.Get().GetModExplorerModel();
            vm.PropertyChanged += ViewModel_PropertyChanged;
            //vm.UpdateMonitoringRequest += (sender, e) => this.ViewModel_UpdateMonitoringRequest(e);

            InitializeComponent();
            ApplyCustomTheme();

            // Init ObjectListView
            this.treeListView.CanExpandGetter = delegate(object x) {
                return((x is DirectoryInfo) && vm.IsTreeview && (x as DirectoryInfo).HasFilesOrFolders());
            };
            this.treeListView.ChildrenGetter = delegate(object x) {
                DirectoryInfo dir = (DirectoryInfo)x;
                return(dir.Exists ? new ArrayList(dir.GetFileSystemInfos()
                                                  .Where(_ => _.Extension != ".bat")
                                                  .ToArray()) : new ArrayList());
            };
            treeListView.SmallImageList    = new ImageList();
            this.olvColumnName.ImageGetter = delegate(object row) {
                string extension = this.GetFileExtension(row);
                if (!this.treeListView.SmallImageList.Images.ContainsKey(extension))
                {
                    try
                    {
                        Image smallImage = GetSmallIconForFileType(extension);
                        this.treeListView.SmallImageList.Images.Add(extension, smallImage);
                    }
                    catch (Exception e)
                    {
                        MainController.LogString("e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3", Logtype.Error);
                        this.Close();
                    }
                }
                return(extension);
            };
            treeListView.RevealAfterExpand = false;

            // Update the TreeView
            vm.RepopulateTreeView();
            treeListView.ExpandAll();
        }
示例#6
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;
            }
        }
示例#7
0
        private async Task <int> /*int*/ RunBulkEdit(ConsoleBulkEditOptions opts)
        {
            var vm = MockKernel.Get().GetBulkEditorViewModel();

            // Bool, Uint64, Int64, Uint32, Int32, Uint16, Int16, Uint8, Int8
            BulkEditOptions.AvailableTypes type = BulkEditOptions.AvailableTypes.ANY;
            if (opts.type == "Bool")
            {
                type = BulkEditOptions.AvailableTypes.CBool;
            }
            else if (opts.type == "Uint64")
            {
                type = BulkEditOptions.AvailableTypes.CUInt64;
            }
            else if (opts.type == "Int64")
            {
                type = BulkEditOptions.AvailableTypes.CInt64;
            }
            else if (opts.type == "Uint32")
            {
                type = BulkEditOptions.AvailableTypes.CUInt32;
            }
            else if (opts.type == "Int32")
            {
                type = BulkEditOptions.AvailableTypes.CInt32;
            }
            else if (opts.type == "Uint16")
            {
                type = BulkEditOptions.AvailableTypes.CUInt16;
            }
            else if (opts.type == "Int16")
            {
                type = BulkEditOptions.AvailableTypes.CInt16;
            }
            else if (opts.type == "Uint8")
            {
                type = BulkEditOptions.AvailableTypes.CUInt8;
            }
            else if (opts.type == "Int8")
            {
                type = BulkEditOptions.AvailableTypes.CInt8;
            }
            else if (opts.type == "String")
            {
                type = BulkEditOptions.AvailableTypes.CString;
            }

            var operation = BulkEditOptions.AvailableOperations.Replace;

            if (opts.option == "*")
            {
                operation = BulkEditOptions.AvailableOperations.Multiply;
            }
            if (opts.option == "/")
            {
                operation = BulkEditOptions.AvailableOperations.Divide;
            }
            if (opts.option == "+")
            {
                operation = BulkEditOptions.AvailableOperations.Add;
            }
            if (opts.option == "-")
            {
                operation = BulkEditOptions.AvailableOperations.Subtract;
            }

            var _opts = new BulkEditOptions()
            {
                Name      = opts.varname,
                Value     = opts.val,
                ChunkName = opts.chunk,
                Type      = type,
                Extension = opts.ext,
                Operation = operation
            };

            if (opts.exc.Count() != 0)
            {
                _opts.Exclude = string.Join(",", opts.exc.ToArray());
            }
            if (opts.inc.Count() != 0)
            {
                _opts.Include = string.Join(",", opts.inc.ToArray());
            }

            return(await Task.Run(() => vm.RunBulkEditInternal(_opts)));
        }