예제 #1
0
 private void lblRefLevel_Click(object sender, EventArgs e)
 {
     if (_tool.ReferenceLevel == null)
     {
         WadActions.LoadReferenceLevel(_tool, this);
     }
 }
예제 #2
0
        public FormMain(WadToolClass tool)
        {
            InitializeComponent();
            Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            // Only how debug menu when a debugger is attached...
            debugToolStripMenuItem.Visible = Debugger.IsAttached;

            _tool = tool;

            panel3D.Configuration = tool.Configuration;
            panel3D.InitializeRendering(DeviceManager.DefaultDeviceManager.Device, tool.Configuration.RenderingItem_Antialias);
            tool.EditorEventRaised += Tool_EditorEventRaised;

            Tool_EditorEventRaised(new InitEvent());

            // Load window size
            Configuration.LoadWindowProperties(this, _tool.Configuration);

            // Try to load reference project on start-up, if specified in config
            if (!string.IsNullOrEmpty(tool.Configuration.Tool_ReferenceProject) &&
                File.Exists(tool.Configuration.Tool_ReferenceProject))
            {
                WadActions.LoadReferenceLevel(tool, this, tool.Configuration.Tool_ReferenceProject);
            }
        }
예제 #3
0
        private void ConvertSourceToTR5MainToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Wad2 dest = WadActions.ConvertWad2ToTR5Main(_tool, this, _tool.SourceWad);

            Wad2Writer.SaveToFile(dest, "F:\\temp.wad2");
            WadActions.LoadWad(_tool, this, true, "F:\\temp.wad2");
        }
예제 #4
0
        private void newSpriteSequenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var result = WadActions.CreateObject(_tool, this, new WadSpriteSequence(new WadSpriteSequenceId()));

            if (result != null)
            {
                treeDestWad.Select(result);
            }
        }
예제 #5
0
 private void treeDestWad_KeyDown(object sender, KeyEventArgs e)
 {
     switch (e.KeyCode)
     {
     case Keys.Delete:
         WadActions.DeleteObjects(_tool, this, WadArea.Destination, treeDestWad.SelectedWadObjectIds.ToList());
         break;
     }
 }
예제 #6
0
        private void butChangeSlot_Click(object sender, EventArgs e)
        {
            var result = WadActions.ChangeSlot(_tool, this);

            if (result != null)
            {
                treeDestWad.Select(result);
            }
        }
예제 #7
0
        private void TryMakeNewWad()
        {
            var result = CheckIfSaved();

            if (result == DialogResult.Yes)
            {
                WadActions.SaveWad(_tool, this, _tool.DestinationWad, false);
            }
            else if (result == DialogResult.Cancel)
            {
                return;
            }

            WadActions.CreateNewWad(_tool, this);
        }
예제 #8
0
        private void TryOpenDestWad()
        {
            var result = CheckIfSaved();

            if (result == DialogResult.Yes)
            {
                WadActions.SaveWad(_tool, this, _tool.DestinationWad, false);
            }
            else if (result == DialogResult.Cancel)
            {
                return;
            }

            WadActions.LoadWadOpenFileDialog(_tool, this, true);
        }
예제 #9
0
        private void CopyObject(bool otherSlot)
        {
            var result = WadActions.CopyObject(_tool, this, treeSourceWad.SelectedWadObjectIds.ToList(), otherSlot);

            if (result != null)
            {
                if (result.Count > 0)
                {
                    treeDestWad.Select(result);
                }
                else
                {
                    _tool.SendMessage("No objects were copied because they are already in different slots.", PopupType.Warning);
                }
            }
            else
            {
                _tool.SendMessage("No objects were copied.", PopupType.Info);
            }
        }
예제 #10
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing ||
                e.CloseReason == CloseReason.None)
            {
                var result = CheckIfSaved();
                if (result == DialogResult.Yes)
                {
                    WadActions.SaveWad(_tool, this, _tool.DestinationWad, false);
                }
                else if (result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }

                Configuration.SaveWindowProperties(this, _tool.Configuration);
                _tool.Configuration.SaveTry();
            }

            base.OnFormClosing(e);
        }
예제 #11
0
 private void butCloseRefLevel_Click(object sender, EventArgs e)
 {
     WadActions.UnloadReferenceLevel(_tool);
 }
예제 #12
0
 private void openReferenceLevelToolStripMenuItem_Click(object sender, EventArgs e)
 {
     WadActions.LoadReferenceLevel(_tool, this);
 }
예제 #13
0
 private void butOpenRefLevel_Click(object sender, EventArgs e)
 {
     WadActions.LoadReferenceLevel(_tool, this);
 }
