Exemple #1
0
        public void InitScenarioSaveList()
        {
            pageIndex = pageIndex1 = 1;

            btScenarioSelectList = new List <ButtonTexture>();

            btScenarioPlayersList = new List <ButtonTexture>();

            ScenarioList = GameScenario.LoadScenarioSaves();

            CurrentScenario = null;

            foreach (var sce in ScenarioList)
            {
                var btOne = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", null)
                {
                    ID = sce.Name
                };
                btOne.OnButtonPress += (sender, e) =>
                {
                    string id = ((ButtonTexture)sender).ID;

                    btScenarioSelectList.ForEach(bt => bt.Selected = false);

                    ((ButtonTexture)sender).Selected = true;

                    CurrentScenario = ScenarioList.FirstOrDefault(sc => sc.Name == id);

                    //pageIndex = 1;
                };
                btScenarioSelectList.Add(btOne);
            }
        }
Exemple #2
0
        public DateRunner()
        {
            btChangeDays                = new ButtonTexture(@"Content\Textures\Resources\Start\Setting", "Setting", null);
            btChangeDays.Scale          = 0.8f;
            btChangeDays.OnButtonPress += (sender, e) =>
            {
                GameDelegates.VoidFunction function = null;

                Session.MainGame.mainGameScreen.Plugins.NumberInputerPlugin.SetMax(MAX_DAY);
                Session.MainGame.mainGameScreen.Plugins.NumberInputerPlugin.SetMapPosition(ShowPosition.Center);
                Session.MainGame.mainGameScreen.Plugins.NumberInputerPlugin.SetDepthOffset(-0.01f);
                if (function == null)
                {
                    function = delegate
                    {
                        var number = Session.MainGame.mainGameScreen.Plugins.NumberInputerPlugin.Number;
                        if (number < 1)
                        {
                            number = 1;
                        }
                        DaysToGo     = number;
                        this.Updated = false;
                    };
                }
                Session.MainGame.mainGameScreen.Plugins.NumberInputerPlugin.SetEnterFunction(function);
                Session.MainGame.mainGameScreen.Plugins.NumberInputerPlugin.IsShowing = true;
            };
        }
Exemple #3
0
        // to do: debugmode, stat

        public override void Load()
        {
            // Since we are using hooks not in older versions, and since ItemID.Count changed, we need to do this.
            if (ModLoader.version < new Version(0, 10, 1, 3))
            {
                throw new Exception("\nThis mod uses functionality only present in the latest tModLoader. Please update tModLoader to use this mod\n\n");
            }
            instance = this;

            ButtonClicked.Clear();
            ButtonTexture.Clear();
            ButtonTooltip.Clear();

            ToggleCheatSheetHotbarHotKey = RegisterHotKey("Toggle Cheat Sheet Hotbar", "K");

            if (Main.rand == null)
            {
                Main.rand = new Terraria.Utilities.UnifiedRandom();
            }

            FieldInfo translationsField = typeof(Mod).GetField("translations", BindingFlags.Instance | BindingFlags.NonPublic);

            translations = (Dictionary <string, ModTranslation>)translationsField.GetValue(this);
            //LoadTranslations();
        }
Exemple #4
0
        // to do: debugmode, stat

        public override void Load()
        {
            // Since we are using hooks not in older versions, and since ItemID.Count changed, we need to do this.
            if (ModLoader.version < new Version(0, 10))
            {
                throw new Exception("\nThis mod uses functionality only present in the latest tModLoader. Please update tModLoader to use this mod\n\n");
            }
            instance = this;

            ButtonClicked.Clear();
            ButtonTexture.Clear();
            ButtonTooltip.Clear();

            ToggleCheatSheetHotbarHotKey = RegisterHotKey("Toggle Cheat Sheet Hotbar", "K");

            if (Main.rand == null)
            {
                Main.rand = new Terraria.Utilities.UnifiedRandom();
            }

            ModTranslation text = CreateTranslation("ButcherNotification");

            text.SetDefault("NPCs were butchered by {0}");
            AddTranslation(text);
            text = CreateTranslation("VacuumNotification");
            text.SetDefault("Items on the ground were vacuumed by {0}");
            AddTranslation(text);
            text = CreateTranslation("SpawnNPCNotification");
            text.SetDefault("Spawned {0} by {1}");
            AddTranslation(text);
            text = CreateTranslation("VolcanoWarning");
            text.SetDefault("Did you hear something....A Volcano! Find Cover!");
            AddTranslation(text);
        }
