Ejemplo n.º 1
0
        /// <summary>
        /// 加载新UI
        /// </summary>
        private static UIBase LoadUI <T, W> (UIIDEnum id, UIParam param = null) where T : UIBase, new()//todo不觉得这传泛型的方式是一种好的处理方式
            where W : WindowBase, new()
        {
            var newUI = new T();

            return(newUI.Init <W>(param) ? newUI : null);
        }
Ejemplo n.º 2
0
    public override void SetPanel(UIParam param)
    {
        if (param == null)
        {
            return;
        }

        UIItemParam uit = (UIItemParam)param;

        Dictionary <Item, int> itemCounter     = uit._itemCounter;
        Action <Item>          onClickItemSlot = uit._onClickItemSlot;

        gameObject.SetActive(true);
        itemSlots.ForEach(slot => slot.UnsetPanel());

        foreach (var(item, count, idx) in itemCounter.Select((p, i) => (p.Key, p.Value, i)))
        {
            if (idx >= itemSlots.Count)
            {
                break;
            }

            itemSlots[idx].SetSlot(item, count, () => onClickItemSlot(item));
        }
    }
Ejemplo n.º 3
0
        private bool applyNewParams(List <UIParam> parameters)
        {
            UndoRedoManager.putInUndoStack(owner);
            UndoRedoManager.clearRedoStack(owner);

            foreach (UIElement el in sp.Children)
            {
                if (el is DockPanel)
                {
                    DockPanel dp = el as DockPanel;
                    System.Windows.Controls.Label l = dp.Children[0] as System.Windows.Controls.Label;
                    ParameterInput input            = dp.Children[1] as ParameterInput;
                    UIParam        param            = parameters.Find(p => p.DisplayedText == l.Content.ToString());
                    if (!param.Validator.validate(input.getValue().ToString()))
                    {
                        MessageBox.Show("Параметр '" + l.Content + "' задан не верно");
                        return(false);
                    }
                    if (sapr_sim.Figures.UIEntity.ENTITY_NAME_PARAM.Equals(param.DisplayedText) && !param.RawValue.Equals(input.getValue().ToString()))
                    {
                        owner.updateText(input.getValue().ToString());
                    }
                    param.RawValue = input.getValue();
                }
            }
            return(true);
        }
Ejemplo n.º 4
0
 public override void SetPanel(UIParam u = null)
 {
     if (u == null)
     {
         gameObject.SetActive(true);
     }
 }
Ejemplo n.º 5
0
    public override void SetPanel(UIParam u = null)
    {
        PlanningIndicatorUIParam param = (PlanningIndicatorUIParam)u;

        planningTargetUnit = param.planningUnit;

        gameObject.SetActive(true);
    }
Ejemplo n.º 6
0
        public override void Write(XmlElement parent)
        {
            CreateElement(parent, "systemParameter",

                          "spiAction", SpiAction.ToString(),
                          "uiParam", UIParam.ToStringInvariant(),
                          "pvParam", PVParam.ToStringInvariant()
                          );
        }
Ejemplo n.º 7
0
        public WorkerResource(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            this.bottomPort = info.GetValue("bottomPort", typeof(Port)) as Port;
            ports.Add(bottomPort);

            efficiency = info.GetValue("efficiency", typeof(UIParam <Double>)) as UIParam <Double>;
            price      = info.GetValue("price", typeof(UIParam <Double>)) as UIParam <Double>;

            init();
        }
Ejemplo n.º 8
0
        public InstrumentResource(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            this.bottomPort = info.GetValue("bottomPort", typeof(Port)) as Port;
            ports.Add(bottomPort);

            price = info.GetValue("price", typeof(UIParam <Double>)) as UIParam <Double>;
            power = info.GetValue("power", typeof(UIParam <Double>)) as UIParam <Double>;

            init();
        }
Ejemplo n.º 9
0
        public Source(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            this.port = info.GetValue("port", typeof(Port)) as Port;
            ports.Add(port);

            projectsCount = info.GetValue("projectsCount", typeof(UIParam <Int32>)) as UIParam <Int32>;
            complexity    = info.GetValue("complexity", typeof(UIParam <Int32>)) as UIParam <Int32>;

            init();
        }
Ejemplo n.º 10
0
    public override void SetPanel(UIParam u)
    {
        UIStageSelectPopupParam usspp = (UIStageSelectPopupParam)u;

        stageData = usspp.nextStageData;
        nextScene = usspp.nextScene;

        ResetUI();

        StartCoroutine(PopupAnimator(true));
    }
