Esempio n. 1
0
 public PlanEntry(IUnityContainer container, UIState state, long id)
     : this()
 {
     this.container = new PlanContainer(container, state, id);
     binding = new BindingSource();
     binding.AddingNew += Binding_AddingNew;
 }
Esempio n. 2
0
    void Update()
    {
        if(Input.GetButtonDown("Start"))
        {
            // Start will open the menu if in game, or will close any other menu screen and return to game.
            switch((int)state)
            {
                case 0: // Game
                    state = UIState.MENU;
                    GameManager.inst.player.GetComponent<Player>().controlsEnabled = false;
                    break;
                default:
                    state = UIState.GAME;
                    GameManager.inst.player.GetComponent<Player>().controlsEnabled = true;
                    break;
            }
            UpdateUIState();
        }

        goldText.text = "" + GameManager.inst.inventory.gold;
        healthText.text = GameManager.inst.stats.hpCur + "/" + GameManager.inst.stats.hpMax;

        // Will need to move these into a function call when required, rather than every update.
        imgWep1.sprite = GameManager.inst.activeItems.wepSlot1.GetComponent<SpriteRenderer>().sprite;

        if(GameManager.inst.activeItems.wepSlot2)
            imgWep2.sprite = GameManager.inst.activeItems.wepSlot2.GetComponent<SpriteRenderer>().sprite;
    }
    public GameUIManager()
    {
          int max = System.Enum.GetNames (typeof(MainUIState)).Length;
		m_UIStates = new UIState[max];
		for (int i = 0; i <max; i++) 
		{
			m_UIStates [i] = new UIState();
		}
        Debug.Log("Count of m_uistates" + m_UIStates.Length);
    }
Esempio n. 4
0
	// Use this for initialization
	void Start () {
		Shop.gameObject.SetActive(true);
		Closet.gameObject.SetActive(false);
		Bag.gameObject.SetActive(false);
	
		m_currentState = Shop;
		m_currentState.OnEnter();
		
		m_nextState = m_currentState;		
	}
Esempio n. 5
0
 void Awake()
 {
     if (s_instance == null)
     {
         s_instance = this;
     }
     else
     {
         Debug.LogError("Bad singleton with UIState");
     }
 }
    private void SetState(UIState state)
    {
        if (state == UIState.Menu)
        {
            m_PrevState = m_CurrentState;
        }

        m_CurrentState = state;

        if (m_CurrentState != UIState.Menu)
        {
            AllControls.Where(c => c.UIState != m_CurrentState).ToList().ForEach(c => c.Hide());
        }
        switch (m_CurrentState)
        {
        case UIState.StartScreen:
            StartScreen.Show();
            break;

        case UIState.Introduction:
            Introduction.Show();
            break;

        case UIState.Tasks:
            Tasks.Show(MainManager.Instance.PersonInfo, MainManager.Instance.CurrentBuildingInfo.URL);
            break;

        case UIState.AR:
            AR.Show();
            VuforiaBehaviour.Instance.enabled = true;
            break;

        case UIState.Test:
            Test.Show(MainManager.Instance.CurrentBuildingInfo);
            break;

        case UIState.RightAnswer:
            RightAnswer.Show(MainManager.Instance.PrevBuildingInfo.RightAnswerMessage, MainManager.Instance.CurrentBuildingInfo.URL);
            break;

        case UIState.WrongAnswer:
            WrongAnswer.Show();
            break;

        case UIState.EndScreen:
            EndScreen.Show(MainManager.Instance.PersonInfo.EndMessage);
            break;

        case UIState.Menu:
            Menu.Show(MainManager.Instance.Helper);
            break;
        }
    }
Esempio n. 7
0
    private void ApplyState(UIState newState)
    {
        for (int i = 0; i < newState.disabled.Length; i++)
        {
            newState.disabled[i].SetActive(false);
        }

        for (int i = 0; i < newState.enabled.Length; i++)
        {
            newState.enabled[i].SetActive(true);
        }
    }
Esempio n. 8
0
 public void ConstructMap()
 {
     if (uiState == UIState.SubmitNewMap)
     {
         uiState = UIState.Default;
     }
     else
     {
         uiState = UIState.SubmitNewMap;
     }
     ChangeState(uiState);
 }
Esempio n. 9
0
 // -------------------------------------------------------------------------------
 //
 // -------------------------------------------------------------------------------
 public void RevertState()
 {
     if (stateStack.Count > 0)
     {
         UIState state = stateStack.Peek();
         UpdateUIState(state);
     }
     else
     {
         UpdateUIState(UIState.None);
     }
 }
Esempio n. 10
0
 public void DeleteData()
 {
     if (uiState == UIState.DeleteData)
     {
         uiState = UIState.Default;
     }
     else
     {
         uiState = UIState.DeleteData;
     }
     ChangeState(uiState);
 }
    public void EndGame()
    {
        uiState = UIState.END;
        int currentScore = GetComponent <Score>().score;

        if (currentScore > highScore)
        {
            highScore = currentScore;
        }
        allowGameplayInputs = false;
        StartCoroutine(SlowMotion());
    }
Esempio n. 12
0
        public override void ProcessState(UIState state)
        {
            bFinish = false;
            isIdle  = false;
            level   = (int)state.value0;

            SoundPlayer.GetInstance().PlaySoundType("level_up_" + mLocalPetInfoAgent.getCurrentPet());

            levelUpBlur.SetActive(true);
            levelUpAni.AnimationState.ClearTracks();
            levelUpAni.AnimationState.SetAnimation(1, "lv_enter", false);
        }
