Beispiel #1
0
        // Inventory Tab
        /// <summary>
        /// Gets a list of SSCInventoryLog entries. 
        /// </summary>
        public SSCInventory GetSSCInventory(int account)
        {
            JArray inventory;
            String inventoryList;
            Color hairColor;
            Color pantsColor;
            Color shirtColor;
            Color underShirtColor;
            Color shoeColor;
            Color skinColor;
            Color eyeColor;
            int hair = 0;
            int hairDye = 0;
            bool isPlaying = false;
            int health = 0;
            int maxHealth = 0;
            int mana = 0;
            int maxMana = 0;
            int questsCompleted = 0;

            SSCInventory SSCInventory = new SSCInventory();
            SSCInventory.Inventory = "";
            hairColor = Color.Black;
            pantsColor = Color.Black;
            shirtColor = Color.Black;
            underShirtColor = Color.Black;
            shoeColor = Color.Black;
            skinColor = Color.Black;
            eyeColor = Color.Black;
            inventoryList = "";
            inventoryUpdateStatus.Text = "";
            inventoryPreviewImage0 = true;

            // And now use this to connect server
            JObject results = ru.communicateWithTerraria("AdminREST/getinventory", "account=" + account);
            string status = (string)results["status"];
            if (status.Equals("200"))
            {
                try
                {
                    inventory = (JArray)results["inventory"];
                    JObject innerObj = (JObject)inventory[0];
                    inventoryList = (String)innerObj["Inventory"];
                    JObject colorObj = null;
                    colorObj = (JObject)innerObj["SkinColor"];
                    skinColor = Color.FromArgb((int)colorObj["A"], (int)colorObj["R"], (int)colorObj["G"], (int)colorObj["B"]);
                    colorObj = (JObject)innerObj["HairColor"];
                    hairColor = Color.FromArgb((int)colorObj["A"], (int)colorObj["R"], (int)colorObj["G"], (int)colorObj["B"]);
                    colorObj = (JObject)innerObj["PantsColor"];
                    pantsColor = Color.FromArgb((int)colorObj["A"], (int)colorObj["R"], (int)colorObj["G"], (int)colorObj["B"]);
                    colorObj = (JObject)innerObj["ShirtColor"];
                    shirtColor = Color.FromArgb((int)colorObj["A"], (int)colorObj["R"], (int)colorObj["G"], (int)colorObj["B"]);
                    colorObj = (JObject)innerObj["UnderShirtColor"];
                    underShirtColor = Color.FromArgb((int)colorObj["A"], (int)colorObj["R"], (int)colorObj["G"], (int)colorObj["B"]);
                    colorObj = (JObject)innerObj["ShoeColor"];
                    shoeColor = Color.FromArgb((int)colorObj["A"], (int)colorObj["R"], (int)colorObj["G"], (int)colorObj["B"]);
                    colorObj = (JObject)innerObj["EyeColor"];
                    eyeColor = Color.FromArgb((int)colorObj["A"], (int)colorObj["R"], (int)colorObj["G"], (int)colorObj["B"]);
                    isPlaying = (Boolean)innerObj["IsPlaying"];
                    health = (int)innerObj["Health"];
                    maxHealth = (int)innerObj["MaxHealth"];
                    mana = (int)innerObj["Mana"];
                    maxMana = (int)innerObj["MaxMana"];
                    questsCompleted = (int)innerObj["QuestsCompleted"];
                }
                catch (NullReferenceException)
                {
                    inventoryList = "0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~";
                }
                catch (InvalidCastException)
                {
                    inventoryList = "0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~0,0,0~";
                }
            }
            SSCInventory = new SSCInventory(account, health, maxHealth, mana, maxMana, questsCompleted, inventoryList, hair, hairDye, hairColor, pantsColor, shirtColor, underShirtColor, shoeColor, skinColor, eyeColor, isPlaying);
            return SSCInventory;
        }
