void Update()
        {
            if (DocumentContext == null)
            {
                return;
            }
            var parsedDocument = DocumentContext.ParsedDocument;

            if (parsedDocument == null)
            {
                return;
            }
            var caretOffset = Editor.CaretOffset;
            var model       = parsedDocument.GetAst <SemanticModel>();

            if (model == null)
            {
                return;
            }
            CancelUpdatePath();
            var cancellationToken = src.Token;

            amb = new AstAmbience(TypeSystemService.Workspace.Options);
            var loc = Editor.CaretLocation;

            Task.Run(async delegate {
                var unit = model.SyntaxTree;
                SyntaxNode root;
                SyntaxNode node;
                try {
                    root = await unit.GetRootAsync(cancellationToken).ConfigureAwait(false);
                    if (root.FullSpan.Length <= caretOffset)
                    {
                        return;
                    }
                    node = root.FindNode(TextSpan.FromBounds(caretOffset, caretOffset));
                    if (node.SpanStart != caretOffset)
                    {
                        node = root.SyntaxTree.FindTokenOnLeftOfPosition(caretOffset, cancellationToken).Parent;
                    }
                } catch (Exception ex) {
                    Console.WriteLine(ex);
                    return;
                }

                var curMember = node != null ? node.AncestorsAndSelf().FirstOrDefault(m => m is VariableDeclaratorSyntax && m.Parent != null && !(m.Parent.Parent is LocalDeclarationStatementSyntax) || (m is MemberDeclarationSyntax && !(m is NamespaceDeclarationSyntax))) : null;
                var curType   = node != null ? node.AncestorsAndSelf().FirstOrDefault(IsType) : null;

                var curProject = ownerProjects != null && ownerProjects.Count > 1 ? DocumentContext.Project : null;

                if (curType == curMember || curType is DelegateDeclarationSyntax)
                {
                    curMember = null;
                }
                if (isPathSet && curType == lastType && curMember == lastMember && curProject == lastProject)
                {
                    return;
                }
                var curTypeMakeup   = GetEntityMarkup(curType);
                var curMemberMarkup = GetEntityMarkup(curMember);
                if (isPathSet && curType != null && lastType != null && curTypeMakeup == lastTypeMarkup &&
                    curMember != null && lastMember != null && curMemberMarkup == lastMemberMarkup && curProject == lastProject)
                {
                    return;
                }

                var regionEntry = await GetRegionEntry(DocumentContext.ParsedDocument, loc).ConfigureAwait(false);

                Gtk.Application.Invoke(delegate {
                    var result = new List <PathEntry>();

                    if (curProject != null)
                    {
                        // Current project if there is more than one
                        result.Add(new PathEntry(ImageService.GetIcon(curProject.StockIcon, Gtk.IconSize.Menu), GLib.Markup.EscapeText(curProject.Name))
                        {
                            Tag = curProject
                        });
                    }

                    if (curType == null)
                    {
                        if (CurrentPath != null && CurrentPath.Length == 1 && CurrentPath [0]?.Tag is CSharpSyntaxTree)
                        {
                            return;
                        }
                        if (CurrentPath != null && CurrentPath.Length == 2 && CurrentPath [1]?.Tag is CSharpSyntaxTree)
                        {
                            return;
                        }
                        var prevPath = CurrentPath;
                        result.Add(new PathEntry(GettextCatalog.GetString("No selection"))
                        {
                            Tag = unit
                        });
                        if (cancellationToken.IsCancellationRequested)
                        {
                            return;
                        }

                        CurrentPath    = result.ToArray();
                        lastType       = curType;
                        lastTypeMarkup = curTypeMakeup;

                        lastMember       = curMember;
                        lastMemberMarkup = curMemberMarkup;

                        lastProject = curProject;
                        OnPathChanged(new DocumentPathChangedEventArgs(prevPath));
                        return;
                    }

                    if (curType != null)
                    {
                        var type = curType;
                        var pos  = result.Count;
                        while (type != null)
                        {
                            if (!(type is BaseTypeDeclarationSyntax))
                            {
                                break;
                            }
                            var tag = (object)type.Ancestors().FirstOrDefault(IsType) ?? unit;
                            result.Insert(pos, new PathEntry(ImageService.GetIcon(type.GetStockIcon(), Gtk.IconSize.Menu), GetEntityMarkup(type))
                            {
                                Tag = tag
                            });
                            type = type.Parent;
                        }
                    }
                    if (curMember != null)
                    {
                        result.Add(new PathEntry(ImageService.GetIcon(curMember.GetStockIcon(), Gtk.IconSize.Menu), curMemberMarkup)
                        {
                            Tag = curMember
                        });
                        if (curMember.Kind() == SyntaxKind.GetAccessorDeclaration ||
                            curMember.Kind() == SyntaxKind.SetAccessorDeclaration ||
                            curMember.Kind() == SyntaxKind.AddAccessorDeclaration ||
                            curMember.Kind() == SyntaxKind.RemoveAccessorDeclaration)
                        {
                            var parent = curMember.Parent;
                            if (parent != null)
                            {
                                result.Insert(result.Count - 1, new PathEntry(ImageService.GetIcon(parent.GetStockIcon(), Gtk.IconSize.Menu), GetEntityMarkup(parent))
                                {
                                    Tag = parent
                                });
                            }
                        }
                    }

                    if (regionEntry != null)
                    {
                        result.Add(regionEntry);
                    }

                    PathEntry noSelection = null;
                    if (curType == null)
                    {
                        noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                        {
                            Tag = unit
                        };
                    }
                    else if (curMember == null && !(curType is DelegateDeclarationSyntax))
                    {
                        noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                        {
                            Tag = curType
                        };
                    }

                    if (noSelection != null)
                    {
                        result.Add(noSelection);
                    }
                    var prev = CurrentPath;
                    if (prev != null && prev.Length == result.Count)
                    {
                        bool equals = true;
                        for (int i = 0; i < prev.Length; i++)
                        {
                            if (prev [i].Markup != result [i].Markup)
                            {
                                equals = false;
                                break;
                            }
                        }
                        if (equals)
                        {
                            return;
                        }
                    }
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                    CurrentPath    = result.ToArray();
                    lastType       = curType;
                    lastTypeMarkup = curTypeMakeup;

                    lastMember       = curMember;
                    lastMemberMarkup = curMemberMarkup;

                    lastProject = curProject;

                    OnPathChanged(new DocumentPathChangedEventArgs(prev));
                });
            });
        }