Exemple #5
0
 public void RegisterButton(Texture2D texture, Action buttonClickedAction, Func <string> tooltip)
 {
     ButtonClicked.Add(buttonClickedAction);
     ButtonTexture.Add(texture);
     ButtonTooltip.Add(tooltip);
     //ErrorLogger.Log("1 "+ButtonClicked.Count);
     //ErrorLogger.Log("2 "+ ButtonTexture.Count);
     //ErrorLogger.Log("3 "+ ButtonTooltip.Count);
 }
Exemple #6
0
        public override void Unload()
        {
            ButtonClicked.Clear();
            ButtonTexture.Clear();
            ButtonTooltip.Clear();

            GenericItemSlot.backgroundTexture     = null;
            NPCSlot.backgroundTexture             = null;
            NPCSlot.filteredBackgroundTexture     = null;
            RecipeQuerySlot.backgroundTexture     = null;
            RecipeQuerySlot.backgroundTextureFake = null;
            RecipeSlot.backgroundTexture          = null;
            RecipeSlot.selectedBackgroundTexture  = null;
            Slot.backgroundTexture          = null;
            PaintToolsSlot.CurrentSelect    = null;
            AllItemsMenu.singleSlotArray    = null;
            UI.UICheckbox.checkboxTexture   = null;
            UI.UICheckbox.checkmarkTexture  = null;
            UI.UIScrollBar.ScrollbarTexture = null;
            UI.UIScrollView.ScrollbgTexture = null;
            UI.UITextbox.textboxBackground  = null;
            //UI.UIView.closeTexture = null;
            ItemBrowser.bCategories         = null;
            RecipeBrowserWindow.ingredients = null;
            RecipeBrowserWindow.bCategories = null;
            NPCBrowser.tooltipNpc           = null;
            NPCBrowser.hoverNpc             = null;
            NPCBrowser.bCategories          = null;
            if (itemBrowser != null)
            {
                itemBrowser.itemView = null;
            }
            itemBrowser   = null;
            npcBrowser    = null;
            recipeBrowser = null;
            if (hotbar != null)
            {
                hotbar.buttonView?.RemoveAllChildren();
                hotbar.buttonView = null;
                hotbar            = null;
            }
            instance = null;
            ToggleCheatSheetHotbarHotKey          = null;
            RecipeBrowserWindow.recipeView        = null;
            RecipeBrowserWindow.lookupItemSlot    = null;
            ConfigurationTool.cheatSheet          = null;
            ConfigurationTool.configurationWindow = null;
            Hotbar.loginTexture        = null;
            Hotbar.logoutTexture       = null;
            ConfigurationTool.button   = null;
            SpawnRateMultiplier.button = null;
            MinionSlotBooster.button   = null;
            LightHack.button           = null;
            GodMode.button             = null;
        }
Exemple #7
0
        public BackTool()
        {
            btBack = new ButtonTexture(@"Content\Textures\Resources\Start\Back", "Back", null);
            btBack.OnButtonPress += (sender, e) =>
            {
                var architectureDetail = Session.MainGame.mainGameScreen.Plugins.ArchitectureDetailPlugin;
                var personDetail       = Session.MainGame.mainGameScreen.Plugins.PersonDetailPlugin;
                var treasureDetail     = Session.MainGame.mainGameScreen.Plugins.TreasureDetailPlugin;
                var factionTech        = Session.MainGame.mainGameScreen.Plugins.FactionTechniquesPlugin;
                var optionDialog       = Session.MainGame.mainGameScreen.Plugins.OptionDialogPlugin as OptionDialogPlugin.OptionDialogPlugin;
                var troopDetail        = Session.MainGame.mainGameScreen.Plugins.TroopDetailPlugin;
                var createTroop        = Session.MainGame.mainGameScreen.Plugins.CreateTroopPlugin;
                var transPort          = Session.MainGame.mainGameScreen.Plugins.TransportDialogPlugin;
                var numberInputer      = Session.MainGame.mainGameScreen.Plugins.NumberInputerPlugin;

                if (architectureDetail.IsShowing)
                {
                    architectureDetail.IsShowing = false;
                }
                else if (personDetail.IsShowing)
                {
                    personDetail.IsShowing = false;
                }
                else if (treasureDetail.IsShowing)
                {
                    treasureDetail.IsShowing = false;
                }
                else if (factionTech.IsShowing)
                {
                    factionTech.IsShowing = false;
                }
                else if (optionDialog.IsShowing)
                {
                    optionDialog.IsShowing = false;
                }
                else if (troopDetail.IsShowing)
                {
                    troopDetail.IsShowing = false;
                }
                else if (createTroop.IsShowing)
                {
                    createTroop.IsShowing = false;
                }
                else if (numberInputer.IsShowing)
                {
                    numberInputer.IsShowing = false;
                }
                else if (transPort.IsShowing)
                {
                    transPort.IsShowing = false;
                }
            };
        }
