Esempio n. 1
0
        /// <summary>
        ///     Prints a line that fits perfectly to the window width
        /// </summary>
        /// <param name="linePattern">The pattern for the line</param>
        /// <param name="colorCode">Extra color code for the line (optional)</param>
        /// <param name="consoleType">Should extra console Type used?</param>
        public static void PrintLine(string linePattern, string colorCode = "",
                                     ConsoleType consoleType = ConsoleType.Line)
        {
            var returnString = colorCode;

            // Generate line
            for (var i = 0;
                 i *linePattern.Length < ConsoleSize.Width;
                 i++)
            {
                returnString += linePattern;
            }

            // Optional cut line
            if (returnString.Length > ConsoleSize.Width)
            {
                returnString = returnString.Substring(0, ConsoleSize.Width);
            }
            if (consoleType != ConsoleType.Line)
            {
                returnString = "~!--!~" + returnString;
            }
            ConsoleUtils.ResetColor();

            // Write line
            WriteLine(consoleType, returnString, true);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsoleMessage"/> class.
 /// </summary>
 /// <param name="type">Type.</param>
 /// <param name="text">Text.</param>
 /// <param name="args">Arguments.</param>
 /// <param name="location">Message location</param>
 public ConsoleMessage(ConsoleType type, string text, IList <JSHandle> args, ConsoleMessageLocation location = null)
 {
     Type     = type;
     Text     = text;
     Args     = args;
     Location = location;
 }
Esempio n. 3
0
        public frmControllerConfig(ControllerInfo controllerInfo, int portNumber, ConsoleType consoleType)
        {
            InitializeComponent();

            Entity = controllerInfo;

            AddBinding("TurboSpeed", trkTurboSpeed);
            ctrlStandardController0.Initialize(controllerInfo.Keys[0]);
            ctrlStandardController1.Initialize(controllerInfo.Keys[1]);
            ctrlStandardController2.Initialize(controllerInfo.Keys[2]);
            ctrlStandardController3.Initialize(controllerInfo.Keys[3]);

            if (portNumber == 1 && consoleType == ConsoleType.Famicom)
            {
                ctrlStandardController0.ShowMicrophone = true;
                ctrlStandardController1.ShowMicrophone = true;
                ctrlStandardController2.ShowMicrophone = true;
                ctrlStandardController3.ShowMicrophone = true;
            }

            this.btnSelectPreset.Image = BaseControl.DownArrow;

            ResourceHelper.ApplyResources(this, mnuStripPreset);

            this.Text += ": " + ResourceHelper.GetMessage("PlayerNumber", (portNumber + 1).ToString());
        }
Esempio n. 4
0
        public static void WriteLine(object value, ConsoleType type, ConsoleWriter writer)
        {
            switch (type)
            {
                case ConsoleType.Info:
                    WriteLine("  [INFO] " + value, ConsoleColor.Yellow, writer); break;

                case ConsoleType.Error:
                    WriteLine("  [ERROR] " + value, ConsoleColor.Red, writer); break;

                case ConsoleType.Connect:
                    if (!GlobalConfig.Debug) return;
                    WriteLine("    [CONNECTION] " + value, ConsoleColor.Cyan, writer); break;

                case ConsoleType.Disconnect:
                    if (!GlobalConfig.Debug) return;
                    WriteLine("    [DISCONNNECTION] " + value, ConsoleColor.DarkCyan, writer); break;

                case ConsoleType.Receive:
                    if (!GlobalConfig.Debug) return;
                    WriteLine("      [RECV] " + value, ConsoleColor.Green, writer); break;

                case ConsoleType.Send:
                    if (!GlobalConfig.Debug) return;
                    WriteLine("      [SEND] " + value, ConsoleColor.DarkGreen, writer); break;

                default:
                    WriteLine(value, ConsoleColor.White, writer); break;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 构建控制台
        /// </summary>
        /// <param name="consoleType">控制台类型</param>
        /// <param name="bold">字体粗细</param>
        /// <param name="maximum">最大化</param>
        /// <param name="width">宽度</param>
        /// <param name="height">高度</param>
        /// <param name="title">标题</param>
        /// <returns>是否成功</returns>
        public static void Construct(ConsoleType consoleType, bool bold, bool maximum,
                                     short width, short height, string title = "Destroy")
        {
            SetConsoleSetting(title);

            switch (consoleType)
            {
            case ConsoleType.Default:
                SetFontAndWindow("Consolas", bold, 16, 16, maximum, width, height);
                break;

            case ConsoleType.Chinese:
                SetFontAndWindow("新宋体", bold, 16, 16, maximum, width, height);
                break;

            case ConsoleType.Pixel:
                SetFontAndWindow("Terminal", bold, 8, 8, maximum, width, height);
                break;

            case ConsoleType.HignQuality:
                SetFontAndWindow("MS Gothic", bold, 1, 1, maximum, width, height);
                break;
            }

            if (maximum)
            {
                KERNEL.SET_WINDOW_POS(0, 0);
            }
            else
            {
                CONSOLE.CenterConsoleWindowPosition();
            }
            CONSOLE.CursorVisible = false;
        }
Esempio n. 6
0
        /// <summary>
        ///     Writes a full centred Text in the Console.
        /// </summary>
        /// <param name="consoleType"></param>
        /// <param name="text"></param>
        public static void WriteCentredText(ConsoleType consoleType, string text)
        {
            // Parse linebreaks for clear output
            var messages = text.Split(new[] { "\n", "~n~" }, StringSplitOptions.RemoveEmptyEntries);

            // No text -> return;
            if (!messages.Any())
            {
                return;
            }

            //Make each line the same length
            var longestTextLine = messages.OrderBy(s => s.Length).First().Length;

            for (var i = 0; i < messages.Length; i++)
            {
                // wrapp messages if they are to long for the console space
                var wrappedMessages = WordWrapMessage(messages[i]);
                for (var b = 0; b < wrappedMessages.Length; b++)
                {
                    var firstMessageOfSet = i == 0 && b == 0;
                    var lastMessageOfSet  = i == messages.Length - 1 && b == wrappedMessages.Length - 1;
                    InternalWrite(consoleType,
                                  _prefix + ConsoleUtils.AlignText(wrappedMessages[b], longestTextLine, true), true, "\n",
                                  firstMessageOfSet, lastMessageOfSet);
                }
            }
        }
Esempio n. 7
0
        public static void WriteConsole(string message, ConsoleType type = ConsoleType.Infor)
        {
            Console.Write(DateTime.Now.ToString("HH:mm:ss.fff dd-MM-yyyy"));
            Console.Write(" - ");
            switch (type)
            {
            case ConsoleType.Infor:
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write("infor");
                Console.ResetColor();
                break;

            case ConsoleType.Warnning:
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write("warrning");
                Console.ResetColor();
                break;

            case ConsoleType.Error:
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("error");
                Console.ResetColor();
                break;
            }
            Console.Write(" - ");
            Console.WriteLine(message);
        }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsoleMessage"/> class.
 /// </summary>
 /// <param name="type">Type.</param>
 /// <param name="text">Text.</param>
 /// <param name="args">Arguments.</param>
 /// <param name="handleToString">IJSHandle to string.</param>
 /// <param name="location">Message location.</param>
 internal ConsoleMessage(ConsoleType type, string text, IEnumerable <IJSHandle> args, Func <IJSHandle, bool, string> handleToString, ConsoleMessageLocation location = null)
 {
     Type            = type;
     _text           = text;
     _handleToString = handleToString;
     Args            = args;
     Location        = location;
 }
Esempio n. 9
0
    public int GetFirmwareInfo(ref int firmware, ref int ccapiVersion, ref ConsoleType consoleType)
    {
        int cType = 0;
        int ret   = CCAPIGetFirmwareInfo(ref firmware, ref ccapiVersion, ref cType);

        consoleType = (ConsoleType)cType;
        return(ret);
    }
Esempio n. 10
0
        /// <summary>
        ///     Returns the propertys for the given ConsoleType
        /// </summary>
        /// <param name="consoleType">The requested console type</param>
        /// <returns></returns>
        public static ConsoleTypeProperties GetConsoleTypeProperties(ConsoleType consoleType)
        {
            MemberInfo[]          memberInfo = consoleType.GetType().GetMember(consoleType.ToString());
            ConsoleTypeProperties attributes =
                (ConsoleTypeProperties)memberInfo[0].GetCustomAttribute(typeof(ConsoleTypeProperties), false);

            return(attributes);
        }
Esempio n. 11
0
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


    //---------- void AddMesage(string message, string color) ------
    //Adds a mesage to the list
    //--------------------------------------------------------------

    public void AddMessage(string message, ConsoleType type = ConsoleType.INFO)
    {
        if (Level >= type)
        {
            messages.Add(new ConsoleMessage(type, message));
            _needUpdate = true;
        }
    }
 public static void Settings(Text Text, ScrollRect ScrollRect, ConsoleButtons ConsoleButtons)
 {
     text           = Text;
     scrollRect     = ScrollRect;
     text.text      = consoleReport;
     activeConsole  = ConsoleType.REPORT;
     consoleButtons = ConsoleButtons;
 }
Esempio n. 13
0
        /// <summary>
        /// 构建控制台并创建相应的图形对象
        /// </summary>
        /// <param name="consoleType">控制台类型</param>
        /// <param name="bold">字体粗细</param>
        /// <param name="maximum">最大化</param>
        /// <param name="width">宽度</param>
        /// <param name="height">高度</param>
        /// <param name="charWidth">字符宽度</param>
        /// <param name="title">标题</param>
        /// <returns>图形对象</returns>
        public static Graphics Construct2(ConsoleType consoleType, bool bold, bool maximum,
                                          short width, short height, CharWidth charWidth, string title = "Destroy")
        {
            short w = (short)(width * (int)charWidth);

            Construct(consoleType, bold, maximum, w, height, title);
            Graphics graphics = new Graphics(width, height, charWidth);

            return(graphics);
        }
Esempio n. 14
0
        /// <summary>
        /// Creates an instance of Console.
        /// </summary>
        /// <param name="consoleType"></param>
        public Console(ConsoleType consoleType)
        {
            _type = consoleType;

            if (consoleType == ConsoleType.Cmd)
            {
                if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings[Console.CmdExecutionStringKey]))
                {
                    _executionString = ConfigurationManager.AppSettings[Console.CmdExecutionStringKey];
                    _arguments       = ConfigurationManager.AppSettings[Console.CmdArgumentsKey];
                }
                else
                {
                    throw new ConfigurationErrorsException("Cmd is not configured.");
                }
            }
            else if (consoleType == ConsoleType.CygWin)
            {
                if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings[Console.CygWinExecutionStringKey]))
                {
                    _executionString = ConfigurationManager.AppSettings[Console.CygWinExecutionStringKey];
                    _arguments       = ConfigurationManager.AppSettings[Console.CygWinArgumentsKey];
                }
                else
                {
                    throw new ConfigurationErrorsException("CygWin is not configured.");
                }
            }
            else if (consoleType == ConsoleType.PowerShell)
            {
                if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings[Console.PowerShellExecutionStringKey]))
                {
                    _executionString = ConfigurationManager.AppSettings[Console.PowerShellExecutionStringKey];
                }
                else
                {
                    throw new ConfigurationErrorsException("PowerShell is not configured.");
                }
            }
            else
            {
                throw new ArgumentException("ConsoleType is not of a recognized or configured type");
            }

            _process = Process.Start(_executionString, _arguments);
            _process.StartInfo.CreateNoWindow         = true;
            _process.StartInfo.UseShellExecute        = false;
            _process.StartInfo.RedirectStandardInput  = true;
            _process.StartInfo.RedirectStandardError  = true;
            _process.StartInfo.RedirectStandardOutput = true;
            _process.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            _process.Start();
        }
