Ejemplo n.º 1
0
 public void Set(bool state)
 {
     if (this.tabRoot != null && state)
     {
         UITab[] componentsInChildren = this.tabRoot.GetComponentsInChildren <UITab>(true);
         int     i   = 0;
         int     num = componentsInChildren.Length;
         while (i < num)
         {
             UITab uITab = componentsInChildren[i];
             if (uITab != this && uITab.tabRoot == this.tabRoot)
             {
                 uITab.Set(false);
                 uITab.mChecked = false;
             }
             i++;
         }
     }
     this.mChecked = state;
     for (int j = 0; j < this.tabSprite.Length; j++)
     {
         if (this.tabSprite[j] != null)
         {
             TweenAlpha.Begin(this.tabSprite[j].gameObject, 0.15f, (!this.mChecked) ? 0f : 1f);
         }
     }
     this.DispatcherEvents();
 }
Ejemplo n.º 2
0
 public void Set(bool state)
 {
     if (tabRoot != null && state)
     {
         UITab[] cbs = tabRoot.GetComponentsInChildren <UITab>(true);
         for (int i = 0, imax = cbs.Length; i < imax; ++i)
         {
             UITab cb = cbs[i];
             if (cb != this && cb.tabRoot == tabRoot)
             {
                 cb.Set(false);
                 cb.mChecked = false;
             }
         }
     }
     mChecked = state;
     for (int i = 0; i < tabSprite.Length; i++)
     {
         if (tabSprite[i] != null)
         {
             TweenAlpha.Begin(tabSprite[i].gameObject, 0.15f, mChecked ? 1f : 0f);
         }
     }
     if (state)
     {
         DispatcherEvents();
     }
 }
Ejemplo n.º 3
0
        protected bool ShouldShowTab(UITab tab)
        {
            switch (tab)
            {
            case UITab.Maintenance:
            case UITab.Facilities:
            case UITab.Integration:
                return(HighLogic.LoadedScene == GameScenes.SPACECENTER && HighLogic.CurrentGame.Mode == Game.Modes.CAREER);

            case UITab.Tooling:
            case UITab.ToolingType:
            case UITab.Contracts:
                return(HighLogic.CurrentGame.Mode == Game.Modes.CAREER);

            case UITab.Avionics:
                return(HighLogic.LoadedSceneIsEditor);

            case UITab.Astronauts:
                return(HighLogic.LoadedScene == GameScenes.SPACECENTER);

            case UITab.Training:
            case UITab.Courses:
            case UITab.NewCourse:
            case UITab.Naut:
            case UITab.CareerLog:
            default:
                return(true);
            }
        }
Ejemplo n.º 4
0
 private void UpdateSelectedTab()
 {
     if (ShouldShowTab(UITab.Maintenance) && RenderToggleButton("Maintenance", _currentTab == UITab.Maintenance))
     {
         _currentTab = UITab.Maintenance;
     }
     if (ShouldShowTab(UITab.Tooling) && RenderToggleButton("Tooling", _currentTab == UITab.Tooling))
     {
         _currentTab = UITab.Tooling;
     }
     if (ShouldShowTab(UITab.Training) && RenderToggleButton("Astronauts", _currentTab == UITab.Training))
     {
         _currentTab = UITab.Training;
     }
     if (ShouldShowTab(UITab.Courses) && RenderToggleButton("Courses", _currentTab == UITab.Courses))
     {
         _currentTab = UITab.Courses;
     }
     if (ShouldShowTab(UITab.Avionics) && RenderToggleButton("Avionics", _currentTab == UITab.Avionics))
     {
         _currentTab = UITab.Avionics;
     }
     if (ShouldShowTab(UITab.CareerLog) && RenderToggleButton("Career Log", _currentTab == UITab.CareerLog))
     {
         _currentTab = UITab.CareerLog;
     }
 }
Ejemplo n.º 5
0
 void Init()
 {
     tab = FindComponent <UITab>("Group");
     tab.tabClickAction = OnDiskSetAndPlay;
     tab.tabHoverAction = OnDiskSet;
     btnRoot            = tab.transform;
 }