Exemple #8
0
        // to do: debugmode, stat

        public override void Load()
        {
            // Since we are using hooks not in older versions, and since ItemID.Count changed, we need to do this.
            if (ModLoader.version < new Version(0, 11, 5))
            {
                throw new Exception("\nThis mod uses functionality only present in the latest tModLoader. Please update tModLoader to use this mod\n\n");
            }
            instance = this;

            ButtonClicked.Clear();
            ButtonTexture.Clear();
            ButtonTooltip.Clear();

            ToggleCheatSheetHotbarHotKey = RegisterHotKey("Toggle Cheat Sheet Hotbar", "K");

            if (Main.rand == null)
            {
                Main.rand = new Terraria.Utilities.UnifiedRandom();
            }

            FieldInfo translationsField = typeof(Mod).GetField("translations", BindingFlags.Instance | BindingFlags.NonPublic);

            translations = (Dictionary <string, ModTranslation>)translationsField.GetValue(this);
            //LoadTranslations();

            // set all to true on load
            herosPermissions[PaintTools_Permission] = true;
            herosPermissions[ModifySpawnRateMultiplier_Permission] = true;
            herosPermissions[RecipeBrowser_Permission]             = true;
            herosPermissions[MinionBooster_Permission]             = true;
            herosPermissions[ClearItemNPCProjectile_Permission]    = true;
            herosPermissions[ExtraAccessories_Permission]          = true;
            herosPermissions[Vacuum_Permission]               = true;
            herosPermissions[NPCButcher_Permission]           = true;
            herosPermissions[CheatSheetExtensions_Permission] = true;
            herosPermissions[QuickTeleport_Permission]        = true;

            GenericItemSlot.backgroundTexture     = Main.inventoryBack9Texture;
            NPCSlot.backgroundTexture             = Main.inventoryBack9Texture;
            NPCSlot.filteredBackgroundTexture     = Main.inventoryBack5Texture;
            RecipeQuerySlot.backgroundTexture     = Main.inventoryBack9Texture;
            RecipeQuerySlot.backgroundTextureFake = Main.inventoryBack8Texture;
            RecipeSlot.backgroundTexture          = Main.inventoryBack9Texture;
            RecipeSlot.selectedBackgroundTexture  = Main.inventoryBack15Texture;
            Slot.backgroundTexture = Main.inventoryBack9Texture;
        }
Exemple #9
0
        //Button with text
        public Button(Rectangle buttonBounds, ButtonTexture buttonTexture, Text text, bool center = false)
        {
            if (center)
            {
                ButtonBounds = new Rectangle(buttonBounds.X - (buttonBounds.Width / 2), buttonBounds.Y - (buttonBounds.Height / 2), buttonBounds.Width, buttonBounds.Height);
            }
            else
            {
                ButtonBounds = new Rectangle(buttonBounds.X, buttonBounds.Y, buttonBounds.Width, buttonBounds.Height);
            }

            TextBox = new TextBox(text, ButtonBounds);
            TextBox.LineAlignment = Alignment.Center;
            TextBox.Alignment     = Alignment.Center;
            TextBox.IgnoreHeight  = true;
            TextBox.Padding       = new Rectangle(0, 0, 0, 0);

            this.buttonTexture = buttonTexture;
        }
Exemple #10
0
 //Textless button
 public TextureButton(Rectangle buttonBounds, ButtonTexture buttonTexture)
     : base(buttonBounds)
 {
     this.buttonTexture = buttonTexture;
 }
