Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Junction Lane Arrows Editor rework with preview #391

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
beb0abe
WIP experimental world space canvas
kvakvs Jun 23, 2019
5104c2f
UI creation in world space
kvakvs Jun 24, 2019
d136b7e
Buttons are now clickable, but no animations and no texture updates
kvakvs Jun 24, 2019
fd433a9
Fixed 'cursor in secondary panel' for nicer behaviour
kvakvs Jun 24, 2019
4f1ef13
Lane control buttons one per lane in the ground plane
kvakvs Jun 25, 2019
c1a1f87
Lane arrows look better and work
kvakvs Jun 26, 2019
c30a19e
For a single lane, open arrow buttons right away
kvakvs Jun 26, 2019
a3bdc6f
Calculate possible turn directions, and disable the lane arrow buttons
kvakvs Jun 26, 2019
186ea33
Better graphics for lane arrow buttons; Sprite handling improved; Ren…
kvakvs Jun 26, 2019
6a08ac7
Load and set shader (WIP)
kvakvs Jun 26, 2019
2e0f57b
Speed Limits textures into their own sub-struct in TextureResources
kvakvs Jun 27, 2019
99b4716
ESC hides the UI correctly
kvakvs Jun 27, 2019
026a041
Outgoing lanes are displayed in bright green
kvakvs Jun 28, 2019
5e2395f
Darker off arrows in lane arrows GUI
kvakvs Jul 2, 2019
5711587
Untabify, place texture loader and lane arrow tool into their own dirs
kvakvs Jul 2, 2019
3e0bdc5
Mass untabify for UI modules
kvakvs Jul 2, 2019
3069fb3
Detect inverted tangents and correct them for UI orientation
kvakvs Jul 2, 2019
f538338
Lane arrows now edit the whole junction
kvakvs Jul 4, 2019
07f7805
Lane Arrows tool has a state machine now and no buttons, click on the…
kvakvs Jul 6, 2019
7e59acb
Lane clicking works in Lane Arrows mode
kvakvs Jul 6, 2019
e25a66e
Accept other node click in Outgoing mode; Allow only segments which b…
kvakvs Jul 6, 2019
16c7e8f
Hovering a lane in incoming select mode, will show allowed turns as c…
kvakvs Jul 7, 2019
ce56049
Lane can be hovered only within 50m from its end; Correct unhovering
kvakvs Jul 7, 2019
8271c42
Moved SpeedLimits texture accessors into their texture class
kvakvs Jul 7, 2019
3610f0a
Using lane curves to display turns
kvakvs Jul 7, 2019
ba6228a
Use World helper more
kvakvs Jul 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
110 changes: 54 additions & 56 deletions TLM/CSUtil.Commons/Log.cs
@@ -1,67 +1,65 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
using UnityEngine;
namespace CSUtil.Commons {
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using UnityEngine;

namespace CSUtil.Commons {
public static class Log {
private enum LogLevel {
Debug,
Info,
Warning,
Error
}

public static class Log {
private enum LogLevel {
Debug,
Info,
Warning,
Error
}
private static object logLock = new object();

private static object logLock = new object();
private static string logFilename = Path.Combine(Application.dataPath, "TMPE.log"); // TODO refactor log filename to configuration
private static Stopwatch sw = Stopwatch.StartNew();

private static string logFilename = Path.Combine(Application.dataPath, "TMPE.log"); // TODO refactor log filename to configuration
private static Stopwatch sw = Stopwatch.StartNew();
static Log() {
try {
if (File.Exists(logFilename)) {
File.Delete(logFilename);
}
} catch (Exception) {

static Log() {
try {
if (File.Exists(logFilename)) {
File.Delete(logFilename);
}
} catch (Exception) {

}
}
}
}

[Conditional("DEBUG")]
public static void _Debug(string s) {
LogToFile(s, LogLevel.Debug);
}
[Conditional("DEBUG")]
public static void _Debug(string s) {
LogToFile(s, LogLevel.Debug);
}

public static void Info(string s) {
LogToFile(s, LogLevel.Info);
}
public static void Info(string s) {
LogToFile(s, LogLevel.Info);
}

public static void Warning(string s) {
LogToFile(s, LogLevel.Warning);
}
public static void Warning(string s) {
LogToFile(s, LogLevel.Warning);
}

public static void Error(string s) {
LogToFile(s, LogLevel.Error);
}
public static void Error(string s) {
LogToFile(s, LogLevel.Error);
}

private static void LogToFile(string log, LogLevel level) {
try {
Monitor.Enter(logLock);

using (StreamWriter w = File.AppendText(logFilename)) {
w.WriteLine($"[{level.ToString()}] @ {sw.ElapsedTicks} {log}");
if (level == LogLevel.Warning || level == LogLevel.Error) {
w.WriteLine((new System.Diagnostics.StackTrace()).ToString());
w.WriteLine();
}
}
} finally {
Monitor.Exit(logLock);
}
}
}
private static void LogToFile(string log, LogLevel level) {
try {
Monitor.Enter(logLock);

}
using (StreamWriter w = File.AppendText(logFilename)) {
w.WriteLine($"[{level.ToString()}] @ {sw.ElapsedTicks} {log}");
if (level == LogLevel.Warning || level == LogLevel.Error) {
w.WriteLine((new System.Diagnostics.StackTrace()).ToString());
w.WriteLine();
}
}
} finally {
Monitor.Exit(logLock);
}
}
}

}
21 changes: 9 additions & 12 deletions TLM/TLM/Geometry/ISegmentEndId.cs
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TrafficManager.Geometry {
using System;

namespace TrafficManager.Geometry {
public interface ISegmentEndId : IEquatable<ISegmentEndId> {
// TODO documentation
ushort SegmentId { get; }
bool StartNode { get; }
public interface ISegmentEndId : IEquatable<ISegmentEndId> {
// TODO documentation
ushort SegmentId { get; }
bool StartNode { get; }

bool Relocate(ushort segmentId, bool startNode);
}
}
bool Relocate(ushort segmentId, bool startNode);
}
}
6 changes: 5 additions & 1 deletion TLM/TLM/LoadingExtension.cs
Expand Up @@ -2539,6 +2539,8 @@ public class Detour {

public override void OnLevelUnloading() {
Log.Info("OnLevelUnloading");
World.TearDown();

base.OnLevelUnloading();
if (IsPathManagerReplaced) {
CustomPathManager._instance.WaitForAllPaths();
Expand Down Expand Up @@ -2698,7 +2700,7 @@ public class Detour {

// add "remove citizen instance" button
UIView.GetAView().gameObject.AddComponent<RemoveCitizenInstanceButtonExtender>();

initDetours();

//Log.Info("Fixing non-created nodes with problems...");
Expand All @@ -2713,6 +2715,8 @@ public class Detour {
//InitTool();
//Log._Debug($"Current tool: {ToolManager.instance.m_properties.CurrentTool}");

World.Setup();

Log.Info("OnLevelLoaded complete.");
}

Expand Down