Esempio n. 15
0
 void Start()
 {
     ConsoleReport.Settings(text, scrollRect, this);
     btnReport.onClick.AddListener(() => Console(ConsoleType.REPORT, btnReport));
     btnBattle.onClick.AddListener(() => Console(ConsoleType.BATTLE, btnBattle));
     btnHistory.onClick.AddListener(() => Console(ConsoleType.HISTORY, btnHistory));
     btnMission.onClick.AddListener(() => Console(ConsoleType.MISSION, btnMission));
     consoleTypeSelected = ConsoleType.REPORT;
     btnReport.Select();
     colorBlock  = btnReport.colors;
     btnSelected = btnReport;
 }
Esempio n. 16
0
        public frmControllerConfig(ControllerInfo controllerInfo, int portNumber, ConsoleType consoleType, InteropEmu.ControllerType controllerType)
        {
            InitializeComponent();

            if (!this.DesignMode)
            {
                SetMainTab(this.tabMain);

                Entity = controllerInfo;

                AddBinding("TurboSpeed", trkTurboSpeed);

                ctrlStandardController0.Initialize(controllerInfo.Keys[0]);
                ctrlStandardController1.Initialize(controllerInfo.Keys[1]);
                ctrlStandardController2.Initialize(controllerInfo.Keys[2]);
                ctrlStandardController3.Initialize(controllerInfo.Keys[3]);

                ctrlStandardController0.PortNumber = portNumber;
                ctrlStandardController1.PortNumber = portNumber;
                ctrlStandardController2.PortNumber = portNumber;
                ctrlStandardController3.PortNumber = portNumber;

                if (portNumber == 1 && consoleType == ConsoleType.Famicom)
                {
                    ctrlStandardController0.ShowMicrophone = true;
                    ctrlStandardController1.ShowMicrophone = true;
                    ctrlStandardController2.ShowMicrophone = true;
                    ctrlStandardController3.ShowMicrophone = true;
                }

                if (controllerType == InteropEmu.ControllerType.SnesController)
                {
                    ctrlStandardController0.Type = StandardControllerType.SnesController;
                    ctrlStandardController1.Type = StandardControllerType.SnesController;
                    ctrlStandardController2.Type = StandardControllerType.SnesController;
                    ctrlStandardController3.Type = StandardControllerType.SnesController;
                }

                if (InteropEmu.IsVsSystem())
                {
                    ctrlStandardController0.Type = StandardControllerType.VsSystem;
                    ctrlStandardController1.Type = StandardControllerType.VsSystem;
                    ctrlStandardController2.Type = StandardControllerType.VsSystem;
                    ctrlStandardController3.Type = StandardControllerType.VsSystem;
                }

                this.btnSelectPreset.Image = BaseControl.DownArrow;

                ResourceHelper.ApplyResources(this, mnuStripPreset);
                this.Text += ": " + ResourceHelper.GetMessage("PlayerNumber", (portNumber + 1).ToString());
            }
        }