Exemple #11
0
        void InitScenarioList()
        {
            string path = @"Content\Data\Scenario\";

            string file = path + "Scenarios.json";

            pageIndex = pageIndex1 = 1;

            CurrentScenario = null;

            btScenarioSelectList = new List <ButtonTexture>();

            btScenarioPlayersList = new List <ButtonTexture>();

            ScenarioList = SimpleSerializer.DeserializeJsonFile <List <Scenario> >(file, false, false, false);
            //var str = SimpleSerializer.SerializeJson(ScenarioList, false, true, true);

            foreach (var sce in ScenarioList)
            {
                //var path0 = @"Content\Data\Scenario\" + sce.Name + ".json";

                //var str = Platform.Current.LoadText(path0);

                //var str2 = WordTools.TranslationWords(str, false, true);

                //Platform.Current.WriteAllText(sce.Name + ".json", str2);

                var btOne = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", null)
                {
                    ID = sce.Name
                };
                btOne.OnButtonPress += (sender, e) =>
                {
                    string id = ((ButtonTexture)sender).ID;

                    btScenarioSelectList.ForEach(bt => bt.Selected = false);

                    ((ButtonTexture)sender).Selected = true;

                    CurrentScenario = ScenarioList.FirstOrDefault(sc => sc.Name == id);

                    var iDs   = CurrentScenario.IDs.Split(',').NullToEmptyList();
                    var names = CurrentScenario.Names.Split(',').NullToEmptyList();

                    btScenarioPlayersList = new List <ButtonTexture>();

                    for (int i = 0; i < iDs.Count; i++)
                    {
                        var id0      = iDs[i];
                        var btPlayer = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", null)
                        {
                            ID = id0
                        };
                        btPlayer.OnButtonPress += (sender0, e0) =>
                        {
                            var btP = (ButtonTexture)sender0;
                            btP.Selected = !btP.Selected;
                        };
                        btScenarioPlayersList.Add(btPlayer);
                    }

                    pageIndex1 = 1;
                };
                btScenarioSelectList.Add(btOne);
            }
            //var sces = new List<Scenario>();
            //var files = Platform.Current.GetFiles(path).NullToEmptyList().Where(fi => fi.EndsWith(".mdb")).NullToEmptyList();
            //foreach (var fi in files)
            //{
            //    var sce = GetScenario(fi);
            //    sces.Add(sce);
            //}
            //var sers = SimpleSerializer.SerializeJson(sces, true).TranslationWords(false, false);
        }
