public ViewNameCharacter(GameSystem game, RenderSystem renderer) : base(game, renderer) { GUI = new GUISystem(); Header = new Label("Tell me what is your name", GetScreenPoint(0.5f, 0.25f)); Name = new GUITextInput(GetScreenPoint(0.5f, 0.5f), MaxNameLength); Continue = new GUIButton(GetScreenPoint(0.5f, 0.75f), "Continue", ActionContinue); GUI.Add(Name); GUI.Add(Continue); }
public void AllowsCyclingThroughSelectableWidgets() { System.Add(Button); System.Add(Button2); Assert.AreEqual(Button, System.CurrentSelectable); // Cycle 30 times for (int i = 0; i < 30; i++) { System.NextSelectable(); Assert.AreEqual(Button2, System.CurrentSelectable); System.NextSelectable(); Assert.AreEqual(Button, System.CurrentSelectable); } }
public StaticGui(MainWindow window, MasterRenderer renderer) { this.window = window; this.renderer = renderer; gsys = renderer.Sprites.GUISystem; area = new GUIArea(gsys); renderer.Sprites.Add(area); BMPFont smallFont = AssetManager.LoadFont("arial-bold-12"); BMPFont normalFont = AssetManager.LoadFont("arial-bold-14"); BMPFont bigFont = AssetManager.LoadFont("arial-bold-20"); BMPFont tinyFont = AssetManager.LoadFont("arial-bold-10"); GUITheme theme = AssetManager.CreateDefaultGameTheme(); theme.SetField("SmallFont", smallFont); theme.SetField("Font", normalFont); theme.SetField("TinyFont", tinyFont); controls = new ControlsWindow(gsys, theme); controls.ZIndex = 200; // Overlay fpsLabel = new GUILabel(UDim2.Zero, UDim2.Zero, "FPS: --", TextAlign.TopLeft, theme); timeLabel = new GUILabel(new UDim2(1f, 0, 0, 0), UDim2.Zero, "Time: --", TextAlign.TopRight, theme); versionLabel = new GUILabel(new UDim2(0, 0, 1f, 0), UDim2.Zero, GameVersion.Current.ToString(), TextAlign.BottomLeft, theme); fpsLabel.Font = smallFont; timeLabel.Font = smallFont; versionLabel.Font = bigFont; if (screenshots == null) { string[] mainMenuFiles = Directory.GetFiles("Content/Textures/MainMenu"); screenshots = new List <Texture>(); foreach (string file in mainMenuFiles) { // Skip thumbs.db if (file.EndsWith(".db")) { continue; } try { screenshots.Add(GLoader.LoadTexture(file, TextureMinFilter.Linear, TextureMagFilter.Linear, true)); } catch (Exception e) { DashCMD.WriteError("Failed to load main menu background '{1}'. \n{0}", e, file); } } } background = new GUIFrame(UDim2.Zero, new UDim2(1f, 0, 1f, 0), Image.Blank); background.ZIndex = -100; area.AddTopLevel(background, fpsLabel, timeLabel, versionLabel); gsys.Add(controls); }
private void InitUI() { GUI = new GUISystem(); string text = string.Format("You are in the {0}\nWhat do you want to do?", Location.DisplayName); CityText = new Label(text, GetScreenPoint(0.5f, 0.25f)); ButtonsLayout = new LinearLayout(LayoutDirection.Vertical, GetScreenPoint(0.5f, 0.75f), Vector2f.Center); ButtonsLayout.Size = GetScreenPoint(0.5f, 0.35f); foreach (var interactable in Location.Interactables) { var button = new GUIButton(Vector2.Zero, interactable.MenuText, () => interactable.Interact(Game)); ButtonsLayout.Add(button); GUI.Add(button); } var travel = new GUIButton(Vector2.Zero, "Travel", () => Travel()); ButtonsLayout.Add(travel); GUI.Add(travel); }
public GameScreen(MainWindow window, string name) { Name = name; Window = window; Renderer = window.Renderer; GUISystem = Renderer.Sprites.GUISystem; GUIArea = new GUIArea(GUISystem); GUISystem.Add(GUIArea); GUIArea.Visible = false; Windows = new HashSet <GUIWindowBase>(); }
public SingleplayerScreen(MainWindow window) : base(window, "Singleplayer") { GUITheme theme = AssetManager.CreateDefaultGameTheme(); theme.SetField("Font", AssetManager.LoadFont("arial-14")); menu = new SingleplayerMenu(GUISystem, theme, Window); menu.OnClosed += Menu_OnClosed; GUISystem.Add(menu); Windows.Add(menu); }
private void InitUI() { GUI = new GUISystem(); Greeting = new Label(Text, GetScreenPoint(0.5f, 0.25f)); ProductsLayout = new LinearLayout(LayoutDirection.Vertical, GetScreenPoint(0.5f, 0.75f), Vector2f.Center); ProductsLayout.Size = GetScreenPoint(0.4f, 0.4f); foreach (var group in Vendor.GroupedProducts) { Item item = group.Item1; int count = group.Item2; string text = GetItemLabel(item, count); var button = new GUIButton(Vector2.Zero, text, () => TryBuy(item)); ProductsLayout.Add(button); GUI.Add(button); } var leave = new GUIButton(Vector2.Zero, "Back", () => Game.PopView()); ProductsLayout.Add(leave); GUI.Add(leave); }
private void Init() { GUI = new GUISystem(); Title = new Label(@" _____ _ ____________ _____ |_ _| | | | ___ \ ___ \ __ \ | | _____ _| |_ | |_/ / |_/ / | \/ | |/ _ \ \/ / __| | /| __/| | __ | | __/> <| |_ | |\ \| | | |_\ \ \_/\___/_/\_\\__| \_| \_\_| \____/", GetScreenPoint(0.5f, 0.25f), Vector2f.Center, Color.DarkGray); Author = new Label("by Pawel Gronowski", Vector2.Zero, Vector2f.Center, Color.DarkBlue); Help = new Label("TAB: Switch button\nENTER: Activate", Vector2.Zero, Vector2f.Center, Color.DarkGreen); MenuLayout = new LinearLayout(LayoutDirection.Vertical, GetScreenPoint(0.5f, 0.5f), Vector2f.Center); MenuLayout.Size = new Vector2((int)Renderer.Size.X, (int)Renderer.Size.Y); MenuLayout.Spacing = 2; ButtonsLayout = new LinearLayout(LayoutDirection.Horizontal, GetScreenPoint(0.5f, 0.5f), Vector2f.Center); ButtonsLayout.Spacing = 5; ContinueGame = new GUIButton(Vector2.Zero, "Continue Game", () => ActionContinueGame()); NewGame = new GUIButton(Vector2.Zero, "New Game", () => ActionNewGame()); Quit = new GUIButton(Vector2.Zero, "Quit", () => Game.Running = false); // TODO: Enable when game saving/loading is done // ButtonsLayout.Add(ContinueGame); // GUI.Add(ContinueGame); ButtonsLayout.Add(NewGame); ButtonsLayout.Add(Quit); ButtonsLayout.Size = new Vector2((int)Renderer.Size.X, (int)Renderer.Size.Y / 4); MenuLayout.Add(new GUIAdapter(Title)); MenuLayout.Add(new GUIAdapter(Author)); MenuLayout.Add(new GUIAdapter(Help)); MenuLayout.Add(ButtonsLayout); GUI.Add(NewGame); GUI.Add(Quit); }
private void Init() { GUI = new GUISystem(); Description = new Label(""); Description.Position = GetScreenPoint(0.5f, 0.05f); Description.Pivot = new Vector2f(0.5f, 0); Log = new Label(""); Log.Position = GetScreenPoint(0.5f, 0.75f); Log.Size = GetScreenPoint(0.5f, 0.25f); Log.Pivot = new Vector2f(0.5f, 1.0f); Actions = new LinearLayout(LayoutDirection.Horizontal, GetScreenPoint(0.5f, 0.25f), Vector2f.Center); NextTurn = new GUIButton(Vector2.Zero, "Next Turn", () => Tick()); Retreat = new GUIButton(Vector2.Zero, "Retreat", () => DoRetreat()); Quit = new GUIButton(Vector2.Zero, "Close", () => DoClose()); Actions.Add(NextTurn); Actions.Add(Retreat); GUI.Add(NextTurn); GUI.Add(Retreat); Refresh(); }
private void Tick() { ++Turn; Combat.Tick(); Refresh(); if (Combat.IsFinished) { GUI.Remove(NextTurn); GUI.Remove(Retreat); Actions.Remove(NextTurn); Actions.Remove(Retreat); Actions.Add(Quit); GUI.Add(Quit); } }
public ViewMessage(GameSystem game, RenderSystem renderer, string text, IList <MenuOption> options) : base(game, renderer) { GUI = new GUISystem(); Text = new Label(text, GetScreenPoint(0.5f, 0.25f)); ButtonsLayout = new LinearLayout(LayoutDirection.Vertical, GetScreenPoint(0.5f, 0.6f), Vector2f.Center); foreach (var option in options) { var button = new GUIButton(Vector2.Zero, option.Text, option.Callback); ButtonsLayout.Add(button); GUI.Add(button); } }
public ViewChooseProfession(GameSystem game, RenderSystem renderer) : base(game, renderer) { GUI = new GUISystem(); Header = new Label("What is your profession?", GetScreenPoint(0.5f, 0.25f)); ProfessionsLayout = new LinearLayout(LayoutDirection.Horizontal, GetScreenPoint(0.5f, 0.5f), Vector2f.Center); ProfessionsLayout.Size = new Vector2((int)Renderer.Size.X, (int)Renderer.Size.Y / 3); ProfessionsLayout.Spacing = 3; foreach (var profession in Professions.All) { var button = new GUIButton( Vector2.Zero, profession.Name, () => ChooseProfession(profession) ); ProfessionsLayout.Add(button); GUI.Add(button); } }
protected override void OnClientInitialized() { // Initialize remotes channel.AddRemoteEvent("Client_UnloadWorld", R_UnloadWorld); channel.AddRemoteEvent("Client_Announcement", R_Announcement); channel.AddRemoteEvent("Client_AddFeedItem", R_AddFeedItem); channel.AddRemoteEvent("Client_ChatItem", R_ChatItem); channel.AddRemoteEvent("Client_SwitchGamemode", R_SwitchGamemode); channel.AddRemoteEvent("Client_TeamWon", R_TeamWon); // Create the leaderboard leaderboard = new Leaderboard(GUISystem, theme, netPlayerComponent); GUISystem.Add(leaderboard); Windows.Add(leaderboard); // Enable some debugging InitializeCMD(); base.OnClientInitialized(); }
public EditorUI(MasterRenderer renderer, EditorScreen screen) { this.renderer = renderer; this.screen = screen; GUISystem gsys = renderer.Sprites.GUISystem; area = new GUIArea(gsys); renderer.Sprites.Add(area); theme = EditorTheme.Glass; GenBar(renderer.ScreenWidth); openFileWindow = new FileBrowserWindow(gsys, theme, new UDim2(0.75f, 0, 0.75f, 0), "Open Model", FileBrowserMode.OpenFile, new string[] { ".aosm" }, (window) => { if (File.Exists(window.FileName)) { screen.LoadModel(window.FileName); } }); saveFileWindow = new FileBrowserWindow(gsys, theme, new UDim2(0.75f, 0, 0.75f, 0), "Save Model", FileBrowserMode.Save, new string[] { ".aosm" }, (window) => { string fullPath = Path.Combine(window.CurrentDirectory, window.FileName); if (!Path.HasExtension(fullPath)) { fullPath += ".aosm"; } screen.SaveModel(fullPath); }); gsys.Add(openFileWindow, saveFileWindow); }
public MultiplayerScreen(MainWindow window) : base(window, "Multiplayer") { debugRenderer = Renderer.GetRenderer3D <DebugRenderer>(); gamemodes = new Dictionary <GamemodeType, NetworkedGamemode>() { { GamemodeType.TDM, new TDMGamemode(this) }, { GamemodeType.CTF, new CTFGamemode(this) } }; // Build the UI elements theme = AssetManager.CreateDefaultGameTheme(); font = theme.GetField <BMPFont>(null, "SmallFont"); hud = new HUD(Renderer); loadingBar = new MultiplayerLoadingBar(GUISystem, theme); chat = new ChatBox(new UDim2(0, 40, 1f, -240), new UDim2(0, 350, 0, 165), theme, this); menu = new MultiplayerMenu(GUISystem, theme, Window); menu.OnClosed += Menu_OnClosed; announcementLabel = new GUILabel(new UDim2(0.5f, 0, 0.5f, 0), UDim2.Zero, "", TextAlign.Center, theme); announcementLabel.Font = AssetManager.LoadFont("karmasuture-32"); announcementLabel.Visible = false; // Add each UI element GUIArea.AddTopLevel(chat, announcementLabel); GUISystem.Add(loadingBar, menu); Windows.Add(loadingBar); Windows.Add(menu); // Setup default multiplayer cvars DashCMD.SetCVar("cl_impacts", false); DashCMD.SetCVar("cl_interp", 0.5f); // Client interpolation with server position DashCMD.SetCVar("cl_interp_movement_smooth", 1f); // Client player movement smoothing (1f = no smoothing) DashCMD.SetCVar("cl_interp_rep", 20f); // Replicated entities interpolation DashCMD.SetCVar("cl_max_error_dist", 12f); // Max distance the client's position can be off from the server's }
public MainMenuScreen(MainWindow mainWindow) : base(mainWindow, "MainMenu") { theme = AssetManager.CreateDefaultGameTheme(); theme.SetField("SmallFont", AssetManager.LoadFont("arial-bold-14")); theme.SetField("Font", AssetManager.LoadFont("arial-16")); theme.SetField("BigFont", AssetManager.LoadFont("arial-20")); popup = new MessageWindow(GUISystem, theme, new UDim2(0.1f, 0, 0.3f, 0), "Alert!"); popup.MinSize = new UDim2(0, 215, 0, 200); popup.MaxSize = new UDim2(1f, 0, 0, 275); connectWindow = new ConnectWindow(GUISystem, theme, new UDim2(1f, 0, 1f, 0)); connectWindow.MinSize = new UDim2(0, 375, 0, 200); connectWindow.MaxSize = new UDim2(0, 700, 0, 200); connectWindow.OnConnectPressed += ConnectWindow_OnConnectPressed; GUIFrame title = new GUIFrame(new UDim2(0.5f, -260, 0.2f, -40), new UDim2(0, 520, 0, 80), new Image(GLoader.LoadTexture("Textures/title.png"))); GUIFrame btnFrame = new GUIFrame(new UDim2(0.5f, -200, 0.5f, -50), new UDim2(0, 400, 0, 110), theme); btnFrame.Image = null; GUIButton connectBtn = new GUIButton(new UDim2(0, 0, 0, 0), new UDim2(1f, 0, 0, 30), "Connect to a Server", TextAlign.Center, theme) { Parent = btnFrame }; connectBtn.OnMouseClick += (btn, mbtn) => { if (mbtn == MouseButton.Left) { connectWindow.Visible = true; } }; GUIButton controlsBtn = new GUIButton(new UDim2(0, 0, 0, 40), new UDim2(1f, 0, 0, 30), "View Controls", TextAlign.Center, theme) { Parent = btnFrame }; controlsBtn.OnMouseClick += (btn, mbtn) => { if (mbtn == MouseButton.Left) { Window.StaticGui.ToggleControlsWindow(true); } }; GUIButton spBtn = new GUIButton(new UDim2(0, 0, 0, 80), new UDim2(1f, 0, 0, 30), "Start Singleplayer Test", TextAlign.Center, theme) { Parent = btnFrame }; spBtn.OnMouseClick += (btn, mbtn) => { if (mbtn == MouseButton.Left) { Window.SwitchScreen("Singleplayer"); } }; GUIButton randomImageButton = new GUIButton(new UDim2(1f, -160, 1f, -40), new UDim2(0, 150, 0, 30), "Random Image", theme); randomImageButton.OnMouseClick += (btn, mbtn) => { Window.StaticGui.ShowRandomBackgroundImage(); }; GUIArea.AddTopLevel(title, randomImageButton, btnFrame); GUISystem.Add(connectWindow, popup); Windows.Add(connectWindow); Windows.Add(popup); }
public EditorUI(MasterRenderer renderer, EditorScreen screen) { this.renderer = renderer; this.screen = screen; GUISystem = renderer.Sprites.GUISystem; area = new GUIArea(GUISystem); renderer.Sprites.Add(area); Theme = EditorTheme.Glass; TranslateTerrainWindow transTerrainWindow; newWindow = new NewWorldWindow(GUISystem, screen, Theme); transTerrainWindow = new TranslateTerrainWindow(GUISystem, Theme); transTerrainWindow.OnApply += (sender, d) => { screen.World.TranslateTerrain(d); }; GUIFrame topBar = new GUIFrame(UDim2.Zero, new UDim2(1, 0, 0, 40), Theme); float menuItemWidth = 220; GUIDropDown fileMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false) { Parent = topBar, Text = "File" }; fileMenu.AddItem("New", null, (d, b) => { newWindow.Visible = true; }); fileMenu.AddItem("Open", null, (d, b) => { openWorldWindow.Visible = true; }); fileMenu.AddItem("Save", null, (d, b) => { if (screen.CurrentFile != null) { screen.SaveWorld(); } else { saveWorldWindow.Visible = true; } }); fileMenu.AddItem("Save As...", null, (d, b) => { saveWorldWindow.Visible = true; }); GUIDropDown editMenu = new GUIDropDown(new UDim2(0, menuItemWidth, 0, 0), new UDim2(0, menuItemWidth, 1, 0), Theme, false) { Parent = topBar, Text = "Edit" }; GUIDropDown editModeMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false) { HideMainButton = true }; editMenu.AddItemSub("Mode", editModeMenu); editModeButtons = new GUIDropDownButton[] { editModeMenu.AddItem("Select", null, OnEditModeSelected), editModeMenu.AddItem("Add", null, OnEditModeSelected), editModeMenu.AddItem("Delete", null, OnEditModeSelected), editModeMenu.AddItem("Paint", null, OnEditModeSelected), editModeMenu.AddItem("Terrain Move", null, OnEditModeSelected), editModeMenu.AddItem("Terraform", null, OnEditModeSelected), }; GUIDropDown insertSubMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false) { HideMainButton = true }; editMenu.AddItemSub("Insert", insertSubMenu); GUIDropDownButton[] insertButtons = new GUIDropDownButton[] { insertSubMenu.AddItem("Command Post", null, (d, b) => { screen.World.AddNewCommandPost(); }), insertSubMenu.AddItem("Intel", null, (d, b) => { screen.World.AddNewIntel(); }), }; editMenu.AddItem("Bake Damage Colors", null, (d, b) => { screen.WorldEditor.TerrainEditor.BakeDamageColors(); }); editMenu.AddItem("Translate Terrain", null, (d, b) => { transTerrainWindow.Visible = true; }); editModeButtons[0].Toggled = true; GUIDropDown gfxMenu = new GUIDropDown(new UDim2(0, menuItemWidth * 2, 0, 0), new UDim2(0, menuItemWidth, 1, 0), Theme, false) { Parent = topBar, Text = "Graphics" }; gfxMenu.AddItem("FXAA", null, (d, b) => { TogglePostProcess(b, true); }); gfxMenu.AddItem("Shadows", null, (d, b) => { b.Toggled = renderer.GFXSettings.RenderShadows = !renderer.GFXSettings.RenderShadows; }); GUIDropDown gfxFogMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false) { HideMainButton = true }; gfxMenu.AddItemSub("Fog", gfxFogMenu); fogButtons = new GUIDropDownButton[4]; fogButtons[0] = gfxFogMenu.AddItem("Off", null, OnFogSelected); fogButtons[1] = gfxFogMenu.AddItem("Low", null, OnFogSelected); fogButtons[2] = gfxFogMenu.AddItem("Medium", null, OnFogSelected); fogButtons[3] = gfxFogMenu.AddItem("High", null, OnFogSelected); GUIDropDown gfxPCFMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false) { HideMainButton = true }; gfxMenu.AddItemSub("PCF Samples", gfxPCFMenu); pcfButtons = new GUIDropDownButton[5]; pcfButtons[0] = gfxPCFMenu.AddItem("1", 1, OnPCFSelected); pcfButtons[1] = gfxPCFMenu.AddItem("2", 2, OnPCFSelected); pcfButtons[2] = gfxPCFMenu.AddItem("4", 4, OnPCFSelected); pcfButtons[3] = gfxPCFMenu.AddItem("6", 6, OnPCFSelected); pcfButtons[4] = gfxPCFMenu.AddItem("12", 12, OnPCFSelected); GUIDropDown viewMenu = new GUIDropDown(new UDim2(0, menuItemWidth * 3, 0, 0), new UDim2(0, menuItemWidth, 1, 0), Theme, false) { Parent = topBar, Text = "View" }; viewMenu.AddItem("Color Picker", null, (d, b) => { ColorWindow.Visible = true; }); viewMenu.AddItem("Chunk Borders", null, (d, b) => { b.Toggled = screen.World.ShowChunkBorders = !screen.World.ShowChunkBorders; }); currentToolLabel = new GUILabel(new UDim2(1f, -5, 0, 5), UDim2.Zero, "Current Tool: Add", TextAlign.TopRight, Theme) { Parent = topBar }; SetupDefaultGraphicsSettings(gfxMenu); area.AddTopLevel(topBar); GUIFrame bottomBar = new GUIFrame(new UDim2(0, 0, 1, -30), new UDim2(1, 0, 0, 30), Theme); statusLeft = new GUILabel(UDim2.Zero, new UDim2(0.5f, 0, 1, 0), "<left status>", TextAlign.Left, Theme) { Parent = bottomBar }; statusRight = new GUILabel(new UDim2(0.5f, 0, 0, 0), new UDim2(0.5f, 0, 1, 0), "<right status>", TextAlign.Right, Theme) { Parent = bottomBar }; statusMid = new GUILabel(new UDim2(0.25f, 0, 0, 0), new UDim2(0.5f, 0, 1f, 0), "", TextAlign.Center, Theme) { Parent = bottomBar }; area.AddTopLevel(bottomBar); openWorldWindow = new FileBrowserWindow(GUISystem, Theme, new UDim2(0.75f, 0, 0.75f, 0), "Open World", FileBrowserMode.OpenFile, new string[] { ".aosw" }, (window) => { if (File.Exists(window.FileName)) { screen.LoadWorld(window.FileName); } }); saveWorldWindow = new FileBrowserWindow(GUISystem, Theme, new UDim2(0.75f, 0, 0.75f, 0), "Save World", FileBrowserMode.Save, new string[] { ".aosw" }, (window) => { string fullPath = Path.Combine(window.CurrentDirectory, window.FileName); if (!Path.HasExtension(fullPath)) { fullPath += ".aosw"; } screen.SaveWorld(fullPath); }); ColorWindow = new GUIColorPickerWindow(GUISystem, new UDim2(0.3f, 0, 0.3f, 0), Theme); ColorWindow.Visible = true; ColorWindow.Position = new UDim2(0.7f, -10, 0.7f, -10); ColorWindow.MinSize = new UDim2(0, 400, 0, 300); ColorWindow.MaxSize = new UDim2(0, 550, 0, 400); popup = new MessageWindow(GUISystem, Theme, new UDim2(0.6f, 0, 0.3f, 0), "Alert!"); popup.MinSize = new UDim2(0, 215, 0, 200); popup.MaxSize = new UDim2(0, 600, 0, 275); GUISystem.Add(ColorWindow, transTerrainWindow, openWorldWindow, saveWorldWindow, newWindow, popup); }