Code cleanup.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -66,7 +66,7 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
var coverFile = item.GetFiles(meta.cover);
|
var coverFile = item.GetFiles(meta.cover);
|
||||||
if (coverFile.Length > 0) {
|
if (coverFile.Length > 0) {
|
||||||
cover = new AsyncDelivery<Texture2D>();
|
cover = new AsyncDelivery<Texture2D>();
|
||||||
var task = new LoadTextureTask(Game.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
var task = new LoadTextureTask(PlatformConfig.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
||||||
cover.CancelSource = task.Cancel;
|
cover.CancelSource = task.Cancel;
|
||||||
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
var coverFile = item.GetFiles(meta.cover);
|
var coverFile = item.GetFiles(meta.cover);
|
||||||
if (coverFile.Length > 0) {
|
if (coverFile.Length > 0) {
|
||||||
cover = new AsyncDelivery<Texture2D>();
|
cover = new AsyncDelivery<Texture2D>();
|
||||||
var task = new LoadTextureTask(Game.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
var task = new LoadTextureTask(PlatformConfig.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
||||||
cover.CancelSource = task.Cancel;
|
cover.CancelSource = task.Cancel;
|
||||||
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#define BUILD
|
|
||||||
|
|
||||||
using Cryville.Common;
|
using Cryville.Common;
|
||||||
using Cryville.Common.Buffers;
|
using Cryville.Common.Buffers;
|
||||||
using Cryville.Crtr.Config;
|
using Cryville.Crtr.Config;
|
||||||
@@ -82,7 +80,6 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
status = GameObject.Find("Status").GetComponent<TextMeshProUGUI>();
|
status = GameObject.Find("Status").GetComponent<TextMeshProUGUI>();
|
||||||
|
|
||||||
#if BUILD
|
|
||||||
try {
|
try {
|
||||||
Play();
|
Play();
|
||||||
}
|
}
|
||||||
@@ -91,7 +88,6 @@ namespace Cryville.Crtr {
|
|||||||
Popup.CreateException(ex);
|
Popup.CreateException(ex);
|
||||||
ReturnToMenu();
|
ReturnToMenu();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Camera.main.RenderToCubemap();
|
// Camera.main.RenderToCubemap();
|
||||||
}
|
}
|
||||||
@@ -186,9 +182,7 @@ namespace Cryville.Crtr {
|
|||||||
Logger.Log("main", 4, "Load/MainThread", "Load failed");
|
Logger.Log("main", 4, "Load/MainThread", "Load failed");
|
||||||
loadThread = null;
|
loadThread = null;
|
||||||
Popup.CreateException(threadException);
|
Popup.CreateException(threadException);
|
||||||
#if BUILD
|
|
||||||
ReturnToMenu();
|
ReturnToMenu();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (texloaddone) {
|
else if (texloaddone) {
|
||||||
if (texLoader == null) Stop();
|
if (texLoader == null) Stop();
|
||||||
@@ -377,7 +371,7 @@ namespace Cryville.Crtr {
|
|||||||
areaJudgePrecision = 1 << Settings.Default.AreaJudgePrecision;
|
areaJudgePrecision = 1 << Settings.Default.AreaJudgePrecision;
|
||||||
forceSyncFrames = Settings.Default.ForceSyncFrames;
|
forceSyncFrames = Settings.Default.ForceSyncFrames;
|
||||||
texloaddone = false;
|
texloaddone = false;
|
||||||
Game.NetworkTaskWorker.SuspendBackgroundTasks();
|
Game.SuspendBackgroundTasks();
|
||||||
Game.AudioSession = Game.AudioSequencer.NewSession();
|
Game.AudioSession = Game.AudioSequencer.NewSession();
|
||||||
|
|
||||||
var hitPlane = new Plane(Vector3.forward, Vector3.zero);
|
var hitPlane = new Plane(Vector3.forward, Vector3.zero);
|
||||||
@@ -455,7 +449,7 @@ namespace Cryville.Crtr {
|
|||||||
for (int i = 0; i < queue.Count; i++) {
|
for (int i = 0; i < queue.Count; i++) {
|
||||||
#if UNITY_5_4_OR_NEWER
|
#if UNITY_5_4_OR_NEWER
|
||||||
texHandler = new DownloadHandlerTexture();
|
texHandler = new DownloadHandlerTexture();
|
||||||
texLoader = new UnityWebRequest(Game.FileProtocolPrefix + queue[i], "GET", texHandler, null);
|
texLoader = new UnityWebRequest(PlatformConfig.FileProtocolPrefix + queue[i], "GET", texHandler, null);
|
||||||
texLoader.SendWebRequest();
|
texLoader.SendWebRequest();
|
||||||
#else
|
#else
|
||||||
texLoader = new WWW(Game.FileProtocolPrefix + queue[i]);
|
texLoader = new WWW(Game.FileProtocolPrefix + queue[i]);
|
||||||
@@ -568,10 +562,8 @@ namespace Cryville.Crtr {
|
|||||||
started = false;
|
started = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Game.NetworkTaskWorker.ResumeBackgroundTasks();
|
Game.ResumeBackgroundTasks();
|
||||||
#if BUILD
|
|
||||||
ReturnToMenu();
|
ReturnToMenu();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnSettingsUpdate() {
|
void OnSettingsUpdate() {
|
||||||
@@ -588,11 +580,9 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Exception threadException;
|
Exception threadException;
|
||||||
#if !NO_THREAD
|
|
||||||
Thread loadThread = null;
|
Thread loadThread = null;
|
||||||
volatile float loadPregress;
|
volatile float loadPregress;
|
||||||
Stopwatch workerTimer;
|
Stopwatch workerTimer;
|
||||||
#endif
|
|
||||||
void Load(object _info) {
|
void Load(object _info) {
|
||||||
var info = (LoadInfo)_info;
|
var info = (LoadInfo)_info;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -22,14 +22,6 @@ namespace Cryville.Crtr {
|
|||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
public static readonly string FileProtocolPrefix
|
|
||||||
#if UNITY_STANDALONE_WIN
|
|
||||||
= "file:///";
|
|
||||||
#elif UNITY_ANDROID
|
|
||||||
= "file://";
|
|
||||||
#else
|
|
||||||
#error No file protocol prefix is defined.
|
|
||||||
#endif
|
|
||||||
public static IAudioDeviceManager AudioManager;
|
public static IAudioDeviceManager AudioManager;
|
||||||
public static AudioClient AudioClient;
|
public static AudioClient AudioClient;
|
||||||
public static SimpleSequencerSource AudioSequencer;
|
public static SimpleSequencerSource AudioSequencer;
|
||||||
@@ -129,19 +121,10 @@ namespace Cryville.Crtr {
|
|||||||
Settings.Default.Save();
|
Settings.Default.Save();
|
||||||
|
|
||||||
Logger.Log("main", 1, "UI", "Initializing font manager");
|
Logger.Log("main", 1, "UI", "Initializing font manager");
|
||||||
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
|
TMPAutoFont.FontMatcher = new FallbackListFontMatcher(PlatformConfig.FontManager) {
|
||||||
var fontMatcher = new FallbackListFontMatcher(new FontManagerWindows());
|
MapScriptToTypefaces = PlatformConfig.ScriptFontMap
|
||||||
fontMatcher.LoadDefaultWindowsFallbackList();
|
};
|
||||||
TMPAutoFont.FontMatcher = fontMatcher;
|
TMPAutoFont.DefaultShader = Resources.Load<Shader>(PlatformConfig.TextShader);
|
||||||
TMPAutoFont.DefaultShader = Resources.Load<Shader>("TextMesh Pro/Shaders/TMP_SDF SSD");
|
|
||||||
#elif UNITY_ANDROID
|
|
||||||
var fontMatcher = new FallbackListFontMatcher(new FontManagerAndroid());
|
|
||||||
fontMatcher.LoadDefaultAndroidFallbackList();
|
|
||||||
TMPAutoFont.FontMatcher = fontMatcher;
|
|
||||||
TMPAutoFont.DefaultShader = Resources.Load<Shader>("TextMesh Pro/Shaders/TMP_SDF-Mobile SSD");
|
|
||||||
#else
|
|
||||||
#error No font manager initialization logic.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Logger.Log("main", 1, "Game", "Initialized");
|
Logger.Log("main", 1, "Game", "Initialized");
|
||||||
}
|
}
|
||||||
@@ -181,5 +164,14 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
Logger.Log("main", l, "Internal", "{0}\n{1}", condition, stackTrace);
|
Logger.Log("main", l, "Internal", "{0}\n{1}", condition, stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SuspendBackgroundTasks() {
|
||||||
|
NetworkTaskWorker.SuspendBackgroundTasks();
|
||||||
|
Dialog.Suppress();
|
||||||
|
}
|
||||||
|
public static void ResumeBackgroundTasks() {
|
||||||
|
Dialog.Release();
|
||||||
|
NetworkTaskWorker.ResumeBackgroundTasks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,10 +262,9 @@ namespace Cryville.Crtr {
|
|||||||
frame.Vector = vec;
|
frame.Vector = vec;
|
||||||
}
|
}
|
||||||
else frame = rc.InverseTransform(frame);
|
else frame = rc.InverseTransform(frame);
|
||||||
bool locked = false;
|
Monitor.Enter(_etor);
|
||||||
try {
|
try {
|
||||||
Profiler.BeginSample("InputProxy.OnInput");
|
Profiler.BeginSample("InputProxy.OnInput");
|
||||||
Monitor.Enter(_etor, ref locked);
|
|
||||||
InputProxyEntry proxy;
|
InputProxyEntry proxy;
|
||||||
if (_sproxies.TryGetValue(id.Source, out proxy)) {
|
if (_sproxies.TryGetValue(id.Source, out proxy)) {
|
||||||
float ft, tt = (float)GetSyncedTime(frame.Time, id.Source.Handler);
|
float ft, tt = (float)GetSyncedTime(frame.Time, id.Source.Handler);
|
||||||
@@ -289,8 +288,8 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (locked) Monitor.Exit(_etor);
|
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
Monitor.Exit(_etor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static readonly int _var_fv = IdentifierManager.Shared.Request("input_vec_from");
|
static readonly int _var_fv = IdentifierManager.Shared.Request("input_vec_from");
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace Cryville.Crtr {
|
|||||||
void OnEnable() {
|
void OnEnable() {
|
||||||
Application.targetFrameRate = 60;
|
Application.targetFrameRate = 60;
|
||||||
if (animatorState != null) m_targetAnimator.PlayInFixedTime(animatorState, 0, 0);
|
if (animatorState != null) m_targetAnimator.PlayInFixedTime(animatorState, 0, 0);
|
||||||
Game.NetworkTaskWorker.ResumeBackgroundTasks();
|
Game.ResumeBackgroundTasks();
|
||||||
}
|
}
|
||||||
#pragma warning restore IDE0051
|
#pragma warning restore IDE0051
|
||||||
|
|
||||||
|
|||||||
27
Assets/Cryville/Crtr/PlatformConfig.cs
Normal file
27
Assets/Cryville/Crtr/PlatformConfig.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using Cryville.Common.Font;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Cryville.Crtr {
|
||||||
|
internal static class PlatformConfig {
|
||||||
|
#if UNITY_STANDALONE_WIN
|
||||||
|
public static readonly string Name = "windows";
|
||||||
|
#elif UNITY_ANDROID
|
||||||
|
public static readonly string Name = "android";
|
||||||
|
#else
|
||||||
|
#error Unknown platform.
|
||||||
|
#endif
|
||||||
|
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||||
|
public static readonly string FileProtocolPrefix = "file:///";
|
||||||
|
public static readonly FontManager FontManager = new FontManagerWindows();
|
||||||
|
public static readonly Dictionary<string, List<string>> ScriptFontMap = FallbackListFontMatcher.GetDefaultWindowsFallbackMap();
|
||||||
|
public static readonly string TextShader = "TextMesh Pro/Shaders/TMP_SDF SSD";
|
||||||
|
#elif UNITY_ANDROID
|
||||||
|
public static readonly string FileProtocolPrefix = "file://";
|
||||||
|
public static readonly FontManager FontManager = new FontManagerAndroid();
|
||||||
|
public static readonly Dictionary<string, List<string>> ScriptFontMap = FallbackListFontMatcher.GetDefaultAndroidFallbackMap();
|
||||||
|
public static readonly string TextShader = "TextMesh Pro/Shaders/TMP_SDF-Mobile SSD";
|
||||||
|
#else
|
||||||
|
#error Unknown platform.
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Crtr/PlatformConfig.cs.meta
Normal file
11
Assets/Cryville/Crtr/PlatformConfig.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5b9be7f84b72ac9468dacec2d44003a9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user