Example #1
0
        public static bool ContainsPoint(this DiscoveryZoneData Data, Point p, MainForm mainForm)
        {
            Rectangle Rect = Data.GetRect(mainForm.currentProject);

            PointF rotatedP = StaticHelpers.RotatePointAround(p, new PointF(Rect.Left + Rect.Width / 2.0f, Rect.Top + Rect.Height / 2.0f), -Data.rotation);

            p.X = (int)rotatedP.X;
            p.Y = (int)rotatedP.Y;

            return(Rect.Contains(p));
        }
Example #2
0
        public static Rectangle GetRect(this DiscoveryZoneData Data, Project currentProject)
        {
            if (currentProject == null)
            {
                return(new Rectangle());
            }

            float relativeX = Data.sizeX * currentProject.coordsScaling;
            float relativeY = Data.sizeY * currentProject.coordsScaling;

            return(new Rectangle((int)Math.Round(Data.worldX * currentProject.coordsScaling - relativeX / 2f), (int)Math.Round(Data.worldY * currentProject.coordsScaling - relativeY / 2f), (int)Math.Round(relativeX), (int)Math.Round(relativeY)));
        }
Example #3
0
 public EditDiscoveryZoneInstance(MainForm mainForm, DiscoveryZoneData targetInstance)
 {
     InitializeComponent();
     this.mainForm                  = mainForm;
     this.targetInstance            = targetInstance;
     this.zoneIdTxt.Text            = targetInstance.id + "";
     this.zoneNameTxt.Text          = targetInstance.name;
     this.zoneSizeXTxt.Text         = targetInstance.sizeX + "";
     this.zoneSizeYTxt.Text         = targetInstance.sizeY + "";
     this.zoneSizeZTxt.Text         = targetInstance.sizeZ + "";
     this.zoneXPTxt.Text            = targetInstance.xp + "";
     this.explorerNoteIndexTxt.Text = targetInstance.explorerNoteIndex + "";
     this.allowSeaCheckbox.Checked  = targetInstance.allowSea;
 }
Example #4
0
        public static DiscoveryZoneData SetFrom(this DiscoveryZoneData Data, string name, float worldX, float worldY, float sizeX, float sizeY, float rotation, int id)
        {
            Data.name              = name;
            Data.worldX            = worldX;
            Data.worldY            = worldY;
            Data.rotation          = rotation;
            Data.id                = id;
            Data.sizeX             = sizeX;
            Data.sizeY             = sizeY;
            Data.xp                = 0.0f;
            Data.startWorldX       = worldX;
            Data.startWorldY       = worldY;
            Data.sizeZ             = 40000.0f;
            Data.explorerNoteIndex = 0;
            Data.allowSea          = false;

            return(Data);
        }
