예제 #1
0
        private void Button_OnMouseOver(object sender, ButtonEventArgs args)
        {
            ControlPanelButton senderButton = ((ControlPanelButton)sender);

            if (tooltip == null && senderButton.TooltipText != "")
            {
                tooltip            = new Tooltip(this.Game, 2);
                tooltip.StackOrder = 3;
                tooltip.Visible    = true;
                AddChild(tooltip);
            }
            if (senderButton.TooltipText != "")
            {
                tooltip.Text = " " + senderButton.TooltipText;
                if (senderButton.ButtonType == ControlPanelButtonType.Graph ||
                    senderButton.ButtonType == ControlPanelButtonType.Research)
                {
                    tooltip.XRelative = backgroundGraph.XRelative + 5;
                }
                else
                {
                    tooltip.XRelative = senderButton.XRelative;
                }

                tooltip.YRelative = senderButton.YRelative + ((ControlPanelButton)sender).Height + 7;
                tooltip.IsVisible = true;
            }
        }
        public void Refresh(ConstructionType mg)
        {
            Clear();
            selectedMG = mg;
            List <Research> list = GameManager.GetResearchList(mg);

            while (icons.Count > 0)
            {
                RemoveChild(icons[0]);
                icons.RemoveAt(0);
            }

            foreach (Research r in list)
            {
                //int range = ResearchPanel.RightPositioningLimit - ResearchPanel.LeftPositioningLimit;

                ////int travelRange = GameManager.EndTravelYear - GameManager.StartingTravelYear;
                ////float yearRatio = (float)(r.YearAvailable - GameManager.StartingTravelYear) / travelRange;

                //int travelRange = GameManager.EndTravelYear - 1800;
                //float yearRatio = (float)(r.YearAvailable - 1800) / travelRange;

                //float pos = yearRatio * range + LeftPositioningLimit;
                int pos = list.IndexOf(r) * (300 / (list.Count - 1)) + ResearchPanel.LeftPositioningLimit;
                if (r.YearAvailable <= GameManager.CurrentYear)
                {
                    ControlPanelButton icon;
                    if (!r.Completed || (r.Completed && r.YearCompleted > GameManager.CurrentYear))
                    {
                        icon = new ControlPanelButton(this.Game, ControlPanelButtonType.ResearchIcon);
                    }
                    else
                    {
                        icon = new ControlPanelButton(this.Game, ControlPanelButtonType.ResearchOK);
                    }
                    icon.StackOrder    = 3;
                    icon.XRelative     = (int)pos;
                    icon.YRelative     = 206;
                    icon.Data          = r;
                    icon.IsVisible     = this.IsVisible;
                    icon.OnMousePress += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(icon_OnMousePress);
                    AddChild(icon);
                    icons.Add(icon);
                }
                ok.IsVisible = this.IsVisible;
            }
            if (selectedResearch != null && selectedResearch.ResearchType == selectedMG)
            {
                Refresh(selectedResearch);
            }
            else
            {
                if (icons.Count > 0)
                {
                    Refresh((Research)icons[0].Data);
                }
            }
        }
        public ResearchPanel(Game game)
            : base(game)
        {
            selectedResearch = null;
            selectedMG       = ConstructionType.None;

            timeline           = new Sprite(game, GraphicsCollection.GetPack("control-research-timeline"));
            timeline.XRelative = 91;
            timeline.YRelative = 197;
            AddChild(timeline);

            ok           = new ControlPanelButton(game, ControlPanelButtonType.ResearchOK);
            ok.XRelative = 413;
            ok.YRelative = 64;
            ok.IsVisible = false;
            ok.Enabled   = false;
            ok.OnPress  += new EventHandler <ButtonEventArgs>(ok_OnPress);
            AddChild(ok);

            name           = new SpriteText(game, FontsCollection.GetPack("Calibri 11").Font);
            name.Tint      = Color.White;
            name.XRelative = 101;
            name.YRelative = 64;
            AddChild(name);

            description           = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            description.Tint      = Color.White;
            description.XRelative = 101;
            description.YRelative = 82;
            AddChild(description);

            price           = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            price.Tint      = Color.Lime;
            price.XRelative = 101;
            price.YRelative = 178;
            AddChild(price);

            year           = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            year.Tint      = Color.Lime;
            year.XRelative = 347;
            year.YRelative = 178;
            AddChild(year);

            icons = new List <ControlPanelButton>();
        }
