private static void SetupUI() { display = new Display(); display.Ready += Display_Ready; // Simple Dispatcher and SynchronizationContext do the same job as in a typical GUI: // - SynchronizationContext Keeps async code continuations running on the main (UI) thread // - Dispatcher allows other threads to invoke Actions on the main (UI) thread SynchronizationContext.SetSynchronizationContext(new ConsoleSynchronizationContext(display)); Dispatcher.Init(display); mainDisplayToggler = new AreaToggler(); scriptDisplay = new ScriptDisplay(display, debugger, new Bounds(0, 0, Length.Percent(60), -2)); infoDisplay = new InfoDisplay(display, new Bounds(Length.Percent(60), 0, Length.Percent(40), -2)); helpDisplay = new HelpDisplay(display, new Bounds(0, 0, Length.Percent(100), -2)); prompt = new Prompt(display, new Bounds(0, -2, Length.Percent(100), 1)); errorDisplay = new ErrorDisplay(display, new Bounds(0, -1, Length.Percent(100), 1)); mainDisplayToggler .Add(scriptDisplay) .Add(helpDisplay); display.Add(scriptDisplay); display.Add(helpDisplay); display.Add(infoDisplay); display.Add(prompt); display.Add(errorDisplay); }
public void UpdateValuesFromParent(ResourcePackModelBase parent) { if (parent == null) { return; } if (!GuiLight.HasValue && parent.GuiLight.HasValue) { GuiLight = parent.GuiLight; } if (Elements.Length == 0 && parent.Elements.Length > 0) { Elements = parent.Elements.Select(x => x.Clone()).ToArray();//.Clone(); } foreach (var kvp in parent.Textures) { if (!Textures.ContainsKey(kvp.Key)) { Textures.Add(kvp.Key, kvp.Value); } } foreach (var kvp in parent.Display) { if (!Display.ContainsKey(kvp.Key)) { Display.Add(kvp.Key, kvp.Value); } } }
private void Go_KeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) { Display.Add(new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(Value.Text))); } }
private void Value_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Enter) { Display.Add(new BitmapImage(new Uri(Value.Text))); } }
public void ResetDisplay() { Display.Clear(); Display.Add(DisplayInfoTypes.UsagePeriod); Display.Add(DisplayInfoTypes.Overcharge); Display.Add(DisplayInfoTypes.DayRemaining); Display.Add(DisplayInfoTypes.SuggestCombined); Display.Add(DisplayInfoTypes.UploadDownloadGraph); Display.Add(DisplayInfoTypes.CombinedGraph); Display.Add(DisplayInfoTypes.HistoryGraph); }
private void Create() { #if DEBUG Debugger.Log(1, "Main", "Started initialization phase.\n"); #endif Rectangle window = new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); sky = new Sky(skyTex, window); yat = new Yat(yatClimbing, yatRunning, yatSmashing, yatFalling, snapEffect, window); BlockManager blockManager = new BlockManager(ground3Tex, ground2Tex, ground1Tex, ladder, window); level = new Level(blockManager, window); experience = new Experiencebar(yat, cage, xpBar, button14, new Vector2(50, window.Height - 50), new Resize(DockType.LowerLeft, new Vector2(cage.Width, cage.Height), new Vector2(25)), 0, 100, AmountType.AmountAndTotal); XPManager xpManager = new XPManager(yat, experience, xpOrb, xpEffect); MushroomFactory mgen = new MushroomFactory(mushroomSheet, fireballSheet, Mushroom.Size, level, yat, flameEffect, squashEffect, xpManager, window); CoinFactory cgen = new CoinFactory(level, yat, coin, coinEffect, window); BirdFactory bgen = new BirdFactory(level, yat, birdSheet, hawkEffect, xpManager, window); PotionManager pmanager = new PotionManager(yat, (Experiencebar)experience, new Texture2D[] { potionRed, potionGreen, potionBlue, potionYellow }, potionEffect, 20); yat.Init(level, pmanager); Plains hillzone = new Plains(ground3Tex, ground2Tex, ground1Tex, ladder, 2, 7, Rand.Next(10, 20), window); level.Init(new IFactory <ILevelObject>[] { cgen }, new IFactory <IEntity>[] { mgen, bgen }, new ITerrain[] { hillzone }); fpsCounter = new FPSCounter(new Vector2(10), new Resize(new Vector2(10)), window, button14, Color.Black); score = new Score(new Vector2(0, 10), new Resize(new Vector2(2, 0), new Vector2(0, 35)), window, button36, Color.Black); gameoverLabel = new Button(new Vector2(0, window.Height / 3), new Resize(new Vector2(2, 3), new Vector2(0, 0)), window, "Game over", button72, true, Color.Black, Color.Black, false, null, tint); mainMenuLabel = new Button(new Vector2(0, window.Height / 3 + 100), new Resize(new Vector2(2, 3), new Vector2(0, 100)), window, "Main menu", button36, true, Color.Black, Color.Red, true, new Request(0, 2, delegate() { Actions.Gameover = false; Score.Points = 0; })); soundButton = new ImageButton(new Vector2(window.Width - 50, 20), new Resize(DockType.UpperRight, new Vector2(soundLoud.Width, soundLoud.Height), new Vector2(50, 20)), new Action[] { delegate() { Settings.PlaySounds = false; MediaPlayer.IsMuted = true; }, delegate() { Settings.PlaySounds = true; MediaPlayer.IsMuted = false; } }, window, null, false, soundLoud, soundMute); playPauseButton = new ImageButton(new Vector2(window.Width - 120, 20), new Resize(DockType.UpperRight, new Vector2(pauseButton.Width, pauseButton.Height), new Vector2(120, 20)), new Request[] { new Request(1, 2), new Request(3, 2) }, window, 'P', true, pauseButton, playButton); healthbar = new Healthbar(yat, cage, healthBar, button14, new Vector2(window.Width - 200, window.Height - 50), new Resize(DockType.LowerRight, new Vector2(cage.Width, cage.Height), new Vector2(25)), Yat.health, Yat.health, AmountType.Percentage); clock = new Clock(button36, new Vector2(window.Width / 2, 75), new Resize(new Vector2(2, 0), new Vector2(0, 75)), Color.Black, window); gameplay = new Screen(1, new IButton[] { fpsCounter, score, clock, soundButton, playPauseButton, healthbar, experience }, new IObject[] { sky, level, yat }, gameplaySong, true); Button title = new Button(new Vector2(0, window.Height / 3), new Resize(new Vector2(2, 3), new Vector2(0)), window, "Yat Sprint", button72, true, Color.Black, Color.DimGray, false, null); Button play = new Button(new Vector2(0, window.Height / 3 + 100), new Resize(new Vector2(2, 3), new Vector2(0, 100)), window, "Play", button36, true, Color.Black, Color.DimGray, true, new Request(1, 1)); Button fullscreen = new Button(new Vector2(0, window.Height / 3 + 150), new Resize(new Vector2(2, 3), new Vector2(0, 150)), window, "Fullscreen", button36, true, Color.Black, Color.DimGray, true, new Request(-1, 1, delegate() { if (graphics.IsFullScreen) { graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; graphics.ApplyChanges(); } else { graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; graphics.ApplyChanges(); } display.UpdateWindow(new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); Actions.ToggleFullscreen = true; })); Button exit = new Button(new Vector2(0, window.Height / 3 + 200), new Resize(new Vector2(2, 3), new Vector2(0, 200)), window, "Exit", button36, true, Color.Black, Color.DimGray, true, new Request(-1, 1, delegate() { Actions.Exitgame = true; })); Button motd = new Button(new Vector2(window.Width / 2 + 250, window.Width / 3 + 10), new Resize(new Vector2(2, 3), new Vector2(250, 25)), window, Messages[Rand.Next(Messages.Length)], button14, false, Color.Black, Color.Black, false, null); motd.SetRotation(Rand.Next(-45, -20)); titleScreen = new Screen(0, new IButton[] { fpsCounter, soundButton, title, motd, play, fullscreen, exit }, new IObject[] { sky }, mainmenuSong, true); gameover = new Screen(2, new IButton[] { fpsCounter, score, soundButton, gameoverLabel, mainMenuLabel }, new IObject[] { sky }, gameplaySong, true); Button pauseTitle = new Button(new Vector2(0, window.Height / 3), new Resize(new Vector2(2, 3), new Vector2(0)), window, "Paused", button72, true, Color.Black, Color.Black, false, null, tint); Button resumeButton = new Button(new Vector2(0, window.Height / 3 + 100), new Resize(new Vector2(2, 3), new Vector2(0, 100)), window, "Resume", button36, true, Color.Black, Color.Gray, true, new Request(1, 2)); Button mainMenuPause = new Button(new Vector2(0, window.Height / 3 + 150), new Resize(new Vector2(2, 3), new Vector2(0, 150)), window, "Main Menu", button36, true, Color.Black, Color.Gray, true, new Request(0, 2)); paused = new Screen(3, new IButton[] { fpsCounter, score, soundButton, playPauseButton, pauseTitle, resumeButton, mainMenuPause }, new IObject[] { sky }, gameplaySong, false); display = new Display(); display.Add(gameplay); display.Add(titleScreen); display.Add(gameover); display.Add(paused); MediaPlayer.Play(mainmenuSong); #if DEBUG Debugger.Log(1, "Main", "Finished initialization phase.\n"); #endif }