Ejemplo n.º 6
0
Archivo: FSGUI.cs Proyecto: KvaNTy/RP-0
        private void RenderSummaryBody(UITab currentTab)
        {
            UpdateActiveCourseMap();
            float scrollHeight = currentTab == UITab.Training ? 420 : 305;

            _nautListScroll = GUILayout.BeginScrollView(_nautListScroll, GUILayout.Width(505), GUILayout.Height(scrollHeight));
            try
            {
                RenderNautListHeading();
                for (int i = 0; i < HighLogic.CurrentGame.CrewRoster.Count; i++)
                {
                    ProtoCrewMember student = HighLogic.CurrentGame.CrewRoster[i];
                    if (student.type == ProtoCrewMember.KerbalType.Crew &&
                        (student.rosterStatus == ProtoCrewMember.RosterStatus.Available ||
                         (currentTab == UITab.Training && student.rosterStatus == ProtoCrewMember.RosterStatus.Assigned)))
                    {
                        RenderNautListRow(currentTab, student);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
            GUILayout.EndScrollView();
        }
Ejemplo n.º 7
0
 public static void SwitchTabTo(UITab newTab)
 {
     if (newTab == _currentTab)
     {
         return;
     }
     _currentTab        = newTab;
     _shouldResetUISize = true;
 }
Ejemplo n.º 8
0
 protected override void Start()
 {
     base.Start();
     if (Tabs.Count > 0)
     {
         OpenTab = Tabs[0];
         ChangeTab(OpenTab);
     }
 }
Ejemplo n.º 9
0
    void Init()
    {
        Control("Continue").GetComponent <Button>().onClick.AddListener(OnClickClose);
        audioTab = Control("AudioTab").GetComponent <UITab>();
        saveTab  = Control("SaveTab").GetComponent <UITab>();
        if (Startup.ins != null)
        {
            Control("BGMSlider").GetComponent <Slider>().value    = GameData.gameStatus.MusicVolume;
            Control("EffectSlider").GetComponent <Slider>().value = GameData.gameStatus.SoundVolume;
            Control("HSliderBar").GetComponent <Slider>().value   = GameData.gameStatus.AxisSensitivity.x;
            Control("VSliderBar").GetComponent <Slider>().value   = GameData.gameStatus.AxisSensitivity.y;
        }
        Control("BGMSlider").GetComponent <Slider>().onValueChanged.AddListener(OnMusicVolumeChange);
        Control("EffectSlider").GetComponent <Slider>().onValueChanged.AddListener(OnEffectVolumeChange);
        Control("HSliderBar").GetComponent <Slider>().onValueChanged.AddListener(OnXSensitivityChange);
        Control("VSliderBar").GetComponent <Slider>().onValueChanged.AddListener(OnYSensitivityChange);
        Control("QuitGame").GetComponent <UIButtonExtended>().onClick.AddListener(OnClickBack);
        Control("ResetPosition").GetComponent <Button>().onClick.AddListener(OnResetPosition);
        Control("ReloadTable").GetComponent <Button>().onClick.AddListener(() => { U3D.ReloadTable(); });
        Control("LoadLevel").GetComponent <Button>().onClick.AddListener(OnLoadLevel);
        Control("SetJoyPosition").GetComponent <Button>().onClick.AddListener(OnSetJoyPosition);
        Control("DoScript").GetComponent <Button>().onClick.AddListener(OnDoScript);

        Toggle toggleDebug = Control("EnableDebug").GetComponent <Toggle>();

        toggleDebug.isOn = GameData.gameStatus.EnableDebug;
        toggleDebug.onValueChanged.AddListener(OnEnableDebug);

        Toggle toggleEnableFunc = Control("EnableFunc").GetComponent <Toggle>();

        toggleEnableFunc.isOn = GameData.gameStatus.EnableFunc;
        toggleEnableFunc.onValueChanged.AddListener(OnEnableFunc);

        Toggle toggleEnableInfiniteAngry = Control("EnableInfiniteAngry").GetComponent <Toggle>();

        toggleEnableInfiniteAngry.isOn = GameData.gameStatus.EnableInfiniteAngry;
        toggleEnableInfiniteAngry.onValueChanged.AddListener(OnEnableInfiniteAngry);

        Toggle toggleEnableItemName = Control("EnableItemName").GetComponent <Toggle>();

        toggleEnableItemName.isOn = GameData.gameStatus.EnableItemName;
        toggleEnableItemName.onValueChanged.AddListener(OnEnableItemName);

        Toggle toggleEnableGodMode = Control("EnableGodMode").GetComponent <Toggle>();

        toggleEnableGodMode.isOn = GameData.gameStatus.EnableGodMode;
        toggleEnableGodMode.onValueChanged.AddListener(OnEnableGodMode);

        Control("ChangeV107").GetComponent <Button>().onClick.AddListener(() => { OnChangeVer("1.07"); });
        //Control("Ver108").GetComponent<Button>().onClick.AddListener(() => { OnChangeVer(108); });
        Control("ChangeV907").GetComponent <Button>().onClick.AddListener(() => { OnChangeVer("9.07"); });
        Control("AppVerText").GetComponent <Text>().text    = Global.AppVersion;
        Control("MeteorVerText").GetComponent <Text>().text = Global.MeteorVersion;
        Control("ChangeModel").GetComponent <Button>().onClick.AddListener(() => { ModelWnd.Instance.Open(); });
        mWindowStyle = WindowStyle.WS_Modal;
    }
Ejemplo n.º 10
0
 public void UnselectTab(IUITab uiTab)
 {
     try{
         UITab tab = (UITab)uiTab;
         tab.GetComponent <Image>().color = Color.white;
     }
     catch (UnityException ex) {
         Debug.Log(ex.StackTrace);
     }
 }
Ejemplo n.º 11
0
    public void ShowTab(int tab)
    {
        GameObject grid    = Control("Tabs Grid");
        Transform  tabCtrl = grid.transform.GetChild(tab);

        if (tabCtrl != null)
        {
            UITab t = tabCtrl.GetComponent <UITab>();
            t.isOn = true;
        }
    }
Ejemplo n.º 12
0
    void Init()
    {
        GameObject chapterTab = Control("ChapterTab", WndObject);
        GameObject modelTab   = Control("ModelTab", WndObject);

        Control("Return").GetComponent <Button>().onClick.AddListener(() => {
            Close();
        });
        Control("PluginPrev").GetComponent <Button>().onClick.AddListener(OnPrevPagePlugin);
        Control("PluginNext").GetComponent <Button>().onClick.AddListener(OnNextPagePlugin);
        Control("ResetModel").GetComponent <Button>().onClick.AddListener(() => {
            GameStateMgr.Ins.gameStatus.UseModel = -1;
            U3D.PopupTip("已设置使用默认角色");
        });
        ChapterRoot = Control("Content", chapterTab);
        ModelRoot   = Control("Content", modelTab);
        //模组分页内的功能设定
        Control("DeletePlugin").GetComponent <Button>().onClick.AddListener(() => {
            U3D.DeletePlugins(filter);
            int f = filter;
            Close();
            Main.Ins.DialogStateManager.ChangeState(Main.Ins.DialogStateManager.DlcManagerDialogState, f);
        });
        Toggle togShowInstallPlugin = Control("ShowInstallToggle").GetComponent <Toggle>();

        togShowInstallPlugin.onValueChanged.AddListener((bool value) => { this.showInstallPlugin = value; DlcMng.Ins.CollectAll(this.showInstallPlugin, filter); this.PluginPageRefreshEx(); });
        togShowInstallPlugin.isOn = true;

        Control("InstallAll").GetComponent <Button>().onClick.AddListener(OnInstallAll);
        UITab select = null;

        UITab[] tabs = WndObject.GetComponentsInChildren <UITab>();
        for (int i = 0; i < tabs.Length; i++)
        {
            tabs[i].onValueChanged.AddListener(OnTabShow);
            if (filter == i)
            {
                select = tabs[i];
            }
        }
        if (select != null)
        {
            if (!select.isOn)
            {
                select.Select();
                return;
            }
        }
        OnTabShow(true);
    }
Ejemplo n.º 13
0
 public void ClearTab()
 {
     try{
         foreach (UITab tab in tabs)
         {
             // set all tabs to silhouette
             tab.GetComponent <Image>().color = Color.white;
         }
         selectedTab = null;
     }
     catch (UnityException ex) {
         Debug.Log(ex.StackTrace);
     }
 }
Ejemplo n.º 14
0
        public void Callback_TabClicked(UITab tab)
        {
            //Find the type of tab that was clicked on and select it.
            foreach (var kvp in TabTypeToObj)
            {
                if (kvp.Value == tab)
                {
                    SwitchToTab(kvp.Key);
                    return;
                }
            }

            throw new ArgumentException(tab.name);
        }
Ejemplo n.º 15
0
    public static UITab Get(GameObject go)
    {
        UITab load = go.GetComponent <UITab>();

        if (load == null)
        {
            load = go.AddComponent <UITab>();
        }

        if (!load.m_init)
        {
            load.Start();
        }

        return(load);
    }
Ejemplo n.º 16
0
    public void ChangeTab(UITab newTab)
    {
        if (OpenTab.Tab != null)
        {
            OpenTab.Tab.interactable = true;
        }
        OpenTab.Settings.Group.alpha          = 0;
        OpenTab.Settings.Group.blocksRaycasts = false;

        if (newTab.Tab != null)
        {
            newTab.Tab.interactable = false;
        }
        newTab.Settings.Group.alpha          = 1;
        newTab.Settings.Group.blocksRaycasts = true;
        OpenTab = newTab;
    }
Ejemplo n.º 17
0
    public void ChangeTabs(Button click)
    {
        int index = -1;

        for (int i = 0; i < Tabs.Count; i++)
        {
            UITab tab = Tabs[i];
            if (tab.Tab == click)
            {
                index = i;
                break;
            }
        }

        if (index >= 0)
        {
            ChangeTab(Tabs[index]);
        }
    }
Ejemplo n.º 18
0
    public void SelectTab(IUITab uiTab)
    {
        if (uiTab == null)
        {
            return;
        }

        try{
            UITab tab = (UITab)uiTab;
            if (selectedTab != tab)
            {
                ClearTab();
                tab.GetComponent <Image>().color = transparent;
                selectedTab = tab;
            }
        }
        catch (UnityException ex) {
            Debug.Log(ex.StackTrace);
        }
    }
Ejemplo n.º 19
0
    void Awake()
    {
        m_transform = transform;
        m_window    = m_transform.FindChild("Anchor_Center/Window");

        #region Button
        m_window.FindChild("CloseButton").GetComponent <UIEventListener>().onClick = OnClose;
        m_window.FindChild("HelpButton").GetComponent <UIEventListener>().onClick  = OnHelp;
        #endregion

        #region Tab
        SelectTab selectTab = new SelectTab(OnSelectTab);
        m_tabGroup = new UITab[(int)ACHIEVE_TAB_TYPE.TYPE_END];
        string[] tabPathArray = { "Tab_Group/Daily_Tab", "Tab_Group/Progress_Tab", "Tab_Group/Complete_Tab" };

        for (int i = 0; i < tabPathArray.Length; i++)
        {
            m_tabGroup[i] = new UITab(m_window.FindChild(tabPathArray[i]).gameObject, (ACHIEVE_TAB_TYPE)i, selectTab);
        }
        #endregion

        #region Scroll
        m_scrollPanel = m_window.FindChild("ScrollWindow/ScrollView").GetComponent <UIPanel>();
        m_scrollView  = m_scrollPanel.GetComponent <UIScrollView>();
        m_scrollGrid  = m_scrollPanel.transform.FindChild("Grid");
        m_scrollBar   = m_window.FindChild("ScrollWindow/ScrollBar").GetComponent <UIScrollBar>();

        m_emptyView = m_window.FindChild("ScrollWindow/EmptyView").gameObject;

        InitItem();
        #endregion

        #region Object
        GameObject tooltipObj = Instantiate(AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/UIItemTooltip")) as GameObject;
        tooltipObj.transform.parent        = m_window;
        tooltipObj.transform.localPosition = Vector3.zero;
        tooltipObj.transform.localScale    = Vector3.one;
        m_uiItemTooltip = tooltipObj.GetComponent <UIItemTooltip>();
        #endregion
    }
Ejemplo n.º 20
0
        private static void _autoExtendTabPages(UITab tab)
        {
            if (tab == null)
            {
                return;
            }
            if (tab.TabPages == null)
            {
                return;
            }
            if (tab.TabPages.Count == 0)
            {
                return;
            }

            for (int i = 0; i < tab.TabPages.Count; ++i)
            {
                var page = tab.TabPages[i];
                page.Size     = new Size(tab.Width, page.Height);
                page.Location = new Point(0, page.Location.Y);
            }
        }
Ejemplo n.º 21
0
 private void TryLoadItemsOfTab(UIFrameworkDefinition uidef, UITab uitab, RibbonTab tab)
 {
     if (uitab.Children == null)
     {
         return;
     }
     foreach (UIItem it in uitab.Children)
     {
         if (it is UICommandGroup)
         {
             RadRibbonBarGroup group = GetRadRibbonBarGroup(it as UICommandGroup);
             if (group != null)
             {
                 tab.Items.Add(group);
                 if (!it.Visible)
                 {
                     group.Visibility = ElementVisibility.Collapsed;
                 }
             }
         }
     }
 }
Ejemplo n.º 22
0
    public void OnTabSelect(UITab selectedTab)
    {
        selectedTab.Background.depth = 12;
        int step         = 1;
        int currentDepth = 1;

        foreach (UITab tab in Tabs)
        {
            if (tab == selectedTab)
            {
                step         = -1;
                currentDepth = 10;
            }
            else
            {
                tab.Background.depth = currentDepth + step;
                currentDepth         = tab.Background.depth;
                tab.OnDeselectTab();
            }
        }

        ParentPanel.OnTabSelect(selectedTab.Name);
    }
Ejemplo n.º 23
0
        public static void Main(string[] args)
        {
            uiInitOptions o = new uiInitOptions();

            uiInit(ref o);

            List <UIMenu> menus = new List <UIMenu>();
            var           menu  = new UIMenu("File");

            menus.Add(menu);
            var item = menu.AppendItem("Open");

            item.OnClicked += (mi, w) =>
            {
                string filename = window.OpenFile();
                if (String.IsNullOrEmpty(filename))
                {
                    window.MessageBox("No file selected", "Don't be alarmed!", true);
                    return;
                }
                window.MessageBox("File selected", filename);
            };
            item            = menu.AppendItem("Save");
            item.OnClicked += (mi, w) =>
            {
                string filename = window.OpenFile();
                if (String.IsNullOrEmpty(filename))
                {
                    window.MessageBox("No file selected", "Don't be alarmed!", true);
                    return;
                }
                window.MessageBox("File selected (don't worry, it's still there)", filename);
            };
            item = menu.AppendQuitItem();
            //uiOnShouldQuit()

            menu = new UIMenu("Edit");
            menus.Add(menu);
            item = menu.AppendCheckItem("Checkable Item");
            menu.AppendSeparator();
            item         = menu.AppendItem("Disabled Item");
            item.Enabled = false;
            item         = menu.AppendPreferencesItem();

            menu = new UIMenu("Help");
            menus.Add(menu);
            item = menu.AppendItem("Help");
            menu.AppendAboutItem();

            window = new UIWindow("libui Control Gallery", 640, 480, true);

            window.Margined   = true;
            window.OnClosing += (w) =>
            {
                window.Dispose();
                uiQuit();
                return(0);
            };

            var box = new UIBox(true);

            box.Padded = true;
            window.SetChild(box);

            var hbox = new UIBox();

            box.Padded = true;
            box.Append(hbox, true);

            var group = new UIGroup("Basic Controls");

            group.Margined = true;
            hbox.Append(group, false);

            var inner = new UIBox(true);

            inner.Padded = true;
            group.SetChild(inner);

            inner.Append(new UIButton("Button"), false);

            var entry = new UIEntry();

            entry.Text = "Entry";
            inner.Append(entry, false);

            inner.Append(new UILabel("Label"), false);

            inner.Append(new UISeparator(), false);

            inner.Append(new UIDateTimePicker(UIDateTimePickerType.Date), false);

            inner.Append(new UIDateTimePicker(UIDateTimePickerType.Time), false);

            inner.Append(new UIDateTimePicker(UIDateTimePickerType.DateTime), false);

            //inner.Append(new UIFontButton(), false);

            var inner2 = new UIBox(true);

            inner2.Padded = true;
            hbox.Append(inner2, true);

            group          = new UIGroup("Numbers");
            group.Margined = true;
            inner2.Append(group, false);

            inner        = new UIBox(true);
            inner.Padded = true;
            group.SetChild(inner);

            var spinbox = new UISpinbox(0, 100);

            inner.Append(spinbox, false);

            var slider = new UISlider(0, 100);

            inner.Append(slider, false);

            var progressbar = new UIProgressBar();

            inner.Append(progressbar, false);

            group          = new UIGroup("Lists");
            group.Margined = true;
            inner2.Append(group, false);

            inner        = new UIBox(true);
            inner.Padded = true;
            group.SetChild(inner);

            spinbox.OnChanged += (s) =>
            {
                slider.Value      = spinbox.Value;
                progressbar.Value = (int)spinbox.Value;
            };

            slider.OnChanged += (s) =>
            {
                spinbox.Value     = slider.Value;
                progressbar.Value = (int)slider.Value;
            };

            var cbox = new UICombobox();

            cbox.Append("Combobox Item 1");
            cbox.Append("Combobox Item 2");
            cbox.Append("Combobox Item 3");
            inner.Append(cbox, false);

            cbox = new UICombobox(true);
            cbox.Append("Editable Item 1");
            cbox.Append("Editable Item 2");
            cbox.Append("Editable Item 3");
            inner.Append(cbox, false);

            var rb = new UIRadioButtons();

            rb.Append("Radio Button 1");
            rb.Append("Radio Button 2");
            rb.Append("Radio Button 3");
            inner.Append(rb, true);

            var tab = new UITab();

            tab.Append("Page 1", new UIBox());
            tab.Append("Page 2", new UIBox());
            tab.Append("Page 3", new UIBox());
            inner2.Append(tab, true);

            GC.Collect();

            window.Shown = true;
            uiMain();
            uiUninit();
            GC.KeepAlive(menus);
            GC.KeepAlive(window);
        }
Ejemplo n.º 24
0
 public int GetIndexOfTab(UITab uiTab) => tabs.IndexOf(uiTab);
Ejemplo n.º 25
0
	protected virtual void TabSelected (UITab curretItemTab)
	{
		currentTab = tabs.IndexOf(curretItemTab);
		foreach(UITab tab in tabs)
		{
			if(tab != curretItemTab)
				tab.Normnal ();
		}
		Reset ();
	}
Ejemplo n.º 26
0
        public void SwitchTab(UITab button)
        {
            CMTab newTab = null;


            switch (button)
            {
            case UITab.Combat:
                if (!(currentTab is CombatTab))
                {
                    newTab = CombatTab;
                    toolbar.SetClickedButton(0);
                }
                break;

            case UITab.Monsters:
                if (!(currentTab is MonstersTab))
                {
                    newTab = MonstersTab;
                    toolbar.SetClickedButton(1);
                }
                break;

            case UITab.Feats:
                if (!(currentTab is FeatsTab))
                {
                    newTab = FeatsTab;
                    toolbar.SetClickedButton(2);
                }
                break;

            case UITab.Spells:
                if (!(currentTab is SpellsTab))
                {
                    newTab = SpellsTab;
                }
                toolbar.SetClickedButton(3);
                break;

            case UITab.Rules:
                if (!(currentTab is RulesTab))
                {
                    newTab = RulesTab;
                }
                toolbar.SetClickedButton(4);
                break;

            case UITab.Treasure:
                if (!(currentTab is TreasureTab))
                {
                    newTab = TreasureTab;
                }
                toolbar.SetClickedButton(5);
                break;
            }
            if (newTab != null && newTab != currentTab)
            {
                currentTab.RemoveFromSuperview();
                currentTab = newTab;
                AddSubview(newTab);

                Resize();
                toolbar.SetNeedsDisplay();
            }
        }
Ejemplo n.º 27
0
 public TopWindow()
 {
     // Reset the tab on scene changes
     _currentTab = default;
 }
Ejemplo n.º 28
0
 public TopWindow()
 {
     // Reset the tab on scene changes
     _currentTab        = HighLogic.LoadedSceneIsEditor ? UITab.Tooling : default;
     _shouldResetUISize = true;
 }
Ejemplo n.º 29
0
 public static void SwitchTabTo(UITab newTab)
 {
     _currentTab = newTab;
 }
Ejemplo n.º 30
0
	protected override void TabSelected (UITab curretItemTab)
	{
		base.TabSelected (curretItemTab);
		detailInformation.Hide ();
	}
Ejemplo n.º 31
0
        public void DrawWindow(int windowID)
        {
            GUILayout.BeginVertical();
            try
            {
                // If TotalUpkeep is zero, we probably haven't calculated the upkeeps yet, so recalculate now
                if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && MaintenanceHandler.Instance.TotalUpkeep == 0)
                {
                    MaintenanceHandler.Instance?.UpdateUpkeep();
                }

                UpdateSelectedTab();
                if (ShouldShowTab(_currentTab))
                {
                    switch (_currentTab)
                    {
                    case UITab.Maintenance:
                        _maintUI.RenderSummaryTab();
                        break;

                    case UITab.Facilities:
                        _maintUI.RenderFacilitiesTab();
                        break;

                    case UITab.Integration:
                        _maintUI.RenderIntegrationTab();
                        break;

                    case UITab.Astronauts:
                        _maintUI.RenderAstronautsTab();
                        break;

                    case UITab.Tooling:
                        _currentTab = _toolUI.RenderToolingTab();
                        break;

                    case UITab.ToolingType:
                        _toolUI.RenderTypeTab();
                        break;

                    case UITab.Training:
                        _currentTab = _fsUI.RenderSummaryTab();
                        break;

                    case UITab.Courses:
                        _currentTab = _fsUI.RenderCoursesTab();
                        break;

                    case UITab.NewCourse:
                        _currentTab = _fsUI.RenderNewCourseTab();
                        break;

                    case UITab.Naut:
                        _fsUI.RenderNautTab();
                        break;

                    case UITab.Avionics:
                        _avUI.RenderAvionicsTab();
                        break;

                    case UITab.CareerLog:
                        _logUI.RenderTab();
                        break;

                    default:        // can't happen
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Ejemplo n.º 32
0
Archivo: FSGUI.cs Proyecto: KvaNTy/RP-0
        protected void RenderNautListRow(UITab currentTab, ProtoCrewMember student)
        {
            ActiveCourse currentCourse = null;

            if (_activeMap.ContainsKey(student))
            {
                currentCourse = _activeMap[student];
            }
            bool selectedForCourse = _selectedCourse != null && _selectedCourse.Students.Contains(student);

            GUILayout.BeginHorizontal();
            try
            {
                GUILayout.Label($"{student.trait.Substring(0, 1)} {student.experienceLevel}", GUILayout.Width(24));
                if (currentCourse == null && _selectedCourse != null && (selectedForCourse || _selectedCourse.MeetsStudentReqs(student)))
                {
                    var c = new GUIContent(student.name, "Select for course");
                    if (RenderToggleButton(c, selectedForCourse, GUILayout.Width(144)))
                    {
                        if (selectedForCourse)
                        {
                            _selectedCourse.RemoveStudent(student);
                        }
                        else
                        {
                            _selectedCourse.AddStudent(student);
                        }
                    }
                }
                else if (currentTab == UITab.Training)
                {
                    if (GUILayout.Button(student.name, HighLogic.Skin.button, GUILayout.Width(144)))
                    {
                        _selectedNaut = student;
                    }
                }
                else
                {
                    GUILayout.Label(student.name, GUILayout.Width(144));
                }

                string course, complete, retires;
                bool   isInactive = false;
                if (currentCourse == null)
                {
                    if (student.rosterStatus == ProtoCrewMember.RosterStatus.Assigned)
                    {
                        course   = "(in-flight)";
                        complete = "(n/a)";
                    }
                    else if (student.inactive)
                    {
                        course     = "(inactive)";
                        complete   = KSPUtil.PrintDate(student.inactiveTimeEnd, false);
                        isInactive = true;
                    }
                    else
                    {
                        course   = "(free)";
                        complete = "(n/a)";
                    }
                }
                else
                {
                    course   = currentCourse.name;
                    complete = KSPUtil.PrintDate(currentCourse.CompletionTime(), false);
                }
                GUILayout.Label(course, GUILayout.Width(96));
                GUILayout.Label(complete, GUILayout.Width(80));

                if (CrewHandler.Instance.KerbalRetireTimes.ContainsKey(student.name))
                {
                    retires = CrewHandler.Instance.RetirementEnabled ? KSPUtil.PrintDate(CrewHandler.Instance.KerbalRetireTimes[student.name], false) : "(n/a)";
                }
                else
                {
                    retires = "(unknown)";
                }
                GUILayout.Label(retires, GUILayout.Width(80));

                if (currentCourse != null)
                {
                    if (currentCourse.seatMin > 1)
                    {
                        if (GUILayout.Button(new GUIContent("X", "Cancel course"), HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
                        {
                            CancelCourse(currentCourse);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button(new GUIContent("X", "Remove from course"), HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
                        {
                            LeaveCourse(currentCourse, student);
                        }
                    }

                    if (KACWrapper.APIReady && GUILayout.Button(_nautRowAlarmBtnContent, HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
                    {
                        CreateCourseFinishAlarm(student, currentCourse);
                    }
                }
                else if (KACWrapper.APIReady && isInactive && GUILayout.Button(_nautRowAlarmBtnContent, HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
                {
                    CreateReturnToDutyAlarm(student);
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
            GUILayout.EndHorizontal();
        }