示例#1
0
        public VoidVaultEditor(GameContext Context, Form ParentForm, Player TargetPlayer, bool Editable)
            : base(Context, ParentForm, TargetPlayer, TargetPlayer.Bank4.Item, Editable, TargetPlayer.Bank4.Item.Length)
        {
            Text = MainForm.CurrentLanguage["VoidVault"];
            SlotsPanel.Location = new Point(0, 30);


            Button OK = new Button();

            OK.Enabled = Editable;
            OK.Click  += (sender, e) =>
            {
                ApplyItemData(Selected);
                InitItemData(Selected);
                RefreshSelected();
            };
            OK.FlatStyle = FlatStyle.Flat;
            OK.Text      = MainForm.CurrentLanguage["Confirm"];
            OK.Size      = new Size(80, 30);
            OK.Location  = new Point(260, 0);
            ItemPropertiesPanel.Controls.Add(OK);


            Button Refresh = new Button();

            Refresh.Click += (sender, e) =>
            {
                InitItemData(Selected);
                SlotsPanel.Refresh();
            };
            Refresh.FlatStyle = FlatStyle.Flat;
            Refresh.Text      = MainForm.CurrentLanguage["Refresh"];
            Refresh.Size      = new Size(80, 30);
            Refresh.Location  = new Point(260, 30);
            ItemPropertiesPanel.Controls.Add(Refresh);


            Button InitItem = new Button();

            InitItem.Enabled = Editable;
            InitItem.Click  += (sender, e) =>
            {
                Item item = TargetItemSlots[Selected];
                item.SetDefaults(Convert.ToInt32(((TextBox)ItemPropertiesPanel.Hack["Type"]).Text));
                item.SetPrefix(GetPrefixFromIndex(ItemPropertiesPanel.SelectedPrefix));
                int stack = Convert.ToInt32(((TextBox)ItemPropertiesPanel.Hack["Stack"]).Text);
                item.Stack = stack == 0 ? 1 : stack;
                RefreshSelected();
                InitItemData(Selected);
            };
            InitItem.FlatStyle = FlatStyle.Flat;
            InitItem.Text      = MainForm.CurrentLanguage["Init"];
            InitItem.Size      = new Size(80, 30);
            InitItem.Location  = new Point(260, 60);
            ItemPropertiesPanel.Controls.Add(InitItem);
        }
