Beispiel #1
0
        private HashSet <StageButtonView> CreateStageButtons(StageGroup stageGroup)
        {
            var buttons = new HashSet <StageButtonView>();

            var noChildren = stageGroup.GroupedStages.Count == 0;

            var rowSpan      = noChildren ? 2 : 1;
            var inverseScale = noChildren ? 1 : 1.5;

            var mainStageButton = new StageButtonView(stageGroup.MainStage, buttonView => stageSelectedCommand.Execute(buttonView.Stage));

            Grid.SetRowSpan(mainStageButton, rowSpan);
            mainStageButton.InverseScaleText(inverseScale);
            ButtonGrid.Children.Add(mainStageButton);
            buttons.Add(mainStageButton);


            inverseScale += (stageGroup.GroupedStages.Count - 1) * 0.5;
            for (int i = 0; i < stageGroup.GroupedStages.Count; i++)
            {
                GroupedStages.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });

                var groupStageButton = new StageButtonView(stageGroup.GroupedStages[i], buttonView => stageSelectedCommand.Execute(buttonView.Stage));
                groupStageButton.InverseScaleText(inverseScale);
                buttons.Add(groupStageButton);

                GroupedStages.Children.Add(groupStageButton, i, 0);
            }

            return(buttons);
        }
        public void HasStage_IsChild_True()
        {
            var testObj = new StageGroup(stageA, stageB, stageC);

            var hasStage = testObj.HasStage(stageC);

            Assert.True(hasStage);
        }
 public static StageElement createStageElement(StageGroup group, Form_Main form_MainT)
 {
     form_Main = form_MainT;
     element = new StageElement(group);
     SmallDialog_Stage dialog = new SmallDialog_Stage("新建场景",true);
     dialog.ShowDialog();
     return element;
 }
        public void HasStage_DoesNot_False()
        {
            var testObj = new StageGroup(stageA, stageB);

            var hasStage = testObj.HasStage(stageC);

            Assert.False(hasStage);
        }
Beispiel #5
0
 private void StageDestroy(StageGroup group)
 {
     if (panels.Contains(group))
     {
         panels[group].Destroy();
         panels[group] = null;
         panels.Remove(group);
     }
 }
        public static StageElement createStageElement(StageGroup group, Form_Main form_MainT)
        {
            form_Main = form_MainT;
            element   = new StageElement(group);
            SmallDialog_Stage dialog = new SmallDialog_Stage("新建场景", true);

            dialog.ShowDialog();
            return(element);
        }
Beispiel #7
0
        public void AddGroup(string groupName, int stageId)
        {
            var        maxSequene = _dbContext.StageGroups.Where(x => x.StageId == stageId).Select(x => x.Sequence).Max();
            StageGroup group      = new StageGroup();

            group.GroupName = groupName;
            group.StageId   = stageId;
            group.Sequence  = maxSequene++;
            _dbContext.StageGroups.Add(group);
        }
        private void UpdateWinBanners(StageGroup stageGroup, IStageGroupView stageGroupView, Player player)
        {
            var winStack = ViewModel.SetController.totalWins[player];
            int winCount = winStack.Count(stageGroup.HasStage);

            if (winCount > 0)
            {
                stageGroupView.ShowWins(winCount, player, stageGroup.HasStage(winStack.Peek()));
            }
        }
Beispiel #9
0
        private void StageAwake(StageGroup group)
        {
            bool display = BasicDeltaV.Instance.DisplayActive;

            //BasicDeltaV.BasicLogging("New Stage: Index: {0} - Last Stage: {1} - Current Stage: {2}", group.inverseStageIndex, StageManager.LastStage, StageManager.CurrentStage);

            if (display && HighLogic.LoadedSceneIsFlight && BasicDeltaV_Settings.Instance.ShowCurrentStageOnly)
            {
                display = group.inverseStageIndex == StageManager.LastStage;
            }

            AddStagePanel(group, display);
        }