Exemple #12
0
        public LoadingScreen(string mode, string scenario)
        {
            Mode = mode;

            Scenario = scenario.NullToString().Split('-')[0];

            if (Mode == "Start")
            {
                string baseDir = @"Content\Textures\Resources\ScenarioLoading\Maps\";

                var dirs = Platform.Current.GetMODDirectories(baseDir, true).NullToEmptyArray();

                var dir = dirs.FirstOrDefault(di => di.Contains(Scenario));

                if (dir == null)
                {
                    Mode = "";
                }
                else
                {
                    maps = Platform.Current.GetMODFiles(dir + "/", true).NullToEmptyArray().Where(fi => fi.EndsWith(".jpg")).NullToEmptyArray();  //.Select(fi => baseDir + Scenario + @"\" + fi).NullToEmptyArray();
                }

                var soundDir = @"Content\Sound\Scenario\";

                var soundFiles = Platform.Current.GetMODFiles(soundDir, true).NullToEmptyArray();

                sound = soundFiles.FirstOrDefault(fi => fi.Contains(Scenario));

                if (!String.IsNullOrEmpty(sound))
                {
                    Platform.Current.PlayEffect(sound);
                }
            }

            if (Mode == "Start")
            {
                btPre = new ButtonTexture(@"Content\Textures\Resources\Start\Play", "Pre", new Vector2(200 - 50, 640));
                btPre.OnButtonPress += (sender, e) =>
                {
                    if (page > 1)
                    {
                        page--;
                        pageTime = 0f;
                        if (Platform.IsMobilePlatForm)
                        {
                            InputManager.PoX = 0;
                            InputManager.PoY = 0;
                        }
                    }
                };

                btPlay = new ButtonTexture(@"Content\Textures\Resources\Start\Play", "Play", new Vector2(200 + 220, 640));
                btPlay.OnButtonPress += (sender, e) =>
                {
                    pause = false;
                };

                btPause = new ButtonTexture(@"Content\Textures\Resources\Start\Play", "Pause", new Vector2(200 + 220, 640));
                btPause.OnButtonPress += (sender, e) =>
                {
                    pause = true;
                };

                btNext = new ButtonTexture(@"Content\Textures\Resources\Start\Play", "Next", new Vector2(200 + 220 * 2, 640));
                btNext.OnButtonPress += (sender, e) =>
                {
                    if (page < maps.Length)
                    {
                        page++;
                        pageTime = 0f;
                        if (Platform.IsMobilePlatForm)
                        {
                            InputManager.PoX = 0;
                            InputManager.PoY = 0;
                        }
                    }
                };

                btLoad        = new ButtonTexture(@"Content\Textures\Resources\Start\Play", "Load", new Vector2(200 + 220 * 3 + 100, 640));
                btLoad.Enable = false;

                btStart = new ButtonTexture(@"Content\Textures\Resources\Start\Play", "Start", new Vector2(200 + 220 * 3 + 100, 640));
                btStart.OnButtonPress += (sender, e) =>
                {
                    Session.MainGame.loadingScreen = null;
                };
            }
            else
            {
                var baseDir = @"Content\Textures\Resources\ScenarioLoading\";

                var pictures = Platform.Current.GetMODFiles(baseDir, true).NullToEmptyArray().Where(pi => pi.EndsWith(".jpg")).NullToEmptyArray();  //.Select(fi => baseDir + fi).NullToEmptyArray();

                if (pictures.Length > 0)
                {
                    int ran = new Random().Next(1, pictures.Length);

                    //string ranStr = ran < 10 ? ("0" + ran) : ran.ToString();

                    background = pictures[ran - 1];  // "Content/Textures/Resources/ScenarioLoading/" + ranStr + ".jpg";

                    tishi = new TiShiText().getRandomText();

                    var textLength = 22.4 * tishi.Trim().Length;

                    textPre = Convert.ToSingle((845 - textLength) / 2);
                }
            }
        }
Exemple #13
0
 public ToggleButton(Rectangle Bounds, ButtonTexture buttonTexture, Text text, bool center = false)
     : base(Bounds, buttonTexture, text, center)
 {
     this.LeftClicked += OnLeftClicked;
 }
Exemple #14
0
 public Button(Rectangle buttonBounds, string Text, SpriteFont SpriteFont, ButtonTexture buttonTexture, bool center = false)
     : this(buttonBounds, buttonTexture, new Text(Text, Color.Black, SpriteFont), center)
 {
 }
Exemple #15
0
 //Textless button
 public Button(Rectangle buttonBounds)
 {
     buttonTexture = StandardTexture;
     ButtonBounds  = buttonBounds;
     TextBox       = new TextBox(new Text("", Color.Black, InputController.DefaultFont), buttonBounds);
 }
Exemple #16
0
 public virtual void Inactivate()
 {
     inActive    = true;
     buttonState = ButtonTexture.InactiveTexture;
     transform.SetTexture(textures[(int)ButtonTexture.InactiveTexture]);
 }