Esempio n. 13
0
 public void SwitchMode()
 {
     if (uiState == UIState.Workspace)
     {
         uiState = UIState.Visualize;
     }
     else
     {
         uiState = UIState.Workspace;
     }
     ChangeState(uiState);
 }
Esempio n. 14
0
 public void Options()
 {
     if (uiState == UIState.Options)
     {
         uiState = UIState.Default;
     }
     else
     {
         uiState = UIState.Options;
     }
     ChangeState(uiState);
 }
Esempio n. 15
0
    private IUIScreen GetScreenForState(UIState uiState)
    {
        for (int i = 0; i < this.UIScreens.Length; i++)
        {
            if (this.UIScreens[i].StateId == uiState)
            {
                return(this.UIScreens[i]);
            }
        }

        throw new System.NotImplementedException("UIScreen for state " + uiState.ToString() + "not found!");
    }
 public void ToggleSettingsPanel()
 {
     if (m_State == UIState.Settings)
     {
         m_State = UIState.Navigation;
     }
     else
     {
         m_State = UIState.Settings;
     }
     ChangeState(m_State);
 }
Esempio n. 17
0
 public void AlignMapsPrompt()
 {
     if (uiState == UIState.AlignMaps)
     {
         uiState = UIState.Default;
     }
     else
     {
         uiState = UIState.AlignMaps;
     }
     ChangeState(uiState);
 }
 public void Options()
 {
     state = UIState.OptionMenu;
     if (mainMenu != null)
     {
         mainMenu.SetActive(false);
     }
     if (optionMenu != null)
     {
         optionMenu.SetActive(true);
     }
 }
Esempio n. 19
0
 //取消事件
 private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     LoadBillMainList();
     LoadBPriceMain();
     gridControlPopupMaterial.Visible            = false;
     gridControlPopupMatSeq.Visible              = false;
     gridColumnStockNum.OptionsColumn.AllowEdit  = false;
     gridColumnStockNum.OptionsColumn.AllowFocus = false;
     gridColumnMaterialNewRetailPrice.Visible    = false;
     this._UIState_BillPriceMain = UIState.Default;
     ShowUIState();
 }
        public override void Hide(UIState ui)
        {
            base.Hide(ui);

            /*UIElement elem;
             * if( !ReflectionHelpers.Get( ui, "_rootElement", out elem ) && elem == null ) {
             *      LogHelpers.Alert( "_rootElement not found for " + ui.GetType().Name );
             * } else {
             *      elem.Left.Pixels -= UITagMenuButton.ButtonWidth;
             *      elem.Recalculate();
             * }*/
        }
    public void PauseGame()
    {
        isPaused            = true;
        allowGameplayInputs = false;

        previousTimeScale = Time.timeScale;
        Time.timeScale    = 0f;

        previousFixedDeltaTime = Time.fixedDeltaTime;
        Time.fixedDeltaTime    = 0f;
        uiState = UIState.PAUSE;
    }
Esempio n. 22
0
        public override void Show(UIState ui)
        {
            base.Show(ui);

            Timers.SetTimer("ModHelpersUpdatesLoaderPause", 5, () => {
                Promises.AddValidatedPromise <ModInfoListPromiseArguments>(GetModInfo.ModInfoListPromiseValidator, (args) => {
                    this.DisplayModListVersions(ui, args.ModInfo);
                    return(false);
                });
                return(false);
            });
        }
        ////////////////

        public override void Show(UIState ui)
        {
            if (this.OccludesLogo)
            {
                Main.instance.LoadProjectile(ProjectileID.ShadowBeamHostile);

                Main.logoTexture  = Main.projectileTexture[ProjectileID.ShadowBeamHostile];
                Main.logo2Texture = Main.projectileTexture[ProjectileID.ShadowBeamHostile];
            }

            this.MyUI = ui;
        }
Esempio n. 24
0
    void exitSupplyBox()
    {
        isSupply = false;

        state = UIState.NONE;

        exitUI();

        SupplyBoxUI.GetComponent <SupplyBoxController>().ClosedBox();

        SupplyBoxUI.SetActive(false);
    }
Esempio n. 25
0
 public void Tools()
 {
     if (uiState == UIState.Tools)
     {
         uiState = UIState.Default;
     }
     else
     {
         uiState = UIState.Tools;
     }
     ChangeState(uiState);
 }
Esempio n. 26
0
 public PlanContainer(IUnityContainer container, UIState state, Plan plan)
     : this(container, state)
 {
     if (state == UIState.New)
     {
         Entity = new Plan();
     }
     else
     {
         this.Entity = plan;
     }
 }
Esempio n. 27
0
 public void HandleOnWNDHide(string wnd_base_id)
 {
     Debug.LogWarning("camera move " + wnd_base_id);
     //当前是通过场景交互打开的UI,退出时播放相机拉远动画
     if (isFacing2Obj)
     {
         HandleOnExitUI();
         return;
     }
     //当前是通过非场景交互方式打开的UI,则不需要播放动画
     _uiState = UIState.Free;
 }
