diff --git a/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/CameraSettingsControl.xaml b/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/CameraSettingsControl.xaml index 28016c02d..946302f54 100644 --- a/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/CameraSettingsControl.xaml +++ b/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/CameraSettingsControl.xaml @@ -120,11 +120,12 @@ + diff --git a/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/ViewModels/DisplaySettingsViewModel.cs b/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/ViewModels/DisplaySettingsViewModel.cs index fc0ab5735..2e7fae4db 100644 --- a/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/ViewModels/DisplaySettingsViewModel.cs +++ b/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/ViewModels/DisplaySettingsViewModel.cs @@ -334,6 +334,14 @@ public int Scale set => Set(value); } + [DependsOn(nameof(IsScaleUiEnabled))] + public Visibility GameResolutionLabelVisibility => IsScaleUiEnabled.ToVisibility(); + + [DependsOn(nameof(Scale))] + [DependsOn(nameof(ResolutionWidth))] + [DependsOn(nameof(ResolutionHeight))] + public string GameDisplayResolutionText => $"Game Display Resolution: {ResolutionWidth*Scale/100}x{ResolutionHeight*Scale/100}"; + [DependsOn(nameof(RunInFullScreen))] public bool IsScaleUiEnabled => RunInFullScreen == false; diff --git a/FRBDK/Glue/OfficialPlugins/Wizard/Models/WizardDefinition.cs b/FRBDK/Glue/OfficialPlugins/Wizard/Models/WizardDefinition.cs index a82d15e49..2d5b1ee4a 100644 --- a/FRBDK/Glue/OfficialPlugins/Wizard/Models/WizardDefinition.cs +++ b/FRBDK/Glue/OfficialPlugins/Wizard/Models/WizardDefinition.cs @@ -278,6 +278,7 @@ public void CreatePages() options.Add("1920x1080 (16:9)", CameraResolution._1920x1080); formsData.AddIntValue("Game Scale%", nameof(ViewModel.ScalePercent)); + formsData.AddBoundText(nameof(ViewModel.EffectiveCameraResolutionText)); formsData.AddText("The Camera Controller Entity can simplify code for following a player and staying within the bounds of a map."); diff --git a/FRBDK/Glue/OfficialPlugins/Wizard/Models/WizardPage.cs b/FRBDK/Glue/OfficialPlugins/Wizard/Models/WizardPage.cs index fcee9531c..4e5bcce32 100644 --- a/FRBDK/Glue/OfficialPlugins/Wizard/Models/WizardPage.cs +++ b/FRBDK/Glue/OfficialPlugins/Wizard/Models/WizardPage.cs @@ -43,7 +43,15 @@ class DataItem public StackOrFill StackOrFill { get; set; } public int? LabelFontSize { get; set; } + /// + /// The string value to display. This is only applied if LabelBinding is not set. + /// public string LabelText { get; set; } + + /// + /// The property to bind to on the view model, allowing for labels to have dynamic text + /// + public string LabelBinding { get; set; } public object Value { get; set; } public string ViewModelProperty { get; set; } @@ -136,6 +144,14 @@ public void AddText(string text, string visibilityBinding = null) Add(dataItem); } + public void AddBoundText(string dataBinding) + { + var dataItem = new DataItem { LabelText = dataBinding }; + dataItem.ViewType = ViewType.TextBlock; + dataItem.LabelBinding = dataBinding; + Add(dataItem); + } + public void AddAction(string text, Action clickAction) { var dataItem = new DataItem { LabelText = text }; @@ -333,12 +349,16 @@ void TryBindVisibility(FrameworkElement element) innerStack.Children.Add(radioButton); } break; - //case ViewType.RadioButton: - - // break; case ViewType.TextBlock: var textBlock = new TextBlock(); - textBlock.Text = dataItem.LabelText; + if (!string.IsNullOrEmpty(dataItem.LabelBinding)) + { + textBlock.SetBinding(TextBlock.TextProperty, dataItem.LabelBinding); + } + else + { + textBlock.Text = dataItem.LabelText; + } textBlock.TextWrapping = TextWrapping.Wrap; if (dataItem.LabelFontSize != null) { diff --git a/FRBDK/Glue/OfficialPlugins/Wizard/ViewModels/WizardViewModel.cs b/FRBDK/Glue/OfficialPlugins/Wizard/ViewModels/WizardViewModel.cs index 16670e04a..68e3b3fa0 100644 --- a/FRBDK/Glue/OfficialPlugins/Wizard/ViewModels/WizardViewModel.cs +++ b/FRBDK/Glue/OfficialPlugins/Wizard/ViewModels/WizardViewModel.cs @@ -4,6 +4,7 @@ using OfficialPluginsCore.Wizard.ViewModels; using System; using System.Collections.Generic; +using System.Runtime.CompilerServices; using System.Text; using System.Windows; using System.Xml.Serialization; @@ -43,6 +44,39 @@ public enum CameraResolution _1920x1080 } + public static class CameraResolutionExtensions + { + public static int ResolutionWidth(this CameraResolution cameraResolution) + { + switch (cameraResolution) + { + case CameraResolution._256x224: return 256; + case CameraResolution._360x240: return 360; + case CameraResolution._480x360: return 480; + case CameraResolution._640x480: return 640; + case CameraResolution._800x600: return 800; + case CameraResolution._1024x768: return 1024; + case CameraResolution._1920x1080: return 1920; + } + return 0; + } + + public static int ResolutionHeight(this CameraResolution cameraResolution) + { + switch (cameraResolution) + { + case CameraResolution._256x224: return 224; + case CameraResolution._360x240: return 240; + case CameraResolution._480x360: return 360; + case CameraResolution._640x480: return 480; + case CameraResolution._800x600: return 600; + case CameraResolution._1024x768: return 768; + case CameraResolution._1920x1080: return 1080; + } + return 0; + } + } + #endregion public class WizardViewModel : ViewModel @@ -327,6 +361,10 @@ public int ScalePercent set => Set(value); } + [DependsOn(nameof(SelectedCameraResolution))] + [DependsOn(nameof(ScalePercent))] + public string EffectiveCameraResolutionText => $"Game Display Size: {SelectedCameraResolution.ResolutionWidth() * ScalePercent/100}x{SelectedCameraResolution.ResolutionHeight() * ScalePercent/100}"; + #endregion #region Additional Entities