Beispiel #10
0
        public StageGroupView(StageGroup stageGroup, StrikingViewModel strikingViewModel)
        {
            this.stageGroup        = stageGroup;
            this.strikingViewModel = strikingViewModel;

            strikingViewModel.StageStruckEvent   += OnStageStruck;
            strikingViewModel.StageUnstruckEvent += OnStageUnstruck;

            InitializeComponent();

            stageSelectedCommand = new Command(OnStageSelected);
            stageButtons         = CreateStageButtons(stageGroup);
        }
        private void AddStageGroupNode()
        {
            TreeNode newStG    = new StageGroup(parent.ActivatedWorkSpaceData);
            TreeNode newSt     = new Stage(parent.ActivatedWorkSpaceData);
            TreeNode newTask   = new TaskNode(parent.ActivatedWorkSpaceData);
            TreeNode newFolder = new Folder(parent.ActivatedWorkSpaceData, "Initialize");

            newFolder.AddChild(new StageBG(parent.ActivatedWorkSpaceData));
            newTask.AddChild(newFolder);
            newTask.AddChild(new TaskWait(parent.ActivatedWorkSpaceData, "240"));
            newSt.AddChild(newTask);
            newStG.AddChild(newSt);
            parent.Insert(newStG);
        }
        public StageGroupSingleView(StageGroup stageGroup, StrikingViewModel strikingViewModel)
        {
            this.stageGroup        = stageGroup;
            this.strikingViewModel = strikingViewModel;

            stageSelectedCommand = new Command(OnStageSelected);

            strikingViewModel.StageStruckEvent   += OnStageStruck;
            strikingViewModel.StageUnstruckEvent += OnStageUnstruck;

            InitializeComponent();

            var button = new StageButtonView(stageGroup.MainStage, view => stageSelectedCommand.Execute(stageGroup.MainStage));

            ButtonLayout.Children.Add(button);
        }
        private async Task <GroupCoords> CreateTournamentAndStages(IDbConnection c, IDbTransaction t, Competition competition)
        {
            var result = new GroupCoords();

            var tournament = new Tournament
            {
                Name   = competition.Caption,
                Status = (int)TournamentStatus.Playing,
                Type   = 1
            };

            tournament.Id = await c.InsertAsync(tournament, t);

            result.IdTournament = tournament.Id;
            result.Tournament   = tournament;

            var stage = new TournamentStage
            {
                Name          = "Liga",
                IdTournament  = result.IdTournament,
                SequenceOrder = 1,
                Type          = (int)CalendarType.League
            };

            stage.Id = await c.InsertAsync(stage, t);

            result.IdStage = stage.Id;
            result.Stage   = stage;

            var group = new StageGroup
            {
                Name          = "Grupo único",
                IdTournament  = result.IdTournament,
                IdStage       = result.IdStage,
                SequenceOrder = 1,
                NumTeams      = competition.NumberOfTeams,
                NumRounds     = 1
            };

            group.Id = await c.InsertAsync(group, t);

            result.IdGroup = group.Id;
            result.Group   = group;

            return(result);
        }
