refactored the modal manager :popping and pushing

This commit is contained in:
alexiscatnip
2022-01-05 02:11:44 +08:00
parent bff23a0d83
commit f15647fcc8
15 changed files with 352 additions and 505 deletions
+29
View File
@@ -0,0 +1,29 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Lean.Gui;
using Raindrop;
using Raindrop.ServiceLocator;
using Raindrop.Services;
using UnityEngine;
public class ButtonTriggerViewTransition : MonoBehaviour
{
public CanvasType canvasTypeToPush;
public bool popCurrent;
private void Start()
{
this.GetComponent<LeanButton>().OnClick.AddListener(OnClick);
}
private void OnClick()
{
if (popCurrent)
{
ServiceLocator.Instance.Get<UIService>().canvasManager.PopAndPush(canvasTypeToPush);
} else
{
ServiceLocator.Instance.Get<UIService>().canvasManager.Push(canvasTypeToPush);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e2c84a856e3e4e442822ff4c7870a1c3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
-115
View File
@@ -1,115 +0,0 @@
//
// Radegast Metaverse Client
// Copyright (c) 2009-2014, Radegast Development Team
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the application "Radegast", nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// $Id$
//
using System;
using OpenMetaverse;
using System.Collections.Generic;
using Raindrop.Services;
namespace Raindrop
{
//holds the chats in memory. functions as the model layer.
// equivalent to a chat window with all the tabs and chats the user is chatting in.
public class ChatManager
{
public ChatTextManager localChatManager { get; private set; }
RaindropInstance instance;
GridClient client { get { return instance.Client; } }
//this is the main chat.
private string mainChatStringReference;
public ChatManager(RaindropInstance instance, ITextPrinter textPrinter)
{
this.instance = instance;
TextPrinter = textPrinter;
UnityEngine.Debug.Log("chatmanager being constructed");
//start local chat if connected to localsim
instance.Client.Network.SimConnected += Network_SimConnected;
instance.Client.Network.Disconnected += Network_Disconnected;
//make the chat manager. (seems like we destroy it on disconnection.)
localChatManager = new ChatTextManager(instance, TextPrinter);
//subscribe to localchat received event
// localChatManager.ChatLineAdded += LocalChatManager_ChatLineAdded;
}
public ITextPrinter TextPrinter { get; set; }
public void Dispose()
{
localChatManager = null;
}
private void Network_Disconnected(object sender, OpenMetaverse.DisconnectedEventArgs e)
{
Logger.Log("Network_Disconnected", Helpers.LogLevel.Info);
//wind down chatmanager
localChatManager.Dispose();
localChatManager = null;
}
private void Network_SimConnected(object sender, OpenMetaverse.SimConnectedEventArgs e)
{
//create local chat.
Logger.Log("Simulator Connected", Helpers.LogLevel.Info);
if (localChatManager == null)
localChatManager = new ChatTextManager(instance, TextPrinter);
Logger.Log("creating local chat in memory.", Helpers.LogLevel.Info);
printToMainChat("Simulator Connected");
}
public void printToMainChat(string message)
{
//print success msg.
ChatBufferItem line = new ChatBufferItem(
DateTime.Now,
string.Empty,
UUID.Zero,
message,
ChatBufferTextStyle.Normal
);
UnityMainThreadDispatcher.Instance().Enqueue(() =>
{
//process printing in main thread.
localChatManager.ProcessBufferItem(line, true);
});
}
}
}
+109
View File
@@ -0,0 +1,109 @@
using System;
using OpenMetaverse;
using System.Collections.Generic;
using Raindrop.Services;
using UnityEngine;
using Logger = OpenMetaverse.Logger;
namespace Raindrop
{
//holds the chats in memory. functions as the model layer.
// equivalent to a chat window with all the tabs and chats the user is chatting in.
public class ChatPresenterManager
{
public LocalChatTextManager LocalLocalChat { get; private set; }
public List<IMTextManager> IMChats { get; private set; }
RaindropInstance instance;
public ChatPresenterManager(RaindropInstance instance, ITextPrinter textPrinter)
{
UnityEngine.Debug.Log("chatmanager being constructed");
if (instance == null)
Debug.LogError("instance is not avaailbe in chat prensetermgr");
if (textPrinter == null)
Debug.LogError("textPrinter is not avaailbe in chat prensetermgr");
this.instance = instance;
TextPrinter = textPrinter;
RegisterClientEvents(instance);
//make the chat manager. (seems like we destroy it on disconnection.)
LocalLocalChat = new LocalChatTextManager(instance, TextPrinter);
IMChats = new List<IMTextManager>();
}
private void RegisterClientEvents(RaindropInstance instance)
{
instance.Client.Network.SimConnected += Network_SimConnected;
instance.Client.Network.Disconnected += Network_Disconnected;
LocalLocalChat.ChatLineAdded += LocalChatManager_ChatLineAdded;
}
public ITextPrinter TextPrinter { get; set; }
public void Dispose()
{
LocalLocalChat = null;
IMChats = new List<IMTextManager>();
}
private void Network_Disconnected(object sender, OpenMetaverse.DisconnectedEventArgs e)
{
Logger.Log("Network_Disconnected", Helpers.LogLevel.Info);
//wind down chatmanager
LocalLocalChat.Dispose();
LocalLocalChat = null;
}
private void LocalChatManager_ChatLineAdded(object sender, ChatLineAddedArgs chatLineAddedArgs)
{
Logger.Log("new message in local chat!", Helpers.LogLevel.Info);
if (LocalLocalChat == null)
LocalLocalChat = new LocalChatTextManager(instance, TextPrinter);
Logger.Log("creating local chat in memory.", Helpers.LogLevel.Info);
printToMainChat("todo");
}
private void Network_SimConnected(object sender, OpenMetaverse.SimConnectedEventArgs e)
{
//create local chat.
Logger.Log("Simulator Connected", Helpers.LogLevel.Info);
if (LocalLocalChat == null)
LocalLocalChat = new LocalChatTextManager(instance, TextPrinter);
Logger.Log("creating local chat in memory.", Helpers.LogLevel.Info);
printToMainChat("Simulator Connected");
//we experiment to start a IM with nuki.
UUID agentID; //todo.
// ah ok, so it seems use (A xor B) = C , where A is us and B is target, because this represents a link between us.
// we send C to let the lindens know its between A and B. abit strange TBH.
IMChats.Add(new IMTextManager(instance, null,IMTextManagerType.Agent, instance.Client.Self.AgentID ^ agentID, "cutie nuki"));
}
public void printToMainChat(string message)
{
//print success msg.
ChatBufferItem line = new ChatBufferItem(
DateTime.Now,
string.Empty,
UUID.Zero,
message,
ChatBufferTextStyle.Normal
);
UnityMainThreadDispatcher.Instance().Enqueue(() =>
{
//process printing in main thread.
LocalLocalChat.ProcessBufferItem(line, true);
});
}
}
}
@@ -1,27 +1,6 @@
/**
* 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.Collections.Generic;
using System.Linq;
//using System.Drawing;
using System.Text;
using Raindrop.Netcom;
using OpenMetaverse;
@@ -36,14 +15,12 @@ using Raindrop.Core;
namespace Raindrop
{
//if you pass a refernce to the text box, this class will print to it.
//class that functions as model. holds data on the local chat.
public class ChatTextManager : IDisposable
//This class orchestrates the printing into a text box.
//it has a text buffer to hold data (optional).
public class LocalChatTextManager : IDisposable
{
private Regex chatRegex = new Regex(@"^/(\d+)\s*(.*)", RegexOptions.Compiled);
private int chatPointer;
public event EventHandler<ChatLineAddedArgs> ChatLineAdded;
private RaindropInstance instance;
@@ -55,25 +32,27 @@ namespace Raindrop
{
return textBuffer;
}
public ITextPrinter TextPrinter { get; set; }
private bool showTimestamps;
//public static Dictionary<string, Settings.FontSetting> fontSettings = new Dictionary<string, Settings.FontSetting>();
public ChatTextManager(RaindropInstance instance, ITextPrinter textPrinter)
public LocalChatTextManager(RaindropInstance instance, ITextPrinter textPrinter)
{
TextPrinter = textPrinter;
textBuffer = new List<ChatBufferItem>(); // a pipe into the string.
this.instance = instance;
InitializeConfig();
this.localChat = localChat;
// Callbacks
netcom.ChatReceived += new EventHandler<ChatEventArgs>(netcom_ChatReceived);
netcom.ChatSent += new EventHandler<ChatSentEventArgs>(netcom_ChatSent);
netcom.AlertMessageReceived += new EventHandler<AlertMessageEventArgs>(netcom_AlertMessageReceived);
client.Self.TeleportProgress += new EventHandler<TeleportEventArgs>(Self_TeleportProgress);
PrintStartupMessage();
}
public void Dispose()
@@ -81,41 +60,18 @@ namespace Raindrop
netcom.ChatReceived -= new EventHandler<ChatEventArgs>(netcom_ChatReceived);
netcom.ChatSent -= new EventHandler<ChatSentEventArgs>(netcom_ChatSent);
netcom.AlertMessageReceived -= new EventHandler<AlertMessageEventArgs>(netcom_AlertMessageReceived);
client.Self.TeleportProgress -= new EventHandler<TeleportEventArgs>(Self_TeleportProgress);
}
private void InitializeConfig()
{
Settings s = instance.GlobalSettings;
//var serializer = new JavaScriptSerializer();
if (s["chat_timestamps"].Type == OSDType.Unknown)
{
s["chat_timestamps"] = OSD.FromBoolean(true);
}
//if (s["chat_fonts"].Type == OSDType.Unknown)
//{
// try
// {
// s["chat_fonts"] = JsonConvert.SerializeObject(Settings.DefaultFontSettings);
// }
// catch (Exception ex)
// {
// //System.Windows.Forms.MessageBox.Show("Failed to save default font settings: " + ex.Message);
// Debug.LogError("Failed to save default font settings: " + ex.Message);
// instance.MainCanvas.modals.showSimpleModalBoxWithActionBtn("Failed to save default font settings: ", ex.Message, "OK");
// }
//}
//try
//{
// fontSettings = serializer.Deserialize<Dictionary<string, Settings.FontSetting>>(s["chat_fonts"]);
//}
//catch (Exception ex)
//{
// System.Windows.Forms.MessageBox.Show("Failed to read chat font settings: " + ex.Message);
//}
showTimestamps = s["chat_timestamps"].AsBoolean();
s.OnSettingChanged += new Settings.SettingChangedCallback(s_OnSettingChanged);
@@ -128,19 +84,15 @@ namespace Raindrop
showTimestamps = e.Value.AsBoolean();
ReprintAllText();
}
//else if(e.Key == "chat_fonts")
//{
// try
// {
// var serializer = new JavaScriptSerializer();
// fontSettings = serializer.Deserialize<Dictionary<string, Settings.FontSetting>>(e.Value);
// }
// catch (Exception ex)
// {
// System.Windows.Forms.MessageBox.Show("Failed to read new font settings: " + ex.Message);
// }
// ReprintAllText();
//}
}
void Self_TeleportProgress(object sender, TeleportEventArgs e)
{
if (e.Status == TeleportStatus.Progress || e.Status == TeleportStatus.Finished)
{
TextPrinter.PrintTextLine("teleport...");
}
}
private void netcom_ChatSent(object sender, ChatSentEventArgs e)
@@ -174,20 +126,18 @@ namespace Raindrop
ChatBufferTextStyle.StartupTitle);
ChatBufferItem ready = new ChatBufferItem(
DateTime.Now, "", UUID.Zero, "Ready.", ChatBufferTextStyle.StatusBlue);
DateTime.Now, "", UUID.Zero, "Local chat Ready.", ChatBufferTextStyle.StatusBlue);
ProcessBufferItem(title, true);
ProcessBufferItem(ready, true);
}
private Object SyncChat = new Object();
private string localChat;
// put the buffer item into the chat string.
// append the buffer item into the chat.
// optionally, append buffer item into buffer list.
public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer)
{
// tell the world that a chat line is added.
ChatLineAdded?.Invoke(this, new ChatLineAddedArgs(item));
lock (SyncChat)
@@ -201,14 +151,10 @@ namespace Raindrop
}
}
public ITextPrinter TextPrinter { get; set; }
//process sending-out of local chat
internal void ProcessChatInput(string input, ChatType type)
{
//TextPrinter.ClearText();
string msg;
msg = input.Length >= 1000 ? input.Substring(0, 1000) : input;
//msg = msg.Replace(ChatInputBox.NewlineMarker, Environment.NewLine);
@@ -227,28 +173,14 @@ namespace Raindrop
msg = m.Groups[2].Value;
}
//if (instance.CommandsManager.IsValidCommand(msg))
//{
// instance.CommandsManager.ExecuteCommand(msg);
//}
//else
//{
#region RLV
#endregion
var processedMessage = GestureManager.Instance.PreProcessChatMessage(msg).Trim();
if (!string.IsNullOrEmpty(processedMessage))
{
netcom.ChatOut(processedMessage, type, ch);
}
//}
}
//Used only for non-public chat
private void ProcessOutgoingChat(ChatSentEventArgs e)
{
@@ -302,16 +234,6 @@ namespace Raindrop
|| (me.Type == MuteType.ByName && me.Name == e.FromName) // Object muted by name
)) return;
// if (instance.RLV.Enabled && e.Message.StartsWith("@"))
// {
// instance.RLV.TryProcessCMD(e);
//#if !DEBUG
// if (!instance.RLV.EnabledDebugCommands) {
// return;
// }
//#endif
// }
ChatBufferItem item = new ChatBufferItem {ID = e.SourceID, RawMessage = e};
StringBuilder sb = new StringBuilder();
@@ -404,9 +326,10 @@ namespace Raindrop
sb = null;
}
//reprint all the text in the printer.
public void ReprintAllText()
{
//TextPrinter.ClearText();
TextPrinter.ClearText();
foreach (ChatBufferItem item in textBuffer)
{
@@ -418,8 +341,6 @@ namespace Raindrop
{
textBuffer.Clear();
}
//public ITextPrinter TextPrinter { get; set; }
}
public class ChatLineAddedArgs : EventArgs
@@ -1,6 +1,5 @@
using Raindrop;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Raindrop.ServiceLocator;
@@ -44,30 +43,27 @@ public class CanvasManager : MonoBehaviour
public void resetToInitialScreen()
{
if (! getEulaAcceptance())
if (! GetEulaAcceptance())
{
canvasControllerList.ForEach(x => x.gameObject.SetActive(false));
pushCanvas(CanvasType.Eula);
Push(CanvasType.Eula);
}
else
{
canvasControllerList.ForEach(x => x.gameObject.SetActive(false));
pushCanvas(main);
Push(main);
}
}
private bool getEulaAcceptance()
private bool GetEulaAcceptance()
{
if (ServiceLocator.Instance.Get<RaindropInstance>().GlobalSettings["EulaAccepted"])
{
Debug.Log("User has already accepted the EULA");
return true;
}
else
{
Debug.Log("User has NOT accepted the EULA");
return false;
}
}
@@ -95,25 +91,21 @@ public class CanvasManager : MonoBehaviour
return CanvasType.UNKNOWN;
}
public void pushCanvas(string _type)
{
pushCanvasWithOrWithoutPop(_type, false);
}
//isPopCurrentActiveCanvas true will pop the current top canvas and then push the new desired one.
public void pushCanvasWithOrWithoutPop(string _type, bool isPopCurrentActiveCanvas)
//pop current, then push the desired canvas.
public void PopAndPush(CanvasType type)
{
CanvasType theCanvasType = getCanvasTypeFromString(_type);
if (theCanvasType ==CanvasType.UNKNOWN)
{
Debug.LogError("unable to get the canvas of identifer: "+ _type);
}
if (isPopCurrentActiveCanvas)
{
popCanvas();
}
pushCanvas(theCanvasType);
PopCanvas();
Push(type);
// CanvasType theCanvasType = getCanvasTypeFromString(_type);
// if (theCanvasType ==CanvasType.UNKNOWN)
// {
// Debug.LogError("unable to get the canvas of identifer: "+ _type);
// }
//
// popCanvas();
// pushCanvas(theCanvasType);
}
// pop the current login screen, and push the game view. This is for viewing chats offline.
@@ -124,43 +116,38 @@ public class CanvasManager : MonoBehaviour
{
activeCanvasStack.Pop();
}
pushCanvasWithOrWithoutPop("Game", false);
PopAndPush(CanvasType.Game);
}
public void pushCanvas(CanvasType _type)
public void Push(CanvasType type)
{
//deactivate present canvas
if (activeCanvasStack.Count() != 0)
{
var lastActiveCanvas = activeCanvasStack.Peek();
//i think the old canvas will essentially be 'frozen in time'
lastActiveCanvas.gameObject.SetActive(false);
}
CanvasIdentifier desiredCanvas = canvasControllerList.Find(x => x.canvasType == _type);
//find the new canvas to push.
CanvasIdentifier desiredCanvas = canvasControllerList.Find(x => x.canvasType == type);
if (desiredCanvas != null)
{
desiredCanvas.gameObject.SetActive(true);
activeCanvasStack.Push (desiredCanvas);
}
else { Debug.LogWarning("The desired canvas was not found!"); }
else { Debug.LogWarning("The desired canvas was not found!" + desiredCanvas.ToString()); }
}
public void popCanvas()
public void PopCanvas()
{
if (activeCanvasStack.Count() == 0)
var topCanvas = activeCanvasStack.Peek();
if (! topCanvas)
{
Debug.LogWarning("tried to pop empty canvas stack.");
return;
}
var lastActiveCanvas = activeCanvasStack.Peek();
if (lastActiveCanvas != null)
{
lastActiveCanvas.gameObject.SetActive(false); //this lince causes error, as the function was called from the login thread!
activeCanvasStack.Pop();
}
topCanvas.gameObject.SetActive(false); //this lince causes error, as the function was called from the login thread!
activeCanvasStack.Pop();
}
}
+41 -225
View File
@@ -14,17 +14,31 @@ using TMPro;
using System.Text.RegularExpressions;
using Raindrop.Core;
using Raindrop.Services;
using UnityEngine.Serialization;
using Quaternion = UnityEngine.Quaternion;
using Vector3 = UnityEngine.Vector3;
//view(unitytext) -- presenter(this) -- controller(this?) -- model (raindropinstance singleton)
//view(unitytext) -- presenter(this) -- controller(this?) -- model (raindropinstance singleton)
//5_jan_2022 : view(unity UI) --has a component--> chatpresenter(this, monobehavior)
// -> unityPresenterManager(not monobehavior)
// -> chattextmaanager(seems to handle all the local chat printing and events.)
// -> chattextprinter(monobehavior. depedency injected all the way down from root.)
namespace Raindrop.Presenters
{
//this class is attached to the chatview gameobject.
//it launches the manager that takes care of incoming and outgoing chats.
public class ChatPresenter : MonoBehaviour
{
/* +---------------------------+
* | Local ^ | [user1] Yo! |
* | IM 1 | | [user2] oh hey |
* | IM 2 | | ... |
* | | |____________ ____|
* | v | reply... |SEND|
* +-------------------------+
*/
//left pane: scrollable list of chats.
//right pane: the contents of the selected chat in the left pane.+
// input bar of the text to send to said chat.
@@ -33,16 +47,9 @@ namespace Raindrop.Presenters
private RaindropNetcom netcom { get { return instance.Netcom; } }
private GridClient client => instance.Client;
bool Active => instance.Client.Network.Connected;
private ChatManager chatManager;
public readonly Dictionary<UUID, ulong> agentSimHandle = new Dictionary<UUID, ulong>();
private static readonly string LOCALCHATTITLE = "Local Chat";
public int selectedChatIdx = -1; //-1 means public chat
private ChatPresenterManager _chatPresenterManager;
#region references to UI elements
[Tooltip("button to close the chat view")]
@@ -51,36 +58,25 @@ namespace Raindrop.Presenters
public Button SendButton;
[Tooltip("list of chats. buttons.")]
public GameObject ChatButtonContainer;
public GameObject ChatsListRoot;
public List<GameObject> ChatButtons;
//public GameObject SelectedButton;
[Tooltip("user types here.")]
[Tooltip("user input field")]
public TMP_InputField ChatInputField;
[Tooltip("show the current chat the user is viewing")]
[Tooltip("contents of currently-selected chat")]
public TMP_Text ChatBox;
//the printer that is printing into the big chat box.
[Tooltip("chatbox's printer component")]
public TMPTextFieldPrinter localChatPrinter;
#endregion
#region internal representations
private List<string> chatTitles= new List<string>
{
LOCALCHATTITLE
};
private string msgtext;
private string inputString;
public GameObject buttonPrefab;
#endregion
// Use this for initialization
void Start()
{
CloseButton.onClick.AsObservable().Subscribe(_ => OnCloseBtnClick()); //when clicked, runs this method.
@@ -88,189 +84,58 @@ namespace Raindrop.Presenters
ChatInputField.onValueChanged.AsObservable().Subscribe(_ => OnInputChanged(_)); //change username property.
RegisterClientEvents(client);
//check if printer is attached to textbox. else attach it.
localChatPrinter = ChatBox.gameObject.GetComponent<TMPTextFieldPrinter>();
if (!localChatPrinter)
{
localChatPrinter = ChatBox.gameObject.AddComponent<TMPTextFieldPrinter>();
//OpenMetaverse.Logger.Log("failed to make the tmp_printer component to the tmp textbox.", Helpers.LogLevel.Error);
}
chatManager = new ChatManager(instance, localChatPrinter);
// chatManager.localChatManager.ChatLineAdded += LocalChatManager_ChatLineAdded;
//startChat(true);
_chatPresenterManager = new ChatPresenterManager(instance, localChatPrinter);
AddChatTabToListOfChats("localChat");
}
// private void LocalChatManager_ChatLineAdded(object sender, ChatLineAddedArgs e)
// {
// //new message in local chat! print it.
// ChatBufferItem item = e.Item;
// runPrinterOnItem(tmp_printer, item);
// }
//id relative to the list. -1 means local. 0 means others.
public void setShowingChat(int id)
//append another chat to the chat-list.
public void AddChatTabToListOfChats(string name)
{
if (id == -1)
{
//print everything in text buffer list.
List<ChatBufferItem> x = chatManager.localChatManager.getChatBuffer();
// runPrinterOnList(tmp_printer, x, 0,20); //print the selected range into the UI
}
}
//
// public void runPrinterOnItem(TMPTextFieldPrinter TextPrinter, ChatBufferItem item)
// {
// //ChatBufferItem item = x[i];
//
// if (/*showTimestamps*/ true)
// {
// //if(fontSettings.ContainsKey("Timestamp"))
// //{
// // var fontSetting = fontSettings["Timestamp"];
// // TextPrinter.ForeColor = fontSetting.ForeColor;
// // TextPrinter.BackColor = fontSetting.BackColor;
// // TextPrinter.Font = fontSetting.Font;
// // TextPrinter.PrintText(item.Timestamp.ToString("[HH:mm] "));
// //}
// //else
// //{
// //TextPrinter.ForeColor = SystemColors.GrayText;
// //TextPrinter.BackColor = Color.Transparent;
// //TextPrinter.Font = Settings.FontSetting.DefaultFont;
// TextPrinter.PrintText(item.Timestamp.ToString("[HH:mm] "));
// //}
// }
//
// //if(fontSettings.ContainsKey("Name"))
// //{
// // var fontSetting = fontSettings["Name"];
// // TextPrinter.ForeColor = fontSetting.ForeColor;
// // TextPrinter.BackColor = fontSetting.BackColor;
// // TextPrinter.Font = fontSetting.Font;
// //}
// //else
// //{
// //TextPrinter.ForeColor = SystemColors.WindowText;
// //TextPrinter.BackColor = Color.Transparent;
// //TextPrinter.Font = Settings.FontSetting.DefaultFont;
// //}
//
// if (item.Style == ChatBufferTextStyle.Normal && item.ID != UUID.Zero && instance.GlobalSettings["av_name_link"])
// {
// TextPrinter.InsertLink(item.From, $"secondlife:///app/agent/{item.ID}/about");
// }
// else
// {
// TextPrinter.PrintText(item.From);
// }
//
// //if(fontSettings.ContainsKey(item.Style.ToString()))
// //{
// // var fontSetting = fontSettings[item.Style.ToString()];
// // TextPrinter.ForeColor = fontSetting.ForeColor;
// // TextPrinter.BackColor = fontSetting.BackColor;
// // TextPrinter.Font = fontSetting.Font;
// //}
// //else
// //{
// // TextPrinter.ForeColor = SystemColors.WindowText;
// // TextPrinter.BackColor = Color.Transparent;
// // TextPrinter.Font = Settings.FontSetting.DefaultFont;
// //}
//
// TextPrinter.PrintTextLine(item.Text);
// }
//
// //you can run the printer when a new text comes in.
// //or you can run it when the user opens a new chat and you gotta update the chat text.
// public void runPrinterOnList(TMPTextFieldPrinter TextPrinter, List<ChatBufferItem> x, int rangeNew, int rangeOld)
// {
// for (int i = rangeNew; i < rangeOld; i++)
// {
// runPrinterOnItem(TextPrinter, x[i]);
// }
// }
//adds another chat to the left side
public void startChat(bool isSimChat)
{
if (isSimChat)
{
//add button and set transforms
var chatButton = Instantiate(buttonPrefab, new Vector3(0, 0, 0), Quaternion.identity);
ChatButtons.Add(chatButton);
//SelectedButton = chatButton;
chatButton.transform.SetParent(ChatButtonContainer.transform);
//setup internal lcoalchat manager.
//ChatManager = new ChatTextManager(instance, tmp_printer); //you gotta pass the printer, not the gameobject.
} else
{
//var chatButton = Instantiate(buttonPrefab, new Vector3(0, 0, 0), Quaternion.identity);
//ChatButtons.Add(chatButton);
//SelectedButton = chatButton;
//chatButton.transform.SetParent(ChatButtonContainer.transform);
////IM = new ChatTextManager(instance, tmp_printer); //you gotta pass the printer, not the gameobject.
}
//add button and set transforms
var chatButton = Instantiate(buttonPrefab, new Vector3(0, 0, 0), Quaternion.identity);
ChatButtons.Add(chatButton);
chatButton.transform.SetParent(ChatsListRoot.transform);
}
private void OnDestroy()
{
UnregisterClientEvents(client);
chatManager.Dispose();
chatManager = null;
_chatPresenterManager.Dispose();
_chatPresenterManager = null;
}
private void OnInputChanged(string _)
{
msgtext = _;
inputString = _;
return;
}
private void OnSendBtnClick()
{
//public chat
ProcessChatInput(msgtext, ChatType.Normal);
Debug.Log("Sending chat to local");
chatManager.printToMainChat("sending message (test)");
ProcessChatInput(inputString, ChatType.Normal);
Debug.Log("Sending localchat to server");
}
private void OnCloseBtnClick()
{
var uimanager = ServiceLocator.ServiceLocator.Instance.Get<UIService>();
uimanager.canvasManager.popCanvas();
uimanager.canvasManager.PopCanvas();
}
private void RegisterClientEvents(GridClient client)
{
//client.Grid.CoarseLocationUpdate += new EventHandler<CoarseLocationUpdateEventArgs>(Grid_CoarseLocationUpdate);
client.Self.TeleportProgress += new EventHandler<TeleportEventArgs>(Self_TeleportProgress);
client.Network.SimDisconnected += new EventHandler<SimDisconnectedEventArgs>(Network_SimDisconnected);
}
private void UnregisterClientEvents(GridClient client)
{
//client.Grid.CoarseLocationUpdate -= new EventHandler<CoarseLocationUpdateEventArgs>(Grid_CoarseLocationUpdate);
client.Self.TeleportProgress -= new EventHandler<TeleportEventArgs>(Self_TeleportProgress);
client.Network.SimDisconnected -= new EventHandler<SimDisconnectedEventArgs>(Network_SimDisconnected);
}
//adds a tab for this particular IM session
@@ -283,54 +148,8 @@ namespace Raindrop.Presenters
//return imTab;
}
void Self_TeleportProgress(object sender, TeleportEventArgs e)
{
if (e.Status == TeleportStatus.Progress || e.Status == TeleportStatus.Finished)
{
//ResetAvatarList();
}
}
private void Network_SimDisconnected(object sender, SimDisconnectedEventArgs e)
{
try
{
//if (InvokeRequired)
//{
// if (!instance.MonoRuntime || IsHandleCreated)
// BeginInvoke(new MethodInvoker(() => Network_SimDisconnected(sender, e)));
// return;
//}
lock (agentSimHandle)
{
var h = e.Simulator.Handle;
List<UUID> remove = new List<UUID>();
foreach (var uh in agentSimHandle)
{
if (uh.Value == h)
{
remove.Add(uh.Key);
}
}
if (remove.Count == 0) return;
}
}
catch (Exception ex)
{
Debug.LogError("Failed to update radar: " + ex);
}
}
//process the content of the inputfield to send to the simulator as local chat
//send message into local chat
public void ProcessChatInput(string input, ChatType type)
{
if (string.IsNullOrEmpty(input)) return;
@@ -338,7 +157,7 @@ namespace Raindrop.Presenters
//call the ProcessChatInput in the respective manager class.
if (/*chatList.getSelected() == "local chat"*/ true)
{
chatManager.localChatManager.ProcessChatInput(input, type);
_chatPresenterManager.LocalLocalChat.ProcessChatInput(input, type);
}
//else
@@ -348,10 +167,7 @@ namespace Raindrop.Presenters
// chatHistory.Add(cbxInput.Text);
// chatPointer = chatHistory.Count;
//}
ClearChatInput();
netcom.ChatOut(inputString, ChatType.Normal, 0);
}
+2 -2
View File
@@ -163,13 +163,13 @@ namespace Raindrop.Presenters
public void OnChatBtnClick()
{
uimanager.canvasManager.pushCanvas(CanvasType.Chat);
uimanager.canvasManager.Push(CanvasType.Chat);
}
public void OnMapBtnClick()
{
uimanager.canvasManager.pushCanvas(CanvasType.Map);
uimanager.canvasManager.Push(CanvasType.Map);
}
+1 -1
View File
@@ -185,7 +185,7 @@ namespace Raindrop.Presenters
instance.Client.Groups.RequestCurrentGroups();
uimanager.modalManager.showModalNotification("Logging in process...","Logged in !");
uimanager.canvasManager.pushCanvasWithOrWithoutPop("Game", true); //refactor needed: better way to schedule push and pop as we are facing some issues here.
uimanager.canvasManager.PopAndPush(CanvasType.Game);
//instance.UI.canvasManager.popCanvas();
LoginButton.interactable = true;
break;
@@ -94,14 +94,13 @@ namespace Raindrop
}
#region ITextPrinter Members
public void PrintText(string text)
{
rtb.text = rtb.text + text;
//else
//{
FindURLs(text);
// FindURLs(text);
//}
}
+100 -9
View File
@@ -688,6 +688,25 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &89864945 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 361051093761253963, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
m_PrefabInstance: {fileID: 1369961384}
m_PrefabAsset: {fileID: 0}
--- !u!114 &89864946
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 89864945}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e2c84a856e3e4e442822ff4c7870a1c3, type: 3}
m_Name:
m_EditorClassIdentifier:
canvasTypeToPush: 1
popCurrent: 1
--- !u!1 &94005489
GameObject:
m_ObjectHideFlags: 0
@@ -763,6 +782,25 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 94005489}
m_CullTransparentMesh: 1
--- !u!1 &100122705 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 361051094640251306, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
m_PrefabInstance: {fileID: 1369961384}
m_PrefabAsset: {fileID: 0}
--- !u!114 &100122706
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 100122705}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e2c84a856e3e4e442822ff4c7870a1c3, type: 3}
m_Name:
m_EditorClassIdentifier:
canvasTypeToPush: 5
popCurrent: 0
--- !u!1 &125379937
GameObject:
m_ObjectHideFlags: 0
@@ -3140,7 +3178,8 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Children:
- {fileID: 829731402}
m_Father: {fileID: 0}
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -3151,7 +3190,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 609529405}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fa47482bed1a47e29216fc5416bb73ba, type: 3}
m_Name:
@@ -4710,6 +4749,50 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 16
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &829731401
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 829731402}
- component: {fileID: 829731403}
m_Layer: 7
m_Name: 3DSceneSpawner
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &829731402
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 829731401}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 609529406}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &829731403
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 829731401}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fa47482bed1a47e29216fc5416bb73ba, type: 3}
m_Name:
m_EditorClassIdentifier:
ObjectPrefab: {fileID: 3767279658298423867, guid: bbf350bf4403f494eb2f02fa73a70779, type: 3}
--- !u!1 &831097301
GameObject:
m_ObjectHideFlags: 0
@@ -7143,9 +7226,13 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 338201708}
m_Modifications:
- target: {fileID: 361051093761253961, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
propertyPath: onClick.m_PersistentCalls.m_Calls.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 361051093761253961, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
propertyPath: onClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 1
value: 5
objectReference: {fileID: 0}
- target: {fileID: 361051093761253961, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
propertyPath: onClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
@@ -7157,7 +7244,7 @@ PrefabInstance:
objectReference: {fileID: 338201709}
- target: {fileID: 361051093761253961, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
propertyPath: onClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: popCanvas
value: pushCanvas
objectReference: {fileID: 0}
- target: {fileID: 361051093761253961, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
propertyPath: onClick.m_PersistentCalls.m_Calls.Array.data[1].m_MethodName
@@ -7183,6 +7270,10 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: -94.3267
objectReference: {fileID: 0}
- target: {fileID: 361051094640251304, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
propertyPath: onClick.m_PersistentCalls.m_Calls.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 361051094640251304, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
propertyPath: onClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
@@ -8441,7 +8532,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7869931064171861450, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3}
propertyPath: m_AnchoredPosition.y
value: -0.00012868317
value: -0.000041463845
objectReference: {fileID: 0}
- target: {fileID: 7869931064171861451, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3}
propertyPath: m_ChildControlWidth
@@ -8525,7 +8616,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7869931064370213011, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3}
propertyPath: m_SizeDelta.x
value: 796.31476
value: 1412.3885
objectReference: {fileID: 0}
- target: {fileID: 7869931064370213011, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3}
propertyPath: m_SizeDelta.y
@@ -8533,7 +8624,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7869931064370213011, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3}
propertyPath: m_AnchoredPosition.x
value: 408.15738
value: 716.1943
objectReference: {fileID: 0}
- target: {fileID: 7869931064370213011, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3}
propertyPath: m_AnchoredPosition.y
@@ -8750,7 +8841,7 @@ PrefabInstance:
- target: {fileID: 7869931065211819622, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3}
propertyPath: localChatPrinter
value:
objectReference: {fileID: 1984392858}
objectReference: {fileID: 1984392860}
- target: {fileID: 7869931065226065626, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3}
propertyPath: m_AnchorMax.y
value: 0
@@ -10355,7 +10446,7 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 7869931064370213010, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3}
m_PrefabInstance: {fileID: 1679152091}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1984392858
--- !u!114 &1984392860
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
+1 -2
View File
@@ -1981,8 +1981,7 @@ PrefabInstance:
objectReference: {fileID: 904771132}
- target: {fileID: 361051093761253961, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
propertyPath: onClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: popCanvas
objectReference: {fileID: 0}
value:PopCanvas objectReference: {fileID: 0}
- target: {fileID: 361051093761253961, guid: b48e30ed103c4324a9e537dd82576993, type: 3}
propertyPath: onClick.m_PersistentCalls.m_Calls.Array.data[1].m_MethodName
value: pushCanvas
+1 -1
View File
@@ -8534,7 +8534,7 @@ MonoBehaviour:
m_Calls:
- m_Target: {fileID: 904771132}
m_TargetAssemblyTypeName: CanvasManager, RaindropUnity
m_MethodName: popCanvas
m_MethodName: PopCanvas
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}