Example #1
0
        public void UpdateTitle()
        {
            _runInformations = RunInformations.GetOrNewInstance();
            _consoleSettings = ConsoleSettings.GetOrNewInstance();
            _formatUtils     = FormatUtils.GetOrNewInstance();

            string title = null;

            switch (_runInformations.runStatus)
            {
            case RunInformations.RunStatus.Idle:
            {
                title = _formatUtils.FormatTitle(_consoleSettings.idleTitleFormat);

                break;
            }

            case RunInformations.RunStatus.Running:
            {
                title = _formatUtils.FormatTitle(_consoleSettings.runningTitleFormat);

                break;
            }

            case RunInformations.RunStatus.Finished:
            {
                title = _formatUtils.FormatTitle(_consoleSettings.finishedTitleFormat);

                break;
            }
            }

            Console.Title = title;
        }
Example #2
0
        public void InitConsoleSettings()
        {
            this._logger.LogInformation($"Starting {nameof(InitConsoleSettings)}");

            if (_consoleSettings == null)
            {
                if (!_fileSystem.File.Exists(APP_CONFIG_PATH))
                {
                    throw new ApplicationException($"Application config not found at {APP_CONFIG_PATH}!");
                }

                var configBuilder = new ConfigurationBuilder()
                                    .SetBasePath(Directory.GetCurrentDirectory())
                                    .AddJsonFile(APP_CONFIG_PATH, false)
                                    .Build();
                _consoleSettings = configBuilder.Get <ConsoleSettings>();
            }

            Validate();

            ReadSimulationConfigurationFiles();

            this._logger.LogInformation($"Finished {nameof(InitConsoleSettings)}");

            StartDemo();
        }
Example #3
0
        public MilkyManager()
        {
            KeyboardListener = KeyboardListener.GetOrNewInstance();

            ConsoleLoops    = ConsoleLoops.GetOrNewInstance();
            LoopsManager    = LoopsManager.GetOrNewInstance();
            StatisticsLoops = StatisticsLoops.GetOrNewInstance();

            OutputSettings = OutputSettings.GetOrNewInstance();

            ProgramInformations = ProgramInformations.GetOrNewInstance();
            ProgramManager      = ProgramManager.GetOrNewInstance();

            RunInformations = RunInformations.GetOrNewInstance();
            RunLists        = RunLists.GetOrNewInstance();
            RunManager      = RunManager.GetOrNewInstance();

            ConsoleSettings = ConsoleSettings.GetOrNewInstance();
            RunSettings     = RunSettings.GetOrNewInstance();

            CustomStatistics = CustomStatistics.GetOrNewInstance();
            RunStatistics    = RunStatistics.GetOrNewInstance();

            ConsoleUtils  = ConsoleUtils.GetOrNewInstance();
            DateTimeUtils = DateTimeUtils.GetOrNewInstance();
            FileUtils     = FileUtils.GetOrNewInstance();
            FormatUtils   = FormatUtils.GetOrNewInstance();
            HashUtils     = HashUtils.GetOrNewInstance();
            ListUtils     = ListUtils.GetOrNewInstance();
            RequestUtils  = RequestUtils.GetOrNewInstance();
            StringUtils   = StringUtils.GetOrNewInstance();
            UserUtils     = UserUtils.GetOrNewInstance();
        }
            private void Update(T data)
            {
                lock (LockContext)
                {
                    var progress     = Converter(data);
                    var restorePoint = new ConsoleSettings();
                    Console.CursorVisible = false;
                    Console.SetCursorPosition(0, LineNumber);
                    var           bfWidth = Console.BufferWidth;
                    StringBuilder sb      = new StringBuilder(bfWidth);

                    if (!String.IsNullOrEmpty(Name))
                    {
                        sb.Insert(0, $"[ {Name} ] ");
                    }

                    var progressStr     = $" {progress.ToString("0.##", CultureInfo.CurrentCulture)}%";
                    var loadingBarWidth = bfWidth
                                          - sb.Length
                                          - progressStr.Length;

                    var cells = Convert.ToInt32(
                        Math.Ceiling(
                            loadingBarWidth * (progress / 100)));
                    sb.Insert(0, "=", cells);
                    sb.Append(progressStr);

                    Console.WriteLine(sb.ToString());

                    // Restore defaults.
                    restorePoint.Restore(true);
                }
            }
Example #5
0
        static void Main(string[] args)
        {
            Console.Clear();
            Console.WriteLine("Welcome please type a command below and press enter to begin.");
            Console.WriteLine("compare or move or exit");
            ConsoleSettings.EnableQuickEditMode();
            var input = Console.ReadLine();

            Enum.TryParse(input, out command usercommand);

            switch (usercommand)
            {
            case command.compare:
            {
                Compare();
                break;
            }

            case command.move:
            {
                Move();
                break;
            }

            case command.exit:
            {
                Exit();
                break;
            }
            }
        }
Example #6
0
        protected void SetConsole(ConsoleSettings settings)
        {
            switch (settings)
            {
            case ConsoleSettings.Text:
                Console.BackgroundColor = ViewSettings.ConsoleDefaultBackgroundColor;
                Console.ForegroundColor = ViewSettings.ConsoleDefaultForegroundColor;
                return;

            case ConsoleSettings.WaterNotHit:
                Console.BackgroundColor = ViewSettings.NotHitBackgroundColor;
                Console.ForegroundColor = ViewSettings.WaterNotHitForegroundColor;
                return;

            case ConsoleSettings.WaterHit:
                Console.BackgroundColor = ViewSettings.HitBackgroundColor;
                Console.ForegroundColor = ViewSettings.WaterHitForegroundColor;
                return;

            case ConsoleSettings.ShipNotHit:
                Console.BackgroundColor = ViewSettings.NotHitBackgroundColor;
                Console.ForegroundColor = ViewSettings.ShipNotHitForegroundColor;
                return;

            case ConsoleSettings.ShipHit:
                Console.BackgroundColor = ViewSettings.HitBackgroundColor;
                Console.ForegroundColor = ViewSettings.ShipHitForegroundColor;
                return;

            case ConsoleSettings.EmptyMatrix:
                Console.BackgroundColor = ViewSettings.ConsoleDefaultBorderBackgroundColor;
                Console.ForegroundColor = ViewSettings.ConsoleDefaultBorderColor;
                return;
            }
        }
Example #7
0
        private static async Task Main()
        {
            Console.Title = "Наигламурнейший оптимизатор маршрутов по нейтронкам от TrickyBestia";
            Console.WriteLine("Вас приветствует наигламурнейший оптимизатор маршрутов по нейтронкам от TrickyBestia.");
            Console.Write("Введите начальную систему: ");
            string sourceSystem = Console.ReadLine();

            Console.Write("Введите конечную систему: ");
            string destinationSystem = Console.ReadLine();

            Console.Write("Введите дальность вашего прыжка: ");
            int range = int.Parse(Console.ReadLine());

            Progress = 0;

            Response optimalRoute = await Plotter.GetOptimalRoute(sourceSystem, destinationSystem, range, new Progress <int>(progress => Progress = progress));

            lock (_writeLock)
            {
                Console.WriteLine("Кратчайший маршрут:");
                string          optimalRouteUrl = $"https://spansh.co.uk/plotter/results/{optimalRoute.Result.Job.ToString().ToUpper()}{new Request(range, optimalRoute.Result.Efficiency, sourceSystem, destinationSystem).ToQuery()}";
                ConsoleSettings settings        = SaveSetting(false);
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(optimalRouteUrl);
                LoadSettings(settings);
                Console.ReadLine();
            }
        }
