// Use this for initialization void Start () { list = GetComponent<UIScrollList>(); list.SetValueChangedDelegate(scrollList_OnClick); StartCoroutine(waitForList()); }
public void Init( UIScrollList _list, body2_SC_PRIVATESHOP_SEARCH_RESULT _item, delListBtnClicked _del) { m_SearchInfo = _item; m_Del = _del; listBtn.SetInputDelegate( OnListButton); _list.AddItem( container); Item item = ItemMgr.ItemManagement.GetItem( _item.sItem.nItemTableIdx); GameObject objIcon = item.GetIcon(); objIcon = Instantiate( objIcon) as GameObject; objIcon.transform.parent = objSlot.transform; objIcon.transform.localPosition = Vector3.zero; count_ = objIcon.GetComponentInChildren<SpriteText>(); if( count_ != null && m_SearchInfo.sItem.nOverlapped > 1) count_.Text = m_SearchInfo.sItem.nOverlapped.ToString(); // item number must be added txt_Grade.Text = item.GetStrGrade(); txt_Level.Text = item.ItemData.levelLimit.ToString(); string str = m_SimpleName = AsTableManager.Instance.GetTbl_String(item.ItemData.nameId); if( m_SearchInfo.sItem.nStrengthenCount > 0) str = Color.white + "+" + m_SearchInfo.sItem.nStrengthenCount + " " + m_SimpleName; txt_Name.Text = str; // txt_Price.Text = _item.nItemGold.ToString(); txt_Price.Text = _item.nItemGold.ToString("#,#0", CultureInfo.InvariantCulture); container.ScanChildren(); container.GetScrollList().ClipItems(); }
public override void Copy(SpriteRoot s, ControlCopyFlags flags) { base.Copy(s, flags); if (!(s is UIListItem)) { return; } UIListItem b = (UIListItem)s; if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings) { list = b.list; } if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance) { topLeftEdge = b.topLeftEdge; bottomRightEdge = b.bottomRightEdge; colliderTL = b.colliderTL; colliderBR = b.colliderBR; colliderCenter = b.colliderCenter; customCollider = b.customCollider; } }
////////////////////////////////////////////////// public void SetEZGUIScrollList(UIScrollList ObjectScrollList) { ScrollList = ObjectScrollList; ScrollList.transform.position = new Vector3(0, 0, 0); SetValid(false); }
protected override void OnUpdate() { if (waiting && Planetarium.GetUniversalTime() > completionTime) { waiting = false; SetComplete(); } // Every time the clock ticks over, make an attempt to update the contract window // notes. We do this because otherwise the window will only ever read the notes once, // so this is the only way to get our fancy timer to work. else if (waiting && trackedVessel != null && Planetarium.GetUniversalTime() - lastUpdate > 1.0f) { lastUpdate = Planetarium.GetUniversalTime(); // Go through all the list items in the contracts window UIScrollList list = ContractsApp.Instance.cascadingList.cascadingList; for (int i = 0; i < list.Count; i++) { // Try to find a rich text control that matches the expected text UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i); SpriteTextRich richText = listObject.GetComponentInChildren <SpriteTextRich>(); if (richText != null && noteTracker.ContainsKey(richText.Text)) { // Clear the noteTracker, and replace the text noteTracker.Clear(); richText.Text = notePrefix + GetNotes(); } } } }
// 检测是否有超链接在 HyperItemBase CheckHyperHover(RaycastHit hitInfo) { if (hitInfo.collider == null) { return(null); } // 防止移动到容器上误判为超链接之上 UIScrollList list = hitInfo.collider.gameObject.GetComponent <UIScrollList>(); if (list != null) { return(null); } SpriteText currTextItem = hitInfo.collider.gameObject.GetComponentInChildren <SpriteText>(); if (currTextItem != null) { //string showText = currTextItem.Text.Replace("\0", ""); int charIndex = currTextItem.GetNearestInsertionPoint(hitInfo.point); return(HyperLinkManager.Instance.GetHyperHover(currTextItem.DisplayString, charIndex)); } return(null); }
void Start() { UIScrollList scrollList = FindControlByName <UIScrollList> ("Scroll View"); scrollList.SetLayout(UIScrollList.UILayoutDirection.HORIZONTAL_LEFT); scrollList.ItemSize = new Vector2(120, 120); scrollList.ContentSize = new Vector2(180, 180); scrollList.SetPadding(new RectOffset(20, 20, 0, 0)); scrollList.SetSpacing(30); foreach (KeyValuePair <string, string> item in _Images) { scrollList.AddItem(CreateButton(item.Key, item.Key, (UIControl ui) => { UIButton btn = (UIButton)ui; if (_LastTouchUI != null) { _LastTouchUI.Label.Color = Color.white; _LastTouchUI.Background.Alpha = 1; } btn.Label.Color = Color.red; btn.Background.Alpha = 0.5f; SetImageUrl(item.Value); _LastTouchUI = btn; })); } _Image = FindControlByName <UIImage> ("Image"); KeyboardListener.Instance.AddDispatch(this.gameObject, KeyCode.Delete, (TouchPhase phase) => { if (phase != TouchPhase.Began) { return; } if (_LastTouchUI != null) { _LastTouchUI.Label.Color = Color.white; _LastTouchUI.Background.Alpha = 1; } SetImageUrl(""); _LastTouchUI = null; }); SetImageUrl(""); UIDropdown dropDown = FindControlByName <UIDropdown> ("Dropdown"); dropDown.RemoveAllOptions(); dropDown.AddOption("地块层"); dropDown.AddOption("建筑层"); dropDown.AddOption("角色层"); dropDown.OnValueChanged.AddListener((int arg0) => { SetEnableLayer(arg0); }); }
public override void Create() { base.Create(); ScrollList = null; ViewSizeX = 0.0f; ViewSizeY = 0.0f; }
// Use this for initialization protected override void InitControl() { base.InitControl(); _DropDown = this.GetComponent <Dropdown> (); _Background = AppendControl <UIImage> (this); _Label = this.FindControlByName <UIText> ("Label"); _Arrow = this.FindControlByName <UIImage> ("Arrow"); _Template = this.FindControlByName <UIScrollList> ("Template"); }
/// <summary> /// Call this any time the title text has changed - this will make an attempt to update /// the contract window title. We do this because otherwise the window will only ever read /// the title once. /// </summary> /// <param name="newTitle">New title to display</param> public void UpdateContractWindow(ContractParameter param, string newTitle) { // Try to find the cascading list in the contracts window. Note that we may pick up // the ones from the Engineer's report in the VAB/SPH instead - but we don't care about // title updates in those scenes anyway. if (cascadingList == null || !cascadingList.gameObject.activeSelf) { cascadingList = UnityEngine.Object.FindObjectOfType <GenericCascadingList>(); } // Every time the clock ticks over, make an attempt to update the contract window // title. We do this because otherwise the window will only ever read the title once, // so this is the only way to get our fancy timer to work. // Go through all the list items in the contracts window if (cascadingList != null) { UIScrollList list = cascadingList.ruiList.cascadingList; if (list != null) { for (int i = 0; i < list.Count; i++) { // Try to find a rich text control that matches the expected text UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i); SpriteTextRich richText = listObject.GetComponentInChildren <SpriteTextRich>(); if (richText != null) { // Check for any string in titleTracker string found = null; foreach (string title in titles) { if (richText.Text.Contains(title)) { found = title; break; } } // Clear the titleTracker, and replace the text if (found != null) { titles.Clear(); richText.Text = richText.Text.Replace(found, newTitle); titles.Add(newTitle); } } } // Reposition items to account for items where the height increased or decreased list.RepositionItems(); } } // Contracts Window + update ContractsWindow.SetParameterTitle(param, newTitle); }
public void SendToFriend(CustomStage level) { if (isRankingScreen) { scroll = Flow.config.GetComponent <ConfigManager>().challengeInviteScroll; scroll.transform.parent = transform; scroll.transform.localPosition = new Vector3(-0.1220818f, 0.1973438f, -7.011475f); } currentCustomStage = level; EnteredInvite(); }
public void SendToFriend(CustomStage level) { if(isRankingScreen) { scroll = Flow.config.GetComponent<ConfigManager>().challengeInviteScroll; scroll.transform.parent = transform; scroll.transform.localPosition = new Vector3(-0.1220818f, 0.1973438f, -7.011475f); } currentCustomStage = level; EnteredInvite(); }
// Use this for initialization void Start () { TextAsset XMLTextAsset = (TextAsset) Resources.Load(LevelXMLPath); levelXmlDoc = new XmlDocument (); levelXmlDoc.LoadXml(XMLTextAsset.text); levelScrollList = GetComponent<UIScrollList>(); levelManager = transform.parent.GetComponentInChildren<LevelSelectManager>(); //Populate the level list with levels. PopulateLevels(); }
// Use this for initialization void Start () { scroll = Flow.config.GetComponent<ConfigManager>().inviteAllScroll; playingScroll = Flow.config.GetComponent<ConfigManager>().invitePlayingScroll; scroll.transform.parent = gameObject.transform; playingScroll.transform.parent = gameObject.transform; scroll.transform.position = new Vector3 ( // primeira coluna refere-se a posicao do panel manager no mundo // segunda coluna refere-se a posicao do invite em relacao ao panel manager // terceira coluna refere-se a posicao do scroll em relacao ao invite panel -31.4336f +65.6814f -0.7232132f, // x -0.9254344f +0.9254344f +0.7468368f, // y 914.5213f +5.99231f -7.011475f // z ); playingScroll.transform.position = new Vector3 ( // primeira coluna refere-se a posicao do panel manager no mundo // segunda coluna refere-se a posicao do invite em relacao ao panel manager // terceira coluna refere-se a posicao do scroll em relacao ao invite panel -31.4336f +65.6814f -0.7232132f, // x -0.9254344f +0.9254344f +0.7468368f, // y 914.5213f +5.99231f -7.011475f // z ); UIInteractivePanel panel = GetComponent<UIInteractivePanel>(); panel.transitions.list[0].AddTransitionStartDelegate(EnteredInvite); panel.transitions.list[1].AddTransitionStartDelegate(EnteredInvite); inviteFriendPanel.GetComponent<UIInteractivePanel>().transitions.list[2].AddTransitionEndDelegate(SetInviteFriendsInactive); //searchText.SetFocusDelegate(ClearText); //searchText.AddValidationDelegate(TextChanged); ChangedAllPlaying(); // Find Friends Button if(Save.HasKey(PlayerPrefsKeys.FACEBOOK_TOKEN.ToString())) { findFriendsPanel.SetActive(false); } else { fb_account = new GameFacebook(handleLinkFacebook); } }
protected override void OnUpdate() { base.OnUpdate(); // Every time the clock ticks over, make an attempt to update the contract window // title. We do this because otherwise the window will only ever read the title once, // so this is the only way to get our fancy timer to work. if (Planetarium.GetUniversalTime() - lastUpdate > 1.0f) { // Boom! if (Planetarium.GetUniversalTime() > endTime) { SetFailed(); } lastUpdate = Planetarium.GetUniversalTime(); // Go through all the list items in the contracts window UIScrollList list = ContractsApp.Instance.cascadingList.cascadingList; if (list != null) { for (int i = 0; i < list.Count; i++) { // Try to find a rich text control that matches the expected text UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i); SpriteTextRich richText = listObject.GetComponentInChildren <SpriteTextRich>(); if (richText != null) { // Check for any string in titleTracker string found = null; foreach (string title in titleTracker) { if (richText.Text.Contains(title)) { found = title; break; } } // Clear the titleTracker, and replace the text if (found != null) { titleTracker.Clear(); richText.Text = richText.Text.Replace(found, GetTitle()); } } } } } }
public void InitCall() { GetComponent<UIScrollList>().ClearList (true); if(Flow.customStages != null) { foreach(CustomStage c in Flow.customStages) { AddContainer(c); } } scroll = Flow.config.GetComponent<ConfigManager>().challengeInviteScroll; scroll.transform.parent = transform; scroll.transform.localPosition = new Vector3(-0.1220818f, 0.1973438f, -7.011475f); }
public void InitCall() { GetComponent <UIScrollList>().ClearList(true); if (Flow.customStages != null) { foreach (CustomStage c in Flow.customStages) { AddContainer(c); } } scroll = Flow.config.GetComponent <ConfigManager>().challengeInviteScroll; scroll.transform.parent = transform; scroll.transform.localPosition = new Vector3(-0.1220818f, 0.1973438f, -7.011475f); }
public void SetAlpha(float value) { foreach (IUIObject current in this.uiObjs.Values) { if (current is AutoSpriteControlBase) { ((AutoSpriteControlBase)current).SetAlpha(value); } else if (current is UIScrollList) { UIScrollList uIScrollList = (UIScrollList)current; uIScrollList.SetAlpha(value); } } }
void Awake() { startWavePanel = GameObject.Find("WavePanel").GetComponent<UIInteractivePanel>(); startWaveButton = GameObject.Find("startWaveButton").GetComponent<UIButton>(); waveInfoPanel = GameObject.Find("WaveInfoPanel").GetComponent<UIPanel>(); waveInfoScrollList = GameObject.Find("WaveInfoScrollList").GetComponent<UIScrollList>(); waveInfoPanel.BringIn(); heroWaveManager = GameObject.Find("WaveManager").GetComponent<HeroWaveManager>(); heroWaveManager.onAllWaveEnemiesDefeated += HandleAllWaveEnemiesDefeated; heroWaveManager.onNextWaveReady += HandleOnNextWaveReady; heroWaveManager.onSpawnNewHero += HandleOnSpawnNewHero; waveButton = GameObject.Find("startWaveButton").GetComponent<tk2dSprite>(); waveButton.spriteId = waveButton.GetSpriteIdByName(waveStartButtonName); }
void Start() { monsterScrollList = GameObject.Find("MonsterScrollList").GetComponent<UIScrollList>(); statsPanel = GameObject.Find("MonsterInfoPanel").GetComponent<UIPanel>(); magnitudeBar = statsPanel.transform.FindChild("damage").FindChild("damageBar").GetComponent<UIProgressBar>(); attackSpeedBar = statsPanel.transform.FindChild("attackSpeed").FindChild("attackSpeedBar").GetComponent<UIProgressBar>(); attackRangeBar = statsPanel.transform.FindChild("range").FindChild("rangeBar").GetComponent<UIProgressBar>(); movementSpeedBar = statsPanel.transform.FindChild("moveSpeed").FindChild("moveSpeedBar").GetComponent<UIProgressBar>(); healthBar = statsPanel.transform.FindChild("health").FindChild("healthBar").GetComponent<UIProgressBar>(); spawnRate = statsPanel.transform.FindChild("spawnRate").GetComponent<SpriteText>(); monsterName = statsPanel.transform.FindChild("name").GetComponent<SpriteText>(); monsterSprite = statsPanel.transform.FindChild("sprite").GetComponent<tk2dSprite>(); goldCost = statsPanel.transform.FindChild("goldCost").GetComponent<SpriteText>(); confirmButton = statsPanel.transform.FindChild("okayButton").GetComponent<UIButton>(); confirmButtonImage = confirmButton.GetComponent<tk2dSprite>(); monsterSaleConfirmationPanel = GameObject.Find("SellConfirmationPanel").GetComponent<UIPanel>(); monsterSaleConfirmButton = monsterSaleConfirmationPanel.transform.FindChild("okayButton").GetComponent<UIButton>(); monsterSaleCancelButton = monsterSaleConfirmationPanel.transform.FindChild("cancelButton").GetComponent<UIButton>(); monsterSaleConfirmButton.scriptWithMethodToInvoke = this; monsterSaleCancelButton.scriptWithMethodToInvoke = this; monsterSaleConfirmButton.methodToInvoke = "MonsterSaleConfirmed"; monsterSaleCancelButton.methodToInvoke = "MonsterSaleCancelled"; scrollListCamera = monsterScrollList.renderCamera; levelManager = GameObject.Find("LevelManager").GetComponent<LevelManager>(); listPanel = GameObject.Find("MonsterSelectionPanel").GetComponent<UIPanel>(); Transform attackEffectParent = GameObject.Find("attackEffectIcons").transform.FindChild("icons"); actionEffectIcons = attackEffectParent.GetComponentsInChildren<tk2dSprite>(); if (playerStatusManager == null) playerStatusManager = GameObject.Find("PlayerStatusManager").GetComponent<PlayerStatusManager>(); entityFactory = EntityFactory.GetInstance(); monsterSelectedCallback = null; LoadMonsterScrollPanel(); }
/// <summary> /// Call this any time the title text has changed - this will make an attempt to update /// the contract window title. We do this because otherwise the window will only ever read /// the title once. /// </summary> /// <param name="newTitle">New title to display</param> public void UpdateContractWindow(string newTitle) { // Every time the clock ticks over, make an attempt to update the contract window // title. We do this because otherwise the window will only ever read the title once, // so this is the only way to get our fancy timer to work. // Go through all the list items in the contracts window UIScrollList list = ContractsApp.Instance.cascadingList.cascadingList; if (list != null) { for (int i = 0; i < list.Count; i++) { // Try to find a rich text control that matches the expected text UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i); SpriteTextRich richText = listObject.GetComponentInChildren <SpriteTextRich>(); if (richText != null) { // Check for any string in titleTracker string found = null; foreach (string title in titles) { if (richText.Text.Contains(title)) { found = title; break; } } // Clear the titleTracker, and replace the text if (found != null) { titles.Clear(); richText.Text = richText.Text.Replace(found, newTitle); titles.Add(newTitle); } } } // Reposition items to account for items where the height increased or decreased list.RepositionItems(); } }
internal void AddHollowWindow(GameObject window) { if (window == null) { return; } UIScrollList list = window.GetComponentInChildren <UIScrollList>(); if (list != null) { list.AddInputDelegate(HollowWindowInput); } AutoSpriteControlBase baseControl = window.GetComponentInChildren <AutoSpriteControlBase>(); if (baseControl != null) { baseControl.AddInputDelegate(HollowWindowInput); } }
public void On_ClickItem(IUIObject obj) { UIScrollList uIScrollList = obj as UIScrollList; if (uIScrollList != null) { UIListItemContainer selectedItem = uIScrollList.SelectedItem; if (selectedItem != null) { ImageSlot imageSlot = selectedItem.Data as ImageSlot; if (imageSlot != null && imageSlot.c_oItem != null) { ITEM iTEM = new ITEM(); iTEM.Set(imageSlot.c_oItem as ITEM); if (iTEM != null && iTEM.m_nItemUnique > 0) { ItemTooltipDlg itemTooltipDlg = NrTSingleton<FormsManager>.Instance.LoadForm(G_ID.ITEMTOOLTIP_DLG) as ItemTooltipDlg; itemTooltipDlg.Set_Tooltip((G_ID)base.WindowID, iTEM, null, false); } } } } }
// Use this for initialization void Start () { repositoryLists = Flow.config.transform.FindChild("-Lists-").gameObject; scroll = Flow.config.GetComponent<ConfigManager>().inviteAllScroll; playingScroll = Flow.config.GetComponent<ConfigManager>().invitePlayingScroll; scroll.transform.parent = gameObject.transform; playingScroll.transform.parent = gameObject.transform; scroll.transform.localPosition = new Vector3(-0.7232132f, 0.7468368f, -7.011475f); playingScroll.transform.position = new Vector3(-0.7232132f, 0.7468368f, -7.011475f); UIInteractivePanel panel = GetComponent<UIInteractivePanel>(); panel.transitions.list[0].AddTransitionStartDelegate(EnteredInvite); panel.transitions.list[1].AddTransitionStartDelegate(EnteredInvite); inviteFriendPanel.GetComponent<UIInteractivePanel>().transitions.list[2].AddTransitionEndDelegate(SetInviteFriendsInactive); inviteFriendPanel.GetComponent<UIInteractivePanel>().transitions.list[0].AddTransitionEndDelegate(AddEmail); //searchText.SetFocusDelegate(ClearText); //searchText.AddValidationDelegate(TextChanged); ChangedAllPlaying(); // Find Friends Button if(Save.HasKey(PlayerPrefsKeys.FACEBOOK_TOKEN.ToString())) { findFriendsPanel.SetActive(false); } else { fb_account = new GameFacebook(handleLinkFacebook); } }
// Use this for initialization void Start() { repositoryLists = Flow.config.transform.FindChild("-Lists-").gameObject; scroll = Flow.config.GetComponent <ConfigManager>().inviteAllScroll; playingScroll = Flow.config.GetComponent <ConfigManager>().invitePlayingScroll; scroll.transform.parent = gameObject.transform; playingScroll.transform.parent = gameObject.transform; scroll.transform.localPosition = new Vector3(-0.7232132f, 0.7468368f, -7.011475f); playingScroll.transform.position = new Vector3(-0.7232132f, 0.7468368f, -7.011475f); UIInteractivePanel panel = GetComponent <UIInteractivePanel>(); panel.transitions.list[0].AddTransitionStartDelegate(EnteredInvite); panel.transitions.list[1].AddTransitionStartDelegate(EnteredInvite); inviteFriendPanel.GetComponent <UIInteractivePanel>().transitions.list[2].AddTransitionEndDelegate(SetInviteFriendsInactive); inviteFriendPanel.GetComponent <UIInteractivePanel>().transitions.list[0].AddTransitionEndDelegate(AddEmail); //searchText.SetFocusDelegate(ClearText); //searchText.AddValidationDelegate(TextChanged); ChangedAllPlaying(); // Find Friends Button if (Save.HasKey(PlayerPrefsKeys.FACEBOOK_TOKEN.ToString())) { findFriendsPanel.SetActive(false); } else { fb_account = new GameFacebook(handleLinkFacebook); } }
public void SetList(UIScrollList c) { list = c; }
public StockRoster(UIScrollList crew) { this.crew = crew; }
private void _CreateListItem(UIScrollList scrollList) { UIListItem chatItem = scrollList.CreateItem( chatListItem) as UIListItem; chatItem.collider.enabled = false; chatItem.width = scrollList.viewableArea.x; chatItem.spriteText.maxWidth = scrollList.viewableArea.x; chatItem.CalcSize(); AsLanguageManager.Instance.SetFontFromSystemLanguage( chatItem.spriteText); chatItem.Text = ""; }
void handleDeleteFriendConnection(string error, IJSonObject data) { Flow.game_native.stopLoading(); if (error != null) { Flow.game_native.showMessage("Error", error); return; } // Remove o amigo da lista all e da lista playing independentemente se você clicou no delete de uma ou de outra. if (gameObject.GetComponent <UIListItemContainer>().GetScrollList().transform.tag == "FriendList") { UIScrollList playingScroll = gameObject.GetComponent <UIListItemContainer>().GetScrollList().transform.parent.FindChild("PlayingList").GetComponent <UIScrollList>(); for (int i = 0; i < playingScroll.Count; i++) { if (playingScroll.GetItem(i).transform.GetComponent <Friend>() && id == playingScroll.GetItem(i).transform.GetComponent <Friend>().id) { // se for 2, soh tem um container e uma letra if (playingScroll.Count != 2) { // se o proximo cara nao tiver o component friend, indica que ele é uma letra if (!playingScroll.GetItem(i + 1).transform.GetComponent <Friend>()) { // se o cara anterior nao tiver o component friend, indica que ele é uma letra if (!playingScroll.GetItem(i - 1).transform.GetComponent <Friend>()) { // remove a letra passada pois o container sendo removido é o unico da letra playingScroll.RemoveItem(i - 1, true); // o cara passou a ter o indice da letra, remove ele playingScroll.RemoveItem(i - 1, true); break; } } } else { // remove letra playingScroll.RemoveItem(0, true); // o cara passou a ter o indice da letra, remove ele playingScroll.RemoveItem(0, true); break; } // remove o container playingScroll.RemoveItem(i, true); break; } } } else { UIScrollList allScroll = gameObject.GetComponent <UIListItemContainer>().GetScrollList().transform.parent.FindChild("FriendList").GetComponent <UIScrollList>(); for (int i = 0; i < allScroll.Count; i++) { if (allScroll.GetItem(i).transform.GetComponent <Friend>() && id == allScroll.GetItem(i).transform.GetComponent <Friend>().id) { // se for 2, soh tem um container e uma letra if (allScroll.Count != 2) { // se o proximo cara nao tiver o component friend, indica que ele é uma letra if (!allScroll.GetItem(i + 1).transform.GetComponent <Friend>()) { // se o cara anterior nao tiver o component friend, indica que ele é uma letra if (!allScroll.GetItem(i - 1).transform.GetComponent <Friend>()) { // remove a letra passada pois o container sendo removido é o unico da letra allScroll.RemoveItem(i - 1, true); // o cara passou a ter o indice da letra, remove ele allScroll.RemoveItem(i - 1, true); break; } } } else { // remove a letra allScroll.RemoveItem(0, true); // o cara passou a ter o indice da letra, remove ele allScroll.RemoveItem(0, true); break; } // remove o container allScroll.RemoveItem(i, true); break; } } } // se for 2, soh tem um container e uma letra if (gameObject.GetComponent <UIListItemContainer>().GetScrollList().Count != 2) { // se o proximo cara nao tiver o component friend, indica que ele é uma letra if (!gameObject.GetComponent <UIListItemContainer>().GetScrollList().GetItem(GetComponent <UIListItemContainer>().Index + 1).transform.GetComponent <Friend>()) { // se o cara anterior nao tiver o component friend, indica que ele é uma letra if (!gameObject.GetComponent <UIListItemContainer>().GetScrollList().GetItem(GetComponent <UIListItemContainer>().Index - 1).transform.GetComponent <Friend>()) { // remove a letra passada pois o container sendo removido é o unico da letra gameObject.GetComponent <UIListItemContainer>().GetScrollList().RemoveItem(GetComponent <UIListItemContainer>().Index - 1, true); // o cara passou a ter o indice da letra, remove ele (MAS NESSE CASO O EZGUI ATUALIZOU O INDEX) gameObject.GetComponent <UIListItemContainer>().GetScrollList().RemoveItem(GetComponent <UIListItemContainer>().Index, true); return; } } } else { // remove a letra gameObject.GetComponent <UIListItemContainer>().GetScrollList().RemoveItem(0, true); // o cara passou a ter o indice da letra, remove ele gameObject.GetComponent <UIListItemContainer>().GetScrollList().RemoveItem(0, true); return; } gameObject.GetComponent <UIListItemContainer>().GetScrollList().RemoveItem(GetComponent <UIListItemContainer>(), false); }
public void InitList(bool bMainSelect) { SolComposeListDlg.SOL_LIST_INSERT_TYPE eIndex = this.INSERT_TYPE; if (null != this.ddList1) { if (bMainSelect && this.ShowType == SOLCOMPOSE_TYPE.COMPOSE) { this.ddList1.SetViewArea(this.ddlListKey1.Length); this.ddList1.Clear(); int num = 0; string[] array = this.ddlListKey1; for (int i = 0; i < array.Length; i++) { string strTextKey = array[i]; ListItem listItem = new ListItem(); listItem.SetColumnStr(0, NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface(strTextKey)); listItem.Key = num++; this.ddList1.Add(listItem); } this.ddList1.SetIndex((int)this.INSERT_TYPE); this.ddList1.RepositionItems(); } else if (bMainSelect && this.ShowType == SOLCOMPOSE_TYPE.TRANSCENDENCE) { this.ddList1.SetViewArea(this.ddlListKey1.Length); this.ddList1.Clear(); int num2 = 0; string[] array2 = this.ddlListKey1; for (int j = 0; j < array2.Length; j++) { string strTextKey2 = array2[j]; ListItem listItem2 = new ListItem(); listItem2.SetColumnStr(0, NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface(strTextKey2)); listItem2.Key = num2++; this.ddList1.Add(listItem2); } this.ddList1.SetIndex((int)this.INSERT_TYPE); this.ddList1.RepositionItems(); } else { this.ddList1.SetViewArea(1); this.ddList1.Clear(); int num3 = 0; ListItem listItem3 = new ListItem(); listItem3.SetColumnStr(0, NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface(this.ddlListKey1[0])); listItem3.Key = num3++; this.ddList1.Add(listItem3); this.ddList1.SetIndex((int)this.INSERT_TYPE); this.ddList1.RepositionItems(); } } if (!bMainSelect || this.ShowType == SOLCOMPOSE_TYPE.EXTRACT) { eIndex = SolComposeListDlg.SOL_LIST_INSERT_TYPE.WAIT; } if (bMainSelect && this.ShowType == SOLCOMPOSE_TYPE.TRANSCENDENCE) { eIndex = SolComposeListDlg.SOL_LIST_INSERT_TYPE.ALL; } UIScrollList arg_231_0 = this.ddList1; this.m_bMainSelect = bMainSelect; arg_231_0.controlIsEnabled = bMainSelect; this.InsertList(eIndex); }
public virtual void CheckMorelistMark(UIScrollList _scrollList) { if (_scrollList == null || upArrowSprite == null || downArrowSprite == null) return; if (_scrollList.Count > 0 && _scrollList.gameObject.activeSelf) { if (!_scrollList.IsShowingLastItem()) { if (downArrowSprite.IsHidden() == true) downArrowSprite.Hide(false); } else { if (downArrowSprite.IsHidden() == false) downArrowSprite.Hide(true); } if (!_scrollList.IsShowingFirstItem()) { if (upArrowSprite.IsHidden() == true) upArrowSprite.Hide(false); } else { if (upArrowSprite.IsHidden() == false) upArrowSprite.Hide(true); } } else { if (downArrowSprite.IsHidden() == false) downArrowSprite.Hide(true); if (upArrowSprite.IsHidden() == false) upArrowSprite.Hide(true); } }
public override void Copy(SpriteRoot s, ControlCopyFlags flags) { base.Copy(s, flags); if (!(s is UIListItem)) return; UIListItem b = (UIListItem)s; if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings) { list = b.list; } if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance) { topLeftEdge = b.topLeftEdge; bottomRightEdge = b.bottomRightEdge; colliderTL = b.colliderTL; colliderBR = b.colliderBR; colliderCenter = b.colliderCenter; customCollider = b.customCollider; } }
/// <summary> /// Set up the SortBar for the Editors' crew assignment panel. (Callback) /// </summary> protected void Start() { try { // Game Event Hooks GameEvents.onEditorScreenChange.Add(OnEditorScreenChange); GameEvents.onEditorLoad.Add(OnEditorLoad); GameEvents.onEditorRestart.Add(OnEditorRestart); GameEvents.onEditorShipModified.Add(OnEditorShipModified); // We actually do need these: GameEvents.onGUIAstronautComplexSpawn.Add(OnACSpawn); GameEvents.onGUIAstronautComplexDespawn.Add(OnACDespawn); // Get Roster: UIScrollList[] lists = UIManager.instance.gameObject.GetComponentsInChildren<UIScrollList>(true); availableCrew = null; vesselCrew = null; foreach( UIScrollList list in lists ) { if( list.name == "scrolllist_avail" ) { availableCrew = list; if( vesselCrew != null ) { break; } } else if( list.name == "scrolllist_crew" ) { vesselCrew = list; if( availableCrew != null ) { break; } } } if( availableCrew == null ) { throw new Exception("Could not find Available Crew List!"); } if( vesselCrew == null ) { throw new Exception("Could not find Vessel Crew List!"); } StockRoster available = new StockRoster(availableCrew); // Get position: (This is probably the one time we actually want to do this here) Transform tab_crewavail = availableCrew.transform.parent.Find("tab_crewavail"); BTButton tab = tab_crewavail.GetComponent<BTButton>(); Vector3 tabPos = Utilities.GetPosition(tab_crewavail); float x = tabPos.x + tab.width + 5; float y = tabPos.y - 1; // Set up button list: SortButtonDef[] buttons = new SortButtonDef[]{ StandardButtonDefs.ByName, StandardButtonDefs.ByClass, StandardButtonDefs.ByLevel, StandardButtonDefs.ByGender, StandardButtonDefs.ByNumFlights }; // Initialize the sort bar: sortBar = gameObject.AddComponent<SortBar>(); sortBar.SetRoster(available); sortBar.SetButtons(buttons); sortBar.SetDefaultOrdering(StandardKerbalComparers.DefaultAvailable); sortBar.SetPos(x, y); sortBar.enabled = false; // Create a fly-in animation for the sort bar. baseX = x; baseY = y; float animBeginTime = 0.2f; animEndTime = 0.5f; anim = AnimationCurve.Linear(animBeginTime, -575f, animEndTime, 0f); // This is what I would have *liked* to have done, but Unity decided this should do absolutely nothing. /*AnimationCurve curve = AnimationCurve.Linear(0f, 0f, 10f, 100f); AnimationClip clip = new AnimationClip(); clip.SetCurve("", typeof(Transform), "position.x", curve); sortBar.gameObject.AddComponent<Animation>().AddClip(clip, "flyin");*/ // Add some extra hooks: availableCrew.AddValueChangedDelegate(OnAvailListValueChanged); Transform trans = UIManager.instance.transform.FindChild("panel_CrewAssignmentInEditor"); foreach( BTButton btn in trans.GetComponentsInChildren<BTButton>() ) { if( btn.name == "button_reset" ) { btn.AddValueChangedDelegate(OnResetBtn); } else if( btn.name == "button_clear" ) { btn.AddValueChangedDelegate(OnClearBtn); } } trans = UIManager.instance.transform.FindChild("TopRightAnchor"); foreach( UIButton btn in trans.GetComponentsInChildren<UIButton>() ) { if( btn.name == "ButtonLoad" ) { btn.AddValueChangedDelegate(OnLoadBtn); } } fixDefaultAssignment = false; loadBtnPressed = false; noParts = true; } catch( Exception e ) { Debug.LogError("KerbalSorter: Unexpected error in EditorHook: " + e); } }
public void SetList(UIScrollList c) { this.list = c; }
void Start() { _scrollList = GetComponent<UIScrollList>(); }
/// <summary> /// Replaces a vessel's default crew with the first few kerbals available according to the given sortbar's settings. /// </summary> /// Prequisites: The vessel has only one cabin with crew in it. /// <param name="vesselCrew">List containing the vessel's crew</param> /// <param name="availableCrew">List containing the available crew</param> /// <param name="sortBar">The sortbar whose criterion to sort by</param> public static void FixDefaultVesselCrew(UIScrollList vesselCrew, UIScrollList availableCrew, SortBar sortBar) { // WARNING: Apparently this causes NullReferenceExceptions when used. I have yet to determine exactly why. // Until I can fix the NullReferenceExceptions, this will be commented out. // Find the one cabin with crew in it: /*int numCrew = 0; int crewLoc = -1; for( int i = 0; i < vesselCrew.Count; i++ ) { IUIListObject obj = vesselCrew.GetItem(i); CrewItemContainer cont = obj.gameObject.GetComponent<CrewItemContainer>(); if( cont == null && crewLoc >= 0 ) { // If both the above are true, we've hit the end of the crewed cabin. break; } else if( cont != null ) { if( crewLoc < 0 ) { crewLoc = i; } string debug = "KerbalSorter: " + cont.GetName() + " found in the vessel's crew."; debug += " In Vessel "; if( cont.GetCrewRef() != null && cont.GetCrewRef().KerbalRef != null && cont.GetCrewRef().KerbalRef.InVessel != null ) { debug += cont.GetCrewRef().KerbalRef.InVessel.name; } else { debug += "???"; } debug += " In Part "; if( cont.GetCrewRef() != null && cont.GetCrewRef().KerbalRef != null && cont.GetCrewRef().KerbalRef.InPart != null ) { debug += cont.GetCrewRef().KerbalRef.InPart.name; } else { debug += "???"; } debug += " Seat "; if( cont.GetCrewRef() != null && cont.GetCrewRef().seat != null ) { debug += cont.GetCrewRef().seat.name; } else { debug += "???"; } debug += " Idx "; if( cont.GetCrewRef() != null ) { debug += cont.GetCrewRef().seatIdx; } else { debug += "?"; } Debug.Log(debug); cont.SetButton(CrewItemContainer.ButtonTypes.V); vesselCrew.RemoveItem(i, false); availableCrew.AddItem(obj); numCrew++; i--; // Don't accidentally skip something! } }*/ // Re-sort the kerbals sortBar.SortRoster(); // Add input listeners to each of the kerbals so we can tell when they're dragged /*for( int i = 0; i < availableCrew.Count; i++ ) { availableCrew.GetItem(i).AddInputDelegate(OnInput); }*/ // Place the appropriate number of kerbals back into the crew roster /*for( int i = 0; i < numCrew; i++ ) { IUIListObject obj = availableCrew.GetItem(0); availableCrew.RemoveItem(0, false); vesselCrew.InsertItem(obj, crewLoc + i); obj.gameObject.GetComponent<CrewItemContainer>().SetButton(CrewItemContainer.ButtonTypes.X); }*/ }
/// <summary> /// Set up the Sort Bar for the Launch Windows. (Callback) /// </summary> protected void Start() { try { GameEvents.onGUILaunchScreenSpawn.Add(LaunchScreenSpawn); GameEvents.onGUILaunchScreenDespawn.Add(LaunchScreenDespawn); GameEvents.onGUILaunchScreenVesselSelected.Add(VesselSelect); // We actually do need these: GameEvents.onGUIAstronautComplexSpawn.Add(OnACSpawn); GameEvents.onGUIAstronautComplexDespawn.Add(OnACDespawn); // Get the Roster and the vessel crew list: VesselSpawnDialog window = UIManager.instance.gameObject.GetComponentsInChildren <VesselSpawnDialog>(true).FirstOrDefault(); if (window == null) { throw new Exception("Could not find Launch Window!"); } UIScrollList[] lists = window.GetComponentsInChildren <UIScrollList>(true); availableCrew = null; vesselCrew = null; foreach (UIScrollList list in lists) { if (list.name == "scrolllist_avail") { availableCrew = list; if (vesselCrew != null) { break; } } else if (list.name == "scrolllist_crew") { vesselCrew = list; if (availableCrew != null) { break; } } } if (availableCrew == null) { throw new Exception("Could not find Available Crew List!"); } if (vesselCrew == null) { throw new Exception("Could not find Vessel Crew List!"); } StockRoster available = new StockRoster(availableCrew); // Set up button list: SortButtonDef[] buttons = new SortButtonDef[] { StandardButtonDefs.ByName, StandardButtonDefs.ByClass, StandardButtonDefs.ByLevel, StandardButtonDefs.ByGender, StandardButtonDefs.ByNumFlights }; // Initialize the sort bar: sortBar = gameObject.AddComponent <SortBar>(); sortBar.SetRoster(available); sortBar.SetButtons(buttons); sortBar.SetDefaultOrdering(StandardKerbalComparers.DefaultAvailable); sortBar.enabled = false; // Set up some hooks to detect when the list is changing: availableCrew.AddValueChangedDelegate(OnAvailListValueChanged); Transform anchorButtons = window.transform.FindChild("anchor/vesselInfo/crewAssignment/crewAssignmentSpawnpoint/anchorButtons"); BTButton btn = anchorButtons.FindChild("button_reset").GetComponent <BTButton>(); btn.AddValueChangedDelegate(OnResetBtn); btn = anchorButtons.FindChild("button_clear").GetComponent <BTButton>(); btn.AddValueChangedDelegate(OnClearBtn); } catch (Exception e) { Debug.LogError("KerbalSorter: Unexpected error in LaunchWindowHook: " + e); } }
/// <summary> /// Set up the SortBars for the Astronaut Complex. (Callback) /// </summary> protected void Start() { try { // Set up hooks: GameEvents.onGUIAstronautComplexSpawn.Add(OnACSpawn); GameEvents.onGUIAstronautComplexDespawn.Add(OnACDespawn); GameEvents.OnCrewmemberHired.Add(OnHire); GameEvents.OnCrewmemberSacked.Add(OnFire); // Get rosters: complex = UIManager.instance.gameObject.GetComponentsInChildren <CMAstronautComplex>(true).FirstOrDefault(); if (complex == null) { throw new Exception("Could not find astronaut complex"); } UIScrollList availableList = complex.transform.Find("CrewPanels/panel_enlisted/panelManager/panel_available/scrolllist_available").GetComponent <UIScrollList>(); UIScrollList assignedList = complex.transform.Find("CrewPanels/panel_enlisted/panelManager/panel_assigned/scrolllist_assigned").GetComponent <UIScrollList>(); UIScrollList killedList = complex.transform.Find("CrewPanels/panel_enlisted/panelManager/panel_kia/scrolllist_kia").GetComponent <UIScrollList>(); UIScrollList applicantList = complex.transform.Find("CrewPanels/panel_applicants/scrolllist_applicants").GetComponent <UIScrollList>(); available = new StockRoster(availableList); assigned = new StockRoster(assignedList); killed = new StockRoster(killedList); applicants = new StockRoster(applicantList); // Set up button list: SortButtonDef[] buttonsCrew = new SortButtonDef[] { StandardButtonDefs.ByName, StandardButtonDefs.ByClass, StandardButtonDefs.ByLevel, StandardButtonDefs.ByGender, StandardButtonDefs.ByNumFlights }; SortButtonDef[] buttonsApplicants = new SortButtonDef[] { StandardButtonDefs.ByName, StandardButtonDefs.ByClass, StandardButtonDefs.ByGender }; // Initialize the crew sort bar: sortBarCrew = gameObject.AddComponent <SortBar>(); sortBarCrew.SetRoster(available); sortBarCrew.SetButtons(buttonsCrew); sortBarCrew.SetDefaultOrdering(StandardKerbalComparers.DefaultAvailable); sortBarCrew.enabled = false; curPanel = CrewPanel.Available; /// Initialize the applicant sort bar: sortBarApplicants = gameObject.AddComponent <SortBar>(); sortBarApplicants.SetRoster(applicants); sortBarApplicants.SetButtons(buttonsApplicants); sortBarApplicants.SetDefaultOrdering(StandardKerbalComparers.DefaultApplicant); sortBarApplicants.enabled = false; // Assign enable listeners to the rosters: Utilities.AddOnEnableListener(availableList.gameObject, OnTabAvailable, true); Utilities.AddOnEnableListener(assignedList.gameObject, OnTabAssigned, true); Utilities.AddOnEnableListener(killedList.gameObject, OnTabKilled, true); // There's no other way to detect KSI's presence, unfortunately. :/ foreach (AssemblyLoader.LoadedAssembly asm in AssemblyLoader.loadedAssemblies) { if (asm.dllName == "KSI") { KSILoaded = true; } } } catch (Exception e) { Debug.LogError("KerbalSorter: Unexpected error in AstronautComplexHook: " + e); } }
/// <summary> /// Set up the Sort Bar for the Launch Windows. (Callback) /// </summary> protected void Start() { try { GameEvents.onGUILaunchScreenSpawn.Add(LaunchScreenSpawn); GameEvents.onGUILaunchScreenDespawn.Add(LaunchScreenDespawn); GameEvents.onGUILaunchScreenVesselSelected.Add(VesselSelect); // We actually do need these: GameEvents.onGUIAstronautComplexSpawn.Add(OnACSpawn); GameEvents.onGUIAstronautComplexDespawn.Add(OnACDespawn); // Get the Roster and the vessel crew list: VesselSpawnDialog window = UIManager.instance.gameObject.GetComponentsInChildren<VesselSpawnDialog>(true).FirstOrDefault(); if( window == null ) { throw new Exception("Could not find Launch Window!"); } UIScrollList[] lists = window.GetComponentsInChildren<UIScrollList>(true); availableCrew = null; vesselCrew = null; foreach( UIScrollList list in lists ) { if( list.name == "scrolllist_avail" ) { availableCrew = list; if( vesselCrew != null ) { break; } } else if( list.name == "scrolllist_crew" ) { vesselCrew = list; if( availableCrew != null ) { break; } } } if( availableCrew == null ) { throw new Exception("Could not find Available Crew List!"); } if( vesselCrew == null ) { throw new Exception("Could not find Vessel Crew List!"); } StockRoster available = new StockRoster(availableCrew); // Set up button list: SortButtonDef[] buttons = new SortButtonDef[]{ StandardButtonDefs.ByName, StandardButtonDefs.ByClass, StandardButtonDefs.ByLevel, StandardButtonDefs.ByGender, StandardButtonDefs.ByNumFlights }; // Initialize the sort bar: sortBar = gameObject.AddComponent<SortBar>(); sortBar.SetRoster(available); sortBar.SetButtons(buttons); sortBar.SetDefaultOrdering(StandardKerbalComparers.DefaultAvailable); sortBar.enabled = false; // Set up some hooks to detect when the list is changing: availableCrew.AddValueChangedDelegate(OnAvailListValueChanged); Transform anchorButtons = window.transform.FindChild("anchor/vesselInfo/crewAssignment/crewAssignmentSpawnpoint/anchorButtons"); BTButton btn = anchorButtons.FindChild("button_reset").GetComponent<BTButton>(); btn.AddValueChangedDelegate(OnResetBtn); btn = anchorButtons.FindChild("button_clear").GetComponent<BTButton>(); btn.AddValueChangedDelegate(OnClearBtn); } catch( Exception e ) { Debug.LogError("KerbalSorter: Unexpected error in LaunchWindowHook: " + e); } }
/// <summary> /// Set up the SortBar for the Editors' crew assignment panel. (Callback) /// </summary> protected void Start() { try { // Game Event Hooks GameEvents.onEditorScreenChange.Add(OnEditorScreenChange); GameEvents.onEditorLoad.Add(OnEditorLoad); GameEvents.onEditorRestart.Add(OnEditorRestart); GameEvents.onEditorShipModified.Add(OnEditorShipModified); // We actually do need these: GameEvents.onGUIAstronautComplexSpawn.Add(OnACSpawn); GameEvents.onGUIAstronautComplexDespawn.Add(OnACDespawn); // Get Roster: UIScrollList[] lists = UIManager.instance.gameObject.GetComponentsInChildren <UIScrollList>(true); availableCrew = null; vesselCrew = null; foreach (UIScrollList list in lists) { if (list.name == "scrolllist_avail") { availableCrew = list; if (vesselCrew != null) { break; } } else if (list.name == "scrolllist_crew") { vesselCrew = list; if (availableCrew != null) { break; } } } if (availableCrew == null) { throw new Exception("Could not find Available Crew List!"); } if (vesselCrew == null) { throw new Exception("Could not find Vessel Crew List!"); } StockRoster available = new StockRoster(availableCrew); // Get position: (This is probably the one time we actually want to do this here) Transform tab_crewavail = availableCrew.transform.parent.Find("tab_crewavail"); BTButton tab = tab_crewavail.GetComponent <BTButton>(); Vector3 tabPos = Utilities.GetPosition(tab_crewavail); float x = tabPos.x + tab.width + 5; float y = tabPos.y - 1; // Set up button list: SortButtonDef[] buttons = new SortButtonDef[] { StandardButtonDefs.ByName, StandardButtonDefs.ByClass, StandardButtonDefs.ByLevel, StandardButtonDefs.ByGender, StandardButtonDefs.ByNumFlights }; // Initialize the sort bar: sortBar = gameObject.AddComponent <SortBar>(); sortBar.SetRoster(available); sortBar.SetButtons(buttons); sortBar.SetDefaultOrdering(StandardKerbalComparers.DefaultAvailable); sortBar.SetPos(x, y); sortBar.enabled = false; // Create a fly-in animation for the sort bar. baseX = x; baseY = y; float animBeginTime = 0.2f; animEndTime = 0.5f; anim = AnimationCurve.Linear(animBeginTime, -575f, animEndTime, 0f); // This is what I would have *liked* to have done, but Unity decided this should do absolutely nothing. /*AnimationCurve curve = AnimationCurve.Linear(0f, 0f, 10f, 100f); * AnimationClip clip = new AnimationClip(); * clip.SetCurve("", typeof(Transform), "position.x", curve); * sortBar.gameObject.AddComponent<Animation>().AddClip(clip, "flyin");*/ // Add some extra hooks: availableCrew.AddValueChangedDelegate(OnAvailListValueChanged); Transform trans = UIManager.instance.transform.FindChild("panel_CrewAssignmentInEditor"); foreach (BTButton btn in trans.GetComponentsInChildren <BTButton>()) { if (btn.name == "button_reset") { btn.AddValueChangedDelegate(OnResetBtn); } else if (btn.name == "button_clear") { btn.AddValueChangedDelegate(OnClearBtn); } } trans = UIManager.instance.transform.FindChild("TopRightAnchor"); foreach (UIButton btn in trans.GetComponentsInChildren <UIButton>()) { if (btn.name == "ButtonLoad") { btn.AddValueChangedDelegate(OnLoadBtn); } } fixDefaultAssignment = false; loadBtnPressed = false; noParts = true; } catch (Exception e) { Debug.LogError("KerbalSorter: Unexpected error in EditorHook: " + e); } }
public void OnGUI() { needRepaint = false; int oldState = curState; textureAreaBottom = 0; isDirty = false; if (restarted) { selGO = null; control = null; OnSelectionChange(); restarted = false; } // See if our window size has changed: if (wndRect != position) { WindowResized(); } // See if we need to update our selection: if (Selection.activeGameObject != selGO) { OnSelectionChange(); } //#if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9) if (Selection.activeGameObject != null) { control = (IControl)Selection.activeGameObject.GetComponent("IControl"); } //#endif // Bailout if we don't have valid values: if (null == (MonoBehaviour)control) { // See if this is a scroll list: UIScrollList list = null; if (Selection.activeGameObject != null) { list = Selection.activeGameObject.GetComponent <UIScrollList>(); } if (list != null) { list.DrawPreTransitionUI(0, this); return; } else { PrintNoSelectMsg(); return; } } // Start keeping track of any changed values: BeginMonitorChanges(); // Do the pre-state selection GUI, if any: height = control.DrawPreStateSelectGUI(curState, false); EndMonitorChanges(); // Get the control's state names: stateNames = control.EnumStateElements(); if (stateNames == null) { return; } // Cap our state to the number of states available: if (stateNames != null) { curState = Mathf.Min(curState, stateNames.Length - 1); } else { curState = 0; } // Choose the state we want to edit: curState = GUILayout.Toolbar(curState, stateNames); // Reset our selected transition element // if the state selection changed: if (curState != oldState) { curFromTrans = 0; curTransElement = 0; } // Keep track of any changed values: BeginMonitorChanges(); // Do the post-state selection GUI, if any: height += control.DrawPostStateSelectGUI(curState); EndMonitorChanges(); // Adjust our texture selection rect: tempRect = texRect; tempRect.y += height; if (control is IPackableControl) { ShowSpriteSettings(); } else { stateInfo = control.GetStateElementInfo(curState); } transitions = stateInfo.transitions; if (!Application.isPlaying) { #if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9) // Box off our script selection and transition fields area: GUILayout.BeginArea(new Rect(0, textureAreaBottom, position.width, position.height - textureAreaBottom)); GUILayout.FlexibleSpace(); #endif //----------------------------------------- // Draw script selection: //----------------------------------------- BeginMonitorChanges(); control.DrawPreTransitionUI(curState, this); EndMonitorChanges(); //----------------------------------------- // Draw our state label stuff: //----------------------------------------- if (stateInfo.stateLabel != null) { BeginMonitorChanges(); DoStateLabel(); EndMonitorChanges(); } //----------------------------------------- // Draw our transition stuff: //----------------------------------------- if (transitions != null) { if (transitions.list != null) { if (transitions.list.Length > 0) { DoTransitionStuff(); } } } #if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9) // End the boxed off area for our script selection and transition fields. GUILayout.EndArea(); #endif } GUILayout.BeginVertical(); GUILayout.Space(10f); GUILayout.EndVertical(); // Set dirty if anything changed: if (isDirty) { EditorUtility.SetDirty((MonoBehaviour)control); } if (needRepaint) { Repaint(); } }
/// <summary> /// Replaces a vessel's default crew with the first few kerbals available according to the given sortbar's settings. /// </summary> /// Prequisites: The vessel has only one cabin with crew in it. /// <param name="vesselCrew">List containing the vessel's crew</param> /// <param name="availableCrew">List containing the available crew</param> /// <param name="sortBar">The sortbar whose criterion to sort by</param> public static void FixDefaultVesselCrew(UIScrollList vesselCrew, UIScrollList availableCrew, SortBar sortBar) { // WARNING: Apparently this causes NullReferenceExceptions when used. I have yet to determine exactly why. // Until I can fix the NullReferenceExceptions, this will be commented out. // Find the one cabin with crew in it: /*int numCrew = 0; * int crewLoc = -1; * for( int i = 0; i < vesselCrew.Count; i++ ) { * IUIListObject obj = vesselCrew.GetItem(i); * CrewItemContainer cont = obj.gameObject.GetComponent<CrewItemContainer>(); * if( cont == null && crewLoc >= 0 ) { * // If both the above are true, we've hit the end of the crewed cabin. * break; * } * else if( cont != null ) { * if( crewLoc < 0 ) { * crewLoc = i; * } * string debug = "KerbalSorter: " + cont.GetName() + " found in the vessel's crew."; * debug += " In Vessel "; * if( cont.GetCrewRef() != null && cont.GetCrewRef().KerbalRef != null && cont.GetCrewRef().KerbalRef.InVessel != null ) { * debug += cont.GetCrewRef().KerbalRef.InVessel.name; * } * else { * debug += "???"; * } * debug += " In Part "; * if( cont.GetCrewRef() != null && cont.GetCrewRef().KerbalRef != null && cont.GetCrewRef().KerbalRef.InPart != null ) { * debug += cont.GetCrewRef().KerbalRef.InPart.name; * } * else { * debug += "???"; * } * debug += " Seat "; * if( cont.GetCrewRef() != null && cont.GetCrewRef().seat != null ) { * debug += cont.GetCrewRef().seat.name; * } * else { * debug += "???"; * } * debug += " Idx "; * if( cont.GetCrewRef() != null ) { * debug += cont.GetCrewRef().seatIdx; * } * else { * debug += "?"; * } * Debug.Log(debug); * cont.SetButton(CrewItemContainer.ButtonTypes.V); * vesselCrew.RemoveItem(i, false); * availableCrew.AddItem(obj); * numCrew++; * i--; // Don't accidentally skip something! * } * }*/ // Re-sort the kerbals sortBar.SortRoster(); // Add input listeners to each of the kerbals so we can tell when they're dragged /*for( int i = 0; i < availableCrew.Count; i++ ) { * availableCrew.GetItem(i).AddInputDelegate(OnInput); * }*/ // Place the appropriate number of kerbals back into the crew roster /*for( int i = 0; i < numCrew; i++ ) { * IUIListObject obj = availableCrew.GetItem(0); * availableCrew.RemoveItem(0, false); * vesselCrew.InsertItem(obj, crewLoc + i); * * obj.gameObject.GetComponent<CrewItemContainer>().SetButton(CrewItemContainer.ButtonTypes.X); * }*/ }