Skip to content

Commit

Permalink
[HaCreator] Added a combobox for the selection of render resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
LastBattle committed Oct 7, 2020
1 parent f99e1c2 commit 615188a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
11 changes: 10 additions & 1 deletion HaCreator/GUI/HaRibbon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,18 @@
<RibbonTab x:Name="toolsTab" Header="Tools" KeyTip="T">
<RibbonGroup x:Name="Tools" Header="Tools">
<RibbonButton Label="Settings" LargeImageSource="pack://application:,,,/HaCreator;component/Images/Settings_big.png" Command="ns:HaRibbon.Settings" Focusable="False"/>
<RibbonButton Label="Map Simulation" LargeImageSource="pack://application:,,,/HaCreator;component/Images/Play.png" Command="ns:HaRibbon.MapSim" Focusable="False"/>
<RibbonButton Label="Manage User Objects" LargeImageSource="pack://application:,,,/HaCreator;component/Images/UserObjs.png" Command="ns:HaRibbon.UserObjs" Focusable="False"/>
</RibbonGroup>
<RibbonGroup x:Name="SimulatorSettings" Header="Map Simulator">
<StackPanel Orientation="Horizontal">
<RibbonButton Label="Preview" LargeImageSource="pack://application:,,,/HaCreator;component/Images/Play.png" Command="ns:HaRibbon.MapSim" Focusable="False"/>

<ComboBox x:Name="comboBox_Resolution" Width="100"
Foreground="Black" VerticalAlignment="Center"
SelectionChanged="comboBox_Resolution_SelectionChanged">
</ComboBox>
</StackPanel>
</RibbonGroup>
<RibbonGroup x:Name="Options" Header="Options">
<RibbonToggleButton x:Name="minimapBtn" Label="Show Minimap" LargeImageSource="pack://application:,,,/HaCreator;component/Images/Minimap.png" Command="ns:HaRibbon.Minimap" Focusable="False"/>
<RibbonToggleButton x:Name="parallaxBtn" Label="Parallax BGs" LargeImageSource="pack://application:,,,/HaCreator;component/Images/diagram_parallax.png" Command="ns:HaRibbon.Parallax" Focusable="False"/>
Expand Down
40 changes: 40 additions & 0 deletions HaCreator/GUI/HaRibbon.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using HaCreator.CustomControls;
using HaCreator.MapEditor;
using HaSharedLibrary.Render.DX;
using MapleLib.WzLib.WzStructure.Data;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -33,6 +34,7 @@ public partial class HaRibbon : UserControl
public HaRibbon()
{
InitializeComponent();

this.PreviewMouseWheel += HaRibbon_PreviewMouseWheel;
}

Expand Down Expand Up @@ -64,6 +66,30 @@ private void Ribbon_Loaded(object sender, RoutedEventArgs e)
reducedHeight = (int)child.RowDefinitions[0].ActualHeight;
child.RowDefinitions[0].Height = new GridLength(0);
}

// Load map simulator resolutions
foreach (RenderResolution val in Enum.GetValues(typeof(RenderResolution)))
{
ComboBoxItem comboBoxItem = new ComboBoxItem
{
Tag = val,
Content = val.ToString().Replace("Res_", "").Replace("_", " ").Replace("PercScaled", "% scale")
};

comboBox_Resolution.Items.Add(comboBoxItem);
}
//comboBox_Resolution.DisplayMemberPath = "Content";

int i = 0;
foreach (ComboBoxItem item in comboBox_Resolution.Items)
{
if ((RenderResolution)item.Tag == UserSettings.SimulateResolution)
{
comboBox_Resolution.SelectedIndex = i;
break;
}
i++;
}
}

public static readonly RoutedUICommand New = new RoutedUICommand("New", "New", typeof(HaRibbon),
Expand Down Expand Up @@ -530,5 +556,19 @@ protected override void OnPreviewKeyDown(KeyEventArgs e)
RibbonKeyDown.Invoke(this, new System.Windows.Forms.KeyEventArgs((System.Windows.Forms.Keys)KeyInterop.VirtualKeyFromKey(e.Key)));
}
}

/// <summary>
/// On simulator preview resolution changed
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void comboBox_Resolution_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (comboBox_Resolution.SelectedItem == null)
return;

RenderResolution selectedItem = (RenderResolution) (comboBox_Resolution.SelectedItem as ComboBoxItem).Tag;
UserSettings.SimulateResolution = selectedItem; // combo box selection. 800x600, 1024x768, 1280x720, 1920x1080
}
}
}

0 comments on commit 615188a

Please sign in to comment.