Esempio n. 17
0
        private void Console(ConsoleType consoleType, Button button)
        {
            consoleTypeSelected = consoleType;
            ConsoleReport.SetConsole(consoleType);
            Canvas.ForceUpdateCanvases();
            scrollRect.verticalNormalizedPosition = 0f;
            ColorBlock color = button.colors;

            color.normalColor  = Color.black;
            btnSelected.colors = color;
            color.normalColor  = Color.gray;
            button.colors      = color;
            btnSelected        = button;
        }
Esempio n. 18
0
 public RomHeader(RomVersion version, MemorySizes program, MemorySizes character, int mapper, int submapper, CpuTimingMode cpuTiming, RomFlags flags, ConsoleType console, int consoleTypeDetail, int miscellaneousRomCount, int defaultExpansionDevice)
 {
     Version                = version;
     Program                = program;
     Character              = character;
     Mapper                 = mapper;
     Submapper              = submapper;
     CpuTiming              = cpuTiming;
     Flags                  = flags;
     Console                = console;
     ConsoleTypeDetail      = consoleTypeDetail;
     MiscellaneousRomCount  = miscellaneousRomCount;
     DefaultExpansionDevice = defaultExpansionDevice;
 }
Esempio n. 19
0
        public static Account Decrypt(Stream inputStream, ConsoleType consoleType)
        {
            var hmac = new HMACSHA1(consoleType == ConsoleType.Retail ? RetailKey : DevkitKey);
            var hash = inputStream.ReadBytes(16);
            var rc4Key = hmac.ComputeHash(hash);
            Array.Resize(ref rc4Key, 16);

            var rest = inputStream.ReadBytes(388);
            var body = RC4.Decrypt(rc4Key, rest);

            var compareBuffer = hmac.ComputeHash(body);
            if (!memcmp(hash, compareBuffer, 16))
                throw new InvalidDataException("Keys do not match");
            return ModelFactory.GetModel<Account>(body.Skip(8).ToArray());
        }
