예제 #1
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            checkIfChanged();

            SectorTab.Text = e.Node.Text;
            String selName = e.Node.Text.ToString();

            pCanvas1.Dispose();

            this.pCanvas1 = new UMD.HCIL.Piccolo.PCanvas();
            this.SectorTab.Controls.Add(this.pCanvas1);
            this.pCanvas1.AllowDrop        = true;
            this.pCanvas1.BackColor        = System.Drawing.Color.White;
            this.pCanvas1.Dock             = System.Windows.Forms.DockStyle.Fill;
            this.pCanvas1.GridFitText      = false;
            this.pCanvas1.Location         = new System.Drawing.Point(0, 0);
            this.pCanvas1.Name             = "pCanvas1";
            this.pCanvas1.RegionManagement = true;
            this.pCanvas1.Size             = new System.Drawing.Size(554, 438);
            this.pCanvas1.TabIndex         = 0;
            this.pCanvas1.Text             = "pCanvas1";

            if (e.Node.Level == 0)
            {
                if (e.Node.Nodes.Count > 0)
                {
                    DataRow[] systemRow = systems.findRowsByName(selName);
                    String    systemID  = systemRow[0]["system_id"].ToString();
                    selectedSystemRow = systemRow[0];

                    //Populate Properties
                    SystemProps sp = new SystemProps();
                    sp.Name = selName;

                    int   R     = int.Parse(systemRow[0]["color_r"].ToString());
                    int   G     = int.Parse(systemRow[0]["color_g"].ToString());
                    int   B     = int.Parse(systemRow[0]["color_b"].ToString());
                    Color color = Color.FromArgb(R, G, B);
                    sp.Color = color;

                    sp.GalaxyX = float.Parse(systemRow[0]["galaxy_x"].ToString());
                    sp.GalaxyY = float.Parse(systemRow[0]["galaxy_y"].ToString());
                    sp.GalaxyZ = float.Parse(systemRow[0]["galaxy_z"].ToString());
                    sp.Notes   = systemRow[0]["notes"].ToString();

                    DataRow[] sectorTable = sectors.getRowsBySystemID(systemID);

                    createPropertyGrid();
                    propertyGrid1.SelectedObject = sp;

                    systemWindow = new SystemWindow(pCanvas1, selName, sectorTable, propertyGrid1, selectedSystemRow);
                    propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(systemWindow.pg_PropertyValueChanged);
                }
                else
                {
                    MessageBox.Show("Sorry, There are no sector's to display in the selected system! \n Please add a new sector to it, or select another system.");
                }
            }
            else if (e.Node.Level == 1)
            {
                DataRow[] sectorRow = sectors.findRowsByName(selName);
                sectorID = int.Parse(sectorRow[0]["sector_id"].ToString());
                createPropertyGrid();
                sectorWindow = new SectorWindow(pCanvas1, sectorRow, propertyGrid1, dataGridView1);
                createOptions(sectorWindow);
                sectorObjects = sectorWindow.getSectorObjectsSQL();
                propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(sectorWindow.PropertyGrid1_PropertyValueChanged);

                dataGridView1.Rows.Clear();
                DataTable secObjects = sectorObjects.getSectorObject();
                object[]  dataSource = new object[4];
                foreach (DataRow dr in secObjects.Rows)
                {
                    int    id   = int.Parse(dr["sector_object_id"].ToString());
                    String name = dr["name"].ToString();
                    int    baID = int.Parse(dr["base_asset_id"].ToString());
                    int    type = int.Parse(dr["type"].ToString());

                    dataSource[0] = id;
                    dataSource[1] = name;
                    dataSource[2] = baID;
                    dataSource[3] = type;

                    dataGridView1.Rows.Add(dataSource);
                }
            }
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (lastInsertID == 0)
            {
                DataTable tmp = sectorObjectsSQL.getSectorObject();
                newSectorObjectsRow = tmp.NewRow();

                QuaternionCalc qtmp = new QuaternionCalc();
                double[]       q1   = null;

                switch (type2)
                {
                case 0:
                    newSectorObjectsRow["sector_id"]         = mp.SectorID;
                    newSectorObjectsRow["nav_type"]          = mp.NavType;
                    newSectorObjectsRow["signature"]         = mp.Signature;
                    newSectorObjectsRow["is_huge"]           = mp.IsHuge;
                    newSectorObjectsRow["base_xp"]           = mp.BaseXP;
                    newSectorObjectsRow["exploration_range"] = mp.ExplorationRange;
                    newSectorObjectsRow["base_asset_id"]     = mp.BaseAssetID;
                    newSectorObjectsRow["h"]          = mp.Color.GetHue();
                    newSectorObjectsRow["s"]          = mp.Color.GetSaturation();
                    newSectorObjectsRow["v"]          = mp.Color.GetBrightness();
                    newSectorObjectsRow["type"]       = 0;
                    newSectorObjectsRow["scale"]      = mp.Scale;
                    newSectorObjectsRow["position_x"] = mp.PositionX;
                    newSectorObjectsRow["position_y"] = mp.PositionY;
                    newSectorObjectsRow["position_z"] = mp.PositionZ;

                    q1 = qtmp.AngleToQuat(mp.Orientation_Yaw, mp.Orientation_Pitch, mp.Orientation_Roll);

                    newSectorObjectsRow["orientation_z"] = q1[0];
                    newSectorObjectsRow["orientation_u"] = q1[1];
                    newSectorObjectsRow["orientation_v"] = q1[2];
                    newSectorObjectsRow["orientation_w"] = q1[3];

                    newSectorObjectsRow["name"]               = mp.Name.Replace("'", "''");
                    newSectorObjectsRow["appears_in_radar"]   = mp.AppearsInRadar;
                    newSectorObjectsRow["radar_range"]        = mp.RadarRange;
                    newSectorObjectsRow["gate_to"]            = mp.Destination;
                    newSectorObjectsRow["sound_effect_id"]    = mp.SoundEffect;
                    newSectorObjectsRow["sound_effect_range"] = mp.SoundEffectRange;

                    newSectorObjectsRow["mob_spawn_radius"] = mp.SpawnRadius;
                    newSectorObjectsRow["mob_count"]        = mp.Count;

                    newSectorObjectsRow["respawn_time"]  = mp.RespawnTime;
                    newSectorObjectsRow["delayed_spawn"] = mp.DelayedSpawn;
                    break;

                case 3:
                    newSectorObjectsRow["sector_id"]         = pp.SectorID;
                    newSectorObjectsRow["nav_type"]          = pp.NavType;
                    newSectorObjectsRow["signature"]         = pp.Signature;
                    newSectorObjectsRow["is_huge"]           = pp.IsHuge;
                    newSectorObjectsRow["base_xp"]           = pp.BaseXP;
                    newSectorObjectsRow["exploration_range"] = pp.ExplorationRange;
                    newSectorObjectsRow["base_asset_id"]     = pp.BaseAssetID;
                    newSectorObjectsRow["h"]          = pp.Color.GetHue();
                    newSectorObjectsRow["s"]          = pp.Color.GetSaturation();
                    newSectorObjectsRow["v"]          = pp.Color.GetBrightness();
                    newSectorObjectsRow["type"]       = 3;
                    newSectorObjectsRow["scale"]      = pp.Scale;
                    newSectorObjectsRow["position_x"] = pp.PositionX;
                    newSectorObjectsRow["position_y"] = pp.PositionY;
                    newSectorObjectsRow["position_z"] = pp.PositionZ;

                    q1 = qtmp.AngleToQuat(pp.Orientation_Yaw, pp.Orientation_Pitch, pp.Orientation_Roll);

                    newSectorObjectsRow["orientation_z"] = q1[0];
                    newSectorObjectsRow["orientation_u"] = q1[1];
                    newSectorObjectsRow["orientation_v"] = q1[2];
                    newSectorObjectsRow["orientation_w"] = q1[3];

                    newSectorObjectsRow["name"]               = pp.Name.Replace("'", "''");
                    newSectorObjectsRow["appears_in_radar"]   = pp.AppearsInRadar;
                    newSectorObjectsRow["radar_range"]        = pp.RadarRange;
                    newSectorObjectsRow["gate_to"]            = pp.Destination;
                    newSectorObjectsRow["sound_effect_id"]    = pp.SoundEffect;
                    newSectorObjectsRow["sound_effect_range"] = pp.SoundEffectRange;

                    newSectorObjectsRow["orbit_id"]     = pp.OrbitID;
                    newSectorObjectsRow["orbit_dist"]   = pp.OrbitDist;
                    newSectorObjectsRow["orbit_angle"]  = pp.OrbitAngle;
                    newSectorObjectsRow["orbit_rate"]   = pp.OrbitRate;
                    newSectorObjectsRow["rotate_rate"]  = pp.RotateRate;
                    newSectorObjectsRow["rotate_angle"] = pp.RotateAngle;
                    newSectorObjectsRow["tilt_angle"]   = pp.TiltAngle;
                    newSectorObjectsRow["is_landable"]  = pp.IsLandable;
                    break;

                case 11:
                    newSectorObjectsRow["sector_id"]         = sgp.SectorID;
                    newSectorObjectsRow["nav_type"]          = sgp.NavType;
                    newSectorObjectsRow["signature"]         = sgp.Signature;
                    newSectorObjectsRow["is_huge"]           = sgp.IsHuge;
                    newSectorObjectsRow["base_xp"]           = sgp.BaseXP;
                    newSectorObjectsRow["exploration_range"] = sgp.ExplorationRange;
                    newSectorObjectsRow["base_asset_id"]     = sgp.BaseAssetID;
                    newSectorObjectsRow["h"]          = sgp.Color.GetHue();
                    newSectorObjectsRow["s"]          = sgp.Color.GetSaturation();
                    newSectorObjectsRow["v"]          = sgp.Color.GetBrightness();
                    newSectorObjectsRow["type"]       = 11;
                    newSectorObjectsRow["scale"]      = sgp.Scale;
                    newSectorObjectsRow["position_x"] = sgp.PositionX;
                    newSectorObjectsRow["position_y"] = sgp.PositionY;
                    newSectorObjectsRow["position_z"] = sgp.PositionZ;

                    q1 = qtmp.AngleToQuat(sgp.Orientation_Yaw, sgp.Orientation_Pitch, sgp.Orientation_Roll);

                    newSectorObjectsRow["orientation_z"] = q1[0];
                    newSectorObjectsRow["orientation_u"] = q1[1];
                    newSectorObjectsRow["orientation_v"] = q1[2];
                    newSectorObjectsRow["orientation_w"] = q1[3];

                    newSectorObjectsRow["name"]               = sgp.Name.Replace("'", "''");
                    newSectorObjectsRow["appears_in_radar"]   = sgp.AppearsInRadar;
                    newSectorObjectsRow["radar_range"]        = sgp.RadarRange;
                    newSectorObjectsRow["gate_to"]            = sgp.Destination;
                    newSectorObjectsRow["classSpecific"]      = sgp.IsClassSpecific;
                    newSectorObjectsRow["sound_effect_id"]    = sgp.SoundEffect;
                    newSectorObjectsRow["sound_effect_range"] = sgp.SoundEffectRange;

                    int factionID = mainFrm.factions.findIDbyName(sgp.FactionID);
                    newSectorObjectsRow["faction_id"] = factionID;
                    break;

                case 12:
                    newSectorObjectsRow["sector_id"]         = sbp.SectorID;
                    newSectorObjectsRow["nav_type"]          = sbp.NavType;
                    newSectorObjectsRow["signature"]         = sbp.Signature;
                    newSectorObjectsRow["is_huge"]           = sbp.IsHuge;
                    newSectorObjectsRow["base_xp"]           = sbp.BaseXP;
                    newSectorObjectsRow["exploration_range"] = sbp.ExplorationRange;
                    newSectorObjectsRow["base_asset_id"]     = sbp.BaseAssetID;
                    newSectorObjectsRow["h"]          = sbp.Color.GetHue();
                    newSectorObjectsRow["s"]          = sbp.Color.GetSaturation();
                    newSectorObjectsRow["v"]          = sbp.Color.GetBrightness();
                    newSectorObjectsRow["type"]       = 12;
                    newSectorObjectsRow["scale"]      = sbp.Scale;
                    newSectorObjectsRow["position_x"] = sbp.PositionX;
                    newSectorObjectsRow["position_y"] = sbp.PositionY;
                    newSectorObjectsRow["position_z"] = sbp.PositionZ;

                    q1 = qtmp.AngleToQuat(sbp.Orientation_Yaw, sbp.Orientation_Pitch, sbp.Orientation_Roll);

                    newSectorObjectsRow["orientation_z"] = q1[0];
                    newSectorObjectsRow["orientation_u"] = q1[1];
                    newSectorObjectsRow["orientation_v"] = q1[2];
                    newSectorObjectsRow["orientation_w"] = q1[3];

                    newSectorObjectsRow["name"]               = sbp.Name.Replace("'", "''");
                    newSectorObjectsRow["appears_in_radar"]   = sbp.AppearsInRadar;
                    newSectorObjectsRow["radar_range"]        = sbp.RadarRange;
                    newSectorObjectsRow["gate_to"]            = sbp.Destination;
                    newSectorObjectsRow["sound_effect_id"]    = sbp.SoundEffect;
                    newSectorObjectsRow["sound_effect_range"] = sbp.SoundEffectRange;

                    newSectorObjectsRow["capShip"]  = sbp.IsCapShip;
                    newSectorObjectsRow["dockable"] = sbp.IsDockable;
                    break;

                case 37:
                    newSectorObjectsRow["sector_id"]         = bp.SectorID;
                    newSectorObjectsRow["nav_type"]          = bp.NavType;
                    newSectorObjectsRow["signature"]         = bp.Signature;
                    newSectorObjectsRow["is_huge"]           = bp.IsHuge;
                    newSectorObjectsRow["base_xp"]           = bp.BaseXP;
                    newSectorObjectsRow["exploration_range"] = bp.ExplorationRange;
                    newSectorObjectsRow["base_asset_id"]     = bp.BaseAssetID;
                    newSectorObjectsRow["h"]          = bp.Color.GetHue();
                    newSectorObjectsRow["s"]          = bp.Color.GetSaturation();
                    newSectorObjectsRow["v"]          = bp.Color.GetBrightness();
                    newSectorObjectsRow["type"]       = 37;
                    newSectorObjectsRow["scale"]      = bp.Scale;
                    newSectorObjectsRow["position_x"] = bp.PositionX;
                    newSectorObjectsRow["position_y"] = bp.PositionY;
                    newSectorObjectsRow["position_z"] = bp.PositionZ;

                    q1 = qtmp.AngleToQuat(bp.Orientation_Yaw, bp.Orientation_Pitch, bp.Orientation_Roll);

                    newSectorObjectsRow["orientation_z"] = q1[0];
                    newSectorObjectsRow["orientation_u"] = q1[1];
                    newSectorObjectsRow["orientation_v"] = q1[2];
                    newSectorObjectsRow["orientation_w"] = q1[3];

                    newSectorObjectsRow["name"]               = bp.Name.Replace("'", "''");
                    newSectorObjectsRow["appears_in_radar"]   = bp.AppearsInRadar;
                    newSectorObjectsRow["radar_range"]        = bp.RadarRange;
                    newSectorObjectsRow["gate_to"]            = bp.Destination;
                    newSectorObjectsRow["sound_effect_id"]    = bp.SoundEffect;
                    newSectorObjectsRow["sound_effect_range"] = bp.SoundEffectRange;
                    break;

                case 38:
                    newSectorObjectsRow["sector_id"]         = hp.SectorID;
                    newSectorObjectsRow["nav_type"]          = hp.NavType;
                    newSectorObjectsRow["signature"]         = hp.Signature;
                    newSectorObjectsRow["is_huge"]           = hp.IsHuge;
                    newSectorObjectsRow["base_xp"]           = hp.BaseXP;
                    newSectorObjectsRow["exploration_range"] = hp.ExplorationRange;
                    newSectorObjectsRow["base_asset_id"]     = hp.BaseAssetID;
                    newSectorObjectsRow["h"]          = hp.Color.GetHue();
                    newSectorObjectsRow["s"]          = hp.Color.GetSaturation();
                    newSectorObjectsRow["v"]          = hp.Color.GetBrightness();
                    newSectorObjectsRow["type"]       = 38;
                    newSectorObjectsRow["scale"]      = hp.Scale;
                    newSectorObjectsRow["position_x"] = hp.PositionX;
                    newSectorObjectsRow["position_y"] = hp.PositionY;
                    newSectorObjectsRow["position_z"] = hp.PositionZ;

                    q1 = qtmp.AngleToQuat(hp.Orientation_Yaw, hp.Orientation_Pitch, hp.Orientation_Roll);

                    newSectorObjectsRow["orientation_z"] = q1[0];
                    newSectorObjectsRow["orientation_u"] = q1[1];
                    newSectorObjectsRow["orientation_v"] = q1[2];
                    newSectorObjectsRow["orientation_w"] = q1[3];

                    newSectorObjectsRow["name"]               = hp.Name.Replace("'", "''");
                    newSectorObjectsRow["appears_in_radar"]   = hp.AppearsInRadar;
                    newSectorObjectsRow["radar_range"]        = hp.RadarRange;
                    newSectorObjectsRow["gate_to"]            = hp.Destination;
                    newSectorObjectsRow["sound_effect_id"]    = hp.SoundEffect;
                    newSectorObjectsRow["sound_effect_range"] = hp.SoundEffectRange;

                    newSectorObjectsRow["level"]            = hp.Level;
                    newSectorObjectsRow["res_count"]        = hp.ResCount;
                    newSectorObjectsRow["spawn_radius"]     = hp.MobSpawnRadius;
                    newSectorObjectsRow["pop_rock_chance"]  = hp.PopRockChance;
                    newSectorObjectsRow["max_field_radius"] = hp.MaxFieldRadius;

                    if (hp.Field == "Random")
                    {
                        newSectorObjectsRow["field"] = 0;
                    }
                    else if (hp.Field == "Ring")
                    {
                        newSectorObjectsRow["field"] = 1;
                    }
                    else if (hp.Field == "Donut")
                    {
                        newSectorObjectsRow["field"] = 2;
                    }
                    else if (hp.Field == "Cylinder")
                    {
                        newSectorObjectsRow["field"] = 3;
                    }
                    else if (hp.Field == "Sphere")
                    {
                        newSectorObjectsRow["field"] = 4;
                    }
                    else if (hp.Field == "Gas Cloud Clump")
                    {
                        newSectorObjectsRow["field"] = 5;
                    }
                    break;
                }

                //Check if their is a sound_effect and set its default range if it has not been set.
                int id = int.Parse(newSectorObjectsRow["sound_effect_id"].ToString());
                Console.Out.WriteLine(id);
                float range = int.Parse(newSectorObjectsRow["sound_effect_range"].ToString());
                if (id != -1)
                {
                    if (range == 0)
                    {
                        newSectorObjectsRow["sound_effect_range"] = 30000;
                    }
                }

                //Add To dataTable
                tmp.Rows.Add(newSectorObjectsRow);;

                //Add to Database
                sectorObjectsSQL.newRow(newSectorObjectsRow);

                switch (type2)
                {
                case 0:
                    Boolean b1 = validateMobs(0);
                    if (b1 == true)
                    {
                        //Add to Graphic window
                        mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow);
                        this.Close();
                    }
                    break;

                case 3:
                    mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow);
                    this.Close();
                    break;

                case 11:
                    mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow);
                    this.Close();
                    break;

                case 12:
                    mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow);
                    this.Close();
                    break;

                case 37:
                    mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow);
                    this.Close();
                    break;

                case 38:
                    Boolean b2 = validateHarvestables(0);
                    if (b2 == true)
                    {
                        //Add to Graphic window
                        mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow);
                        this.Close();
                    }
                    break;
                }
            }
            else
            {
                if (type2 == 0)
                {
                    Boolean b1 = validateMobs(lastInsertID);
                    if (b1 == true)
                    {
                        //Add to Graphic window
                        mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow);
                        this.Close();
                    }
                }
                else if (type2 == 38)
                {
                    Boolean b2 = validateHarvestables(lastInsertID);
                    if (b2 == true)
                    {
                        //Add to Graphic window
                        mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow);
                        this.Close();
                    }
                }
            }
        }