public void OpenPlanetScreen(ViewController view, Desktop desktop, System system) { //Debug.WriteLine("planet in system " + systemId); //parentScreen.AddChildScreen(new PlanetScreen(2, "planetscreen", new PlanetScreenAlign(parentScreen, planetId), systemId, planetId)); var PlanetWindow = new Window { Background = new TextureRegion(Assets.GetTexture("planetscreen"), new Rectangle(0, 0, 320, 294)), Title = system.name + Constants.PlanetNames[planetId], Width = 560, Height = 560 }; var Panel = new Panel { }; var PlanetInfoStack = new VerticalStackPanel { Spacing = 60 }; var Disposition = new Label { Text = "Disposition ???/100", Border = new SolidBrush(new Color(128, 128, 128)), BorderThickness = new Thickness(4), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top }; PlanetInfoStack.AddChild(Disposition); var PlanetTypeImage = new Image { Background = new TextureRegion(Assets.PlanetTypeTextures[GetTypeTexture()]), Width = 128, Height = 128, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; PlanetInfoStack.AddChild(PlanetTypeImage); Panel.AddChild(PlanetInfoStack); PlanetWindow.Content = Panel; PlanetWindow.ShowModal(desktop); }
public void AddRemove() { var stackPanel = new VerticalStackPanel(); var label1 = new Label(); var label2 = new Label(); var label3 = new Label(); stackPanel.AddChild(label1); stackPanel.AddChild(label2); stackPanel.AddChild(label3); stackPanel.RemoveChild(label2); Assert.AreEqual(2, stackPanel.Widgets.Count); Assert.AreEqual(label1, stackPanel.Widgets[0]); Assert.AreEqual(label3, stackPanel.Widgets[1]); }
public override void LoadContent() { this.Logo = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\twister"); this._font = this.GameManager.Game.Content.Load <SpriteFont>(@"Fonts\MenuFont"); SpriteFont bigFont = this.GameManager.Game.Content.Load <SpriteFont>(@"Fonts\GameFont"); PopSound = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\POP2"); this.Assets.Add(Logo); this.Assets.Add(PopSound); _configurePanel.Bounds = new Rectangle(20, 0, 780, 480); _configurePanel.HorizontalAlignment = HorizontalAlignment.Left; XnaLabel label = new XnaLabel(new Rectangle(0, 0, 800, 100)); label.HorizontalAlignment = HorizontalAlignment.Left; label.Font = bigFont; label.FontZoom = 1.0f; label.Text = "Select Difficulty.."; _configurePanel.AddChild(label); foreach (TwisterDifficulty diff in new TwisterDifficulty[] { TwisterDifficulty.Beginner, TwisterDifficulty.Intermediate, TwisterDifficulty.Master }) { XnaButton difficultyButton = new XnaButton(new Rectangle(0, 0, 800, 80)); difficultyButton.Tag = diff; difficultyButton.HorizontalAlignment = HorizontalAlignment.Left; difficultyButton.Font = bigFont; difficultyButton.FontZoom = 0.8f; difficultyButton.Text = diff.ToString(); difficultyButton.Click += new EventHandler(difficultyButton_Click); if (FingerGames.IsTrial && diff != TwisterDifficulty.Intermediate) { difficultyButton.Color = new Color(110, 110, 110); } _configurePanel.AddChild(difficultyButton); } base.LoadContent(); }
public override void LoadContent() { LeftFoot = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\leftfoot"); RightFoot = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\rightfoot"); Hurdle = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\hurdle"); this._track = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\track"); this._font = this.GameManager.Game.Content.Load <SpriteFont>(@"Fonts\FixedWidthFont"); this._fixedFont = this._font; _leftFootDrum = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\FootDrum"); _rightFootDrum = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\FootDrum"); this.Logo = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\runner"); this._raceFlags = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\racerflags"); this.Assets.Add(LeftFoot); this.Assets.Add(RightFoot); this.Assets.Add(Hurdle); this.Assets.Add(_track); this.Assets.Add(_leftFootDrum); this.Assets.Add(_rightFootDrum); this.Assets.Add(Logo); this.Assets.Add(_raceFlags); this._timePanel.Bounds = new Rectangle(0, 10, 800, 470); this._timePanel.FixedSize = true; XnaImage flagsImage = new XnaImage(this._raceFlags, new Rectangle(0, 0, this._raceFlags.Width, this._raceFlags.Height)); XnaLabel completedLabel = new XnaLabel(new Rectangle(0, 0, 800, 90)); completedLabel.BackColor = new Color(0, 0, 0, 150); completedLabel.FontZoom = 1.5f; completedLabel.Text = "Race Completed!"; this._timePanel.AddChild(flagsImage); this._timePanel.AddChild(completedLabel); this._timePanel.AddChild(_timeLabel); this._timePanel.AddChild(_timeLabel2); SpriteFont bigFont = this.GameManager.Game.Content.Load <SpriteFont>(@"Fonts\GameFont"); _configurePanel.Bounds = new Rectangle(20, 0, 780, 480); _configurePanel.HorizontalAlignment = HorizontalAlignment.Left; XnaLabel label = new XnaLabel(new Rectangle(0, 0, 800, 100)); label.HorizontalAlignment = HorizontalAlignment.Left; label.Font = bigFont; label.FontZoom = 1.0f; label.Text = "Select Race Length.."; _configurePanel.AddChild(label); int index = 0; foreach (RaceLengths diff in new RaceLengths[] { RaceLengths.Sprint, RaceLengths.Medium, RaceLengths.Marathon }) { XnaButton raceLengthButton = new XnaButton(new Rectangle(0, 0, 800, 80)); raceLengthButton.Tag = diff; raceLengthButton.HorizontalAlignment = HorizontalAlignment.Left; raceLengthButton.Font = bigFont; raceLengthButton.FontZoom = 0.8f; raceLengthButton.Text = diff.ToString(); raceLengthButton.Click += new EventHandler(raceLengthButton_Click); if (FingerGames.IsTrial && index > 0) { raceLengthButton.Color = new Color(110, 110, 110); } _configurePanel.AddChild(raceLengthButton); index++; } base.LoadContent(); }
private void BuildUI() { Left = 0; Top = 0; ItemListBox = new ListBox(); ItemListBox.Id = "ItemListBox"; TopPanel = new HorizontalStackPanel() { Padding = new Thickness(10), Margin = new Thickness(0, 10, 0, 0), }; HintText = new Label() { Margin = new Thickness(10, 0, 0, 10), TextColor = Color.White, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom }; TopPanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; TopPanel.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Top; for (var i = 0; i < 8; i++) { var panel = new Panel(); panel.Width = 64; panel.Height = 64; panel.VerticalAlignment = VerticalAlignment.Center; var inventorySlotBackground = new Image(); inventorySlotBackground.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; inventorySlotBackground.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Stretch; var inventorySlotItemImage = new Image(); inventorySlotItemImage.Width = 32; inventorySlotItemImage.Height = 32; inventorySlotItemImage.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; inventorySlotItemImage.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center; var inventorySlotCount = new Label(); inventorySlotCount.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right; inventorySlotCount.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Bottom; InventorySlotBackgrounds.Add(inventorySlotBackground); InventorySlotItemImages.Add(inventorySlotItemImage); InventorySlotItemCounts.Add(inventorySlotCount); panel.Widgets.Add(inventorySlotBackground); panel.Widgets.Add(inventorySlotItemImage); panel.Widgets.Add(inventorySlotCount); TopPanel.Widgets.Add(panel); } var topPanel = new Panel() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, Background = null, Padding = new Thickness(5) }; InventoryPanel = new VerticalStackPanel() { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Background = new SolidBrush(Color.Black * 0.5f), IsDraggable = true, DragHandle = topPanel }; InventoryPanel.AddChild(topPanel); topPanel.AddChild(new Label() { Text = "Inventory", TextColor = Color.White, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); var closeInventoryButton = topPanel.AddChild(new TextButton() { Text = "x", Background = null, FocusedBackground = null, OverBackground = null, PressedBackground = null, DisabledBackground = null, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center }); closeInventoryButton.Click += (sender, args) => InventoryPanel.Visible = false; for (var i = 0; i < 4; i++) { var horizontalRow = new HorizontalStackPanel(); for (var j = 0; j < 6; j++) { var panel = new Panel(); panel.Width = 64; panel.Height = 64; var inventorySlotBackground = new Image(); inventorySlotBackground.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; inventorySlotBackground.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Stretch; var inventorySlotItemImage = new Image(); inventorySlotItemImage.Width = 32; inventorySlotItemImage.Height = 32; inventorySlotItemImage.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; inventorySlotItemImage.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center; var inventorySlotCount = new Label(); inventorySlotCount.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right; inventorySlotCount.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Bottom; MainInventorySlotBackgrounds.Add(inventorySlotBackground); MainInventorySlotItemImages.Add(inventorySlotItemImage); MainInventorySlotItemCounts.Add(inventorySlotCount); panel.Widgets.Add(inventorySlotBackground); panel.Widgets.Add(inventorySlotItemImage); panel.Widgets.Add(inventorySlotCount); horizontalRow.AddChild(panel); } InventoryPanel.AddChild(horizontalRow); } ; Widgets.Add(ItemListBox); Widgets.Add(TopPanel); Widgets.Add(InventoryPanel); Widgets.Add(HintText); }
public FactionCreatorState(GameManager gameManager, GraphicsDevice graphicsDevice, ContentManager contentManager) : base(gameManager, graphicsDevice, contentManager) { this.gameManager = gameManager; this.graphicsDevice = graphicsDevice; SpriteBatch = new SpriteBatch(graphicsDevice); viewController = new MenuViewController(); GameManager.graphics.PreferredBackBufferWidth = GameManager.window.ClientBounds.Width; GameManager.graphics.PreferredBackBufferHeight = GameManager.window.ClientBounds.Height; viewController.viewPortWidth = GameManager.window.ClientBounds.Width; viewController.viewPortHeight = GameManager.window.ClientBounds.Height; GameManager.graphics.ApplyChanges(); // I'm not questioning why this works. _factionCreator = new Desktop(); var Panel = new Panel { Background = new TextureRegion(Assets.GetTexture("faction_creator_background")) }; var BackButtonTexture = new TextureRegion(Assets.GetButton("back")); var BackButton = new ImageButton { Background = BackButtonTexture, OverImage = BackButtonTexture, Width = 128, Height = 32, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 0, 20) }; BackButton.TouchDown += (s, a) => { gameManager.ChangeState(new CampaignPickerState(gameManager, gameManager.GraphicsDevice, gameManager.Content)); }; Panel.AddChild(BackButton); var StartButtonTexture = new TextureRegion(Assets.GetButton("ui_but_0")); var StartButton = new TextButton { //Background = StartButtonTexture, //OverImage = StartButtonTexture, Text = "Start", TextColor = Color.White, Width = 128, Height = 32, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 20, 20) }; StartButton.TouchDown += (s, a) => { // Initialize Sector with Faction information. playerFaction = new Faction(); playerFaction.Name = "TODO"; // TODO ChapterMaster.Sector.Factions.Add(playerFaction.Name, playerFaction); ChapterMaster.Sector.CurrentFaction = playerFaction.Name; gameManager.ChangeState(new GameState(gameManager, gameManager.GraphicsDevice, gameManager.Content, false)); }; Panel.AddChild(StartButton); var FactionPickerBackground = new TextureRegion(Assets.GetTexture("campaign_picker")); var FactionPicker = new Panel { Background = FactionPickerBackground, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, //Width = 800, //Height = 1000, }; FactionPicker.Layout2d.Expresion = "this.w=W.w*0.45;this.h=W.h*0.95"; // TODO SET THIS UP var FactionVertical = new VerticalStackPanel { //HorizontalAlignment = HorizontalAlignment.Center }; var SelectFactionLabel = new Label { Text = "Select Chapter", Font = Assets.CaslonAntiqueBoldFSS.GetFont(32), TextColor = new Color(0, 143, 0), HorizontalAlignment = HorizontalAlignment.Center, //Width = , Height = 80, Margin = new Thickness(0, 40, 0, 0) }; FactionVertical.AddChild(SelectFactionLabel); var FoundingChaptersLabel = new Label { Text = "Founding Chapters", Font = Assets.CaslonAntiqueBoldFSS.GetFont(32), TextColor = new Color(0, 143, 0), HorizontalAlignment = HorizontalAlignment.Left, //Width = , Height = 80, Margin = new Thickness(20, 0, 0, 0) }; FactionVertical.AddChild(FoundingChaptersLabel); var FoundingChapters = new Grid { ColumnSpacing = 16, RowSpacing = 30, ShowGridLines = false, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(15, 0, 0, 0) }; for (int i = 1; i < 10; i++) { var ChapterTexture = new TextureRegion(Assets.GetIcon("founding_chapter_" + i)); var ChapterButton = new ImageButton { Background = ChapterTexture, OverImage = ChapterTexture, GridColumn = i - 1 //Width = 32, //Height = 32, }; ChapterButton.Layout2d.Expresion = "this.w = W.w*0.04; this.h = W.h*0.04"; ChapterButton.TouchDown += (s, a) => { // TODO: set up faction chosed by player }; FoundingChapters.AddChild(ChapterButton); } FactionVertical.AddChild(FoundingChapters); var SuccessorChaptersLabel = new Label { Text = "Successor Chapters", Font = Assets.CaslonAntiqueBoldFSS.GetFont(32), TextColor = new Color(0, 143, 0), HorizontalAlignment = HorizontalAlignment.Left, //Width = , Height = 80, Margin = new Thickness(20, 0, 0, 0) }; FactionVertical.AddChild(SuccessorChaptersLabel); var SuccessorChapters = new Grid { ColumnSpacing = 16, RowSpacing = 30, ShowGridLines = false, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(15, 0, 0, 0) }; for (int i = 1; i < 5; i++) { var ChapterTexture = new TextureRegion(Assets.GetIcon("successor_chapter_" + i)); var ChapterButton = new ImageButton { Background = ChapterTexture, OverImage = ChapterTexture, GridColumn = i - 1, //Width = 32, //Height = 32, }; ChapterButton.Layout2d.Expresion = "this.w = W.w*0.04; this.h = W.h*0.04"; ChapterButton.TouchDown += (s, a) => { // TODO: set up faction chosed by player }; SuccessorChapters.AddChild(ChapterButton); } FactionVertical.AddChild(SuccessorChapters); var CustomFactionsLabel = new Label { Text = "Custom Factions", Font = Assets.CaslonAntiqueBoldFSS.GetFont(32), TextColor = new Color(0, 143, 0), HorizontalAlignment = HorizontalAlignment.Left, //Width = , Height = 80, Margin = new Thickness(20, 0, 0, 0) }; FactionVertical.AddChild(CustomFactionsLabel); var CustomFactions = new Grid { ColumnSpacing = 16, RowSpacing = 30, ShowGridLines = false, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(15, 0, 0, 0) }; var CustomFactionButton = new TextButton { Text = "Create Marine Chapter", TextColor = Color.White, Width = 128, Height = 32, //VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 0, 0) }; CustomFactionButton.TouchDown += (s, e) => { }; CustomFactions.AddChild(CustomFactionButton); FactionVertical.AddChild(CustomFactions); var OrkKlansLabel = new Label { Text = "Ork Klans", Font = Assets.CaslonAntiqueBoldFSS.GetFont(32), TextColor = new Color(0, 143, 0), HorizontalAlignment = HorizontalAlignment.Left, //Width = , Height = 80, Margin = new Thickness(20, 0, 0, 0) }; FactionVertical.AddChild(OrkKlansLabel); var OrkKlans = new Grid { ColumnSpacing = 16, RowSpacing = 30, ShowGridLines = false, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(15, 0, 0, 0) }; FactionVertical.AddChild(OrkKlans); //Button exitButton = new Button("back", "", new CornerAlign(Corner.BOTTOMLEFT, 128, 32, 64), Back); //This button does not want to be put into subAlign. Finish adjusting CornerAlign //Button startButton = new Button("ui_but_0", "START", new CornerAlign(Corner.BOTTOMRIGHT, 128, 32, rightMargin:64), Start); //TextBox factionNameBox = new TextBox("textbox", "Faction Name", new CornerAlign(Corner.TOPLEFT, 250, 50, leftMargin:64,topMargin:20), outOfFocus:FactionName); //TextBox homeWorldNameBox = new TextBox("textbox", "Homeworld Name", new CornerAlign(Corner.TOPLEFT, 250, 50, leftMargin:64,topMargin:100), outOfFocus:HomeWorldName); FactionPicker.AddChild(FactionVertical); Panel.AddChild(FactionPicker); _factionCreator.Widgets.Add(Panel); _factionCreator.InvalidateLayout(); _factionCreator.UpdateLayout(); }
public CampaignPickerState(GameManager gameManager, GraphicsDevice graphicsDevice, ContentManager contentManager) : base(gameManager, graphicsDevice, contentManager) { this.gameManager = gameManager; this.graphicsDevice = graphicsDevice; SpriteBatch = new SpriteBatch(graphicsDevice); viewController = new MenuViewController(); GameManager.graphics.PreferredBackBufferWidth = GameManager.window.ClientBounds.Width; GameManager.graphics.PreferredBackBufferHeight = GameManager.window.ClientBounds.Height; viewController.viewPortWidth = GameManager.window.ClientBounds.Width; viewController.viewPortHeight = GameManager.window.ClientBounds.Height; GameManager.graphics.ApplyChanges(); // I'm not questioning why this works. _campaignPicker = new Desktop(); var Panel = new Panel { Background = new TextureRegion(Assets.GetTexture("faction_creator_background")) }; var BackButtonTexture = new TextureRegion(Assets.GetButton("back")); var BackButton = new ImageButton { Background = BackButtonTexture, OverImage = BackButtonTexture, Width = 128, Height = 32, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 0, 20) }; BackButton.TouchDown += (s, a) => { gameManager.ChangeState(new MenuState(gameManager, gameManager.GraphicsDevice, gameManager.Content)); }; Panel.AddChild(BackButton); var CampaignPicker = new Panel { Background = new TextureRegion(Assets.GetTexture("campaign_picker")), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Width = 400, Height = 500 }; CampaignPicker.Layout2d.Expresion = "this.w=W.w*0.45;this.h=W.h*0.95"; var CampaignButtons = new VerticalStackPanel { HorizontalAlignment = HorizontalAlignment.Left }; var SpaceMarineTexture = new TextureRegion(Assets.GetButton("space_marine")); var SpaceMarine = new ImageButton { Background = SpaceMarineTexture, OverImage = SpaceMarineTexture, Width = 64, Height = 128, Margin = new Thickness(40, 40, 0, 0) }; SpaceMarine.TouchDown += (s, a) => { gameManager.ChangeState(new FactionCreatorState(gameManager, gameManager.GraphicsDevice, gameManager.Content)); }; CampaignButtons.AddChild(SpaceMarine); CampaignPicker.AddChild(CampaignButtons); Panel.AddChild(CampaignPicker); _campaignPicker.Widgets.Add(Panel); _campaignPicker.InvalidateLayout(); _campaignPicker.UpdateLayout(); }
public override void LoadContent() { this._font = this.GameManager.Game.Content.Load <SpriteFont>(@"Fonts\GameFont"); this._engineIdle = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\Engine").CreateInstance(); this._carScreech = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\pop").CreateInstance(); this._carHorn = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\Horn").CreateInstance(); this.Logo = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\racer"); this._car = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\car"); this._raceFlags = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\racerflags"); _textureMap.Add(TilePiece.Grass, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\grass")); _textureMap.Add(TilePiece.TopLeft, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\tl")); _textureMap.Add(TilePiece.TopRight, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\tr")); _textureMap.Add(TilePiece.BottomLeft, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\bl")); _textureMap.Add(TilePiece.BottomRight, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\br")); _textureMap.Add(TilePiece.Horizontal, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\h")); _textureMap.Add(TilePiece.Vertical, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\v")); _textureMap.Add(TilePiece.Start, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\tl")); this.Assets.Add(_engineIdle); this.Assets.Add(_carScreech); this.Assets.Add(_carHorn); this.Assets.Add(Logo); this.Assets.Add(_car); this.Assets.Add(_raceFlags); foreach (IDisposable asset in _textureMap.Values) { this.Assets.Add(asset); } this._engineIdle.Volume = this._carScreech.Volume = this._carHorn.Volume = 0.5f; this._engineIdle.IsLooped = true; _mapPanel.Bounds = new Rectangle(0, 0, 800, 480); int mapCount = 0; HorizontalStackPanel panel = null; foreach (string mapName in MapNames) { string mapData = this.GameManager.Game.Content.Load <string>(@"RacerMaps\" + mapName).Trim(); LoadedMaps.Add(mapName, mapData); if (null == panel) { panel = new HorizontalStackPanel(); panel.VerticalAlignment = VerticalAlignment.Middle; panel.FixedSize = false; panel.Bounds = new Rectangle(0, 0, 800, 180); _mapPanel.AddChild(panel); } VerticalStackPanel vertPanel = new VerticalStackPanel(); vertPanel.Bounds = new Rectangle(0, 0, 200, 150); XnaRaceTrackTile tile = new XnaRaceTrackTile(_textureMap, mapName, mapData); tile.Tag = tile; tile.Bounds = new Rectangle(0, 0, 200, 120); tile.Click += new EventHandler(mapTile_Click); XnaButton button = new XnaButton(new Rectangle(0, 0, 250, 30)); button.Tag = tile; button.Text = mapName; button.FontZoom = 0.5f; button.Click += new EventHandler(mapTile_Click); if (FingerGames.IsTrial && mapCount > 2) { button.Color = new Color(110, 110, 110); } vertPanel.AddChild(tile); vertPanel.AddChild(button); panel.AddChild(vertPanel); mapCount++; if ((mapCount % 3) == 0) { panel = null; } } _mapPanel.ForceLayout(); float maxX = 0; for (int i = 0; i < 10; ++i) { maxX = Math.Max(maxX, _font.MeasureString(i.ToString()).X); } _decimalWidth = maxX * 1.05f / 2; this._timePanel.Bounds = new Rectangle(0, 10, 800, 470); this._timePanel.FixedSize = true; XnaImage flagsImage = new XnaImage(this._raceFlags, new Rectangle(0, 0, this._raceFlags.Width, this._raceFlags.Height)); XnaLabel completedLabel = new XnaLabel(new Rectangle(0, 0, 800, 90)); completedLabel.BackColor = new Color(0, 0, 0, 150); completedLabel.FontZoom = 1.5f; completedLabel.Text = "Race Completed!"; this._timePanel.AddChild(flagsImage); this._timePanel.AddChild(completedLabel); this._timePanel.AddChild(_timeLabel); base.LoadContent(); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); _font = Content.Load <SpriteFont>("MainFont"); _fontSmall = Content.Load <SpriteFont>("FontSmall"); // TODO: use this.Content to load your game content MyraEnvironment.Game = this; var vstack = new VerticalStackPanel(); vstack.AddChild(new Label { Id = "hello", Text = "This is synthy." }); var kbdBtn = new TextButton { Text = $"Keyboard ({Piano.Devices.Count}): {Piano.SelectedDevice?.Name}" }; kbdBtn.Click += (s, a) => { Piano.Rotate(); kbdBtn.Text = $"Keyboard: {Piano.SelectedDevice?.Name}"; }; vstack.AddChild(kbdBtn); vstack.AddChild(new Label { Id = "Songs", Text = "Songs:" }); var hstack = new HorizontalStackPanel(); hstack.AddChild(new Label { Id = "sldjk", Text = "Time Window: " }); var timeWindowLabel = new Label { Id = "twL", Text = $"{Settings.TimeWindowMillis} ms" }; var plusBtn = new TextButton { Text = " + " }; plusBtn.Click += (sender, args) => { Settings.TimeWindowMillis += 50; timeWindowLabel.Text = $"{Settings.TimeWindowMillis} ms"; }; var minusBtn = new TextButton { Text = " - " }; minusBtn.Click += (sender, args) => { if ((Settings.TimeWindowMillis - 50) != 0) { Settings.TimeWindowMillis -= 50; } timeWindowLabel.Text = $"{Settings.TimeWindowMillis} ms"; }; hstack.AddChild(minusBtn); hstack.AddChild(timeWindowLabel); hstack.AddChild(plusBtn); vstack.AddChild(hstack); foreach (var file in Directory.GetFiles(Program.SynthyRoot, "*.mid*")) { var btn = new TextButton { Text = file }; btn.Click += (sender, args) => { this._currentSong = new Song(btn.Text, this); this._currentSong.Start(); }; vstack.AddChild(btn); } _desktop = new Desktop(); _desktop.Root = vstack; Textures.InitTextures(this); OnScreenPiano = new DrawnPiano(this); }
public override void LoadContent() { this._font = this.GameManager.Game.Content.Load<SpriteFont>(@"Fonts\GameFont"); this._engineIdle = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\Engine").CreateInstance(); this._carScreech = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\pop").CreateInstance(); this._carHorn = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\Horn").CreateInstance(); this.Logo = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\racer"); this._car = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\car"); this._raceFlags = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\racerflags"); _textureMap.Add(TilePiece.Grass, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\grass")); _textureMap.Add(TilePiece.TopLeft, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tl")); _textureMap.Add(TilePiece.TopRight, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tr")); _textureMap.Add(TilePiece.BottomLeft, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\bl")); _textureMap.Add(TilePiece.BottomRight, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\br")); _textureMap.Add(TilePiece.Horizontal, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\h")); _textureMap.Add(TilePiece.Vertical, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\v")); _textureMap.Add(TilePiece.Start, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tl")); this.Assets.Add(_engineIdle); this.Assets.Add(_carScreech); this.Assets.Add(_carHorn); this.Assets.Add(Logo); this.Assets.Add(_car); this.Assets.Add(_raceFlags); foreach (IDisposable asset in _textureMap.Values) { this.Assets.Add(asset); } this._engineIdle.Volume = this._carScreech.Volume = this._carHorn.Volume = 0.5f; this._engineIdle.IsLooped = true; _mapPanel.Bounds = new Rectangle(0, 0, 800, 480); int mapCount = 0; HorizontalStackPanel panel = null; foreach (string mapName in MapNames) { string mapData = this.GameManager.Game.Content.Load<string>(@"RacerMaps\" + mapName).Trim(); LoadedMaps.Add(mapName, mapData); if (null == panel) { panel = new HorizontalStackPanel(); panel.VerticalAlignment = VerticalAlignment.Middle; panel.FixedSize = false; panel.Bounds = new Rectangle(0, 0, 800, 180); _mapPanel.AddChild(panel); } VerticalStackPanel vertPanel = new VerticalStackPanel(); vertPanel.Bounds = new Rectangle(0, 0, 200, 150); XnaRaceTrackTile tile = new XnaRaceTrackTile(_textureMap, mapName, mapData); tile.Tag = tile; tile.Bounds = new Rectangle(0, 0, 200, 120); tile.Click += new EventHandler(mapTile_Click); XnaButton button = new XnaButton(new Rectangle(0, 0, 250, 30)); button.Tag = tile; button.Text = mapName; button.FontZoom = 0.5f; button.Click += new EventHandler(mapTile_Click); if (FingerGames.IsTrial && mapCount > 2) { button.Color = new Color(110, 110, 110); } vertPanel.AddChild(tile); vertPanel.AddChild(button); panel.AddChild(vertPanel); mapCount++; if ((mapCount % 3) == 0) { panel = null; } } _mapPanel.ForceLayout(); float maxX = 0; for (int i = 0; i < 10; ++i) { maxX = Math.Max(maxX, _font.MeasureString(i.ToString()).X); } _decimalWidth = maxX * 1.05f / 2; this._timePanel.Bounds = new Rectangle(0, 10, 800, 470); this._timePanel.FixedSize = true; XnaImage flagsImage = new XnaImage(this._raceFlags, new Rectangle(0, 0, this._raceFlags.Width, this._raceFlags.Height)); XnaLabel completedLabel = new XnaLabel(new Rectangle(0, 0, 800, 90)); completedLabel.BackColor = new Color(0, 0, 0, 150); completedLabel.FontZoom = 1.5f; completedLabel.Text = "Race Completed!"; this._timePanel.AddChild(flagsImage); this._timePanel.AddChild(completedLabel); this._timePanel.AddChild(_timeLabel); base.LoadContent(); }