Esempio n. 20
0
        public static string GetRemoteGameSyncPath(ConsoleType consoleType)
        {
            if (RemoteGameSyncPath == null)
            {
                throw new NullReferenceException("No valid sync path is available");
            }

            if (ConfigIni.Instance.SeparateGameStorage)
            {
                if (consoleType == ConsoleType.Unknown)
                {
                    throw new ArgumentException("No valid console type was given");
                }
                return(RemoteGameSyncPath + "/" + ConsoleTypeToSystemCode[consoleType]);
            }
            return(RemoteGameSyncPath);
        }
Esempio n. 21
0
        public static Account Decrypt(Stream inputStream, ConsoleType consoleType)
        {
            var hmac   = new HMACSHA1(consoleType == ConsoleType.Retail ? RetailKey : DevkitKey);
            var hash   = inputStream.ReadBytes(16);
            var rc4Key = hmac.ComputeHash(hash);

            Array.Resize(ref rc4Key, 16);

            var rest = inputStream.ReadBytes(388);
            var body = RC4.Decrypt(rc4Key, rest);

            var compareBuffer = hmac.ComputeHash(body);

            if (!memcmp(hash, compareBuffer, 16))
            {
                throw new InvalidDataException("Keys do not match");
            }
            return(ModelFactory.GetModel <Account>(body.Skip(8).ToArray()));
        }