Esempio n. 28
0
 public PlanContainer(IUnityContainer container, UIState state, long id)
     : this(container, state)
 {
     if (state == UIState.New)
     {
         Entity = new Plan();
     }
     else
     {
         QueryPlanById(id);
     }
 }
 public void LoadGame()
 {
     state = UIState.LoadMenu;
     if (mainMenu != null)
     {
         mainMenu.SetActive(false);
     }
     if (loadMenu != null)
     {
         loadMenu.SetActive(true);
     }
 }
        private void DuplicateMissionComplete(UIState state)
        {
            this.uiDuplicateMission.uiPropsItems.ForEach(t => t.SetStatus(false));
            this.uiDuplicateMission.uiPropsItems[0].SetStatus(true);
            this.uiDuplicateMission.uiPropsItems[0].SetContent(this.uiDuplicateMission.CoinIcon, (int)state.value2);
            this.uiDuplicateMission.uiPropsItems[1].SetStatus(true);
            this.uiDuplicateMission.uiPropsItems[1].SetContent(this.uiDuplicateMission.ExpIcon, (int)state.value1);

            this.gameObject.SetActive(true);
            this.uiDuplicateMission.SetPosition(320.0f, 0.0f);
            SoundPlayer.GetInstance().PlaySoundType("mission_complete_init");
        }
 public void ToggleEditMode()
 {
     if (m_State == UIState.EditMode)
     {
         m_State = UIState.Navigation;
     }
     else
     {
         m_State = UIState.EditMode;
     }
     ChangeState(m_State);
 }
Esempio n. 32
0
    void OnState()
    {
        if (state == UIState.CREATE)
        {
            int             buildingWidth   = 5;
            int             buildingHeight  = 5;
            Vector2Int      mouseCoord      = World.nodeCoordFromWorldPos((Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition) - new Vector2((buildingWidth - 1) / 2f * 1.044f, 0));
            PlaceableReturn placeableReturn = Placeable(mouseCoord.x, mouseCoord.y, buildingWidth, buildingHeight);

            RemoveMarkers();

            if (Input.GetMouseButtonDown(0) && placeableReturn.placeable)
            {
                Building            building = new Building(Tower);
                List <BuildingNode> newNodes = new List <BuildingNode>();
                foreach (PlanetNode n in placeableReturn.placeableNodes)
                {
                    BuildingNode newNode = new BuildingNode(n.Q, n.R, n.worldPos, building);
                    newNodes.Add(newNode);
                    World.nodes[new Vector2Int(n.Q, n.R)] = newNode;
                    World.planetNodes.TryRemove(new Vector2Int(n.Q, n.R), out _);
                }
                building.buildingNodes = newNodes;

                HashSet <PlanetNode> workerNodes = new HashSet <PlanetNode>();
                foreach (PlanetNode n in placeableReturn.placeableNodes)
                {
                    foreach (PlanetNode neighbour in n.getNeighbours())
                    {
                        if (!workerNodes.Contains(neighbour))
                        {
                            workerNodes.Add(neighbour);
                        }
                    }
                }
                building.workerNodes = workerNodes;

                InstantiateJob j = new InstantiateJob(building);
                JobManager.instance.QueueJob(j);

                _workerNodes = workerNodes;

                ExitState(UIState.CREATE);
                state = UIState.IDLE;
                EnterState(state);
            }
            else
            {
                SetMarkers(placeableReturn);
            }
        }
    }
Esempio n. 33
0
 //开始游戏/重新布置
 public void AgainBtnOnClick()
 {
     if (again_t.text == "开始游戏~")//开始游戏
     {
         CurrentState = UIState.run;
         //重置所有小兵状态
         foreach (var item in GameObject.FindGameObjectsWithTag("Blue"))
         {
             if (item.GetComponent <Pawn1>() != null)
             {
                 item.GetComponent <Pawn1>().ChangeIdle();
             }
             else if (item.GetComponent <Pawn2>() != null)
             {
                 item.GetComponent <Pawn2>().ChangeIdle();
             }
         }
         //重置所有小兵状态
         foreach (var item in GameObject.FindGameObjectsWithTag("Red"))
         {
             if (item.GetComponent <Pawn1>() != null)
             {
                 item.GetComponent <Pawn1>().ChangeIdle();
             }
             else if (item.GetComponent <Pawn2>() != null)
             {
                 item.GetComponent <Pawn2>().ChangeIdle();
             }
         }
     }
     else//重新布置
     {
         CurrentState = UIState.select;
         again_t.text = "开始游戏~";
         againBtn.gameObject.SetActive(false);
         //蓝方胜清除在场所有蓝方小兵,反之...
         if (win)
         {
             foreach (var item in GameObject.FindGameObjectsWithTag("Blue"))
             {
                 Destroy(item);
             }
         }
         else
         {
             foreach (var item in GameObject.FindGameObjectsWithTag("Red"))
             {
                 Destroy(item);
             }
         }
     }
 }
Esempio n. 34
0
    public void Show3D()
    {
        NavigateImage.sprite = NavigateTo3D;

        if (!UIView3D.gameObject.activeSelf)
        {
            UIView3D.gameObject.SetActive(true);
        }

        UIView2D.gameObject.SetActive(false);

        State = UIState.VIEW_3D;
    }
Esempio n. 35
0
	// Update is called once per frame
	void Update () {
		if( m_currentState != m_nextState )
		{
			m_currentState.OnExit();
			m_currentState.gameObject.SetActive(false);
			
			m_nextState.OnEnter();
			m_nextState.gameObject.SetActive(true);
			m_currentState = m_nextState;
		}
		
		m_currentState.OnUpdate();
	}
