Esempio n. 1
0
        public override void Select(MainForm frm)
        {
            if (frm.grpSite.Text == ToString() && frm.MainTab.SelectedTab == frm.tabSite)
            {
                return;
            }
            Program.MakeSelected(frm.tabSite, frm.lstSite, this);

            frm.grpSite.Text = ToString();
            if (IsPlayerControlled)
            {
                frm.grpSite.Text += @" (PLAYER CONTROLLED)";
            }
#if DEBUG
            frm.grpSite.Text += $" - ID: {Id}";
#endif
            frm.grpSite.Show();

            frm.lblSiteName.Text      = ToString();
            frm.lblSiteAltName.Text   = AltName;
            frm.lblSiteType.Text      = SiteType;
            frm.lblSiteCoord.Data     = new Coordinate(Coords);
            frm.lblSiteOwner.Data     = Owner;
            frm.lblSiteParentCiv.Data = Parent;
            frm.lblSiteCurOwner.Data  = CurOwner;
            frm.lblSiteCiv.Data       = Civ;

            var siteMapPath = World.MapPath.Replace("world_map", "site_map-" + Id);
            frm.SiteMapLabel.Visible = File.Exists(siteMapPath);



            frm.grpSiteCreated.Visible = CreatedEvent != null;
            if (CreatedEvent != null)
            {
                frm.lblSiteCreatedBy.Data    = CreatedEvent.Entity_SiteCiv;
                frm.lblSiteCreatedByCiv.Data = CreatedEvent.Entity;
                frm.lblSiteCreatedTime.Data  = CreatedEvent;
                frm.lblSiteCreatedTime.Text  = CreatedEvent.Time.ToString();
            }

            if (Population != null)
            {
                frm.grpSitePopulation.FillListboxWith(frm.lstSitePopulation, Population.Keys, this);
                frm.grpSitePopulation.Text = $"Population ({Population.Sum(x => x.Value)})";
            }
            else
            {
                frm.grpSitePopulation.Visible = false;
            }
            frm.grpSiteArtifacts.FillListboxWith(frm.lstSiteArtifacts, CreatedArtifacts);
            frm.grpSiteStructures.FillListboxWith(frm.lstSiteStructures, Structures);
            if (Prisoners != null)
            {
                frm.grpSitePrisoners.FillListboxWith(frm.lstSitePrisoners, Prisoners.Keys, this);
                frm.grpSitePrisoners.Text = $"Prisoners ({Prisoners.Sum(x => x.Value)})";
            }
            else
            {
                frm.grpSitePrisoners.Visible = false;
            }
            if (Outcasts != null)
            {
                frm.grpSiteOutcasts.FillListboxWith(frm.lstSiteOutcasts, Outcasts.Keys, this);
                frm.grpSiteOutcasts.Text = $"Outcasts ({Outcasts.Sum(x => x.Value)})";
            }
            else
            {
                frm.grpSiteOutcasts.Visible = false;
            }
            frm.grpSiteInhabitants.FillListboxWith(frm.lstSiteInhabitants, Inhabitants);
            frm.grpSiteEvent.FillListboxWith(frm.lstSiteEvent, Events);


            frm.trvSiteEventCollection.Nodes.Clear();
            if (AbductionEventCollections != null)
            {
                var thisNode = new TreeNode("Abduction");
                foreach (var newNode in AbductionEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (BattleEventCollections != null)
            {
                var thisNode = new TreeNode("Battle");
                foreach (var newNode in BattleEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (BeastAttackEventCollections != null)
            {
                var thisNode = new TreeNode("Beast Attack");
                foreach (var newNode in BeastAttackEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (DuelEventCollections != null)
            {
                var thisNode = new TreeNode("Duel");
                foreach (var newNode in DuelEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (SiteConqueredEventCollections != null)
            {
                var thisNode = new TreeNode("Site Conquered");
                foreach (var newNode in SiteConqueredEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (TheftEventCollections != null)
            {
                var thisNode = new TreeNode("Theft");
                foreach (var newNode in TheftEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (InsurrectionEventCollections != null)
            {
                var thisNode = new TreeNode("Insurrection");
                foreach (var newNode in InsurrectionEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }


            frm.grpSiteEventCollection.Visible = frm.trvSiteEventCollection.Nodes.Count > 0;

            frm.SetDisplayedItem(this);
        }
Esempio n. 2
0
        //public Site(NameValueCollection data, World world)
        //    : base (world)
        //{
        //    Name = data["Name"].ToString();
        //    Type = data["Type"].ToString();
        //    Coords = new Point(
        //                Convert.ToInt32(data["Coords"].ToString().Split(',')[0]),
        //                Convert.ToInt32(data["Coords"].ToString().Split(',')[1]));
        //}

        public override void Select(MainForm frm)
        {
            frm.grpSite.Text = ToString();
            if (isPlayerControlled)
            {
                frm.grpSite.Text += @" (PLAYER CONTROLLED)";
            }
            frm.grpSite.Show();

            frm.lblSiteName.Text      = ToString();
            frm.lblSiteAltName.Text   = AltName;
            frm.lblSiteType.Text      = Types[Type];
            frm.lblSiteCoord.Data     = new Coordinate(Coords);
            frm.lblSiteOwner.Data     = Owner;
            frm.lblSiteParentCiv.Data = Parent;

            frm.grpSiteCreated.Visible = CreatedEvent != null;
            if (CreatedEvent != null)
            {
                frm.lblSiteCreatedBy.Data    = CreatedEvent.SiteCiv;
                frm.lblSiteCreatedByCiv.Data = CreatedEvent.Civ;
                frm.lblSiteCreatedTime.Data  = CreatedEvent;
                frm.lblSiteCreatedTime.Text  = CreatedEvent.Time.ToString();
            }
            frm.lstSitePopulation.Items.Clear();
            if (Population != null)
            {
                frm.lstSitePopulation.Items.AddRange(Population.Keys.ToArray());
            }
            frm.grpSitePopulation.Visible = frm.lstSitePopulation.Items.Count > 0;

            frm.lstSiteArtifacts.Items.Clear();
            if (CreatedArtifacts != null)
            {
                frm.lstSiteArtifacts.Items.AddRange(CreatedArtifacts.ToArray());
            }
            frm.grpSiteArtifacts.Visible = frm.lstSiteArtifacts.Items.Count > 0;


            frm.lstSiteStructures.Items.Clear();
            if (Structures != null)
            {
                frm.lstSiteStructures.Items.AddRange(Structures.ToArray());
            }
            frm.grpSiteStructures.Visible = frm.lstSiteStructures.Items.Count > 0;

            frm.lstSitePrisoners.Items.Clear();
            if (Outcasts != null)
            {
                frm.lstSitePrisoners.Items.AddRange(Prisoners.Keys.ToArray());
            }
            frm.grpSitePrisoners.Visible = frm.lstSitePrisoners.Items.Count > 0;

            frm.lstSiteOutcasts.Items.Clear();
            if (Outcasts != null)
            {
                frm.lstSiteOutcasts.Items.AddRange(Outcasts.Keys.ToArray());
            }
            frm.grpSiteOutcasts.Visible = frm.lstSiteOutcasts.Items.Count > 0;

            frm.lstSiteInhabitants.BeginUpdate();
            frm.lstSiteInhabitants.Items.Clear();
            if (Inhabitants != null)
            {
                frm.lstSiteInhabitants.Items.AddRange(Inhabitants.ToArray());
            }
            frm.lstSiteInhabitants.EndUpdate();
            frm.grpSiteInhabitants.Visible = frm.lstSiteInhabitants.Items.Count > 0;
            frm.grpSiteInhabitants.Text    = string.Format("Historical Figures ({0})", frm.lstSiteInhabitants.Items.Count);

            frm.trvSiteEvent.Nodes.Clear();
            if (AttackedEvents != null)
            {
                var thisNode = new TreeNode("Attacked");
                foreach (var newNode in AttackedEvents.Select(evt => new TreeNode(evt.ToString())
                {
                    Tag = evt
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEvent.Nodes.Add(thisNode);
            }
            if (DestroyedEvents != null)
            {
                var thisNode = new TreeNode("Destroyed");
                foreach (var newNode in DestroyedEvents.Select(evt => new TreeNode(evt.ToString())
                {
                    Tag = evt
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEvent.Nodes.Add(thisNode);
            }
            if (NewLeaderEvents != null)
            {
                var thisNode = new TreeNode("NewLeader");
                foreach (var newNode in NewLeaderEvents.Select(evt => new TreeNode(evt.ToString())
                {
                    Tag = evt
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEvent.Nodes.Add(thisNode);
            }
            if (PlunderedEvents != null)
            {
                var thisNode = new TreeNode("Plundered");
                foreach (var newNode in PlunderedEvents.Select(evt => new TreeNode(evt.ToString())
                {
                    Tag = evt
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEvent.Nodes.Add(thisNode);
            }
            if (ReclaimedEvents != null)
            {
                var thisNode = new TreeNode("Reclaimed");
                foreach (var newNode in ReclaimedEvents.Select(evt => new TreeNode(evt.ToString())
                {
                    Tag = evt
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEvent.Nodes.Add(thisNode);
            }

            frm.grpSiteEvent.Visible = frm.trvSiteEvent.Nodes.Count > 0;

            frm.trvSiteEventCollection.Nodes.Clear();
            if (AbductionEventCollections != null)
            {
                var thisNode = new TreeNode("Abduction");
                foreach (var newNode in AbductionEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (BattleEventCollections != null)
            {
                var thisNode = new TreeNode("Battle");
                foreach (var newNode in BattleEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (BeastAttackEventCollections != null)
            {
                var thisNode = new TreeNode("Beast Attack");
                foreach (var newNode in BeastAttackEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (DuelEventCollections != null)
            {
                var thisNode = new TreeNode("Duel");
                foreach (var newNode in DuelEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (SiteConqueredEventCollections != null)
            {
                var thisNode = new TreeNode("Site Conquered");
                foreach (var newNode in SiteConqueredEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (TheftEventCollections != null)
            {
                var thisNode = new TreeNode("Theft");
                foreach (var newNode in TheftEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (InsurrectionEventCollections != null)
            {
                var thisNode = new TreeNode("Insurrection");
                foreach (var newNode in InsurrectionEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += string.Format(" ({0})", thisNode.Nodes.Count);
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }


            frm.grpSiteEventCollection.Visible = frm.trvSiteEventCollection.Nodes.Count > 0;

            Program.MakeSelected(frm.tabSite, frm.lstSite, this);
        }