예제 #2
0
        void UpdatePath(object sender, Mono.TextEditor.DocumentLocationEventArgs e)
        {
            var parsedDocument = Document.ParsedDocument;

            if (parsedDocument == null || parsedDocument.ParsedFile == null)
            {
                return;
            }
            amb = new AstAmbience(document.GetFormattingOptions());

            var unit = parsedDocument.GetAst <SyntaxTree> ();

            if (unit == null)
            {
                return;
            }

            var loc = Document.Editor.Caret.Location;

            var curType   = (EntityDeclaration)unit.GetNodeAt(loc, n => n is TypeDeclaration || n is DelegateDeclaration);
            var curMember = unit.GetNodeAt <EntityDeclaration> (loc);

            if (curType == curMember)
            {
                curMember = null;
            }
            if (isPathSet && curType == lastType && lastMember == curMember)
            {
                return;
            }

            var curTypeMakeup   = GetEntityMarkup(curType);
            var curMemberMarkup = GetEntityMarkup(curMember);

            if (isPathSet && curType != null && lastType != null && curType.StartLocation == lastType.StartLocation && curTypeMakeup == lastTypeMarkup &&
                curMember != null && lastMember != null && curMember.StartLocation == lastMember.StartLocation && curMemberMarkup == lastMemberMarkup)
            {
                return;
            }

            lastType       = curType;
            lastTypeMarkup = curTypeMakeup;

            lastMember       = curMember;
            lastMemberMarkup = curMemberMarkup;

            if (curType == null)
            {
                if (CurrentPath != null && CurrentPath.Length == 1 && CurrentPath [0].Tag is IUnresolvedFile)
                {
                    return;
                }
                var prevPath = CurrentPath;
                CurrentPath = new PathEntry[] { new PathEntry(GettextCatalog.GetString("No selection"))
                                                {
                                                    Tag = unit
                                                } };
                OnPathChanged(new DocumentPathChangedEventArgs(prevPath));
                return;
            }

            //	ThreadPool.QueueUserWorkItem (delegate {
            var result = new List <PathEntry> ();

            if (curType != null)
            {
                var type = curType;
                while (type != null)
                {
                    var declaringType = type.Parent as TypeDeclaration;
                    result.Insert(0, new PathEntry(ImageService.GetPixbuf(type.GetStockIcon(false), Gtk.IconSize.Menu), GetEntityMarkup(type))
                    {
                        Tag = (AstNode)declaringType ?? unit
                    });
                    type = declaringType;
                }
            }

            if (curMember != null)
            {
                result.Add(new PathEntry(ImageService.GetPixbuf(curMember.GetStockIcon(true), Gtk.IconSize.Menu), curMemberMarkup)
                {
                    Tag = curMember
                });
                if (curMember is Accessor)
                {
                    var parent = curMember.Parent as EntityDeclaration;
                    if (parent != null)
                    {
                        result.Insert(result.Count - 1, new PathEntry(ImageService.GetPixbuf(parent.GetStockIcon(true), Gtk.IconSize.Menu), GetEntityMarkup(parent))
                        {
                            Tag = parent
                        });
                    }
                }
            }

            var entry = GetRegionEntry(parsedDocument, loc);

            if (entry != null)
            {
                result.Add(entry);
            }

            PathEntry noSelection = null;

            if (curType == null)
            {
                noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = unit
                };
            }
            else if (curMember == null && !(curType is DelegateDeclaration))
            {
                noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = curType
                };
            }

            if (noSelection != null)
            {
                result.Add(noSelection);
            }

            var prev = CurrentPath;

            if (prev != null && prev.Length == result.Count)
            {
                bool equals = true;
                for (int i = 0; i < prev.Length; i++)
                {
                    if (prev [i].Markup != result [i].Markup)
                    {
                        equals = false;
                        break;
                    }
                }
                if (equals)
                {
                    return;
                }
            }
            //		Gtk.Application.Invoke (delegate {
            CurrentPath = result.ToArray();
            OnPathChanged(new DocumentPathChangedEventArgs(prev));
            //		});
            //	});
        }
        // Yoinked from C# binding
        void UpdatePath(object sender, Mono.TextEditor.TextDocumentLocationEventArgs e)
        {
            var unit = Document.CompilationUnit;

            if (unit == null)
            {
                return;
            }

            var              loc    = textEditorData.Caret.Location;
            IType            type   = unit.GetTypeAt(loc.Line, loc.Column);
            List <PathEntry> result = new List <PathEntry> ();
            Ambience         amb    = GetAmbience();
            IMember          member = null;
            INode            node   = (INode)unit;

            if (type != null && type.ClassType != ClassType.Delegate)
            {
                member = type.GetMemberAt(loc.Line, loc.Column);
            }

            if (null != member)
            {
                node = member;
            }
            else if (null != type)
            {
                node = type;
            }

            while (node != null)
            {
                PathEntry entry;
                if (node is ICompilationUnit)
                {
                    if (!Document.ParsedDocument.UserRegions.Any())
                    {
                        break;
                    }
                    FoldingRegion reg = Document.ParsedDocument.UserRegions.Where(r => r.Region.Contains(loc.Line, loc.Column)).LastOrDefault();
                    if (reg == null)
                    {
                        entry = new PathEntry(GettextCatalog.GetString("No region"));
                    }
                    else
                    {
                        entry = new PathEntry(CompilationUnitDataProvider.Pixbuf, reg.Name);
                    }
                    entry.Position = EntryPosition.Right;
                }
                else
                {
                    entry = new PathEntry(ImageService.GetPixbuf(((IMember)node).StockIcon, IconSize.Menu), amb.GetString((IMember)node, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates));
                }
                entry.Tag = node;
                result.Insert(0, entry);
                node = node.Parent;
            }

            PathEntry noSelection = null;

            if (type == null)
            {
                noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = new CustomNode(Document.CompilationUnit)
                };
            }
            else if (member == null && type.ClassType != ClassType.Delegate)
            {
                noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = new CustomNode(type)
                }
            }
            ;
            if (noSelection != null)
            {
                result.Add(noSelection);
            }

            var prev = CurrentPath;

            CurrentPath = result.ToArray();
            OnPathChanged(new DocumentPathChangedEventArgs(prev));
        }