Esempio n. 36
0
        public override void Unload()
        {
            // UI
            UI            = deadUI = null;
            UserInterface = deadUserInterface = null;

            // Other static Fields
            Camera.Target = null;
            Camera.Locked = false;

            // Hotkeys
            nextPlayer = prevPlayer = null;
        }
Esempio n. 37
0
    public void LevelDone(float timeInSeconds)
    {
        System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, Mathf.RoundToInt(timeInSeconds * 1000f));
        string          s  = "" + ts.Seconds + "." + ts.Milliseconds;

        if (ts.Minutes > 0)
        {
            s = s.Insert(0, ts.Minutes + ":");
        }
        timeLabel.text = s;
        animator.SetTrigger("game_over");
        uiState = UIState.GameOver;
    }
Esempio n. 38
0
    public UIState PopState()
    {
        if (uiStateStack.Count == 0)
        {
            return(null);
        }

        UIState uiState = uiStateStack.Pop();

        uiState.Exit();
        uiStateStack.Peek().Enter();
        return(uiState);
    }
Esempio n. 39
0
    private void changeState(UIState state)
    {
        if (m_currentState == UIState.MAINMENU && state == UIState.OPTIONS)
        {
            m_currAnimState = AnimState.MAINMENU_TO_OPTIONS;
            m_currentState = UIState.OPTIONS;

        }
        else
        if ( m_currentState == UIState.OPTIONS && state == UIState.MAINMENU )
        {
            m_currAnimState = AnimState.OPTIONS_TO_MAINMENU;
            m_currentState = UIState.MAINMENU;
        }
    }
Esempio n. 40
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 0, 100, 20), "Create State"))
        {
            UIState newState = new UIState();
            if (m_UIStates.Count == 0) { newState.IsRoot = true; }
            newState.StateName = string.Format ("State {0}", m_UIStates.Count);
            newState.Window = this;
            m_UIStates.Add(newState);
        }

        BeginWindows();
        for (int i = 0; i < m_UIStates.Count; i++)
        {
            m_UIStates[i].StateRect = GUI.Window(i, m_UIStates[i].StateRect,
                                                    m_UIStates[i].DrawState,
                                                    m_UIStates[i].StateName);
        }
        EndWindows();
    }
 private void ChangeState(UIState state)
 {
     Debug.Log("C#: change state: " + state);
     switch (state) {
     case UIState.Placement:
         mainUIView.enabled = true;
         eventUIView.enabled = false;
         userUIView.enabled = false;
         break;
     case UIState.Event:
         mainUIView.enabled = false;
         eventUIView.enabled = true;
         userUIView.enabled = false;
         break;
     case UIState.User:
         mainUIView.enabled = false;
         eventUIView.enabled = false;
         userUIView.enabled = true;
         break;
     }
     uiState = state;
 }
Esempio n. 42
0
 private void ChangeUIState(UIState state)
 {
     userInterfaceState = state;
     switch (state)
     {
         case UIState.AddState:
             taskTitleTextBox.Text = "";//Clear boxes
             descriptionTextBox.Text = "";
             dateField.Text = "";
             priorityDropBox.Text = "";
             addTaskButton.IsEnabled = true;
             changeTaskButton.IsEnabled = false;
             break;
         case UIState.EditState:
             taskTitleTextBox.Text = "";//Clear boxes
             descriptionTextBox.Text = "";
             dateField.Text = "";
             priorityDropBox.Text = "";
             addTaskButton.IsEnabled = false;
             changeTaskButton.IsEnabled = true;
             break;
     }
 }
Esempio n. 43
0
    public void ButtonClicked(string buttonState)
    {
        //clearUI();
        switch (buttonState)
        {
            case "Movement":
                History.Push(currentState);
                currentState = UIState.Movement;
                break;
            case "Attack":
                History.Push(currentState);
                currentState = UIState.Attacking;
                break;
            case "Standby": // Standby button is pressed

                // The selected character can no longer act during the turn
                // The next character is then selected

                selectedCharacter.canAct = false;
                FindNextCharacter();
                break;
            case "Back":
                CleanMap();

                currentState = (UIState)History.Pop();
                break;
            case "Hold":
                CleanMap();
                currentState = UIState.Default;
                UIUpdate();
                break;
            default:
                currentState = UIState.Default;
                break;
        }
        UIUpdate();
    }
        private void clickManualControl(UIComponent component, UIMouseEventParameter eventParam)
        {
            if (_uiState != UIState.ManualSwitch)
            {
                _uiState = UIState.ManualSwitch;

                _buttonManualControl.focusedBgSprite = "ButtonMenuFocused";

                TrafficLightTool.SetToolMode(ToolMode.ManualSwitch);
            }
            else
            {
                _uiState = UIState.None;

                _buttonManualControl.focusedBgSprite = "ButtonMenu";

                TrafficLightTool.SetToolMode(ToolMode.None);
            }
        }
        private void clickCrosswalk(UIComponent component, UIMouseEventParameter eventParam)
        {
            if (_uiState != UIState.Crosswalk)
            {
                _uiState = UIState.Crosswalk;

                _buttonCrosswalk.focusedBgSprite = "ButtonMenuFocused";

                TrafficLightTool.SetToolMode(ToolMode.Crosswalk);
            }
            else
            {
                _uiState = UIState.None;

                _buttonCrosswalk.focusedBgSprite = "ButtonMenu";

                TrafficLightTool.SetToolMode(ToolMode.None);
            }
        }
        private void clickChangeLanes(UIComponent component, UIMouseEventParameter eventParam)
        {
            if (_uiState != UIState.LaneChange)
            {
                _uiState = UIState.LaneChange;

                if (!LoadingExtension.PathfinderIncompatibility)
                {
                    _buttonLaneChange.focusedBgSprite = "ButtonMenuFocused";
                }

                TrafficLightTool.SetToolMode(ToolMode.LaneChange);
            }
            else
            {
                _uiState = UIState.None;

                if (!LoadingExtension.PathfinderIncompatibility)
                {
                    _buttonLaneChange.focusedBgSprite = "ButtonMenu";
                }

                TrafficLightTool.SetToolMode(ToolMode.None);
            }
        }
        private void clickAddPrioritySigns(UIComponent component, UIMouseEventParameter eventParam)
        {
            if (_uiState != UIState.AddStopSign)
            {
                _uiState = UIState.AddStopSign;

                _buttonPrioritySigns.focusedBgSprite = "ButtonMenuFocused";

                TrafficLightTool.SetToolMode(ToolMode.AddPrioritySigns);
            }
            else
            {
                _uiState = UIState.None;

                _buttonPrioritySigns.focusedBgSprite = "ButtonMenu";

                TrafficLightTool.SetToolMode(ToolMode.None);
            }
        }
        protected virtual void ClickLaneRestrictions(UIComponent component, UIMouseEventParameter eventParam)
        {
            if (_uiState != UIState.LaneRestrictions)
            {
                _uiState = UIState.LaneRestrictions;

                _buttonLaneRestrictions.focusedBgSprite = "ButtonMenuFocused";

                TrafficLightTool.SetToolMode(ToolMode.LaneRestrictions);
            }
            else
            {
                _uiState = UIState.None;

                _buttonLaneRestrictions.focusedBgSprite = "ButtonMenu";

                TrafficLightTool.SetToolMode(ToolMode.None);
            }
        }
