예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ColorSliderVertical"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public ColorSliderVertical(string name) : base(name)
        {
            // Initialize Colors
            this.hsl = new HSL {
                H = 1.0, S = 1.0, L = 1.0
            };
            this.rgba = AdobeColors.HSLToRGB(this.hsl);

            // pick a format to show
            this.drawStyle = DrawStyle.Hue;

            this.Padding = 9;

            Config.Width  = Theme.ControlHeight;
            Config.Height = Theme.ControlWidth;
        }
예제 #2
0
        /// <summary>
        /// Takes the value that came from the relative position of the mouse , to update color.
        /// </summary>
        /// <param name="newValue">The new value.</param>
        private void TakeValue(DVector2 newValue)
        {
            switch (this.drawStyle)
            {
            case DrawStyle.Hue:
                HSL.S     = newValue.X;
                HSL.L     = 1 - newValue.Y;
                this.RGBA = AdobeColors.HSLToRGB(HSL);
                break;

            case DrawStyle.Saturation:
                HSL.H     = newValue.X;
                HSL.L     = 1 - newValue.Y;
                this.RGBA = AdobeColors.HSLToRGB(HSL);
                break;

            case DrawStyle.Brightness:
                HSL.H     = newValue.X;
                HSL.S     = 1 - newValue.Y;
                this.RGBA = AdobeColors.HSLToRGB(HSL);
                break;

            case DrawStyle.Red:
                this.RGBA.UpdateG((byte)(1 - newValue.Y));
                this.RGBA.UpdateB((byte)newValue.X);
                HSL = AdobeColors.RGBToHSL(this.RGBA);
                break;

            case DrawStyle.Green:
                this.RGBA.UpdateB((byte)newValue.X);
                this.RGBA.UpdateR((byte)(1 - newValue.Y));
                HSL = AdobeColors.RGBToHSL(this.RGBA);
                break;

            case DrawStyle.Blue:
                this.RGBA.UpdateR((byte)newValue.X);
                this.RGBA.UpdateG((byte)(1 - newValue.Y));
                HSL = AdobeColors.RGBToHSL(this.RGBA);
                break;
            }
        }
예제 #3
0
        /// <summary>
        /// Called when graphics resources need to be loaded.
        ///
        /// Use this for the usage of :
        /// - creation of the internal embedded controls.
        /// - setting of the variables and resources in this control
        /// - to load any game-specific graphics resources
        /// - take over the config width and height and use it into State
        /// - overriding how this item looks like , by settings its texture or theme
        ///
        /// Call base.LoadContent before you do your override code, this will cause :
        /// - State.SourceRectangle to be reset to the Config.Size
        /// </summary>
        public override void LoadContent()
        {
            if (this.hsl == null)
            {
                this.hsl = new HSL {
                    H = 1.0, S = 1.0, L = 1.0
                };
                this.rgba = AdobeColors.HSLToRGB(this.hsl);
            }

            Config.Width  = Theme.ControlHeight;
            Config.Height = Theme.ControlWidth;

            // create left indicator
            this.IndicatorLeft = new ColorSliderVerticalIndicator(Name + "-indicatorLeft")
            {
                Side    = Side.Left,
                Manager = Manager
            };
            this.AddControl(this.IndicatorLeft);

            // create right indicator
            this.IndicatorRight = new ColorSliderVerticalIndicator(Name + "-indicatorRight")
            {
                Side    = Side.Right,
                Manager = Manager
            };
            this.AddControl(this.IndicatorRight);

            this.SetIndicatorPosition(0);

            this.RedrawControl();

            // do the basic stuff
            base.LoadContent();
            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
        }
