Exemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            LevelSettings settings = _editor?.Level?.Settings;

            if (settings == null)
            {
                return;
            }
            if (settings.Wads.All(wad => wad.LoadException != null))
            {
                ReferencedWad errorWad = settings.Wads.FirstOrDefault(wad => wad.LoadException != null);
                string        notifyMessage;
                if (errorWad == null)
                {
                    notifyMessage = "Click here to load new WAD file.";
                }
                else
                {
                    string filePath = settings.MakeAbsolute(errorWad.Path);
                    string fileName = PathC.GetFileNameWithoutExtensionTry(filePath) ?? "";
                    if (PathC.IsFileNotFoundException(errorWad.LoadException))
                    {
                        notifyMessage = "Wad file '" + fileName + "' was not found!\n";
                    }
                    else
                    {
                        notifyMessage = "Unable to load wad from file '" + fileName + "'.\n";
                    }
                    notifyMessage += "Click here to choose a replacement.\n\n";
                    notifyMessage += "Path: " + (filePath ?? "");
                }

                e.Graphics.Clear(Parent.BackColor);
                using (var b = new SolidBrush(Colors.DisabledText))
                    e.Graphics.DrawString(notifyMessage, Font, b, ClientRectangle,
                                          new StringFormat {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });

                ControlPaint.DrawBorder(e.Graphics, ClientRectangle, Colors.GreySelection, ButtonBorderStyle.Solid);
            }
            else
            {
                base.OnPaint(e);
            }
        }
Exemplo n.º 2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            switch (e.Button)
            {
            case MouseButtons.Left:
                LevelSettings settings = _editor?.Level?.Settings;
                if (settings != null && settings.Wads.All(wad => wad.LoadException != null))
                {
                    ReferencedWad wadToUpdate = settings.Wads.FirstOrDefault(wad => wad.LoadException != null);
                    if (wadToUpdate != null)
                    {
                        EditorActions.UpdateWadFilepath(Parent, wadToUpdate);
                    }
                    else
                    {
                        EditorActions.AddWad(Parent);
                    }
                }
                else if (_editor.ChosenItem != null)
                {
                    if (_editor.ChosenItem.Value.IsStatic)
                    {
                        var stat = _editor.Level.Settings.WadTryGetStatic(_editor.ChosenItem.Value.StaticId);
                        if (stat != null)
                        {
                            DoDragDrop(stat, DragDropEffects.Copy);
                        }
                    }
                    else
                    {
                        var mov = _editor.Level.Settings.WadTryGetMoveable(_editor.ChosenItem.Value.MoveableId);
                        if (mov != null)
                        {
                            DoDragDrop(mov, DragDropEffects.Copy);
                        }
                    }
                }
                break;
            }
        }
Exemplo n.º 3
0
            public override void TryReload(FileSystemWatcherManager sender, FileSystemWatcherManager.ReloadArgs e)
            {
                LevelSettings settings = Parent.Settings;

                if (settings == null)
                {
                    return;
                }

                ReferencedWad newWad = Wad.Clone();

                newWad.Reload(settings);
                Parent.SynchronizationContext.Post(unused =>
                {
                    Wad.Assign(newWad);
                    Parent?.WadChanged(null, new ChangedEventArgs <ReferencedWad> {
                        Object = newWad
                    });
                }, null);
            }
        private void AddWadFileNodes(LevelSettings settings)
        {
            for (int i = 0; i < settings.Wads.Count; i++)
            {
                ReferencedWad wad         = settings.Wads[i];
                string        wadFilePath = GetFullFilePath(wad.Path, settings);

                if (!File.Exists(wadFilePath))
                {
                    continue;
                }

                DarkTreeNode node = new DarkTreeNode
                {
                    Icon = Properties.Resources.wad_file.ToBitmap(),
                    Text = wadFilePath,
                };

                treeView_Resources.Nodes[1].Nodes.Add(node);
                treeView_Resources.Nodes[1].Expanded = true;
            }
        }