Esempio n. 22
0
        public static string GetConsoleTypeString(this ConsoleType ct, string pr = "")
        {
            string r   = string.Empty;
            var    ots = GetTimeStamp();

            switch (ct)
            {
            case ConsoleType.ServiceStart: r = $"{ots}: WiFi Reconnecter service started..."; break;

            case ConsoleType.ServiceStop: r = $"{ots}: Not connected to a wifi access point and can't connect to one. Service stopped."; break;

            case ConsoleType.WiFiConnected: r = $"{ots}: WiFi {pr} is connected!"; break;

            case ConsoleType.WiFiReconnected: r = $"{ots}: WiFi {pr} reconnected"; break;

            case ConsoleType.WiFiReconnectionProblem: r = $"{ots}: Reconnection problem! Trying again in 1 minute..."; break;
            }

            return(r);
        }
        public static string ExecuteCommand(string command, ConsoleType console)
        {
            ProcessStartInfo procStartInfo = null;

            switch (console)
            {
            case ConsoleType.CMD:
                procStartInfo = new ProcessStartInfo("cmd", "/c " + command);
                break;

            case ConsoleType.Powershell:
                procStartInfo = new ProcessStartInfo("powershell", "-command " + command);
                break;

            case ConsoleType.Bash:
                procStartInfo = new ProcessStartInfo("/bin/bash", "-c " + command);
                break;

            case ConsoleType.None:
                return(null);

            default:
                throw new ArgumentException(nameof(console));
            }

            procStartInfo.RedirectStandardOutput = true;
            procStartInfo.UseShellExecute        = false;
            procStartInfo.CreateNoWindow         = true;

            Process proc = new Process();

            proc.StartInfo = procStartInfo;
            proc.Start();

            string result = proc.StandardOutput.ReadToEnd();

            // HACK: Only need it because my server doesn't handle NewLine too well
            result = result.Replace(Environment.NewLine, "\n");

            return(result);
        }
