/// Sets thumbnails to those from the team players public void initThumbnails() { hlThumbnails.remove(hlThumbnails.Children.ToArray()); if (Team != null) { Team.Player.ForEach(player => { ImageItem thumb = new ImageItem(player.Thumbnail); thumb.Width = thumb.Height = 128; hlThumbnails.add(thumb); }); } }
private void addThumb(Creature c) { ImageItem thumb = new ImageItem(c.Thumbnail); thumb.PercentWidth = 80; thumb.PercentHeight = 80; hlThumbs.add(thumb); int sel = hlThumbs.SelectedIndex; int off = sel - (hlThumbs.VisibleRange + 2); if (hlThumbs.Children.Count - (sel + 2) >= hlThumbs.VisibleRange) { thumb.Disabled = true; } if (off >= 0) { (hlThumbs.Children[0] as MenuItem).Disabled = true; } }
// private GameConfig gameConfig; public VideoSettingsPane(GameConfig gameConfig) { hlResolutions = new HList(); hlFullscreen = new HList( new TextItem("Enabled", "fonts/menu_font1"), new TextItem("Disabled", "fonts/menu_font1") ); foreach (Point res in GameConfig.CommonResolutions) { hlResolutions.add(new TextItem(resToStr(res), "fonts/menu_font1")); } VList vlNames = new VList( new TextItem("Resolution", "fonts/menu_font1"), new TextItem("Fullscreen", "fonts/menu_font1") ); VPane vpSettings = new VPane(hlResolutions, hlFullscreen); vlNames.SelectedEvent += (sender, args) => { hlResolutions.IsFocused = args.SelectedIndex == 0; hlFullscreen.IsFocused = args.SelectedIndex == 1; }; vlNames.CancelEvent += (sender, args) => { hlResolutions.IsFocused = false; hlFullscreen.IsFocused = false; vlNames.select(0); hide(0.5f); }; hlResolutions.SelectedEvent += (sender, args) => gameConfig.Resolution = GameConfig.CommonResolutions[args.SelectedIndex]; hlFullscreen.SelectedEvent += (sender, args) => gameConfig.IsFullscreen = args.SelectedIndex == 0; int selectedFullscreen = gameConfig.IsFullscreen ? 0 : 1; int selectedResolution = 0; for (int i = 0; i < GameConfig.CommonResolutions.Length; ++i) { if (GameConfig.CommonResolutions[i].Equals(gameConfig.Resolution)) { selectedResolution = i; break; } } hlResolutions.select(selectedResolution); hlFullscreen.select(selectedFullscreen); hlResolutions.SelectedColor = Color.White; hlFullscreen.SelectedColor = Color.White; vlNames.PercentWidth = 30; vlNames.PercentHeight = 100; vlNames.HAlignment = HAlignment.Left; vlNames.EffectAlpha = 0.5f; vlNames.Color = Color.Black; vpSettings.PercentWidth = 70; vpSettings.PercentHeight = 100; vpSettings.HAlignment = HAlignment.Left; vpSettings.EffectAlpha = 0.5f; vpSettings.Color = Color.Gray; FocusRequestEvent += (s, a) => { vlNames.select(0); vlNames.IsFocused = true; }; FocusLossEvent += (s, a) => { vlNames.IsFocused = false; vlNames.SelectedIndex = -1; }; HPane hpMain = new HPane(vlNames, vpSettings); hpMain.PercentWidth = 100; hpMain.PercentHeight = 100; add(hpMain); }
public GameplaySettingsPane(GameConfig gameConfig) { hlLang = new HList(); foreach (Language lang in GameConfig.SupportedLanguages) { hlLang.add(new TextItem(lang.Title, "fonts/menu_font1")); } VList vlNames = new VList(new TextItem(gameConfig.Language.translate("Language"), "fonts/menu_font1")); VPane vpSettings = new VPane(hlLang); hlLang.VisibleRange = 2; vlNames.SelectedEvent += (sender, args) => hlLang.IsFocused = args.SelectedIndex == 0; vlNames.CancelEvent += (sender, args) => { hlLang.IsFocused = false; hide(0.5f); }; hlLang.SelectedEvent += (sender, args) => gameConfig.Language = GameConfig.SupportedLanguages[args.SelectedIndex]; Language[] langs = GameConfig.SupportedLanguages; int index = langs.Length - 1; for (; index >= 0 && gameConfig.Language.ID != langs[index].ID; --index) { ; } hlLang.select(index < 0 ? 0 : index); hlLang.SelectedColor = Color.White; vlNames.PercentWidth = 30; vlNames.PercentHeight = 100; vlNames.HAlignment = HAlignment.Left; vlNames.EffectAlpha = 0.5f; vlNames.Color = Color.Black; vpSettings.PercentWidth = 70; vpSettings.PercentHeight = 100; vpSettings.HAlignment = HAlignment.Left; vpSettings.EffectAlpha = 0.5f; vpSettings.Color = Color.Gray; FocusRequestEvent += (s, a) => { vlNames.select(0); vlNames.IsFocused = true; }; FocusLossEvent += (s, a) => { vlNames.IsFocused = false; vlNames.SelectedIndex = -1; }; HPane hpMain = new HPane(vlNames, vpSettings); hpMain.PercentWidth = 100; hpMain.PercentHeight = 100; add(hpMain); }
public AudioSettingsPane(GameConfig gameConfig) { hlMusic = new HList(new TextItem("Off", "fonts/menu_font1")); hlSFX = new HList(new TextItem("Off", "fonts/menu_font1")); for (int i = 10; i <= 100; i += 10) { hlMusic.add(new TextItem(" " + i.ToString() + " ", "fonts/menu_font1")); hlSFX.add(new TextItem(" " + i.ToString() + " ", "fonts/menu_font1")); } VList vlNames = new VList( new TextItem("Music Volume", "fonts/menu_font1"), new TextItem("Audio Volume", "fonts/menu_font1") ); hlSFX.VisibleRange = 4; hlMusic.VisibleRange = 4; VPane vpSettings = new VPane(hlMusic, hlSFX); vlNames.SelectedEvent += (sender, args) => { hlMusic.IsFocused = args.SelectedIndex == 0; hlSFX.IsFocused = args.SelectedIndex == 1; }; vlNames.CancelEvent += (sender, args) => { hlMusic.IsFocused = false; hlSFX.IsFocused = false; vlNames.select(0); hide(0.5f); }; hlMusic.SelectedEvent += (sender, args) => gameConfig.MusicVolume = args.SelectedIndex * 10; hlSFX.SelectedEvent += (sender, args) => gameConfig.SFXVolume = args.SelectedIndex * 10; hlMusic.select(gameConfig.MusicVolume / 10); hlSFX.select(gameConfig.SFXVolume / 10); hlMusic.SelectedColor = Color.White; hlSFX.SelectedColor = Color.White; vlNames.PercentWidth = 30; vlNames.PercentHeight = 100; vlNames.HAlignment = HAlignment.Left; vlNames.EffectAlpha = 0.5f; vlNames.Color = Color.Black; vpSettings.PercentWidth = 70; vpSettings.PercentHeight = 100; vpSettings.HAlignment = HAlignment.Left; vpSettings.EffectAlpha = 0.5f; vpSettings.Color = Color.Gray; FocusRequestEvent += (s, a) => { vlNames.select(0); vlNames.IsFocused = true; }; FocusLossEvent += (s, a) => { vlNames.IsFocused = false; vlNames.SelectedIndex = -1; }; HPane hpMain = new HPane(vlNames, vpSettings); hpMain.PercentWidth = 100; hpMain.PercentHeight = 100; add(hpMain); }
private void initGrid() { if (vlGrid != null) { remove(vlGrid); } grid = new StackPane[width, height]; vlGrid = new VList(); vlGrid.PercentWidth = 100; vlGrid.PercentHeight = 50; vlGrid.MillisPerInput = 128; vlGrid.InputSingleMode = true; vlGrid.CancelEvent += (sender, args) => { if (!setFormation()) { ParentScreen.ScreenManager .AddScreen(new ConfirmDialog(ParentScreen as BesmashScreen, (a) => { if (a == 0) { hide(); // yes -> hide() } if (a == 1) { ; // no -> do nothing } if (a == 2) { ; // cancel -> do nothing } }, "No Leader assigned", "Omit changes?"), null); } else { hide(); } }; vlGrid.SelectedEvent += (sender, args) => { if (args.SelectedItem is HList) { HList row = args.SelectedItem as HList; row.IsFocused = true; row.select(columnIndex); } }; vlGrid.DeselectedEvent += (sender, args) => { if (args.SelectedItem is HList) { HList row = args.SelectedItem as HList; row.IsFocused = false; row.SelectedIndex = -1; } }; for (int x, y = 0, c = 0; y < height; ++y) { HList row = new HList(); row.PercentWidth = 100; row.PercentHeight = (int)(100f / height); row.IsStatic = true; row.MillisPerInput = 128; row.InputSingleMode = true; row.SelectedEvent += (sender, args) => { Container cell = args.SelectedItem as Container; columnIndex = args.SelectedIndex; // if(cell.Children.Count > 0) // cell.Children[0].EffectScale = 1.2f; if (cursor != null) { // if(cursor.ParentContainer != null) // cursor.ParentContainer.remove(cursor); if (cursor.ParentContainer != null) { // image switching if (selected != null && cell.Children.Count > 0) { cursor.ParentContainer.add(cell.Children[0]); cell.remove(cell.Children[0]); } cursor.ParentContainer.remove(cursor); } cell.add(cursor); } }; row.ActionEvent += (sender, args) => { Container cell = args.SelectedItem as Container; ImageItem pick = cell.Children.Count > 0 ? cell.Children[0] as ImageItem : null; if (pick != null) { cell.remove(pick); cursor.prepend(pick); pick.EffectScale = 1.2f; } if (selected != null) { cell.prepend(selected); cursor.remove(selected); selected.EffectScale = 1; } selected = pick; }; for (x = 0; x < width; ++x, ++c) { StackPane cell = new StackPane(); cell.PercentWidth = (int)(100f / width); cell.PercentHeight = 100; cell.Color = (c % 2) == 0 ? Color.Black : Color.Gray; cell.Alpha = 0.5f; grid[x, y] = cell; row.add(cell); } vlGrid.add(row); } add(vlGrid); }
public ControlSettingsPane(GameConfig gameConfig) { StackPane spSettings = new StackPane(); VPane vpMain = new VPane(hlCategories, spSettings); hlCategories.PercentWidth = 100; spSettings.PercentWidth = 100; hlCategories.PercentHeight = 10; spSettings.PercentHeight = 90; hlCategories.Color = Color.Black; hlCategories.EffectAlpha = 0.5f; gameConfig.KeyMaps.Keys.ToList().ForEach(key => { hlCategories.add(new TextItem(key, "fonts/menu_font1")); VList vlNames = new VList(); VList vlKeys = new VList(); VList vlButtons = new VList(); HPane hpBorder = new HPane(); HPane hpControls = new HPane(vlNames, vlKeys, hpBorder, vlButtons); hpControls.PercentWidth = 100; hpControls.PercentHeight = 100; vlNames.PercentWidth = 25; vlKeys.PercentWidth = 25; hpBorder.PercentWidth = 5; vlButtons.PercentWidth = 45; vlNames.PercentHeight = 100; vlKeys.PercentHeight = 100; hpBorder.PercentHeight = 100; vlButtons.PercentHeight = 100; vlNames.Color = Color.Black; vlKeys.Color = Color.Gray; hpBorder.Color = Color.Black; vlButtons.Color = Color.Gray; vlNames.EffectAlpha = 0.5f; vlKeys.EffectAlpha = 0.5f; hpBorder.EffectAlpha = 0.5f; vlButtons.EffectAlpha = 0.5f; List <UserInput> input_refs = new List <UserInput>(); List <TextItem> key_refs = new List <TextItem>(); List <TextItem> button_refs = new List <TextItem>(); vlNames.ActionEvent += (sender, args) => { ParentScreen.ScreenManager.AddScreen(new InputDialog( (BesmashScreen)ParentScreen, input_refs[args.SelectedIndex], "Press a new Key or Button", 5, a => initKeyTextItems(input_refs[args.SelectedIndex], key_refs[args.SelectedIndex], button_refs[args.SelectedIndex]) ), null); }; spSettings.add(hpControls); hPanes.Add(hpControls); vLists.Add(vlNames); gameConfig.KeyMaps[key].Keys.ToList().ForEach(key2 => { List <Keys> keys = gameConfig.KeyMaps[key][key2].TriggerKeys; List <Buttons> buttons = gameConfig.KeyMaps[key][key2].TriggerButtons; string title_key = "", title_button = ""; int i; for (i = 0; i < keys.Count(); ++i) { title_key += (i > 0 ? ", " : "") + keys[i].ToString(); } for (i = 0; i < buttons.Count(); ++i) { title_button += (i > 0 ? ", " : "") + buttons[i].ToString(); } TextItem tiName = new TextItem(key2, "fonts/menu_font1"); TextItem tiKeys = new TextItem("", "fonts/menu_font1"); TextItem tiButtons = new TextItem("", "fonts/menu_font1"); initKeyTextItems(gameConfig.KeyMaps[key][key2], tiKeys, tiButtons); vlNames.add(new TextItem(key2, "fonts/menu_font1")); vlKeys.add(tiKeys); vlButtons.add(tiButtons); key_refs.Add(tiKeys); button_refs.Add(tiButtons); input_refs.Add(gameConfig.KeyMaps[key][key2]); }); vlNames.SelectedIndex = 0; }); hlCategories.SelectedEvent += (sender, args) => { if (hlCategories.IsFocused) { vLists[args.SelectedIndex].IsFocused = true; show(true, 1); } }; hlCategories.DeselectedEvent += (sender, args) => vLists[args.SelectedIndex].IsFocused = false; hlCategories.CancelEvent += (sender, args) => { vLists[hlCategories.SelectedIndex].IsFocused = false; hide(0.5f); }; FocusRequestEvent += (s, a) => { vLists[hlCategories.SelectedIndex].IsFocused = true; hlCategories.IsFocused = true; }; FocusLossEvent += (s, a) => hlCategories.IsFocused = false; vpMain.PercentWidth = 100; vpMain.PercentHeight = 100; hlCategories.IsFocused = false; hlCategories.select(0); add(vpMain); }