Beispiel #14
0
        private void AddStageGroupNode()
        {
            TreeNode newStG    = new StageGroup(parent.ActivatedWorkSpaceData);
            TreeNode newSt     = new Stage(parent.ActivatedWorkSpaceData);
            TreeNode newTask   = new TaskNode(parent.ActivatedWorkSpaceData);
            TreeNode newFolder = new Folder(parent.ActivatedWorkSpaceData, "Initialize");

            newFolder.AddChild(new Code(parent.ActivatedWorkSpaceData,
                                        "LoadMusic(\'spellcard\',\'THlib\\\\music\\\\spellcard.ogg\',75,0xc36e80/44100/4)"));
            newFolder.AddChild(new StageBG(parent.ActivatedWorkSpaceData, "bamboo_background"));
            newTask.AddChild(newFolder);
            newTask.AddChild(new TaskWait(parent.ActivatedWorkSpaceData, "60"));
            newTask.AddChild(new PlayBGM(parent.ActivatedWorkSpaceData, "\"spellcard\"", "", "false"));
            newTask.AddChild(new TaskWait(parent.ActivatedWorkSpaceData, "180"));
            newSt.AddChild(newTask);
            newStG.AddChild(newSt);
            parent.Insert(newStG);
        }
        private void Start()
        {
            if (HighLogic.LoadedSceneIsEditor && !BasicDeltaV.ReadoutsAvailable)
            {
                Destroy(this);
                return;
            }
            else if (HighLogic.LoadedSceneIsFlight && !BasicDeltaV.ReadoutsAvailable)
            {
                Destroy(this);
                return;
            }

            group = GetComponent <StageGroup>();

            if (group != null)
            {
                OnStageGroupAwake.Invoke(group);
            }
        }
        private void processEditorStageGroup()
        {
            StageManager prefabEditor = null;

            var prefabs = Resources.FindObjectsOfTypeAll <StageManager>();

            for (int i = prefabs.Length - 1; i >= 0; i--)
            {
                var pre = prefabs[i];

                if (pre.name == "StageManagerEditor")
                {
                    prefabEditor = pre;
                }
            }

            if (prefabEditor == null)
            {
                return;
            }

            StageGroup group = prefabEditor.stageGroupPrefab;

            if (stageGroupSprite == null)
            {
                Transform layout = group.transform.Find("IconLayout");

                if (layout != null)
                {
                    stageGroupSprite = layout.GetComponent <Image>().sprite;
                }
            }

            group.gameObject.AddComponent <BasicDeltaV_StageGroupHandler>();

            stageEditorGroupProcessed = true;
        }
        private void loadSprites()
        {
            ContractsApp prefab = null;

            var prefabs = Resources.FindObjectsOfTypeAll <ContractsApp>();

            for (int i = prefabs.Length - 1; i >= 0; i--)
            {
                var pre = prefabs[i];

                if (pre.name != "ContractsApp")
                {
                    continue;
                }

                prefab = pre;
                break;
            }

            if (prefab != null)
            {
                GenericAppFrame      appFrame      = null;
                GenericCascadingList cascadingList = null;
                UIListItem_spacer    spacer        = null;

                try
                {
                    var fields = typeof(ContractsApp).GetFields(BindingFlags.NonPublic | BindingFlags.Instance).ToArray();

                    appFrame = fields[7].GetValue(prefab) as GenericAppFrame;

                    cascadingList = fields[9].GetValue(prefab) as GenericCascadingList;

                    spacer = fields[11].GetValue(prefab) as UIListItem_spacer;
                }
                catch (Exception e)
                {
                    BasicOrbit.BasicLogging("Error in processing toolbar panel UI: {0}", e);
                }

                if (appFrame != null)
                {
                    windowSprite = appFrame.gfxBg.sprite;
                    titleSprite  = appFrame.gfxHeader.sprite;
                    footerSprite = appFrame.gfxFooter.sprite;
                }

                if (cascadingList != null)
                {
                    buttonSprite        = cascadingList.cascadeHeader.GetComponent <Image>().sprite;
                    contentFooterSprite = cascadingList.cascadeFooter.GetComponent <Image>().sprite;
                }

                if (spacer != null)
                {
                    componentSprite = spacer.GetComponent <Image>().sprite;

                    UIStateImage stateImage = spacer.GetComponentInChildren <UIStateImage>();

                    selectedSprite   = stateImage.states[1].sprite;
                    unselectedSprite = stateImage.states[0].sprite;
                }
            }

            StageManager prefabFlight = null;

            var stages = Resources.FindObjectsOfTypeAll <StageManager>();

            for (int i = stages.Length - 1; i >= 0; i--)
            {
                var pre = stages[i];

                if (pre.name == "StageManager")
                {
                    prefabFlight = pre;
                }
            }

            if (prefabFlight != null)
            {
                StageGroup group = prefabFlight.stageGroupPrefab;

                Transform layout = group.transform.FindChild("IconLayout");

                if (layout != null)
                {
                    panelSprite = layout.GetComponent <Image>().sprite;
                }
            }

            spritesLoaded = true;
        }
        private void processFlightStageGroup()
        {
            StageManager prefabFlight = null;

            var prefabs = Resources.FindObjectsOfTypeAll <StageManager>();

            for (int i = prefabs.Length - 1; i >= 0; i--)
            {
                var pre = prefabs[i];

                if (pre.name == "StageManager")
                {
                    prefabFlight = pre;
                }
            }

            if (prefabFlight == null)
            {
                return;
            }

            try
            {
                var fields = typeof(StageIcon).GetFields(BindingFlags.NonPublic | BindingFlags.Instance).ToArray();

                StageIconInfoBox infoBar = fields[12].GetValue(prefabFlight.stageIconPrefab) as StageIconInfoBox;

                panelInfoBarPrefab = Instantiate(infoBar, BasicDeltaV_Settings.Instance.transform);
                panelInfoBarPrefab.gameObject.name = "BasicerDeltaV";

                RectTransform infoRect = panelInfoBarPrefab.GetComponent <RectTransform>();

                infoRect.anchorMin        = new Vector2(1, 1);
                infoRect.anchorMax        = new Vector2(1, 1);
                infoRect.anchoredPosition = new Vector2(25, 12);

                panelInfoBarPrefab.GetComponent <LayoutElement>().ignoreLayout = true;

                panelInfoBarPrefab.SetCaption(string.Format("<color=#{0}> ΔV</color>", BasicDeltaV.TextColor));
                panelInfoBarPrefab.SetProgressBarBgColor(new Color(0.51765f, 0.71765f, 0.003922f, 0.6f));
                panelInfoBarPrefab.SetProgressBarColor(new Color(1, 1, 0.078431f, 0.6f));

                Slider slider = panelInfoBarPrefab.GetComponentInChildren <Slider>();

                RectTransform sliderRect = slider.GetComponent <RectTransform>();

                sliderRect.sizeDelta        = new Vector2(sliderRect.sizeDelta.x, 16);
                sliderRect.anchoredPosition = new Vector2(sliderRect.anchoredPosition.x, -2);

                TextMeshProUGUI captionText = panelInfoBarPrefab.GetComponentsInChildren <TextMeshProUGUI>()[1];

                captionText.color = Color.white;

                RectTransform captionRect = captionText.rectTransform;

                captionRect.sizeDelta = new Vector2(captionRect.sizeDelta.x, 16);

                tooltipPrefab = panelInfoBarPrefab.GetComponent <TooltipController_Text>();

                //BasicDeltaV.BasicLogging("Toolip: Enabled: {0} tooltip prefab: {1} instance" , tool.enabled
                //    , tool.prefab == null ? "Null" : "Valid", tool.TooltipPrefabInstance == null ? "Null" : "Valid");

                tooltipPrefab.enabled          = true;
                tooltipPrefab.continuousUpdate = true;

                Destroy(panelInfoBarPrefab.GetComponentInChildren <TextMeshProUGUI>().gameObject);
                Destroy(panelInfoBarPrefab.GetComponentInChildren <Image>().gameObject);

                //BasicDeltaV.BasicLogging("DV Panel Prefab processed");
            }
            catch (Exception e)
            {
                panelInfoBarPrefab = null;

                BasicDeltaV.BasicLogging("Error in stage panel info box UI: {0}", e);
            }

            StageGroup group = prefabFlight.stageGroupPrefab;

            if (stageGroupSprite == null)
            {
                Transform layout = group.transform.Find("IconLayout");

                if (layout != null)
                {
                    stageGroupSprite = layout.GetComponent <Image>().sprite;
                }
            }

            group.gameObject.AddComponent <BasicDeltaV_StageGroupHandler>();

            stageFlightGroupProcessed = true;
        }