Esempio n. 24
0
        public FlexConsole(ConsoleType consoleType, MgaProject mgaProject = null)
        {
            switch (consoleType)
            {
            case ConsoleType.NONE:
                _info = _warning = _error = _out = new NullTextWriter();
                break;

            case ConsoleType.CONSOLE:
                _info = _warning = _error = Console.Error;
                _out  = Console.Out;
                break;

            case ConsoleType.GMECONSOLE:
                _gmeConsole = GMEConsole.CreateFromProject(mgaProject);
                _info       = _gmeConsole.Info;
                _warning    = _gmeConsole.Warning;
                _error      = _gmeConsole.Error;
                _out        = _gmeConsole.Out;
                break;
            }
        }
Esempio n. 25
0
        public static void WriteLine(ConsoleType consoleType, string message, bool noWordWrap = false)
        {
            // No word wrap -> output & return;
            if (noWordWrap)
            {
                InternalWrite(consoleType, message + "\n");
                return;
            }

            // Parse linebreaks for clear output
            var messages = message.Split(new[] { "\n", "~n~" }, StringSplitOptions.RemoveEmptyEntries);
            var messageStartColorCode = "";

            // Search for message starting color code. Used to add same color code to splitted lines
            if (messages.Any())
            {
                var messageColorCodes = ColorUtils.ParseColorCodesSimple(messages[0]);
                if (messageColorCodes.Any())
                {
                    messageStartColorCode = "~" + messageColorCodes[0] + "~";
                }
            }

            // Cut messages to fit in the console
            for (var i = 0; i < messages.Length; i++)
            {
                // wrap messages if they are too long for the console space
                var wrappedMessages = WordWrapMessage(messages[i]);
                for (var b = 0; b < wrappedMessages.Length; b++)
                {
                    var firstMessageOfSet = i == 0 && b == 0;
                    var lastMessageOfSet  = i == messages.Length - 1 && b == wrappedMessages.Length - 1;
                    InternalWrite(consoleType, messageStartColorCode + _prefix + wrappedMessages[b] + "\n", false, "",
                                  firstMessageOfSet,
                                  lastMessageOfSet);
                }
            }
        }
        public static void Log(string log, ConsoleType consoleType)
        {
            log += "\n";
            switch (consoleType)
            {
            case (ConsoleType.REPORT):
                consoleReport += log;
                break;

            case (ConsoleType.BATTLE):
                consoleBattle += log;
                break;

            case (ConsoleType.HISTORY):
                consoleHistory += log;
                break;

            case (ConsoleType.MISSION):
                consoleMission += log;
                break;
            }
            UpdateConsole();
        }
Esempio n. 27
0
    public static string ConsoleTypeToString(ConsoleType cType)
    {
        string s = "UNK";

        switch (cType)
        {
        case ConsoleType.CEX:
            s = "CEX";
            break;

        case ConsoleType.DEX:
            s = "DEX";
            break;

        case ConsoleType.TOOL:
            s = "TOOL";
            break;

        default:
            break;
        }

        return(s);
    }
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsoleMessage"/> class.
 /// </summary>
 /// <param name="type">Type.</param>
 /// <param name="text">Text.</param>
 /// <param name="args">Arguments.</param>
 public ConsoleMessage(ConsoleType type, string text, IList <JSHandle> args)
 {
     Type = type;
     Text = text;
     Args = args;
 }