Example #8
0
        public void SetDefaults(ConsoleSettings settings)
        {
            InputPrefix      = settings.InputPrefix;
            InputPrefixColor = settings.InputPrefixColor;
            NumPositionsToMoveWhenOutOfScreen      = settings.NumPositionsToMoveWhenOutOfScreen;
            RepeatingInput.RepeatingInputCooldown  = settings.TimeToCooldownRepeatingInput;
            RepeatingInput.TimeUntilRepeatingInput = settings.TimeToTriggerRepeatingInput;
            Selection.Color = settings.SelectionColor;

            Caret.SetSettings(settings);
        }
        public void OnGet()
        {
            // Bind the content of default configuration file "appsettings.json" to an instance of DatabaseSettings
            ConsoleSettings console = _configuration.GetSection("xbox").Get <ConsoleSettings>();

            Owner      = console.Owner;
            Developper = console.Developper;
            Product    = console.Product;
            Storage    = console.Storage;
            Display    = console.Display;
        }
Example #10
0
        public static void Main()
        {
            ConsoleSettings.CustomizeConsole();

            Wall  wall  = new Wall(60, 20);
            Snake snake = new Snake(wall);

            Engine engine = new Engine(wall, snake);

            engine.Run();
        }
Example #11
0
 public static void LoadSettings(ConsoleSettings settings)
 {
     if (settings.CursorLeft is not null)
     {
         Console.CursorLeft = settings.CursorLeft.Value;
     }
     if (settings.CursorTop is not null)
     {
         Console.CursorTop = settings.CursorTop.Value;
     }
     Console.ForegroundColor = settings.ForegroundColor;
     Console.BackgroundColor = settings.BackgroundColor;
 }
Example #12
0
        public ConsoleNotifier(ConsoleSettings settings, Action <string> writeLine)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (writeLine == null)
            {
                throw new ArgumentNullException(nameof(writeLine));
            }

            this.settings  = settings;
            this.writeLine = writeLine;
        }
        public ConsoleContext()
        {
            directoryStack = new Stack <IDirectory>();
            generalCommands.Add("exit", typeof(ExitCommand));
            generalCommands.Add("help", typeof(HelpCommand));
            generalCommands.Add("up", typeof(BackCommand));
            generalCommands.Add("list", typeof(ListCommand));
            generalCommands.Add("credits", typeof(CreditsCommand));
            PushDirectory(new RootDirectory());

            ConsoleSettings settings = new ConsoleSettings();

            ConsoleSettings = settings;
        }
        public override void SetUp()
        {
            base.SetUp();

            fakeWriteLine = s =>
            {
                lastWrittenLine = s;
            };

            fakeSettings = new ConsoleSettings
            {
                Threshold = NotificationLevel.Warning
            };
        }
Example #15
0
        public void Dispose()
        {
            ConsoleSettings.SetForeGroundColour(ConsoleColor.Green, false);
            if (GenerateSourceMap)
            {
                _output.TrivialWriteLine(string.Format(ArtifactsFactory.SrcMapRefLine, ArtifactsFactory.ConsoleJs));
            }
            ConsoleSettings.SetForeGroundColour(ConsoleColor.Cyan, false);
            if (WriteWaterMark)
            {
                _output.TrivialWriteLine(WaterMark);
            }
            ConsoleSettings.SetForeGroundColour();

            _output.Dispose();
        }
Example #16
0
        private void Awake()
        {
            DeveloperConsole.OnConsoleOpened    += OnConsoleOpened;
            DeveloperConsole.OnConsoleClosed    += OnConsoleClosed;
            DeveloperConsole.OnDirectoryChanged += OnDirectoryChanged;

            // Check if there is currently an EventSystem active.
            // If not, the UI will not work, and we must instantiate one
            if (EventSystem.current == null)
            {
                var eventSystemInstance = Instantiate(EventSystemPrefab);
                EventSystem.current = eventSystemInstance.GetComponent <EventSystem>();
            }

            mViewSettings                  = ConsoleSettings.GetViewSettings();
            Overlay.alpha                  = ConsoleSettings.ConsoleOverlayAlpha;
            InputField.fontAsset           = mViewSettings.Font;
            InputField.textComponent.color = mViewSettings.FontColor;
            InputField.pointSize           = mViewSettings.FontSize;

            // Configure input field prefix visuals
            var mPrefixRightMarginSizeAdjustment = InputFieldPrefix.TextComponent.margin.z / InputFieldPrefix.TextComponent.fontSize;

            InputFieldPrefix.Configure(mViewSettings);
            InputFieldPrefix.TextComponent.margin = new Vector4(0, 0, mViewSettings.FontSize * mPrefixRightMarginSizeAdjustment, 0);

            // Get format for the console prefix
            mPrefixFormat = $"<color=#{ColorUtility.ToHtmlStringRGB(ConsoleSettings.ConsoleFilePathColor)}>{{0}}</color>";
            if (ConsoleSettings.ConsolePrefixCharacter != ' ')
            {
                mPrefixFormat += $" <color=#{ColorUtility.ToHtmlStringRGB(ConsoleSettings.ConsoleFontColor)}>{ConsoleSettings.ConsolePrefixCharacter}</color>";
            }

            InputField.onSubmit.AddListener(OnInputSubmitted);
            InputField.onValueChanged.AddListener(OnInputValueChanged);

            Scroll.onBeginDrag += _ => mCachedCaretPosition = InputField.caretPosition;
            Scroll.onEndDrag   += _ =>
            {
                InputField.ActivateInputField();
                InputField.caretPosition = mCachedCaretPosition;
            };

            OnConsoleClosed();
        }
Example #17
0
        public LightingConsole(
            string ip,
            ConsoleSettings settings,
            bool disablePacketEvents = false,
            SK[] sks = null,
            ConnectionHandler connectionHandler             = null,
            ScreenManager screenManager                     = null,
            TastenManager tastenManager                     = null,
            Dictionary <MlPal.Flag, List <MlPal> > paletten = null)
        {
            Settings = settings;
            SKMSteckbrief steckbrief = settings.Steckbrief;

            Stromkreise = sks ?? new SK[Settings.SkSize];
            SKSize      = Settings.SkSize;

            _disablePacketEvents = disablePacketEvents;

            Connection          = connectionHandler ?? new ConnectionHandler(ip, steckbrief, Settings.SkmType);
            Connection.Errored += Connection_Errored;
            if (!_disablePacketEvents)
            {
                Connection.PacketReceived += OnPacketReceived;
            }

            Bedienstelle = Settings.Bedienstelle;
            Logger       = Settings.Logger;

            ScreenManager = new ScreenManager(this);

            TastenManager = new TastenManager();

            Paletten = new Dictionary <MlPal.Flag, List <MlPal> >
            {
                { MlPal.Flag.I, new List <MlPal>() },
                { MlPal.Flag.F, new List <MlPal>() },
                { MlPal.Flag.C, new List <MlPal>() },
                { MlPal.Flag.B, new List <MlPal>() },
                { MlPal.Flag.SKG, new List <MlPal>() },
                { MlPal.Flag.BLK, new List <MlPal>() },
                { MlPal.Flag.DYN, new List <MlPal>() },
                { MlPal.Flag.CUR_SEL, new List <MlPal>() }
            };
        }