Beispiel #19
0
        private void AddStagePanel(StageGroup group, bool display)
        {
            bool iconInfo = false;

            StageIconInfoBox dvInfo = null;

            if (HighLogic.LoadedSceneIsFlight)
            {
                int checks = 0;

                for (int i = group.Icons.Count - 1; i >= 0; i--)
                {
                    StageIcon icon = group.Icons[i];

                    if (icon.grouped)
                    {
                        if (icon.expanded)
                        {
                            if (checks >= 1)
                            {
                                if (icon.groupedIcons[icon.groupedIcons.Count - 1].isDisplayingInfo)
                                {
                                    iconInfo = true;
                                    break;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                checks += 2;
                            }
                        }
                        else
                        {
                            checks++;
                        }

                        if (!icon.isDisplayingInfoInGroup)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        checks++;

                        if (!icon.isDisplayingInfo)
                        {
                            continue;
                        }
                    }

                    iconInfo = true;
                    break;
                }

                //BasicDeltaV.BasicLogging("Info Box: {0}", BasicDeltaV_Loader.PanelInfoBarPrefab == null ? "Null" : "Valid");

                dvInfo = Instantiate(BasicDeltaV_Loader.PanelInfoBarPrefab, group.transform);
                dvInfo.transform.SetAsFirstSibling();
            }

            BasicDeltaV_StagePanel panel = new BasicDeltaV_StagePanel(group.RectTransform, group.inverseStageIndex, iconInfo, display, dvInfo);

            panels.Add(group, panel);
        }
Beispiel #20
0
        public void UpdatePanels()
        {
            for (int i = panels.Count - 1; i >= 0; i--)
            {
                StageGroup group = panels.KeyAt(i);

                if (group == null)
                {
                    continue;
                }

                BasicDeltaV_StagePanel panel = panels.At(i);

                if (panel == null)
                {
                    continue;
                }

                panel.Index = group.inverseStageIndex;

                panel.Stage = BasicDeltaV.Instance.GetStage(panel.Index);

                if (panel.Stage == null)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (!BasicDeltaV.Instance.DisplayActive)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (group.Icons.Count <= 0)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (HighLogic.LoadedSceneIsFlight && BasicDeltaV_Settings.Instance.ShowCurrentStageOnly)
                {
                    if (group.inverseStageIndex == StageManager.LastStage)
                    {
                        if (panel.Stage.deltaV <= 0)
                        {
                            panel.ToggleNoDVModules(true);
                        }
                        else
                        {
                            panel.ToggleNoDVModules(false);
                        }
                    }
                    //if (group.inverseStageIndex != StageManager.LastStage)
                    //{
                    //    panel.SetVisible(false);
                    //    continue;
                    //}
                    //else if (panel.Stage.deltaV <= 0)
                    //{
                    //    panel.ToggleNoDVModules(true);
                    //}
                    //else
                    //{
                    //    panel.ToggleNoDVModules(false);
                    //}
                }
                else if (panel.Stage.deltaV <= 0)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (HighLogic.LoadedSceneIsFlight)
                {
                    bool info = false;

                    int checks = 0;

                    for (int j = group.Icons.Count - 1; j >= 0; j--)
                    {
                        if (checks >= 2)
                        {
                            break;
                        }

                        StageIcon icon = group.Icons[j];

                        if (icon.grouped)
                        {
                            if (icon.expanded)
                            {
                                if (checks >= 1)
                                {
                                    if (icon.groupedIcons[icon.groupedIcons.Count - 1].isDisplayingInfo)
                                    {
                                        info = true;
                                        break;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    checks += 2;
                                }
                            }
                            else
                            {
                                checks++;
                            }

                            if (!icon.isDisplayingInfoInGroup)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            checks++;

                            if (!icon.isDisplayingInfo)
                            {
                                continue;
                            }
                        }

                        info = true;
                        break;
                    }

                    if (info)
                    {
                        if (!panel.PanelRight)
                        {
                            panel.MovePanel(true);
                        }
                    }
                    else if (panel.PanelRight)
                    {
                        panel.MovePanel(false);
                    }
                }

                panel.SetVisible(true);
            }
        }