Пример #1
0
        public void Write(char character)
        {
            if (ColorMappings.IsForegroundMapping(character))
            {
                _vga.ActiveForegroundColor = ColorMappings.GetForeground(character);
                return;
            }

            if (ColorMappings.IsBackgroundMapping(character))
            {
                _vga.ActiveBackgroundColor = ColorMappings.GetBackground(character);
                return;
            }

            if (character == '\uff40')
            {
                _vga.ActiveForegroundColor = _vga.DefaultForegroundColor;
                return;
            }

            if (character == '\ufe40')
            {
                _vga.ActiveBackgroundColor = _vga.DefaultBackgroundColor;
                return;
            }

            if (character == '\b')
            {
                MoveCursorBackwards();
                _vga.PutCharAt(' ', _vga.CursorX, _vga.CursorY);
            }
            else if (character == '\n')
            {
                _vga.CursorX = _vga.Margins.Left;
                _vga.CursorY++;

                if (_vga.CursorY >= _vga.TotalRows - _vga.Margins.Bottom)
                {
                    _vga.CursorY = (ushort)(_vga.TotalRows - _vga.Margins.Bottom - 1);
                    _vga.ScrollUp();
                }
            }
            else if (character == '\r')
            {
                _vga.CursorX = _vga.Margins.Left;
            }
            else
            {
                _vga.PutCharAt(character, _vga.CursorX, _vga.CursorY);
                MoveCursorForwards();
            }
        }
Пример #2
0
        private void ImportColorMappings()
        {
            var open = new OpenFileDialog();

            open.Filter                       = "Chromatics Palette Files|*.chromatics";
            open.Title                        = "Import Color Palette";
            open.AddExtension                 = true;
            open.AutoUpgradeEnabled           = true;
            open.CheckFileExists              = true;
            open.CheckPathExists              = true;
            open.DefaultExt                   = "chromatics";
            open.DereferenceLinks             = true;
            open.FileName                     = "mypalette";
            open.FilterIndex                  = 1;
            open.Multiselect                  = false;
            open.ReadOnlyChecked              = false;
            open.RestoreDirectory             = false;
            open.ShowHelp                     = false;
            open.ShowReadOnly                 = false;
            open.SupportMultiDottedExtensions = false;
            open.ValidateNames                = true;

            if (open.ShowDialog() == DialogResult.OK)
            {
                WriteConsole(ConsoleTypes.System, @"Importing Color Palette..");

                try
                {
                    using (var sr = new StreamReader(open.FileName))
                    {
                        var reader        = new XmlSerializer(ColorMappings.GetType());
                        var colorMappings = (FfxivColorMappings)reader.Deserialize(sr);
                        sr.Close();

                        ColorMappings = colorMappings;

                        WriteConsole(ConsoleTypes.System,
                                     "Success. Imported Color Palette from " + open.FileName + ".");
                        open.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    WriteConsole(ConsoleTypes.Error, @"Error importing Color Palette. Error: " + ex.Message);
                    open.Dispose();
                }
            }
        }
Пример #3
0
        private void LoadColorMappings()
        {
            WriteConsole(ConsoleTypes.System, @"Searching for mappings.chromatics..");
            var enviroment = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName;
            var path       = enviroment + @"/mappings.chromatics";

            if (File.Exists(path))
            {
                //Read Device Save
                WriteConsole(ConsoleTypes.System, @"Attempting to load mappings.chromatics..");
                using (var sr = new StreamReader(path))
                {
                    try
                    {
                        var reader        = new XmlSerializer(ColorMappings.GetType());
                        var colorMappings = (FfxivColorMappings)reader.Deserialize(sr);
                        sr.Close();

                        ColorMappings = colorMappings;

                        WriteConsole(ConsoleTypes.System, @"mappings.chromatics loaded.");
                    }
                    catch (Exception ex)
                    {
                        WriteConsole(ConsoleTypes.Error, @"Error loading mappings.chromatics. Error: " + ex.Message);
                    }
                }
            }
            else
            {
                //Create Device Save
                WriteConsole(ConsoleTypes.System, @"mappings.chromatics not found. Creating one..");
                try
                {
                    using (var sw = new StreamWriter(path))
                    {
                        var x = new XmlSerializer(ColorMappings.GetType());
                        x.Serialize(sw, ColorMappings);
                        sw.WriteLine();
                        sw.Close();
                    }
                }
                catch (Exception ex)
                {
                    WriteConsole(ConsoleTypes.Error, @"Error creating mappings.chromatics. Error: " + ex.Message);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Writes text to the console after changing chat colors to
        /// console colors.
        /// </summary>
        public static void WriteLine(string text)
        {
            var parts = text.Split('§');

            Console.ResetColor();
            foreach (var part in parts)
            {
                if (string.IsNullOrEmpty(part))
                {
                    continue;
                }
                if (ColorMappings.ContainsKey(part[0]))
                {
                    Console.ForegroundColor = ColorMappings[part[0]];
                }
                Console.Write(part.Substring(1));
            }
            Console.WriteLine();
            Console.ResetColor();
        }