public static void HandleRoomVariableUpdate(UserVariable userVar) { RoomVariableUrlController controller = null; if (allRmVarControllers.TryGetValue(userVar.Name, out controller)) { controller.SetNewURL(userVar.GetStringValue(), false); } }
public static void HandleRoomVariableUpdate(BaseEvent evt) { Room room = (Room)evt.Params["room"]; RoomVariableUrlController controller = null; ArrayList changedVars = (ArrayList)evt.Params["changedVars"]; foreach (string varName in changedVars) { if (allRmVarControllers.TryGetValue(varName, out controller)) { controller.SetNewURL(room.GetVariable(varName).GetStringValue(), false); } } }
// Shows the active collabBrowser in the corner of the screen. void DrawPresenterTool() { GUI.color = Color.white; if (presenterToolCollabBrowser == null) { return; } // Pull texture from collabBrowserTexture Texture2D presenterToolTexture = presenterToolCollabBrowser.GetTexture(); Rect presenterToolRect = GetPresenterToolRect(presenterToolTexture); // Get position of mouse relative to presenter tool. Vector2 mouseLocalPos = Vector2.zero; mouseLocalPos.x = (Input.mousePosition.x - presenterToolRect.x) / presenterToolRect.width; mouseLocalPos.y = ((Screen.height - presenterToolRect.y) - Input.mousePosition.y) / presenterToolRect.height; // Detect if mouse is in presenter tool. mouseInPresenterTool = mouseLocalPos.x >= 0f && mouseLocalPos.x <= 1f && mouseLocalPos.y >= 0f && mouseLocalPos.y <= 1f; if (mouseInPresenterTool) { presenterToolCollabBrowser.InjectMousePosition(new Vector2(-mouseLocalPos.x + 0.5f, -mouseLocalPos.y + 0.5f), true, Input.GetMouseButton(0)); PlayerController.ClickToMoveInterrupt(); } GUI.DrawTexture(presenterToolRect, presenterToolTexture); if (showPresentToolButtons) { presentToolResizeButton.SetPosition(VirCustomButton.Corner.bottomRight, (int)presenterToolRect.x, (int)presenterToolRect.y); presentToolResizeButton.Draw(); } // Scale to 0 'minimizes' the presenter tool. if (presentToolScale > 0) { // Close button only shows if the presenter is open. if (showPresentToolButtons) { presentToolCloseButton.SetPosition(VirCustomButton.Corner.topRight, (int)presenterToolRect.x, (int)presenterToolRect.y); presentToolCloseButton.Draw(); } // URL entry field if (GameGUI.Inst.IsVisible(GUIVis.PRESENTERINPUT) && GameManager.Inst.LocalPlayerType >= PlayerType.LEADER) { Rect presenterURLRect = new Rect(presenterToolRect.x + 5, presenterToolRect.y - 35, presenterToolRect.width - 5, 30); DrawConsoleGUIBar(presenterURLRect); Rect presenterURLTextRect = new Rect(presenterURLRect.x + 5, presenterURLRect.y + 3, presenterURLRect.width, presenterURLRect.height); // by default tab puts focus on unity text fields, disabling that here. if (!((Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t') && FocusManager.Inst.AnyKeyInputBrowsersFocused())) { GUI.SetNextControlName("presenterInput"); presenterURL = GUI.TextField(presenterURLTextRect, presenterURL); } Rect presenterURLTooltipRect = new Rect(presenterURLRect.x, presenterURLRect.y - 20, presenterURLRect.width, presenterURLRect.height); GUI.Label(presenterURLTooltipRect, "Enter URL:"); Event e = Event.current; // Enter a URL if (GUI.GetNameOfFocusedControl().Equals("presenterInput") && (e.isKey) && (e.keyCode == KeyCode.Return)) { presenterURL = WebStringHelpers.AppendHTTP(presenterURL); RoomVariableUrlController controller = presenterToolCollabBrowser.GetComponent <RoomVariableUrlController>(); if (controller != null) { controller.SetNewURL(presenterURL, true); } else { GameGUI.Inst.WriteToConsoleLog("Web panel does not have an associated room variable, url change is only local"); presenterToolCollabBrowser.GoToURL(presenterURL); } } } } float previousScale = presentToolScale; // Resize based on mouse position. if (presentToolResizeButton.IsDragged()) { presentToolScale = Mathf.Max(Mathf.Clamp((((presenterToolRect.x + presenterToolRect.width) - (Input.mousePosition.x + (presentToolResizeButton.width * 0.5f))) / presenterToolTexture.width), 0.3f, 1f), Mathf.Clamp((((presenterToolRect.y + presenterToolRect.height) - ((Screen.height - Input.mousePosition.y) + (presentToolResizeButton.height * 0.5f))) / presenterToolTexture.height), 0.3f, 1f)); } // Tool is minimized. if (presentToolCloseButton.IsClicked()) { presentToolScale = 0f; presentToolCloseButton.Close(); } if (GameGUI.Inst.guiLayer != null && sendGuiPresentToolUpdates && (forceSendNextGuiPresentToolRect || (previousScale != presentToolScale))) { GameGUI.Inst.guiLayer.SendGuiLayerPresenterToolInfo(GetPresenterToolRect(presenterToolTexture)); } forceSendNextGuiPresentToolRect = false; // Handle actions if (!presentToolResizeButton.IsDragged() && mouseInPresenterTool) { Event e = Event.current; if ((e.type != EventType.ScrollWheel) || (presenterToolCollabBrowser.enableScrollWheel)) { presenterToolCollabBrowser.HandleBrowserEvent(e, (int)(mouseLocalPos.x * presenterToolCollabBrowser.width), (int)((1 - mouseLocalPos.y) * presenterToolCollabBrowser.height)); } } }
public void SetNewURL(string url, bool updateServer) { urlController.SetNewURL(url, updateServer); }