Skip to content

Commit

Permalink
Added "OverviewerGUI.ini" This will store your most recent paths.
Browse files Browse the repository at this point in the history
In the future will store settings. :)
  • Loading branch information
but2002 committed Mar 22, 2012
1 parent 69c7331 commit f9f35fd
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 7 deletions.
66 changes: 66 additions & 0 deletions INI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.IO;

namespace Ini
{
/// <summary>
/// Create a New INI file to store or load data
/// </summary>
public class IniFile
{
public string path;

[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,
string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section,
string key, string def, StringBuilder retVal,
int size, string filePath);

/// <summary>
/// INIFile Constructor.
/// </summary>
/// <PARAM name="INIPath"></PARAM>
public IniFile(string INIPath)
{
path = INIPath;
if (!File.Exists(path))
{
var configFile = File.Create(path);
configFile.Close();
}
}
/// <summary>
/// Write Data to the INI File
/// </summary>
/// <PARAM name="Section"></PARAM>
/// Section name
/// <PARAM name="Key"></PARAM>
/// Key Name
/// <PARAM name="Value"></PARAM>
/// Value Name
public void IniWriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, this.path);
}

/// <summary>
/// Read Data Value From the Ini File
/// </summary>
/// <PARAM name="Section"></PARAM>
/// <PARAM name="Key"></PARAM>
/// <PARAM name="Path"></PARAM>
/// <returns></returns>
public string IniReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp,
255, this.path);
return temp.ToString();

}
}
}
21 changes: 20 additions & 1 deletion MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Diagnostics;
using System.IO;
using System.Net;
using Ini;


namespace OverviewerGUI
Expand All @@ -23,6 +24,7 @@ public partial class MainWindow : Form
private Process proc = new Process();
private Boolean haltedRender = false;
private Boolean windowExpanded = false;
private IniFile configuration = new IniFile(".\\OverviewerGUI.ini");
private String[] splashes = {
"Can't track the killers IP!",
"CLOOOOOOOUD",
Expand Down Expand Up @@ -107,8 +109,23 @@ private void MainWindow_Load(object sender, EventArgs e)
// Redirect the out Console stream
Console.SetOut(_writer);
Console.WriteLine("Now redirecting output to the text box");

this.Text = "Overviewer GUI - " + getSplash();

//Configuration initialization
var configWorldPath = configuration.IniReadValue("Paths", "worldDir");
var configOutPath = configuration.IniReadValue("Paths", "outDir");
if (configWorldPath != "" && configWorldPath != null) {
worldFolder.Text = configWorldPath;
worldDir = configWorldPath;
}

if (configOutPath != "" && configOutPath != null)
{
outputFolder.Text = configOutPath;
outDir = configOutPath;
}


}

private void buttonLevelBrowse_Click(object sender, EventArgs e)
Expand All @@ -119,6 +136,7 @@ private void buttonLevelBrowse_Click(object sender, EventArgs e)
{
worldFolder.Text = LevelDialog.SelectedPath;
worldDir = LevelDialog.SelectedPath;
configuration.IniWriteValue("Paths", "worldDir", LevelDialog.SelectedPath);
}
}

Expand All @@ -130,6 +148,7 @@ private void buttonDirBrowse_Click(object sender, EventArgs e)
{
outputFolder.Text = outputDir.SelectedPath;
outDir = outputDir.SelectedPath;
configuration.IniWriteValue("Paths", "outDir", outputDir.SelectedPath);
}
}

Expand Down
1 change: 1 addition & 0 deletions OverviewerGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ConsoleRedirect.cs" />
<Compile Include="INI.cs" />
<Compile Include="MainWindow.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
Binary file modified OverviewerGUI.suo
Binary file not shown.
6 changes: 0 additions & 6 deletions gitpush.sh

This file was deleted.

0 comments on commit f9f35fd

Please sign in to comment.