Esempio n. 29
0
        /// <summary>
        ///     The internal write function.
        ///     Handles each write subfunction
        /// </summary>
        /// <param name="consoleType">ConsoleType</param>
        /// <param name="message">The message with color codes</param>
        /// <param name="centered">Should the text be centered?</param>
        /// <param name="suffix">Message suffix?</param>
        /// <param name="firstMessageOfSet">The first message of a bunch of splitted messages?</param>
        /// <param name="lastMessageOfSet">The last message of a bunch of splitted messages?</param>
        private static void InternalWrite(ConsoleType consoleType, string message, bool centered = false,
                                          string suffix = "", bool firstMessageOfSet = true, bool lastMessageOfSet = true)
        {
            // Message empty -> return;
            if (string.IsNullOrEmpty(message?.Replace("\n", "")))
            {
                return;
            }

            message = message.Replace("\r\n", "\n");

            var colorCodes = ColorUtils.ParseColorCodesSimple(message);

            // Format message output
            var writeMessage = string.Empty;

            // Save the color codes if the message starts with any
            // Used for mutiline control codes
            var firstMessageColorCodes = "";

            foreach (var colorCode in colorCodes)
            {
                if (message.StartsWith($"{firstMessageColorCodes}{colorCode}"))
                {
                    firstMessageColorCodes += colorCode;
                }
            }

            //ConsoleUtils.ParseColorCodesSimple(message);

            var wasControlCodeLine  = false;
            var messageHasLinebreak = false;

            var maxInnerLineLength = ConsoleSize.Width - LastHeaderLength - PrefixLength;

            // Prepare message.
            if (message.EndsWith("\n"))
            {
                messageHasLinebreak = true;
                message             = message.Substring(0, message.Length - "\n".Length);
            }

            message = message.Replace("\t", "  ");

            // Get consoleType properties & parse message colors
            var typeProperties = ConsoleUtils.GetConsoleTypeProperties(consoleType);

            #region Prepare Head and lines

            if (consoleType != ConsoleType.Empty)
            {
                var timestamp = $"~#FFFFFF~{DateTime.Now.ToString(CultureInfo.CurrentUICulture)}";

                // Timestamp didn't changed -> dark it up
                if (LastTimestamp != timestamp)
                {
                    CountSameTimestamp = -1;
                }

                LastTimestamp = timestamp;
                CountSameTimestamp++;
                var multiplier = (float)0.011 * CountSameTimestamp;
                timestamp = ColorUtils.DarkUpHexColors(timestamp, multiplier < 0.9 ? multiplier : (float)0.9);


                // Write log type information
                writeMessage =
                    $"{timestamp}~w~ │{typeProperties.TypeText(' ', " ")} ~;~~w~│ ";

                // Save header length for calculation
                LastHeaderLength   = ColorUtils.CleanUp(writeMessage).Replace("\t", "  ").Length;
                maxInnerLineLength = ConsoleSize.Width - LastHeaderLength - PrefixLength;

                // Trim ConsoleType.Line for fit in console window
                // Or Lines with other ConsoleType
                if (consoleType == ConsoleType.Line || message.StartsWith("~!--!~"))
                {
                    // Cut special line switch
                    if (message.StartsWith("~!--!~"))
                    {
                        message            = message.Substring("~!--!~".Length);
                        wasControlCodeLine = true;
                    }

                    if (LastHeaderLength < message.Length)
                    {
                        var colorCodeLength = message.Length - ColorUtils.CleanUp(message).Length;
                        var colorCode       = message.Substring(0, colorCodeLength);
                        message = colorCode + message.Substring(LastHeaderLength);
                    }
                }
            }

            #endregion //Prepare Head and lines

            // Get message color from type
            var consoleTypeTextColorCode = typeProperties.TextCode;


            // Filter all control codes from the typetextcode to use it as reset code
            var harmlessTypeTextCode = consoleTypeTextColorCode;
            foreach (ColorCode colorCode in Enum.GetValues(typeof(ColorCode)))
            {
                var colorCodeProperty = ColorUtils.GetColorCodeProperty(colorCode);
                if (colorCodeProperty.HasSpecialLogic)
                {
                    harmlessTypeTextCode = harmlessTypeTextCode.Replace(colorCodeProperty.Identifier, "");
                }
            }

            // Center text if it should full centered,
            // or if control key (~>-<~) given. But not if message is a control coded line
            if (centered || consoleTypeTextColorCode.Contains("~>-<~") && !wasControlCodeLine)
            {
                if (consoleTypeTextColorCode.Contains("~>-<~"))
                {
                    consoleTypeTextColorCode = consoleTypeTextColorCode.Replace("~>-<~", "");
                }

                message = harmlessTypeTextCode +
                          ConsoleUtils.AlignText(message, maxInnerLineLength, true);
            }

            // Message is line and was by consoleTypeTextColorCode given ->
            // Replace again or endless loop
            if (wasControlCodeLine)
            {
                consoleTypeTextColorCode = harmlessTypeTextCode;
            }

            // Append message
            message = $"{consoleTypeTextColorCode}{message}~|~";


            // React to some special control codes
            var printLineBottom = false;

            // Line Above
            if (firstMessageOfSet)
            {
                if (message.Contains(ColorUtils.GetColorCodeProperty(ColorCode.InsertLineAbove).Identifier))
                {
                    PrintLine("-", firstMessageColorCodes, consoleType);
                }
            }

            // Line Below
            if (lastMessageOfSet)
            {
                if (message.Contains(ColorUtils.GetColorCodeProperty(ColorCode.InsertLineBelow).Identifier))
                {
                    printLineBottom = true;
                }
            }

            // Append message to complete message
            writeMessage += message;

            var fillUpLength = ConsoleSize.Width -
                               ColorUtils.CleanUp(writeMessage + suffix).Replace("\n", "").Length;
            var fillUpString = "".PadRight(fillUpLength > 0 ? fillUpLength : 0);

            // Add suffixs and possible linebreak
            writeMessage += "~;~" + fillUpString + suffix;

            if (messageHasLinebreak)
            {
                writeMessage += "\n";
            }

            // Replace reset controlcode with message defaultColor + resetControl
            var resetIdentifer = ColorUtils.GetColorCodeProperty(ColorCode.ResetColor).Identifier;
            if (writeMessage.Contains(resetIdentifer))
            {
                writeMessage = writeMessage.Replace(resetIdentifer,
                                                    $"{resetIdentifer}{harmlessTypeTextCode}");
            }

            // Parse color and control codes
            FinalConsoleWrite(writeMessage);

            // Print, if control code was given, bottom line
            if (printLineBottom)
            {
                PrintLine("-", "", consoleType);
            }

            //ConsoleUtils.ResetColor();
        }
