Skip to content

Commit

Permalink
Detecting if ZEN selected to run is not exists (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Szmyk committed Jul 28, 2018
1 parent 5e73a36 commit 98f612a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/gmbt/src/Test.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;

namespace GMBT
{
Expand Down Expand Up @@ -52,11 +53,35 @@ protected override void runHooks(HookType hookType, HookEvent hookEvent)
}
}

public void DetectIfWorldIsNotExists()
{
var worlds = Directory.GetFiles(gothic.GetGameDirectory(Gothic.GameDirectory.Worlds), "*.ZEN", SearchOption.AllDirectories).ToList();

foreach(var dir in Program.Config.ModFiles.Assets)
{
var worldsDir = Path.Combine(dir, "Worlds");

if (Directory.Exists(worldsDir))
{
worlds.AddRange(Directory.GetFiles(worldsDir, "*.ZEN", SearchOption.AllDirectories).ToList());
}
}

var world = Program.Options.TestVerb.World ?? Program.Config.ModFiles.DefaultWorld;

if (worlds.Where(x => Path.GetFileName(x) == Path.GetFileName(world)).Count() < 1)
{
Program.Logger.Fatal("Config.Error.FileDidNotFound".Translate(world));
}
}

/// <summary>
/// Starts test.
/// </summary>
public override void Start()
{
DetectIfWorldIsNotExists();

if (Program.Options.TestVerb.Merge != Merge.MergeOptions.None)
{
runHooks(HookType.Pre, HookEvent.AssetsMerge);
Expand Down

0 comments on commit 98f612a

Please sign in to comment.