Skip to content

Commit

Permalink
desired fov ui element updated
Browse files Browse the repository at this point in the history
* change desired fov label to a text box
* add up and down arrows to control text box and fov slider values
  • Loading branch information
rex706 committed Dec 18, 2016
1 parent e78533d commit 0cd00de
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 16 deletions.
8 changes: 5 additions & 3 deletions ARMA FOV Changer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
<TextBox x:Name="DesiredFovLeftTextBox" HorizontalAlignment="Left" Height="23" Margin="77,198,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="82" Grid.Column="1"/>
<TextBox x:Name="DesiredFovTopTextBox" HorizontalAlignment="Left" Height="23" Margin="77,171,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="82" Grid.Column="1"/>
<Label x:Name="currentLabel" Content="Current" Height="27" VerticalAlignment="Top" Margin="132,127,10,0"/>
<Label x:Name="fovSliderLabel" Content="Desired FOV" Height="27" VerticalAlignment="Top" Margin="62,26,45,0" HorizontalContentAlignment="Center" Grid.Column="1"/>
<Label x:Name="fovLabel" Content="" Height="28" VerticalAlignment="Center" Margin="78,55,60,333" HorizontalAlignment="Center" Width="72" HorizontalContentAlignment="Center" Grid.Column="1" FontSize="14"/>
<Slider x:Name="fovSlider" Value="90" Minimum="65" Maximum="165" Height="24" VerticalAlignment="Top" Margin="10,92,10,0" ValueChanged="fovSlider_ValueChanged" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight" Foreground="#FF4D4D4D" Background="{x:Null}" BorderBrush="{x:Null}" Grid.ColumnSpan="2"/>
<Label x:Name="fovSliderLabel" Content="Desired FOV" Height="27" VerticalAlignment="Top" Margin="65,24,42,0" HorizontalContentAlignment="Center" Grid.Column="1"/>
<Slider x:Name="fovSlider" Value="91" Minimum="65" Maximum="165" Height="24" VerticalAlignment="Top" Margin="10,92,10,0" ValueChanged="fovSlider_ValueChanged" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight" Foreground="#FF4D4D4D" Background="{x:Null}" BorderBrush="{x:Null}" Grid.ColumnSpan="2"/>
<Label x:Name="aspectRatioLabel" Content="" Height="27" VerticalAlignment="Top" Margin="0,53,162,0" HorizontalContentAlignment="Center" Grid.Column="1"/>
<Label x:Name="profileLabelLabel" Content="Profile:" HorizontalAlignment="Left" Margin="28,24,0,0" VerticalAlignment="Top"/>
<Label x:Name="profileLabel" Content="" HorizontalAlignment="Left" Margin="79,25,0,0" VerticalAlignment="Top" Width="191" Grid.ColumnSpan="2"/>
Expand All @@ -57,5 +56,8 @@
<Label x:Name="uiBottomRightXLabel_Copy2" HorizontalAlignment="Left" Height="23" Margin="131,293,0,0" Content="" VerticalAlignment="Top" Width="86"/>
<Label x:Name="uiBottomRightYLabel_Copy2" HorizontalAlignment="Left" Height="23" Margin="131,321,0,0" Content="" VerticalAlignment="Top" Width="86"/>
<CheckBox x:Name="autoCheckBox" Content="Auto" HorizontalAlignment="Left" Margin="32,133,0,0" VerticalAlignment="Top" Checked="autoCheckBox_Checked" Unchecked="autoCheckBox_Unchecked" Visibility="Hidden" ToolTip="Autofill Fov settings"/>
<ScrollBar x:Name="scrollBar" Grid.Column="1" HorizontalAlignment="Left" Margin="75,48,0,0" VerticalAlignment="Top" Height="36" Width="18" ValueChanged="scrollBar_ValueChanged" Minimum="0" Maximum="1000" Value="425"/>
<Label x:Name="degreeLabel" Content="°" Height="20" VerticalAlignment="Top" Margin="131,49,58,0" Grid.Column="1" FontSize="14"/>
<TextBox x:Name="fovTextBox" HorizontalAlignment="Left" Height="23" Margin="94,56,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="40" TextChanged="fovTextBox_TextChanged" Grid.Column="1" HorizontalContentAlignment="Center"/>
</Grid>
</Window>
68 changes: 57 additions & 11 deletions ARMA FOV Changer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace ARMA_FOV_Changer
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>

public partial class MainWindow : Window
{
private static Version latest;
Expand Down Expand Up @@ -97,7 +97,7 @@ private async void MainWindow_Loaded(object sender, RoutedEventArgs e)

LoadProfile();
}