Esempio n. 49
0
 protected void SetUIState(UIState value)
 {
     if (_TheUIState != value)
     {
         _TheUIState = value;
         if (UIStateChanged != null)
             UIStateChanged(this, EventArgs.Empty);
     }
 }
Esempio n. 50
0
        private void bufferView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (m_Core.LogLoaded && MeshView)
            {
                m_ContextUIState = GetUIState(sender);

                if (e.Button == MouseButtons.Right &&
                    m_ContextUIState.m_Input != null &&
                    m_ContextUIState.m_Input.BufferFormats != null)
                {
                    selectColumnAsPositionToolStripMenuItem.Visible = true;
                    selectAlphaAsSecondaryToolStripMenuItem.Visible = true;

                    m_ContextColumn = 0;
                    int colidx = 2; // skip VTX and IDX columns

                    for (int el = 0; el < m_ContextUIState.m_Input.BufferFormats.Length; el++)
                    {
                        for (int i = 0; i < m_ContextUIState.m_Input.BufferFormats[el].format.compCount; i++)
                        {
                            if (colidx == e.ColumnIndex)
                            {
                                m_ContextColumn = el;
                                selectAlphaAsSecondaryToolStripMenuItem.Visible = (m_ContextUIState.m_Input.BufferFormats[el].format.compCount >= 4);
                            }

                            colidx++;
                        }
                    }

                    columnContextMenu.Show(Cursor.Position);
                }
            }
        }
