コード例 #1
0
        public frmStructureInventoryViewer(ArkStructure structure)
        {
            InitializeComponent();

            selectedStructure = structure;
            string structureName = structure.ClassName;

            StructureClassMap classMap = Program.ProgramConfig.StructureMap.Where(d => d.ClassName == structure.ClassName).FirstOrDefault();

            if (classMap != null && classMap.FriendlyName.Length > 0)
            {
                structureName = classMap.FriendlyName;
            }
            lblStructureName.Text = structureName;

            //inventory images
            imageList1.Images.Clear();
            int x = 1;

            while (true)
            {
                Image itemImage = (Image)ARKViewer.Properties.Resources.ResourceManager.GetObject($"item_{x}");
                if (itemImage == null)
                {
                    break;
                }

                imageList1.Images.Add(itemImage);
                x++;
            }

            PopulateStructureInventory();
        }
コード例 #2
0
        private void PopulateStructures()
        {
            if (gd == null)
            {
                return;
            }
            if (gd.Structures == null)
            {
                return;
            }

            var playerStructureTypes = gd.Structures.Where(s => (s.OwningPlayerId != null || s.TargetingTeam != null))
                                       .GroupBy(g => g.ClassName)
                                       .Select(s => s.Key);


            lstStructureFilter.Items.Clear();
            foreach (var className in playerStructureTypes)
            {
                var structureName         = className;
                StructureClassMap itemMap = Program.ProgramConfig.StructureMap.Where(i => i.ClassName == className).FirstOrDefault();
                if (itemMap != null && itemMap.FriendlyName.Length > 0)
                {
                    structureName = itemMap.FriendlyName;
                }

                if (className.ToLower().Contains(txtFilter.Text.ToLower()) || structureName.ToLower().Contains(txtFilter.Text.ToLower()))
                {
                    int newIndex = lstStructureFilter.Items.Add(new ComboValuePair()
                    {
                        Key = className, Value = structureName
                    });
                    lstStructureFilter.SetItemChecked(newIndex, Program.ProgramConfig.StructureExclusions.Contains(className));
                }
            }

            //add rafts
            int itemIndex = lstStructureFilter.Items.Add(new ComboValuePair()
            {
                Key = "Raft_BP_C", Value = "Raft"
            });

            lstStructureFilter.SetItemChecked(itemIndex, Program.ProgramConfig.StructureExclusions.Contains("Raft_BP_C"));

            itemIndex = lstStructureFilter.Items.Add(new ComboValuePair()
            {
                Key = "MotorRaft_BP_C", Value = "Motorboat"
            });
            lstStructureFilter.SetItemChecked(itemIndex, Program.ProgramConfig.StructureExclusions.Contains("MotorRaft_BP_C"));

            lstStructureFilter.Sorted = true;
        }
コード例 #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();
            }
        }