Skip to content

Commit

Permalink
chore: replaced broken loading bars (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
sargeantPig authored Jan 4, 2024
1 parent 0e7998f commit 6084921
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
4 changes: 2 additions & 2 deletions RTWLibPlus/helpers/FileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public static string GetPartOfPath(string path, string from)
return "";
}

string[] split = path.Split('\\');
string[] split = path.Split('\\', '/');

string[] arr = split.GetItemsFromFirstOf(from.GetHashCode());

string str = ConstructPath(arr);
return string.Format("..\\{0}", str);
return string.Format("../{0}", str);


}
Expand Down
2 changes: 0 additions & 2 deletions RTWLibPlus/map/voronoi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ private static void StealSettlement(List<string[]> groups, int emptyGroupInd)
if (groups[i].Length > 2)
{
string temp = groups[i][^1];
Console.WriteLine("city to add " + temp);
groups[emptyGroupInd] = groups[emptyGroupInd].Add(temp);
Console.WriteLine(groups[emptyGroupInd][0]);
groups[i] = groups[i].Remove(groups[i].Length - 1);
break;
}
Expand Down
8 changes: 5 additions & 3 deletions RTWLib_CLI/cmd/cmdProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ public static string ReadCMD(string cmd, Type type = null)
public static string ProcessTemplate(string template)
{
string[] cmds = templates[template];
Progress p = new(1f / cmds.Length, "Running: " + template);
Console.WriteLine("Running: " + template);
//Progress p = new(1f / cmds.Length, "Running: " + template);
foreach (string cmd in cmds)
{
p.Message("Doing: " + cmd);
Console.WriteLine("Doing: " + cmd);
//p.Message("Doing: " + cmd);
ReadCMD(cmd);
p.Update("Complete");
//p.Update("Complete");
}
return "template finished processing";
}
Expand Down
19 changes: 12 additions & 7 deletions RTWLib_CLI/cmd/modules/randomiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using RTWLibPlus.interfaces;
using RTWLibPlus.map;
using RTWLibPlus.randomiser;
using System;
using System.Collections.Generic;

public class RandCMD
Expand Down Expand Up @@ -84,19 +85,22 @@ public string InitialSetup()
{

List<IWrapper> list = new() { this.edu, this.edb, this.ds, this.dr, this.smf, this.mr, this.bm };
Progress p = new(1f / (list.Count + 1), "Setting up");
Console.WriteLine("Setting up");
//Progress p = new(1f / (list.Count + 1), "Setting up");
for (int i = 0; i < list.Count; i++)
{

list[i].Clear();
p.Message("Loading: " + RFH.GetPartOfPath(list[i].LoadPath, "randomiser"));
Console.WriteLine("Loading: " + RFH.GetPartOfPath(list[i].LoadPath, "randomiser"));
//p.Message("Loading: " + RFH.GetPartOfPath(list[i].LoadPath, "randomiser"));
list[i].Parse();
p.Update("Complete");
//p.Update("Complete");
}
this.edu.PrepareEDU();
this.cm = new CityMap(this.mr, this.dr);
p.Message("Forming: City Map");
p.Update("Complete");
Console.WriteLine("Forming: City Map");
//p.Message("Forming: City Map");
//p.Update("Complete");

return "Files Loaded";
}
Expand All @@ -106,11 +110,12 @@ public string Output()
string path = string.Empty;

List<IWrapper> list = new() { this.edu, this.ds };
Progress p = new(0.50f, "Writing Files");
Console.WriteLine("Writing Files...");
//Progress p = new(0.50f, "Writing Files");
for (int i = 0; i < list.Count; i++)
{
list[i].Output();
p.Update();
//p.Update();
}

if (this.edu != null)
Expand Down
10 changes: 10 additions & 0 deletions RTWLib_Tests/helper/Tests_String.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace RTWLib_Tests.helper;

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RTWLibPlus.helpers;

Expand All @@ -24,4 +25,13 @@ public void FirstWordRemoved()
Assert.AreEqual(expected, result);
}

// [TestMethod]
// public void PartOfPath()
// {
// string test2 = Environment.CurrentDirectory;
// string test = "drive\\path\\long\\this\\something\\randomiser\\files\\somefile.txt";
// string result = RFH.GetPartOfPath(test, "randomiser");
// Assert.AreEqual("../randomiser/files/somefile.txt", result);
// }

}

0 comments on commit 6084921

Please sign in to comment.