Skip to content

Commit

Permalink
Added UsingCo8 handling to Configurator ( fixes #201 )
Browse files Browse the repository at this point in the history
  • Loading branch information
DudeMcDude committed Apr 2, 2016
1 parent 52174f9 commit 9894830
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
32 changes: 29 additions & 3 deletions Configurator/IniViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public class IniViewModel : DependencyObject
"PointBuyPoints", typeof (int), typeof (IniViewModel), new PropertyMetadata(default(int)));

public static readonly DependencyProperty MaxLevelProperty = DependencyProperty.Register(
"MaxLevel", typeof(int), typeof(IniViewModel), new PropertyMetadata(default(int)));
"MaxLevel", typeof(int), typeof(IniViewModel), new PropertyMetadata(default(int)));

public static readonly DependencyProperty UsingCo8Property = DependencyProperty.Register(
"UsingCo8", typeof(bool), typeof(IniViewModel), new PropertyMetadata(default(bool)));

public IEnumerable<HpOnLevelUpType> HpOnLevelUpTypes => Enum.GetValues(typeof (HpOnLevelUpType))
.Cast<HpOnLevelUpType>();
Expand All @@ -49,8 +52,14 @@ public IniViewModel()

public string InstallationPath
{
get { return (string) GetValue(InstallationPathProperty); }
set { SetValue(InstallationPathProperty, value); }
get
{
return (string) GetValue(InstallationPathProperty);
}
set
{
SetValue(InstallationPathProperty, value);
}
}

public int RenderWidth
Expand Down Expand Up @@ -101,10 +110,24 @@ public int MaxLevel
set { SetValue(MaxLevelProperty, value); }
}

public bool UsingCo8
{
get
{
return (bool)GetValue(UsingCo8Property);
}
set
{
SetValue(UsingCo8Property, value);
}
}

public void LoadFromIni(IniData iniData)
{
var tpData = iniData["TemplePlus"];
InstallationPath = tpData["toeeDir"];
UsingCo8 = tpData["usingCo8"] == "true";

DisableAutomaticUpdates = tpData["autoUpdate"] != "true";
if (tpData["hpOnLevelup"] != null)
{
Expand Down Expand Up @@ -153,6 +176,8 @@ public void LoadFromIni(IniData iniData)
{
MaxLevel = maxLevel;
}


}

public void SaveToIni(IniData iniData)
Expand Down Expand Up @@ -186,6 +211,7 @@ public void SaveToIni(IniData iniData)
tpData["windowHeight"] = RenderHeight.ToString();
tpData["softShadows"] = SoftShadows ? "true" : "false";
tpData["maxLevel"] = MaxLevel.ToString();
tpData["usingCo8"] = UsingCo8 ? "true": "false";
}
}

Expand Down
15 changes: 15 additions & 0 deletions Configurator/InstallationDir.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ namespace TemplePlusConfig
/// </summary>
public partial class InstallationDir : UserControl
{
public static readonly DependencyProperty UsingCo8Property = DependencyProperty.Register(
"UsingCo8", typeof(bool), typeof(InstallationDir), new PropertyMetadata(default(bool)));

public static readonly DependencyProperty InstallationPathProperty = DependencyProperty.Register(
"InstallationPath", typeof (string), typeof (InstallationDir), new PropertyMetadata(default(string)));

public static readonly DependencyProperty InstallationPathStatusProperty = DependencyProperty.Register(
"InstallationPathStatus", typeof (InstallationDirStatus), typeof (InstallationDir),
new PropertyMetadata(default(InstallationDirStatus)));




public InstallationDir()
{
InitializeComponent();
Expand All @@ -38,6 +44,15 @@ public InstallationDirStatus InstallationPathStatus
set { SetValue(InstallationPathStatusProperty, value); }
}

public bool UsingCo8
{
get
{
return (bool)(InstallationPathStatus.IsCo8);
}
set { InstallationPathStatus.IsCo8= value; }
}

private void RevalidateInstallationDir()
{
InstallationPathStatus = InstallationDirValidator.Validate(InstallationPath);
Expand Down
7 changes: 5 additions & 2 deletions Configurator/InstallationDirValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ public static InstallationDirStatus Validate(string path)
+ dllVersion.Description);
}

return new InstallationDirStatus {Valid = true, Status = dllVersion.Description};
return new InstallationDirStatus {Valid = true, Status = dllVersion.Description, IsCo8 = dllVersion.Co8};
}

private static InstallationDirStatus CreateInvalid(string reason)
{
return new InstallationDirStatus
{
Valid = false,
Status = reason
Status = reason,
IsCo8 = false
};
}
}
Expand All @@ -65,5 +66,7 @@ public class InstallationDirStatus
public bool Valid { get; set; }

public string Status { get; set; }

public bool IsCo8 { get; set; }
}
}
2 changes: 1 addition & 1 deletion Configurator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Button x:Name="OkButton" Width="75" Height="23" Click="Button_Click" VerticalAlignment="Top">Ok</Button>
</Grid>
<StackPanel Margin="10,10,10,10">
<local:InstallationDir x:Name="InstallationDir" InstallationPath="{Binding InstallationPath}" />
<local:InstallationDir x:Name="InstallationDir" InstallationPath="{Binding InstallationPath}" UsingCo8="{Binding UsingCo8}" />
<TextBlock TextWrapping="Wrap" Text="Select resolution:"/>
<StackPanel Orientation="Horizontal" Margin="0,5,0,5" ToolTip="Please select the resolution at which the game should render. It will automatically be upscaled to your screen resolution. The aspect ratio of your monitor will be respected.">
<Label VerticalAlignment="Center">Width</Label>
Expand Down
1 change: 1 addition & 0 deletions Configurator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private void Button_Click(object sender, RoutedEventArgs e)

// TODO: Check why two-way binding in this particular case is not working
_iniViewModel.InstallationPath = InstallationDir.InstallationPath;
_iniViewModel.UsingCo8 = InstallationDir.UsingCo8;
_iniViewModel.SaveToIni(iniData);

// Disable BOM otherwise TP barfs when loading the ini
Expand Down

0 comments on commit 9894830

Please sign in to comment.