Esempio n. 30
0
 public static bool IsSnes(ConsoleType consoleType)
 {
     return((new ConsoleType[] { ConsoleType.SNES_EUR, ConsoleType.SNES_USA, ConsoleType.SuperFamicom }).Contains(consoleType));
 }
Esempio n. 31
0
        public FlexConsole(ConsoleType consoleType, MgaProject mgaProject = null) {

            switch (consoleType) {
                case ConsoleType.NONE:
                    _info = _warning = _error = _out = new NullTextWriter();
                    break;
                case ConsoleType.CONSOLE:
                    _info = _warning = _error = Console.Error;
                    _out = Console.Out;
                    break;
                case ConsoleType.GMECONSOLE:
                    _gmeConsole = GMEConsole.CreateFromProject(mgaProject);
                    _info = _gmeConsole.Info;
                    _warning = _gmeConsole.Warning;
                    _error = _gmeConsole.Error;
                    _out = _gmeConsole.Out;
                    break;
            }

        }
Esempio n. 32
0
 public static bool IsNes(ConsoleType consoleType)
 {
     return((new ConsoleType[] { ConsoleType.Famicom, ConsoleType.NES, ConsoleType.ShonenJump }).Contains(consoleType));
 }
Esempio n. 33
0
 public static bool HasPixelArt(ConsoleType consoleType)
 {
     return(consoleType == ConsoleType.NES || consoleType == ConsoleType.Famicom);
 }