예제 #1
0
        internal string GetNewTitle(Solution solution, string pattern, Settings cfg)
        {
            var info = AvailableInfo.GetCurrent(ideName: this.IDEName, solution: solution, cfg: cfg, globalSettings: this.UISettings);

            if (info == null)
            {
                return(this.IDEName);
            }

#if false
            pattern = this.TagRegex.Replace(pattern, match =>
            {
                try
                {
                    var tag = match.Groups[1].Value;
                    try
                    {
                        if (SimpleTagResolvers.TryGetValue(tag, out ISimpleTagResolver resolver))
                        {
                            return(resolver.Resolve(info: info));
                        }
                        foreach (var tagResolver in this.TagResolvers)
                        {
                            if (tagResolver.TryResolve(tag: tag, info: info, s: out string value))
                            {
                                return(value);
                            }
                        }
예제 #2
0
 public bool TryResolve(string tag, AvailableInfo info, out string s)
 {
     s = null;
     if (tag != this.TagName)
     {
         return(false);
     }
     s = this.Resolve(info: info);
     return(true);
 }
        public override bool TryResolve(string tag, AvailableInfo info, out string s)
        {
            s = null;
            if (!tag.StartsWith(tagName, StringComparison.InvariantCulture))
            {
                return(false);
            }
            var svnPath = this.Resolve(info);

            if (string.IsNullOrWhiteSpace(svnPath))
            {
                return(false);
            }
            var directorySeparator = info.GlobalSettings.SvnDirectorySeparator;
            var svnPathParts       = new List <string>();

            if (Path.IsPathRooted(svnPath))
            {
                svnPathParts.Add(directorySeparator);
            }
            svnPathParts.AddRange(svnPath.Split(new[] { directorySeparator }, StringSplitOptions.RemoveEmptyEntries));
            var m = Globals.RangeRegex.Match(tag.Substring(tagName.Length));

            if (m.Success)
            {
                if (!svnPathParts.Any())
                {
                    s = string.Empty;
                }
                else
                {
                    var x         = int.Parse(m.Groups["startIndex"].Value, CultureInfo.InvariantCulture);
                    var y         = int.Parse(m.Groups["endIndex"].Value, CultureInfo.InvariantCulture);
                    var pathRange = Globals.GetPathRange(svnPathParts, x, y);
                    s = string.Join(directorySeparator, pathRange);
                }
                return(true);
            }
            m = Globals.IndexRegex.Match(tag.Substring(tagName.Length));
            if (m.Success)
            {
                if (!svnPathParts.Any())
                {
                    s = string.Empty;
                }
                else
                {
                    var index = int.Parse(m.Groups["index"].Value, CultureInfo.InvariantCulture);
                    s = Globals.GetPathPart(svnPathParts, index);
                }
                return(true);
            }
            return(false);
        }
        public override bool TryResolve(string tag, AvailableInfo info, out string s)
        {
            s = null;
            var m = EnvRegex.Match(tag);

            if (m.Success)
            {
                s = Environment.GetEnvironmentVariable(m.Groups[1].Value);
                return(true);
            }
            return(false);
        }
예제 #5
0
 public bool RewriteTag(out string result, AvailableInfo info, string tag)
 {
     if (m_TagsToFunctions.TryGetValue(tag, out var f))
     {
         result = f.Invoke(info);
         return(true);
     }
     else
     {
         result = null;
         return(false);
     }
 }
        private bool IsDirty(AvailableInfo info)
        {
            if (info.Solution != null && info.Solution.IsOpen && !info.Solution.Saved)
            {
                return(true);
            }
            var hasUnsavedDocument = info.ActiveDocument?.Collection
                                     .OfType <Document>()
                                     .Any(document => !document.Saved)
                                     ?? false;

            return(hasUnsavedDocument);
        }
예제 #7
0
        public override bool TryResolve(string tag, AvailableInfo availableInfo, out string s)
        {
            var m = StartupProjectsXRegex.Match(tag);

            if (!m.Success)
            {
                s = null;
                return(false);
            }

            s = string.Join(m.Groups[1].Value, GetStartupProjectNames());
            return(true);
        }
예제 #8
0
        public override bool TryResolve(string tag, AvailableInfo info, out string s)
        {
            s = null;
            if (!tag.StartsWith("documentPath", StringComparison.InvariantCulture))
            {
                return(false);
            }

            var m = Globals.RangeRegex.Match(tag.Substring("documentPath".Length));

            if (m.Success)
            {
                if (!info.DocumentPathParts.Any())
                {
                    s = string.Empty;
                }
                else
                {
                    var x         = int.Parse(m.Groups["startIndex"].Value, CultureInfo.InvariantCulture);
                    var y         = int.Parse(m.Groups["endIndex"].Value, CultureInfo.InvariantCulture);
                    var pathRange = Globals.GetPathRange(info.DocumentPathParts, x, y);
                    s = Globals.GetPathForTitle(pathRange);
                }
                return(true);
            }
            m = Globals.IndexRegex.Match(tag.Substring("documentPath".Length));
            if (m.Success)
            {
                if (!info.DocumentPathParts.Any())
                {
                    s = string.Empty;
                }
                else
                {
                    var x = int.Parse(m.Groups["index"].Value, CultureInfo.InvariantCulture);
                    s = Globals.GetPathPart(info.DocumentPathParts, x);
                }
                return(true);
            }
            return(false);
        }
        public override bool TryResolve(string tag, AvailableInfo info, out string s)
        {
            s = null;
            if (!tag.StartsWith(tagName, StringComparison.InvariantCulture))
            {
                return(false);
            }

            var m = Globals.RangeRegex.Match(tag.Substring(tagName.Length));

            if (m.Success)
            {
                if (!info.PathParts.Any())
                {
                    s = string.Empty;
                }
                else
                {
                    var startIndex = Math.Min(info.PathParts.Length - 1, Math.Max(0, int.Parse(m.Groups["startIndex"].Value, CultureInfo.InvariantCulture)));
                    var endIndex   = Math.Min(info.PathParts.Length - 1, Math.Max(0, int.Parse(m.Groups["endIndex"].Value, CultureInfo.InvariantCulture)));
                    var pathRange  = info.PathParts.GetRange(startIndex: info.PathParts.Length - 1 - startIndex, endIndex: info.PathParts.Length - 1 - endIndex).ToArray();
                    s = Globals.GetPathForTitle(pathRange);
                }
                return(true);
            }
            m = Globals.IndexRegex.Match(tag.Substring(tagName.Length));
            if (m.Success)
            {
                if (!info.PathParts.Any())
                {
                    s = string.Empty;
                }
                else
                {
                    var index = Math.Min(info.PathParts.Length - 1, Math.Max(0, int.Parse(m.Groups["index"].Value, CultureInfo.InvariantCulture)));
                    s = info.PathParts[info.PathParts.Length - 1 - index];
                }
                return(true);
            }
            return(false);
        }
        public override string Resolve(AvailableInfo info)
        {
            var list = new List <Tuple <string, string> >();

            // var process = Globals.DTE.Debugger.CurrentProcess; returns null for some reason.
            foreach (Process2 process in Globals.DTE.Debugger.DebuggedProcesses)
            {
                if (GetCommandLine(process, out var executablePath, out var args) && !string.IsNullOrWhiteSpace(args))
                {
                    list.Add(Tuple.Create(executablePath, args));
                }
            }
            if (!list.Any())
            {
                return("");
            }
            if (list.Count == 1)
            {
                return(list.Single().Item2);
            }
            return(string.Join(" & ", list.Select(e => Path.GetFileName(e.Item1) + " " + e.Item2)));
        }
예제 #11
0
 public override string Resolve(AvailableInfo info)
 {
     return(string.Join(" & ", GetStartupProjectNamesNonRelative()));
 }
 public override string Resolve(AvailableInfo info)
 {
     return(IsDirty(info) ? "*" : string.Empty);
 }
예제 #13
0
        public static bool ResearchNode_Draw_Prefix(object __instance, Rect visibleRect, bool forceDetailedMode = false)
        {
            //Reflected objects
            Rect rect = (Rect)RectInfo.GetValue(__instance);
            ResearchProjectDef Research = (ResearchProjectDef)ResearchInfo.GetValue(__instance);
            bool available = (bool)AvailableInfo.GetValue(__instance);
            bool completed = Research.IsFinished; //simplified

            //

            if (!(bool)IsVisibleInfo.Invoke(__instance, new object[] { visibleRect }))
            {
                HighlightedProxy(__instance, false);
                return(false);
            }
            bool detailedMode = forceDetailedMode || (float)ZoomLevelInfo.GetValue(InstanceInfo.GetValue(__instance)) < DetailedModeZoomLevelCutoff;
            bool mouseOver    = Mouse.IsOver(rect);
            bool highlighted  = HighlightedProxy(__instance);

            if (Event.current.type == EventType.Repaint)
            {
                //researches that are completed or could be started immediately, and that have the required building(s) available
                GUI.color = mouseOver ? BrightColor : (Color)ColorInfo.GetValue(__instance);
                if (mouseOver || highlighted)
                {
                    GUI.DrawTexture(rect, ResearchTree_Assets.ButtonActive);
                }
                else
                {
                    GUI.DrawTexture(rect, ResearchTree_Assets.Button);
                }

                //grey out center to create a progress bar effect, completely greying out research not started.
                if (available)
                {
                    var progressBarRect = rect.ContractedBy(3f);
                    GUI.color             = ResearchTree_Assets.ColorAvailable[Research.techLevel];
                    progressBarRect.xMin += Research.ProgressPercent * progressBarRect.width;
                    GUI.DrawTexture(progressBarRect, BaseContent.WhiteTex);
                }
                HighlightedProxy(__instance, interest == Research);

                //draw the research label
                if (!completed && !available)
                {
                    GUI.color = Color.grey;
                }
                else
                {
                    GUI.color = Color.white;
                }

                if (detailedMode)
                {
                    Text.Anchor   = TextAnchor.UpperLeft;
                    Text.WordWrap = false;
                    Text.Font     = (bool)largeLabelInfo.GetValue(__instance) ? GameFont.Tiny : GameFont.Small;
                    Widgets.Label((Rect)LabelRectInfo.GetValue(__instance), Research.LabelCap);
                }
                else
                {
                    Text.Anchor   = TextAnchor.MiddleCenter;
                    Text.WordWrap = false;
                    Text.Font     = GameFont.Medium;
                    Widgets.Label(rect, Research.LabelCap);
                }

                //draw research cost and icon
                if (detailedMode)
                {
                    Text.Anchor = TextAnchor.UpperRight;
                    Text.Font   = Research.CostApparent > 1000000 ? GameFont.Tiny : GameFont.Small;
                    Widgets.Label((Rect)CostLabelRectInfo.GetValue(__instance), Research.CostApparent.ToStringByStyle(ToStringStyle.Integer));
                    GUI.DrawTexture((Rect)CostIconRectInfo.GetValue(__instance), !completed && !available ? ResearchTree_Assets.Lock : ResearchTree_Assets.ResearchIcon,
                                    ScaleMode.ScaleToFit);
                }

                Text.WordWrap = true;

                //attach description and further info to a tooltip
                string root = HarmonyPatches.ResearchPal ? "ResearchPal" : "Fluffy.ResearchTree";
                TooltipHandler.TipRegion(rect, new Func <string>(() => (string)GetResearchTooltipStringInfo.Invoke(__instance, new object[] { })), Research.GetHashCode());
                if (!BuildingPresentProxy(Research))
                {
                    string languageKey = root + ".MissingFacilities";
                    TooltipHandler.TipRegion(rect, languageKey.Translate(string.Join(", ", MissingFacilities(Research).Select(td => td.LabelCap).ToArray())));
                }
                else if (!TechprintAvailable(Research))
                {
                    string languageKey = root + ".MissingTechprints";
                    TooltipHandler.TipRegion(rect, languageKey.Translate(Research.TechprintsApplied, Research.techprintCount));
                }

                //draw unlock icons
                if (detailedMode)
                {
                    Rect IconsRect = (Rect)IconsRectInfo.GetValue(__instance);
                    var  unlocks   = GetUnlockDefsAndDescs(Research);
                    for (var i = 0; i < unlocks.Count; i++)
                    {
                        var iconRect = new Rect(
                            IconsRect.xMax - (i + 1) * (IconSize.x + 4f),
                            IconsRect.yMin + (IconsRect.height - IconSize.y) / 2f,
                            IconSize.x,
                            IconSize.y);

                        if (iconRect.xMin - IconSize.x < IconsRect.xMin &&
                            i + 1 < unlocks.Count)
                        {
                            //stop the loop if we're about to overflow and have 2 or more unlocks yet to print.
                            iconRect.x = IconsRect.x + 4f;
                            GUI.DrawTexture(iconRect, ResearchTree_Assets.MoreIcon, ScaleMode.ScaleToFit);
                            var tip = string.Join("\n", unlocks.GetRange(i, unlocks.Count - i).Select(p => p.Second).ToArray());
                            TooltipHandler.TipRegion(iconRect, tip);
                            //new TipSignal(tip, Settings.TipID, TooltipPriority.Pawn) );
                            break;
                        }

                        //draw icon
                        unlocks[i].First.DrawColouredIcon(iconRect);

                        //tooltip
                        TooltipHandler.TipRegion(iconRect, unlocks[i].Second);
                    }
                }

                if (mouseOver)
                {
                    if (interest != null && interest != Research)
                    {
                        DeInterest();
                    }

                    //highlight prerequisites if research available
                    if (available)
                    {
                        HighlightedProxy(__instance, true);
                        foreach (var prerequisite in (IEnumerable <object>)GetMissingRequiredRecursiveInfo.Invoke(__instance, new object[] { }))
                        {
                            HighlightedProxy(Convert.ChangeType(prerequisite, ResearchNodeType()), true);
                        }
                    }
                    //highlight children if completed
                    else if (completed)
                    {
                        foreach (var child in (IEnumerable <object>)ChildrenInfo.GetValue(__instance))
                        {
                            HighlightedProxy(Convert.ChangeType(child, ResearchNodeType()), true);
                        }
                    }
                }
            }

            //CUSTOM: a bunch of things on top
            Research.DrawExtras(rect, mouseOver || highlighted);

            if (Widgets.ButtonInvisible(rect))
            {
                //CUSTOM: replaced queue operations for assignment menu
                if (Event.current.button == 0)
                {
                    Research.SelectMenu(completed);
                }
                if (DebugSettings.godMode && Prefs.DevMode && Event.current.button == 1 && !Research.IsFinished)
                {
                    Find.ResearchManager.FinishProject(Research);
                    Research.WipeAssignments();
                }
            }

            return(false);
        }
 public override string Resolve(AvailableInfo info)
 {
     return(info.ElevationSuffix ?? string.Empty);
 }
예제 #15
0
 public override string Resolve(AvailableInfo info)
 {
     return(IdeHelper.VsMajorVersionYear.ToString(CultureInfo.InvariantCulture));
 }
예제 #16
0
 public string Resolve(AvailableInfo info)
 {
     return(string.IsNullOrEmpty(info.DocumentName) ? info.WindowName : info.DocumentPath);
 }
예제 #17
0
 public override string Resolve(AvailableInfo info)
 {
     GitInfo.UpdateGitExecFp(info.GlobalSettings.GitDirectory); // there is likely a better way to adjust the git path
     return(GetGitRepoNameOrEmpty(info.Solution));
 }
예제 #18
0
 public string ResolveBranch(AvailableInfo info)
 {
     //UpdateGitExecFp(info.GlobalSettings.GitDirectory); // there is likely a better way to adjust the git path
     //return GetGitBranchNameOrEmpty(info.Solution);
     return("lulz");
 }
예제 #19
0
 public override string Resolve(AvailableInfo info)
 {
     UpdateHgExecFp(info.GlobalSettings.HgDirectory);
     return(GetHgBranchNameOrEmpty(info.Solution));
 }
 public override string Resolve(AvailableInfo info)
 {
     return(GetActiveConfigurationNameOrEmpty(info.Solution));
 }
예제 #21
0
 public override string Resolve(AvailableInfo info)
 {
     return(info.IdeName ?? string.Empty);
 }
예제 #22
0
 public string Resolve(AvailableInfo info)
 {
     return(string.Join(" & ", GetStartupProjectNames()));
 }
예제 #23
0
 public override string Resolve(AvailableInfo info)
 {
     return(info.Cfg.SolutionName ?? string.Empty);
 }
 public override string Resolve(AvailableInfo info)
 {
     return(AvailableInfo.GetParentPath(info.PathParts, info.Cfg?.ClosestParentDepth ?? info.GlobalSettings.ClosestParentDepth, info.Cfg?.FarthestParentDepth ?? info.GlobalSettings.FarthestParentDepth) ?? string.Empty);
 }
 public override string Resolve(AvailableInfo info)
 {
     return(GetWorkspaceNameOrEmpty(info.Solution));
 }
 public string Resolve(AvailableInfo info)
 {
     UpdateSvnExecFp(info.GlobalSettings.SvnDirectory);
     return(GetSvnDirectoryOrEmpty(info.Solution));
 }
예제 #27
0
 public override string Resolve(AvailableInfo info)
 {
     return(DocumentHelper.GetActiveDocumentProjectNameOrEmpty(activeDocument: info.ActiveDocument));
 }
 public override string Resolve(AvailableInfo info)
 {
     return(info.WindowName);
 }
 public override string Resolve(AvailableInfo info)
 {
     return(GetPlatformNameOrEmpty(info.Solution));
 }
예제 #30
0
 public override string Resolve(AvailableInfo info)
 {
     return(VsProcessId.Value.ToString(CultureInfo.InvariantCulture));
 }