public void DrawTextSkipSpaces(string text, int x, int y, char col, float fade = 1, char backColor = ' ') { int xoff = x; int yoff = 0; text = StringScrambler.GetScrambledString(text, 1 - fade); for (int i = 0; i < text.Length; ++i) { if (text[i] == '\n' || (int)text[i] == 10) { xoff = x; yoff++; } else { if (Random.value < fade) { if (text[i] != ' ') { SetPixelFront(text[i], xoff, y + yoff, col); if (backColor != ' ') { SetPixelBack('█', xoff, y + yoff, backColor); } } } xoff++; } } //DrawRectBack (x, y, x + text.Length, y + 1, 'g'); }
public void DrawBlack(string text, int x, int y) { int xoff = x; int yoff = 0; text = StringScrambler.GetScrambledString(text, 1 - 1); for (int i = 0; i < text.Length; ++i) { if (text[i] == '\n' || (int)text[i] == 10) { xoff = x; yoff++; } else { if (Random.value < 1) { if (text[i] != ' ') { SetPixelFront(' ', xoff, y + yoff, 'x'); } } xoff++; } } //DrawRectBack (x, y, x + text.Length, y + 1, 'g'); }
public void ExecuteMetricsStringScramblerTest() { IScrambler <string> scrambler = new StringScrambler(); ScramblerClient <string> client = new ScramblerClient <string>(scrambler); List <string> inputStrings = new List <string>(); for (var i = 0; i <= 100000; i++) { inputStrings.Add($"Hello World {i}"); } var watch = System.Diagnostics.Stopwatch.StartNew(); foreach (string str in inputStrings) { FluentActions.Invoking(() => client.ExecuteScramble(str)) .Should() .NotThrow(); } watch.Stop(); var elapsedSeconds = watch.ElapsedMilliseconds / 1000; Console.WriteLine($"Time taken: {elapsedSeconds}"); }
static void Main(string[] args) { Console.WriteLine("Starting text scrambling test"); var scrambler = new StringScrambler(); var seedText = "This is a seed"; var seedInt = 3433; var textList = new string[] { "test", "sample", "test sample", "sample test", "asdf sample test 323423 @#$#@dfsd df", "teetw sdfds.dsf sfdfsdf #@#$32 sdfsf fdsfs" }; var skipChars = new List <char> { ' ', '$' }; var outputChars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray().ToList(); WriteDataTableHeader("Text", "Scrambled Text"); foreach (var text in textList) { var scrambledText = scrambler.Scramble(seedText, seedInt, text, skipChars, outputChars); WriteDataTableRow(text, scrambledText); } Console.WriteLine("Completed text scrambling test"); Console.ReadLine(); }
public void ExecuteStringScramblerTest() { IScrambler <string> scrambler = new StringScrambler(); ScramblerClient <string> client = new ScramblerClient <string>(scrambler); string input = "Hello World"; string output = client.ExecuteScramble(input); Assert.AreNotEqual(input, output); Assert.AreEqual(input.Length, output.Length); }
public override void Update() { base.Update(); if (constantScramble) { if (orgPrefix == null) { orgPrefix = prefix; } if (orgSuffix == null) { orgSuffix = suffix; } constantScrambleTimer -= Time.unscaledDeltaTime; if (constantScrambleTimer < 0) { constantScrambleTimer = constantScrambleSpeed; prefix = StringScrambler.GetScrambledString(orgPrefix, .9f, "▀ ▄ █ ▌ ▐░ ▒ ▓ ■▪ "); suffixView.text = StringScrambler.GetScrambledString(orgSuffix, .9f, "▀ ▄ █ ▌ ▐░ ▒ ▓ ■▪ "); } } highlightedLastFrame = highlighted; if (highlighted && fadingIn) { //fade += 1.5f * Time.deltaTime * 30; //SpeedUpFadeIn(); } if (highlighted) { if (listLink != null && listLink.currentPanelContentId != this.id) { listLink.currentPanelContentId = this.id; listLink.rightPanel.text = data; listLink.rightPanel.BreakTextForLineLength(listLink.rightPanelContentWidth).CutTextForMaxLines(19); if (ContentAlign == SHAlign.Center) { listLink.rightPanel.CenterTextForLineLength(listLink.rightPanelContentWidth); } listLink.rightPanel.ForcedSoftFadeIn(); } } if (OnUpdate != null) { OnUpdate.Invoke(); } }
string PrepareLevelDescription(string keywords) { string desc = StringScrambler.GetGlitchString(288 * 2); //32 columns x 9 rows var dictionary = keywords.Split(',').ToList(); int iterations = 25; for (int i = 0; i < iterations; i++) { desc = desc.Insert(Random.Range(0, desc.Length - 1), dictionary[Random.Range(0, dictionary.Count)]); } return(desc); }
void ClearRect(int startx, int starty, int endx, int endy, float fade = 1) { for (int x = (int)(startx * fade); x < (int)(endx * fade); ++x) { for (int y = (int)(starty * fade); y < (int)(endy * fade); ++y) { if (UnityEngine.Random.value < fade) { SetPixelFront(' ', x, y, ' '); } else { SetPixelFront(StringScrambler.GetGlitchChar(), x, y, ' '); } } } }
void DrawTextProgress(string content, int X, int Y, char color, float progress, int progressEdgeLength = 6) { int intProgress = (int)(Mathf.Clamp01(progress) * content.Length); bool drawEdge = true; if (progress > 1) { drawEdge = false; } int X1 = 0; int Y1 = 0; for (int i = 0; i < intProgress; ++i) { if (content[i] == '\n') { X1 = 0; Y1++; } else { char zzz = content[i]; char ccc = color; if (Mathf.Abs(i - intProgress) < progressEdgeLength) { if (drawEdge && zzz != ' ' && Random.value < .5f) { zzz = StringScrambler.GetGlitchChar(); ccc = 'w'; } } if (zzz != ' ') { SHGUI.current.SetPixelFront(zzz, X + X1, Y + Y1, ccc); } X1++; } } }
public override void Redraw(int offx, int offy) { console.ClearMessagesAbove(0); time += Time.unscaledDeltaTime; //if (fade < 0.99f) // return; base.Redraw(offx, offy); XX -= Time.unscaledDeltaTime * 30; int X = (int)XX; if (X < 0) { X += SHGUI.current.resolutionX; } int Y = 4; for (int i = 0; i < columns.Count - 1; ++i) { for (int j = 0; j < columns[i].Length; ++j) { if (columns[i][j] != ' ') { ; } int startx = mapxcol(X + i); if (startx < SHGUI.current.resolutionX - 1) { if (fade > 0.5f) { SHGUI.current.SetPixelFront(StringScrambler.GetScrambledString(columns[i][j] + "", 1 - fade)[0], startx, Y + j + (int)(mysin(time, startx)), 'w'); } } } } //APPFRAME.Redraw (offx, offy); }
public void ExecuteMetricsStringScramblerTest() { IScrambler <string> scrambler = new StringScrambler(); ScramblerClient <string> client = new ScramblerClient <string>(scrambler); List <string> inputStrings = new List <string>(); for (var i = 0; i <= 100000; i++) { inputStrings.Add(String.Format("Hello World" + i)); } var watch = System.Diagnostics.Stopwatch.StartNew(); foreach (string str in inputStrings) { client.ExecuteScramble(str); } watch.Stop(); var elapsedSeconds = watch.ElapsedMilliseconds / 1000; Console.WriteLine(String.Format("Time taken: ", elapsedSeconds)); }
public void DrawText(string text, int x, int y, char col, float fade = 1) { int xoff = x; int yoff = 0; text = StringScrambler.GetScrambledString(text, 1 - fade); for (int i = 0; i < text.Length; ++i) { if (text[i] == '\n' || (int)text[i] == 10) { xoff = x; yoff++; } else { if (Random.value < fade) { if (text[i] == headChar) { col = 'r'; } else if (text[i] == tailChar) { col = 'r'; } else if (text[i] == wireChar) { col = 'z'; } SHGUI.current.SetPixelBack(text[i], xoff, y + yoff, col); xoff++; } } } }
private void CreateViewFromNode(XElement e = null) { bool isRoot = false; if (e == null) { isRoot = true; e = DATA.Root; } string currentPath = ""; SHGUIcommanderview l = new SHGUIcommanderview(); createdView = l; l.isRoot = isRoot; SHGUIcommanderbutton b = null; string description = ""; if (!isRoot) { b = new SHGUIcommanderbutton("/.. │<UP-FOL>", 'w', () => { SHGUI.current.PopView(); }).SetListLink(l).SetData("directory: GO UP"); l.AddButtonView(b); SHGUIcommanderview L = SHGUI.current.GetInteractableView() as SHGUIcommanderview; if (L != null) { l.path = L.path + e.Name.ToString().ToUpper() + "\\"; } } else { l.path = "C:\\"; //AnalProbe.PushEnvironmentSurvey(); } foreach (XElement E in e.Elements()) { XElement node = E; string name = ""; if (!(node.Attribute("showInBarebones") != null && node.Attribute("showInBarebones").Value.ToString() == "true")) { elementCounter++; displayedThisCounter = false; } else { } if (elementCounter >= downloadProgress) { if (!(node.Attribute("showInBarebones") != null && node.Attribute("showInBarebones").Value.ToString() == "true")) { continue; } else { } } if (E.Name.ToString() != "item") { name = E.Name.ToString().ToUpper(); while (name.Length < 12) { name += " "; } name = name + "│>FOLDER<"; description = "directory: " + name; b = new SHGUIcommanderbutton(name, 'w', () => CreateViewFromNode(node)).SetListLink(l).SetData(description); l.AddButtonView(b); } else { string type = node.Attribute("type").Value.ToString(); //.ToLower(); name = node.Attribute("name").Value.ToString(); while (name.Length < 12) { name += " "; } if (type == "readme") { name = name + "│--ITEM->"; description = StringScrambler.GetScrambledSimply(node.Value.ToString()); b = new SHGUIcommanderbutton(name, 'w', null).SetListLink(l).SetData(description); //.SetOnActivate(()=>{SHGUI.current.ShowReadmeFile(node.Attribute("name").Value.ToString(),node.Value.ToString());}); if (node.Attribute("align") != null) { if (node.Attribute("align").Value == "left") { b.ContentAlign = SHAlign.Left; } else if (node.Attribute("align").Value == "center") { b.ContentAlign = SHAlign.Center; } if (node.Attribute("align").Value == "right") { b.ContentAlign = SHAlign.Right; } } l.AddButtonView(b); } else if (type == "separator") { name = "------------│--------"; description = ""; b = new SHGUIcommanderbutton(name, 'w', () => {}).SetListLink(l).SetData(description); l.AddButtonView(b); } ///NOT USED else if (type == "level") { name = name + "│--ITEM->"; description = "level: " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', null).SetListLink(l).SetData(description); l.AddButtonView(b); } else if (type == "userlevel") { name = name + "│--ITEM->"; description = "userlevel: " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', () => { SHGUI.current.LaunchUserLevel(node.Attribute("bundle").Value.ToString(), node.Attribute("scene").Value.ToString()); }).SetListLink(l).SetData("launches user level: " + node.Attribute("bundle").Value.ToString()); l.AddButtonView(b); } else if (type == "mod") { name = name + "│--ITEM->"; description = StringScrambler.GetScrambledSimply(StringScrambler.longfiller + StringScrambler.longfiller + "\n\n" + node.Value.ToString() + StringScrambler.longfiller + StringScrambler.longfiller); //description = node.Attribute("description").Value.ToString(); b = new SHGUIcommanderbutton(name, 'w', null).SetListLink(l).SetData(description); l.AddButtonView(b); } else if (type == "app") { name = name + "│--ITEM->"; description = "app: " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', () => { SHGUI.current.LaunchAppByName(node.Attribute("appclass").Value.ToString()); }).SetListLink(l).SetData(description); l.AddButtonView(b); if (node.Attribute("appclass").Value.ToString() == "APPquit") { b.IsQuitButton = true; } } else if (type == "lua") { name = name + "│--ITEM->"; description = "app: " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', () => { SHGUI.current.LaunchLuaAppByScriptName(node.Attribute("luafile").Value.ToString()); }).SetListLink(l).SetData(description); l.AddButtonView(b); } else if (type == "exploit" && !dontShowExploit) { name = name + "│--ITEM->"; description = "app: " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', () => SHGUI.current.LaunchAppByName("APPkill")).SetListLink(l).SetData(description); l.AddButtonView(b); } else if (type == "reboot") { name = name + "│--ITEM->"; description = "app " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', () => { }).SetListLink(l).SetData(description); l.AddButtonView(b); } else if (type == "endless") { name = name + "│--ITEM->"; description = "app " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', () => { }).SetListLink(l).SetData(description); l.AddButtonView(b); } else if (type == "last" && !dontShowPlayLast) { } else if (type == "vid") { name = name + "│--ITEM->"; description = "vid: " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', () => { SHGUI.current.ShowVideo(node.Attribute("vidname").Value.ToString()); }).SetListLink(l).SetData(description); l.AddButtonView(b); } else if (type == "wir") { name = name + "│--ITEM->"; description = "wir: " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', () => { SHGUI.current.ShowWiresSchem(node.Attribute("wirname").Value.ToString()); }).SetListLink(l).SetData(description); l.AddButtonView(b); } else if (type == "art") { name = name + "│--ITEM->"; description = "app: " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', () => { SHGUI.current.ShowArtFile(node.Attribute("name").Value.ToString(), node.Attribute("artname").Value.ToString(), false); }).SetListLink(l).SetData(description); l.AddButtonView(b); } else if (type == "artcent") { name = name + "│--ITEM->"; description = "app: " + name + " " + Random.Range(0, 3000); b = new SHGUIcommanderbutton(name, 'w', () => { SHGUI.current.ShowArtFile(node.Attribute("name").Value.ToString(), node.Attribute("artname").Value.ToString(), true); }).SetListLink(l).SetData(description); l.AddButtonView(b); } else if (type == "storylevels") { AppendGameDataListFromNode(l, GameData.Descendants("Story").First()); } else if (type == "endlesslevels") { AppendGameDataListFromNode(l, GameData.Descendants("Endless").First()); CheckEndlessAvaliability(); } else if (type == "modslist") { AppendGameDataListFromNode(l, GameData.Descendants("Mods").First()); } if (type == "deactivate") { name = name + "│--ITEM->"; description = StringScrambler.GetScrambledSimply(node.Value); b = new SHGUIcommanderbutton(name, 'w', null).SetListLink(l).SetData(description).SetOnActivate( () => { var modsButtons = SHGUI.current.GetInteractableView().children.Where( c => (c is SHGUIcommanderbutton) && (c as SHGUIcommanderbutton).AssignedModifier != null); b.data = node.Value; b.highlighted = true; }).SetOnHighlight( () => { var activeMods = SHGUI.current.GetInteractableView().children.Where( c => (c is SHGUIcommanderbutton) && (c as SHGUIcommanderbutton).AssignedModifier != null && (c as SHGUIcommanderbutton).Active); foreach (SHGUIcommanderbutton mod in activeMods) { b.data += mod.Text.Substring(0, 12) + "\n"; } }).SetOnDeHighlight( () => { b.data = node.Value; }); l.AddButtonView(b); } if (type == "web") { name = name + "│--LINK->"; description = StringScrambler.GetScrambledSimply(node.Value); b = new SHGUIcommanderbutton(name, 'w', null).SetListLink(l).SetData(description);//.SetOnActivate(()=>{SHGUI.current.ShowReadmeFile(node.Attribute("name").Value.ToString(),node.Value.ToString());}); b.Url = node.Attribute("url").Value; l.AddButtonView(b); } if (type == "settingInvert") { name = name + "│>------<"; description = StringScrambler.GetScrambledSimply(node.Value); b = new SHGUIcommanderbutton(name, 'w', null).SetListLink(l).SetData(description); var b1 = b; b.SetOnActivate( () => { //AnalProbe.PushEnvironmentSurvey(); }); l.AddButtonView(b); } if (type == "settingReset") { name = name + "│--ITEM->"; description = StringScrambler.GetScrambledSimply(node.Value); b = new SHGUIcommanderbutton(name, 'w', () => SHGUI.current.LaunchAppByName("APPResetStory")).SetListLink(l).SetData(description); l.AddButtonView(b); } if (type == "settingUnlock") { name = name + "│--ITEM->"; description = StringScrambler.GetScrambledSimply(node.Value); b = new SHGUIcommanderbutton(name, 'w', () => SHGUI.current.LaunchAppByName("APPUnlockEverything")).SetListLink(l).SetData(description); l.AddButtonView(b); } if (type == "settingAttract") { name = name + "│>------<"; description = StringScrambler.GetScrambledSimply(node.Value); b = new SHGUIcommanderbutton(name, 'w', null).SetListLink(l).SetData(description); var b1 = b; b.SetOnActivate( () => { }); l.AddButtonView(b); } if (b != null && b.data.Contains("[RANDOM_TIME_PUN]")) { b.data = b.data.Replace("[RANDOM_TIME_PUN]", GetRandomTimepun()); } } if (b != null) { if (Mathf.Abs(downloadProgress - elementCounter) <= 20 && !displayedThisCounter) { if ((node.Attribute("type") != null && node.Attribute("type").Value.ToString() == "separator") || (node.Attribute("showInBarebones") != null && node.Attribute("showInBarebones").Value.ToString() == "true")) { displayedThisCounter = true; } else { displayedThisCounter = true; b.SetColorRecursive('r'); b.constantScramble = true; b.constantScrambleSpeed = .01f; b.color = 'r'; } } else { } } } if (l.buttons[l.currentButton].OnHighlight != null && AddToQueueMode == false) { l.buttons[l.currentButton].OnHighlight.Invoke(); } if (!AddToQueueMode) { SHGUI.current.AddViewOnTop(l); } else { SHGUI.current.AddViewToQueue(l); AddToQueueMode = false; } }
public void Constructor() { FluentActions.Invoking(() => systemUnderTest = new EmailScambler()) .Should() .NotThrow(); }
public void Setup() { systemUnderTest = new StringScrambler(); }