示例#2
0
        public InvEditor(GameContext Context, Form ParentForm, Player TargetPlayer, bool Editable) : base(Context, ParentForm, TargetPlayer, TargetPlayer.Inventory, Editable, Player.ITEM_MAX_COUNT - 9)
        {
            Text = MainForm.CurrentLanguage["Inventory"];



            Button OK = new Button();

            OK.Enabled = Editable;
            OK.Click  += (sender, e) =>
            {
                ApplyItemData(Selected);
                InitItemData(Selected);
                RefreshSelected();
            };
            OK.FlatStyle = FlatStyle.Flat;
            OK.Text      = MainForm.CurrentLanguage["Confirm"];
            OK.Size      = new Size(80, 30);
            OK.Location  = new Point(260, 0);
            ItemPropertiesPanel.Controls.Add(OK);


            Button Refresh = new Button();

            Refresh.Click += (sender, e) =>
            {
                InitItemData(Selected);
                SlotsPanel.Refresh();
            };
            Refresh.FlatStyle = FlatStyle.Flat;
            Refresh.Text      = MainForm.CurrentLanguage["Refresh"];
            Refresh.Size      = new Size(80, 30);
            Refresh.Location  = new Point(260, 30);
            ItemPropertiesPanel.Controls.Add(Refresh);


            Button SaveInv = new Button();

            SaveInv.Click += (sender, e) =>
            {
                SaveFileDialog sfd = new SaveFileDialog()
                {
                    Filter = "inv files (*.inv)|*.inv",
                };
                if (!Directory.Exists("./invs"))
                {
                    Directory.CreateDirectory("./invs");
                }
                sfd.InitialDirectory = Path.GetFullPath("./invs");
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    SaveInventory(sfd.FileName);
                    SlotsPanel.Refresh();
                }
            };
            SaveInv.FlatStyle = FlatStyle.Flat;
            SaveInv.Text      = MainForm.CurrentLanguage["Save"];
            SaveInv.Size      = new Size(80, 30);
            SaveInv.Location  = new Point(260, 60);
            ItemPropertiesPanel.Controls.Add(SaveInv);

            Button LoadInv = new Button();

            LoadInv.Enabled = Editable;
            LoadInv.Click  += (sender, e) =>
            {
                OpenFileDialog ofd = new OpenFileDialog()
                {
                    Filter = "inv files (*.inv)|*.inv"
                };
                if (!Directory.Exists("./invs"))
                {
                    Directory.CreateDirectory("./invs");
                }
                ofd.InitialDirectory = Path.GetFullPath("./invs");
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    LoadInventory(ofd.FileName);
                    SlotsPanel.Refresh();
                    InitItemData(Selected);
                }
            };
            LoadInv.FlatStyle = FlatStyle.Flat;
            LoadInv.Text      = MainForm.CurrentLanguage["Load"];
            LoadInv.Size      = new Size(80, 30);
            LoadInv.Location  = new Point(260, 90);
            ItemPropertiesPanel.Controls.Add(LoadInv);

            Button SaveInvPItem = new Button();

            SaveInvPItem.Enabled = Editable;
            SaveInvPItem.Click  += (sender, e) =>
            {
                SaveFileDialog sfd = new SaveFileDialog()
                {
                    Filter = "inv files (*.invp)|*.invp"
                };
                if (!Directory.Exists("./invs"))
                {
                    Directory.CreateDirectory("./invs");
                }
                sfd.InitialDirectory = Path.GetFullPath("./invs");
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    File.WriteAllText(sfd.FileName, TargetPlayer.SerializeInventoryWithProperties());
                    SlotsPanel.Refresh();
                }
            };
            SaveInvPItem.FlatStyle = FlatStyle.Flat;
            SaveInvPItem.Text      = $"{MainForm.CurrentLanguage["Save"]}(P)";
            SaveInvPItem.Size      = new Size(80, 30);
            SaveInvPItem.Location  = new Point(260, 120);
            ItemPropertiesPanel.Controls.Add(SaveInvPItem);

            Button LoadInvPItem = new Button();

            LoadInvPItem.Enabled = Editable;
            LoadInvPItem.Click  += (sender, e) =>
            {
                OpenFileDialog ofd = new OpenFileDialog()
                {
                    Filter = "inv files (*.invp)|*.invp"
                };
                if (!Directory.Exists("./invs"))
                {
                    Directory.CreateDirectory("./invs");
                }
                ofd.InitialDirectory = Path.GetFullPath("./invs");
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    int         j = 0;
                    Form        p = new Form();
                    ProgressBar pb = new ProgressBar();
                    Label       tip = new Label(), percent = new Label();
                    tip.Text          = "Loading inventory...";
                    tip.Location      = new Point(0, 0);
                    tip.Size          = new Size(150, 30);
                    tip.TextAlign     = ContentAlignment.MiddleCenter;
                    percent.Location  = new Point(150, 0);
                    percent.Size      = new Size(30, 30);
                    percent.TextAlign = ContentAlignment.MiddleCenter;
                    System.Timers.Timer timer = new System.Timers.Timer(1);
                    p.FormBorderStyle = FormBorderStyle.FixedSingle;
                    p.ClientSize      = new Size(300, 60);
                    p.ControlBox      = false;
                    pb.Location       = new Point(0, 30);
                    pb.Size           = new Size(300, 30);
                    pb.Maximum        = 2;
                    pb.Minimum        = 0;
                    pb.Value          = 0;
                    p.Controls.Add(tip);
                    p.Controls.Add(percent);
                    p.Controls.Add(pb);
                    timer.Elapsed += (sender1, e1) =>
                    {
                        pb.Value     = j;
                        percent.Text = pb.Value + "/" + pb.Maximum;
                        if (j >= pb.Maximum)
                        {
                            p.Dispose();
                        }
                    };
                    timer.Start();
                    p.Show();
                    p.Location = new System.Drawing.Point(ParentForm.Location.X + ParentForm.Width / 2 - p.ClientSize.Width / 2, ParentForm.Location.Y + ParentForm.Height / 2 - p.ClientSize.Height / 2);
                    new System.Threading.Thread((s) =>
                    {
                        j++;

                        TargetPlayer.DeserializeInventoryWithProperties(File.ReadAllText(ofd.FileName));
                        InitItemData(Selected);
                        j++;
                    }
                                                ).Start();
                }
            };
            LoadInvPItem.FlatStyle = FlatStyle.Flat;
            LoadInvPItem.Text      = $"{MainForm.CurrentLanguage["Load"]}(P)";
            LoadInvPItem.Size      = new Size(80, 30);
            LoadInvPItem.Location  = new Point(260, 150);
            ItemPropertiesPanel.Controls.Add(LoadInvPItem);

            Button InitItem = new Button();

            InitItem.Enabled = Editable;
            InitItem.Click  += (sender, e) =>
            {
                Item item = TargetPlayer.Inventory[Selected];
                item.SetDefaults(Convert.ToInt32(((TextBox)ItemPropertiesPanel.Hack["Type"]).Text));
                item.SetPrefix(GetPrefixFromIndex(ItemPropertiesPanel.SelectedPrefix));
                int stack = Convert.ToInt32(((TextBox)ItemPropertiesPanel.Hack["Stack"]).Text);
                item.Stack = stack == 0 ? 1 : stack;
                RefreshSelected();
                InitItemData(Selected);
            };
            InitItem.FlatStyle = FlatStyle.Flat;
            InitItem.Text      = MainForm.CurrentLanguage["Init"];
            InitItem.Size      = new Size(80, 30);
            InitItem.Location  = new Point(260, 180);
            ItemPropertiesPanel.Controls.Add(InitItem);

            SlotsPanel.ItemSlots[0].Selected = true;
            InitItemData(0);
        }