private void LoadProfile()
{
// Open splash window for game selection.
Expand All @@ -122,7 +122,7 @@ private void LoadProfile()
// Get profile name from file path string.
int lastSlashIdx = profilePath.LastIndexOf("\\") + 1;
int profNameLength = profilePath.LastIndexOf(".") - lastSlashIdx;

int cwSlashIdx = lastSlashIdx > 0 ? profilePath.LastIndexOf("\\", lastSlashIdx - 2) : -1;
int profNameLengthCW = profilePath.LastIndexOf("\\") - cwSlashIdx;

Expand Down Expand Up @@ -243,7 +243,7 @@ private void LoadProfile()
}

private void saveButton_Click(object sender, RoutedEventArgs e)
{
{
// Overwrite fov values.
arrLine[fovTopLine] = fovstring + "=" + DesiredFovTopTextBox.Text + ";";
if (button != DayZ)
Expand Down Expand Up @@ -293,7 +293,7 @@ private void refreshMath()
desiredFov = (int)fovSlider.Value;
if (autoCheckBox.IsChecked == false)
{
fovLabel.Content = fovSlider.Value.ToString() + "°";
fovTextBox.Text = fovSlider.Value.ToString();
}

// Find resolution and aspect ratio in saved ratios class.
Expand Down Expand Up @@ -325,23 +325,23 @@ private void refreshMath()
double uiBottomRightY = 1.0;
double cwFovTop = 0.75;
double cwFovLeft = 1.0;

// Set up aspect ratio variables and ui scaling based on http://ofp-faguss.com/files/ofp_aspect_ratio.pdf
if (testRatio == 1.25)
{
aspectRatio = "5:4";
cwFovTop = 0.8;
uiTopLeftY = 0.03125;
uiBottomRightY = 0.96875;
}
}
else if (testRatio == 1.33 || testRatio == 1.37)
{
aspectRatio = "4:3";
}
else if (testRatio == 1.50)
{
aspectRatio = "3:2";
}
}
else if (testRatio == 1.60)
{
aspectRatio = "16:10";
Expand All @@ -359,7 +359,7 @@ private void refreshMath()
else if (testRatio == 1.71)
{
aspectRatio = "128:75";
}
}
else if (testRatio == 1.78)
{
aspectRatio = "16:9";
Expand Down Expand Up @@ -392,7 +392,7 @@ private void refreshMath()
cwFovLeft = 3.0;
uiTopLeftX = 0.333333;
uiBottomRightX = 0.666667;
}
}
else if (testRatio == 4.80)
{
aspectRatio = "48:10";
Expand Down Expand Up @@ -526,6 +526,8 @@ private void ProfileMenuItem_Click(object sender, RoutedEventArgs e)
autoCheckBox.IsChecked = false;
autoCheckBox.Visibility = Visibility.Hidden;

scrollBar.IsEnabled = true;
fovTextBox.IsEnabled = true;
fovSlider.IsEnabled = true;
fovSlider.ToolTip = null;

Expand Down Expand Up @@ -592,15 +594,59 @@ private void ExitMenuItem_Click(object sender, RoutedEventArgs e)

private void autoCheckBox_Checked(object sender, RoutedEventArgs e)
{
scrollBar.IsEnabled = false;
fovSlider.IsEnabled = false;
fovLabel.Content = "Auto";
degreeLabel.Visibility = Visibility.Hidden;
fovTextBox.Text = "Auto";
fovTextBox.IsEnabled = false;
refreshMath();
}

private void autoCheckBox_Unchecked(object sender, RoutedEventArgs e)
{
scrollBar.IsEnabled = true;
fovSlider.IsEnabled = true;
degreeLabel.Visibility = Visibility.Visible;
fovTextBox.IsEnabled = true;
refreshMath();
}

private void scrollBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (e.NewValue < e.OldValue)
fovSlider.Value += 1;
else if (e.NewValue > e.OldValue)
fovSlider.Value -= 1;
}

private void fovTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
int value;

if (fovTextBox.Text.Length >= 2)
{
try
{
value = Int32.Parse(fovTextBox.Text);
}
catch
{
value = 90;
}

if (value >= 65 && value <= 165)
{
fovSlider.Value = value;
}
else if (value < 65)
{
fovSlider.Value = 65;
}
else if (value > 165)
{
fovSlider.Value = 165;
}
}
}
}
}
4 changes: 2 additions & 2 deletions ARMA FOV Changer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.1.1")]
[assembly: AssemblyFileVersion("1.2.1.1")]
[assembly: AssemblyVersion("1.2.2.0")]
[assembly: AssemblyFileVersion("1.2.2.0")]

0 comments on commit 0cd00de

Please sign in to comment.