Example #18
0
        public static void Edit()
        {
            ConsoleSettings settings = LoadInstance();

            if (settings == null)
            {
                settings = CreateInstance <ConsoleSettings>();
                string path = Path.Combine(Application.dataPath, SETTINGS_PATH);

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                string path2 = Path.Combine("Assets", SETTINGS_PATH, SETTINGS_NAME + ".asset");
                AssetDatabase.CreateAsset(settings, path2);
            }
            Selection.activeObject = settings;
        }
 static void Main(string[] args)
 {
     try
     {
         var settings = new ConsoleSettings(new[]
         {
             new ConsoleSettings.SettingFile(typeof(XrmSetting)),
         });
         if (!settings.ConsoleArgs(args))
         {
             var xrmSetting = settings.Resolve <XrmSetting>();
             var controller = new LogController(new ConsoleUserInterface(false));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.XrmDisplayString());
     }
     Console.WriteLine("Press Any Key To Close");
     Console.ReadKey();
 }
        // Finds a valid ConsoleSettings instance, or, if none exist, creates one and returns it.
        private ConsoleSettings GetOrCreateSettings()
        {
            var settings = ConsoleSettings.FindSettings();

            if (settings == null)
            {
                // No settings object was found in project, so let's create one in a specified path
                settings = ConsoleSettings.CreateSettings();

                // Ensure parent directory of asset exists
                if (!Directory.Exists(kSettingsContainerPath))
                {
                    Directory.CreateDirectory(kSettingsContainerPath);
                }

                AssetDatabase.CreateAsset(settings, kSettingsPath);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }

            return(settings);
        }
Example #21
0
        protected virtual void RegisterScriptedCommands(object sender, EventArgs e)
        {
            try
            {
                ConsoleSettings section = ConfigurationManager.GetSection("Saga.Manager.ConsoleSettings") as ConsoleSettings;
                if (section != null)
                {
                    foreach (FactoryFileElement Element in section.Commands)
                    {
                        RegisterExternal(Element.Path);
                    }

                    foreach (FactoryFileElement Element in section.GmCommands)
                    {
                        RegisterExternalGmCommand(Element.Path);
                    }
                }
            }
            catch (Exception x)
            {
                HostContext.UnhandeldExceptionList.Add(x);
            }
        }
            private void Update(T data)
            {
                lock (LockContext)
                {
                    var message      = Converter(data);
                    var restorePoint = new ConsoleSettings();
                    Console.CursorVisible = false;
                    Console.SetCursorPosition(0, LineNumber);
                    var prefix = String.Empty;

                    if (!String.IsNullOrEmpty(Name))
                    {
                        prefix += $"[ {Name} ] ";
                    }

                    prefix += $"{message}";

                    Console.WriteLine(
                        prefix.PadRight(Console.BufferWidth));

                    // Restore defaults.
                    restorePoint.Restore(true);
                }
            }
Example #23
0
        public override void    OnEnable(NGConsoleWindow editor, int id)
        {
            base.OnEnable(editor, id);

            this.requiredServices = new string[]
            {
                NGTools.NGAssemblyInfo.Name,
                NGTools.NGAssemblyInfo.Version,
                NGTools.NGGameConsole.NGAssemblyInfo.Name,
                NGTools.NGGameConsole.NGAssemblyInfo.Version
            };

            for (int i = 0; i < this.rows.Count; i++)
            {
                this.rows[i].Init(this.console, this.rows[i].log);
            }

            foreach (StreamLog stream in this.streams)
            {
                stream.Init(this.console, this);
                stream.rowsDrawer.SetRowGetter(this);
                stream.FilterAltered += this.console.SaveModules;
                stream.OptionAltered += this.console.SaveModules;
                stream.Cleared       += this.console.SaveModules;

                for (int i = 0; i < this.rows.Count; i++)
                {
                    stream.AddLog(i, this.rows[i]);
                }

                this.console.CheckNewLogConsume -= stream.ConsumeLog;
                this.console.PropagateNewLog    -= stream.AddLog;
            }

            // Populate with default commands if missing.
            ConsoleSettings settings = HQ.Settings.Get <ConsoleSettings>();

            settings.inputsManager.AddCommand("Navigation", ConsoleConstants.SwitchNextStreamCommand, KeyCode.Tab, true);
            settings.inputsManager.AddCommand("Navigation", ConsoleConstants.SwitchPreviousStreamCommand, KeyCode.Tab, true, true);

            this.parser           = new RemoteCommandParser();
            this.parser.CallExec += this.Exec;
            this.pendingCommands  = new List <CommandRequest>();
            this.command          = string.Empty;

            this.tcpClientProviders = Utility.CreateNGTInstancesOf <AbstractTcpClient>();

            this.tcpClientProviderNames = new string[this.tcpClientProviders.Length];

            for (int i = 0; i < this.tcpClientProviders.Length; i++)
            {
                this.tcpClientProviderNames[i] = this.tcpClientProviders[i].GetType().Name;
            }

            if (this.selectedTcpClientProvider > this.tcpClientProviders.Length - 1)
            {
                this.selectedTcpClientProvider = this.tcpClientProviders.Length - 1;
            }

            ConnectionsManager.Executer.HandlePacket(GameConsolePacketId.Logger_ServerSendLog, this.OnLogReceived);
            ConnectionsManager.NewServer    += this.RepaintOnServerUpdated;
            ConnectionsManager.UpdateServer += this.RepaintOnServerUpdated;
            ConnectionsManager.KillServer   += this.RepaintOnServerUpdated;

            if (this.perWindowVars == null)
            {
                this.perWindowVars = new PerWindowVars <Vars>();
            }
        }
Example #24
0
 public void Error(string msg, bool keyInfo)
 {
     ConsoleSettings.SetForeGroundColour(Console.ConsoleColor.Red);
     SysConsole.WriteLine("{0}{1}", Prompt(keyInfo), msg);
     ConsoleSettings.SetForeGroundColour();
 }
 public ConsoleSettingsViewModel()
 {
     ConsoleSettings = App.ModelManager.Get <UserSettings>().ConsoleSettings;
 }
