Skip to content

Commit

Permalink
Renamed ConfigManager as SettingsManager.
Browse files Browse the repository at this point in the history
Renamed Config.cs as SettingsReader.cs.
Initial work done for bonesoul/voxeliq#45.
  • Loading branch information
Hüseyin Uslu committed Jan 15, 2013
1 parent ac8b7e4 commit d36333d
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 33 deletions.
4 changes: 0 additions & 4 deletions assets/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ Enabled = false;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; General logging settings
[Logging]
Root=logs

; Settings for console logger
[ConsoleLog]
Enabled=true
Expand Down
10 changes: 5 additions & 5 deletions src/Engine/Common/Logging/FileTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace VoxeliqEngine.Common.Logging
/// </summary>
public class FileTarget : LogTarget, IDisposable
{
private const string LogRoot = "logs";

private readonly string _fileName; // log-file's filename.
private readonly string _filePath; // log-file's full path.
private FileStream _fileStream; // filestream pointing to logfile.
Expand All @@ -30,16 +32,14 @@ public class FileTarget : LogTarget, IDisposable
/// <param name="reset">Reset log file on application startup?</param>
public FileTarget(string fileName, Logger.Level minLevel, Logger.Level maxLevel, bool includeTimeStamps, bool reset = false)
{
var logRoot = "logs";

this.MinimumLevel = minLevel;
this.MaximumLevel = maxLevel;
this.IncludeTimeStamps = includeTimeStamps;
this._fileName = fileName;
this._filePath = string.Format("{0}/{1}", logRoot, _fileName); // construct the full path using LoggingRoot defined in config.ini
this._filePath = string.Format("{0}/{1}", LogRoot, _fileName); // construct the full path using LoggingRoot defined in config.ini

if (!Directory.Exists(logRoot)) // create logging directory if it does not exist yet.
Directory.CreateDirectory(logRoot);
if (!Directory.Exists(LogRoot)) // create logging directory if it does not exist yet.
Directory.CreateDirectory(LogRoot);

this._fileStream = new FileStream(_filePath, reset ? FileMode.Create : FileMode.Append, FileAccess.Write, FileShare.Read); // init the file stream.
this._logStream = new StreamWriter(this._fileStream) { AutoFlush = true }; // init the stream writer.
Expand Down
1 change: 1 addition & 0 deletions src/Engine/Core/Config/EngineConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public EngineConfig()
/// <returns></returns>
internal bool Validate()
{
// valide all the subconfigurations.
if (!this.Chunk.Validate())
return false;

Expand Down
3 changes: 0 additions & 3 deletions src/game/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ private static void Main(string[] args)

InitLoggers(); // init logging facility.

// print version information.
var frameworkVersion = Assembly.GetAssembly(typeof(Microsoft.Xna.Framework.Game)).GetName().Version;

Logger.Info("voxeliq v{0} warming-up..", Assembly.GetAssembly(typeof (Player)).GetName().Version);
Logger.Info(string.Format("Using framework {0} over {1}.", VersionInfo.GameFramework, VersionInfo.GraphicsApi));

Expand Down
2 changes: 1 addition & 1 deletion src/game/Settings/Readers/AudioSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace VoxeliqGame.Settings.Readers
{
public sealed class AudioSettings : Config
public sealed class AudioSettings : SettingsReader
{
/// <summary>
/// Is audio enabled?
Expand Down
2 changes: 1 addition & 1 deletion src/game/Settings/Readers/GraphicsSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace VoxeliqGame.Settings.Readers
{
public sealed class GraphicsSettings : Config
public sealed class GraphicsSettings : SettingsReader
{
/// <summary>
/// Sets the screen width.
Expand Down
13 changes: 2 additions & 11 deletions src/game/Settings/Readers/LogSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,8 @@ namespace VoxeliqGame.Settings.Readers
/// <summary>
/// Holds configuration info for log manager.
/// </summary>
public sealed class LogSettings : Config
public sealed class LogSettings : SettingsReader
{
/// <summary>
/// Gets or sets the logging root.
/// </summary>
public string LoggingRoot
{
get { return this.GetString("Root", @"logs"); }
set { this.Set("Root", value); }
}

/// <summary>
/// Available log target configs.
/// </summary>
Expand Down Expand Up @@ -53,7 +44,7 @@ private LogSettings() :
/// <summary>
/// Holds configuration of a log target.
/// </summary>
public class LogTargetConfig : Config
public class LogTargetConfig : SettingsReader
{
/// <summary>
/// Is enabled?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

namespace VoxeliqGame.Settings
{
public sealed class ConfigManager
public sealed class SettingsManager
{
private static readonly Logger Logger = LogManager.CreateLogger();
private static readonly IniConfigSource Parser; // the ini parser.
private static readonly string ConfigFile;
private static bool _fileExists = false; // does the ini file exists?

static ConfigManager()
static SettingsManager()
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@

namespace VoxeliqGame.Settings
{
public class Config
public class SettingsReader
{
private readonly IConfig _section;

public Config(string sectionName)
public SettingsReader(string sectionName)
{
this._section = ConfigManager.Section(sectionName) ?? ConfigManager.AddSection(sectionName);
this._section = SettingsManager.Section(sectionName) ?? SettingsManager.AddSection(sectionName);
}

public void Save()
{
ConfigManager.Save();
SettingsManager.Save();
}

protected bool GetBoolean(string key, bool defaultValue) { return this._section.GetBoolean(key, defaultValue); }
Expand Down
4 changes: 2 additions & 2 deletions src/game/VoxeliqGame.Windows.XNA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Settings\Readers\AudioSettings.cs" />
<Compile Include="Settings\Config.cs" />
<Compile Include="Settings\ConfigManager.cs" />
<Compile Include="Settings\SettingsReader.cs" />
<Compile Include="Settings\SettingsManager.cs" />
<Compile Include="Settings\Readers\GraphicsSettings.cs" />
<Compile Include="Settings\Readers\LogSettings.cs" />
<Compile Include="SampleGame.cs" />
Expand Down

0 comments on commit d36333d

Please sign in to comment.