mirror of
https://github.com/RaindropViewer/RaindropViewer.git
synced 2026-07-27 22:11:39 +00:00
Oops, forgot to commit many things:
- bootstrapper now not longer init the Logger. - bootstrapper now starts the copy of missing files from StreamingAssets folder to the device's internal storage. - UIBootstrapper now requires you to manually inject the components from the scene graph - Added alot of logic to gridmanager for saving and loading custom grids, but it seems quite repeated and convoluted. - some disparities between our Raindrop core and Radegast core is noticed. - start to use color in the chat printer. - add loading screen to UIService - add the canvas type of POP so that the ButtonTriggerViewTransition can trigger a pop-only.
This commit is contained in:
@@ -43,6 +43,10 @@ namespace Raindrop.Services.Bootstrap
|
||||
{
|
||||
//0. start rolling log file
|
||||
// ConfigureRollingLogFile();
|
||||
|
||||
startupPrintLogger();
|
||||
|
||||
Assign_MainThreadReference();
|
||||
|
||||
Init_StaticFileSystem();
|
||||
|
||||
@@ -53,33 +57,18 @@ namespace Raindrop.Services.Bootstrap
|
||||
CreateAndRegister_RaindropInstance();
|
||||
}
|
||||
|
||||
private static void ConfigureRollingLogFile()
|
||||
private static void Assign_MainThreadReference()
|
||||
{
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
//1. log to unity console.
|
||||
var unityDebugAppender = new UnityDebugAppender();
|
||||
unityDebugAppender.Layout = new PatternLayout("%date{HH:mm:ss} [%level] - %message");
|
||||
//appender.Layout = new PatternLayout("%timestamp [%thread] %-5level - %message%newline");
|
||||
BasicConfigurator.Configure(unityDebugAppender);
|
||||
|
||||
|
||||
var logFileAppender = new RollingFileAppender();
|
||||
logFileAppender.Layout = new PatternLayout("%date{HH:mm:ss} [%level] - %message");
|
||||
logFileAppender.File = Path.Combine(
|
||||
DirectoryHelpers.GetInternalCacheDir(),
|
||||
"log.txt");
|
||||
logFileAppender.AppendToFile = true;
|
||||
logFileAppender.RollingStyle = RollingFileAppender.RollingMode.Size;
|
||||
logFileAppender.MaxSizeRollBackups = 10;
|
||||
logFileAppender.MaxFileSize = 250 * 1000; // 250KB
|
||||
logFileAppender.StaticLogFileName = true;
|
||||
XmlConfigurator.Configure();
|
||||
Globals.GMainThread = System.Threading.Thread.CurrentThread;
|
||||
}
|
||||
|
||||
|
||||
public static void startupPrintLogger()
|
||||
{
|
||||
Logger.Log("Logger is ready", Helpers.LogLevel.Debug);
|
||||
Logger.Log("Logger is logging to : "+ Path.Combine(
|
||||
DirectoryHelpers.GetInternalCacheDir(),
|
||||
"log.txt")
|
||||
DirectoryHelpers.GetInternalCacheDir(),
|
||||
"log.txt")
|
||||
, Helpers.LogLevel.Debug);
|
||||
}
|
||||
|
||||
@@ -104,6 +93,21 @@ namespace Raindrop.Services.Bootstrap
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
void SaveInventoryToDiskAndLogout(RaindropInstance raindropInstance, RaindropNetcom raindropNetcom)
|
||||
{
|
||||
Thread saveInvToDisk = new Thread(delegate()
|
||||
{
|
||||
raindropInstance.Client.Inventory.Store.SaveToDisk(raindropInstance.InventoryCacheFileName);
|
||||
})
|
||||
{
|
||||
Name = "Save inventory to disk"
|
||||
};
|
||||
saveInvToDisk.Start();
|
||||
|
||||
raindropNetcom.Logout();
|
||||
Debug.Log("Logged out! :)");
|
||||
}
|
||||
|
||||
RaindropInstance instance;
|
||||
try
|
||||
{
|
||||
@@ -119,29 +123,20 @@ namespace Raindrop.Services.Bootstrap
|
||||
OpenMetaverse.Logger.Log("Application ending after " + Time.time + " seconds"
|
||||
, Helpers.LogLevel.Debug);
|
||||
|
||||
//if (statusTimer != null)
|
||||
//{
|
||||
// statusTimer.Stop();
|
||||
// statusTimer.Dispose();
|
||||
// statusTimer = null;
|
||||
//}
|
||||
// if (statusTimer != null)
|
||||
// {
|
||||
// statusTimer.Stop();
|
||||
// statusTimer.Dispose();
|
||||
// statusTimer = null;
|
||||
// }
|
||||
|
||||
if (!netcom.IsLoggedIn) return;
|
||||
|
||||
Thread saveInvToDisk = new Thread(delegate ()
|
||||
if (netcom.IsLoggedIn)
|
||||
{
|
||||
instance.Client.Inventory.Store.SaveToDisk(instance.InventoryCacheFileName);
|
||||
})
|
||||
{
|
||||
Name = "Save inventory to disk"
|
||||
};
|
||||
saveInvToDisk.Start();
|
||||
|
||||
netcom.Logout();
|
||||
Debug.Log("Logged out! :)");
|
||||
SaveInventoryToDiskAndLogout(instance, netcom);
|
||||
}
|
||||
|
||||
frmMain_Disposed(instance);
|
||||
Debug.Log("disposed mainform! :)");
|
||||
Debug.Log("disposed netcom and client! :) This marks the end of the app.");
|
||||
}
|
||||
|
||||
//wraps up the netcom and client.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Threading;
|
||||
using Raindrop.Map.Model;
|
||||
using Raindrop.Netcom;
|
||||
using Raindrop.Presenters;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Raindrop.Services.Bootstrap
|
||||
@@ -13,6 +14,11 @@ namespace Raindrop.Services.Bootstrap
|
||||
private RaindropInstance instance => ServiceLocator.ServiceLocator.Instance.Get<RaindropInstance>();
|
||||
private RaindropNetcom netcom => instance.Netcom;
|
||||
|
||||
[SerializeField] public ModalManager mm;
|
||||
[SerializeField] public ScreensManager sm;
|
||||
[SerializeField] public LoadingCanvasPresenter ll;
|
||||
|
||||
|
||||
// bootstraps the UI.
|
||||
// 1. it first bootstraps the base layer of RaindropInstance
|
||||
// 2. then it find all the canvasmanager and modal managers.
|
||||
@@ -36,13 +42,17 @@ namespace Raindrop.Services.Bootstrap
|
||||
}
|
||||
|
||||
//2. ui services
|
||||
var cm = GetComponentInChildren<ScreensManager>();
|
||||
if (cm == null)
|
||||
Debug.LogError("canvasmanager not present");
|
||||
var mm = GetComponentInChildren<ModalManager>();
|
||||
//getcomponent only can handle active objects.
|
||||
// var cm = GetComponentInChildren<ScreensManager>();
|
||||
if (sm == null)
|
||||
Debug.LogError("ScreensManager not present");
|
||||
// var mm = GetComponentInChildren<ModalManager>();
|
||||
if (mm == null)
|
||||
Debug.LogError("modalmanager not present");
|
||||
ServiceLocator.ServiceLocator.Instance.Register<UIService>(new UIService(cm, mm));
|
||||
Debug.LogError("ModalManager not present");
|
||||
// var ll = GetComponentInChildren<LoadingCanvasPresenter>();
|
||||
if (ll == null)
|
||||
Debug.LogError("loadingscreen not present");
|
||||
ServiceLocator.ServiceLocator.Instance.Register<UIService>(new UIService(sm, mm, ll));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,10 +31,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Disk;
|
||||
//using System.Reflection;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using UnityEngine.Assertions;
|
||||
|
||||
namespace Raindrop
|
||||
{
|
||||
@@ -86,22 +89,50 @@ namespace Raindrop
|
||||
|
||||
return grid;
|
||||
}
|
||||
|
||||
public static OSD ToOSD(Grid grid)
|
||||
{
|
||||
OSDMap map = new OSDMap();
|
||||
|
||||
map["gridnick"] = grid.ID;
|
||||
map["gridname"] = grid.Name;
|
||||
map["platform"] = grid.Platform;
|
||||
map["loginuri"] = grid.LoginURI;
|
||||
map["loginpage"] = grid.LoginPage;
|
||||
map["helperuri"] = grid.HelperURI;
|
||||
map["website"] = grid.Website;
|
||||
map["support"] = grid.Support;
|
||||
map["register"] = grid.Register;
|
||||
map["password"] = grid.PasswordURL;
|
||||
map["version"] = grid.Version;
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
public class GridManager : IDisposable
|
||||
{
|
||||
public List<Grid> Grids;
|
||||
public List<Grid> CustomGrids;
|
||||
private string gridsFileCustom = "grids_custom.xml";
|
||||
private string gridsFileDefault = "grids.xml";
|
||||
|
||||
public GridManager()
|
||||
// _appDataDir: the folder of the 2 grid xml files.
|
||||
public GridManager(string _appDataDir)
|
||||
{
|
||||
Grids = new List<Grid>();
|
||||
CustomGrids = new List<Grid>();
|
||||
|
||||
LoadDefaultGrids(_appDataDir);
|
||||
LoadCustomGrids(_appDataDir);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public void LoadGrids(string datadir)
|
||||
// load default, hard-coded list of grids.
|
||||
public void LoadDefaultGrids(string datadir)
|
||||
{
|
||||
Grids.Clear();
|
||||
Grids.Add(new Grid("agni", "Second Life (agni)", "https://login.agni.lindenlab.com/cgi-bin/login.cgi"));
|
||||
@@ -109,7 +140,7 @@ namespace Raindrop
|
||||
|
||||
try
|
||||
{
|
||||
string sysGridsFile = Path.Combine(datadir, "grids.xml");
|
||||
string sysGridsFile = Path.Combine(datadir, gridsFileDefault);
|
||||
OSDArray sysGrids = (OSDArray)OSDParser.DeserializeLLSDXml(File.ReadAllText(sysGridsFile));
|
||||
for (int i = 0; i < sysGrids.Count; i++)
|
||||
{
|
||||
@@ -121,6 +152,29 @@ namespace Raindrop
|
||||
Logger.Log(string.Format("Error loading grid information: {0}", ex.Message), Helpers.LogLevel.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
//save the current instance into the grids.xml file
|
||||
public void SaveCustomGrids(string datadir)
|
||||
{
|
||||
try
|
||||
{
|
||||
OSDArray customGrids = new OSDArray();
|
||||
foreach (var grid in Grids)
|
||||
{
|
||||
var item = Grid.ToOSD(grid);
|
||||
customGrids.Add(item);
|
||||
}
|
||||
|
||||
var bytesToWrite = OSDParser.SerializeLLSDXmlBytes(customGrids);
|
||||
string customGridsFile = Path.Combine(datadir, gridsFileCustom);
|
||||
|
||||
DirectoryHelpers.WriteToFile(bytesToWrite, customGridsFile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log(string.Format("Error saving custom grids information: {0}", ex.Message), Helpers.LogLevel.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterGrid(Grid grid)
|
||||
{
|
||||
@@ -134,6 +188,19 @@ namespace Raindrop
|
||||
Grids[ix] = grid;
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterCustomGrid(Grid grid)
|
||||
{
|
||||
int ix = CustomGrids.FindIndex((Grid g) => { return g.ID == grid.ID; });
|
||||
if (ix < 0)
|
||||
{
|
||||
CustomGrids.Add(grid);
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomGrids[ix] = grid;
|
||||
}
|
||||
}
|
||||
|
||||
public Grid this[int ix]
|
||||
{
|
||||
@@ -165,5 +232,31 @@ namespace Raindrop
|
||||
{
|
||||
get { return Grids.Count; }
|
||||
}
|
||||
|
||||
public void LoadCustomGrids(string datadir)
|
||||
{
|
||||
CustomGrids.Clear();
|
||||
|
||||
//create blank LLSD file if not exists.
|
||||
string sysGridsFile = Path.Combine(datadir, gridsFileCustom);
|
||||
if (!File.Exists(sysGridsFile))
|
||||
{
|
||||
SaveCustomGrids(datadir);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OSDArray sysGrids = (OSDArray)OSDParser.DeserializeLLSDXml(File.ReadAllText(sysGridsFile));
|
||||
for (int i = 0; i < sysGrids.Count; i++)
|
||||
{
|
||||
RegisterCustomGrid(Grid.FromOSD(sysGrids[i]));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log(string.Format("Error loading custom grid information: {0}", ex.Message), Helpers.LogLevel.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +81,10 @@ namespace Raindrop.Media
|
||||
protected bool Cloned = false;
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (!Cloned)
|
||||
if (!Cloned && sound.hasHandle())
|
||||
{
|
||||
sound.release();
|
||||
//sound = null;
|
||||
sound.clearHandle();
|
||||
}
|
||||
|
||||
Disposed = true;
|
||||
|
||||
+159
-165
@@ -39,6 +39,8 @@ using OpenMetaverse.StructuredData;
|
||||
//using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using UnityEngine;
|
||||
using Formatting = System.Xml.Formatting;
|
||||
//using Font = Catnip.Drawing.Font;
|
||||
using Logger = OpenMetaverse.Logger;
|
||||
@@ -53,105 +55,95 @@ namespace Raindrop
|
||||
public delegate void SettingChangedCallback(object sender, SettingsEventArgs e);
|
||||
public event SettingChangedCallback OnSettingChanged;
|
||||
|
||||
//public static readonly Dictionary<string, FontSetting> DefaultFontSettings = new Dictionary<string, FontSetting>()
|
||||
//{
|
||||
// {"Normal", new FontSetting {
|
||||
// Name = "Normal",
|
||||
// ForeColor = Color.Black,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"StatusBlue", new FontSetting {
|
||||
// Name = "StatusBlue",
|
||||
// ForeColor = Color.Blue,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"StatusDarkBlue", new FontSetting {
|
||||
// Name = "StatusDarkBlue",
|
||||
// ForeColor = Color.DarkBlue,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"LindenChat", new FontSetting {
|
||||
// Name = "LindenChat",
|
||||
// ForeColor = Color.DarkGreen,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"ObjectChat", new FontSetting {
|
||||
// Name = "ObjectChat",
|
||||
// ForeColor = Color.DarkCyan,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"StartupTitle", new FontSetting {
|
||||
// Name = "StartupTitle",
|
||||
// ForeColor = Color.Black,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"Alert", new FontSetting {
|
||||
// Name = "Alert",
|
||||
// ForeColor = Color.DarkRed,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"Error", new FontSetting {
|
||||
// Name = "Error",
|
||||
// ForeColor = Color.Red,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"OwnerSay", new FontSetting {
|
||||
// Name = "OwnerSay",
|
||||
// ForeColor = Color.DarkGoldenrod,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"Timestamp", new FontSetting {
|
||||
// Name = "Timestamp",
|
||||
// ForeColor = Color.Gray,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"Name", new FontSetting {
|
||||
// Name = "Name",
|
||||
// ForeColor = Color.Black,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"Notification", new FontSetting {
|
||||
// Name = "Notification",
|
||||
// ForeColor = Color.Black,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"IncomingIM", new FontSetting {
|
||||
// Name = "IncomingIM",
|
||||
// ForeColor = Color.Black,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"OutgoingIM", new FontSetting {
|
||||
// Name = "OutgoingIM",
|
||||
// ForeColor = Color.Black,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"Emote", new FontSetting {
|
||||
// Name = "Emote",
|
||||
// ForeColor = Color.Black,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
// {"Self", new FontSetting {
|
||||
// Name = "Self",
|
||||
// ForeColor = Color.Black,
|
||||
// BackColor = Color.Transparent,
|
||||
// Font = FontSetting.DefaultFont,
|
||||
// }},
|
||||
//};
|
||||
private static Color DarkBlue => new Color(0.2f,0.2f,1f);
|
||||
private static Color LightBlue => new Color(0.5f,0.7f,1f);
|
||||
private static Color DarkRed => new Color(0.6f,0f,0f);
|
||||
private static Color DarkGoldenrod => new Color(0.72f,0.52f,4.0f);
|
||||
private static Color DarkCyan => new Color(0f,1f,1f);
|
||||
|
||||
public static readonly Dictionary<string, FontSetting> DefaultFontSettings = new Dictionary<string, FontSetting>()
|
||||
{
|
||||
{"Normal", new FontSetting {
|
||||
Name = "Normal",
|
||||
ForeColor = Color.black,
|
||||
|
||||
}},
|
||||
{"StatusBlue", new FontSetting {
|
||||
Name = "StatusBlue",
|
||||
ForeColor = LightBlue,
|
||||
|
||||
}},
|
||||
{"StatusDarkBlue", new FontSetting {
|
||||
Name = "StatusDarkBlue",
|
||||
ForeColor = DarkBlue,
|
||||
|
||||
}},
|
||||
{"LindenChat", new FontSetting {
|
||||
Name = "LindenChat",
|
||||
ForeColor = Color.green,
|
||||
|
||||
}},
|
||||
{"ObjectChat", new FontSetting {
|
||||
Name = "ObjectChat",
|
||||
ForeColor = DarkCyan,
|
||||
|
||||
}},
|
||||
{"StartupTitle", new FontSetting {
|
||||
Name = "StartupTitle",
|
||||
ForeColor = Color.black,
|
||||
|
||||
}},
|
||||
{"Alert", new FontSetting {
|
||||
Name = "Alert",
|
||||
ForeColor = DarkRed,
|
||||
|
||||
}},
|
||||
{"Error", new FontSetting {
|
||||
Name = "Error",
|
||||
ForeColor = Color.red,
|
||||
|
||||
}},
|
||||
{"OwnerSay", new FontSetting {
|
||||
Name = "OwnerSay",
|
||||
ForeColor = DarkGoldenrod,
|
||||
|
||||
}},
|
||||
{"Timestamp", new FontSetting {
|
||||
Name = "Timestamp",
|
||||
ForeColor = Color.gray,
|
||||
|
||||
}},
|
||||
{"Name", new FontSetting {
|
||||
Name = "Name",
|
||||
ForeColor = Color.black,
|
||||
|
||||
}},
|
||||
{"Notification", new FontSetting {
|
||||
Name = "Notification",
|
||||
ForeColor = Color.black,
|
||||
|
||||
}},
|
||||
{"IncomingIM", new FontSetting {
|
||||
Name = "IncomingIM",
|
||||
ForeColor = Color.black,
|
||||
|
||||
}},
|
||||
{"OutgoingIM", new FontSetting {
|
||||
Name = "OutgoingIM",
|
||||
ForeColor = Color.black,
|
||||
|
||||
}},
|
||||
{"Emote", new FontSetting {
|
||||
Name = "Emote",
|
||||
ForeColor = Color.black,
|
||||
|
||||
}},
|
||||
{"Self", new FontSetting {
|
||||
Name = "Self",
|
||||
ForeColor = Color.black,
|
||||
|
||||
}},
|
||||
};
|
||||
|
||||
public class FontSetting
|
||||
{
|
||||
@@ -162,75 +154,77 @@ namespace Raindrop
|
||||
//public Font Font;
|
||||
|
||||
|
||||
[IgnoreDataMember]
|
||||
public Color ForeColor;
|
||||
|
||||
public String Name;
|
||||
//
|
||||
// public string ForeColorString
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (ForeColor != null)
|
||||
// {
|
||||
// return ColorTranslator.ToHtml(ForeColor);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return ColorTranslator.ToHtml(Color.Black);
|
||||
// }
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// ForeColor = ColorTranslator.FromHtml(value);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public string BackColorString
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (BackColor != null)
|
||||
// {
|
||||
// return ColorTranslator.ToHtml(BackColor);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return ColorTranslator.ToHtml(Color.Black);
|
||||
// }
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// BackColor = ColorTranslator.FromHtml(value);
|
||||
// }
|
||||
// }
|
||||
|
||||
//public string ForeColorString
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (ForeColor != null)
|
||||
// {
|
||||
// return ColorTranslator.ToHtml(ForeColor);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return ColorTranslator.ToHtml(Color.Black);
|
||||
// }
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// ForeColor = ColorTranslator.FromHtml(value);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public string BackColorString
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (BackColor != null)
|
||||
// {
|
||||
// return ColorTranslator.ToHtml(BackColor);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return ColorTranslator.ToHtml(Color.Black);
|
||||
// }
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// BackColor = ColorTranslator.FromHtml(value);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public string FontString
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (this.Font != null)
|
||||
// {
|
||||
// TypeConverter converter = TypeDescriptor.GetConverter(typeof(Font));
|
||||
// return converter.ConvertToString(this.Font);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// TypeConverter converter = TypeDescriptor.GetConverter(typeof(Font));
|
||||
// this.Font = converter.ConvertFromString(value) as Font;
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// this.Font = DefaultFont;
|
||||
// }
|
||||
|
||||
// }
|
||||
//}
|
||||
// public string FontString
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (this.Font != null)
|
||||
// {
|
||||
// TypeConverter converter = TypeDescriptor.GetConverter(typeof(Font));
|
||||
// return converter.ConvertToString(this.Font);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// TypeConverter converter = TypeDescriptor.GetConverter(typeof(Font));
|
||||
// this.Font = converter.ConvertFromString(value) as Font;
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// this.Font = DefaultFont;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using OpenMetaverse;
|
||||
using Raindrop.Netcom;
|
||||
using Raindrop.Presenters;
|
||||
using Raindrop.ServiceLocator;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -9,11 +10,12 @@ namespace Raindrop.Services
|
||||
public class UIService : IGameService
|
||||
{
|
||||
//UI is a service. it will always be available.
|
||||
// note that presenters should register with the canvas manager. presenters themselves provide the logic of ui-traversal.
|
||||
// presenters themselves provide the logic of ui-traversal.
|
||||
// modals on the other hand are provided and popped in by the presenters themselves. for example a confirmation prompt for the user - obviously that should fall under the responsibility of the UI-logic layer.
|
||||
// UIservice contains:
|
||||
// CanvasManager - manages the UI stack. Access this to pop and push views onto the ui stack.
|
||||
// ModalManager - manages the modals. access this to pop and show modals.
|
||||
// Notification - manages app-wide notifications.
|
||||
// <deprecated> LoadingCanvasPresenter - this particular modal/screen is tricky; it appears only when the scene is loading.
|
||||
|
||||
private RaindropInstance instance;
|
||||
@@ -26,11 +28,21 @@ namespace Raindrop.Services
|
||||
// modals are single-display. however, there is a modal queue, such that when the current modal is dismissed, the next-in-queue will appear.
|
||||
//care has to be taken not to spam the user with modals.
|
||||
public ModalManager modalManager { set; get; }
|
||||
|
||||
// fade into loading screen.
|
||||
public LoadingController _loadingController;
|
||||
|
||||
public UIService(ScreensManager cm, ModalManager mm)
|
||||
// refactor:
|
||||
/* initial: UIService(ScreensManager cm, ModalManager mm)
|
||||
* desired: UIService(raindropinstance)
|
||||
* +UIService.showScreen(UIBuilder(CanvasType.Login))
|
||||
* +UIService.showModal
|
||||
*/
|
||||
public UIService(ScreensManager cm, ModalManager mm, LoadingCanvasPresenter loadingCanvasPresenter)
|
||||
{
|
||||
ScreensManager = cm;
|
||||
modalManager = mm;
|
||||
_loadingController = new LoadingController(loadingCanvasPresenter);
|
||||
|
||||
// UI depends on raindrop business layer.
|
||||
try
|
||||
@@ -109,7 +121,7 @@ namespace Raindrop.Services
|
||||
{
|
||||
if (e.Status == LoginStatus.Failed)
|
||||
{
|
||||
modalManager.setVisibleGenericModal("Login failed. Server reply: ", e.Message, true);
|
||||
//modalManager.showModalNotification("Login failed. Server reply: ", e.Message);
|
||||
//if (InAutoReconnect)
|
||||
//{
|
||||
// if (instance.GlobalSettings["auto_reconnect"].AsBoolean() && e.FailReason != "tos")
|
||||
@@ -120,7 +132,7 @@ namespace Raindrop.Services
|
||||
}
|
||||
else if (e.Status == LoginStatus.Success)
|
||||
{
|
||||
modalManager.setVisibleGenericModal("Login success! Server reply: ", e.Message, true);
|
||||
//modalManager.showModalNotification("Login success! Server reply: ", e.Message);
|
||||
//InAutoReconnect = false;
|
||||
//reconnectToolStripMenuItem.Enabled = false;
|
||||
//loginToolStripMenuItem.Enabled = false;
|
||||
@@ -137,28 +149,17 @@ namespace Raindrop.Services
|
||||
|
||||
private void netcom_ClientLoggedOut(object sender, EventArgs e)
|
||||
{
|
||||
modalManager.showModalNotification("Logged out", "you have/were logged out");
|
||||
//modalManager.showModalNotification("Logged out", "you have/were logged out");
|
||||
|
||||
ScreensManager.resetToInitialScreen();
|
||||
|
||||
//tsb3D.Enabled = tbtnVoice.Enabled = disconnectToolStripMenuItem.Enabled =
|
||||
//tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
|
||||
// tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = false;
|
||||
|
||||
//reconnectToolStripMenuItem.Enabled = true;
|
||||
//loginToolStripMenuItem.Enabled = true;
|
||||
//InAutoReconnect = false;
|
||||
|
||||
//if (statusTimer != null)
|
||||
// statusTimer.Stop();
|
||||
|
||||
|
||||
//RefreshStatusBar();
|
||||
//RefreshWindowTitle();
|
||||
}
|
||||
|
||||
private void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e)
|
||||
{
|
||||
modalManager.showModalNotification("Client disconnected", e.Message+ " "+e.Reason.ToString());
|
||||
//modalManager.showModalNotification("Client disconnected", e.Message+ " "+e.Reason.ToString());
|
||||
|
||||
firstMoneyNotification = true;
|
||||
|
||||
@@ -193,14 +194,8 @@ namespace Raindrop.Services
|
||||
{
|
||||
if (delta > 50)
|
||||
{
|
||||
//if (oldBalance > e.Balance)
|
||||
//{
|
||||
// instance.MediaManager.PlayUISound(UISounds.MoneyIn);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// instance.MediaManager.PlayUISound(UISounds.MoneyOut);
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,17 +206,7 @@ namespace Raindrop.Services
|
||||
if (!e.Names.ContainsKey(client.Self.AgentID)) return;
|
||||
|
||||
|
||||
//if (InvokeRequired)
|
||||
//{
|
||||
// if (IsHandleCreated || !instance.MonoRuntime)
|
||||
// {
|
||||
// BeginInvoke(new MethodInvoker(() => Names_NameUpdated(sender, e)));
|
||||
// }
|
||||
// return;
|
||||
//}
|
||||
|
||||
//RefreshWindowTitle();
|
||||
//RefreshStatusBar();
|
||||
|
||||
}
|
||||
|
||||
void Self_MoneyBalanceReply(object sender, MoneyBalanceReplyEventArgs e)
|
||||
@@ -243,133 +228,21 @@ namespace Raindrop.Services
|
||||
|
||||
void Parcels_ParcelProperties(object sender, ParcelPropertiesEventArgs e)
|
||||
{
|
||||
//if (PreventParcelUpdate || e.Result != ParcelResult.Single) return;
|
||||
//if (InvokeRequired)
|
||||
//{
|
||||
// BeginInvoke(new MethodInvoker(() => Parcels_ParcelProperties(sender, e)));
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
Parcel parcel = instance.State.Parcel = e.Parcel;
|
||||
|
||||
//tlblParcel.Text = parcel.Name;
|
||||
//tlblParcel.ToolTipText = parcel.Desc;
|
||||
|
||||
//if ((parcel.Flags & ParcelFlags.AllowFly) != ParcelFlags.AllowFly)
|
||||
// icoNoFly.Visible = true;
|
||||
//else
|
||||
// icoNoFly.Visible = false;
|
||||
|
||||
//if ((parcel.Flags & ParcelFlags.CreateObjects) != ParcelFlags.CreateObjects)
|
||||
// icoNoBuild.Visible = true;
|
||||
//else
|
||||
// icoNoBuild.Visible = false;
|
||||
|
||||
//if ((parcel.Flags & ParcelFlags.AllowOtherScripts) != ParcelFlags.AllowOtherScripts)
|
||||
// icoNoScript.Visible = true;
|
||||
//else
|
||||
// icoNoScript.Visible = false;
|
||||
|
||||
//if ((parcel.Flags & ParcelFlags.RestrictPushObject) == ParcelFlags.RestrictPushObject)
|
||||
// icoNoPush.Visible = true;
|
||||
//else
|
||||
// icoNoPush.Visible = false;
|
||||
|
||||
//if ((parcel.Flags & ParcelFlags.AllowDamage) == ParcelFlags.AllowDamage)
|
||||
// icoHealth.Visible = true;
|
||||
//else
|
||||
// icoHealth.Visible = false;
|
||||
|
||||
//if ((parcel.Flags & ParcelFlags.AllowVoiceChat) != ParcelFlags.AllowVoiceChat)
|
||||
// icoNoVoice.Visible = true;
|
||||
//else
|
||||
// icoNoVoice.Visible = false;
|
||||
}
|
||||
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//private void RefreshStatusBar()
|
||||
//{
|
||||
// if (netcom.IsLoggedIn)
|
||||
// {
|
||||
// tlblLoginName.Text = instance.Names.Get(client.Self.AgentID, client.Self.Name);
|
||||
// tlblMoneyBalance.Text = client.Self.Balance.ToString();
|
||||
// icoHealth.Text = client.Self.Health.ToString() + "%";
|
||||
|
||||
// var cs = client.Network.CurrentSim;
|
||||
// tlblRegionInfo.Text =
|
||||
// (cs == null ? "No region" : cs.Name) +
|
||||
// " (" + Math.Floor(client.Self.SimPosition.X).ToString() + ", " +
|
||||
// Math.Floor(client.Self.SimPosition.Y).ToString() + ", " +
|
||||
// Math.Floor(client.Self.SimPosition.Z).ToString() + ")";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// tlblLoginName.Text = "Offline";
|
||||
// tlblMoneyBalance.Text = "0";
|
||||
// icoHealth.Text = "0%";
|
||||
// tlblRegionInfo.Text = "No Region";
|
||||
// tlblParcel.Text = "No Parcel";
|
||||
|
||||
// icoHealth.Visible = false;
|
||||
// icoNoBuild.Visible = false;
|
||||
// icoNoFly.Visible = false;
|
||||
// icoNoPush.Visible = false;
|
||||
// icoNoScript.Visible = false;
|
||||
// icoNoVoice.Visible = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void RefreshWindowTitle()
|
||||
//{
|
||||
// string name = instance.Names.Get(client.Self.AgentID, client.Self.Name);
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.Append("Radegast - ");
|
||||
|
||||
// if (netcom.IsLoggedIn)
|
||||
// {
|
||||
// sb.Append("[" + name + "]");
|
||||
|
||||
// if (instance.State.IsAway)
|
||||
// {
|
||||
// sb.Append(" - Away");
|
||||
// if (instance.State.IsBusy) sb.Append(", Busy");
|
||||
// }
|
||||
// else if (instance.State.IsBusy)
|
||||
// {
|
||||
// sb.Append(" - Busy");
|
||||
// }
|
||||
|
||||
// if (instance.State.IsFollowing)
|
||||
// {
|
||||
// sb.Append(" - Following ");
|
||||
// sb.Append(instance.State.FollowName);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// sb.Append("Logged Out");
|
||||
// }
|
||||
|
||||
// this.Text = sb.ToString();
|
||||
|
||||
// // When minimized to tray, update tray tool tip also
|
||||
// if (WindowState == FormWindowState.Minimized && instance.GlobalSettings["minimize_to_tray"])
|
||||
// {
|
||||
// trayIcon.Text = sb.ToString();
|
||||
// ctxTrayMenuLabel.Text = sb.ToString();
|
||||
// }
|
||||
|
||||
// sb = null;
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public class Notification
|
||||
{
|
||||
public static void AddNotification()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,5 @@
|
||||
Avatar,
|
||||
Inventory,
|
||||
UNKNOWN,
|
||||
NONE //use this if you want to pop only.
|
||||
POP //use this if you want to pop only.
|
||||
}
|
||||
@@ -7,16 +7,15 @@ using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
//helper class that helps to pop, push, stack canvases.
|
||||
//singleton.
|
||||
//on awake, it searches children for all canvases.
|
||||
public class ScreensManager : MonoBehaviour
|
||||
{
|
||||
[Tooltip("The canvases that are available to use.")]
|
||||
public List<CanvasIdentifier> canvasControllerList = new List<CanvasIdentifier>();
|
||||
[FormerlySerializedAs("canvasControllerList")] [Tooltip("The canvases that are available to use.")]
|
||||
public List<CanvasIdentifier> availableCanvases = new List<CanvasIdentifier>();
|
||||
[Tooltip("The canvases that are created and in memory stack.")]
|
||||
public Stack<CanvasIdentifier> activeCanvasStack = new Stack<CanvasIdentifier>();
|
||||
|
||||
public CanvasIdentifier topCanvas
|
||||
public CanvasIdentifier TopCanvas
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -26,6 +25,7 @@ public class ScreensManager : MonoBehaviour
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Debug.Log("pop canvas has error : " + e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -41,14 +41,13 @@ public class ScreensManager : MonoBehaviour
|
||||
var _ = transform.GetChild(i).GetComponent<CanvasIdentifier>();
|
||||
if (_ != null)
|
||||
{
|
||||
canvasControllerList.Add(_);
|
||||
availableCanvases.Add(_);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
canvasControllerList.ForEach(x => x.gameObject.SetActive(false));
|
||||
Debug.Log("Found " + canvasControllerList.Count + " canvas identifiers.");
|
||||
availableCanvases.ForEach(x => x.gameObject.SetActive(false));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -59,19 +58,19 @@ public class ScreensManager : MonoBehaviour
|
||||
|
||||
public void resetToInitialScreen()
|
||||
{
|
||||
if (! GetEulaAcceptance())
|
||||
if (! IsEulaAccepted())
|
||||
{
|
||||
canvasControllerList.ForEach(x => x.gameObject.SetActive(false));
|
||||
availableCanvases.ForEach(x => x.gameObject.SetActive(false));
|
||||
Push(CanvasType.Eula);
|
||||
}
|
||||
else
|
||||
{
|
||||
canvasControllerList.ForEach(x => x.gameObject.SetActive(false));
|
||||
availableCanvases.ForEach(x => x.gameObject.SetActive(false));
|
||||
Push(initialPage);
|
||||
}
|
||||
}
|
||||
|
||||
private bool GetEulaAcceptance()
|
||||
private bool IsEulaAccepted()
|
||||
{
|
||||
if (ServiceLocator.Instance.Get<RaindropInstance>().GlobalSettings["EulaAccepted"])
|
||||
{
|
||||
@@ -94,7 +93,7 @@ public class ScreensManager : MonoBehaviour
|
||||
}
|
||||
public CanvasType getCanvasTypeFromString(string _type)
|
||||
{
|
||||
foreach(CanvasIdentifier _ in canvasControllerList)
|
||||
foreach(CanvasIdentifier _ in availableCanvases)
|
||||
{
|
||||
var thecanvastype = _.canvasType;
|
||||
if (_type == thecanvastype.ToString())
|
||||
@@ -118,7 +117,7 @@ public class ScreensManager : MonoBehaviour
|
||||
// {
|
||||
// Debug.LogError("unable to get the canvas of identifer: "+ _type);
|
||||
// }
|
||||
if (topCanvas)
|
||||
if (TopCanvas)
|
||||
{
|
||||
PopCanvas();
|
||||
}
|
||||
@@ -146,7 +145,7 @@ public class ScreensManager : MonoBehaviour
|
||||
}
|
||||
|
||||
//find the new canvas to push.
|
||||
CanvasIdentifier desiredCanvas = canvasControllerList.Find(x => x.canvasType == type);
|
||||
CanvasIdentifier desiredCanvas = availableCanvases.Find(x => x.canvasType == type);
|
||||
if (desiredCanvas != null)
|
||||
{
|
||||
desiredCanvas.gameObject.SetActive(true);
|
||||
@@ -157,20 +156,20 @@ public class ScreensManager : MonoBehaviour
|
||||
|
||||
public void PopCanvas()
|
||||
{
|
||||
if (! topCanvas)
|
||||
if (! TopCanvas)
|
||||
{
|
||||
Debug.LogWarning("tried to pop empty canvas stack.");
|
||||
return;
|
||||
}
|
||||
|
||||
//1 remove topmost
|
||||
topCanvas.gameObject.SetActive(false); //this lince causes error, as the function was called from the login thread!
|
||||
TopCanvas.gameObject.SetActive(false); //this lince causes error, as the function was called from the login thread!
|
||||
activeCanvasStack.Pop();
|
||||
|
||||
//2 reactivate the one underneath.
|
||||
if (topCanvas)
|
||||
if (TopCanvas)
|
||||
{
|
||||
topCanvas.gameObject.SetActive(true);
|
||||
TopCanvas.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,19 +5,13 @@ using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
|
||||
//a singleton monobehavior that activates modals.
|
||||
//maintains reference to all modals.
|
||||
public class ModalManager : MonoBehaviour
|
||||
{
|
||||
[Header("Provide a reference to your modals:")]
|
||||
|
||||
[Tooltip("The generic modal gameobject")]
|
||||
[SerializeField]
|
||||
public GameObject genericModalPrefab;
|
||||
|
||||
Thread mainThread;
|
||||
// private ModalPresenter eulaModalPresenter;
|
||||
[SerializeField]
|
||||
private ModalPresenter loginStatusModal;
|
||||
|
||||
@@ -32,52 +26,12 @@ public class ModalManager : MonoBehaviour
|
||||
|
||||
private void CheckModals()
|
||||
{
|
||||
// if (genericModalPresenter == null)
|
||||
// {
|
||||
// Debug.LogError("cannot find the gneric modal");
|
||||
// }
|
||||
if (loginStatusModal == null)
|
||||
{
|
||||
Debug.LogError("cannot find the login modal");
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
// public void openEula()
|
||||
// {
|
||||
// setVisibleEulaModal(true);
|
||||
// }
|
||||
//
|
||||
// public void closeEula()
|
||||
// {
|
||||
// setVisibleEulaModal(false);
|
||||
// }
|
||||
|
||||
//
|
||||
// public void setVisibleEulaModal(bool visibility)
|
||||
// {
|
||||
// if (isOnMainThread())
|
||||
// {
|
||||
// if (eulaModalPresenter != null)
|
||||
// {
|
||||
// eulaModalPresenter.gameObject.SetActive(visibility);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log("unable to get the modalPresenter object!");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
//
|
||||
// UnityMainThreadDispatcher.Instance().Enqueue(() => {
|
||||
// Debug.Log(" dispatching of showing modal");
|
||||
// setVisibleEulaModal(visibility);
|
||||
// });
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
// public void setVisibleGenericModal(string title, string content, bool visibility)
|
||||
// {
|
||||
// if (isOnMainThread())
|
||||
@@ -104,35 +58,6 @@ public class ModalManager : MonoBehaviour
|
||||
// }
|
||||
|
||||
|
||||
//by default obviously this must be visible; we are updating the login status.
|
||||
// public void setVisibleLoggingInModal(string content)
|
||||
// {
|
||||
// string title = "Logging in status...";
|
||||
//
|
||||
// if (isOnMainThread())
|
||||
// {
|
||||
// if (loginStatusModal != null)
|
||||
// {
|
||||
// loginStatusModal.setModalNoActions(title, content);
|
||||
// loginStatusModal.gameObject.SetActive(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.LogWarning("unable to get the modalPresenter object!");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
//
|
||||
// UnityMainThreadDispatcher.Instance().Enqueue(() => {
|
||||
// //Debug.Log(" dispatching of showing modal");
|
||||
// setVisibleLoggingInModal(content);
|
||||
// });
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
private bool isOnMainThread()
|
||||
{
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* Radegast Metaverse Client
|
||||
* Copyright(c) 2009-2014, Radegast Development Team
|
||||
* Copyright(c) 2016-2020, Sjofn, LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Radegast is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program.If not, see<https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//using System.Drawing;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Raindrop
|
||||
{
|
||||
public interface ITextPrinter
|
||||
{
|
||||
void InsertLink(string text, string hyperlink);
|
||||
void PrintText(string text);
|
||||
void PrintTextLine(string text);
|
||||
void PrintTextLine(string text, Color color);
|
||||
void ClearText();
|
||||
|
||||
string Content { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b3f7663bf05f754b8329a93dfd37279
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,136 +0,0 @@
|
||||
/**
|
||||
* Radegast Metaverse Client
|
||||
* Copyright(c) 2009-2014, Radegast Development Team
|
||||
* Copyright(c) 2016-2020, Sjofn, LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Radegast is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program.If not, see<https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Raindrop
|
||||
{
|
||||
//this class wraps a TMPtextbox and implements Itextprinter interface, so that you can print into the TMOPtextbox.
|
||||
//consider refactoring ITextPrinter into an adaptor class.
|
||||
public class TMPTextFieldPrinter:MonoBehaviour, ITextPrinter
|
||||
{
|
||||
private TMPro.TMP_Text rtb;
|
||||
private static readonly string urlRegexString = @"(https?://[^ \r\n]+)|(\[secondlife://[^ \]\r\n]* ?(?:[^\]\r\n]*)])|(secondlife://[^ \r\n]*)";
|
||||
Regex urlRegex;
|
||||
private SlUriParser uriParser;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
rtb = this.GetComponent<TMP_Text>();
|
||||
if (!rtb)
|
||||
{
|
||||
Debug.LogError("you added the TMPTEXTBOXprinter to an gameobject without a tmptextbox!!!");
|
||||
}
|
||||
|
||||
uriParser = new SlUriParser();
|
||||
urlRegex = new Regex(urlRegexString, RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void InsertLink(string text, string hyperlink)
|
||||
{
|
||||
rtb.text = rtb.text + "<link=\"" + hyperlink + "\"> <color=blue>" + text + "</color></link>";
|
||||
//rtb.InsertLink(text, hyperlink);
|
||||
}
|
||||
|
||||
private void FindURLs(string text)
|
||||
{
|
||||
string[] lineParts = urlRegex.Split(text);
|
||||
int linePartIndex;
|
||||
|
||||
// 'text' will be split into 1 + NumLinks*2 parts...
|
||||
// If 'text' has no links in it:
|
||||
// lineParts[0] = text
|
||||
// If 'text' has one link in it:
|
||||
// lineParts[0] = <Text before first link>
|
||||
// lineParts[1] = <first link>
|
||||
// lineParts[2] = <text after first link>
|
||||
// If 'text' has two links in it:
|
||||
// lineParts[0] = <Text before first link>
|
||||
// lineParts[1] = <first link>
|
||||
// lineParts[2] = <text after first link>
|
||||
// lineParts[3] = <second link>
|
||||
// lineParts[4] = <text after second link>
|
||||
// ...
|
||||
for (linePartIndex = 0; linePartIndex < lineParts.Length - 1; linePartIndex += 2)
|
||||
{
|
||||
AppendText(lineParts[linePartIndex]);
|
||||
//Color c = ForeColor;
|
||||
InsertLink(uriParser.GetLinkName(lineParts[linePartIndex + 1]), lineParts[linePartIndex + 1]);
|
||||
//ForeColor = c;
|
||||
}
|
||||
if (linePartIndex != lineParts.Length)
|
||||
{
|
||||
AppendText(lineParts[linePartIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
private void AppendText(string v)
|
||||
{
|
||||
rtb.text = rtb.text + v;
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#region ITextPrinter Members
|
||||
public void PrintText(string text)
|
||||
{
|
||||
rtb.text = rtb.text + text;
|
||||
|
||||
//else
|
||||
//{
|
||||
// FindURLs(text);
|
||||
//}
|
||||
}
|
||||
|
||||
public void PrintTextLine(string text)
|
||||
{
|
||||
PrintText(text + Environment.NewLine);
|
||||
}
|
||||
|
||||
public void PrintTextLine(string text, Color color)
|
||||
{
|
||||
//if (rtb.InvokeRequired)
|
||||
//{
|
||||
// rtb.Invoke(new MethodInvoker(() => PrintTextLine(text, color)));
|
||||
// return;
|
||||
//}
|
||||
|
||||
PrintTextLine(text);
|
||||
}
|
||||
|
||||
public void ClearText()
|
||||
{
|
||||
rtb.text = "";
|
||||
}
|
||||
|
||||
public string Content
|
||||
{
|
||||
get => rtb.text;
|
||||
set => rtb.text = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc6b3e25d08ab4e49b26feceddf20fed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+17144
-12166
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user