Exemple #17
0
        public MainMenuScreen()
        {
            //None

            btList = new List <ButtonTexture>()
            {
            };

            var btOne = new ButtonTexture(@"Content\Textures\Resources\Start\Menu", "New", new Vector2(870, 120 + 90));

            btOne.OnButtonPress += (sender, e) =>
            {
                menuTypeElapsed = 0f;
                UnCheckTextBoxs();
                MenuType = MenuType.New;
                InitScenarioList();
            };
            btList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\Menu", "Save", new Vector2(870, 120 + 90 * 2));
            btOne.OnButtonPress += (sender, e) =>
            {
                menuTypeElapsed = 0f;
                UnCheckTextBoxs();
                MenuType = MenuType.Save;
                InitScenarioSaveList();
            };
            btList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\Menu", "Setting", new Vector2(870, 120 + 90 * 3));
            btOne.OnButtonPress += (sender, e) =>
            {
                menuTypeElapsed = 0f;
                UnCheckTextBoxs();
                MenuType = MenuType.Setting;
            };
            btList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\Menu", "About", new Vector2(870, 120 + 90 * 4));
            btOne.OnButtonPress += (sender, e) =>
            {
                menuTypeElapsed = 0f;
                UnCheckTextBoxs();
                MenuType = MenuType.About;
            };
            btList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\Menu", "Exit", new Vector2(870, 120 + 90 * 5));
            btOne.OnButtonPress += (sender, e) =>
            {
                Platform.Current.Exit();
            };
            if (Platform.PlatFormType == PlatFormType.iOS || Platform.PlatFormType == PlatFormType.UWP)
            {
                btOne.Visible = false;
            }
            btList.Add(btOne);


            //New

            btScenarioList       = new List <ButtonTexture>();
            btOne                = new ButtonTexture(@"Content\Textures\Resources\Start\ReadyButton", "OK", new Vector2(800 + 220, 615));
            btOne.OnButtonPress += (sender, e) =>
            {
                //SoundPlayer player = new SoundPlayer("Content/Textures/Resources/SaveSelect/Open");
                //player.Play();

                Platform.Current.PlayEffect(@"Content\Sound\Open");

                if (CurrentScenario == null)
                {
                    message = "请选择剧本。";
                }
                else
                {
                    Session.StartScenario(CurrentScenario, false);
                }
            };
            btScenarioList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\ReadyButton", "Cancel", new Vector2(800, 615));
            btOne.OnButtonPress += (sender, e) =>
            {
                isClosing       = true;
                menuTypeElapsed = 0.5f;
            };
            btScenarioList.Add(btOne);

            btSaveList           = new List <ButtonTexture>();
            btOne                = new ButtonTexture(@"Content\Textures\Resources\Start\ReadyButton", "Load", new Vector2(800 + 220, 615));
            btOne.OnButtonPress += (sender, e) =>
            {
                //SoundPlayer player = new SoundPlayer("Content/Textures/Resources/SaveSelect/Open");
                //player.Play();

                Platform.Current.PlayEffect(@"Content\Sound\Open");

                if (CurrentScenario == null)
                {
                    message = "请选择存档。";
                }
                else
                {
                    Session.StartScenario(CurrentScenario, true);
                }
            };
            btSaveList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\ReadyButton", "Cancel", new Vector2(800, 615));
            btOne.OnButtonPress += (sender, e) =>
            {
                isClosing       = true;
                menuTypeElapsed = 0.5f;
            };
            btSaveList.Add(btOne);

            lbSettingList = new List <LinkButton>();
            var lbOne = new LinkButton("基本")
            {
                Position = new Vector2(50, 50)
            };

            lbOne.OnButtonPress += (sender, e) =>
            {
                CurrentSetting = "基本";
                UnCheckTextBoxs();
            };
            lbSettingList.Add(lbOne);

            lbOne = new LinkButton("环境")
            {
                Position = new Vector2(50 + 100, 50)
            };
            lbOne.OnButtonPress += (sender, e) =>
            {
                CurrentSetting = "环境";
                UnCheckTextBoxs();
            };
            lbSettingList.Add(lbOne);

            lbOne = new LinkButton("人物")
            {
                Position = new Vector2(50 + 100 * 2, 50)
            };
            lbOne.OnButtonPress += (sender, e) =>
            {
                CurrentSetting = "人物";
                UnCheckTextBoxs();
            };
            lbSettingList.Add(lbOne);

            lbOne = new LinkButton("参数")
            {
                Position = new Vector2(50 + 100 * 3, 50)
            };
            lbOne.OnButtonPress += (sender, e) =>
            {
                CurrentSetting = "参数";
                UnCheckTextBoxs();
            };
            lbSettingList.Add(lbOne);

            lbOne = new LinkButton("电脑")
            {
                Position = new Vector2(50 + 100 * 4, 50)
            };
            lbOne.OnButtonPress += (sender, e) =>
            {
                CurrentSetting = "电脑";
                UnCheckTextBoxs();
            };
            lbSettingList.Add(lbOne);

            btSettingList        = new List <ButtonTexture>();
            btOne                = new ButtonTexture(@"Content\Textures\Resources\Start\ReadyButton", "Cancel", new Vector2(800 + 220, 615));
            btOne.OnButtonPress += (sender, e) =>
            {
                UnCheckTextBoxs();
                Setting.Save();
                isClosing       = true;
                menuTypeElapsed = 0.5f;
            };
            btSettingList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", new Vector2(150, 115))
            {
                ID = "简体中文"
            };
            btOne.OnButtonPress += (sender, e) =>
            {
                Setting.Current.Language = "cn";
                Session.LoadFont(Setting.Current.Language);
                InitSetting();
            };
            btSettingList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", new Vector2(150 + 200, 115))
            {
                ID = "传统中文"
            };
            btOne.OnButtonPress += (sender, e) =>
            {
                Setting.Current.Language = "tw";
                Session.LoadFont(Setting.Current.Language);
                InitSetting();
            };
            btSettingList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", new Vector2(150, 115))
            {
                ID = "窗口模式"
            };
            btOne.OnButtonPress += (sender, e) =>
            {
                Setting.Current.DisplayMode = "Window";
                InitSetting();
                Platform.Current.SetFullScreen(false);
                Platform.GraphicsApplyChanges();
            };
            btSettingList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", new Vector2(150 + 200, 115))
            {
                ID = "全屏模式"
            };
            btOne.OnButtonPress += (sender, e) =>
            {
                Setting.Current.DisplayMode = "Full";
                InitSetting();
                Platform.Current.SetFullScreen(true);
                Platform.GraphicsApplyChanges();
            };
            btSettingList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", new Vector2(150, 115 + 60))
            {
                ID = "925*520"
            };
            btOne.OnButtonPress += (sender, e) =>
            {
                Session.Resolution = "925*520";
                Session.ChangeDisplay(true);
                InitSetting();
            };
            btSettingList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", new Vector2(150 + 200, 115 + 60))
            {
                ID = "1120*630"
            };
            btOne.OnButtonPress += (sender, e) =>
            {
                Session.Resolution = "1120*630";
                Session.ChangeDisplay(true);
                InitSetting();
            };
            btSettingList.Add(btOne);

            btOne = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", new Vector2(150 + 400, 115 + 60))
            {
                ID = "1024*768"
            };
            btOne.OnButtonPress += (sender, e) =>
            {
                Session.Resolution = "1024*768";
                Session.ChangeDisplay(true);
                InitSetting();
            };
            btSettingList.Add(btOne);

            nstMusic = new NumericSetTexture(0, 100, 100, null, new Vector2(150, 115 + 60 * 2), true)
            {
                DisNumber = false,
                NowNumber = Setting.Current.MusicVolume
            };
            nstSound = new NumericSetTexture(0, 100, 100, null, new Vector2(150, 115 + 60 * 3), true)
            {
                DisNumber = false,
                NowNumber = Setting.Current.SoundVolume
            };

            cbAIHardList = new List <ButtonTexture>();

            for (int i = 0; i < hards1.Length; i++)
            {
                var hard = hards1[i];

                btOne = new ButtonTexture(@"Content\Textures\Resources\Start\CheckBox", "CheckBox", new Vector2(150 + 100 * i, 115 + 60))
                {
                    ID = hard
                };
                btOne.OnButtonPress += (sender, e) =>
                {
                    Setting.Current.Difficulty = ((ButtonTexture)sender).ID;
                    InitSetting();
                };
                cbAIHardList.Add(btOne);
            }

            tbBattleSpeed = new TextBox(TextBoxStyle.Small, "")
            {
                TextBoxMode = TextBoxMode.Normal,
                MaxLength   = 5,
                Position    = new Vector2(150, 120 + 60 * 2)
            };
            tbBattleSpeed.Text = Setting.Current.BattleSpeed;
            tbBattleSpeed.OnTextBoxSelected += (sender, e) =>
            {
                UnCheckTextBoxs();
                tbBattleSpeed.Selected = true;
            };

            tbGamerName = new TextBox(TextBoxStyle.Small, "")
            {
                MaxLength = 20,
                Position  = new Vector2(150, 120 + 60 * 3)
            };

            if (Platform.PlatFormType == PlatFormType.Win)
            {
                tbGamerName.TextBoxMode = TextBoxMode.Normal;
            }
            else
            {
                tbGamerName.TextBoxMode = TextBoxMode.Chinese;
            }

            tbGamerName.Text = Setting.Current.GamerName;
            tbGamerName.OnTextBoxSelected += (sender, e) =>
            {
                UnCheckTextBoxs();
                tbGamerName.Selected = true;
            };

            btAboutList          = new List <ButtonTexture>();
            btOne                = new ButtonTexture(@"Content\Textures\Resources\Start\ReadyButton", "Cancel", new Vector2(800 + 220, 615));
            btOne.OnButtonPress += (sender, e) =>
            {
                isClosing       = true;
                menuTypeElapsed = 0.5f;
            };
            btAboutList.Add(btOne);

            btPre = new ButtonTexture(@"Content\Textures\Resources\Start\LeftAndRight", "Left", new Vector2(528, 612))
            {
                Enable = false
            };
            btPre.OnButtonPress += (sender, e) =>
            {
                if (pageIndex > 1)
                {
                    pageIndex--;
                }
            };

            btNext = new ButtonTexture(@"Content\Textures\Resources\Start\LeftAndRight", "Right", new Vector2(528 + 120, 612))
            {
                Enable = false
            };
            btNext.OnButtonPress += (sender, e) =>
            {
                if (pageIndex < pageCount)
                {
                    pageIndex++;
                }
            };

            btPre1 = new ButtonTexture(@"Content\Textures\Resources\Start\LeftAndRight", "Left", new Vector2(860, 612))
            {
                Enable = false
            };
            btPre1.OnButtonPress += (sender, e) =>
            {
                if (pageIndex1 > 1)
                {
                    pageIndex1--;
                }
            };

            btNext1 = new ButtonTexture(@"Content\Textures\Resources\Start\LeftAndRight", "Right", new Vector2(860 + 120, 612))
            {
                Enable = false
            };
            btNext1.OnButtonPress += (sender, e) =>
            {
                if (pageIndex1 < pageCount1)
                {
                    pageIndex1++;
                }
            };

            InitSetting();
        }