예제 #4
0
        private void UpdatePath(object sender, Mono.TextEditor.DocumentLocationEventArgs e)
        {
            var ast = Document.ParsedDocument as ParsedDModule;

            if (ast == null)
            {
                return;
            }

            var SyntaxTree = ast.DDom;

            if (SyntaxTree == null)
            {
                return;
            }

            // Resolve the hovered piece of code
            var loc          = new CodeLocation(Document.Editor.Caret.Location.Column, Document.Editor.Caret.Location.Line);
            var currentblock = DResolver.SearchBlockAt(SyntaxTree, loc);

            //could be an enum value, which is not IBlockNode
            if (currentblock is DEnum)
            {
                foreach (INode nd in (currentblock as DEnum).Children)
                {
                    if ((nd is DEnumValue) &&
                        ((nd.Location <= loc) && (nd.EndLocation >= loc)))
                    {
                        currentblock = nd as IBlockNode;
                        break;
                    }
                }
            }

            List <PathEntry> result = new List <PathEntry>();
            INode            node   = currentblock;
            PathEntry        entry;

            while ((node != null) && ((node is IBlockNode) || (node is DEnumValue)))
            {
                var icon = DIcons.GetNodeIcon(node as DNode);

                entry          = new PathEntry(icon.IsNull?null: ImageService.GetIcon(icon.Name, IconSize.Menu), node.Name + DParameterDataProvider.GetNodeParamString(node));
                entry.Position = EntryPosition.Left;
                entry.Tag      = node;
                //do not include the module in the path bar
                if ((node.Parent != null) && !((node is DNode) && (node as DNode).IsAnonymous))
                {
                    result.Insert(0, entry);
                }
                node = node.Parent;
            }

            if (!((currentblock is DMethod) || (currentblock is DEnumValue)))
            {
                PathEntry noSelection = new PathEntry(GettextCatalog.GetString("No Selection"))
                {
                    Tag = new NoSelectionCustomNode(currentblock)
                };
                result.Add(noSelection);
            }

            entry = GetRegionEntry(Document.ParsedDocument, Document.Editor.Caret.Location);
            if (entry != null)
            {
                result.Add(entry);
            }

            var prev = CurrentPath;

            CurrentPath = result.ToArray();
            OnPathChanged(new DocumentPathChangedEventArgs(prev));
        }
        public IEnumerable <T> ShapeCast <TShape>(TShape shape) where TShape : IVolume
        {
            if (!CastPathCache.TryExtractLast(out var path))
            {
                // A search depth of 64 will probably never be reached, so this is on the safe side.
                path = new PathEntry[64];
            }

            var startVersion = version;
            var pathDepth    = 0;
            var cell         = root;
            var childIndex   = -1;
            var fullyInside  = shape.ContainsAabb(root.Start, root.End);

            while (pathDepth >= 0)
            {
                childIndex++;

                if (cell.Children == null)
                {
                    foreach (var item in cell.Items)
                    {
                        if (fullyInside || shape.ContainsPoint(item.Position))
                        {
                            if (startVersion != version)
                            {
                                CastPathCache.Add(path);
                                throw new InvalidOperationException("The enumerator has been modified since the last step and cannot be used anymore.");
                            }

                            yield return(item.Item);
                        }
                    }
                }
                else
                {
                    if (childIndex < cell.Children.Length)
                    {
                        var child = cell.Children[childIndex];
                        if (child != null && (fullyInside || shape.IntersectsAabb(child.Start, child.End)))
                        {
                            var childFullyInside = fullyInside;
                            if (!childFullyInside)
                            {
                                childFullyInside = shape.ContainsAabb(child.Start, child.End);
                            }

                            path[pathDepth] = new PathEntry(cell, childIndex, fullyInside);
                            pathDepth++;
                            cell        = child;
                            childIndex  = -1;
                            fullyInside = childFullyInside;
                        }

                        continue;
                    }
                }

                // Go one layer up
                pathDepth--;
                if (pathDepth < 0)
                {
                    break;
                }

                var c = path[pathDepth];
                cell        = c.Cell;
                childIndex  = c.ChildIndex;
                fullyInside = c.Flag;
            }


            CastPathCache.Add(path);
        }
