コード例 #1
0
        private void lvwMapMarkers_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvwMapMarkers.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem selectedItem = lvwMapMarkers.SelectedItems[0];

            StructureMarker selectedMarker = new StructureMarker();

            if (selectedItem.Tag is ArkStructure)
            {
                ArkStructure selectedStructure = (ArkStructure)selectedItem.Tag;
                selectedMarker.Colour = "White";
                selectedMarker.Lat    = (double)selectedStructure.Location?.Latitude.GetValueOrDefault(0);
                selectedMarker.Lon    = (double)selectedStructure.Location?.Longitude.GetValueOrDefault(0);
                selectedMarker.X      = selectedStructure.Location.X;
                selectedMarker.Y      = selectedStructure.Location.Y;
                selectedMarker.Z      = selectedStructure.Location.Z;
            }
            else if (selectedItem.Tag is StructureMarker)
            {
                selectedMarker = (StructureMarker)selectedItem.Tag;
            }


            HighlightStructure?.Invoke(this, selectedMarker);
        }
コード例 #2
0
        private void btnCopyCommand_Click(object sender, EventArgs e)
        {
            if (cboConsoleCommands.SelectedItem == null)
            {
                return;
            }
            if (lvwMapMarkers.SelectedItems.Count <= 0)
            {
                return;
            }

            ListViewItem    selectedItem   = lvwMapMarkers.SelectedItems[0];
            StructureMarker selectedMarker = new StructureMarker();

            if (selectedItem.Tag is ArkStructure)
            {
                ArkStructure selectedStructure = (ArkStructure)selectedItem.Tag;
                selectedMarker.Colour = "White";
                selectedMarker.Lat    = (double)selectedStructure.Location?.Latitude.GetValueOrDefault(0);
                selectedMarker.Lon    = (double)selectedStructure.Location?.Latitude.GetValueOrDefault(0);
                selectedMarker.X      = selectedStructure.Location.X;
                selectedMarker.Y      = selectedStructure.Location.Y;
                selectedMarker.Z      = selectedStructure.Location.Z;
            }
            else if (selectedItem.Tag is StructureMarker)
            {
                selectedMarker = (StructureMarker)selectedItem.Tag;
            }

            var commandText = cboConsoleCommands.SelectedItem.ToString();

            if (commandText != null)
            {
                commandText = commandText.Replace("<x>", System.FormattableString.Invariant($"{selectedMarker.X:0.00}"));
                commandText = commandText.Replace("<y>", System.FormattableString.Invariant($"{selectedMarker.Y:0.00}"));
                commandText = commandText.Replace("<z>", System.FormattableString.Invariant($"{selectedMarker.Z + 500:0.00}")); //+500

                switch (Program.ProgramConfig.CommandPrefix)
                {
                case 1:
                    commandText = $"admincheat {commandText}";

                    break;

                case 2:
                    commandText = $"cheat {commandText}";
                    break;
                }

                Clipboard.SetText(commandText);
                MessageBox.Show($"Command copied to the clipboard:\n\n{commandText}", "Command Copied", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #3
0
        public void Load()
        {
            var savePath     = AppDomain.CurrentDomain.BaseDirectory;
            var saveFilename = Path.Combine(savePath, "config.json");

            Mode           = ViewerModes.Mode_SinglePlayer;
            SelectedFile   = "TheIsland.ark";
            SelectedServer = "";

            //load colours

            ColourMap = new List <ColourMap>();
            string colourMapFilename = Path.Combine(savePath, "colours.json");

            if (File.Exists(colourMapFilename))
            {
                string jsonFileContent = File.ReadAllText(colourMapFilename);

                JObject itemFile = JObject.Parse(jsonFileContent);
                JArray  itemList = (JArray)itemFile.GetValue("colors");
                foreach (JObject itemObject in itemList)
                {
                    ColourMap item = new ColourMap();
                    item.Id  = itemObject.Value <int>("id");
                    item.Hex = itemObject.Value <string>("hex");
                    ColourMap.Add(item);
                }
            }

            //load markers
            MapMarkerList = new List <MapMarker>();
            string markerFilename = Path.Combine(savePath, "mapmarkers.json");

            if (File.Exists(markerFilename))
            {
                string jsonFileContent = File.ReadAllText(markerFilename);

                JObject markerFile = JObject.Parse(jsonFileContent);
                JArray  markerList = (JArray)markerFile.GetValue("markers");
                foreach (JObject markerObject in markerList)
                {
                    MapMarker mapMarker = new MapMarker();

                    mapMarker.Map          = markerObject.Value <string>("Map");
                    mapMarker.Name         = markerObject.Value <string>("Name");
                    mapMarker.Colour       = markerObject.Value <int>("Colour");
                    mapMarker.BorderColour = markerObject.Value <int>("BorderColour");
                    mapMarker.BorderWidth  = markerObject.Value <int>("BorderWidth");
                    mapMarker.Marker       = markerObject.Value <int>("Marker");
                    mapMarker.Lat          = markerObject.Value <double>("Lat");
                    mapMarker.Lon          = markerObject.Value <double>("Lon");


                    MapMarkerList.Add(mapMarker);
                }
            }


            //load terminal markers
            string structureMarkerFilename = Path.Combine(savePath, "structuremarkers.json");

            if (File.Exists(structureMarkerFilename))
            {
                string jsonFileContent = File.ReadAllText(structureMarkerFilename);

                TerminalMarkers = new List <StructureMarker>();
                JObject markerFile   = JObject.Parse(jsonFileContent);
                JArray  terminalList = (JArray)markerFile.GetValue("terminals");

                foreach (JObject markerObject in terminalList)
                {
                    StructureMarker mapMarker = new StructureMarker();

                    mapMarker.Map = markerObject.Value <string>("Map");
                    mapMarker.Lat = markerObject.Value <double>("Lat");
                    mapMarker.Lon = markerObject.Value <double>("Lon");
                    mapMarker.X   = markerObject.Value <float>("X");
                    mapMarker.Y   = markerObject.Value <float>("Y");
                    mapMarker.Z   = markerObject.Value <float>("Z");

                    mapMarker.Colour = markerObject.Value <string>("Colour");

                    TerminalMarkers.Add(mapMarker);
                }


                GlitchMarkers = new List <StructureMarker>();
                JArray glitchList = (JArray)markerFile.GetValue("glitches");

                foreach (JObject markerObject in glitchList)
                {
                    StructureMarker mapMarker = new StructureMarker();

                    mapMarker.Map = markerObject.Value <string>("Map");
                    mapMarker.Lat = markerObject.Value <double>("Lat");
                    mapMarker.Lon = markerObject.Value <double>("Lon");
                    mapMarker.X   = markerObject.Value <float>("X");
                    mapMarker.Y   = markerObject.Value <float>("Y");
                    mapMarker.Z   = markerObject.Value <float>("Z");

                    mapMarker.Colour = markerObject.Value <string>("Colour");

                    GlitchMarkers.Add(mapMarker);
                }
            }


            //load item map
            ItemMap = new List <ItemClassMap>();
            string itemMapFilename = Path.Combine(savePath, "itemmap.json");

            if (File.Exists(itemMapFilename))
            {
                string jsonFileContent = File.ReadAllText(itemMapFilename);

                JObject itemFile = JObject.Parse(jsonFileContent);
                JArray  itemList = (JArray)itemFile.GetValue("items");
                foreach (JObject itemObject in itemList)
                {
                    ItemClassMap item = new ItemClassMap();
                    item.ClassName    = itemObject.Value <string>("ClassName");
                    item.FriendlyName = itemObject.Value <string>("FriendlyName");
                    item.Category     = itemObject.Value <string>("Category");
                    item.Icon         = itemObject.Value <int>("Icon");
                    ItemMap.Add(item);
                }
            }

            //load structure map
            StructureMap = new List <StructureClassMap>();
            string structureMapFilename = Path.Combine(savePath, "structuremap.json");

            if (File.Exists(structureMapFilename))
            {
                string jsonFileContent = File.ReadAllText(structureMapFilename);

                JObject itemFile = JObject.Parse(jsonFileContent);
                JArray  itemList = (JArray)itemFile.GetValue("structures");
                foreach (JObject itemObject in itemList)
                {
                    StructureClassMap item = new StructureClassMap();
                    item.ClassName    = itemObject.Value <string>("ClassName");
                    item.FriendlyName = itemObject.Value <string>("FriendlyName");
                    StructureMap.Add(item);
                }
            }

            //load dino map
            DinoMap = new List <DinoClassMap>();
            string dinoMapFilename = Path.Combine(savePath, "creaturemap.json");

            if (File.Exists(dinoMapFilename))
            {
                string jsonFileContent = File.ReadAllText(dinoMapFilename);

                JObject dinoFile = JObject.Parse(jsonFileContent);
                JArray  dinoList = (JArray)dinoFile.GetValue("creatures");
                foreach (JObject dinoObject in dinoList)
                {
                    DinoClassMap dino = new DinoClassMap();
                    dino.ClassName    = dinoObject.Value <string>("ClassName");
                    dino.FriendlyName = dinoObject.Value <string>("FriendlyName");
                    DinoMap.Add(dino);
                }
            }

            ServerList = new List <ServerConfiguration>();
            if (File.Exists(saveFilename))
            {
                //found, load the saved state
                string jsonFileContent = File.ReadAllText(saveFilename);
                configFromJson(jsonFileContent);

                //decrypt server password after reading from disk
                if (EncryptionPassword != null && EncryptionPassword.Length > 0)
                {
                    //decode from base64
                    byte[] passwordBytes = Convert.FromBase64String(EncryptionPassword);
                    this.EncryptionPassword = ASCIIEncoding.ASCII.GetString(passwordBytes);

                    if (ServerList.Count > 0)
                    {
                        foreach (var server in ServerList)
                        {
                            string mapFilename = "theisland.ark";
                            if (server.SaveGamePath.ToLower().EndsWith(".ark"))
                            {
                                if (server.SaveGamePath.Contains("/"))
                                {
                                    mapFilename         = server.SaveGamePath.Substring(server.SaveGamePath.LastIndexOf("/") + 1).ToLower();
                                    server.SaveGamePath = server.SaveGamePath.Substring(0, server.SaveGamePath.LastIndexOf("/") + 1);
                                }
                            }
                            else
                            {
                                mapFilename = server.Map;
                            }
                            server.Map = mapFilename.ToLower();
                            if (server.Address.ToLower().Contains("ftp://"))
                            {
                                server.Address = server.Address.Substring(server.Address.IndexOf("ftp://") + 6);
                            }

                            server.Username = DecryptString(server.Username, Convert.FromBase64String(this.IV), this.EncryptionPassword);
                            server.Password = DecryptString(server.Password, Convert.FromBase64String(this.IV), this.EncryptionPassword);
                        }
                    }
                }
                else
                {
                    //create random initial password for this installation
                    Random rnd = new Random();

                    string randomPasswordString = "";
                    for (int charIndex = 0; charIndex < 16; charIndex++)
                    {
                        int nextRand = rnd.Next(32, 126);
                        randomPasswordString += (char)nextRand;
                    }

                    this.EncryptionPassword = randomPasswordString;
                }
            }
            else
            {
                Aes aes = Aes.Create();
                this.IV = Convert.ToBase64String(aes.IV);

                Save();
            }
        }