Exemple #18
0
        private void CreateGateButtons(InputContainer componentMenu, GameMenu gameMenu)
        {
            List <TextureField> icons = new List <TextureField>();

            ButtonTexture bt = new ButtonTexture(
                InputController.DefaultTexture,
                new Color(50, 50, 50),
                new Color(100, 100, 100),
                new Color(75, 75, 75),
                new Color(95, 115, 255)
                );
            int buttonSize = (Width - (ButtonPrRow + 1) * BPadding) / ButtonPrRow;
            int offsetY    = 0;

            for (int i = 0; i < gateTypes.Count; i++)
            {
                Type gateType = gateTypes[i];
                int  offsetX  = (i % ButtonPrRow);
                offsetX = offsetX * buttonSize + offsetX * BPadding;
                offsetY = (i / ButtonPrRow);
                offsetY = offsetY * buttonSize + offsetY * BPadding;

                Rectangle bounds     = new Rectangle(X + BPadding + offsetX, Y + BPadding + offsetY, buttonSize, buttonSize);
                Rectangle iconBounds = bounds;
                iconBounds.Inflate(-4, -4);

                Texture2D texture;
                if (gameMenu.GateTextureMap.ContainsKey(gateType.FullName))
                {
                    texture = gameMenu.GateTextureMap[gateType.FullName];
                }
                else
                {
                    texture = InputController.DefaultTexture;
                }

                TextureField icon = new TextureField(iconBounds, texture, Color.White);
                Button       temp = new Button(bounds, bt, new Text("", Color.White));
                temp.ID = gateType.FullName;

                icons.Add(icon);
                group.Add(temp, false);
            }



            group.BeforeSelectedButtonChange += (object sender, ButtonEventArgs e) =>
            {
                if (group.SelectedButton != null)
                {
                    Containers[group.SelectedButton.ID].Active = false;
                    Containers[group.SelectedButton.ID].DeFocus();
                }

                if (!Selected)
                {
                    OnActive?.Invoke();
                }
            };

            group.AfterSelectedButtonChange += (object sender, ButtonEventArgs e) =>
            {
                Containers[e.Button.ID].Active = true;
                Containers[e.Button.ID].Focus();
            };

            componentMenu.Add(group);
            componentMenu.Add(icons);
            CurrentY = offsetY + buttonSize + BPadding;
        }