예제 #6
0
        void UpdatePath(object sender, Mono.TextEditor.DocumentLocationEventArgs e)
        {
            var parsedDocument = Document.ParsedDocument;

            if (parsedDocument == null || parsedDocument.ParsedFile == null)
            {
                return;
            }
            amb = new AstAmbience(document.GetFormattingOptions());

            var unit = parsedDocument.GetAst <SyntaxTree> ();

            if (unit == null)
            {
                return;
            }

            var loc         = Document.Editor.Caret.Location;
            var compExt     = Document.GetContent <CSharpCompletionTextEditorExtension> ();
            var caretOffset = Document.Editor.Caret.Offset;
            var segType     = compExt.GetTypeAt(caretOffset);

            if (segType != null)
            {
                loc = segType.Region.Begin;
            }

            var curType = (EntityDeclaration)unit.GetNodeAt(loc, n => n is TypeDeclaration || n is DelegateDeclaration);

            var curProject = ownerProjects.Count > 1 ? Document.Project : null;

            var segMember = compExt.GetMemberAt(caretOffset);

            if (segMember != null)
            {
                loc = segMember.Region.Begin;
            }
            else
            {
                loc = Document.Editor.Caret.Location;
            }

            var curMember = unit.GetNodeAt <EntityDeclaration> (loc);

            if (curType == curMember || curType is DelegateDeclaration)
            {
                curMember = null;
            }
            if (isPathSet && curType == lastType && curMember == lastMember && curProject == lastProject)
            {
                return;
            }

            var curTypeMakeup   = GetEntityMarkup(curType);
            var curMemberMarkup = GetEntityMarkup(curMember);

            if (isPathSet && curType != null && lastType != null && curType.StartLocation == lastType.StartLocation && curTypeMakeup == lastTypeMarkup &&
                curMember != null && lastMember != null && curMember.StartLocation == lastMember.StartLocation && curMemberMarkup == lastMemberMarkup && curProject == lastProject)
            {
                return;
            }

            lastType       = curType;
            lastTypeMarkup = curTypeMakeup;

            lastMember       = curMember;
            lastMemberMarkup = curMemberMarkup;

            lastProject = curProject;

            var result = new List <PathEntry> ();

            if (ownerProjects.Count > 1)
            {
                // Current project if there is more than one
                result.Add(new PathEntry(ImageService.GetIcon(Document.Project.StockIcon, Gtk.IconSize.Menu), GLib.Markup.EscapeText(Document.Project.Name))
                {
                    Tag = Document.Project
                });
            }

            if (curType == null)
            {
                if (CurrentPath != null && CurrentPath.Length == 1 && CurrentPath [0].Tag is IUnresolvedFile)
                {
                    return;
                }
                if (CurrentPath != null && CurrentPath.Length == 2 && CurrentPath [1].Tag is IUnresolvedFile)
                {
                    return;
                }
                var prevPath = CurrentPath;
                result.Add(new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = unit
                });
                CurrentPath = result.ToArray();
                OnPathChanged(new DocumentPathChangedEventArgs(prevPath));
                return;
            }

            if (curType != null)
            {
                var type = curType;
                var pos  = result.Count;
                while (type != null)
                {
                    var declaringType = type.Parent as TypeDeclaration;
                    result.Insert(pos, new PathEntry(ImageService.GetIcon(type.GetStockIcon(), Gtk.IconSize.Menu), GetEntityMarkup(type))
                    {
                        Tag = (AstNode)declaringType ?? unit
                    });
                    type = declaringType;
                }
            }

            if (curMember != null)
            {
                result.Add(new PathEntry(ImageService.GetIcon(curMember.GetStockIcon(), Gtk.IconSize.Menu), curMemberMarkup)
                {
                    Tag = curMember
                });
                if (curMember is Accessor)
                {
                    var parent = curMember.Parent as EntityDeclaration;
                    if (parent != null)
                    {
                        result.Insert(result.Count - 1, new PathEntry(ImageService.GetIcon(parent.GetStockIcon(), Gtk.IconSize.Menu), GetEntityMarkup(parent))
                        {
                            Tag = parent
                        });
                    }
                }
            }

            var entry = GetRegionEntry(parsedDocument, loc);

            if (entry != null)
            {
                result.Add(entry);
            }

            PathEntry noSelection = null;

            if (curType == null)
            {
                noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = unit
                };
            }
            else if (curMember == null && !(curType is DelegateDeclaration))
            {
                noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = curType
                };
            }

            if (noSelection != null)
            {
                result.Add(noSelection);
            }

            var prev = CurrentPath;

            if (prev != null && prev.Length == result.Count)
            {
                bool equals = true;
                for (int i = 0; i < prev.Length; i++)
                {
                    if (prev [i].Markup != result [i].Markup)
                    {
                        equals = false;
                        break;
                    }
                }
                if (equals)
                {
                    return;
                }
            }
            //		Gtk.Application.Invoke (delegate {
            CurrentPath = result.ToArray();
            OnPathChanged(new DocumentPathChangedEventArgs(prev));
            //		});
            //	});
        }
예제 #7
0
        public bool LoadState(string _key, string GameSystem, string GameName)
        {
            string Key;
            bool   GameHasChanged = false;
            string TheoricalSaveStateFilename;

            if (_key == "btn")
            {
                Key = btnParentKeys[Convert.ToInt32(currentSelectedState)];

                GlobalWin.Sound.StopSound();

                if (ChangeGameWarning(btnAttachedRom[Convert.ToInt32(currentSelectedState)]))
                {
                    RTC_Core.LoadRom(btnAttachedRom[Convert.ToInt32(currentSelectedState)]);
                    GameHasChanged = true;
                }
                else
                {
                    GlobalWin.Sound.StartSound();
                    return(false);
                }

                GlobalWin.Sound.StartSound();
            }
            else if (_key == null)
            {
                RTC_Restore.SaveRestore();
                return(false);
            }
            else
            {
                Key = _key;
            }


            PathEntry pathEntry = Global.Config.PathEntries[Global.Game.System, "Savestates"] ??
                                  Global.Config.PathEntries[Global.Game.System, "Base"];

            if (!GameHasChanged)
            {
                TheoricalSaveStateFilename = RTC_Core.bizhawkDir + "\\" + GameSystem + "\\State\\" + GameName + "." + Key + ".timejump.State";
            }
            else
            {
                TheoricalSaveStateFilename = RTC_Core.bizhawkDir + "\\" + RTC_Core.EmuFolderCheck(pathEntry.SystemDisplayName) + "\\State\\" + PathManager.FilesystemSafeName(Global.Game) + "." + Key + ".timejump.State";
            }


            if (File.Exists(TheoricalSaveStateFilename))
            {
                RTC_Core.LoadStateCorruptorSafe(Key + ".timejump", null);
            }
            else
            {
                GlobalWin.Sound.StopSound();
                MessageBox.Show("Error loading savestate (File not found)");
                GlobalWin.Sound.StartSound();
                return(false);
            }

            RTC_Restore.SaveRestore();
            return(true);
        }
