From 89f7764730b5315488f4c7879317e18c907a5d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Bar=C3=A1t?= Date: Tue, 3 Nov 2020 00:44:39 +0100 Subject: [PATCH] Add font type setting to Settings menu --- .../Settings/Commands/FontTypeCommand.cs | 19 +++++++++++++++++++ .../BuiltInMenus/Settings/SettingsMenu.cs | 1 + .../DisplayController.cs | 3 +++ .../DisplayInfrastructure/IView.cs | 5 ++--- .../IMenuInstanceServices.cs | 1 + src/GridOS/GridOS.projitems | 1 + 6 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/GridOS/BuiltInMenus/Settings/Commands/FontTypeCommand.cs diff --git a/src/GridOS/BuiltInMenus/Settings/Commands/FontTypeCommand.cs b/src/GridOS/BuiltInMenus/Settings/Commands/FontTypeCommand.cs new file mode 100644 index 0000000..787e460 --- /dev/null +++ b/src/GridOS/BuiltInMenus/Settings/Commands/FontTypeCommand.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace IngameScript +{ + class FontTypeCommand : ConfigurationCommand + { + protected override IReadOnlyList> OptionsList => StaticConfig.FontTypes.AsList; + protected override string LabelFormatString => "Font: {0}"; + + public FontTypeCommand(IMenuInstanceServices menuServices) : base(menuServices) + {} + + protected override string GetInitialValue() + => _menuServices.DisplayConfig.BaseFontName; + + protected override void SetNewValue(string value) + => _menuServices.SetFontType(value); + } +} diff --git a/src/GridOS/BuiltInMenus/Settings/SettingsMenu.cs b/src/GridOS/BuiltInMenus/Settings/SettingsMenu.cs index 59f9cd7..557080a 100644 --- a/src/GridOS/BuiltInMenus/Settings/SettingsMenu.cs +++ b/src/GridOS/BuiltInMenus/Settings/SettingsMenu.cs @@ -41,6 +41,7 @@ private List CreateContextualList(IMenuInstance menuInstance) { var services = menuInstance.MenuInstanceServices; return new List() { + new FontTypeCommand(services), new FontSizeCommand(services), new FontColorCommand(services), new BackgroundColorCommand(services) diff --git a/src/GridOS/Core/DisplaySystem/DisplayInfrastructure/DisplayController.cs b/src/GridOS/Core/DisplaySystem/DisplayInfrastructure/DisplayController.cs index 4a6862a..0793f25 100644 --- a/src/GridOS/Core/DisplaySystem/DisplayInfrastructure/DisplayController.cs +++ b/src/GridOS/Core/DisplaySystem/DisplayInfrastructure/DisplayController.cs @@ -59,6 +59,9 @@ public DisplayController(string name, ICommandDispatcher commandDispatcher, Main _menu.PushUpdate(); } + public void SetFontType(string fontName) + => _view.SetFontType(fontName); + public void SetFontSize(float fontSize) => _view.SetFontSize(fontSize); diff --git a/src/GridOS/Core/DisplaySystem/DisplayInfrastructure/IView.cs b/src/GridOS/Core/DisplaySystem/DisplayInfrastructure/IView.cs index 8fbea34..a9462d4 100644 --- a/src/GridOS/Core/DisplaySystem/DisplayInfrastructure/IView.cs +++ b/src/GridOS/Core/DisplaySystem/DisplayInfrastructure/IView.cs @@ -1,6 +1,4 @@ -using System.Text; - -namespace IngameScript +namespace IngameScript { interface IView { @@ -8,6 +6,7 @@ interface IView void RemoveControl(IControl control); void ClearControls(); void Redraw(bool flush = false); + void SetFontType(string fontName); void SetFontSize(float fontSize); void SetFontColor(Color color); void SetBackgroundColor(Color color); diff --git a/src/GridOS/Core/DisplaySystem/MenuInfrastructure/IMenuInstanceServices.cs b/src/GridOS/Core/DisplaySystem/MenuInfrastructure/IMenuInstanceServices.cs index 2bf269e..d0f5290 100644 --- a/src/GridOS/Core/DisplaySystem/MenuInfrastructure/IMenuInstanceServices.cs +++ b/src/GridOS/Core/DisplaySystem/MenuInfrastructure/IMenuInstanceServices.cs @@ -10,5 +10,6 @@ public interface IMenuInstanceServices void SetFontSize(float fontSize); void SetFontColor(Color color); void SetBackgroundColor(Color color); + void SetFontType(string fontName); } } diff --git a/src/GridOS/GridOS.projitems b/src/GridOS/GridOS.projitems index 5257c01..ced1d1d 100644 --- a/src/GridOS/GridOS.projitems +++ b/src/GridOS/GridOS.projitems @@ -15,6 +15,7 @@ +