示例#3
0
        public ItemSlotsEditor(GameContext Context, Form ParentForm, Player TargetPlayer, ItemSlots TargetItemSlots, bool Editable, int Count)
        {
            this.Context         = Context;
            this.ParentForm      = ParentForm;
            this.TargetPlayer    = TargetPlayer;
            this.TargetItemSlots = TargetItemSlots;
            this.Editable        = Editable;


            ItemPropertiesPanel          = new ItemPropertiesPanel();
            ItemPropertiesPanel.Location = new Point(10 * (SlotsPanel.SlotsWidth + SlotsPanel.SlotsGap) + 15, 10);
            this.Controls.Add(ItemPropertiesPanel);


            ContextMenuStrip cms = new ContextMenuStrip();

            cms.Items.Add(MainForm.CurrentLanguage["Copy"]);
            cms.Items.Add(MainForm.CurrentLanguage["Paste"]);
            cms.ItemClicked += (sender, e) =>
            {
                var item = TargetItemSlots[Selected];
                if (e.ClickedItem.Text == MainForm.CurrentLanguage["Copy"])
                {
                    Clip_ItemType   = item.Type;
                    Clip_ItemStack  = item.Stack;
                    Clip_ItemPrefix = item.Prefix;
                    RefreshSelected();
                }
                else if (e.ClickedItem.Text == MainForm.CurrentLanguage["Paste"])
                {
                    if (Clip_ItemType != 0)
                    {
                        item.SetDefaultsAndPrefix(Clip_ItemType, Clip_ItemPrefix);
                        item.Stack = Clip_ItemStack;
                    }
                    RefreshSelected();
                }
            };

            SlotsPanel = new SlotsPanel(Context, TargetItemSlots, Count);
            SlotsPanel.OnItemSlotClick += (sender, e) =>
            {
                foreach (var s in SlotsPanel.ItemSlots)
                {
                    s.Selected = false;
                }
                sender.Selected = true;
                SlotsPanel.Refresh();
                Selected = sender.Number;
                InitItemData(Selected);
                if (e.Button == MouseButtons.Right && Editable)
                {
                    cms.Show(sender, e.Location.X, e.Location.Y);
                }
            };
            this.Controls.Add(SlotsPanel);


            SlotsPanel.ItemSlots[0].Selected = true;
            InitItemData(0);

            Timer = new Timer()
            {
                Interval = 500
            };
            Timer.Tick += (sender, e) =>
            {
                if (Enabled)
                {
                    SlotsPanel.Refresh();
                    Item item = TargetItemSlots[Selected];
                    if (LastSelectedID != item.Type)
                    {
                        InitItemData(Selected);
                        LastSelectedID = item.Type;
                    }
                }
            };
            Timer.Start();
        }