예제 #8
0
		public static void LOAD_GAME_DONE()
		{
			try
			{
				if (disableRTC) return;

				if (AllSpec.UISpec == null)
				{
					CLOSE_GAME();
					GlobalWin.MainForm.CloseRom();
					MessageBox.Show("It appears you haven't connected to StandaloneRTC. Please make sure that the RTC is running and not just Bizhawk.\nIf you have an antivirus, it might be blocking the RTC from launching.\n\nIf you keep getting this message, poke the RTC devs for help (Discord is in the launcher).", "RTC Not Connected");
					return;
				}

				//Glitch Harvester warning for archives

				string uppercaseFilename = GlobalWin.MainForm.CurrentlyOpenRom.ToUpper();
				if (uppercaseFilename.Contains(".ZIP") || uppercaseFilename.Contains(".7Z"))
				{
					MessageBox.Show($"The selected file {Path.GetFileName(uppercaseFilename.Split('|')[0])} is an archive.\nThe RTC does not support archived rom files. Please extract the file then try again.");
					CLOSE_GAME(true);
					return;
				}

				//Load Game vars into RTC_Core
				PathEntry pathEntry = Global.Config.PathEntries[Global.Game.System, "Savestates"] ??
				Global.Config.PathEntries[Global.Game.System, "Base"];



				//prepare memory domains in advance on bizhawk side
				bool domainsChanged = RefreshDomains(false);

				PartialSpec gameDone = new PartialSpec("VanguardSpec");
				gameDone[VSPEC.SYSTEM] = BIZHAWK_GET_CURRENTLYLOADEDSYSTEMNAME().ToUpper();
				gameDone[VSPEC.GAMENAME] = BIZHAWK_GET_FILESYSTEMGAMENAME();
				gameDone[VSPEC.SYSTEMPREFIX] = BIZHAWK_GET_SAVESTATEPREFIX();
				gameDone[VSPEC.SYSTEMCORE] = BIZHAWK_GET_SYSTEMCORENAME(Global.Game.System);
				gameDone[VSPEC.SYNCSETTINGS] = BIZHAWK_GETSET_SYNCSETTINGS;
				gameDone[VSPEC.OPENROMFILENAME] = GlobalWin.MainForm.CurrentlyOpenRom;
				gameDone[VSPEC.MEMORYDOMAINS_BLACKLISTEDDOMAINS] = VanguardCore.GetBlacklistedDomains(BIZHAWK_GET_CURRENTLYLOADEDSYSTEMNAME().ToUpper());
				gameDone[VSPEC.MEMORYDOMAINS_INTERFACES] = GetInterfaces();
				gameDone[VSPEC.CORE_DISKBASED] = isCurrentCoreDiskBased();
				AllSpec.VanguardSpec.Update(gameDone);

				//This is local. If the domains changed it propgates over netcore
				LocalNetCoreRouter.Route(Endpoints.CorruptCore, Remote.EventDomainsUpdated, domainsChanged, true);

				if (VanguardCore.GameName != lastGameName)
				{
					LocalNetCoreRouter.Route(Endpoints.UI, Basic.ResetGameProtectionIfRunning, true);
				}
				lastGameName = VanguardCore.GameName;

				RtcCore.InvokeLoadGameDone();
				VanguardCore.RTE_API.LOAD_GAME();
			}
			catch (Exception ex)
			{
				if (VanguardCore.ShowErrorDialog(ex) == DialogResult.Abort)
					throw new AbortEverythingException();
			}
		}