Esempio n. 51
0
        private void UI_CacheRow(UIState state, int rowIdx)
        {
            if (state.m_Rows[rowIdx] != null || SuppressCaching)
                return;

            var data = state.m_Data;
            Input input = state.m_Input;
            uint instance = m_MeshDisplay.curInstance;

            if (data.Buffers == null)
                return;

            {
                byte[][] d = data.Buffers;

                var bufferFormats = input.BufferFormats;
                var generics = input.GenericValues;
                uint rowlen = 0;

                foreach(var el in bufferFormats)
                    rowlen += el.format.compCount;

                {
                    if (rowIdx >= data.IndexCount)
                    {
                        return;
                    }

                    uint dataIndex = (uint)rowIdx;

                    bool outOfBoundsIdx = false;

                    if (data.DataIndices != null)
                    {
                        if (rowIdx >= data.DataIndices.Length)
                        {
                            dataIndex = 0;
                            outOfBoundsIdx = true;
                        }
                        else
                        {
                            dataIndex = data.DataIndices[rowIdx];
                        }
                    }
                    else if (input.Drawcall != null && (input.Drawcall.flags & DrawcallFlags.UseIBuffer) != 0 &&
                        (state == m_VSIn || state == m_VSOut))
                    {
                        // no index buffer, but indexed drawcall
                        dataIndex = 0;
                        outOfBoundsIdx = true;
                    }

                    uint displayIndex = dataIndex;
                    if (data.Indices != null && rowIdx < data.Indices.Length)
                        displayIndex = data.Indices[rowIdx];

                    object[] rowdata = null;

                    int x = 0;
                    if (MeshView)
                    {
                        rowdata = new object[2 + rowlen];

                        rowdata[0] = rowIdx;
                        if (outOfBoundsIdx)
                            rowdata[1] = "-";
                        else
                            rowdata[1] = displayIndex;

                        bool strip = state.m_Data.Topology == PrimitiveTopology.LineStrip ||
                                     state.m_Data.Topology == PrimitiveTopology.LineStrip_Adj ||
                                     state.m_Data.Topology == PrimitiveTopology.TriangleStrip ||
                                     state.m_Data.Topology == PrimitiveTopology.TriangleStrip_Adj;

                        if (state.m_Input.Drawcall.indexByteWidth == 2 && dataIndex == state.m_Input.IndexRestartValue && state.m_Input.IndexRestart && strip)
                            rowdata[1] = "-1";
                        if (state.m_Input.Drawcall.indexByteWidth == 4 && dataIndex == state.m_Input.IndexRestartValue && state.m_Input.IndexRestart && strip)
                            rowdata[1] = "-1";

                        x = 2;
                    }
                    else
                    {
                        rowdata = new object[1 + rowlen];

                        rowdata[0] = rowIdx;

                        x = 1;
                    }

                    for (int el = 0; el < bufferFormats.Length; el++)
                    {
                        int xstart = x;

                        if (generics != null && generics[el] != null)
                        {
                            for (int g = 0; g < generics[el].Length; g++)
                                rowdata[x++] = generics[el][g];

                            continue;
                        }

                        try
                        {
                            byte[] bytedata = d[bufferFormats[el].buffer];
                            Stream strm = state.m_Stream[bufferFormats[el].buffer];
                            BinaryReader read = state.m_Reader[bufferFormats[el].buffer];

                            uint instIdx = 0;
                            // for instancing, need to handle instance rate being 0 (every instance takes index 0 in that case)
                            if (bufferFormats[el].perinstance)
                                instIdx = bufferFormats[el].instancerate > 0 ? (instance / (uint)bufferFormats[el].instancerate) : 0;
                            else
                                instIdx = dataIndex;

                            uint stride = input.Strides[bufferFormats[el].buffer];
                            if (data.PostVS.stride != 0)
                                stride = data.PostVS.stride;

                            uint offs = stride * instIdx + bufferFormats[el].offset;

                            if (bytedata == null)
                            {
                                strm.Seek(0, SeekOrigin.Begin);
                            }
                            else if (offs >= bytedata.Length)
                            {
                                for (int i = 0; i < bufferFormats[el].format.compCount; i++, x++)
                                {
                                    rowdata[x] = "-";
                                }
                                continue;
                            }
                            else
                            {
                                strm.Seek(offs, SeekOrigin.Begin);
                            }

                            object[] elements = bufferFormats[el].GetObjects(read);

                            if (bufferFormats[el].matrixdim == 1)
                            {
                                for (int i = 0; i < elements.Length; i++)
                                    rowdata[x + i] = ElementString(bufferFormats[el], elements[i]);
                                x += elements.Length;
                            }
                            else
                            {
                                int cols = (int)bufferFormats[el].format.compCount;
                                int rows = (int)bufferFormats[el].matrixdim;

                                for (int col = 0; col < cols; col++)
                                {
                                    string[] colarr = new string[rows];
                                    for (int row = 0; row < rows; row++)
                                    {
                                        if (!bufferFormats[el].rowmajor)
                                            colarr[row] = ElementString(bufferFormats[el], elements[col * rows + row]);
                                        else
                                            colarr[row] = ElementString(bufferFormats[el], elements[row * cols + col]);
                                    }

                                    rowdata[x++] = colarr;
                                }
                            }
                        }
                        catch (System.IO.EndOfStreamException)
                        {
                            for (int i = 0; i < bufferFormats[el].format.compCount; i++)
                            {
                                rowdata[xstart + i] = "-";
                            }

                            x = (int)(xstart + bufferFormats[el].format.compCount);
                        }
                    }

                    if (rowdata != null)
                    {
                        state.m_Rows[rowIdx] = rowdata;
                    }
                }
            }
        }
Esempio n. 52
0
 public MachineEntry(IUnityContainer container, UIState state, Machine entry)
     : this()
 {
     this.container = new MasterEntryContainer<Machine>(container, state, entry);
 }
Esempio n. 53
0
        private void bufferView_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right && m_Core.LogLoaded)
            {
                openFormat.Visible = !MeshView;

                debugVertex.Visible = MeshView &&
                    m_Core.LogLoaded &&
                    sender == vsInBufferView &&
                    vsInBufferView.SelectedRows.Count == 1;
                setInstanceToolStripMenuItem.Enabled = (m_Core.CurDrawcall != null && m_Core.CurDrawcall.numInstances > 1);

                m_ContextUIState = GetUIState(sender);
                rightclickMenu.Show(((DataGridView)sender).PointToScreen(e.Location));
            }
        }
