Exemplo n.º 1
0
        public selectsys_returnObj selectSystemPromptdlg(Galaxy galaxy)
        {
            SystemObj selectedSystem = null;
            Dictionary<string, SystemObj> systemdict = new Dictionary<string, SystemObj>(galaxy.systems_dictionary());
            galaxy.listupdate_sectors(1);
            List<SystemObj> syslist = new List<SystemObj>(galaxy.systems_list());
            //selectedSystem = syslist[0];
            InitializeComponent();

            dataGridView_systems.DataSource = syslist;

            dataGridView_systems.RowHeadersVisible = false;
            dataGridView_systems.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

            dataGridView_systems.Columns["name"].HeaderText = "Name";
            dataGridView_systems.Columns["name"].DisplayIndex = 0;
            dataGridView_systems.Columns["location"].HeaderText = "Coordinates";
            dataGridView_systems.Columns["location"].DisplayIndex = 1;
            dataGridView_systems.Columns["sector"].HeaderText = "Sector";
            dataGridView_systems.Columns["notes"].HeaderText = "Notes";
            dataGridView_systems.Columns["maploc"].Visible = false;
            dataGridView_systems.Refresh();
            this.ShowDialog();

            //button_ok.Click += (sender, e) => { this.Close(); };
            //string key = dataGridView_systems.SelectedRows[0].Cells[1].Value.ToString();
            int keycolumnindex = dataGridView_systems.Columns["location"].Index;

            int keyrowindex = dataGridView_systems.Rows.IndexOf(dataGridView_systems.SelectedRows[0]);
            DataGridViewCell cell = dataGridView_systems[keycolumnindex, keyrowindex];
            string key = cell.Value.ToString();
            selectedSystem = systemdict[key];
            selectsys_returnObj returnobj = new selectsys_returnObj(selectedSystem, (int)numericUpDown_depth.Value, checkBox_resetloc.Checked);
            return returnobj;
        }
Exemplo n.º 2
0
        bool WHPolarity = false; //false = negitive true = positive

        #endregion Fields

        #region Constructors

        public WormHoleObj(string WHName, bool WHPolarity, SystemObj System, Galaxy galaxy)
        {
            this.WHName = WHName;
            this.WHPolarity = WHPolarity;
            makelink(System);
            //galaxy.add_WH(this);
            System.add_WH(this);
        }
Exemplo n.º 3
0
 public SectorObj(string sectorloc, string SectorName, Galaxy galaxy)
 {
     this.sectorlocS = sectorloc;
     this.SectorName = SectorName;
     galaxy.add_sector(sectorlocS, this);
 }
Exemplo n.º 4
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     string filename = openfilediag(".hzm");
     if (filename != null)
     {
         galaxy = (Galaxy)filehandling.DeserializeObject(filename);
     }
 }
Exemplo n.º 5
0
        public static string readscan(string scanfile, Galaxy galaxy)
        {
            string systemName = null;
            string sectorName = null;
            string systemLoc = null;
            string sectorLoc = null;
            bool readingWH = false;
            int whlinecount = 0;
            int whcount = 0;

            string whname = null;
            bool whpolarity = false;
            string linkstosystemName = null;
            string linktosystemLoc = null;
            string linkstosectorName = null;
            string linktosectorLoc = null;
            //SectorObj sector = new SectorObj(sectorName, galaxy);
            SectorObj sector = null;
            SystemObj sys = null;

            //debugging
            int linecount = 0;
            int sectorscount = 0;
            int systemscount = 0;

            string returnstring = null;

            //using (StreamReader reader = new StreamReader(scanfile))
            //{
                //string line;
                //while ((line = reader.ReadLine()) != null)
            List<string> lines = new List<string>(scanfile.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries));
            foreach (string line in lines)
            {
                linecount++;
                if (!readingWH)
                {
                    if (line.Contains("Wormholes"))
                    {
                        readingWH = true;
                    }

                    else if (line.Contains("Sector ("))
                    {
                        int index = line.IndexOf("(");
                        sectorName = line.Trim();
                        sectorLoc = line.Substring(index).Trim();
                    }
                    else if (line.Contains("System ("))
                    {
                        int index = line.IndexOf("(");
                        systemName = line.Remove(index - 7).Trim();
                        systemLoc = line.Substring(index).Trim();
                    }
                    else if (line.Contains("'") && line.Contains("(")) // Same as above but in case of missing system word. See: http://hazeron.com/phpBB3/viewtopic.php?f=6&t=6568
                    {
                        int index = line.IndexOf("(");
                        systemName = line.Remove(index - 1).Trim();
                        systemLoc = line.Substring(index).Trim();
                    }
                }
                else
                {
                    whlinecount++;
                    if (sector == null)
                    {
                        sector = new SectorObj(sectorLoc, sectorName, galaxy);
                        sectorscount++;
                        sys = new SystemObj(systemLoc, systemName, galaxy.sectors_dictionary[sectorLoc]);
                        systemscount++;
                        returnstring = "Added " + systemName;
                    }
                    if (whlinecount == 1)
                    {
                        whname = line;
                    }
                    else if (line.Contains("Positive Wormhole"))
                    {
                        whpolarity = true;
                    }
                    else if (line.Contains("Negative Wormhole"))
                    {
                        whpolarity = false;
                    }
                    else if (whlinecount == 3)
                    {
                        int index = line.IndexOf("(");
                        linkstosystemName = line.Remove(index).Trim();
                        linktosystemLoc = line.Substring(index).Trim();
                    }
                    else if (whlinecount == 4)
                    {
                        int index = line.IndexOf("(");
                        linkstosectorName = line.Trim();
                        linktosectorLoc = line.Substring(index).Trim();
                    }
                    else if (whlinecount == 5)
                    {
                        WormHoleObj wh = new WormHoleObj(whname, whpolarity, galaxy.sectors_dictionary[sectorLoc].systems_dictionary[sys.location], galaxy);
                        //WormHoleObj wh = new WormHoleObj(whname, whpolarity, sys, galaxy);
                        SectorObj whlinksec = new SectorObj(linktosectorLoc, linkstosectorName, galaxy);
                        sectorscount++;
                        SystemObj whlinksys = new SystemObj(linktosystemLoc, linkstosystemName, galaxy.sectors_dictionary[linktosectorLoc]);
                        systemscount++;
                        wh.makelink(galaxy.sectors_dictionary[linktosectorLoc].systems_dictionary[whlinksys.location]);
                        whlinecount = 0;
                        whcount++;
                    }
                }
                if (line == "Primary")
                {
                    break;
                }
            }
            return returnstring;
        }