예제 #9
0
        public Dictionary <Station, StationRenderProps> Render(Graphics g, Margins margin, float width, float height, bool drawHeader, bool exportColor)
        {
            var stationFont    = (Font)attrs.StationFont; // Reminder: Do not dispose, will be disposed with MFont instance!
            var stationOffsets = new Dictionary <Station, StationRenderProps>();

            var raw                 = path.GetRawPath().ToList();
            var allTrackCount       = raw.Select(s => s.Tracks.Count).Sum();
            var stasWithTracks      = raw.Count(s => s.Tracks.Any());
            var allTrackWidth       = (stasWithTracks + allTrackCount) * StationRenderProps.IndividualTrackOffset;
            var verticalTrackOffset = GetTrackOffset(g, stationFont) + TOP_GAP;

            float length = 0f;

            PathEntry lastpe = null;

            foreach (var sta in path.PathEntries)
            {
                var er = path.GetEntryRoute(sta.Station);
                if (er != Timetable.UNASSIGNED_ROUTE_ID)
                {
                    length += (sta !.Station.Positions.GetPosition(er) - lastpe !.Station.Positions.GetPosition(er)) !.Value;
                }
                lastpe = sta;
            }

            StationRenderProps lastPos = null;

            lastpe = null;
            float kil = 0f;

            foreach (var sta in path.PathEntries)
            {
                var style = new StationStyle(sta.Station, attrs);

                var er = path.GetEntryRoute(sta.Station);
                if (er != Timetable.UNASSIGNED_ROUTE_ID)
                {
                    kil += (sta !.Station.Positions.GetPosition(er) - lastpe !.Station.Positions.GetPosition(er)) !.Value;
                }
                lastpe = sta;

                StationRenderProps posX;
                if (!attrs.MultiTrack)
                {
                    posX = new StationRenderProps(sta.Station, kil, ((kil / length) * (width - margin.Right - margin.Left)));
                }
                else
                {
                    var availWidth = width - margin.Right - margin.Left - allTrackWidth;
                    var lastKil    = lastPos?.CurKilometer ?? 0f;
                    var lastRight  = lastPos?.Right ?? 0f;
                    var leftOffset = (((kil / length) - (lastKil / length)) * availWidth);
                    posX = new StationRenderProps(sta.Station, kil, lastRight + leftOffset, true);
                }
                lastPos = posX;
                stationOffsets.Add(sta.Station, posX);

                if (!style.CalcedShow)
                {
                    continue;
                }

                using var pen = new Pen(style.CalcedColor.ToSD(exportColor), style.CalcedWidth)
                      {
                          DashPattern = ds.ParseDashstyle(style.CalcedLineStyle)
                      };
                using var brush = new SolidBrush(style.CalcedColor.ToSD(exportColor));

                if (!attrs.MultiTrack)
                {
                    // Linie (Single-Track-Mode)
                    g.DrawLine(pen, margin.Left + posX.Center, margin.Top - TOP_GAP, margin.Left + posX.Center, height - margin.Bottom);
                }
                else
                {
                    // Linie (Multi-Track-Mode)
                    g.DrawLine(pen, margin.Left + posX.Left, margin.Top - TOP_GAP, margin.Left + posX.Left, height - margin.Bottom);
                    foreach (var trackX in posX.TrackOffsets)
                    {
                        g.DrawLine(pen, margin.Left + trackX.Value, margin.Top - TOP_GAP, margin.Left + trackX.Value, height - margin.Bottom);
                    }
                    g.DrawLine(pen, margin.Left + posX.Right, margin.Top - TOP_GAP, margin.Left + posX.Right, height - margin.Bottom);
                }

                if (!drawHeader)
                {
                    continue;
                }

                // Stationsnamen
                if (attrs.DrawHeader)
                {
                    var display = StationDisplay(sta);
                    var size    = g.MeasureString(stationFont, display);

                    if (attrs.StationVertical)
                    {
                        var matrix = g.Transform.Clone();

                        g.TranslateTransform(margin.Left + posX.Center + (size.Height / 2), margin.Top - 8 - verticalTrackOffset - size.Width);
                        g.RotateTransform(90);
                        g.DrawText(stationFont, brush, 0, 0, display);

                        g.Transform = matrix;
                    }
                    else
                    {
                        g.DrawText(stationFont, brush, margin.Left + posX.Center - (size.Width / 2), margin.Top - size.Height - verticalTrackOffset - TOP_GAP, display);
                    }

                    if (attrs.MultiTrack)
                    {
                        foreach (var track in posX.TrackOffsets)
                        {
                            var trackSize = g.MeasureString(stationFont, track.Key);
                            if (attrs.StationVertical)
                            {
                                var matrix = g.Transform.Clone();

                                g.TranslateTransform(margin.Left + track.Value + (trackSize.Height / 2), margin.Top - 8 - trackSize.Width);
                                g.RotateTransform(90);
                                g.DrawText(stationFont, brush, 0, 0, track.Key);

                                g.Transform = matrix;
                            }
                            else
                            {
                                g.DrawText(stationFont, brush, margin.Left + track.Value - (trackSize.Width / 2), margin.Top - trackSize.Height - TOP_GAP, track.Key);
                            }
                        }
                    }
                }
            }
            return(stationOffsets);
        }
        void Update(Document document, int caretOffset)
        {
            CancelUpdatePath();
            var cancellationToken = src.Token;

            Task.Run(async() => {
                var root = await document.GetSyntaxRootAsync(cancellationToken);
                if (root == null || cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                amb = new AstAmbience(IdeServices.TypeSystemService.Workspace.Options);

                SyntaxNode node;
                try {
                    if (root.FullSpan.Length <= caretOffset)
                    {
                        var prevPath = CurrentPath;
                        CurrentPath  = new PathEntry [] { new PathEntry(GettextCatalog.GetString("No selection"))
                                                          {
                                                              Tag = null
                                                          } };
                        isPathSet = false;
                        Runtime.RunInMainThread(delegate {
                            OnPathChanged(new DocumentPathChangedEventArgs(prevPath));
                        }).Ignore();
                        return;
                    }
                    node = root.FindNode(TextSpan.FromBounds(caretOffset, caretOffset));
                    if (node.SpanStart != caretOffset)
                    {
                        node = root.SyntaxTree.FindTokenOnLeftOfPosition(caretOffset, cancellationToken).Parent;
                    }
                } catch (Exception ex) {
                    LoggingService.LogError("Error updating C# breadcrumbs", ex);
                    return;
                }

                var curMember = node?.AncestorsAndSelf().FirstOrDefault(m => m is VariableDeclaratorSyntax && m.Parent != null && !(m.Parent.Parent is LocalDeclarationStatementSyntax) || (m is MemberDeclarationSyntax && !(m is NamespaceDeclarationSyntax)));
                var curType   = node != null ? node.AncestorsAndSelf().FirstOrDefault(IsType) : null;

                var curProject = ownerProjects != null && ownerProjects.Count > 1 ? ownerProjects [0] : null;
                if (curType == curMember || curType is DelegateDeclarationSyntax)
                {
                    curMember = null;
                }
                if (isPathSet && curType == lastType && curMember == lastMember && curProject == lastProject)
                {
                    return;
                }
                var curTypeMakeup   = GetEntityMarkup(curType);
                var curMemberMarkup = GetEntityMarkup(curMember);
                if (isPathSet && curType != null && lastType != null && curTypeMakeup == lastTypeMarkup &&
                    curMember != null && lastMember != null && curMemberMarkup == lastMemberMarkup && curProject == lastProject)
                {
                    return;
                }

                //			var regionEntry = await GetRegionEntry (DocumentContext.ParsedDocument, loc).ConfigureAwait (false);

                await joinableTaskContext.Factory.SwitchToMainThreadAsync();
                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }
                var result = new List <PathEntry> ();

                if (curProject != null)
                {
                    // Current project if there is more than one
                    result.Add(new PathEntry(ImageService.GetIcon(curProject.StockIcon, Gtk.IconSize.Menu), GLib.Markup.EscapeText(curProject.Name))
                    {
                        Tag = curProject
                    });
                }

                if (curType == null)
                {
                    var prevPath = CurrentPath;
                    result.Add(new PathEntry(GettextCatalog.GetString("No selection"))
                    {
                        Tag = root.SyntaxTree
                    });
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }

                    CurrentPath    = result.ToArray();
                    lastType       = curType;
                    lastTypeMarkup = curTypeMakeup;

                    lastMember       = curMember;
                    lastMemberMarkup = curMemberMarkup;

                    lastProject = curProject;
                    OnPathChanged(new DocumentPathChangedEventArgs(prevPath));
                    return;
                }

                if (curType != null)
                {
                    var type = curType;
                    var pos  = result.Count;
                    while (type != null)
                    {
                        if (!(type is BaseTypeDeclarationSyntax))
                        {
                            break;
                        }
                        var tag = (object)type.Ancestors().FirstOrDefault(IsType) ?? root.SyntaxTree;
                        result.Insert(pos, new PathEntry(ImageService.GetIcon(type.GetStockIcon(), Gtk.IconSize.Menu), GetEntityMarkup(type))
                        {
                            Tag = tag
                        });
                        type = type.Parent;
                    }
                }
                if (curMember != null)
                {
                    result.Add(new PathEntry(ImageService.GetIcon(curMember.GetStockIcon(), Gtk.IconSize.Menu), curMemberMarkup)
                    {
                        Tag = curMember
                    });
                    if (curMember.Kind() == SyntaxKind.GetAccessorDeclaration ||
                        curMember.Kind() == SyntaxKind.SetAccessorDeclaration ||
                        curMember.Kind() == SyntaxKind.AddAccessorDeclaration ||
                        curMember.Kind() == SyntaxKind.RemoveAccessorDeclaration)
                    {
                        var parent = curMember.Parent;
                        if (parent != null)
                        {
                            result.Insert(result.Count - 1, new PathEntry(ImageService.GetIcon(parent.GetStockIcon(), Gtk.IconSize.Menu), GetEntityMarkup(parent))
                            {
                                Tag = parent
                            });
                        }
                    }
                }

                //				if (regionEntry != null)
                //					result.Add(regionEntry);

                PathEntry noSelection = null;
                if (curType == null)
                {
                    noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                    {
                        Tag = root.SyntaxTree
                    };
                }
                else if (curMember == null && !(curType is DelegateDeclarationSyntax))
                {
                    noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                    {
                        Tag = curType
                    };
                }

                if (noSelection != null)
                {
                    result.Add(noSelection);
                }
                var prev = CurrentPath;
                if (prev != null && prev.Length == result.Count)
                {
                    bool equals = true;
                    for (int i = 0; i < prev.Length; i++)
                    {
                        if (prev [i].Markup != result [i].Markup)
                        {
                            equals = false;
                            break;
                        }
                    }
                    if (equals)
                    {
                        return;
                    }
                }
                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }
                CurrentPath    = result.ToArray();
                lastType       = curType;
                lastTypeMarkup = curTypeMakeup;

                lastMember       = curMember;
                lastMemberMarkup = curMemberMarkup;

                lastProject = curProject;

                OnPathChanged(new DocumentPathChangedEventArgs(prev));
            }, cancellationToken).Ignore();
        }