Esempio n. 54
0
        private void UI_FillRawData(UIState state, int horizScroll)
        {
            var data = state.m_Data;

            Input input = state.m_Input;
            uint instance = m_MeshDisplay.curInstance;

            Thread th = Helpers.NewThread(new ThreadStart(() =>
            {
                byte[][] d = data.Buffers;

                Stream rawStream = new MemoryStream(state.m_RawData);
                BinaryWriter rawWriter = new BinaryWriter(rawStream);

                uint rownum = 0;
                bool finished = false;

                var bufferFormats = input.BufferFormats;
                var generics = input.GenericValues;

                Vec3f[] minBounds = new Vec3f[bufferFormats.Length];
                Vec3f[] maxBounds = new Vec3f[bufferFormats.Length];

                for (int el = 0; el < bufferFormats.Length; el++)
                {
                    minBounds[el] = new Vec3f(float.MaxValue, float.MaxValue, float.MaxValue);
                    maxBounds[el] = new Vec3f(-float.MaxValue, -float.MaxValue, -float.MaxValue);

                    if (bufferFormats[el].format.compCount == 1)
                        minBounds[el].y = maxBounds[el].y = minBounds[el].z = maxBounds[el].z = 0.0f;
                    if (bufferFormats[el].format.compCount == 2)
                        minBounds[el].z = maxBounds[el].z = 0.0f;
                }

                while (!finished)
                {
                    if (rownum >= data.IndexCount)
                    {
                        finished = true;
                        break;
                    }

                    uint index = rownum;

                    if (data.Indices != null)
                    {
                        if (rownum >= data.Indices.Length)
                        {
                            index = 0;
                        }
                        else
                        {
                            index = data.Indices[rownum];
                        }
                    }
                    else if ((input.Drawcall.flags & DrawcallFlags.UseIBuffer) != 0 && state == m_VSIn)
                    {
                        // no index buffer, but indexed drawcall
                        index = 0;
                    }

                    int elemsWithData = 0;

                    for (int el = 0; el < bufferFormats.Length; el++)
                    {
                        if (generics != null && generics[el] != null)
                        {
                            for(int g=0; g < generics[el].Length; g++)
                            {
                                if (generics[el][g] is uint)
                                    rawWriter.Write((uint)generics[el][g]);
                                else if (generics[el][g] is int)
                                    rawWriter.Write((int)generics[el][g]);
                                else if (generics[el][g] is float)
                                    rawWriter.Write((float)generics[el][g]);
                            }

                            continue;
                        }

                        try
                        {
                            byte[] bytedata = d[bufferFormats[el].buffer];
                            Stream strm = state.m_Stream[bufferFormats[el].buffer];
                            BinaryReader read = state.m_Reader[bufferFormats[el].buffer];

                            uint instIdx = 0;
                            // for instancing, need to handle instance rate being 0 (every instance takes index 0 in that case)
                            if (bufferFormats[el].perinstance)
                                instIdx = bufferFormats[el].instancerate > 0 ? (instance / (uint)bufferFormats[el].instancerate) : 0;
                            else
                                instIdx = index;

                            uint stride = input.Strides[bufferFormats[el].buffer];
                            if (data.PostVS.stride != 0)
                                stride = data.PostVS.stride;

                            uint offs = stride * instIdx + bufferFormats[el].offset;

                            bool outofBounds = false;

                            if (bytedata == null)
                            {
                                strm.Seek(0, SeekOrigin.Begin);
                            }
                            else if (offs >= bytedata.Length)
                            {
                                outofBounds = true;
                                strm = null;
                                read = new BinaryReader(new MemoryStream(m_Zeroes));
                            }
                            else
                            {
                                strm.Seek(offs, SeekOrigin.Begin);
                            }

                            string elname = bufferFormats[el].name.ToUpperInvariant();
                            var fmt = bufferFormats[el].format;
                            int byteWidth = (int)fmt.compByteWidth;

                            int bytesToRead = (int)(fmt.compByteWidth * fmt.compCount);

                            byte[] bytes = read.ReadBytes(bytesToRead);
                            rawWriter.Write(bytes);

                            if (bytes.Length != bytesToRead)
                                continue;

                            // update min/max for this element
                            {
                                for (int i = 0; i < fmt.compCount; i++)
                                {
                                    float val = 0;

                                    if (fmt.compType == FormatComponentType.Float)
                                    {
                                        if (byteWidth == 4)
                                            val = BitConverter.ToSingle(bytes, i * byteWidth);
                                        else if (byteWidth == 2)
                                            val = fmt.ConvertFromHalf(BitConverter.ToUInt16(bytes, i * byteWidth));
                                    }
                                    else
                                    {
                                        if (byteWidth == 4)
                                            val = (float)BitConverter.ToUInt32(bytes, i * byteWidth);
                                        else if (byteWidth == 2)
                                            val = (float)BitConverter.ToUInt16(bytes, i * byteWidth);
                                        else if (byteWidth == 1)
                                            val = (float)bytes[i * byteWidth];
                                    }

                                    if (outofBounds) continue;

                                    if (i == 0)
                                    {
                                        minBounds[el].x = Math.Min(minBounds[el].x, val);
                                        maxBounds[el].x = Math.Max(maxBounds[el].x, val);
                                    }
                                    else if (i == 1)
                                    {
                                        minBounds[el].y = Math.Min(minBounds[el].y, val);
                                        maxBounds[el].y = Math.Max(maxBounds[el].y, val);
                                    }
                                    else if (i == 2)
                                    {
                                        minBounds[el].z = Math.Min(minBounds[el].z, val);
                                        maxBounds[el].z = Math.Max(maxBounds[el].z, val);
                                    }
                                }
                            }

                            elemsWithData++;
                        }
                        catch (System.IO.EndOfStreamException)
                        {
                            // don't increment elemsWithData
                        }
                    }

                    finished = (elemsWithData == 0);

                    rownum++;
                }

                this.BeginInvoke(new Action(() =>
                {
                    state.m_MinBounds = minBounds;
                    state.m_MaxBounds = maxBounds;

                    UI_UpdateBoundingBox();

                    UI_ShowRows(state, horizScroll);
                }));
            }));

            th.Start();

            state.m_DataParseThread = th;
        }
