예제 #1
0
파일: Menu.cs 프로젝트: xKirtle/Loadouts
        public static void Click(int index)
        {
            ELPlayer mp = Main.LocalPlayer.GetModPlayer <ELPlayer>();

            //Don't want the delete request to be on hold if player clicks somewhere else
            if (index != 0)
            {
                ConfirmDelete.deleteRequest = false;
            }

            switch (index)
            {
            case 0:     //Minus
                if (!ConfirmDelete.deleteRequest && mp.loadouts.Count > 1)
                {
                    Main.PlaySound(SoundID.MenuTick);
                    Main.NewText("Are you sure you want to remove this loadout? Type \"/confirm\" to remove it.", Color.Red);
                    ConfirmDelete.deleteRequest = true;
                }

                break;

            case 1:     //Left
                if (mp.loadoutIndex > 0)
                {
                    Main.PlaySound(SoundID.MenuTick);
                    mp.loadouts[mp.loadoutIndex].SaveLoadout();
                    mp.loadouts[--mp.loadoutIndex].LoadLoadout();
                }

                break;

            case 2:     //Right
                if (mp.loadoutIndex < mp.loadouts.Count - 1)
                {
                    Main.PlaySound(SoundID.MenuTick);
                    mp.loadouts[mp.loadoutIndex].SaveLoadout();
                    mp.loadouts[++mp.loadoutIndex].LoadLoadout();
                }

                break;

            case 3:     //Plus
                if (mp.loadouts.Count < maxLoadouts)
                {
                    Main.PlaySound(SoundID.MenuTick);
                    mp.loadouts[mp.loadoutIndex].SaveLoadout();

                    Loadout loadout = new Loadout();
                    mp.loadouts.Add(loadout);
                    mp.loadoutIndex = mp.loadouts.Count - 1;

                    mp.loadouts[mp.loadoutIndex].LoadLoadout();
                }

                break;
            }
        }
예제 #2
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (deleteRequest)
            {
                ELPlayer mp = Main.LocalPlayer.GetModPlayer <ELPlayer>();
                mp.loadouts[mp.loadoutIndex].DropLoadout();
                mp.loadouts.RemoveAt(mp.loadoutIndex);
                mp.loadoutIndex -= mp.loadoutIndex < mp.loadouts.Count ? 0 : 1;
                mp.loadouts[mp.loadoutIndex].LoadLoadout();
                deleteRequest = false;

                Main.NewText("Loadout removed succesfully.", Color.Green);
            }
        }