Beispiel #2
0
        private void inventoryImport_Click(object sender, EventArgs e)
        {
            Color hairColor;
            Color pantsColor;
            Color shirtColor;
            Color underShirtColor;
            Color shoeColor;
            Color skinColor;
            Color eyeColor;
            int hair = 0;
            int hairDye = 0;
            int account = -1;
            bool isPlaying = false;
            int health = 0;
            int maxHealth = 0;
            int mana = 0;
            int maxMana = 0;
            int questsCompleted = 0;

            // Create an instance of the open file dialog box.
            OpenFileDialog playerFile = new OpenFileDialog();

            // Set filter options and filter index.
            playerFile.Filter = "Player Files (.plr)|*.plr|All Files (*.*)|*.*";
            playerFile.FilterIndex = 1;

            playerFile.Multiselect = false;

            // Call the ShowDialog method to show the dialog box.
            DialogResult response = playerFile.ShowDialog();

            // Process input if the user clicked OK.
            if (response == DialogResult.OK)
            {

                Player p = new Player(playerFile.FileName);
                p.LoadPlayer(playerFile.FileName);
                inputFromImport = true;
                int i = 0;

                hairColor = Color.FromArgb(p.Colors[i].R, p.Colors[i].G, p.Colors[i++].B);
                skinColor = Color.FromArgb(p.Colors[i].R, p.Colors[i].G, p.Colors[i++].B);
                eyeColor = Color.FromArgb(p.Colors[i].R, p.Colors[i].G, p.Colors[i++].B);
                shirtColor = Color.FromArgb(p.Colors[i].R, p.Colors[i].G, p.Colors[i++].B);
                underShirtColor = Color.FromArgb(p.Colors[i].R, p.Colors[i].G, p.Colors[i++].B);
                pantsColor = Color.FromArgb(p.Colors[i].R, p.Colors[i].G, p.Colors[i++].B);
                shoeColor = Color.FromArgb(p.Colors[i].R, p.Colors[i].G, p.Colors[i++].B);
                isPlaying = false;
                health = p.CurrentLife;
                maxHealth = p.MaxLife;
                mana = p.CurrentMana;
                maxMana = p.MaxMana;
                questsCompleted = p.AnglerQuestsFinished;

                string inventoryList = "";
                string sep = "";

                for (int j = 0; j < p.inv.Length; j++)
                {
                    inventoryList = inventoryList + sep + p.inv[j].NetId + "," + p.inv[j].StackSize + "," + p.inv[j].Prefix;
                    sep = "~";
                }
                for (int j = 0; j < p.armor.Length; j++)
                    inventoryList = inventoryList + sep + p.armor[j].NetId + "," + 1 + "," + p.armor[j].Prefix;

                for (int j = 0; j < p.accessories.Length; j++)
                    inventoryList = inventoryList + sep + p.accessories[j].NetId + "," + 1 + "," + p.accessories[j].Prefix;

                for (int j = 0; j < p.vanity.Length; j++)
                    inventoryList = inventoryList + sep + p.vanity[j].NetId + "," + 1 + "," + p.vanity[j].Prefix;

                for (int j = 0; j < p.socialAccessories.Length; j++)
                    inventoryList = inventoryList + sep + p.socialAccessories[j].NetId + "," + 1 + "," + p.socialAccessories[j].Prefix;

                for (int j = 0; j < p.dye.Length; j++)
                    inventoryList = inventoryList + sep + p.dye[j].NetId + "," + 1 + "," + p.dye[j].Prefix;
                SSCInventory = new SSCInventory(account, p.CurrentLife, p.MaxLife, p.CurrentMana, p.MaxMana, p.AnglerQuestsFinished, inventoryList, hair, hairDye, hairColor, pantsColor, shirtColor, underShirtColor, shoeColor, skinColor, eyeColor, isPlaying);
                getInventory();
            }
        }
Beispiel #3
0
        private void getInventory()
        {
            if (!playerFound)
            {
                return;
            }
            DataGridViewRow selectedRow = usersDataList.CurrentRow;
            string name = selectedRow.Cells[0].Value.ToString();
            int account = Int32.Parse(selectedRow.Cells[5].Value.ToString());
            if (!inputFromImport)
                SSCInventory = GetSSCInventory(account);
            inventoryUpdate.Enabled = true;
            if (SSCInventory.IsPlaying)
            {
                sscAccountName.Text = name + " [Player Active]";
                inventoryUpdate.Enabled = false;
            }
            else
                sscAccountName.Text = name;

            inventoryUpdateStatus.Text = "";
            itemPreview.Image = item_0;
            itemPreview.Text = "";
            itemPreviewText.Text = "";
            txtStackSize.Text = "";

            inventoryToolTip.SetToolTip(itemPreview, "");
            inventoryPreviewNetId = 0;
            inventoryPrefixIndex = 0;
            inventoryPreviewImage0 = true;

            string[] inventory = SSCInventory.Inventory.Split('~');
            for (int i = 0; i < slotItems.Length; i++)
                slotItems[i] = new Item();

            SetSSCInventorySlot(this, "sscItem", inventory);

            sscHairColor.BackColor = getColor(SSCInventory.HairColor);
            ToolTipColor(sscHairColor, SSCInventory.HairColor);
            sscEyeColor.BackColor = getColor(SSCInventory.EyeColor);
            ToolTipColor(sscEyeColor, SSCInventory.EyeColor);
            sscSkinColor.BackColor = getColor(SSCInventory.SkinColor);
            ToolTipColor(sscSkinColor, SSCInventory.SkinColor);
            sscShirtColor.BackColor = getColor(SSCInventory.ShirtColor);
            ToolTipColor(sscShirtColor, SSCInventory.ShirtColor);
            sscUnderShirtColor.BackColor = getColor(SSCInventory.UnderShirtColor);
            ToolTipColor(sscUnderShirtColor, SSCInventory.UnderShirtColor);
            sscPantsColor.BackColor = getColor(SSCInventory.PantsColor);
            ToolTipColor(sscPantsColor, SSCInventory.PantsColor);
            sscShoesColor.BackColor = getColor(SSCInventory.ShoeColor);
            ToolTipColor(sscShoesColor, SSCInventory.ShoeColor);

            txtHealth.Text = SSCInventory.Health.ToString();
            txtMaxHealth.Text = SSCInventory.MaxHealth.ToString();
            txtMana.Text = SSCInventory.Mana.ToString();
            txtMaxMana.Text = SSCInventory.MaxMana.ToString();
            txtQuestsCompleted.Text = SSCInventory.QuestsCompleted.ToString();
        }