Example #5
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            //Make sure there are no duplicate ids
            HashSet <int> ids = new HashSet <int>();

            foreach (DataGridViewRow row in discoZonesGrid.Rows)
            {
                if (row.Index == discoZonesGrid.Rows.Count - 1)
                {
                    continue;                                             //Last row is the new row
                }
                int id = -1;
                if (row.Cells[zoneId.Name].Value == null || !int.TryParse(row.Cells[zoneId.Name].Value.ToString(), out id))
                {
                    MessageBox.Show("You must assign a unique numeric only id to each row", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (ids.Contains(id))
                {
                    MessageBox.Show("Duplicate ids " + id + " found\nZone ids must be unique across the atlas", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                ids.Add(id);
            }

            mainForm.currentProject.discoZones.Clear();

            foreach (DataGridViewRow row in discoZonesGrid.Rows)
            {
                if (row.Index == discoZonesGrid.Rows.Count - 1)
                {
                    continue;                                             //Last row is the new row
                }
                string name = row.Cells[zoneName.Name].Value != null ? row.Cells[zoneName.Name].Value.ToString() : "";

                int id = -1;
                int.TryParse(row.Cells[zoneId.Name].Value.ToString(), out id);

                float worldX = 0.0f;
                if (row.Cells[LocX.Name].Value != null)
                {
                    float.TryParse(row.Cells[LocX.Name].Value.ToString(), out worldX);
                }

                float worldY = 0.0f;
                if (row.Cells[LocY.Name].Value != null)
                {
                    float.TryParse(row.Cells[LocY.Name].Value.ToString(), out worldY);
                }

                float sizeX = 0.0f;
                if (row.Cells[zoneSizeX.Name].Value != null)
                {
                    float.TryParse(row.Cells[zoneSizeX.Name].Value.ToString(), out sizeX);
                }

                float sizeY = 0.0f;
                if (row.Cells[zoneSizeY.Name].Value != null)
                {
                    float.TryParse(row.Cells[zoneSizeY.Name].Value.ToString(), out sizeY);
                }

                float sizeZ = 0.0f;
                if (row.Cells[zoneSizeZ.Name].Value != null)
                {
                    float.TryParse(row.Cells[zoneSizeZ.Name].Value.ToString(), out sizeZ);
                }

                float rotation = 0.0f;
                if (row.Cells[zoneRotation.Name].Value != null)
                {
                    float.TryParse(row.Cells[zoneRotation.Name].Value.ToString(), out rotation);
                }

                float xp = 0.0f;
                if (row.Cells[zoneXP.Name].Value != null)
                {
                    float.TryParse(row.Cells[zoneXP.Name].Value.ToString(), out xp);
                }

                string manualZoneName = row.Cells[zoneManualName.Name].Value != null? row.Cells[zoneManualName.Name].Value.ToString() : "";
                bool   bAllowSea      = row.Cells[allowSea.Name].Value != null ? (bool)row.Cells[allowSea.Name].Value : false;
                bool   bIsManual      = row.Cells[IsManual.Name].Value != null? (bool)row.Cells[IsManual.Name].Value : false;
                if (manualZoneName.Length == 0 && bIsManual)
                {
                    MessageBox.Show("Empty manual zone name at index: " + row.Index.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (bIsManual) //Put the zone in the correct server's center
                {
                    int      serverX = -1, serverY = -1;
                    string   parent = row.Cells[zoneParent.Name].Value != null? row.Cells[zoneParent.Name].Value.ToString() : "";
                    string[] splits = parent.Split(',');
                    if (splits.Length == 2)
                    {
                        serverX = int.Parse(splits[0]);
                        serverY = int.Parse(splits[1]);
                    }
                    Server parentServer = mainForm.GetServerByIndex(new Point(serverX, serverY));
                    if (parentServer == null)
                    {
                        MessageBox.Show("Can't find parent server for manual discovery zone: " + manualZoneName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        worldX = parentServer.GetWorldRect(mainForm.currentProject.cellSize).X + parentServer.GetWorldRect(mainForm.currentProject.cellSize).Width / 2;
                        worldY = parentServer.GetWorldRect(mainForm.currentProject.cellSize).Y + parentServer.GetWorldRect(mainForm.currentProject.cellSize).Height / 2;
                    }
                }

                int explorerNoteIndex = -1;
                if (row.Cells[zoneRotation.Name].Value != null)
                {
                    int.TryParse(row.Cells[ExplorerNoteIndex.Name].Value.ToString(), out explorerNoteIndex);
                }

                DiscoveryZoneData discoZone = new DiscoveryZoneData().SetFrom(name, worldX, worldY, sizeX, sizeY, rotation, id);
                discoZone.xp                = xp;
                discoZone.sizeZ             = sizeZ;
                discoZone.bIsManuallyPlaced = bIsManual;
                discoZone.allowSea          = bAllowSea;
                discoZone.ManualVolumeName  = manualZoneName;
                discoZone.explorerNoteIndex = explorerNoteIndex;
                mainForm.currentProject.discoZones.Add(discoZone);
            }

            mainForm.Invalidate();

            Close();
        }