Skip to content

Commit

Permalink
1.1.0.0 Upate
Browse files Browse the repository at this point in the history
* DayZ Standalone support
* Arma Cold War Assualt support
* Bundle updater
  • Loading branch information
rex706 committed Dec 1, 2016
1 parent 9698adc commit e0ea9ff
Show file tree
Hide file tree
Showing 26 changed files with 228 additions and 107 deletions.
Binary file removed ARMA FOV Changer/ArmA_3_Logo.png
Binary file not shown.
Binary file removed ARMA FOV Changer/ArmA_3_Logo_glow.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ProjectGuid>{B5F384FB-64FE-497C-90B3-5DC5546DDA96}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ARMA_FOV_Changer</RootNamespace>
<AssemblyName>ARMA FOV Changer</AssemblyName>
<RootNamespace>FieldOfViews</RootNamespace>
<AssemblyName>Field of Views</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down Expand Up @@ -107,31 +107,31 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="armaiioa-logo_glow.png" />
<Resource Include="Eye-Visible-512.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="armaiioa-logo.png" />
<Resource Include="a2icon_glow.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="ArmA_3_Logo.png" />
<Resource Include="a2icon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="ArmA_3_Logo_glow.png" />
<Resource Include="a3icon_glow.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Eye-Visible-512.ico" />
<Resource Include="a3icon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="arma_2___icon_by_blagoicons-d9ykomv.png" />
<Resource Include="dayzicon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="arma_2___icon_by_blagoicons-d9ykomv_glow.png" />
<Resource Include="acwaicon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="arma_3___icon_by_blagoicons-d9ykouy.png" />
<Resource Include="acwaicon_glow.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="arma_3___icon_by_blagoicons-d9ykouy_glow.png" />
<Resource Include="dayzicon_glow.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
2 changes: 1 addition & 1 deletion ARMA FOV Changer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ARMA_FOV_Changer"
mc:Ignorable="d"
Title="ArmA FOV Changer" Height="305" Width="478" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" Visibility="Visible" Background="#FFF1F1F1" Icon="Eye-Visible-512.ico" BorderBrush="#FF494949">
Title="Field of Views" Height="305" Width="478" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" Visibility="Visible" Background="#FFF1F1F1" Icon="Eye-Visible-512.ico" BorderBrush="#FF494949">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="29*"/>
Expand Down
98 changes: 65 additions & 33 deletions ARMA FOV Changer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
Expand All @@ -17,13 +18,18 @@ public partial class MainWindow : Window
{
private static Version latest;

private static string fileParams;

private static string profilePath;
private static string[] arrLine;

private int fovTopLine;
private int fovLeftLine;

private static int desiredFov;
private static string fovstring;

private static bool dayz = false;

public MainWindow()
{
Expand All @@ -45,10 +51,7 @@ private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
int idx = AssemblyVersion.LastIndexOf('0') - 1;
AssemblyVersion = AssemblyVersion.Substring(0, idx);
}
catch
{

}
catch { }

// Check for a new version.
int updateResult = await CheckForUpdate();
Expand All @@ -65,8 +68,16 @@ private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
else if (updateResult == 2)
{
// An update is available, and the user has chosen to update.
// TODO: Initiate a process that downloads new updated binaries.
Close();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = true;
startInfo.FileName = "Updater.exe";
startInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = fileParams;

Process.Start(startInfo);
Environment.Exit(0);
}

#endregion
Expand All @@ -85,9 +96,7 @@ private void LoadProfile()
profilePath = splashWindow.filePath;

if (splashWindow.filePath == null)
{
Environment.Exit(0);
}

while (profilePath.Contains(".vars."))
{
Expand All @@ -104,11 +113,18 @@ private void LoadProfile()

string profileName = profilePath.Substring(lastSlashIdx, profNameLength);

// DayZ Standalone only uses vertical fov
if (splashWindow.buttonPressed == 3)
{
fovLeftLabel.IsEnabled = false;
fovLeftLabel_Copy.IsEnabled = false;
DesiredFovLeftTextBox.IsEnabled = false;
dayz = true;
}

// Replace %20 (space char) with an actual space
if (profileName.Contains("%20"))
{
profileName = profileName.Replace("%20", " ");
}

profileLabel.Content = profileName;

Expand All @@ -121,11 +137,8 @@ private void LoadProfile()

// Desired fov to radians
double hfovRad = fovSlider.Value * (Math.PI / 180);

double hFoV = 2 * Math.Atan(Math.Tan(hfovRad / 2) * (SystemParameters.PrimaryScreenHeight / SystemParameters.PrimaryScreenWidth));

hFoV = Math.Ceiling(hFoV * 100) / 100;

DesiredFovTopTextBox.Text = hFoV.ToString();

double wFoV = hFoV / ((int)SystemParameters.PrimaryScreenHeight / nGCD);
Expand All @@ -141,9 +154,15 @@ private void LoadProfile()
// Get info we want from desired lines
arrLine = File.ReadAllLines(profilePath);

if (dayz)
fovstring = "fov";
else
fovstring = "fovTop";

// Find line that controls fov
for(int i = 0; i < arrLine.Length; i++)
{
if (arrLine[i].Contains("fovTop"))
if (arrLine[i].Contains(fovstring))
{
fovTopLine = i;
fovLeftLine = i + 1;
Expand All @@ -163,8 +182,11 @@ private void LoadProfile()
fovLen = fovLeft.IndexOf(";") - eqIdx;
fovLeft = fovLeft.Substring(eqIdx, fovLen);

// Update Labels
CurrentFovTopLabel.Content = fovTop;
CurrentFovLeftLabel.Content = fovLeft;

if (!dayz)
CurrentFovLeftLabel.Content = fovLeft;
}

private static int GetGreatestCommonDivisor(int a, int b)
Expand All @@ -182,20 +204,32 @@ private static async Task<int> CheckForUpdate()
try
{
// Open the text file using a stream reader
using (Stream stream = await client.GetStreamAsync("http://textuploader.com/587m9/raw"))
using (Stream stream = await client.GetStreamAsync("http://textuploader.com/d5ivh/raw"))
{
System.Version current = Assembly.GetExecutingAssembly().GetName().Version;
StreamReader reader = new StreamReader(stream);
latest = System.Version.Parse(reader.ReadToEnd());

if (latest != current)
List<string> newFiles = new List<string>();

while (!reader.EndOfStream)
{
newFiles.Add(await reader.ReadLineAsync());
}

for (int i = 0; i < newFiles.Count; i++)
{
MessageBoxResult answer = MessageBox.Show("A new version of ARMA FOV Changer is available!\n\nCurrent Version " + current + "\nLatest Version " + latest + "\n\nUpdate now?", "ARMA FOV Changer Update", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (i == 0)
fileParams += newFiles[i];
else
fileParams += " " + newFiles[i];
}

if (latest > current)
{
MessageBoxResult answer = MessageBox.Show("A new version of Field of Views is available!\n\nCurrent Version " + current + "\nLatest Version " + latest + "\n\nUpdate now?", "Field of Views Update", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (answer == MessageBoxResult.Yes)
{
//TODO: Later on, remove this and replace with automated process of downloading new binaries.
Process.Start("https://github.com/rex706/ARMA-FOV-Changer/");

//Update is available, and user wants to update. Requires app to close.
return 2;
}
Expand All @@ -216,17 +250,19 @@ private static async Task<int> CheckForUpdate()
#region Object Click Events

private void saveButton_Click(object sender, RoutedEventArgs e)
{
arrLine[fovTopLine] = "fovTop=" + DesiredFovTopTextBox.Text + ";";
arrLine[fovLeftLine] = "fovLeft=" + DesiredFovLeftTextBox.Text + ";";
{
arrLine[fovTopLine] = fovstring + "=" + DesiredFovTopTextBox.Text + ";";
if (!dayz)
arrLine[fovLeftLine] = "fovLeft=" + DesiredFovLeftTextBox.Text + ";";

try
{
// Write back to file
File.WriteAllLines(profilePath, arrLine);

CurrentFovTopLabel.Content = DesiredFovTopTextBox.Text;
CurrentFovLeftLabel.Content = DesiredFovLeftTextBox.Text;
if (!dayz)
CurrentFovLeftLabel.Content = DesiredFovLeftTextBox.Text;
}
catch (Exception m)
{
Expand All @@ -249,13 +285,9 @@ private void ExitMenuItem_Click(object sender, RoutedEventArgs e)
private void fovSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if(heightTextBox != null && widthTextBox != null && heightTextBox.Text.Length > 2 && widthTextBox.Text.Length > 2)
{
refreshMath();
}
else
{
Console.WriteLine("Not enough input!");
}
}

private void refreshMath()
Expand Down Expand Up @@ -284,23 +316,23 @@ private void refreshMath()

private void ProfileMenuItem_Click(object sender, RoutedEventArgs e)
{
fovLeftLabel.IsEnabled = true;
fovLeftLabel_Copy.IsEnabled = true;
DesiredFovLeftTextBox.IsEnabled = true;
dayz = false;
LoadProfile();
}

private void widthTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
if (Regex.IsMatch(widthTextBox.Text, @"^\d+$") && widthTextBox.Text.Length > 2 && Regex.IsMatch(widthTextBox.Text, @"^\d+$") && heightTextBox.Text.Length > 2)
{
refreshMath();
}
}

private void heightTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
if (Regex.IsMatch(widthTextBox.Text, @"^\d+$") && heightTextBox.Text.Length > 2 && Regex.IsMatch(widthTextBox.Text, @"^\d+$") && widthTextBox.Text.Length > 2)
{
refreshMath();
}
}
}
}
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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
44 changes: 18 additions & 26 deletions ARMA FOV Changer/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e0ea9ff

Please sign in to comment.