Ejemplo n.º 11
0
    public override void SetPanel(UIParam u)
    {
        if (u == null)
        {
            return;
        }

        UIActionPointParam uap = (UIActionPointParam)u;

        actionPointText.text = $"X {uap._point.ToString()}";
        gameObject.SetActive(true);
    }
Ejemplo n.º 12
0
        public MaterialResource(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            consumption = info.GetValue("consumption", typeof(UIParam <int>)) as UIParam <int>;

            consumptionTimeMeasure = info.GetValue("consumptionTimeMeasure", typeof(UIParam <TimeMeasure>)) as UIParam <TimeMeasure>;
            consumptionTimeMeasure.ContentControl = new ParameterComboBox(TimeMeasure.list())
            {
                SelectedIndex = consumptionTimeMeasure.Value.Order
            };

            init();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 加载并显示一个UI实例
        /// </summary>
        public static void ShowUI <T, W> (UIIDEnum uiID, UIParam param = null) where T : UIBase, new()
            where W : WindowBase, new()
        {
            //检查缓存队列里有没有已经打开的此类UI实例
            var ui = GetFromCache <T>(uiID);

            if (!ReferenceEquals(null, ui))
            {
                CheckClosePrevUI(_uiPool.Peek(), ui);
                ui.Show();
                return;
            }

            //if ui entity is null:
            ui = LoadUI <T, W>(uiID, param);
            //#UIMgr尝试加载UI失败的处理
            if (ui is null)//todo这里处理的其实不太好,尝试加载UI失败
            {
                Log.Error($"UIMgr--->faild to load ui:{typeof(T).Name}");
                return;
            }
            UITools.SetToUIRoot(ui);
            CheckClosePrevUI(_uiPool.Peek(), ui);

            _uiPool.Enqueue(ui);
            _refDic.Add(uiID, ui);

            ui.OnLoad();
            ui.Show();

            #region nouse
            //if (ui is null)//拿不到,加载新的
            //{
            //    ui = LoadUI<T,W>( uiID, param );
            //    if (ui is null)//todo这里处理的其实不太好
            //    {
            //        Tools.Log.Error("UIMgr--->faild to load ui:"+ typeof(T).Name);
            //        return;
            //    }

            //    CheckClosePrevUI( _uiPool.Peek(), ui );

            //    _uiPool.Enqueue( ui );
            //    _refDic.Add( uiID, ui );

            //    ui.OnLoad();
            //    ui.Show();
            //}
            //else//能拿到,直接显示
            //    ui.Show();
            #endregion
        }
Ejemplo n.º 14
0
    public override void SetPanel(UIParam u)
    {
        if (u == null)
        {
            return;
        }

        UIPopupParam up = (UIPopupParam)u;

        // popup position dynamic
        Vector3 viewportPos = Camera.main.ScreenToViewportPoint(up._pos);

        if (viewportPos.x < 0.5f)     // left
        {
            if (viewportPos.y < 0.5f) // bottom
            {
                GetComponent <RectTransform>().pivot = new Vector2(0f, 0f);
            }
            else // top
            {
                GetComponent <RectTransform>().pivot = new Vector2(0f, 1f);
            }
        }
        else // right
        {
            if (viewportPos.y < 0.5f) // bottom
            {
                GetComponent <RectTransform>().pivot = new Vector2(1f, 0f);
            }
            else // top
            {
                GetComponent <RectTransform>().pivot = new Vector2(1f, 1f);
            }
        }


        Description.text   = up._content;
        transform.position = up._pos;
        yesBtn.onClick.AddListener(up._yes);
        yesBtn.onClick.AddListener(() => {
            AudioMgr.Instance.PlayAudio(AudioMgr.AudioClipType.UI_Clicked, AudioMgr.AudioType.UI);
        });
        noBtn.onClick.AddListener(up._no);
        noBtn.onClick.AddListener(() => {
            AudioMgr.Instance.PlayAudio(AudioMgr.AudioClipType.UI_Clicked, AudioMgr.AudioType.UI);
        });

        gameObject.SetActive(true);
    }
Ejemplo n.º 15
0
    public override void SetPanel(UIParam u = null)
    {
        DamageTextUIParam param = (DamageTextUIParam)u;

        Vector3 screenPoint    = Camera.main.WorldToScreenPoint(param.damagedTarget.position);
        var     instanceObject = Instantiate(textUIPrefab, screenPoint, Quaternion.identity, transform);

        textInstancesAndTargets.Add(instanceObject, param.damagedTarget);
        instanceObject.transform.position = screenPoint + Vector3.up * 70f;
        instanceObject.GetComponentInChildren <TextMeshProUGUI>().text = param.damage.ToString();

        gameObject.SetActive(true);

        StartCoroutine(UnsetInstanceAfterSeconds(instanceObject.gameObject, 1f));
    }
Ejemplo n.º 16
0
        public Resource(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            this.topPort = info.GetValue("topPort", typeof(Port)) as Port;
            ports.Add(topPort);

            type = info.GetValue("type", typeof(UIParam <ResourceType>)) as UIParam <ResourceType>;
            type.ContentControl = new ParameterComboBox(ResourceType.list())
            {
                SelectedIndex = type.Value.Order
            };

            isShared = info.GetValue("isShared", typeof(UIParam <Boolean>)) as UIParam <bool>;
            isShared.ContentControl = new ParameterCheckBox(isShared.Value);
            count = info.GetValue("count", typeof(UIParam <int>)) as UIParam <int>;

            init();
        }
Ejemplo n.º 17
0
    public override void SetPanel(UIParam u)
    {
        if (u == null)
        {
            return;
        }

        UIStatusParam us   = (UIStatusParam)u;
        Unit          unit = us._u;

        gameObject.SetActive(true);

        unitName.text             = unit.name;
        unitDescription.text      = "Description For Unit.";
        unitDamage.text           = $"{unit.basicAttackDamageMin.ToString()} ~ {unit.basicAttackDamageMax.ToString()}";
        unitcurrHealth.fillAmount = unit.currHealth / (float)unit.maxHealth;
        unitImage.sprite          = unit.icon;

        // -> skill은 아직 이미지가 없어서~
    }
Ejemplo n.º 18
0
        public UIEntity(SerializationInfo info, StreamingContext context)
        {
            try
            {
                init(info.GetValue("canvas", typeof(ScrollableCanvas)) as Canvas);

                this.name = info.GetValue("textParam", typeof(UIParam <String>)) as UIParam <String>;
                Canvas.SetLeft(this, info.GetDouble("x"));
                Canvas.SetTop(this, info.GetDouble("y"));
                ((MainWindow)System.Windows.Application.Current.MainWindow).attachMovingEvents(this);

                // label can be not found - it's normal behavior
                this.label = info.GetValue("label", typeof(Label)) as Label;

                this.state = "copyed";
            }
            catch (SerializationException e) {
                Console.Out.Write(e.StackTrace);
            }
        }
Ejemplo n.º 19
0
        public override void Execute()
        {
            if (SpiAction == SpiAction.None)
            {
                return;
            }

            Backup(Package.ExecutionInfo.BackupGroup);

            Boolean result = NativeMethods.SystemParametersInfo(SpiAction, UIParam, new IntPtr(PVParam));

            if (!result)
            {
                String error = NativeMethods.GetLastErrorString();

                String args = SpiAction.ToString() + "," + UIParam.ToStringInvariant() + "," + PVParam.ToStringInvariant();

                Package.Log.Add(LogSeverity.Error, "SystemParametersInfo(" + args + ") failed: " + error);
            }
        }
Ejemplo n.º 20
0
        public Procedure(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            this.inputPort    = info.GetValue("inputPort", typeof(Port)) as Port;
            this.outputPort   = info.GetValue("outputPort", typeof(Port)) as Port;
            this.resourcePort = info.GetValue("resourcePort", typeof(Port)) as Port;
            ports.Add(inputPort);
            ports.Add(outputPort);
            ports.Add(resourcePort);

            time    = info.GetValue("time", typeof(UIParam <Double>)) as UIParam <Double>;
            scatter = info.GetValue("scatter", typeof(UIParam <Int32>)) as UIParam <Int32>;

            timeMeasure = info.GetValue("timeMeasure", typeof(UIParam <TimeMeasure>)) as UIParam <TimeMeasure>;
            timeMeasure.ContentControl = new ParameterComboBox(TimeMeasure.list())
            {
                SelectedIndex = timeMeasure.Value.Order
            };

            init();
        }
Ejemplo n.º 21
0
    public override void SetPanel(UIParam u) // 유닛을 받아 그 유닛을 판넬에 세팅하는 함수
    {
        if (u == null)
        {
            return;
        }

        UISummonParam us    = (UISummonParam)u;
        List <Unit>   units = us._units;
        bool          add   = us._add;

        foreach (Unit unit in units) // 유닛을 받아서 순회하며 생성하고,
        {
            if (add)
            {
                if (SummonBtnCount.ContainsKey(unit))
                {
                    SummonBtnCount[unit]++;
                }
                else
                {
                    SummonBtnCount.Add(unit, 1);
                }
            }
            else
            {
                if (SummonBtnCount.ContainsKey(unit) && SummonBtnCount[unit] >= 2)
                {
                    SummonBtnCount[unit]--;
                }
                else
                {
                    SummonBtnCount.Remove(unit);
                }
            }
        }

        UpdateSummonBtns();

        gameObject.SetActive(true);
    }
Ejemplo n.º 22
0
        private IEnumerator UIQueueUpdate()
        {
            ShowMask();
            isUIHandling = true;

            while (uiQueue.Count > 0)
            {
                UIParam handleParam = uiQueue.Dequeue();

                if (handleParam is UIOpenParam openParam)
                {
                    yield return(StartCoroutine(openParam.HandleBase.Handle.SelfOpen(openParam.HandleParams)));

                    if (null == uiHistoryTail)
                    {
                        uiHistoryTail = new UINode {
                            CurBase = openParam.HandleBase, Prev = null, Next = null
                        };
                    }
                    else
                    {
                        UINode node = new UINode
                        {
                            CurBase = openParam.HandleBase, Prev = uiHistoryTail, Next = null
                        };
                        uiHistoryTail.Next = node;
                        uiHistoryTail      = node;
                    }
                }
                else
                {
                    yield return(StartCoroutine(handleParam.HandleBase.Handle.SelfClose()));
                }
            }

            yield return(new WaitForEndOfFrame());

            isUIHandling = false;

            HideMask();
        }
Ejemplo n.º 23
0
    public void SetUIComponent <T>(UIParam uiParam = null, bool isOn = true) where T : PanelUIComponent
    {
        switch (currCanvasType)
        {
        case CanvasType.Main:
        case CanvasType.Select:
        case CanvasType.Battle:
        case CanvasType.Dialog:
            UINormalState normalState = (UINormalState)stateMachine.stateStack.Peek();

            if (isOn)
            {
                normalState._canvas.GetUIComponent <T>().SetPanel(uiParam);
            }
            else
            {
                normalState._canvas.GetUIComponent <T>().UnsetPanel();
            }
            break;
        }
    }
Ejemplo n.º 24
0
    public override void SetPanel(UIParam u)
    {
        UIActionParam ua = (UIActionParam)u;

        actionBtns.ForEach(b => b.SetBtnActive(false));

        foreach (var slot in ua._actionSlots)
        {
            ActionBtn   btn     = actionBtns.Find((actionBtn) => actionBtn.actionType == slot.type);
            UnityAction onClick = ua._btnEvents[slot.type];

            btn.Set(slot.cost, onClick);

            if (ua._actionPointRemain >= slot.cost)
            {
                btn.SetBtnActive(true);
            }
        }

        gameObject.SetActive(true);
    }
Ejemplo n.º 25
0
    public override void SetPanel(UIParam u = null)
    {
        SaveData saveData = SaveManager.LoadData();

        if (saveData == null)
        {
            SaveManager.InitData();
        }
        saveData = SaveManager.LoadData();

        param = (VictoryPanelUIParam)u;

        if (saveData.dialogWatched[param.nextDialogScene] == true) // 이미 봄. 안 보고 StageSelection으로 갈 수 있게하자.
        {
            backToStageSelBtn.interactable = true;
        }
        else // 다이얼로그를 안봤고 보게 하자.
        {
            backToStageSelBtn.interactable = false;
        }

        gameObject.SetActive(true);
    }
Ejemplo n.º 26
0
 public override void SetPanel(UIParam param = null)
 {
 }
Ejemplo n.º 27
0
 public override void SetPanel(UIParam u = null)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 28
0
        private static UIBase LoadUI <T> (UIIDEnum id, UIParam param = null) where T : UIBase, new()
        {
            var newUI = new T();

            return(newUI.Init(param) ? newUI : null);
        }
Ejemplo n.º 29
0
 public void TurnOnUIComponent(UIType ut, UIParam param = null)
 {
     _dictionary[ut].SetPanel(param);
 }
Ejemplo n.º 30
0
 public override void SetPanel(UIParam u) => gameObject.SetActive(true);