/// <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); }
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)); } }
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); }
public override void SetPanel(UIParam u = null) { if (u == null) { gameObject.SetActive(true); } }
public override void SetPanel(UIParam u = null) { PlanningIndicatorUIParam param = (PlanningIndicatorUIParam)u; planningTargetUnit = param.planningUnit; gameObject.SetActive(true); }
public override void Write(XmlElement parent) { CreateElement(parent, "systemParameter", "spiAction", SpiAction.ToString(), "uiParam", UIParam.ToStringInvariant(), "pvParam", PVParam.ToStringInvariant() ); }
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(); }
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(); }
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(); }
public override void SetPanel(UIParam u) { UIStageSelectPopupParam usspp = (UIStageSelectPopupParam)u; stageData = usspp.nextStageData; nextScene = usspp.nextScene; ResetUI(); StartCoroutine(PopupAnimator(true)); }
public override void SetPanel(UIParam u) { if (u == null) { return; } UIActionPointParam uap = (UIActionPointParam)u; actionPointText.text = $"X {uap._point.ToString()}"; gameObject.SetActive(true); }
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(); }
/// <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 }
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); }
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)); }
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(); }
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은 아직 이미지가 없어서~ }
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); } }
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); } }
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(); }
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); }
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(); }
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; } }
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); }
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); }
public override void SetPanel(UIParam param = null) { }
public override void SetPanel(UIParam u = null) { throw new System.NotImplementedException(); }
private static UIBase LoadUI <T> (UIIDEnum id, UIParam param = null) where T : UIBase, new() { var newUI = new T(); return(newUI.Init(param) ? newUI : null); }
public void TurnOnUIComponent(UIType ut, UIParam param = null) { _dictionary[ut].SetPanel(param); }
public override void SetPanel(UIParam u) => gameObject.SetActive(true);