Example #26
0
        private static void Main()
        {
            ConsoleSettings.PrepareConsole();
            KeyboardInterface keyboard = new KeyboardInterface();

            Opponent enemy = new Opponent(new MatrixCoords(3, 3), new char[, ] {
                { '@' }
            }, null);

            ConsoleRenderer renderer = new ConsoleRenderer(ConsoleSettings.ConsoleHeight, ConsoleSettings.ConsoleWidth);

            IList <WorldObject> map = MapParser.ParseMap("../../WorldMaps/map.txt");

            GameEngine.GameEngine gameEngine = new GameEngine.GameEngine(renderer, keyboard);

            int heroChosen = 0;

            Console.WriteLine("Please select your Hero: \nPress 1 for  Mage\nPress 2 for  Thief\nPress 3 for  Warrior");

            // validates hero choice and let's player choose correctly
            do
            {
                try
                {
                    heroChosen = int.Parse(Console.ReadLine());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("Please choose 1, 2 or 3");
                }
            } while (!true || heroChosen < 1 || heroChosen > 3);

            Console.Clear();

            // TODO implement interface for the choice of type of character
            MainCharacter hero = HeroChoice(heroChosen);

            hero.AddWeapon(new Knife("Steel knife")
            {
                MinDmg = 20, MaxDmg = 30
            });
            //hero.AddWeapon(new Knife("mnogo qk knife") { MaxDmg = 30, MinDmg = 20 });
            gameEngine.AddObject(hero);
            gameEngine.AddObject(enemy);
            Opponent newOpponent = new Opponent(new MatrixCoords(2, 35), new char[, ] {
                { '@' }
            }, new BattleAxe("Battle Axe"));
            Opponent newOpponent2 = new Opponent(new MatrixCoords(7, 30), new char[, ] {
                { '@' }
            }, new Knife("Steel knife"));
            Opponent newOpponent3 = new Opponent(new MatrixCoords(10, 10), new char[, ] {
                { '@' }
            }, new BattleAxe("Battle Axe"));
            Opponent newOpponent4 = new Opponent(new MatrixCoords(15, 15), new char[, ] {
                { '@' }
            }, new BattleAxe("Battle Axe"));

            gameEngine.AddObject(newOpponent);
            gameEngine.AddObject(newOpponent2);
            gameEngine.AddObject(newOpponent3);
            gameEngine.AddObject(newOpponent4);
            foreach (var item in map)
            {
                gameEngine.AddObject(item);
            }

            keyboard.OnDownPressed   += (sender, eventInfo) => { hero.Move(Direction.Down); };
            keyboard.OnLeftPressed   += (sender, eventInfo) => { hero.Move(Direction.Left); };
            keyboard.OnRightPressed  += (sender, eventInfo) => { hero.Move(Direction.Right); };
            keyboard.OnUpPressed     += (sender, eventInfo) => { hero.Move(Direction.Top); };
            keyboard.onPotionPressed += (sencer, eventInfo) => { hero.Health += 5; };

            gameEngine.Run();
        }
        /// <summary>
        ///     Initializes the console window.
        /// </summary>
        /// <param name="consoleSettings">The console settings.</param>
        private void InitializeWindow(ConsoleSettings.ConsoleSettings consoleSettings)
        {
            SizeChanged += consoleWindow_SizeChanged;

            Title = consoleSettings.ConsoleTitle;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            Height = consoleSettings.DefaultConsoleHeight;
            Width = consoleSettings.DefaultConsoleWidth;

            _defaultConsoleHeight = consoleSettings.DefaultConsoleHeight;
            _defaultConsoleWidth = consoleSettings.DefaultConsoleWidth;
            _maxConsoleHeight = consoleSettings.MaxConsoleHeight;
            _maxConsoleWidth = consoleSettings.MaxConsoleWidth;
            _minConsoleHeight = consoleSettings.MinConsoleHeight;
            _minConsoleWidth = consoleSettings.MinConsoleWidth;

            var grdMain = new Grid();
            grdMain.Name = "grdMain";
            Content = grdMain;

            // Setup the grid layout
            var cd = new ColumnDefinition();
            cd.Width = new GridLength(100, GridUnitType.Star);
            grdMain.ColumnDefinitions.Add(cd);

            var rd1 = new RowDefinition();
            rd1.Height = new GridLength(100, GridUnitType.Star);
            grdMain.RowDefinitions.Add(rd1);
            var rd2 = new RowDefinition();
            rd2.Height = new GridLength(0, GridUnitType.Auto);
            grdMain.RowDefinitions.Add(rd2);

            _rtbMessageArea = new RichTextBox();
            Grid.SetRow(_rtbMessageArea, 0);
            grdMain.Children.Add(_rtbMessageArea);

            _txtCommandPrompt = new TextBox();
            Grid.SetRow(_txtCommandPrompt, 1);
            grdMain.Children.Add(_txtCommandPrompt);

            // *Box settings
            _rtbMessageArea.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            _rtbMessageArea.IsReadOnly = true;
            _txtCommandPrompt.TextWrapping = TextWrapping.Wrap;
            _txtCommandPrompt.AcceptsReturn = false;

            // Command prompt key events
            _txtCommandPrompt.KeyDown += txtCommandPrompt_KeyDown;
            _txtCommandPrompt.PreviewKeyDown += txtCommandPrompt_PreviewKeyDown;
            _txtCommandPrompt.PreviewKeyUp += txtCommandPrompt_PreviewKeyUp;
            _txtCommandPrompt.KeyUp += txtCommandPrompt_KeyUp;

            InitializeConsole(consoleSettings);
        }
        /// <summary>
        ///     Initializes the console.
        /// </summary>
        /// <param name="consoleSettings">The console settings.</param>
        private void InitializeConsole(ConsoleSettings.ConsoleSettings consoleSettings)
        {
            _allowEmptyCommand = consoleSettings.AllowEmptyCommand;
            _defaultFontSize = consoleSettings.DefaultFontSize;
            _defaultPrompt = consoleSettings.Prompt;
            _delimeters = consoleSettings.Delimiters;
            _enableCommandHistory = consoleSettings.EnableCommandHistory;
            _manualCommandHistory = consoleSettings.ManualCommandHistory;
            _maxFontSize = consoleSettings.MaxFontSize;
            _minFontSize = consoleSettings.MinFontSize;
            _prompt = consoleSettings.Prompt;
            _useInternalCommandParsing = consoleSettings.UseInternalCommandParsing;
            _welcomeMessage = consoleSettings.WelcomeMessage;

            _txtCommandPrompt.Text = consoleSettings.Prompt;
            _txtCommandPrompt.CaretIndex = _txtCommandPrompt.Text.Length;

            _rtbMessageArea.Document = new FlowDocument();

            SetTheme();

            var paragraph = new Paragraph();
            paragraph.Margin = new Thickness(0);
            paragraph.TextAlignment = TextAlignment.Center;
            paragraph.Inlines.Add(new Run(_welcomeMessage)
            {
                Foreground = _styleThemeManager.WelcomeMessageColor
            });

            WriteLineToConsole(paragraph);

            _txtCommandPrompt.Focus();
        }
 /// <summary>
 ///     Resets the console window and all elements to default settings.
 /// </summary>
 /// <param name="consoleSettings">The console settings object.</param>
 public void ResetConsole(ConsoleSettings.ConsoleSettings consoleSettings)
 {
     InitializeConsole(consoleSettings);
     ResetConsoleSize();
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="ConsoleWindow" /> class.
 /// </summary>
 /// <param name="consoleSettings">The console settings.</param>
 public ConsoleWindow(ConsoleSettings.ConsoleSettings consoleSettings)
 {
     _styleThemeManager = new StyleThemeManager(consoleSettings.StyleThemeIndex,
         consoleSettings.EnableLoadStyleThemes);
     InitializeWindow(consoleSettings);
 }
 /// <summary>
 /// Serializes the specified settings back into an INI file.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <returns></returns>
 public String Serialize(ConsoleSettings settings)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Deserializes the specified text into a <see cref="ConsoleSettings" /> object.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <returns></returns>
        public ConsoleSettings Deserialize(String text)
        {
            var stopwatch = Stopwatch.StartNew();

            try
            {
                Logger.Debug("Attempting to deserialize a console settings file");

                var settings = new ConsoleSettings();
                var ini      = Serializer.Deserialize(text);

                settings.ExecutionInfo = new ExecutionInfo()
                {
                    Executable       = ini["exe info"]["exe"].Value,
                    Path             = ini["exe info"]["path"].Value,
                    UseRomPath       = ini["exe info"]["path"].ToBoolean(),
                    IsPcGame         = ini["exe info"]["pcgame"].ToBoolean(),
                    Parameters       = ini["exe info"]["parameters"].Value,
                    RomExtension     = ini["exe info"]["romextension"].Value,
                    RomPath          = ini["exe info"]["rompath"].Value,
                    SearchSubFolders = ini["exe info"]["searchsubfolders"].ToBoolean(),
                    UseHyperLaunch   = ini["exe info"]["hyperlaunch"].ToBoolean(),
                    WindowState      = ini["exe info"]["winstate"].ToEnum <WindowState>()
                };

                settings.Filters = new Filters();

                if (ini["filters"]?["parents_only"] != null)
                {
                    settings.Filters.ParentsOnly = ini["filters"]["parents_only"].ToBoolean();
                }

                if (ini["filters"]?["themes_only"] != null)
                {
                    settings.Filters.ThemesOnly = ini["filters"]["themes_only"].ToBoolean();
                }

                if (ini["filters"]?["wheels_only"] != null)
                {
                    settings.Filters.WheelsOnly = ini["filters"]["wheels_only"].ToBoolean();
                }


                settings.GameText = new GameText()
                {
                    Active           = ini["Game Text"]["game_text_active"].ToBoolean(),
                    ShowDescription  = ini["Game Text"]["show_description"].ToBoolean(),
                    ShowManufacturer = ini["Game Text"]["show_manf"].ToBoolean(),
                    ShowYear         = ini["Game Text"]["show_year"].ToBoolean(),
                    StrokeColor      = ini["Game Text"]["stroke_color"].Value,
                    Text1FontSize    = ini["Game Text"]["text1_textsize"].ToInt32(),
                    Text1StrokeSize  = ini["Game Text"]["text1_strokesize"].ToInt32(),
                    Text1X           = ini["Game Text"]["text1_x"].ToInt32(),
                    Text1Y           = ini["Game Text"]["text1_y"].ToInt32(),
                    Text2FontSize    = ini["Game Text"]["text2_textsize"].ToInt32(),
                    Text2StrokeSize  = ini["Game Text"]["text2_strokesize"].ToInt32(),
                    Text2X           = ini["Game Text"]["text2_x"].ToInt32(),
                    Text2Y           = ini["Game Text"]["text2_y"].ToInt32(),
                    TextColor1       = ini["Game Text"]["text_color1"].Value,
                    TextColor2       = ini["Game Text"]["text_color2"].Value,
                    TextFont         = ini["Game Text"]["text_font"].Value,
                };

                settings.Navigation = new Navigation()
                {
                    GameJump        = ini["navigation"]["game_jump"].ToInt32(),
                    UseIndexes      = ini["navigation"]["use_indexes"].ToBoolean(),
                    JumpTimer       = ini["navigation"]["jump_timer"].ToInt32(),
                    RemoveInfoWheel = ini["navigation"]["remove_info_wheel"].ToBoolean(),
                    RemoveInfoText  = ini["navigation"]["remove_info_text"].ToBoolean(),
                    UseLastGame     = ini["navigation"]["use_last_game"].ToBoolean(),
                    LastGame        = ini["navigation"]["last_game"].Value,
                    RandomGame      = ini["navigation"]["random_game"].ToBoolean(),
                };

                settings.Pointer = new Pointer()
                {
                    IsAnimated = ini["pointer"]["animated"].ToBoolean(),
                    X          = ini["pointer"]["x"].ToInt32(),
                    Y          = ini["pointer"]["y"].ToInt32(),
                };

                settings.Sounds = new Sounds()
                {
                    GameSounds = ini["sounds"]["game_sounds"].ToBoolean(),
                    WheelClick = ini["sounds"]["wheel_click"].ToBoolean(),
                };


                settings.SpecialArtA = new SpecialArt()
                {
                    IsActive       = ini["Special Art A"]["active"].ToBoolean(),
                    IsDefault      = ini["Special Art A"]["default"].ToBoolean(),
                    AnimationType  = ini["Special Art A"]["type"].ToEnum <AnimationType>(),
                    Delay          = ini["Special Art A"]["delay"].ToInt32(),
                    In             = ini["Special Art A"]["in"].ToDecimal(),
                    Length         = ini["Special Art A"]["length"].ToDecimal(),
                    Out            = ini["Special Art A"]["out"].ToDecimal(),
                    Start          = ini["Special Art A"]["start"].ToEnum <StartLocation>(),
                    X              = ini["Special Art A"]["x"].ToInt32(),
                    Y              = ini["Special Art A"]["y"].ToInt32(),
                    SpecialArtType = SpecialArtType.A,
                };

                settings.SpecialArtB = new SpecialArt()
                {
                    IsActive       = ini["Special Art B"]["active"].ToBoolean(),
                    IsDefault      = ini["Special Art B"]["default"].ToBoolean(),
                    AnimationType  = ini["Special Art B"]["type"].ToEnum <AnimationType>(),
                    Delay          = ini["Special Art B"]["delay"].ToInt32(),
                    In             = ini["Special Art B"]["in"].ToDecimal(),
                    Length         = ini["Special Art B"]["length"].ToDecimal(),
                    Out            = ini["Special Art B"]["out"].ToDecimal(),
                    Start          = ini["Special Art B"]["start"].ToEnum <StartLocation>(),
                    X              = ini["Special Art B"]["x"].ToInt32(),
                    Y              = ini["Special Art B"]["y"].ToInt32(),
                    SpecialArtType = SpecialArtType.B,
                };

                settings.SpecialArtC = new SpecialArt()
                {
                    IsActive       = ini["Special Art C"]["active"].ToBoolean(),
                    IsDefault      = false,
                    AnimationType  = ini["Special Art C"]["type"].ToEnum <AnimationType>(),
                    Delay          = ini["Special Art C"]["delay"].ToInt32(),
                    In             = ini["Special Art C"]["in"].ToDecimal(),
                    Length         = ini["Special Art C"]["length"].ToDecimal(),
                    Out            = ini["Special Art C"]["out"].ToDecimal(),
                    Start          = ini["Special Art C"]["start"].ToEnum <StartLocation>(),
                    X              = ini["Special Art C"]["x"].ToInt32(),
                    Y              = ini["Special Art C"]["y"].ToInt32(),
                    SpecialArtType = SpecialArtType.C,
                };


                settings.Themes = new Themes()
                {
                    UseParentVideos   = ini["themes"]["use_parent_vids"].ToBoolean(),
                    UseParentThemes   = ini["themes"]["use_parent_themes"].ToBoolean(),
                    AnimateOutDefault = ini["themes"]["animate_out_default"].ToBoolean(),
                    ReloadBackground  = ini["themes"]["reload_backgrounds"].ToBoolean(),
                };

                settings.Wheel = new Wheel()
                {
                    Alpha                 = ini["wheel"]["alpha"].ToDecimal(),
                    SmallAlpha            = ini["wheel"]["small_alpha"].ToDecimal(),
                    Style                 = ini["wheel"]["style"].ToEnum <WheelStyle>(),
                    Speed                 = ini["wheel"]["speed"].ToEnum <WheelSpeed>(),
                    PinCenterWidth        = ini["wheel"]["pin_center_width"].ToInt32(),
                    HorizontalWheelY      = ini["wheel"]["horz_wheel_y"].ToInt32(),
                    VerticalWheelPosition = ini["wheel"]["vert_wheel_position"].ToEnum <VerticalWheelPosition>(),
                    YRotation             = ini["wheel"]["y_rotation"].ToEnum <RotationPoint>(),
                    NormalLarge           = ini["wheel"]["norm_large"].ToInt32(),
                    NormalSmall           = ini["wheel"]["norm_small"].ToInt32(),
                    VerticalLarge         = ini["wheel"]["vert_large"].ToInt32(),
                    VerticalSmall         = ini["wheel"]["vert_small"].ToInt32(),
                    PinLarge              = ini["wheel"]["pin_large"].ToInt32(),
                    PinSmall              = ini["wheel"]["pin_small"].ToInt32(),
                    HorizontalLarge       = ini["wheel"]["horz_large"].ToInt32(),
                    HorizontalSmall       = ini["wheel"]["horz_small"].ToInt32(),
                    LetterWheelX          = ini["wheel"]["letter_wheel_x"].ToInt32(),
                    LetterWheelY          = ini["wheel"]["letter_wheel_y"].ToInt32(),
                    TextWidth             = ini["wheel"]["text_width"].ToInt32(),
                    TextFont              = ini["wheel"]["text_font"].ToEnum <TextFont>(),
                    SmallTextWidth        = ini["wheel"]["small_text_width"].ToInt32(),
                    LargeTextWidth        = ini["wheel"]["large_text_width"].ToInt32(),
                    TextStrokeSize        = ini["wheel"]["text_stroke_size"].ToInt32(),
                    TextStrokeColor       = ini["wheel"]["text_stroke_color"].Value,
                    TextColor1            = ini["wheel"]["text_color1"].Value,
                    TextColor2            = ini["wheel"]["text_color2"].Value,
                    TextColor3            = ini["wheel"]["text_color3"].Value,
                    ColorRatio            = ini["wheel"]["color_ratio"].ToInt32(),
                    ShadowDistance        = ini["wheel"]["shadow_distance"].ToInt32(),
                    ShadowAngle           = ini["wheel"]["shadow_angle"].ToInt32(),
                    ShadowColor           = ini["wheel"]["shadow_color"].Value,
                    ShadowAlpha           = ini["wheel"]["shadow_alpha"].ToInt32(),
                    ShadowBlur            = ini["wheel"]["shadow_blur"].ToInt32(),
                };

                settings.VideoDefaults = new VideoDefaults()
                {
                    Path = ini["video defaults"]["path"].Value
                };

                return(settings);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                Logger.Debug($"Console settings file deserialized in {stopwatch.ElapsedMilliseconds}ms");
            }
        }
Example #33
0
        private static void FirstRunConfiguration()
        {
            IPAddress     gatewayip           = IPAddress.Loopback;
            int           gatewayport         = 64003;
            IPAddress     mapip               = IPAddress.Loopback;
            byte          worldid             = 0;
            int           mapport             = 64002;
            int           playerlimit         = 60;
            string        databaseusername    = "******";
            string        databasepassword    = "******";
            uint          dbport              = 3306;
            int           cexprates           = 1;
            int           jexprates           = 1;
            int           wexprates           = 1;
            int           droprates           = 1;
            string        databasename        = "saga_world";
            string        dbhost              = "localhost";
            string        dbprovider          = "Saga.Map.Data.Mysql.dll, Saga.Map.Data.Mysql.MysqlProvider";
            string        proof               = "c4ca4238a0b923820dcc509a6f75849b";
            string        questplugin         = "Saga.Map.Data.LuaQuest.dll, Saga.Map.Data.LuaQuest.LuaQuestProvider";
            string        scenarioquestplugin = "Saga.Map.Data.LuaQuest.dll, Saga.Map.Data.LuaQuest.ScenarioLuaQuest";
            string        worldspawn          = "Saga.Map.Plugins.dll, Saga.Map.Plugins.MultifileSpawnWorldObjects";
            string        multiworldspawn     = "Saga.Map.Plugins.dll, Saga.Map.Plugins.MultifileSpawnMultiWorldObjects";
            string        eventprovider       = "Saga.Map.Data.LuaQuest.dll, Saga.Map.Data.LuaQuest.EventInfo";
            ConsoleReader reader              = new ConsoleReader();

            reader.Clear(null);

            System.Configuration.Configuration b = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            if (CheckConfigExists() == false)
            {
                Console.WriteLine("First time run-configuration");
                char key;

                #region Always Configure

                ConfigureRequired("What is the world id of this server?");
                while (!byte.TryParse(Console.ReadLine(), out worldid))
                {
                    Console.WriteLine("Incorrect value please use an number between 0–255");
                }

                ConfigureRequired("What is the player limit of this server?");
                while (!int.TryParse(Console.ReadLine(), out playerlimit))
                {
                    Console.WriteLine("Incorrect value please use an valid number");
                }

                ConfigureRequired("What is the authentication proof of this server?");
                MD5           md5      = MD5.Create();
                byte[]        block    = Encoding.UTF8.GetBytes(Console.ReadLine());
                byte[]        md5block = md5.ComputeHash(block);
                StringBuilder builder  = new StringBuilder();
                foreach (byte c in md5block)
                {
                    builder.AppendFormat("{0:X2}", c);
                }
                proof = builder.ToString();

                ConfigureRequired("What are the cexp-rates?");
                while (!int.TryParse(Console.ReadLine(), out cexprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                cexprates = Math.Min(20, Math.Max(cexprates, 1));

                ConfigureRequired("What are the jexp-rates?");
                while (!int.TryParse(Console.ReadLine(), out jexprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                jexprates = Math.Min(20, Math.Max(jexprates, 1));

                ConfigureRequired("What are the wexp-rates?");
                while (!int.TryParse(Console.ReadLine(), out wexprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                wexprates = Math.Min(20, Math.Max(wexprates, 1));

                ConfigureRequired("What are the item drop-rates?");
                while (!int.TryParse(Console.ReadLine(), out droprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                droprates = Math.Min(20, Math.Max(droprates, 1));

                ConfigureRequired("Detect database plugin");
                dbprovider = FindPlugin(typeof(IDatabase), dbprovider);

                ConfigureRequired("Detect quest plugin");
                questplugin = FindPlugin(typeof(Saga.Quests.IQuest), questplugin);

                ConfigureRequired("Detect scenarion quest plugin");
                scenarioquestplugin = FindPlugin(typeof(Saga.Quests.ISceneraioQuest), scenarioquestplugin);

                ConfigureRequired("Detect npc & map spawn plugin");
                worldspawn = FindPlugin(typeof(Saga.Factory.SpawnWorldObjects), worldspawn);

                ConfigureRequired("Detect mob spawn plugin");
                multiworldspawn = FindPlugin(typeof(Saga.Factory.SpawnMultiWorldObjects), multiworldspawn);

                ConfigureRequired("Detect event plugin");
                eventprovider = FindPlugin(typeof(Saga.Factory.EventManager.BaseEventInfo), eventprovider);

                #endregion Always Configure

                #region Network Settings

ConfigureGatewayNetwork:
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Do you wan to configure the gateway-map network settings? Y/N");
                Console.ResetColor();
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What ip should the gateway-map server listen to?");
                    while (!IPAddress.TryParse(Console.ReadLine(), out gatewayip))
                    {
                        Console.WriteLine("Incorrect value please use an ipv4 adress, recommended 0.0.0.0");
                    }

                    Console.WriteLine("What port should the gateway-map server listen to?");
                    while (!int.TryParse(Console.ReadLine(), out gatewayport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 64003");
                    }
                }
                else if (key != 'n')
                {
                    goto ConfigureGatewayNetwork;
                }

ConfigureWorldNetwork:
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Do you wan to configure the authentication-map network settings? Y/N");
                Console.ResetColor();
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What ip should the authentication-map server listen to?");
                    while (!IPAddress.TryParse(Console.ReadLine(), out mapip))
                    {
                        Console.WriteLine("Incorrect value please use an ipv4 adress, recommended 0.0.0.0");
                    }

                    Console.WriteLine("On what port is the authentication server listening");
                    while (!int.TryParse(Console.ReadLine(), out mapport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 64002");
                    }
                }
                else if (key != 'n')
                {
                    goto ConfigureWorldNetwork;
                }

                #endregion Network Settings

                #region Database Settings

DatabaseName:
                ConfigureOptional("Do you want to configure the database settings? Y/N");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    ConfigureRequired("What is the database name?");
                    databasename = Console.ReadLine();

                    ConfigureRequired("What is the database username?");
                    databaseusername = Console.ReadLine();

                    ConfigureRequired("What is the database password?");
                    databasepassword = Console.ReadLine();

                    ConfigureRequired("What is the database port?");
                    while (!uint.TryParse(Console.ReadLine(), out dbport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 3306");
                    }

                    ConfigureRequired("What is the database host?");
                    dbhost = Console.ReadLine();
                }
                else if (key != 'n')
                {
                    goto DatabaseName;
                }

                #endregion Database Settings



                #region Plugin detection

PluginDetection:
                ConfigureOptional("Do you want to dectect other plugins?");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("no plugins detected");
                }
                else if (key != 'n')
                {
                    goto PluginDetection;
                }

                #endregion Plugin detection

                //CONFIGURE SERVER SETTINGS
                ServerVars serverVarsConfiguration = new ServerVars();
                serverVarsConfiguration.DataDirectory = "../Data/";
                b.Sections.Add("Saga.ServerVars", serverVarsConfiguration);

                //CONFIGURE NETWORK SETTINGS
                NetworkSettings       networkSettings = new NetworkSettings();
                NetworkFileCollection collection      = networkSettings.Connections;
                collection["public"]   = new NetworkElement("public", gatewayip.ToString(), gatewayport);
                collection["internal"] = new NetworkElement("internal", mapip.ToString(), mapport);
                b.Sections.Remove("Saga.Manager.NetworkSettings");
                b.Sections.Add("Saga.Manager.NetworkSettings", networkSettings);
                networkSettings.WorldId     = worldid;
                networkSettings.Proof       = proof;
                networkSettings.PlayerLimit = playerlimit;

                //CONFIGURE CONSOLE SETTING
                ConsoleSettings consoleSettings = new ConsoleSettings();
                consoleSettings.CommandPrefix = "@";
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Broadcast"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Position"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ChatMute"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.GmWarptomap"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.PlayerJump"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.PlayerCall"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Speed"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.GarbageCollector"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ClearNpc"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.KickAll"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Kick"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Time"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ShowMaintenance"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ScheduleMaintenance"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.SetGmLevel"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Spawn"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Unspawn"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.GiveItem"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.QStart"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Kill"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Worldload"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Gmgo"));
                b.Sections.Add("Saga.Manager.ConsoleSettings", consoleSettings);

                //PORTALS
                PortalSettings portalSettings = new PortalSettings();
                portalSettings.FolderItems.Add(new FactoryFileElement("~/portal_data.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.Portals");
                b.Sections.Add("Saga.Factory.Portals", portalSettings);

                //CHARACTERCONFIGURATION
                CharacterConfigurationSettings characterconfigurationSettings = new CharacterConfigurationSettings();
                characterconfigurationSettings.FolderItems.Add(new FactoryFileElement("~/character-template.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.CharacterConfiguration");
                b.Sections.Add("Saga.Factory.CharacterConfiguration", characterconfigurationSettings);

                //ADDITION
                AdditionSettings additionSettings = new AdditionSettings();
                additionSettings.FolderItems.Add(new FactoryFileElement("~/Addition_t.xml", "text/xml"));
                additionSettings.Reference = "~/addition_reference.csv";
                b.Sections.Remove("Saga.Factory.Addition");
                b.Sections.Add("Saga.Factory.Addition", additionSettings);

                //SPELLS
                SpellSettings spellSettings = new SpellSettings();
                spellSettings.FolderItems.Add(new FactoryFileElement("~/spell_data.xml", "text/xml"));
                spellSettings.Reference = "~/skill_reference.csv";
                b.Sections.Remove("Saga.Factory.Spells");
                b.Sections.Add("Saga.Factory.Spells", spellSettings);

                //STATUSBYLEVEL
                StatusByLevelSettings statusbylevelSettings = new StatusByLevelSettings();
                statusbylevelSettings.FolderItems.Add(new FactoryFileElement("~/experience.csv", "text/csv"));
                statusbylevelSettings.Cexp     = cexprates;
                statusbylevelSettings.Jexp     = jexprates;
                statusbylevelSettings.Wexp     = wexprates;
                statusbylevelSettings.Droprate = droprates;

                b.Sections.Remove("Saga.Factory.StatusByLevel");
                b.Sections.Add("Saga.Factory.StatusByLevel", statusbylevelSettings);

                //WARPSETTINGS
                WarpSettings warpSettings = new WarpSettings();
                warpSettings.FolderItems.Add(new FactoryFileElement("~/warp_data.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.Warps");
                b.Sections.Add("Saga.Factory.Warps", warpSettings);

                //ZONES
                ZoneSettings zoneSettings = new ZoneSettings();
                zoneSettings.FolderItems.Add(new FactoryFileElement("~/zone_data.csv", "text/csv"));
                zoneSettings.Directory = "../Data/heightmaps";
                b.Sections.Remove("Saga.Factory.Zones");
                b.Sections.Add("Saga.Factory.Zones", zoneSettings);

                //ITEMS
                ItemSettings itemSettings = new ItemSettings();
                itemSettings.FolderItems.Add(new FactoryFileElement("~/item_data.xml", "text/xml"));
                b.Sections.Remove("Saga.Factory.Items");
                b.Sections.Add("Saga.Factory.Items", itemSettings);

                //WEAPONARY
                WeaponarySettings weaponarySettings = new WeaponarySettings();
                weaponarySettings.FolderItems.Add(new FactoryFileElement("~/weapon_data.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.Weaponary");
                b.Sections.Add("Saga.Factory.Weaponary", weaponarySettings);

                //SPAWNTEMPLATE
                SpawntemplateSettings spawntemplateSettings = new SpawntemplateSettings();
                spawntemplateSettings.FolderItems.Add(new FactoryFileElement("~/npc_templates.csv", "text/csv"));
                spawntemplateSettings.FolderItems.Add(new FactoryFileElement("~/item_templates.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.SpawnTemplate");
                b.Sections.Add("Saga.Factory.SpawnTemplate", spawntemplateSettings);

                //SPAWNS NPC & MAP
                SpawnWorldObjectSettings spawnworldobjectSettings = new SpawnWorldObjectSettings();
                spawnworldobjectSettings.FolderItems.Add(new FactoryFileElement("~/npc-spawns/", "text/csv"));
                spawnworldobjectSettings.FolderItems.Add(new FactoryFileElement("~/item-spawns/", "text/csv"));
                spawnworldobjectSettings.DerivedType = worldspawn;
                b.Sections.Remove("Saga.Factory.SpawnWorldObjects");
                b.Sections.Add("Saga.Factory.SpawnWorldObjects", spawnworldobjectSettings);

                //SPAWNS MOBS
                SpawnMultiWorldObjectSettings spawnmultiworldobjectSettings = new SpawnMultiWorldObjectSettings();
                spawnmultiworldobjectSettings.FolderItems.Add(new FactoryFileElement("~/mob-spawns/", "text/csv"));
                spawnmultiworldobjectSettings.DerivedType = multiworldspawn;
                b.Sections.Remove("Saga.Factory.SpawnMultiWorldObjects");
                b.Sections.Add("Saga.Factory.SpawnMultiWorldObjects", spawnmultiworldobjectSettings);

                //SCRIPTING
                ScriptingSettings scriptingSettings = new ScriptingSettings();
                scriptingSettings.Directory = "../Saga.Scripting";
                scriptingSettings.Assemblies.Add(new FactoryFileElement("System.dll", "text/csv"));
                scriptingSettings.Assemblies.Add(new FactoryFileElement("System.Data.dll", "text/csv"));
                scriptingSettings.Assemblies.Add(new FactoryFileElement("System.Xml.dll", "text/csv"));
                b.Sections.Remove("Saga.Manager.Scripting");
                b.Sections.Add("Saga.Manager.Scripting", scriptingSettings);

                //EVENTS
                EventSettings eventSettings = new EventSettings();
                eventSettings.FolderItems.Add(new FactoryFileElement("~/eventlist.csv", "text/csv"));
                eventSettings.Provider = eventprovider;
                b.Sections.Remove("Saga.Factory.Events");
                b.Sections.Add("Saga.Factory.Events", eventSettings);

                //QUUESTS
                QuestSettings questSettings = new QuestSettings();
                questSettings.Directory        = "../Quests/";
                questSettings.SDirectory       = "~/Scenario.Quests/";
                questSettings.Provider         = questplugin;
                questSettings.ScenarioProvider = scenarioquestplugin;
                b.Sections.Remove("Saga.Manager.Quest");
                b.Sections.Add("Saga.Manager.Quest", questSettings);

                //DATABASE SETTINGS
                DatabaseSettings databaseSettings = new DatabaseSettings();
                databaseSettings.Database = databasename;
                databaseSettings.Username = databaseusername;
                databaseSettings.Password = databasepassword;
                databaseSettings.Port     = dbport;
                databaseSettings.Host     = dbhost;
                databaseSettings.DBType   = dbprovider;
                b.Sections.Remove("Saga.Manager.Database");
                b.Sections.Add("Saga.Manager.Database", databaseSettings);

                //SAVE CONFIGURATION AND REFRESH ALL SECTIONS
                b.Save();

                //REFRESH ALL SECTIONS
                ConfigurationManager.RefreshSection("Saga.Factory.SpawnMultiWorldObjects");
                ConfigurationManager.RefreshSection("Saga.Manager.Database");
                ConfigurationManager.RefreshSection("Saga.Manager.Quest");
                ConfigurationManager.RefreshSection("Saga.Manager.Scripting");
                ConfigurationManager.RefreshSection("Saga.Factory.Events");
                ConfigurationManager.RefreshSection("Saga.Factory.SpawnWorldObject");
                ConfigurationManager.RefreshSection("Saga.ServerVars");
                ConfigurationManager.RefreshSection("Saga.Manager.NetworkSettings");
                ConfigurationManager.RefreshSection("Saga.Manager.ConsoleSettings");
                ConfigurationManager.RefreshSection("Saga.Factory.Portals");
                ConfigurationManager.RefreshSection("Saga.Factory.CharacterConfiguration");
                ConfigurationManager.RefreshSection("Saga.Factory.Addition");
                ConfigurationManager.RefreshSection("Saga.Factory.Spells");
                ConfigurationManager.RefreshSection("Saga.Factory.StatusByLevel");
                ConfigurationManager.RefreshSection("Saga.Factory.Warps");
                ConfigurationManager.RefreshSection("Saga.Factory.Zones");
                ConfigurationManager.RefreshSection("Saga.Factory.Items");
                ConfigurationManager.RefreshSection("Saga.Factory.Weaponary");
                ConfigurationManager.RefreshSection("Saga.Factory.SpawnTemplate");

                Console.WriteLine("Everything configured");
            }
        }
Example #34
0
        private Rect    DrawStreamTabs(Rect r)
        {
            ConsoleSettings settings = HQ.Settings.Get <ConsoleSettings>();
            float           maxWidth = r.width;

            r.height = Constants.SingleLineHeight;

            // Switch stream
            if (settings.inputsManager.Check("Navigation", ConsoleConstants.SwitchNextStreamCommand) == true)
            {
                this.currentVars.workingStream += 1;
                if (this.currentVars.workingStream >= this.streams.Count)
                {
                    this.currentVars.workingStream = 0;
                }

                Event.current.Use();
            }
            if (settings.inputsManager.Check("Navigation", ConsoleConstants.SwitchPreviousStreamCommand) == true)
            {
                this.currentVars.workingStream -= 1;
                if (this.currentVars.workingStream < 0)
                {
                    this.currentVars.workingStream = this.streams.Count - 1;
                }

                Event.current.Use();
            }

            for (int i = 0; i < this.streams.Count; i++)
            {
                r = this.streams[i].OnTabGUI(r, i);
            }

            r.width = 16F;

            if (GUI.Button(r, "+", HQ.Settings.Get <GeneralSettings>().MenuButtonStyle) == true)
            {
                RemoteModuleSettings remoteSettings = HQ.Settings.Get <RemoteModuleSettings>();
                StreamLog            stream         = new StreamLog();
                stream.Init(this.console, this);
                stream.rowsDrawer.SetRowGetter(this);
                stream.FilterAltered += this.console.SaveModules;
                stream.OptionAltered += this.console.SaveModules;

                foreach (ILogFilter filter in remoteSettings.GenerateFilters())
                {
                    stream.groupFilters.filters.Add(filter);
                }

                this.streams.Add(stream);

                if (this.StreamAdded != null)
                {
                    this.StreamAdded(stream);
                }

                this.console.CheckNewLogConsume -= stream.ConsumeLog;
                this.console.PropagateNewLog    -= stream.AddLog;
                this.console.SaveModules();

                if (this.streams.Count == 1)
                {
                    this.currentVars.workingStream = 0;
                }
            }
            r.x += r.width;

            if (this.streams.Count > 2)
            {
                r.y    += r.height + 2F;
                r.x     = 0F;
                r.width = maxWidth;
            }
            else
            {
                r.width = maxWidth - r.x;
            }

            return(r);
        }