コード例 #1
0
        internal static void CacheDisplayStringForThemeSwitch(object osObject)
        {
            var os = (OS)osObject;

            if (os.displayCache == null || lastFileData == null || (os.display.command != "cat" && os.display.command != "less"))
            {
                return;
            }

            if (isFlickering)
            {
                if (displayCache2 == null)
                {
                    displayCache2 = os.displayCache;

                    os.displayCache = Utils.SuperSmartTwimForWidth(LocalizedFileLoader.SafeFilterString(lastFileData), os.display.bounds.Width - 40, GuiData.tinyfont);
                }
                else
                {
                    var temp = displayCache2;
                    displayCache2   = os.displayCache;
                    os.displayCache = temp;
                }
            }
            else
            {
                os.displayCache = Utils.SuperSmartTwimForWidth(LocalizedFileLoader.SafeFilterString(lastFileData), os.display.bounds.Width - 40, GuiData.tinyfont);
            }

            isFlickering = false;
        }
コード例 #2
0
        internal static void WrapOnceInCommandIL(ILContext il)
        {
            ILCursor c = new ILCursor(il);

            c.GotoNext(MoveType.Before,
                       x => x.MatchLdfld(AccessTools.Field(typeof(FileEntry), nameof(FileEntry.data))),
                       x => x.MatchStfld(AccessTools.Field(typeof(OS), nameof(OS.displayCache)))
                       );

            c.Index += 1;

            c.EmitDelegate <Func <string, string> >(fileData =>
            {
                lastFileData = fileData;
                return(Utils.SuperSmartTwimForWidth(LocalizedFileLoader.SafeFilterString(fileData), OS.currentInstance.display.bounds.Width - 40, GuiData.tinyfont));
            });
        }
コード例 #3
0
        public static bool RenderAttachment(string data, object osObj, Vector2 dpos, int startingButtonIndex, SoundEffect buttonSound)
        {
            OS os = (OS)osObj;

            string[] strArray = data.Split(AttachmentRenderer.spaceDelim, StringSplitOptions.RemoveEmptyEntries);
            if (strArray.Length < 1)
            {
                return(false);
            }
            if (strArray[0].Equals("link"))
            {
                Vector2  labelSize = TextItem.doMeasuredTinyLabel(dpos, LocaleTerms.Loc("LINK") + " : " + strArray[1] + "@" + strArray[2], new Color?());
                Computer computer  = Programs.getComputer(os, strArray[2]);
                if (!os.netMap.visibleNodes.Contains(os.netMap.nodes.IndexOf(computer)))
                {
                    AttachmentRenderer.DrawButtonGlow(dpos, labelSize, os);
                }
                if (Button.doButton(800009 + startingButtonIndex, (int)((double)dpos.X + (double)labelSize.X + 5.0), (int)dpos.Y, 20, 17, "+", new Color?()))
                {
                    if (computer == null)
                    {
                        os.write("ERROR: Linked target not found");
                    }
                    else
                    {
                        computer.highlightFlashTime = 1f;
                        os.netMap.discoverNode(computer);
                        SFX.addCircle(Programs.getComputer(os, strArray[2]).getScreenSpacePosition(), Color.White, 32f);
                        if (buttonSound != null && !Settings.soundDisabled)
                        {
                            buttonSound.Play();
                        }
                    }
                }
            }
            else if (strArray[0].Equals("account"))
            {
                Vector2 labelSize = TextItem.doMeasuredTinyLabel(dpos, LocaleTerms.Loc("ACCOUNT") + " : " + strArray[1] + " : User="******" Pass="******"+", new Color?()))
                {
                    Computer computer = Programs.getComputer(os, strArray[2]);
                    computer.highlightFlashTime = 1f;
                    os.netMap.discoverNode(computer);
                    computer.highlightFlashTime = 1f;
                    SFX.addCircle(computer.getScreenSpacePosition(), Color.White, 32f);
                    for (int index = 0; index < computer.users.Count; ++index)
                    {
                        UserDetail user = computer.users[index];
                        if (user.name.Equals(strArray[3]))
                        {
                            user.known            = true;
                            computer.users[index] = user;
                            break;
                        }
                    }
                    if (buttonSound != null && !Settings.soundDisabled)
                    {
                        buttonSound.Play();
                    }
                }
            }
            else
            {
                if (!strArray[0].Equals("note"))
                {
                    return(false);
                }
                Vector2 labelSize = TextItem.doMeasuredTinyLabel(dpos, LocaleTerms.Loc("NOTE") + " : " + strArray[1], new Color?());
                string  note      = LocalizedFileLoader.SafeFilterString(strArray[2]);
                if (!NotesExe.NoteExists(note, os))
                {
                    AttachmentRenderer.DrawButtonGlow(dpos, labelSize, os);
                }
                if (Button.doButton(800009 + startingButtonIndex, (int)((double)dpos.X + (double)labelSize.X + 5.0), (int)dpos.Y, 20, 17, "+", new Color?()))
                {
                    NotesExe.AddNoteToOS(note, os, false);
                }
            }
            return(true);
        }