예제 #4
0
        public ResearchPanel(Game game)
            : base(game)
        {
            selectedResearch = null;
            selectedMG = ConstructionType.None;

            timeline = new Sprite(game, GraphicsCollection.GetPack("control-research-timeline"));
            timeline.XRelative = 91;
            timeline.YRelative = 197;
            AddChild(timeline);

            ok = new ControlPanelButton(game, ControlPanelButtonType.ResearchOK);
            ok.XRelative = 413;
            ok.YRelative = 64;
            ok.IsVisible = false;
            ok.Enabled = false;
            ok.OnPress += new EventHandler<ButtonEventArgs>(ok_OnPress);
            AddChild(ok);

            name = new SpriteText(game, FontsCollection.GetPack("Calibri 11").Font);
            name.Tint = Color.White;
            name.XRelative = 101;
            name.YRelative = 64;
            AddChild(name);

            description = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            description.Tint = Color.White;
            description.XRelative = 101;
            description.YRelative = 82;
            AddChild(description);

            price = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            price.Tint = Color.Lime;
            price.XRelative = 101;
            price.YRelative = 178;
            AddChild(price);

            year = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            year.Tint = Color.Lime;
            year.XRelative = 347;
            year.YRelative = 178;
            AddChild(year);

            icons = new List<ControlPanelButton>();
        }
        public MissionPanel(Game game)
            : base(game)
        {
            frame = new Sprite(game, GraphicsCollection.GetPack("mission-frame"));
            AddChild(frame);

            close               = new ControlPanelButton(game, ControlPanelButtonType.Close);
            close.StackOrder    = 3;
            close.XRelative     = 428;
            close.YRelative     = 7;
            close.OnMousePress += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(close_OnMousePress);
            AddChild(close);

            text            = new SpriteText(game, FontsCollection.GetPack("Calibri 8").Font);
            text.StackOrder = 3;
            text.MaxLength  = 350;
            text.XRelative  = 30;
            text.YRelative  = 50;
            AddChild(text);
        }
예제 #6
0
        public MissionPanel(Game game)
            : base(game)
        {
            frame = new Sprite(game, GraphicsCollection.GetPack("mission-frame"));
            AddChild(frame);

            close = new ControlPanelButton(game, ControlPanelButtonType.Close);
            close.StackOrder = 3;
            close.XRelative = 428;
            close.YRelative = 7;
            close.OnMousePress+=new EventHandler<Operation_Cronos.Input.MouseEventArgs>(close_OnMousePress);
            AddChild(close);

            text = new SpriteText(game, FontsCollection.GetPack("Calibri 8").Font);
            text.StackOrder = 3;
            text.MaxLength = 350;
            text.XRelative = 30;
            text.YRelative = 50;
            AddChild(text);
        }
        void icon_OnMousePress(object sender, Operation_Cronos.Input.MouseEventArgs e)
        {
            ControlPanelButton icon = (ControlPanelButton)sender;

            Refresh((Research)icon.Data);
        }
예제 #8
0
        public void Refresh(ConstructionType mg)
        {
            Clear();
            selectedMG = mg;
            List<Research> list = GameManager.GetResearchList(mg);
            while (icons.Count > 0)
            {
                RemoveChild(icons[0]);
                icons.RemoveAt(0);
            }

            foreach (Research r in list)
            {
                //int range = ResearchPanel.RightPositioningLimit - ResearchPanel.LeftPositioningLimit;

                ////int travelRange = GameManager.EndTravelYear - GameManager.StartingTravelYear;
                ////float yearRatio = (float)(r.YearAvailable - GameManager.StartingTravelYear) / travelRange;

                //int travelRange = GameManager.EndTravelYear - 1800;
                //float yearRatio = (float)(r.YearAvailable - 1800) / travelRange;

                //float pos = yearRatio * range + LeftPositioningLimit;
                int pos = list.IndexOf(r) * (300 / (list.Count - 1)) + ResearchPanel.LeftPositioningLimit;
                if (r.YearAvailable <= GameManager.CurrentYear)
                {
                    ControlPanelButton icon;
                    if (!r.Completed || (r.Completed && r.YearCompleted > GameManager.CurrentYear))
                        icon = new ControlPanelButton(this.Game, ControlPanelButtonType.ResearchIcon);
                    else
                        icon = new ControlPanelButton(this.Game, ControlPanelButtonType.ResearchOK);
                    icon.StackOrder = 3;
                    icon.XRelative = (int)pos;
                    icon.YRelative = 206;
                    icon.Data = r;
                    icon.IsVisible = this.IsVisible;
                    icon.OnMousePress += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(icon_OnMousePress);
                    AddChild(icon);
                    icons.Add(icon);
                }
                ok.IsVisible = this.IsVisible;
            }
            if (selectedResearch != null && selectedResearch.ResearchType == selectedMG)
            {
                Refresh(selectedResearch);
            }
            else
            {
                if (icons.Count > 0)
                {
                    Refresh((Research)icons[0].Data);
                }
            }
        }