Esempio n. 55
0
        private void UI_ShowRows(UIState state, int horizScroll)
        {
            var bufView = state.m_GridView;

            if (bufView.IsDisposed)
                return;

            SuppressCaching = true;

            for (int i = 0; i < bufView.Columns.Count; i++)
            {
                if (bufView.Columns[i].AutoSizeMode == DataGridViewAutoSizeColumnMode.AllCells)
                {
                    bufView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                }
            }

            bufView.RowCount = 0;
            if(!MeshView) byteOffset.Enabled = true;

            if (state.m_Rows != null)
            {
                bufView.RowCount = Math.Min(state.m_Rows.Length, MaxRowCount);

                if (state.m_Rows.Length > MaxRowCount)
                    largeBufferWarning.Visible = true;

                ScrollToRow(bufView, RowOffset);

                SuppressCaching = false;

                bufView.HorizontalScrollingOffset = horizScroll;
            }

            if (vsInBufferView.Focused && m_Core.LogLoaded)
            {
                debugVertex.Enabled = debugVertexToolItem.Enabled = true;
            }
        }
Esempio n. 56
0
        private void bufferView_MouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (m_Core.LogLoaded && e.RowIndex >= 0)
            {
                m_ContextUIState = GetUIState(sender);

                if (e.Button == MouseButtons.Right)
                {
                    openFormat.Visible = !MeshView;

                    debugVertex.Visible = MeshView &&
                        m_Core.LogLoaded &&
                        sender == vsInBufferView &&
                        vsInBufferView.SelectedRows.Count == 1;
                    setInstanceToolStripMenuItem.Enabled = (m_Core.CurDrawcall != null && m_Core.CurDrawcall.numInstances > 1);

                    rightclickMenu.Show(Cursor.Position);
                }
            }
        }
        private void clickSwitchTraffic(UIComponent component, UIMouseEventParameter eventParam)
        {
            if (_uiState != UIState.SwitchTrafficLight)
            {
                _uiState = UIState.SwitchTrafficLight;

                _buttonSwitchTraffic.focusedBgSprite = "ButtonMenuFocused";

                TrafficLightTool.SetToolMode(ToolMode.SwitchTrafficLight);
            }
            else
            {
                _uiState = UIState.None;

                _buttonSwitchTraffic.focusedBgSprite = "ButtonMenu";

                TrafficLightTool.SetToolMode(ToolMode.None);
            }
        }
Esempio n. 58
0
        public BufferViewer(Core core, bool meshview)
        {
            InitializeComponent();

            Icon = global::renderdocui.Properties.Resources.icon;

            UI_SetupDocks(meshview);

            m_Zeroes = new byte[512];
            for (int i = 0; i < 512; i++) m_Zeroes[i] = 0;

            m_VSIn.m_GridView = vsInBufferView;
            m_VSOut.m_GridView = vsOutBufferView;
            m_GSOut.m_GridView = gsOutBufferView;

            largeBufferWarning.Visible = false;
            byteOffset.Enabled = false;

            rowOffset.Font =
                byteOffset.Font =
                instanceIdxToolitem.Font =
                camSpeed.Font =
                fovGuess.Font =
                aspectGuess.Font =
                nearGuess.Font =
                farGuess.Font =
                core.Config.PreferredFont;

            m_ContextUIState = m_VSIn;

            DockHandler.GetPersistStringCallback = PersistString;

            exportToToolStripMenuItem.Enabled = exportToolItem.Enabled = false;

            m_Core = core;

            this.DoubleBuffered = true;

            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            RenderHandle = render.Handle;

            render.Painting = true;

            render.MouseWheel += render_MouseWheel;
            render.MouseWheelHandler = render_MouseWheel;
            (render as Control).KeyDown += new KeyEventHandler(BufferViewer_KeyDown);
            (render as Control).KeyUp += new KeyEventHandler(BufferViewer_KeyUp);
            ResetConfig();

            MeshView = meshview;

            if (!MeshView)
            {
                debugVertexToolItem.Visible = debugSep.Visible = false;
                instLabel.Visible = instSep.Visible = instanceIdxToolitem.Visible = false;
                syncViewsToolItem.Visible = false;
                highlightVerts.Visible = false;
                byteOffset.Text = "0";

                Text = "Buffer Contents";
            }
            else
            {
                byteOffset.Visible = false; byteOffsLab.Visible = false;
                byteOffset.Text = "0";

                Text = "Mesh Output";
            }

            m_Core.AddLogViewer(this);
        }
        private void clickTimedAdd(UIComponent component, UIMouseEventParameter eventParam)
        {
            if (_uiState != UIState.TimedControlNodes)
            {
                _uiState = UIState.TimedControlNodes;

                _buttonTimedMain.focusedBgSprite = "ButtonMenuFocused";

                TrafficLightTool.SetToolMode(ToolMode.TimedLightsSelectNode);
            }
            else
            {
                _uiState = UIState.None;

                _buttonTimedMain.focusedBgSprite = "ButtonMenu";

                TrafficLightTool.SetToolMode(ToolMode.None);
            }
        }
Esempio n. 60
0
        private void UpdateHighlightVerts(UIState ui)
        {
            if (ui == null || ui.m_RawData == null) return;
            if (ui.m_GridView.SelectedRows.Count == 0) return;
            if (!MeshView) return;

            if(highlightVerts.Checked)
                m_MeshDisplay.highlightVert = (uint)ui.m_GridView.SelectedRows[0].Index;
            else
                m_MeshDisplay.highlightVert = ~0U;

            render.Invalidate();
        }