protected override void Init() { font = Content.Load <SpriteFont>("fonts/menu_font"); blank = Content.Load <Texture2D>("textures/blank"); background = new ImageItem(blank); background.HGrow = background.VGrow = 1; background.Color = Color.Black; background.Alpha = 0.3f; TextItem msg = new TextItem(font, message); msg.HAlign = HAlignment.Center; ListMenu menu = new ListMenu(); menu.VAlign = VAlignment.Center; VPane vPane = new VPane(msg, menu); vPane.HAlign = HAlignment.Center; vPane.VGrow = 1; ImageItem vpBack = new ImageItem(blank); vpBack.HGrow = vpBack.VGrow = 1; vpBack.Color = Color.Black; vpBack.Alpha = 0.3f; StackPane sPane = new StackPane(vpBack, vPane); sPane.VAlign = VAlignment.Center; sPane.VGrow = 0.2f; sPane.HGrow = 1; responds.ForEach(respond => { if (respond != responds[0]) { MenuItem gap = new MenuItem(" ", font); gap.IsDisabled = true; menu.AddItem(gap); } MenuItem item = new MenuItem(respond.Text, font); menu.AddItem(item); item.FocusGain += (s, a) => item.TextItem.Color = Color.Yellow; item.FocusLoss += (s, a) => item.TextItem.Color = Color.White; item.Action += (s, a) => { action = respond.Action; Close(); }; }); ViewPane.Clear(); RootPane = new StackPane(background, sPane); RootPane.HGrow = RootPane.VGrow = 1; ViewPane.Add(RootPane); }
protected override void Init() { revealedTextures = new Texture2D[10]; hiddenTexture = Content.Load <Texture2D>("textures/tile_hid_0"); font = Content.Load <SpriteFont>("fonts/menu_font"); blank = Content.Load <Texture2D>("textures/blank"); for (int i = 0; i < 10; ++i) { revealedTextures[i] = Content.Load <Texture2D>("textures/tile_rev_" + i); } ElapsedTime = new TimeSpan(); itemMap = new Dictionary <MenuItem, Point>(); Map = new GameMap(mapTemplate.Width, mapTemplate.Height, mapTemplate.Density); HPane mapPane = new HPane(); mapPane.HAlign = HAlignment.Center; mapPane.VAlign = VAlignment.Center; mapPane.HGrow = Width / (float)Graphics.Viewport.Width; mapPane.VGrow = Height / (float)Graphics.Viewport.Height; StackPane sPane = new StackPane(mapPane); sPane.HGrow = sPane.VGrow = 1; InfoPane iPane = new InfoPane(Map, Game, font, blank); iPane.HAlign = HAlignment.Center; iPane.HGrow = 0.5f; ImageItem iBack = new ImageItem(blank); iBack.HGrow = iBack.VGrow = 1; iBack.Color = Color.Black; iBack.Alpha = 0.42f; StackPane iStack = new StackPane(iBack, iPane); iStack.HGrow = 1; VPane vPane = new VPane(iStack, sPane); vPane.HGrow = vPane.VGrow = 1; ImageItem backItem = new ImageItem(Parent.Background); backItem.HGrow = backItem.VGrow = 1; StackPane sBack = new StackPane(backItem, vPane); sBack.HGrow = sBack.VGrow = 1; InitMapPane(mapPane); ViewPane.Clear(); ViewPane.Add(RootPane = sBack); }
public override void load() { base.load(); cursorSheet = ParentScreen.Content .Load <Texture2D>("images/world/entities/cursor/generic_cursor"); cursorItem = new ImageItem(cursorSheet); cursorItem.PercentWidth = cursorItem.PercentHeight = 100; cursorItem.SourceRectangle = new Rectangle(0, 0, 16, 16); cursor = new StackPane(cursorItem); cursor.PercentWidth = cursor.PercentHeight = 100; cursor.PPSFactor = 4; }
private void InitGrids() { gameOverText = GetItem <TextItem>("gameOverText"); gridPane = GetItem <StackPane>("gridPane"); var sgrid = GetItem <GridPane>("smallGrid"); var mgrid = GetItem <GridPane>("mediumGrid"); var lgrid = GetItem <GridPane>("largeGrid"); var grids = new GridPane[] { sgrid, mgrid, lgrid }; foreach (var grid in grids) { for (int x, y = 0, i = 0; y < grid.GridHeight; ++y) { for (x = 0; x < grid.GridWidth; ++x, ++i) { var cell = grid.Get(x, y) as StackPane; var mni = cell.Children[0] as MenuItem; var fader = cell.Children[1] as FadingPane; var complete = false; int index = i; mni.ImageItem.Color = RandomColor(); mni.Action += (s, a) => { if (fader.State != FadingPaneState.FadedIn) { return; } if (Session.IsListening) { complete = Session.Listen(index); fader.FadeOut(); } }; fader.FadedOut += (s, a) => fader.FadeIn(); fader.FadedIn += (s, a) => { if (complete) { Session.EvaluateNextTiles(); complete = false; } }; } } } }
private bool setFormation() { int leaderX = width / 2; int leaderY = 0; if (grid[leaderX, leaderY].Children.Count == 0 || grid[leaderX, leaderY].Children[0] as ImageItem == null) { return(false); } for (int x, y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { Player player = null; ImageItem image = null; StackPane cell = grid[x, y]; if (cell.Children.Count > 0) { image = cell.Children[0] as ImageItem; } if (image != null) { player = playerMap.GetValueOrDefault(image); } if (x == leaderX && y == leaderY) { if (player != Team.Leader) { player.ContainingMap.Slave = player; Team.Formation.Remove(player); Team.addMembers(Team.Leader); Team.removeMember(player); Team.Leader = player; } } else if (player != null) { Team.Formation[player] = new Point(x - leaderX, y - leaderY); } } } return(true); }
private void initTeam() { playerMap = new Dictionary <ImageItem, Player>(); Point p; for (int x, y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { Player player = null; if (Team != null) { p = new Point(x - width / 2, y); if (p.Equals(Point.Zero)) { player = Team.Leader; } else { KeyValuePair <Player, Point> pair = Team.Formation .Where(kv => kv.Value.Equals(p)) .FirstOrDefault(); if (!pair.Equals(default(KeyValuePair <Player, Point>))) { player = pair.Key; } } } StackPane cell = grid[x, y]; cell.remove(cell.Children.ToArray()); if (player != null) { ImageItem image = new ImageItem(player.Image); image.SourceRectangle = new Rectangle(0, 0, 16, 16); image.PercentWidth = image.PercentHeight = 80; playerMap.Add(image, player); cell.add(image); } } } }
private static void StartGameDungeon() { // 1D446841 MessageBus gameBus = new MessageBus(); string seed = SingletonRandom.DefaultRNG.Next().ToString("X"); Console.WriteLine($"Generating dungeon with seed: {seed}"); Dungeon dungeon = new Dungeon(gameBus, new Rectangle(0, 0, 60, 40), Source.From <GenerationContext, IBiome>(Biomes.TestBiome), seed); JoystickConfig joystickConfig = new JoystickConfig { DownCode = Terminal.TK_S, LeftCode = Terminal.TK_A, RightCode = Terminal.TK_D, UpCode = Terminal.TK_W, MapUp = Terminal.TK_UP, MapDown = Terminal.TK_DOWN, MapRight = Terminal.TK_RIGHT, MapLeft = Terminal.TK_LEFT, Inventory = Terminal.TK_I, Equip = Terminal.TK_E }; Floor initialFloor = dungeon.Floors[0]; // Creating Player GameObject player = new UpdatingGameObject(new Coord(20, 20), Layers.Main, null, initialFloor.Timeline); Being playerBeing = new Being(new SelectedAttributes(new AttributeSet(6, 7, 7, 8, 8)), Alignment.PlayerAlignment, new EquipmentSlotSet(), 10, "You"); playerBeing.Equipment.Equip(new MeleeWeapon(new Damage(10)), EquipmentSlot.RightHandEquip); UserControlAgent control = new UserControlAgent(joystickConfig); gameBus.RegisterSubscriber <MouseMoveEvent>(control); gameBus.RegisterSubscriber <KeyEvent>(control); Actor playerActor = new Actor(playerBeing, control, gameBus); player.AddComponent(playerActor); player.AddComponent(new GlyphComponent(new Glyph(Characters.AT, Color.Aqua))); player.AddComponent(new LightSourceComponent(initialFloor.MapInfo.LightMap, new Light(Color.Aqua, Coord.NONE, 4, 5))); player.AddComponent(new FOVExplorerComponent()); player.AddComponent(new NameComponent(new Title("the", "Hero"))); EffectTargetComponent playerEffectTarget = new EffectTargetComponent(); playerEffectTarget.EffectTarget.AddEffectReceiver(playerActor); player.AddComponent(playerEffectTarget); playerEffectTarget.EffectTarget.ApplyEffect(new StaminaEffect(1, EffectKind.Repeating, new EventTimerTiming(25, 25))); Logger logger = new Logger(); gameBus.RegisterSubscriber(logger); MapViewPane mapViewPane = new MapViewPane(gameBus, joystickConfig, new InventoryDisplayPane(playerBeing.Equipment, playerBeing.Inventory, joystickConfig, gameBus), useFOV: true); EventHandler <ItemEventArgs <IGameObject> > mapChangeDirty = (sender, eventArgs) => mapViewPane.SetDirty(); EventHandler <ItemMovedEventArgs <IGameObject> > MapMoveDirty = (sender, eventArgs) => mapViewPane.SetDirty(); dungeon.OnFloorChange += (previousFloor, newFloor) => { mapViewPane.Map = newFloor.MapInfo.Map; mapViewPane.LightMap = newFloor.MapInfo.LightMap; if (previousFloor != null) { previousFloor.MapInfo.Map.ObjectRemoved -= mapChangeDirty; previousFloor.MapInfo.Map.ObjectMoved -= MapMoveDirty; previousFloor.MapInfo.Map.ObjectAdded -= mapChangeDirty; } newFloor.MapInfo.Map.ObjectRemoved += mapChangeDirty; newFloor.MapInfo.Map.ObjectMoved += MapMoveDirty; newFloor.MapInfo.Map.ObjectAdded += mapChangeDirty; mapViewPane.SetDirty(); }; TextPane descriptionPane = new TextPane("TEST TEXT"); Describer describer = new Describer(descriptionPane); describer.Map = initialFloor.MapInfo.Map; dungeon.OnFloorChange += (previousFloor, newFloor) => describer.Map = newFloor.MapInfo.Map; gameBus.RegisterSubscriber(describer); LogPane logPane = new LogPane(logger); StackPane mapAndConsole = new StackPane(StackPane.StackDirection.Vertical); mapAndConsole.AddChild(descriptionPane, 1); mapAndConsole.AddChild(mapViewPane, 5); mapAndConsole.AddChild(logPane, 1); StackPane statusBars = new StackPane(StackPane.StackDirection.Vertical); statusBars.AddChild(new FillBarPane(playerBeing.Health, "Health", Color.Red, Color.DarkRed), 1); statusBars.AddChild(new FillBarPane(playerBeing.Mana, "Mana", Color.Aqua, Color.DarkBlue), 1); statusBars.AddChild(new FillBarPane(playerBeing.Stamina, "Stamina", Color.Yellow, Color.DarkGoldenrod), 1); StackPane root = new StackPane(StackPane.StackDirection.Horizontal); root.AddChild(mapAndConsole, 4); root.AddChild(statusBars, 1); Window rootWindow = new Window(root, new Rectangle(0, 0, 160, 50), 0); BearTermRenderer renderer = new BearTermRenderer(rootWindow, "window.title='Spell Sword'; window.size=160x50; window.resizeable=true; input.filter=[keyboard+, mouse+, arrows+]"); gameBus.RegisterSubscriber <ParticleEvent>(renderer); gameBus.RegisterSubscriber <WindowEvent>(renderer); //WindowRouter windowRouter = new WindowRouter(); //windowRouter.Handle(WindowEvent.Open(root, new Rectangle(0, 0, 160, 50))); //mainBus.RegisterSubscriber(windowRouter); GameControlConsumer gameControlConsumer = new GameControlConsumer(joystickConfig, gameBus, mapViewPane); BearTermInputRouter inputRouter = new BearTermInputRouter(gameControlConsumer); gameBus.RegisterSubscriber(inputRouter); inputRouter.Handle(WindowEvent.Open(root, new Rectangle(0, 0, 160, 50))); for (int i = 1; i < 5; i++) { //GameObject goblin = TestUtil.CreateGoblin((5 + i, 5 + i % 2 + 1), playerActor, initialFloor.Timeline, initialFloor.GoalMapStore, initialFloor.MessageBus); //initialFloor.MapInfo.Map.AddEntity(goblin); } initialFloor.MapInfo.Map.AddEntity(player); dungeon.Handle(new FloorTransitionEvent(player, 0, 1)); dungeon.Handle(new FloorTransitionEvent(player, 1, 0)); Terminal.Refresh(); int lastFrame = Environment.TickCount; while (true) { inputRouter.HandleInput(); //control.VisualizeAim(playerActor); if (!control.WaitingForInput) { dungeon.Tick(); } if (Environment.TickCount - lastFrame > 20) { renderer.Refresh(); lastFrame = Environment.TickCount; } } }
private static void StartGame() { //Dungeon dungeon = new Dungeon(); // dungeon.Enter(); MessageBus mainBus = new MessageBus(); Timeline timeline = new Timeline(); MapInfo mapInfo = new MapGenerator(timeline, mainBus).Generate(120, 40, "helloseed"); Map map = mapInfo.Map; LightMap lightMap = mapInfo.LightMap; Spawner spawner = new Spawner(map); mainBus.RegisterSubscriber(spawner); JoystickConfig joystickConfig = new JoystickConfig { DownCode = Terminal.TK_S, LeftCode = Terminal.TK_A, RightCode = Terminal.TK_D, UpCode = Terminal.TK_W, MapUp = Terminal.TK_UP, MapDown = Terminal.TK_DOWN, MapRight = Terminal.TK_RIGHT, MapLeft = Terminal.TK_LEFT, Inventory = Terminal.TK_I, Equip = Terminal.TK_E }; //lightMap.AddLight(new Light(Color.AntiqueWhite, new Coord(1, 1), 15, 5)); lightMap.AddLight(new Light(Color.Wheat, new Coord(8, 8), 20, 10000)); // Creating Player GameObject player = new UpdatingGameObject(new Coord(20, 20), Layers.Main, null, timeline); Being playerBeing = new Being(new SelectedAttributes(new AttributeSet(10, 10, 10, 10, 10)), Alignment.PlayerAlignment, new EquipmentSlotSet(), 5, "You"); playerBeing.Equipment.Equip(new MeleeWeapon(new Damage(10)), EquipmentSlot.RightHandEquip); UserControlAgent control = new UserControlAgent(joystickConfig); mainBus.RegisterSubscriber <MouseMoveEvent>(control); mainBus.RegisterSubscriber <KeyEvent>(control); Actor playerActor = new Actor(playerBeing, control, mainBus); player.AddComponent(playerActor); player.AddComponent(new GlyphComponent(new Glyph(Characters.AT, Color.Aqua))); player.AddComponent(new LightSourceComponent(lightMap, new Light(Color.Aqua, Coord.NONE, 4, 8))); player.AddComponent(new FOVExplorerComponent()); player.AddComponent(new NameComponent(new Title("the", "Hero"))); EffectTargetComponent playerEffectTarget = new EffectTargetComponent(); playerEffectTarget.EffectTarget.AddEffectReceiver(playerActor); player.AddComponent(playerEffectTarget); playerEffectTarget.EffectTarget.ApplyEffect(new StaminaEffect(1, EffectKind.Repeating, new EventTimerTiming(25, 25))); Logger logger = new Logger(); mainBus.RegisterSubscriber(logger); MapViewPane viewPane = new MapViewPane(mainBus, joystickConfig, new InventoryDisplayPane(playerBeing.Equipment, playerBeing.Inventory, joystickConfig, mainBus)); viewPane.Map = map; viewPane.LightMap = lightMap; map.ObjectRemoved += (sender, eventArgs) => viewPane.SetDirty(); map.ObjectMoved += (sender, eventArgs) => viewPane.SetDirty(); map.ObjectAdded += (sender, eventArgs) => viewPane.SetDirty(); TextPane descriptionPane = new TextPane("TEST TEXT"); Describer describer = new Describer(descriptionPane); describer.Map = map; mainBus.RegisterSubscriber(describer); LogPane logPane = new LogPane(logger); StackPane mapAndConsole = new StackPane(StackPane.StackDirection.Vertical); mapAndConsole.AddChild(descriptionPane, 1); mapAndConsole.AddChild(viewPane, 5); mapAndConsole.AddChild(logPane, 1); StackPane statusBars = new StackPane(StackPane.StackDirection.Vertical); statusBars.AddChild(new FillBarPane(playerBeing.Health, "Health", Color.Red, Color.DarkRed), 1); statusBars.AddChild(new FillBarPane(playerBeing.Mana, "Mana", Color.Aqua, Color.DarkBlue), 1); statusBars.AddChild(new FillBarPane(playerBeing.Stamina, "Stamina", Color.Yellow, Color.DarkGoldenrod), 1); StackPane root = new StackPane(StackPane.StackDirection.Horizontal); root.AddChild(mapAndConsole, 4); root.AddChild(statusBars, 1); Window rootWindow = new Window(root, new Rectangle(0, 0, 160, 50), 0); BearTermRenderer renderer = new BearTermRenderer(rootWindow, "window.title='Spell Sword'; window.size=160x50; window.resizeable=true; input.filter=[keyboard+, mouse+, arrows+]"); mainBus.RegisterSubscriber <ParticleEvent>(renderer); mainBus.RegisterSubscriber <WindowEvent>(renderer); //WindowRouter windowRouter = new WindowRouter(); //windowRouter.Handle(WindowEvent.Open(root, new Rectangle(0, 0, 160, 50))); //mainBus.RegisterSubscriber(windowRouter); GameControlConsumer gameControlConsumer = new GameControlConsumer(joystickConfig, mainBus, viewPane); BearTermInputRouter inputRouter = new BearTermInputRouter(gameControlConsumer); mainBus.RegisterSubscriber(inputRouter); inputRouter.Handle(WindowEvent.Open(root, new Rectangle(0, 0, 160, 50))); GoalMapStore goalMapStore = new GoalMapStore(map); for (int i = 1; i < 5; i++) { //GameObject goblin = TestUtil.CreateGoblin((5 + i, 5 + i % 2 + 1), playerActor, timeline, goalMapStore, mainBus); //map.AddEntity(goblin); } map.AddEntity(player); Terminal.Refresh(); int lastFrame = Environment.TickCount; while (true) { inputRouter.HandleInput(); //control.VisualizeAim(playerActor); if (!control.WaitingForInput) { timeline.Advance(1); goalMapStore.UpdateMaps(); } if (Environment.TickCount - lastFrame > 20) { renderer.Refresh(); lastFrame = Environment.TickCount; } } }
public SettingsScreen(BesmashScreen parent) : base(parent) { IsPopup = true; // TODO test VList vlItems = new VList( new TextItem("Video", PRIMARY_FONT), new TextItem("Audio", PRIMARY_FONT), new TextItem("Controls", PRIMARY_FONT), new TextItem("Gameplay", PRIMARY_FONT), new TextItem("Back", PRIMARY_FONT) ); Config = new GameConfig(GameManager.Configuration); VideoSettingsPane vsPane = new VideoSettingsPane(Config); AudioSettingsPane asPane = new AudioSettingsPane(Config); ControlSettingsPane csPane = new ControlSettingsPane(Config); GameplaySettingsPane gsPane = new GameplaySettingsPane(Config); MessagePane msPane = new MessagePane(this, "Return to Main Menu"); StackPane spSettings = new StackPane(vsPane, asPane, csPane, gsPane, msPane); HPane hpMain = new HPane(vlItems, spSettings); hpMain.PercentWidth = 100; hpMain.PercentHeight = 100; spSettings.PercentWidth = 100; spSettings.PercentHeight = 100; spSettings.HAlignment = HAlignment.Left; vlItems.ActionEvent += (sender, args) => { showPane(vlItems.SelectedIndex, vsPane, asPane, csPane, gsPane); vlItems.IsFocused = args.SelectedIndex == 4; if (args.SelectedIndex == 4) { close(); } }; vsPane.PercentWidth = 80; vsPane.PercentHeight = 100; vsPane.HAlignment = HAlignment.Left; vsPane.FocusLossEvent += (sender, args) => vlItems.IsFocused = true; asPane.PercentWidth = 80; asPane.PercentHeight = 100; asPane.HAlignment = HAlignment.Left; asPane.FocusLossEvent += (sender, args) => vlItems.IsFocused = true; gsPane.PercentWidth = 80; gsPane.PercentHeight = 100; gsPane.HAlignment = HAlignment.Left; gsPane.FocusLossEvent += (sender, args) => vlItems.IsFocused = true; csPane.PercentWidth = 80; csPane.PercentHeight = 100; csPane.HAlignment = HAlignment.Left; csPane.FocusLossEvent += (sender, args) => vlItems.IsFocused = true; msPane.PercentWidth = 80; msPane.PercentHeight = 100; msPane.HAlignment = HAlignment.Left; vlItems.SelectedEvent += (sender, args) => { if (args.SelectedIndex == 0) { vsPane.show(false, 0.5f); } if (args.SelectedIndex == 1) { asPane.show(false, 0.5f); } if (args.SelectedIndex == 2) { csPane.show(false, 0.5f); } if (args.SelectedIndex == 3) { gsPane.show(false, 0.5f); } if (args.SelectedIndex == 4) { msPane.show(false, 0.5f); } }; vlItems.DeselectedEvent += (sender, args) => { if (args.SelectedIndex == 0) { vsPane.hide(false); } if (args.SelectedIndex == 1) { asPane.hide(false); } if (args.SelectedIndex == 2) { csPane.hide(false); } if (args.SelectedIndex == 3) { gsPane.hide(false); } if (args.SelectedIndex == 4) { msPane.hide(false); } }; vlItems.CancelEvent += (sender, args) => close(); vlItems.Color = Color.DarkSlateBlue; vlItems.Alpha = 0.3f; vlItems.IsFocused = true; vlItems.IsStatic = true; vlItems.PercentHeight = 100; vlItems.PercentWidth = 20; vlItems.HAlignment = HAlignment.Left; asPane.hide(); csPane.hide(); gsPane.hide(); msPane.hide(); vlItems.select(0); MainContainer.add(hpMain); }
public BattlePane(BattleManager battleManager) { BattleManager = battleManager; StackPane spMain = new StackPane(); spMain.PercentWidth = spMain.PercentHeight = 100; PercentWidth = PercentHeight = 100; hlThumbs = new HList(); hlThumbs.HAlignment = HAlignment.Left; hlThumbs.VAlignment = VAlignment.Top; hlThumbs.PercentWidth = 15; hlThumbs.PercentHeight = 15; hlThumbs.VisibleRange = 5; hlThumbs.Color = Color.Black; hlThumbs.Alpha = 0.5f; hpApCost = new HPane(); hpApCost.VAlignment = VAlignment.Top; hpApCost.PercentWidth = 100; hpApCost.Color = Color.Gray; hpApCost.Alpha = 0.5f; vlSkills = new VList(); vlSkills.PercentWidth = 100; vlSkills.VisibleRange = 3; vlSkills.IsStatic = false; vlSkills.Color = Color.Gray; vlSkills.Alpha = 0.5f; skillPane = new VPane(hpApCost, vlSkills); skillPane.HAlignment = HAlignment.Left; // skillPane.HAlignment = HAlignment.Left; // skillPane.VAlignment = VAlignment.Bottom; // skillPane.PercentWidth = 15; // skillPane.PercentHeight = 30; skillPane.PercentWidth = 100; skillPane.PercentHeight = 100; skillPane.Color = Color.Black; skillPane.Alpha = 0.5f; teamInfo = new TeamInfoPane(); teamInfo.HAlignment = HAlignment.Right; teamInfo.VAlignment = VAlignment.Bottom; teamInfo.PercentWidth = 40; teamInfo.PercentHeight = 20; teamInfo.Color = Color.Black; teamInfo.Alpha = 0.5f; objectInfo = new MapObjectInfoPane(); objectInfo.HAlignment = HAlignment.Right; objectInfo.VAlignment = VAlignment.Bottom; objectInfo.PercentWidth = 25; objectInfo.PercentHeight = 20; objectInfo.Color = Color.Black; objectInfo.Alpha = 0.5f; abilityInfo = new AbilityInfoPane(); abilityInfo.HAlignment = HAlignment.Left; abilityInfo.VAlignment = VAlignment.Bottom; // abilityInfo.HAlignment = HAlignment.Center; // abilityInfo.VAlignment = VAlignment.Bottom; abilityInfo.Color = Color.Black; abilityInfo.Alpha = 0.5f; HPane hpSkills = new HPane(skillPane, abilityInfo); hpSkills.HAlignment = HAlignment.Left; hpSkills.VAlignment = VAlignment.Bottom; hpSkills.PercentWidth = 15; hpSkills.PercentHeight = 30; vlSkills.ActionEvent += (sender, args) => { int s = args.SelectedIndex; if (player.ContainingMap.Slave is Cursor) { if (s == 0) { if (moveCost > player.AP || moveCost <= 0) { return; } movePath = new Queue <Point>(pathCache); moveCost = getMoveCost(player, movePath.Count); } else if (s > 0) { nextAbility = player.Abilities[s - 1]; } vlSkills.ControlLock = false; player.ContainingMap.hideCursor(); cursor.MoveStartedEvent -= onCursorMove; objectInfo.hide(); abilityInfo.hide(); hideSkillList(); // teamInfo.show(); // TODO looks to busy } else { int cost = s == 0 ? 10 : player.Abilities[s - 1].APCost; // TODO move cost if (cost > player.AP) { return; } playerPF = new Pathfinder(player); player.ContainingMap.showCursor(player.Position); cursor = player.ContainingMap.Cursor; cursor.MoveStartedEvent -= onCursorMove; cursor.MoveStartedEvent += onCursorMove; objectInfo.MapCursor = cursor; vlSkills.ControlLock = true; objectInfo.show(); teamInfo.hide(); abilityInfo.hide(); } }; vlSkills.CancelEvent += (sender, args) => { if (cursor == null) { return; } vlSkills.ControlLock = false; player.ContainingMap.hideCursor(); cursor.MoveStartedEvent -= onCursorMove; cursor = null; objectInfo.hide(); teamInfo.show(); }; vlSkills.SelectedEvent += (sender, args) => { int sel = args.SelectedIndex; if (sel > 0) { abilityInfo.Ability = player.Abilities[sel - 1]; abilityInfo.show(); } else { abilityInfo.hide(); } }; hlThumbs.SelectedEvent += (sender, args) => { int sel = args.SelectedIndex; int off = sel + hlThumbs.VisibleRange; if (off < hlThumbs.Children.Count) { (hlThumbs.Children[off] as MenuItem).Disabled = false; } }; // spMain.add(hlThumbs, skillPane, objectInfo, teamInfo, abilityInfo); spMain.add(hlThumbs, objectInfo, teamInfo, hpSkills); add(spMain); hide(); }
protected override void Init() { font = Content.Load <SpriteFont>("fonts/menu_font"); blank = Content.Load <Texture2D>("textures/blank"); background = new ImageItem(blank); background.HGrow = background.VGrow = 1; background.Color = Color.Black; background.Alpha = 0.5f; TextItem gameOver = new TextItem(font, "Game Over"); gameOver.HAlign = HAlignment.Center; gameOver.VAlign = VAlignment.Center; gameOver.IsSizeScaled = true; gameOver.Scale = 2; HPane hGameOver = new HPane(gameOver); hGameOver.HGrow = hGameOver.VGrow = 1; ImageItem bTop = new ImageItem(blank); bTop.HGrow = bTop.VGrow = 1; bTop.Color = Color.DarkGray; bTop.Alpha = 0.5f; ImageItem bBot = new ImageItem(blank); bBot.HGrow = bBot.VGrow = 1; bBot.Color = Color.Black; bBot.Alpha = 0.5f; StackPane sTop = new StackPane(bTop, hGameOver); sTop.VAlign = VAlignment.Center; sTop.HAlign = HAlignment.Center; sTop.HGrow = 0.5f; sTop.VGrow = 1; mainPane = new StackPane(bBot); mainPane.HAlign = HAlignment.Center; mainPane.VAlign = VAlignment.Center; mainPane.HGrow = 0.5f; mainPane.VGrow = 1; VPane vPane = new VPane(sTop, mainPane); vPane.HGrow = vPane.VGrow = 1; ViewPane.Clear(); RootPane = new StackPane(background, vPane); RootPane.HGrow = RootPane.VGrow = 1; ViewPane.Add(RootPane); Task.Run(() => { Game.Scores = FileManager.LoadHighscores(Game.ScoresPath); int pos = Game.AddHighscore(score, out kicked); if (score.MinesHit < score.TotalMines && pos <= Minestory.MAX_SCORES_PER_DIFF) { message = "New Highscore! Rank " + pos + ". Enter your Name:"; mainPane.Add(CreateTextInputPane(message)); } else { mainPane.Add(CreateNavPane()); } }); }
protected override void Init() { arrRight = Content.Load <Texture2D>("textures/arrow_right"); arrLeft = Content.Load <Texture2D>("textures/arrow_left"); font = Content.Load <SpriteFont>("fonts/menu_font"); blank = Content.Load <Texture2D>("textures/blank"); tabMap = new Dictionary <MapDifficulty, TabPane>(); selMap = new Dictionary <MapDifficulty, int>(); MenuItem leftDiff = new MenuItem(arrLeft, 32, 32); MenuItem rightDiff = new MenuItem(arrRight, 32, 32); MenuItem leftPage = new MenuItem(arrLeft, 32, 32); MenuItem rightPage = new MenuItem(arrRight, 32, 32); MenuItem back = new MenuItem("Back", font); leftDiff.VAlign = rightDiff.VAlign = VAlignment.Center; leftDiff.HAlign = rightDiff.HAlign = HAlignment.Center; leftPage.VAlign = rightPage.VAlign = VAlignment.Center; leftPage.HAlign = rightPage.HAlign = HAlignment.Center; back.HAlign = HAlignment.Center; back.VAlign = VAlignment.Top; TextItem diff = new TextItem(font, "Difficulty: " + game.Settings.Difficulty); diff.HAlign = HAlignment.Center; diff.VAlign = VAlignment.Center; HPane hDiff = new HPane(diff); hDiff.HAlign = HAlignment.Center; hDiff.HGrow = 0.4f; HPane hDiffArr = new HPane(leftDiff, hDiff, rightDiff); hDiffArr.HGrow = 1; tabMap.Add(MapDifficulty.Easy, CreateScoresPane(game.Scores.Where(s => s.Difficulty == MapDifficulty.Easy).ToList())); tabMap.Add(MapDifficulty.Medium, CreateScoresPane(game.Scores.Where(s => s.Difficulty == MapDifficulty.Medium).ToList())); tabMap.Add(MapDifficulty.Hard, CreateScoresPane(game.Scores.Where(s => s.Difficulty == MapDifficulty.Hard).ToList())); tabMap.Add(MapDifficulty.Custom, CreateScoresPane(game.Scores.Where(s => s.Difficulty == MapDifficulty.Custom).ToList())); TabPane tPane = new TabPane( tabMap[MapDifficulty.Easy], tabMap[MapDifficulty.Medium], tabMap[MapDifficulty.Hard], tabMap[MapDifficulty.Custom]); ImageItem tBack = new ImageItem(blank); tBack.HGrow = tBack.VGrow = 1; tBack.Color = Color.Black; tBack.Alpha = 0.42f; StackPane sPane = new StackPane(tBack, tPane); sPane.HAlign = HAlignment.Center; sPane.HGrow = sPane.VGrow = 1; tPane.HGrow = tPane.VGrow = 1; HPane hPane = new HPane(leftPage, sPane, rightPage); hPane.HAlign = HAlignment.Center; hPane.HGrow = hPane.VGrow = 1; VPane vPane = new VPane(hDiffArr, hPane, back); vPane.HGrow = vPane.VGrow = 1; ImageItem backItem = new ImageItem(Parent.Background); backItem.HGrow = backItem.VGrow = 1; ViewPane.Clear(); RootPane = new StackPane(backItem, vPane); RootPane.HGrow = RootPane.VGrow = 1; ViewPane.Add(RootPane); leftDiff.FocusGain += (s, a) => leftDiff.ImageItem.Color = Color.Yellow; leftDiff.FocusLoss += (s, a) => leftDiff.ImageItem.Color = Color.White; rightDiff.FocusGain += (s, a) => rightDiff.ImageItem.Color = Color.Yellow; rightDiff.FocusLoss += (s, a) => rightDiff.ImageItem.Color = Color.White; leftPage.FocusGain += (s, a) => leftPage.ImageItem.Color = Color.Yellow; leftPage.FocusLoss += (s, a) => leftPage.ImageItem.Color = Color.White; rightPage.FocusGain += (s, a) => rightPage.ImageItem.Color = Color.Yellow; rightPage.FocusLoss += (s, a) => rightPage.ImageItem.Color = Color.White; MapDifficulty selectedDiff = game.Settings.Difficulty; for (int i = 0; i < (int)selectedDiff; ++i) { tPane.NextTab(); } leftDiff.IsDisabled = (int)(selectedDiff) == 0; rightDiff.IsDisabled = (int)(selectedDiff) == 3; UpdateArrow(leftDiff); UpdateArrow(rightDiff); leftDiff.Action += (s, a) => { if (tPane.PrevTab()) { --selectedDiff; } leftDiff.IsDisabled = (int)(selectedDiff) == 0; rightDiff.IsDisabled = (int)(selectedDiff) == 3; diff.Text = "Difficulty: " + (MapDifficulty)selectedDiff; UpdateArrow(leftDiff); UpdateArrow(rightDiff); int sel = selMap[selectedDiff]; rightPage.IsDisabled = sel >= PageCount(selectedDiff) - 1; leftPage.IsDisabled = sel <= 0; UpdateArrow(leftPage); UpdateArrow(rightPage); }; rightDiff.Action += (s, a) => { if (tPane.NextTab()) { ++selectedDiff; } leftDiff.IsDisabled = (int)(selectedDiff) == 0; rightDiff.IsDisabled = (int)(selectedDiff) == 3; diff.Text = "Difficulty: " + (MapDifficulty)selectedDiff; UpdateArrow(leftDiff); UpdateArrow(rightDiff); int sel = selMap[selectedDiff]; rightPage.IsDisabled = sel >= PageCount(selectedDiff) - 1; leftPage.IsDisabled = sel <= 0; UpdateArrow(leftPage); UpdateArrow(rightPage); }; leftPage.IsDisabled = true; if (PageCount(selectedDiff) < 2) { rightPage.IsDisabled = true; } UpdateArrow(leftPage); UpdateArrow(rightPage); selMap.Add(MapDifficulty.Easy, 0); selMap.Add(MapDifficulty.Medium, 0); selMap.Add(MapDifficulty.Hard, 0); selMap.Add(MapDifficulty.Custom, 0); leftPage.Action += (s, a) => { int sel = (selMap[selectedDiff] = Math.Max(0, selMap[selectedDiff] - 1)); rightPage.IsDisabled = sel >= PageCount(selectedDiff) - 1; leftPage.IsDisabled = sel <= 0; tabMap[selectedDiff].PrevTab(); UpdateArrow(leftPage); UpdateArrow(rightPage); }; rightPage.Action += (s, a) => { int pc = PageCount(selectedDiff); int sel = (selMap[selectedDiff] = Math.Min(pc - 1, selMap[selectedDiff] + 1)); rightPage.IsDisabled = sel >= pc - 1; leftPage.IsDisabled = sel <= 0; tabMap[selectedDiff].NextTab(); UpdateArrow(leftPage); UpdateArrow(rightPage); }; back.FocusGain += (s, a) => back.TextItem.Color = Color.Yellow; back.FocusLoss += (s, a) => back.TextItem.Color = Color.White; back.Action += (s, a) => Close(); }
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); }
private static void MapGenerator() { Timeline timeline = new Timeline(); MessageBus mainBus = new MessageBus(); IMapGenerator generator = new MapGenerator(timeline, mainBus); IEnumerator <MapInfo> generationSteps = generator.GenerationSteps(60, 40, SingletonRandom.DefaultRNG.Next() + "").GetEnumerator(); generationSteps.MoveNext(); MapInfo mapInfo = generationSteps.Current; Map map = mapInfo.Map; Spawner spawner = new Spawner(map); JoystickConfig joystickConfig = new JoystickConfig { DownCode = Terminal.TK_S, LeftCode = Terminal.TK_A, RightCode = Terminal.TK_D, UpCode = Terminal.TK_W, MapUp = Terminal.TK_UP, MapDown = Terminal.TK_DOWN, MapRight = Terminal.TK_RIGHT, MapLeft = Terminal.TK_LEFT, Inventory = Terminal.TK_I, Equip = Terminal.TK_E }; MapViewPane viewPane = new MapViewPane(mainBus, joystickConfig, null, false); viewPane.Map = map; viewPane.LightMap = mapInfo.LightMap; map.ObjectRemoved += (sender, eventArgs) => viewPane.SetDirty(); map.ObjectMoved += (sender, eventArgs) => viewPane.SetDirty(); map.ObjectAdded += (sender, eventArgs) => viewPane.SetDirty(); TextPane descriptionPane = new TextPane(""); Describer describer = new Describer(descriptionPane); describer.Map = map; mainBus.RegisterSubscriber(describer); StackPane mapAndConsole = new StackPane(StackPane.StackDirection.Vertical); mapAndConsole.AddChild(descriptionPane, 1); mapAndConsole.AddChild(viewPane, 1); Window rootWindow = new Window(mapAndConsole, new Rectangle(0, 0, 120, 41), 0); BearTermRenderer renderer = new BearTermRenderer(rootWindow, "window.title='Spell Sword'; window.size=120x41; window.resizeable=true; input.filter=[keyboard+, mouse+, arrows+]"); mainBus.RegisterSubscriber <ParticleEvent>(renderer); mainBus.RegisterSubscriber <WindowEvent>(renderer); GameControlConsumer gameControlConsumer = new GameControlConsumer(joystickConfig, mainBus, viewPane); BearTermInputRouter inputRouter = new BearTermInputRouter(gameControlConsumer); mainBus.RegisterSubscriber(inputRouter); inputRouter.Handle(WindowEvent.Open(mapAndConsole, new Rectangle(0, 0, 120, 41))); Terminal.Refresh(); int lastFrame = Environment.TickCount; Stopwatch timer = new Stopwatch(); timer.Start(); int frames = 0; while (generationSteps.MoveNext()) { inputRouter.HandleInput(); renderer.Refresh(); // Artificially slow generation process while (Environment.TickCount - lastFrame < 50) { } lastFrame = Environment.TickCount; frames += 1; } double duration = timer.Elapsed.TotalSeconds; double fps = frames / duration; Console.WriteLine($"Generation and rendering took: {duration} seconds"); Console.WriteLine($"Rendering took place at: {fps} fps"); while (true) { inputRouter.HandleInput(); renderer.Refresh(); } //Console.ReadKey(); }
protected override void Init() { Background = Content.Load <Texture2D>("textures/home_back"); banner = Content.Load <Texture2D>("textures/banner"); font = Content.Load <SpriteFont>("fonts/menu_font"); backItem = new ImageItem(Background); backItem.HGrow = backItem.VGrow = 1; MenuItem start = new MenuItem("Start Game", font); MenuItem highscore = new MenuItem("Highscores", font); MenuItem settings = new MenuItem("Settings", font); MenuItem quit = new MenuItem("Quit", font); start.FocusGain += (s, a) => start.TextItem.Color = Color.Yellow; settings.FocusGain += (s, a) => settings.TextItem.Color = Color.Yellow; highscore.FocusGain += (s, a) => highscore.TextItem.Color = Color.Yellow; quit.FocusGain += (s, a) => quit.TextItem.Color = Color.Yellow; start.FocusLoss += (s, a) => start.TextItem.Color = Color.White; settings.FocusLoss += (s, a) => settings.TextItem.Color = Color.White; highscore.FocusLoss += (s, a) => highscore.TextItem.Color = Color.White; quit.FocusLoss += (s, a) => quit.TextItem.Color = Color.White; // ListMenu menu = new ListMenu(start, settings, highscore, quit); // TODO fix ctor ListMenu menu = new ListMenu(); menu.ItemsOrientation = Orientation.Vertical; menu.VAlign = VAlignment.Top; menu.AddItem(start); menu.AddItem(highscore); menu.AddItem(settings); menu.AddItem(quit); HPane menuPane = new HPane(menu); menuPane.HAlign = HAlignment.Center; menuPane.VGrow = 1; ImageItem bannerItem = new ImageItem(banner, 400, 200); bannerItem.VAlign = VAlignment.Center; bannerItem.HGrow = 1; HPane bannerPane = new HPane(bannerItem); bannerPane.HGrow = bannerPane.VGrow = 1; VPane vPane = new VPane(bannerPane, menuPane); vPane.HAlign = HAlignment.Center; vPane.HGrow = 0.8f; vPane.VGrow = 1; ViewPane.Clear(); RootPane = new StackPane(backItem, vPane); RootPane.HGrow = RootPane.VGrow = 1; ViewPane.Add(RootPane); start.Action += (s, a) => { Manager.Add(Game.CreateMapView(this)); Hide(); }; settings.Action += (s, a) => { Manager.Add(new SettingsView(this, Game)); Hide(); }; highscore.Action += (s, a) => { Manager.Add(new HighscoreView(this, Game)); Hide(); }; quit.Action += (s, a) => Close(); }
public GameMenuScreen(GameplayScreen parent) : base(parent) { TextItem entryStatus = new TextItem("Status", "fonts/menu_font1"); TextItem entryFormation = new TextItem("Formation", "fonts/menu_font1"); TextItem entryInventory = new TextItem("Inventory", "fonts/menu_font1"); TextItem entrySettings = new TextItem("Settings", "fonts/menu_font1"); TextItem entryQuit = new TextItem("Quit", "fonts/menu_font1"); VList menuEntries = new VList(entryStatus, entryFormation, entryInventory, entrySettings, entryQuit); menuEntries.PercentWidth = 25; menuEntries.PercentHeight = 100; menuEntries.HAlignment = HAlignment.Left; menuEntries.Color = Color.Black; menuEntries.Alpha = 0.5f; menuEntries.IsFocused = true; IsPopup = true; TeamStatusPane teamStatus = new TeamStatusPane(); teamStatus.PercentWidth = 75; teamStatus.PercentHeight = 100; teamStatus.HAlignment = HAlignment.Right; TeamFormationPane teamFormation = new TeamFormationPane(); teamFormation.PercentWidth = 75; teamFormation.PercentHeight = 100; teamFormation.HAlignment = HAlignment.Right; teamStatus.FocusLossEvent += (sender, args) => menuEntries.IsFocused = true; teamFormation.FocusLossEvent += (sender, args) => menuEntries.IsFocused = true; menuEntries.ActionEvent += (sender, args) => { if (args.SelectedItem == entryStatus) { menuEntries.IsFocused = false; teamStatus.Team = GameManager.ActiveSave.Team; teamStatus.show(); } if (args.SelectedItem == entryFormation) { menuEntries.IsFocused = false; teamFormation.Team = GameManager.ActiveSave.Team; teamFormation.show(); } if (args.SelectedItem == entryInventory) { // TODO } if (args.SelectedItem == entrySettings) { // if(IsHidden) show(); else hide(); SettingsScreen settingsScreen = new SettingsScreen(this); ScreenManager.AddScreen(settingsScreen, null); } if (args.SelectedItem == entryQuit) { ExitScreen(); parent.quit(true); } }; menuEntries.CancelEvent += (sender, args) => { Alpha = 0; ExitScreen(); }; HideParent = false; MainContainer.Alpha = 0.5f; MainContainer.Color = Color.Black; StackPane sp = new StackPane(menuEntries, teamStatus, teamFormation); sp.PercentWidth = sp.PercentHeight = 100; MainContainer.add(sp); }
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); }