protected override void Run() { try { bool loop = true; /// Avoid a Stupid Debugger loop while (loop) { canvas.ClearBuf(Color.Green); // canvas.Render(); int X = (int)Sys.MouseManager.X; int Y = (int)Sys.MouseManager.Y; // canvas.DrawFilledRectangle(new Pen(Color.Crimson), X, Y, 20, 20); // Kernel.helper.Render(); //canvas.Render(); var input = Console.ReadLine(); MainCommands.RunConsoleCommand(input); } } catch (Exception error) { Console.BackgroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); m_log.WarnFormat("SYSTEM CRASH", MainCommands.UpperCase("System Crashed with exception: " + error.Message + ".")); m_log.WarnFormat("SYSTEM CRASH", MainCommands.UpperCase("If this keeps happening please Contact the Author of RetroBasic at " + system_email)); Console.ReadKey(); Console.BackgroundColor = ConsoleColor.Blue; Console.Clear(); StartScreen(); } }
public bool IsFlubuSetup() { if (MainCommands == null) { return(false); } return(MainCommands.Count == 1 && MainCommands.First().Equals("setup", StringComparison.OrdinalIgnoreCase)); }
public static void ParseClient(Client player, TabCompleteClient tab) { if (tab.Command.StartsWith("/")) { MainCommands.ParseClientTab(player, tab); } else { ParseClientChat(player, tab); } }
public override void Execute() { DateTime now = DateTime.Now; string fileName = $"ClassicAssist-{now.Year}-{now.Month}-{now.Day}-{now.Hour}-{now.Minute}-{now.Second}.png"; bool result = MainCommands.Snapshot(0, false, fileName); if (result) { UOC.SystemMessage(string.Format(Strings.Snapshot_Saved___0_, fileName)); } }
public bool IsInternalCommand() { if (MainCommands == null || MainCommands.Count == 0) { return(false); } var firstCommand = MainCommands.First(); return(firstCommand.Equals(InternalFlubuCommands.Setup, StringComparison.OrdinalIgnoreCase) || firstCommand.Equals(InternalFlubuCommands.New, StringComparison.OrdinalIgnoreCase)); }
public static void StartScreen() { Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); string boot = "**** COSMOS BASIC V1 ****"; Console.SetCursorPosition((Console.WindowWidth - boot.Length) / 2, Console.CursorTop); Console.WriteLine(boot); string memory = MemoryManager.UsedMemory().ToString() + " MB / " + MemoryManager.TotalMemory().ToString() + " MB (used / total)"; Console.SetCursorPosition((Console.WindowWidth - memory.Length) / 2, Console.CursorTop + 1); Console.WriteLine(MainCommands.UpperCase(memory)); Console.WriteLine("READY."); }
public static void ParseClient(Client player, ChatMessageClient chat) { string message = chat.Text; if (message.Contains("§")) { Log.WritePlayer(player, "Illegal chat: " + message); return; } //Flood detection if (player.ChatFloodNextReset < DateTime.Now) { player.ChatFloodCount = 1; player.ChatFloodNextReset = DateTime.Now.AddSeconds(5); } else { player.ChatFloodCount += 1; if (player.ChatFloodCount > 10) { player.ChatFloodCount = 0; player.BanByServer(DateTime.Now.AddMinutes(5), "Chat Flood"); return; } } if (chat.Text.StartsWith("/")) { MainCommands.ParseClientCommand(player, message); } else { ParseClientChat(player, message); } }
public static void Init(MainCommands c) { c.AddCommand(Translate, "translate", "tr", "trans"); }
private static bool OnResync(string[] arg) { MainCommands.Resync(); return(true); }
public void Execute(MacroEntry macro) { _macro = macro; if (Thread != null && Thread.IsAlive) { Stop(); } MainCommands.SetQuietMode(Options.CurrentOptions.DefaultMacroQuietMode); _cancellationToken = new CancellationTokenSource(); if (_importCache == null) { _importCache = InitializeImports(_engine); } ScriptSource source = _engine.CreateScriptSourceFromString(_macro.Macro, SourceCodeKind.Statements); Dictionary <string, object> importCache = new Dictionary <string, object>(_importCache); IsFaulted = false; Thread = new Thread(() => { Thread = Thread.CurrentThread; try { StartedEvent?.Invoke(); AliasCommands.SetDefaultAliases(); ScriptScope macroScope = _engine.CreateScope(importCache); StopWatch.Reset(); StopWatch.Start(); do { _cancellationToken.Token.ThrowIfCancellationRequested(); source.Execute(macroScope); StopWatch.Stop(); bool willLoop = _macro.Loop && !IsFaulted && !_cancellationToken.IsCancellationRequested; if (!willLoop) { break; } if (Options.CurrentOptions.Debug) { UO.Commands.SystemMessage(string.Format(Strings.Loop_time___0_, StopWatch.Elapsed)); } int diff = 50 - (int)StopWatch.ElapsedMilliseconds; if (diff > 0) { Thread.Sleep(diff); } }while (_macro.Loop && !IsFaulted); } catch (TaskCanceledException) { IsFaulted = true; } catch (ThreadInterruptedException) { IsFaulted = true; } catch (ThreadAbortException) { IsFaulted = true; } catch (Exception e) { IsFaulted = true; Exception = e; ExceptionEvent?.Invoke(e); } finally { StoppedEvent?.Invoke(); MacroManager.GetInstance().OnMacroStopped(); } }) { IsBackground = true }; try { Thread.Start(); MacroManager.GetInstance().OnMacroStarted(); } catch (ThreadStateException) { // TODO } catch (ThreadStartException) { // TODO } }
public override void Execute() { MainCommands.Hotkeys(); }
public UpdateWebSocket( KDFCommandsPlugin kdf, Player player, PlayManager playManager, ResolveContext resolver, Ts3Client ts3Client, TsFullClient ts3FullClient, ConfWebSocket confWebSocket ) { this.kdf = kdf; this.player = player; this.playManager = playManager; this.resolver = resolver; this.ts3Client = ts3Client; this.ts3FullClient = ts3FullClient; this.playManager.Queue.OnQueueChange += QueueChanged; this.playManager.Queue.OnQueueIndexChange += UpdateRecentlyPlayed; this.kdf.Autofill.OnStateChange += AutofillChanged; this.kdf.Voting.OnSkipVoteChanged -= SkipVoteChanged; server = new WebSocketServer(IPAddress.Loopback, 2021, confWebSocket); server.OnClientConnected += ClientConnected; running = true; var thread = new Thread(() => { JsonValue <Dictionary <string, IList <(string, string)> > > listeners = null; JsonValue <SongInfo> song = null; bool frozen = false; long frozenSince = -1; while (running) { // Check for listener change var newListeners = KDFCommandsPlugin.CommandListeners(ts3Client, ts3FullClient, player); if (listeners == null || !ListenersEqual(listeners, newListeners)) { SendListenerUpdate(newListeners); } listeners = newListeners; // Check if song should be updated JsonValue <SongInfo> newSong = null; try { newSong = MainCommands.CommandSong(playManager, player, resolver); } catch (CommandException) { // Don't crash just because nothing is playing } if (newSong != null) { var ts = DateTimeOffset.Now.ToUnixTimeMilliseconds(); bool frozenStateChanged = ts - player.WebSocketPipe.LastDataSentTimestamp > 500 != frozen; if (frozenStateChanged) { frozen = !frozen; frozenSince = frozen ? DateTimeOffset.Now.ToUnixTimeSeconds() : -1; } if ( song == null || newSong.Value.Position < song.Value.Position || newSong.Value.Length != song.Value.Length || newSong.Value.Link != song.Value.Link || newSong.Value.Paused != song.Value.Paused || frozenStateChanged && !frozen ) { if (Log.IsTraceEnabled) { string reason = "Unexpected reason."; if (song == null) { reason = "First song started playing."; } else if (newSong.Value.Position < song.Value.Position) { reason = "Position < previous position."; } else if (newSong.Value.Length != song.Value.Length) { reason = "Length changed."; } else if (newSong.Value.Link != song.Value.Link) { reason = "Resource URL changed."; } else if (newSong.Value.Paused != song.Value.Paused) { reason = "Pause state changed."; } else if (frozenStateChanged & !frozen) { reason = "Song was frozen for over 500ms and now unfroze."; } Log.Trace("Song update sent. Reason: " + reason); } SendSongUpdate(newSong); } // Send resync update if frozen every 5 seconds. if (frozen && (DateTimeOffset.Now.ToUnixTimeSeconds() - frozenSince) % 5 == 4) { Log.Trace("Song update sent. Reason: Update in frozen state."); SendSongUpdate(newSong); } } else if (song != null) { // newSong is null but previous song was not --> music stopped SendToAll("song", null); Log.Trace("Song update sent. Reason: Music stopped."); } song = newSong; Thread.Sleep(1000); } }) { IsBackground = true }; thread.Start(); }
public override void Execute() { MainCommands.WarMode("on"); }