예제 #11
0
 private string StationDisplay(PathEntry sta) => sta.Station.ToString(attrs.DisplayKilometre, sta.RouteIndex) +
 (!string.IsNullOrWhiteSpace(sta.Station.StationCode) ? $" ({sta.Station.StationCode})" : "");
예제 #12
0
        public ProgramWnd(ProgramID id)
        {
            InitializeComponent();

            this.Title = Translate.fmt("wnd_program");

            this.grpProgram.Header  = Translate.fmt("lbl_program");
            this.radProgram.Content = Translate.fmt("lbl_exe");
            this.radService.Content = Translate.fmt("lbl_svc");
            this.radApp.Content     = Translate.fmt("lbl_app");

            this.btnOK.Content     = Translate.fmt("lbl_ok");
            this.btnCancel.Content = Translate.fmt("lbl_cancel");

            ID = id;

            SuspendChange++;

            Paths = new ObservableCollection <PathEntry>();

            ListCollectionView lcv = new ListCollectionView(Paths);

            lcv.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
            cmbPath.ItemsSource = lcv;

            Paths.Add(new PathEntry()
            {
                Content = Translate.fmt("pro_browse"), Tag = "*", Group = Translate.fmt("lbl_selec")
            });
            PathEntry itemAll = new PathEntry()
            {
                Content = Translate.fmt("pro_all"), Tag = null, Group = Translate.fmt("lbl_selec")
            };

            Paths.Add(itemAll);

            if (ID != null && ID.Path.Length > 0)
            {
                PathEntry itemPath;
                if (ID.Path.Equals("system"))
                {
                    itemPath = new PathEntry()
                    {
                        Content = Translate.fmt("pro_sys"), Tag = ID.Path, Group = Translate.fmt("lbl_selec")
                    }
                }
                ;
                else
                {
                    itemPath = new PathEntry()
                    {
                        Content = ID.Path, Tag = ID.Path, Group = Translate.fmt("lbl_known")
                    }
                };
                Paths.Add(itemPath);
                cmbPath.SelectedItem = itemPath;
            }
            else
            {
                cmbPath.SelectedItem = itemAll;
            }

            //if (ID != null &&  ((ID.Path.Length == 0 && ID.Name.Length == 0) || ID.Path.Equals("system")))
            if (ID != null)
            {
                radProgram.IsEnabled = false;
                radService.IsEnabled = false;
                radApp.IsEnabled     = false;

                cmbPath.IsEnabled    = false;
                cmbService.IsEnabled = false;
                cmbApp.IsEnabled     = false;
            }

            cmbService.ItemsSource = ServiceModel.GetInstance().GetServices();
            cmbApp.ItemsSource     = AppModel.GetInstance().GetApps();

            if (ID == null)
            {
                radProgram.IsChecked = true;
                ID = ProgramID.NewID(ProgramID.Types.Program);
            }
            else
            {
                switch (ID.Type)
                {
                case ProgramID.Types.Program:
                    radProgram.IsChecked = true;
                    break;

                case ProgramID.Types.Service:
                    radService.IsChecked = true;
                    foreach (ServiceModel.Service service in cmbService.Items)
                    {
                        if (MiscFunc.StrCmp(service.Value, ID.GetServiceId()))
                        {
                            cmbService.SelectedItem = service;
                            break;
                        }
                    }
                    if (cmbService.SelectedItem == null)
                    {
                        cmbService.Text = ID.GetServiceId();
                    }
                    break;

                case ProgramID.Types.App:
                    radApp.IsChecked = true;
                    foreach (AppModel.AppPkg app in cmbApp.Items)
                    {
                        if (MiscFunc.StrCmp(app.Value, ID.GetPackageSID()))
                        {
                            cmbService.SelectedItem = app;
                            break;
                        }
                    }
                    if (cmbApp.SelectedItem == null)
                    {
                        cmbApp.Text = ID.GetPackageName();
                    }
                    break;
                }
            }

            if (UwpFunc.IsWindows7OrLower)
            {
                radApp.IsEnabled = false;
                cmbApp.IsEnabled = false;
            }

            SuspendChange--;
        }
