Skip to content

Commit

Permalink
Add font type setting to Settings menu
Browse files Browse the repository at this point in the history
  • Loading branch information
baratgabor committed Nov 2, 2020
1 parent 3ef9fae commit 89f7764
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/GridOS/BuiltInMenus/Settings/Commands/FontTypeCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;

namespace IngameScript
{
class FontTypeCommand : ConfigurationCommand<string>
{
protected override IReadOnlyList<NamedOption<string>> 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);
}
}
1 change: 1 addition & 0 deletions src/GridOS/BuiltInMenus/Settings/SettingsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private List<IMenuItem> CreateContextualList(IMenuInstance menuInstance)
{
var services = menuInstance.MenuInstanceServices;
return new List<IMenuItem>() {
new FontTypeCommand(services),
new FontSizeCommand(services),
new FontColorCommand(services),
new BackgroundColorCommand(services)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 2 additions & 3 deletions src/GridOS/Core/DisplaySystem/DisplayInfrastructure/IView.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System.Text;

namespace IngameScript
namespace IngameScript
{
interface IView
{
DisplayView AddControl(IControl control);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public interface IMenuInstanceServices
void SetFontSize(float fontSize);
void SetFontColor(Color color);
void SetBackgroundColor(Color color);
void SetFontType(string fontName);
}
}
1 change: 1 addition & 0 deletions src/GridOS/GridOS.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Compile Include="$(MSBuildThisFileDirectory)BuiltInMenus\Settings\Commands\Base\ConfigurationCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)BuiltInMenus\Settings\Commands\FontColorCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)BuiltInMenus\Settings\Commands\FontSizeCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)BuiltInMenus\Settings\Commands\FontTypeCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)BuiltInMenus\Settings\Commands\LogLevelCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)BuiltInMenus\Settings\SettingsMenu.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Core\CommandExecution\ICommandDispatcher.cs" />
Expand Down

0 comments on commit 89f7764

Please sign in to comment.