예제 #14
0
 private void treeSourceWad_ClickOnEmpty(object sender, EventArgs e)
 {
     WadActions.LoadWadOpenFileDialog(_tool, this, false);
 }
예제 #15
0
 private void butEditSpriteSequence_Click(object sender, EventArgs e)
 {
     WadActions.EditObject(_tool, this, DeviceManager.DefaultDeviceManager);
 }
예제 #16
0
 private void butEditStaticModel_Click(object sender, EventArgs e)
 {
     WadActions.EditObject(_tool, this, DeviceManager.DefaultDeviceManager);
 }
예제 #17
0
 private void editAnimationsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     WadActions.EditObject(_tool, this, DeviceManager.DefaultDeviceManager);
 }
예제 #18
0
 private void importModelAsStaticMeshToolStripMenuItem_Click(object sender, EventArgs e)
 {
     WadActions.ImportModelAsStaticMesh(_tool, this);
 }
예제 #19
0
 private void butSaveAs_Click(object sender, EventArgs e)
 {
     WadActions.SaveWad(_tool, this, _tool.DestinationWad, true);
 }
예제 #20
0
 private void butOpenSourceWad_Click(object sender, EventArgs e)
 {
     WadActions.LoadWadOpenFileDialog(_tool, this, false);
 }
예제 #21
0
 private void closeReferenceLevelToolStripMenuItem_Click(object sender, EventArgs e)
 {
     WadActions.UnloadReferenceLevel(_tool);
 }
예제 #22
0
 private void butEditSkeleton_Click(object sender, EventArgs e)
 {
     WadActions.EditSkeletion(_tool, this);
 }
예제 #23
0
 private void editSkeletonToolStripMenuItem_Click(object sender, EventArgs e)
 {
     WadActions.EditSkeletion(_tool, this);
 }
예제 #24
0
        public static void Main(string[] args)
        {
            // Load configuration
            var initialEvents = new List <LogEventInfo>();
            var configuration = new Configuration().LoadOrUseDefault <Configuration>(initialEvents);

            // Update DarkUI configuration
            Colors.Brightness = configuration.UI_FormColor_Brightness / 100.0f;

            // Setup logging
            using (var log = new Logging(configuration.Log_MinLevel, configuration.Log_WriteToFile, configuration.Log_ArchiveN, initialEvents))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                Application.ThreadException += (sender, e) =>
                {
                    log.HandleException(e.Exception);
                    using (var dialog = new ThreadExceptionDialog(e.Exception))
                        if (dialog.ShowDialog() == DialogResult.Abort)
                        {
                            Environment.Exit(1);
                        }
                };

                // Show startup help
                if (configuration.StartUpHelp_Show)
                {
                    var help = new FormStartupHelp();
                    Application.Run(help);
                    switch (help.DialogResult)
                    {
                    case DialogResult.Cancel:
                        return;

                    case DialogResult.OK:
                        configuration.StartUpHelp_Show = false;
                        break;
                    }
                }
                configuration.SaveTry();

                // Run
                if (!File.Exists(Application.StartupPath + "\\Catalogs\\TrCatalog.xml"))
                {
                    MessageBox.Show("TrCatalog.xml is missing.\nMake sure you have TrCatalog.xml in /Catalogs/ subfolder.");
                    Environment.Exit(1);
                }
                TrCatalog.LoadCatalog(Application.StartupPath + "\\Catalogs\\TRCatalog.xml");

                Application.AddMessageFilter(new ControlScrollFilter());
                SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());

                using (WadToolClass tool = new WadToolClass(configuration))
                {
                    string startWad = null;
                    string refLevel = null;

                    if (args.Length > 0)
                    {
                        bool loadAsRefLevel = false;

                        foreach (var arg in args)
                        {
                            if (arg.Equals("-r", StringComparison.InvariantCultureIgnoreCase))
                            {
                                loadAsRefLevel = true;
                            }
                            else
                            {
                                if (!File.Exists(arg))
                                {
                                    continue; // No file and no valid argument, don't even try to load anything
                                }
                                if (loadAsRefLevel)
                                {
                                    if (arg.EndsWith("prj2", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        refLevel = arg;
                                    }
                                }
                                else
                                {
                                    startWad = arg;
                                }

                                loadAsRefLevel = false; // Reset arg mode if no expected path was found next to it
                            }
                        }
                    }

                    using (FormMain form = new FormMain(tool))
                    {
                        form.Show();

                        if (!string.IsNullOrEmpty(refLevel))
                        {
                            WadActions.LoadReferenceLevel(tool, form, refLevel);
                        }
                        if (!string.IsNullOrEmpty(startWad))
                        {
                            WadActions.LoadWad(tool, form, true, startWad);
                        }

                        Application.Run(form);
                    }
                }
            }
        }