public MobileControlView GetViewById(int id) { MobileControlView result = _viewList.Find(delegate(MobileControlView view) { return(view.ViewID == id); }); return(result); }
public void ActivateView(MobileControlView nextView) { // Disable current view: MobileControlView curView = GetCurrentView(); if (curView != null) { curView.DisableView(); } // Enable the next one: nextView.EnableView(); }
public void ActivateNextView() { // Disable current view: MobileControlView curView = GetCurrentView(); curView.DisableView(); int curIndex = _viewList.IndexOf(curView); curIndex = (curIndex + 1) % _viewList.Count; // Enable the next one: MobileControlView nextView = _viewList[curIndex]; nextView.EnableView(); }
public void RegisterView(MobileControlView view) { _viewList.Add(view); _viewList.Sort(delegate(MobileControlView v1, MobileControlView v2) { return(v1.ViewID.CompareTo(v2.ViewID)); }); if (_viewList.Count == 1) { ActivateView(view); } // Update information on mobile device: tcpManager.AddMessage(CreateWindowListMessage()); }
public void UnregisterView(MobileControlView view) { if (view.IsActive) { ActivateNextView(); } _viewList.Remove(view); if (_viewList.Count > 0) { // Update information on mobile device: tcpManager.AddMessage(CreateWindowListMessage()); } else { Debug.LogWarning("MobileControlManager.UnregisterView(): Every view has been unregistered. No active view is left!"); } }
public void ActivatePreviousView() { // Disable current view: MobileControlView curView = GetCurrentView(); curView.DisableView(); int curIndex = _viewList.IndexOf(curView); curIndex--; if (curIndex < 0) { curIndex += _viewList.Count; } // Enable the next one: MobileControlView previousView = _viewList[curIndex]; previousView.EnableView(); }
protected virtual void LateUpdate() { if (_viewList.Count > 0) { if (GetCurrentView() == null) { _viewList[0].EnableView(); } Message message = null; while ((message = tcpManager.GetNextReceivedMessage()) != null) { switch (message.Command) { case Command.GET_WINDOWS: { tcpManager.AddMessage(CreateWindowListMessage()); //Debug.Log("Received GetWindows Message."); } break; case Command.GET_WINDOW_BY_NUMBER: { GetWindowByNumberMessage getWindowByNumMsg = new GetWindowByNumberMessage(message.Bytes); getWindowByNumMsg.UnpackReceivedMessage(); int requestedWindowNumber = (int)getWindowByNumMsg.WindowNumber; //Message viewMsg = null; if (requestedWindowNumber >= 0 && requestedWindowNumber < _viewList.Count) { MobileControlView nextView = _viewList[requestedWindowNumber]; if (nextView.IsActive == false) // No view is active, so set one active (will send a setViewMessage to the client.) { ActivateView(nextView); } else // A view is currently active but the client asks again about the correct view (e.g. after a reconnect). { tcpManager.SetViewMessage(tcpManager.CurrentViewMessage); } } else { Debug.LogError("The requested Window-Number (" + requestedWindowNumber + ") is out of range of the amount of currently available windows (" + _viewList.Count + ")."); } //Debug.Log("Received GetWindowByNumber Message."); } break; case Command.GET_SCENE_MENU: { tcpManager.AddMessage(CreateSceneMenuMessage()); } break; case Command.CHOSE_SCENE: // Set the MSC as current view and tell it about the requested scene: { // A Menu Entry has been chosen. We send this information directly back to the mobile device so that it gets highlighted in the menu. ChoseSceneMessage choseSceneMsg = new ChoseSceneMessage(message.Bytes); choseSceneMsg.UnpackReceivedMessage(); tcpManager.AddMessage(choseSceneMsg); } break; case Command.USE_MICRO_STORY_CONTROL: { // This is a special command button in the middle of the top view. // You have to send a view to the mobile control, else the mobile control only shows the loading symbol. ActivateView(_viewList[0]); // I just take the first one here, but you can chose another one if you want (e.g. some kind of main view). } break; case Command.UNKNOWN: Debug.LogError("Received Unknown Message Command."); break; default: // Process any other message that is directed to the current view: GetCurrentView().ProcessMessage(message); break; } // Tell all passive views about the currently processed Message: foreach (MobileControlPassiveView passiveView in _passiveViewList) { passiveView.GotMessage(message); } } } }