예제 #4
0
        /// <summary>Fills in the content of the control showing all values of Luminance (0 to 100%) for the given
        /// Hue and Saturation.</summary>
        /// <param name="map">The map to update.</param>
        private void DrawStyleLuminance(ref ColorMap map)
        {
            // Use the H and S values of the current color (m_hsl)
            var colorToConvert = new HSL
            {
                H = this.hsl.H,
                S = this.hsl.S
            };

            // i represents the current line of pixels we want to draw horizontally
            for (var i = 0; i < map.Height; i++)
            {
                // L (Luminance) is based on the current vertical position
                colorToConvert.L = 1.0 - ((double)i / map.Height);

                // Get the Color for this line
                var rgb = AdobeColors.HSLToRGB(colorToConvert);
                for (var l = 0; l < map.Width; l++)
                {
                    map.Set(l, i, rgb);
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Fills in the content of the control showing all values of Hue (from 0 to 360) , a rainbow
        /// </summary>
        /// <param name="map">The map to update.</param>
        private static void DrawStyleHue(ref ColorMap map)
        {
            // S and L will both be at 100% for this DrawStyle
            var hsl = new HSL
            {
                S = 1.0,
                L = 1.0
            };

            // i represents the current line of pixels we want to draw horizontally
            for (var i = 0; i < map.Height; i++)
            {
                // H (hue) is based on the current vertical position
                hsl.H = 1.0 - ((double)i / map.Height);

                // Get the Color for this line
                var rgb = AdobeColors.HSLToRGB(hsl);
                for (var l = 0; l < map.Width; l++)
                {
                    map.Set(l, i, rgb);
                }
            }
        }
        public void updateChangedInfo(String propertyName, Object _changedValue)
        {
            String changedValue = _changedValue.ToString();

            //Update DataRow and Graphics (only certain props require graphical updating).
            if (propertyName == "SectorID")
            {
                dr["sector_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "NavType")
            {
                dr["nav_type"] = changedValue;
            }
            else if (propertyName == "Signature")
            {
                dr["signature"] = float.Parse(changedValue);

                float imageWidth  = stargateImage.Width;
                float imageHeight = stargateImage.Height;
                float x           = stargateImage.X;
                float y           = stargateImage.Y;
                stargateImage.GetChild(0).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(0).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(0).Width  = (float.Parse(changedValue) * 2) / 100;
                stargateImage.GetChild(0).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "IsHuge")
            {
                dr["is_huge"] = bool.Parse(changedValue);
            }
            else if (propertyName == "BaseXP")
            {
                dr["base_xp"] = int.Parse(changedValue);
            }
            else if (propertyName == "ExplorationRange")
            {
                dr["exploration_range"] = float.Parse(changedValue);

                float imageWidth  = stargateImage.Width;
                float imageHeight = stargateImage.Height;
                float x           = stargateImage.X;
                float y           = stargateImage.Y;
                stargateImage.GetChild(2).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(2).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(2).Width  = (float.Parse(changedValue) * 2) / 100;
                stargateImage.GetChild(2).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "BaseAssetID")
            {
                dr["base_asset_id"] = int.Parse(changedValue);
                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["base_asset_id"].Value = int.Parse(changedValue);
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "Color")
            {
                Color           color = (Color)_changedValue;
                AdobeColors.HSL hsv   = AdobeColors.RGB_to_HSL(color);

                dr["h"] = hsv.H;
                dr["s"] = hsv.S;
                dr["v"] = hsv.L;
            }
            else if (propertyName == "Type")
            {
                _layer.RemoveChild(stargateImage);

                /*
                 * if (changedValue == "Mobs")
                 * {
                 *  dr["type"] = 0;
                 *  new MobSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Planets")
                 * {
                 *  dr["type"] = 3;
                 *  new PlanetSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Starbases")
                 * {
                 *  dr["type"] = 12;
                 *  new StarbaseSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Decorations")
                 * {
                 *  dr["type"] = 37;
                 *  new DecorationSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Harvestables")
                 * {
                 *  dr["type"] = 38;
                 *  new HarvestableSprite(_layer, dr, _pg);
                 * }*/

                _pg.SelectedObject = null;
            }
            else if (propertyName == "Scale")
            {
                dr["scale"] = float.Parse(changedValue);
            }
            else if (propertyName == "PositionX")
            {
                dr["position_x"] = float.Parse(changedValue);

                float dx = (float.Parse(changedValue) / 100) - stargateImage.X;
                stargateImage.TranslateBy(dx, 0);
            }
            else if (propertyName == "PositionY")
            {
                dr["position_y"] = float.Parse(changedValue);

                float dy = (float.Parse(changedValue) / 100) - stargateImage.Y;
                stargateImage.TranslateBy(0, dy);
            }
            else if (propertyName == "PositionZ")
            {
                dr["position_z"] = float.Parse(changedValue);
            }
            else if (propertyName == "Orientation_Yaw" || propertyName == "Orientation_Pitch" || propertyName == "Orientation_Roll")
            {
                QuaternionCalc qtmp = new QuaternionCalc();
                double[]       q1   = qtmp.AngleToQuat(dp.Orientation_Yaw, dp.Orientation_Pitch, dp.Orientation_Roll);

                dr["orientation_z"] = q1[0];
                dr["orientation_u"] = q1[1];
                dr["orientation_v"] = q1[2];
                dr["orientation_w"] = q1[3];
            }
            else if (propertyName == "Name")
            {
                dr["name"] = changedValue;

                float x    = stargateImage.X;
                float y    = stargateImage.Y;
                PText name = (PText)stargateImage.GetChild(3);
                name.Text          = changedValue;
                name.TextAlignment = StringAlignment.Center;
                name.X             = x - (name.Width / 2);
                name.Y             = y - 20;

                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["name"].Value = changedValue;
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "AppearsInRadar")
            {
                dr["appears_in_radar"] = bool.Parse(changedValue);

                if (bool.Parse(changedValue) == true)
                {
                    changeImage(1);
                }
                else
                {
                    changeImage(0);
                }
            }
            else if (propertyName == "RadarRange")
            {
                dr["radar_range"] = float.Parse(changedValue);

                float imageWidth  = stargateImage.Width;
                float imageHeight = stargateImage.Height;
                float x           = stargateImage.X;
                float y           = stargateImage.Y;
                stargateImage.GetChild(1).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(1).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(1).Width  = (float.Parse(changedValue) * 2) / 100;
                stargateImage.GetChild(1).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "Destination")
            {
                dr["gate_to"] = int.Parse(changedValue);
            }
            else if (propertyName == "IsClassSpecific")
            {
                dr["classSpecific"] = bool.Parse(changedValue);

                if (bool.Parse(changedValue) == true)
                {
                    changeImage(2);
                }
                else
                {
                    if (bool.Parse(dr["appears_in_radar"].ToString()) == true)
                    {
                        changeImage(1);
                    }
                    else
                    {
                        changeImage(0);
                    }

                    if (int.Parse(dr["faction_id"].ToString()) > 0)
                    {
                        changeImage(3);
                    }
                }
            }
            else if (propertyName == "FactionID")
            {
                //get id from name;
                int id = mainFrm.factions.findIDbyName(changedValue);

                dr["faction_id"] = id;

                if (id > 0)
                {
                    Console.Out.WriteLine("test2");
                    changeImage(3);
                }
                else
                {
                    if (bool.Parse(dr["appears_in_radar"].ToString()) == true)
                    {
                        changeImage(1);
                    }
                    else
                    {
                        changeImage(0);
                    }

                    if (bool.Parse(dr["classSpecific"].ToString()) == true)
                    {
                        changeImage(2);
                    }
                }
            }
            else if (propertyName == "SoundEffect")
            {
                dr["sound_effect_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "SoundEffectRange")
            {
                dr["sound_effect_range"] = float.Parse(changedValue);
            }

            if (dr.RowState != DataRowState.Modified)
            {
                dr.SetModified();
            }
        }
        private void setupData(DataRow r)
        {
            int    objectType = int.Parse(r["type"].ToString());
            String oType      = "";

            switch (objectType)
            {
            case 0:
                oType = "Mobs";
                break;

            case 3:
                oType = "Planets";
                break;

            case 11:
                oType = "Stargates";
                break;

            case 12:
                oType = "Starbases";
                break;

            case 37:
                oType = "Decorations";
                break;

            case 38:
                oType = "Harvestables";
                break;
            }

            dp = new StargateProps();

            //Base Props + Nav Point Props
            dp.SectorID         = int.Parse(r["sector_id"].ToString());
            dp.NavType          = r["nav_type"].ToString();
            dp.Signature        = float.Parse(r["signature"].ToString());
            dp.IsHuge           = (Boolean)r["is_huge"];
            dp.BaseXP           = int.Parse(r["base_xp"].ToString());
            dp.ExplorationRange = float.Parse(r["exploration_range"].ToString());

            dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString());

            AdobeColors.HSL hslColor = new AdobeColors.HSL();
            hslColor.H = float.Parse(r["h"].ToString());
            hslColor.S = float.Parse(r["s"].ToString());
            hslColor.L = float.Parse(r["v"].ToString());
            Color newColor = AdobeColors.HSL_to_RGB(hslColor);

            dp.Color = newColor;

            dp.Type      = oType;
            dp.Scale     = float.Parse(r["scale"].ToString());;
            dp.PositionX = float.Parse(r["position_x"].ToString());
            dp.PositionY = float.Parse(r["position_y"].ToString());
            dp.PositionZ = float.Parse(r["position_z"].ToString());;

            double[] quat1 = new double[4];
            quat1[0] = double.Parse(r["orientation_z"].ToString());
            quat1[1] = double.Parse(r["orientation_u"].ToString());
            quat1[2] = double.Parse(r["orientation_v"].ToString());
            quat1[3] = double.Parse(r["orientation_w"].ToString());

            QuaternionCalc qc1 = new QuaternionCalc();

            double[] ang1 = qc1.QuatToAngle(quat1);
            if (ang1[0] == double.NaN)
            {
                ang1[0] = 0;
            }
            if (ang1[1] == double.NaN)
            {
                ang1[1] = 0;
            }
            if (ang1[2] == double.NaN)
            {
                ang1[2] = 0;
            }
            dp.Orientation_Yaw   = Math.Round(ang1[0], 0);
            dp.Orientation_Pitch = Math.Round(ang1[1], 0);
            dp.Orientation_Roll  = Math.Round(ang1[2], 0);

            dp.Name             = r["name"].ToString();
            dp.AppearsInRadar   = (Boolean)r["appears_in_radar"];
            dp.RadarRange       = float.Parse(r["radar_range"].ToString());
            dp.Destination      = int.Parse(r["gate_to"].ToString());
            dp.SoundEffect      = int.Parse(r["sound_effect_id"].ToString());
            dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString());

            //Stargate Specific Props
            dp.IsClassSpecific = (Boolean)r["classSpecific"];

            //TODO: Get Faction Name from ID;
            String factionName = mainFrm.factions.findNameByID(int.Parse(r["faction_id"].ToString()));

            dp.FactionID = factionName;
        }
예제 #8
0
        private void populateFields(int objectID)
        {
            equippedAmmoGroup       = new ListViewGroup("Ammo", HorizontalAlignment.Left);
            equippedDevicesGroup    = new ListViewGroup("Devices", HorizontalAlignment.Left);
            equippedEnginesGroup    = new ListViewGroup("Engines", HorizontalAlignment.Left);
            equippedReactorsGroup   = new ListViewGroup("Reactors", HorizontalAlignment.Left);
            equippedShieldsGroup    = new ListViewGroup("Shields", HorizontalAlignment.Left);
            equippedMissileGroup    = new ListViewGroup("Missile Weapon", HorizontalAlignment.Left);
            equippedProjectileGroup = new ListViewGroup("Projectile Weapon", HorizontalAlignment.Left);
            equippedBeamGroup       = new ListViewGroup("Beam Weapon", HorizontalAlignment.Left);

            listView1.Groups.AddRange(new ListViewGroup[] { equippedAmmoGroup, equippedDevicesGroup, equippedEnginesGroup,
                                                            equippedReactorsGroup, equippedShieldsGroup, equippedMissileGroup,
                                                            equippedProjectileGroup, equippedBeamGroup });

            inventoryAmmoGroup       = new ListViewGroup("Ammo", HorizontalAlignment.Left);
            inventoryDevicesGroup    = new ListViewGroup("Devices", HorizontalAlignment.Left);
            inventoryEnginesGroup    = new ListViewGroup("Engines", HorizontalAlignment.Left);
            inventoryReactorsGroup   = new ListViewGroup("Reactors", HorizontalAlignment.Left);
            inventoryShieldsGroup    = new ListViewGroup("Shields", HorizontalAlignment.Left);
            inventoryMissileGroup    = new ListViewGroup("Missile Weapon", HorizontalAlignment.Left);
            inventoryProjectileGroup = new ListViewGroup("Projectile Weapon", HorizontalAlignment.Left);
            inventoryBeamGroup       = new ListViewGroup("Beam Weapon", HorizontalAlignment.Left);
            inventoryComponentsGroup = new ListViewGroup("Components", HorizontalAlignment.Left);
            inventoryOreGroup        = new ListViewGroup("Ore & Resources", HorizontalAlignment.Left);
            inventoryMiscGroup       = new ListViewGroup("Misc. Loot", HorizontalAlignment.Left);

            listView2.Groups.AddRange(new ListViewGroup[] { inventoryAmmoGroup, inventoryDevicesGroup,
                                                            inventoryEnginesGroup, inventoryReactorsGroup, inventoryShieldsGroup,
                                                            inventoryMissileGroup, inventoryProjectileGroup, inventoryBeamGroup,
                                                            inventoryComponentsGroup, inventoryOreGroup, inventoryMiscGroup });

            selectedRow = mobs.getRowByID(objectID);

            //General Details.
            String name           = selectedRow["name"].ToString();
            int    level          = int.Parse(selectedRow["level"].ToString());
            int    type           = int.Parse(selectedRow["type"].ToString());
            int    intelligence   = int.Parse(selectedRow["intelligence"].ToString());
            int    bravery        = int.Parse(selectedRow["bravery"].ToString());
            int    factionID      = int.Parse(selectedRow["faction_id"].ToString());
            int    baseAssetID    = int.Parse(selectedRow["base_asset_id"].ToString());
            int    altruism       = int.Parse(selectedRow["altruism"].ToString());
            int    aggressiveness = int.Parse(selectedRow["aggressiveness"].ToString());
            float  h     = float.Parse(selectedRow["h"].ToString());
            float  s     = float.Parse(selectedRow["s"].ToString());
            float  v     = float.Parse(selectedRow["v"].ToString());
            float  scale = float.Parse(selectedRow["scale"].ToString());
            String ai    = selectedRow["ai"].ToString();

            nameText.Text           = name;
            levelCombo.SelectedItem = level;
            baseAssetText.Text      = baseAssetID.ToString();
            scaleText.Text          = scale.ToString();
            aiText.Text             = ai;

            AdobeColors.HSL hsl = new AdobeColors.HSL();
            hsl.H          = h;
            hsl.S          = s;
            hsl.L          = v;
            cPicker1.Color = AdobeColors.HSL_to_RGB(hsl);

            switch (type)
            {
            case 0:
                typeCombo.SelectedItem = "Cybernetic";
                break;

            case 1:
                typeCombo.SelectedItem = "Structural";
                break;

            case 2:
                typeCombo.SelectedItem = "Organic_Red";
                break;

            case 3:
                typeCombo.SelectedItem = "Organic_Green";
                break;

            case 4:
                typeCombo.SelectedItem = "Crystalline";
                break;

            case 5:
                typeCombo.SelectedItem = "Energy";
                break;

            case 6:
                typeCombo.SelectedItem = "Rock Based";
                break;
            }

            String factionName = factions.findNameByID(factionID);

            if (factionName != "None")
            {
                factionCombo.SelectedItem = factionName;
            }
            else
            {
                factionCombo.SelectedItem = "Please Make A Selection";
            }

            //Equipped Items & Inventory
            DataRow[] mobItems = mobItemsSql.getRowsByID(objectID);

            listView1.Items.Clear();
            listView2.Items.Clear();

            for (int i = 0; i < mobItems.Length; i++)
            {
                int itemBaseID = int.Parse(mobItems[i]["item_base_id"].ToString());
                int itemType   = int.Parse(mobItems[i]["type"].ToString());
                int itemUsage  = int.Parse(mobItems[i]["usage_chance"].ToString());
                int itemDrop   = int.Parse(mobItems[i]["drop_chance"].ToString());

                DataRow inDR     = itemBase.getRowByID(itemBaseID);
                String  itemName = inDR["name"].ToString();
                int     itemCat  = int.Parse(inDR["sub_category"].ToString());
                int     asset_2d = int.Parse(inDR["2d_asset"].ToString());

                String imageFileName = baseAssets.getFileNameByID(asset_2d);

                if (itemType == 0)
                {
                    ListViewItem lvi1 = new ListViewItem(itemName, imageFileName);
                    lvi1.Tag         = mobItems[i];
                    lvi1.ToolTipText = itemName;

                    switch (itemCat)
                    {
                    case 100:
                        lvi1.Group = equippedBeamGroup;
                        break;

                    case 101:
                        lvi1.Group = equippedProjectileGroup;
                        break;

                    case 102:
                        lvi1.Group = equippedMissileGroup;
                        break;

                    case 103:
                        lvi1.Group = equippedAmmoGroup;
                        break;

                    case 110:
                        lvi1.Group = equippedDevicesGroup;
                        break;

                    case 120:
                        lvi1.Group = equippedReactorsGroup;
                        break;

                    case 121:
                        lvi1.Group = equippedEnginesGroup;
                        break;

                    case 122:
                        lvi1.Group = equippedShieldsGroup;
                        break;
                    }

                    listView1.Items.Add(lvi1);
                }
                else
                {
                    ListViewItem lvi2 = new ListViewItem(itemName, imageFileName);
                    lvi2.ToolTipText = itemName;
                    lvi2.Tag         = mobItems[i];

                    switch (itemCat)
                    {
                    case -1:
                        lvi2.Group = inventoryMiscGroup;
                        break;

                    case 100:
                        lvi2.Group = inventoryBeamGroup;
                        break;

                    case 101:
                        lvi2.Group = inventoryProjectileGroup;
                        break;

                    case 102:
                        lvi2.Group = inventoryMissileGroup;
                        break;

                    case 103:
                        lvi2.Group = inventoryAmmoGroup;
                        break;

                    case 110:
                        lvi2.Group = inventoryDevicesGroup;
                        break;

                    case 120:
                        lvi2.Group = inventoryReactorsGroup;
                        break;

                    case 121:
                        lvi2.Group = inventoryEnginesGroup;
                        break;

                    case 122:
                        lvi2.Group = inventoryShieldsGroup;
                        break;

                    case 500:
                        lvi2.Group = inventoryComponentsGroup;
                        break;

                    case 800:
                        lvi2.Group = inventoryOreGroup;
                        break;
                    }

                    listView2.Items.Add(lvi2);
                }
            }

            //Skills

            setupMainImage(baseAssetID);
        }
예제 #9
0
        private void setupData(DataRow r)
        {
            int    objectType = int.Parse(r["type"].ToString());
            String oType      = "";

            switch (objectType)
            {
            case 0:
                oType = "Mobs";
                break;

            case 3:
                oType = "Planets";
                break;

            case 11:
                oType = "Stargates";
                break;

            case 12:
                oType = "Starbases";
                break;

            case 37:
                oType = "Decorations";
                break;

            case 38:
                oType = "Harvestables";
                break;
            }

            dp                  = new MobProps();
            dp.SectorID         = int.Parse(r["sector_id"].ToString());
            dp.NavType          = r["nav_type"].ToString();
            dp.Signature        = float.Parse(r["signature"].ToString());
            dp.IsHuge           = (Boolean)r["is_huge"];
            dp.BaseXP           = int.Parse(r["base_xp"].ToString());
            dp.ExplorationRange = float.Parse(r["exploration_range"].ToString());

            dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString());

            AdobeColors.HSL hslColor = new AdobeColors.HSL();
            hslColor.H = float.Parse(r["h"].ToString());
            hslColor.S = float.Parse(r["s"].ToString());
            hslColor.L = float.Parse(r["v"].ToString());
            Color newColor = AdobeColors.HSL_to_RGB(hslColor);

            dp.Color = newColor;

            dp.Type      = oType;
            dp.Scale     = float.Parse(r["scale"].ToString());;
            dp.PositionX = float.Parse(r["position_x"].ToString());
            dp.PositionY = float.Parse(r["position_y"].ToString());
            dp.PositionZ = float.Parse(r["position_z"].ToString());;

            double[] quat1 = new double[4];
            quat1[0] = double.Parse(r["orientation_z"].ToString());
            quat1[1] = double.Parse(r["orientation_u"].ToString());
            quat1[2] = double.Parse(r["orientation_v"].ToString());
            quat1[3] = double.Parse(r["orientation_w"].ToString());

            QuaternionCalc qc1 = new QuaternionCalc();

            double[] ang1 = qc1.QuatToAngle(quat1);
            if (ang1[0] == double.NaN)
            {
                ang1[0] = 0;
            }
            if (ang1[1] == double.NaN)
            {
                ang1[1] = 0;
            }
            if (ang1[2] == double.NaN)
            {
                ang1[2] = 0;
            }
            dp.Orientation_Yaw   = Math.Round(ang1[0], 0);
            dp.Orientation_Pitch = Math.Round(ang1[1], 0);
            dp.Orientation_Roll  = Math.Round(ang1[2], 0);

            dp.Name             = r["name"].ToString();
            dp.AppearsInRadar   = (Boolean)r["appears_in_radar"];
            dp.RadarRange       = float.Parse(r["radar_range"].ToString());
            dp.Destination      = int.Parse(r["gate_to"].ToString());
            dp.SoundEffect      = int.Parse(r["sound_effect_id"].ToString());
            dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString());

            dp.SpawnGroup   = "<Collection...>";
            dp.Count        = int.Parse(r["mob_count"].ToString());
            dp.SpawnRadius  = float.Parse(r["mob_spawn_radius"].ToString());
            dp.RespawnTime  = float.Parse(r["respawn_time"].ToString());
            dp.DelayedSpawn = (Boolean)r["delayed_spawn"];
        }
        private void setupData(DataRow r)
        {
            int    objectType = int.Parse(r["type"].ToString());
            String oType      = "";

            switch (objectType)
            {
            case 0:
                oType = "Mobs";
                break;

            case 3:
                oType = "Planets";
                break;

            case 11:
                oType = "Stargates";
                break;

            case 12:
                oType = "Starbases";
                break;

            case 37:
                oType = "Decorations";
                break;

            case 38:
                oType = "Harvestables";
                break;
            }

            dp = new PlanetProps();

            //Base Props
            dp.SectorID         = int.Parse(r["sector_id"].ToString());
            dp.NavType          = r["nav_type"].ToString();
            dp.Signature        = float.Parse(r["signature"].ToString());
            dp.IsHuge           = (Boolean)r["is_huge"];
            dp.BaseXP           = int.Parse(r["base_xp"].ToString());
            dp.ExplorationRange = float.Parse(r["exploration_range"].ToString());

            dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString());

            AdobeColors.HSL hslColor = new AdobeColors.HSL();
            hslColor.H = float.Parse(r["h"].ToString());
            hslColor.S = float.Parse(r["s"].ToString());
            hslColor.L = float.Parse(r["v"].ToString());
            Color newColor = AdobeColors.HSL_to_RGB(hslColor);

            dp.Color = newColor;

            dp.Type      = oType;
            dp.Scale     = float.Parse(r["scale"].ToString());;
            dp.PositionX = float.Parse(r["position_x"].ToString());
            dp.PositionY = float.Parse(r["position_y"].ToString());
            dp.PositionZ = float.Parse(r["position_z"].ToString());;

            double[] quat1 = new double[4];
            quat1[0] = double.Parse(r["orientation_z"].ToString());
            quat1[1] = double.Parse(r["orientation_u"].ToString());
            quat1[2] = double.Parse(r["orientation_v"].ToString());
            quat1[3] = double.Parse(r["orientation_w"].ToString());

            QuaternionCalc qc1 = new QuaternionCalc();

            double[] ang1 = qc1.QuatToAngle(quat1);
            if (ang1[0] == double.NaN)
            {
                ang1[0] = 0;
            }
            if (ang1[1] == double.NaN)
            {
                ang1[1] = 0;
            }
            if (ang1[2] == double.NaN)
            {
                ang1[2] = 0;
            }
            dp.Orientation_Yaw   = Math.Round(ang1[0], 0);
            dp.Orientation_Pitch = Math.Round(ang1[1], 0);
            dp.Orientation_Roll  = Math.Round(ang1[2], 0);

            dp.Name             = r["name"].ToString();
            dp.AppearsInRadar   = (Boolean)r["appears_in_radar"];
            dp.RadarRange       = float.Parse(r["radar_range"].ToString());
            dp.Destination      = int.Parse(r["gate_to"].ToString());
            dp.SoundEffect      = int.Parse(r["sound_effect_id"].ToString());
            dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString());

            try
            {
                //Planet Props
                dp.OrbitID     = int.Parse(r["orbit_id"].ToString());
                dp.OrbitDist   = float.Parse(r["orbit_dist"].ToString());
                dp.OrbitAngle  = float.Parse(r["orbit_angle"].ToString());
                dp.OrbitRate   = float.Parse(r["orbit_rate"].ToString());
                dp.RotateAngle = float.Parse(r["rotate_angle"].ToString());
                dp.RotateRate  = float.Parse(r["rotate_rate"].ToString());
                dp.TiltAngle   = float.Parse(r["tilt_angle"].ToString());
                dp.IsLandable  = bool.Parse(r["is_landable"].ToString());
            }
            catch (Exception)
            {
                dp.OrbitID     = 0;
                dp.OrbitDist   = 0;
                dp.OrbitAngle  = 0;
                dp.OrbitRate   = 0;
                dp.RotateAngle = 0;
                dp.RotateRate  = 0;
                dp.TiltAngle   = 0;
                dp.IsLandable  = false;
            }
        }
        public void updateChangedInfo(String propertyName, Object _changedValue)
        {
            String changedValue = _changedValue.ToString();

            //Update DataRow and Graphics (only certain props require graphical updating).
            if (propertyName == "SectorID")
            {
                dr["sector_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "NavType")
            {
                dr["nav_type"] = changedValue;
            }
            else if (propertyName == "Signature")
            {
                dr["signature"] = float.Parse(changedValue);

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(0).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(0).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(0).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(0).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "IsHuge")
            {
                dr["is_huge"] = bool.Parse(changedValue);
            }
            else if (propertyName == "BaseXP")
            {
                dr["base_xp"] = int.Parse(changedValue);
            }
            else if (propertyName == "ExplorationRange")
            {
                dr["exploration_range"] = float.Parse(changedValue);

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(2).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(2).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(2).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(2).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "BaseAssetID")
            {
                dr["base_asset_id"] = int.Parse(changedValue);
                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["base_asset_id"].Value = int.Parse(changedValue);
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "Color")
            {
                Color           color = (Color)_changedValue;
                AdobeColors.HSL hsv   = AdobeColors.RGB_to_HSL(color);

                dr["h"] = hsv.H;
                dr["s"] = hsv.S;
                dr["v"] = hsv.L;
            }
            else if (propertyName == "Type")
            {
                _layer.RemoveChild(harvestableImage);

                /*
                 * if (changedValue == "Mobs")
                 * {
                 *  dr["type"] = 0;
                 *  new MobSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Planets")
                 * {
                 *  dr["type"] = 3;
                 *  new PlanetSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Stargates")
                 * {
                 *  dr["type"] = 11;
                 *  new StargateSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Starbases")
                 * {
                 *  dr["type"] = 12;
                 *  new StarbaseSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Decorations")
                 * {
                 *  dr["type"] = 37;
                 *  new DecorationSprite(_layer, dr, _pg);
                 * }*/

                _pg.SelectedObject = null;
            }
            else if (propertyName == "Scale")
            {
                dr["scale"] = float.Parse(changedValue);
            }
            else if (propertyName == "PositionX")
            {
                dr["position_x"] = float.Parse(changedValue);

                float dx = (float.Parse(changedValue) / 100) - harvestableImage.X;
                harvestableImage.TranslateBy(dx, 0);
            }
            else if (propertyName == "PositionY")
            {
                dr["position_y"] = float.Parse(changedValue);

                float dy = (float.Parse(changedValue) / 100) - harvestableImage.Y;
                harvestableImage.TranslateBy(0, dy);
            }
            else if (propertyName == "PositionZ")
            {
                dr["position_z"] = float.Parse(changedValue);
            }
            else if (propertyName == "Orientation_Yaw" || propertyName == "Orientation_Pitch" || propertyName == "Orientation_Roll")
            {
                QuaternionCalc qtmp = new QuaternionCalc();
                double[]       q1   = qtmp.AngleToQuat(dp.Orientation_Yaw, dp.Orientation_Pitch, dp.Orientation_Roll);

                dr["orientation_z"] = q1[0];
                dr["orientation_u"] = q1[1];
                dr["orientation_v"] = q1[2];
                dr["orientation_w"] = q1[3];
            }
            else if (propertyName == "Name")
            {
                dr["name"] = changedValue;

                float x    = harvestableImage.X;
                float y    = harvestableImage.Y;
                PText name = (PText)harvestableImage.GetChild(3);
                name.Text          = changedValue;
                name.TextAlignment = StringAlignment.Center;
                name.X             = x - (name.Width / 2);
                name.Y             = y - 20;

                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["name"].Value = changedValue;
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "AppearsInRadar")
            {
                dr["appears_in_radar"] = bool.Parse(changedValue);

                if (bool.Parse(changedValue) == true)
                {
                    changeImage(1);
                }
                else
                {
                    changeImage(0);
                }
            }
            else if (propertyName == "RadarRange")
            {
                dr["radar_range"] = float.Parse(changedValue);

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(1).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(1).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(1).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(1).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "Destination")
            {
                dr["gate_to"] = int.Parse(changedValue);
            }
            else if (propertyName == "Level")
            {
                dr["level"] = changedValue;
            }
            else if (propertyName == "Field")
            {
                if (changedValue == "Random")
                {
                    dr["field"] = 0;
                }
                else if (changedValue == "Ring")
                {
                    dr["field"] = 1;
                }
                else if (changedValue == "Donut")
                {
                    dr["field"] = 2;
                }
                else if (changedValue == "Cylinder")
                {
                    dr["field"] = 3;
                }
                else if (changedValue == "Sphere")
                {
                    dr["field"] = 4;
                }
                else if (changedValue == "Gas Cloud Clump")
                {
                    dr["field"] = 5;
                }
            }
            else if (propertyName == "ResCount")
            {
                dr["res_count"] = int.Parse(changedValue);
            }
            else if (propertyName == "MaxFieldRadius")
            {
                dr["max_field_radius"] = float.Parse(changedValue);

                int navType   = int.Parse(dr["nav_type"].ToString());
                int nodeCount = (3 + navType) + 2;

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(nodeCount).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(nodeCount).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "MobSpawnRadius")
            {
                dr["spawn_radius"] = float.Parse(changedValue);

                int navType   = int.Parse(dr["nav_type"].ToString());
                int nodeCount = (3 + navType) + 1;

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(nodeCount).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(nodeCount).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "PopRockChance")
            {
                dr["pop_rock_chance"] = float.Parse(changedValue);
            }
            else if (propertyName == "SoundEffect")
            {
                dr["sound_effect_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "SoundEffectRange")
            {
                dr["sound_effect_range"] = float.Parse(changedValue);
            }

            if (dr.RowState != DataRowState.Modified)
            {
                dr.SetModified();
            }
        }
        private void setupData(DataRow r)
        {
            int    objectType = int.Parse(r["type"].ToString());
            String oType      = "";

            switch (objectType)
            {
            case 0:
                oType = "Mobs";
                break;

            case 3:
                oType = "Planets";
                break;

            case 11:
                oType = "Stargates";
                break;

            case 12:
                oType = "Starbases";
                break;

            case 37:
                oType = "Decorations";
                break;

            case 38:
                oType = "Harvestables";
                break;
            }

            dp = new HarvestableProps();

            //Base Props
            dp.SectorID         = int.Parse(r["sector_id"].ToString());
            dp.NavType          = r["nav_type"].ToString();
            dp.Signature        = float.Parse(r["signature"].ToString());
            dp.IsHuge           = (Boolean)r["is_huge"];
            dp.BaseXP           = int.Parse(r["base_xp"].ToString());
            dp.ExplorationRange = float.Parse(r["exploration_range"].ToString());

            dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString());

            AdobeColors.HSL hslColor = new AdobeColors.HSL();
            hslColor.H = float.Parse(r["h"].ToString());
            hslColor.S = float.Parse(r["s"].ToString());
            hslColor.L = float.Parse(r["v"].ToString());
            Color newColor = AdobeColors.HSL_to_RGB(hslColor);

            dp.Color = newColor;

            dp.Type      = oType;
            dp.Scale     = float.Parse(r["scale"].ToString());;
            dp.PositionX = float.Parse(r["position_x"].ToString());
            dp.PositionY = float.Parse(r["position_y"].ToString());
            dp.PositionZ = float.Parse(r["position_z"].ToString());;

            double[] quat1 = new double[4];
            quat1[0] = double.Parse(r["orientation_z"].ToString());
            quat1[1] = double.Parse(r["orientation_u"].ToString());
            quat1[2] = double.Parse(r["orientation_v"].ToString());
            quat1[3] = double.Parse(r["orientation_w"].ToString());

            QuaternionCalc qc1 = new QuaternionCalc();

            double[] ang1 = qc1.QuatToAngle(quat1);
            if (ang1[0] == double.NaN)
            {
                ang1[0] = 0;
            }
            if (ang1[1] == double.NaN)
            {
                ang1[1] = 0;
            }
            if (ang1[2] == double.NaN)
            {
                ang1[2] = 0;
            }
            dp.Orientation_Yaw   = Math.Round(ang1[0], 0);
            dp.Orientation_Pitch = Math.Round(ang1[1], 0);
            dp.Orientation_Roll  = Math.Round(ang1[2], 0);

            dp.Name             = r["name"].ToString();
            dp.AppearsInRadar   = (Boolean)r["appears_in_radar"];
            dp.RadarRange       = float.Parse(r["radar_range"].ToString());
            dp.Destination      = int.Parse(r["gate_to"].ToString());
            dp.SoundEffect      = int.Parse(r["sound_effect_id"].ToString());
            dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString());

            //Harvestable Props
            try
            {
                dp.Level          = r["level"].ToString();
                dp.ResType        = "<Collection...>";
                dp.ResCount       = int.Parse(r["res_count"].ToString());
                dp.MobSpawnRadius = float.Parse(r["spawn_radius"].ToString());
                dp.PopRockChance  = int.Parse(r["pop_rock_chance"].ToString());
                dp.SpawnGroup     = "<Collection...>";
                dp.MaxFieldRadius = float.Parse(r["max_field_radius"].ToString());

                String fieldName = "";
                switch (int.Parse(r["field"].ToString()))
                {
                case 0:
                    fieldName = "Random";
                    break;

                case 1:
                    fieldName = "Ring";
                    break;

                case 2:
                    fieldName = "Donut";
                    break;

                case 3:
                    fieldName = "Cylinder";
                    break;

                case 4:
                    fieldName = "Sphere";
                    break;

                case 5:
                    fieldName = "Gas Cloud Clump";
                    break;
                }

                dp.Field = fieldName;
            }
            catch (Exception)
            {
                dp.Level          = "1";
                dp.Field          = "Single";
                dp.ResCount       = 0;
                dp.MaxFieldRadius = 0;
                dp.MobSpawnRadius = 0;
                dp.PopRockChance  = 0;
                dp.SpawnGroup     = "<Collection...>";
            }
        }