예제 #13
0
        public static bool LoadState_NET(StashKey sk, bool ReloadRom = true)
        {
            if (sk == null)
            {
                return(false);
            }

            StashKey.setCore(sk);
            string GameSystem     = sk.SystemName;
            string GameName       = sk.GameName;
            string Key            = sk.ParentKey;
            bool   GameHasChanged = false;
            string TheoricalSaveStateFilename;

            RTC_Core.StopSound();

            if (ReloadRom)
            {
                string ss = null;
                RTC_Core.LoadRom_NET(sk.RomFilename);

                //If the syncsettings are different, update them and load it again. Otheriwse, leave as is
                if (sk.SyncSettings != (ss = StashKey.getSyncSettings_NET(ss)))
                {
                    StashKey.putSyncSettings_NET(sk);
                    RTC_Core.LoadRom_NET(sk.RomFilename);
                }
                GameHasChanged = true;
            }



            RTC_Core.StartSound();


            PathEntry pathEntry = Global.Config.PathEntries[Global.Game.System, "Savestates"] ??
                                  Global.Config.PathEntries[Global.Game.System, "Base"];

            if (!GameHasChanged)
            {
                TheoricalSaveStateFilename = RTC_Core.bizhawkDir + "\\" + GameSystem + "\\State\\" + GameName + "." + Key + ".timejump.State";
            }
            else
            {
                TheoricalSaveStateFilename = RTC_Core.bizhawkDir + "\\" + RTC_Core.EmuFolderCheck(pathEntry.SystemDisplayName) + "\\State\\" + PathManager.FilesystemSafeName(Global.Game) + "." + Key + ".timejump.State";
            }


            if (File.Exists(TheoricalSaveStateFilename))
            {
                RTC_Core.LoadSavestate_NET(Key);
            }
            else
            {
                RTC_Core.StopSound();
                MessageBox.Show($"Error loading savestate : (File {Key + ".timejump"} not found)");
                RTC_Core.StartSound();
                return(false);
            }

            return(true);
        }
        /// <inheritdoc />
        public bool MoveNext()
        {
            if (pathDepth == 0)
            {
                return(false);
            }

            var c  = path[pathDepth - 1];
            var ci = c.Index;
            var cc = c.Cell;
            var cf = c.FullyInside;

            while (true)
            {
                ci++;

                if (cc.Children == null)
                {
                    if (cc.Items.Count > ci)
                    {
                        if (cf || IsPointInside(cc.Items[ci].Position))
                        {
                            Current             = cc.Items[ci].Item;
                            path[pathDepth - 1] = new PathEntry(cc, ci, cf);
                            return(true);
                        }

                        continue;
                    }
                }
                else
                {
                    if (cc.Children.Length > ci)
                    {
                        var child = cc.Children[ci];
                        if (child != null && (cf || IsBoundsIntersecting(child.Start, child.End)))
                        {
                            var childCf = cf;
                            if (!childCf)
                            {
                                childCf = IsBoundsFullyInside(child.Start, child.End);
                            }

                            path[pathDepth - 1] = new PathEntry(cc, ci, cf);
                            path[pathDepth]     = new PathEntry(child, -1, childCf);
                            pathDepth++;
                            ci = -1;
                            cc = child;
                            cf = childCf;
                        }

                        continue;
                    }
                }

                // Go one layer up
                pathDepth--;
                if (pathDepth == 0)
                {
                    return(false);
                }

                c  = path[pathDepth - 1];
                ci = c.Index;
                cc = c.Cell;
                cf = c.FullyInside;
            }
        }
 /// <inheritdoc />
 public void Reset()
 {
     path[0]   = new PathEntry(tree.Root, -1, IsBoundsFullyInside(tree.Root.Start, tree.Root.End));
     pathDepth = 1;
 }