Beispiel #1
0
        public GalaxyEditorForm()
        {
            InitializeComponent();

            SuspendLayout();

            m_SectorInfo = new SectorInfo[24, 24];
            m_SectorButton = new SectorButton[24, 24];

            int buttonSize = 28;

            for (int x = 0; x < GalaxyInfo.NumSectorsX; ++x)
            {
                for (int y = 0; y < GalaxyInfo.NumSectorsY; ++y)
                {
                    m_SectorInfo[x, y] = new SectorInfo(x, y);

                    int positionX = propertyGrid.Location.X + propertyGrid.Width + 8 + (x % GalaxyInfo.NumSectorsX) * buttonSize;
                    int positionY = menuStrip1.Height + y * buttonSize;
                    m_SectorButton[x, y] = new SectorButton();
                    m_SectorButton[x, y].Text = "";
                    m_SectorButton[x, y].Location = new System.Drawing.Point(positionX, positionY);
                    m_SectorButton[x, y].Name = String.Format("Sector_{0}_{1}", x, y);
                    m_SectorButton[x, y].Size = new System.Drawing.Size(buttonSize, buttonSize);
                    m_SectorButton[x, y].TabIndex = x + y * GalaxyInfo.NumSectorsX;
                    m_SectorButton[x, y].UseVisualStyleBackColor = true;
                    m_SectorButton[x, y].SectorX = x;
                    m_SectorButton[x, y].SectorY = y;
                    m_SectorButton[x, y].Click += new System.EventHandler(sectorButton_Click);

                    Controls.Add(m_SectorButton[x, y]);
                }
            }

            ResumeLayout(false);
        }
Beispiel #2
0
        private void SetupButton(SectorButton sectorButton, SectorInfo sectorInfo)
        {
            sectorButton.FlatStyle = FlatStyle.Flat;
            sectorButton.FlatAppearance.BorderSize = 1;

            if (sectorInfo.Faction == "Neutral")
            {
                sectorButton.BackColor = Color.Gray;
            }
            else if (sectorInfo.Faction == "Empire")
            {
                sectorButton.BackColor = Color.Blue;
            }
            else if (sectorInfo.Faction == "Marauders")
            {
                sectorButton.BackColor = Color.Red;
            }
            else if (sectorInfo.Faction == "Pirate")
            {
                sectorButton.BackColor = Color.Brown;
            }
            else if (sectorInfo.Faction == "Ascent")
            {
                sectorButton.BackColor = Color.Orange;
            }
            else if (sectorInfo.Faction == "Iriani")
            {
                sectorButton.BackColor = Color.Purple;
            }

            // Show the background ID unless there is a shipyard
            // There are so few shipyards it doesn't obscure visibility a great deal, but there isn't
            // enough space in a button to show both the ID and the S.
            sectorButton.Text = sectorInfo.Shipyard ? "S" : String.Format("{0}", sectorInfo.BackgroundId);
        }
Beispiel #3
0
 private void ReadXmlShipyard(SectorInfo sectorInfo, SectorButton sectorButton, XmlTextReader reader)
 {
     if (reader.Read() && reader.NodeType == XmlNodeType.Text)
     {
         sectorInfo.Shipyard = (reader.Value == "true");
     }
 }
Beispiel #4
0
 private void ReadXmlPersonal(SectorInfo sectorInfo, SectorButton sectorButton, XmlTextReader reader)
 {
     if (reader.Read() && reader.NodeType == XmlNodeType.Text)
     {
         sectorInfo.Personal = (reader.Value == "true");
     }
 }
Beispiel #5
0
 private void ReadXmlName(SectorInfo sectorInfo, SectorButton sectorButton, XmlTextReader reader)
 {
     if (reader.Read() && reader.NodeType == XmlNodeType.Text)
     {
         sectorInfo.Name = reader.Value;
     }
 }
Beispiel #6
0
 private void ReadXmlHyperspaceInhibitor(SectorInfo sectorInfo, SectorButton sectorButton, XmlTextReader reader)
 {
     if (reader.Read() && reader.NodeType == XmlNodeType.Text)
     {
         sectorInfo.HyperspaceInhibitor = (reader.Value == "true");
     }
 }
Beispiel #7
0
 private void ReadXmlBackgroundId(SectorInfo sectorInfo, SectorButton sectorButton, XmlTextReader reader)
 {
     if (reader.Read() && reader.NodeType == XmlNodeType.Text)
     {
         sectorInfo.BackgroundId = Int32.Parse(reader.Value);
     }
 }