예제 #9
0
        public ControlPanel(Game game)
            : base(game)
        {
            #region Base

            frame = new Sprite(game, GraphicsCollection.GetPack("control-frame"));
            AddChild(frame);

            backgroundResearch            = new Sprite(game, GraphicsCollection.GetPack("control-button-background"));
            backgroundResearch.StackOrder = 1;
            backgroundResearch.XRelative  = 18;
            backgroundResearch.YRelative  = 65;
            AddChild(backgroundResearch);

            backgroundGraph            = new Sprite(game, GraphicsCollection.GetPack("control-button-background"));
            backgroundGraph.StackOrder = 1;
            backgroundGraph.XRelative  = 18;
            backgroundGraph.YRelative  = 135;
            AddChild(backgroundGraph);
            #endregion

            MGButtons = new List <ControlPanelButton>();

            research               = new ControlPanelButton(game, ControlPanelButtonType.Research);
            research.StackOrder    = 3;
            research.XRelative     = 31;
            research.YRelative     = 142;
            research.OnMousePress += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(research_OnMousePress);
            research.OnMouseOver  += new EventHandler <ButtonEventArgs>(Button_OnMouseOver);
            research.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave);
            AddChild(research);

            graph               = new ControlPanelButton(game, ControlPanelButtonType.Graph);
            graph.StackOrder    = 3;
            graph.XRelative     = 24;
            graph.YRelative     = 70;
            graph.OnMousePress += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(research_OnMousePress);
            graph.OnMouseOver  += new EventHandler <ButtonEventArgs>(Button_OnMouseOver);
            graph.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave);
            AddChild(graph);

            close                 = new ControlPanelButton(game, ControlPanelButtonType.Close);
            close.StackOrder      = 3;
            close.XRelative       = 430;
            close.YRelative       = 7;
            close.OnMouseRelease += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(close_OnMousePress);
            AddChild(close);

            #region MGs
            economy               = new ControlPanelButton(game, ControlPanelButtonType.Economy);
            economy.XRelative     = 139;
            economy.YRelative     = 15;
            economy.StackOrder    = 3;
            economy.OnMouseOver  += new EventHandler <ButtonEventArgs>(Button_OnMouseOver);
            economy.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave);
            AddChild(economy);
            MGButtons.Add(economy);

            health               = new ControlPanelButton(game, ControlPanelButtonType.Health);
            health.XRelative     = 185;
            health.YRelative     = 15;
            health.StackOrder    = 3;
            health.OnMouseOver  += new EventHandler <ButtonEventArgs>(Button_OnMouseOver);
            health.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave);
            AddChild(health);
            MGButtons.Add(health);

            education               = new ControlPanelButton(game, ControlPanelButtonType.Education);
            education.XRelative     = 231;
            education.YRelative     = 15;
            education.StackOrder    = 3;
            education.OnMouseOver  += new EventHandler <ButtonEventArgs>(Button_OnMouseOver);
            education.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave);
            AddChild(education);
            MGButtons.Add(education);

            energy               = new ControlPanelButton(game, ControlPanelButtonType.Energy);
            energy.XRelative     = 278;
            energy.YRelative     = 15;
            energy.StackOrder    = 3;
            energy.OnMouseOver  += new EventHandler <ButtonEventArgs>(Button_OnMouseOver);
            energy.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave);
            AddChild(energy);
            MGButtons.Add(energy);

            food               = new ControlPanelButton(game, ControlPanelButtonType.Food);
            food.XRelative     = 324;
            food.YRelative     = 15;
            food.StackOrder    = 3;
            food.OnMouseOver  += new EventHandler <ButtonEventArgs>(Button_OnMouseOver);
            food.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave);
            AddChild(food);
            MGButtons.Add(food);

            environment               = new ControlPanelButton(game, ControlPanelButtonType.Environment);
            environment.XRelative     = 370;
            environment.YRelative     = 15;
            environment.StackOrder    = 3;
            environment.OnMouseOver  += new EventHandler <ButtonEventArgs>(Button_OnMouseOver);
            environment.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave);
            AddChild(environment);
            MGButtons.Add(environment);

            economy.OnMousePress     += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(mgButton_OnMousePress);
            education.OnMousePress   += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(mgButton_OnMousePress);
            energy.OnMousePress      += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(mgButton_OnMousePress);
            environment.OnMousePress += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(mgButton_OnMousePress);
            food.OnMousePress        += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(mgButton_OnMousePress);
            health.OnMousePress      += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(mgButton_OnMousePress);
            #endregion

            researchPanel            = new ResearchPanel(game);
            researchPanel.StackOrder = 1;
            researchPanel.XRelative  = 0;
            AddChild(researchPanel);

            graphPanel            = new GraphPanel(game);
            graphPanel.StackOrder = 1;
            AddChild(graphPanel);

            HideAll();
        }