void altTopFunction() { GUI.backgroundColor = Color.green; GUILayout.BeginVertical("box"); GUILayout.Label("Alternate Top Bar"); GUILayout.FlexibleSpace(); if (GUILayout.Button("Fade Switch")) { topBar.resetRect(); GUIArea.fadeOutIn(0.25f, ref altTop, ref topBar); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Slide Up Switch")) { topBar.setAlpha(1f); GUIArea.slideUpOutIn(0.25f, ref altTop, ref topBar); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Slide Up Rotate")) { topBar.setAlpha(1f); GUIArea.slideTopBottom(0.25f, ref altTop, ref topBar); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUI.backgroundColor = Color.white; }
public static void fadeOutIn(float transTime, GUIArea[] exit, GUIArea enter) { foreach (GUIArea e in exit) { e.exitFade(transTime); } enter.enterFade(transTime); }
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 DrawSoundSetElement(Rect rect, int index, bool isActive, bool isFocused) { string textureName = soundsSets.GetPropertyOfIndex(index, "TextureName").stringValue; Object soundsSet = soundsSets.GetPropertyOfIndex(index, "soundsSet").objectReferenceValue; soundsSets.GetPropertyOfIndex(index, "soundsSet").objectReferenceValue = EditorGUI.ObjectField(GUIArea.ProgressLine(ref rect), textureName, soundsSet, typeof(ControllerSoundStates), false); }
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>(); }
// Use this for initialization void Start() { hat = new GUIArea(hatFunction, new Vector2(0.25f, 1f), "left"); topHat = new GUIArea(topHatFunction, new Vector2(0.25f, 1f), "right"); batman = new GUIArea(batmanFunction, 0.25f); bottomBar = new GUIArea(bottomFunction, new Vector2(0.5f, 0.25f), "bottom"); topBar = new GUIArea(topFunction, new Vector2(0.5f, 0.25f), "top"); altTop = new GUIArea(altTopFunction, new Vector2(0.5f, 0.25f), "top"); hat.enterLeft(0.25f); topHat.exitRight(0.25f); batman.enterSpinScale(1f); topBar.enterTop(0.25f); altTop.exitTop(0.25f); }
public CustomConsole() : base("Debug console", Config.ConsoleRect) { headerArea = new GUIArea(this) .OffsetBy(vertical: 16f) .ChangeSizeRelative(height: 0); consoleArea = new GUIArea(this); commandLineArea = new GUIArea(this) .ChangeSizeRelative(height: 0); RecalculateAreas(); }
//bool showGameItems; public HUD(MasterRenderer renderer) { this.renderer = renderer; font = AssetManager.LoadFont("karmasuture-26"); feed = new List <FeedItem>(); hitIndications = new List <HitIndication>(); if (palletTex == null) { palletTex = GLoader.LoadTexture("Textures/Gui/palette.png"); Texture crosshairTex = GLoader.LoadTexture("Textures/Gui/crosshair.png"); Texture hitmarkerTex = GLoader.LoadTexture("Textures/Gui/hitmarker.png"); crosshairImage = new Image(crosshairTex); hitmarkerImage = new Image(hitmarkerTex); hurtRingTex = GLoader.LoadTexture("Textures/Gui/hurt-ring.png"); intelTex = GLoader.LoadTexture("Textures/Gui/intel.png", TextureMinFilter.Nearest, TextureMagFilter.Nearest); } GUISystem gsys = renderer.Sprites.GUISystem; area = new GUIArea(gsys); area.ZIndex = -1; theme = GUITheme.Basic; theme.SetField("Font", font); theme.SetField("SmallFont", AssetManager.LoadFont("arial-bold-14")); theme.SetField("Label.TextColor", Color.White); theme.SetField("Label.TextShadowColor", new Color(0, 0, 0, 0.6f)); healthLabel = new GUILabel(new UDim2(0, 40, 1, -20), UDim2.Zero, "Health: --", TextAlign.BottomLeft, theme); ammoLabel = new GUILabel(new UDim2(1, -50, 1, -25), UDim2.Zero, "", TextAlign.BottomRight, theme); crosshair = new GUIFrame(new UDim2(0.5f, -28, 0.5f, -28), new UDim2(0, 56, 0, 56), crosshairImage); hitmarker = new GUIFrame(new UDim2(0.5f, -43, 0.5f, -43), new UDim2(0, 86, 0, 86), hitmarkerImage); hitmarker.Visible = false; intelInHand = new GUIFrame(new UDim2(0.5f, -20, 0, 100), new UDim2(0, 40, 0, 40), new Image(intelTex)); intelPickedUpNotification = new GUILabel(new UDim2(0.5f, 0, 0, 150), UDim2.Zero, "You have picked up the intel!", TextAlign.TopCenter, theme); intelInHand.Visible = false; intelPickedUpNotification.Visible = false; crosshair.CapturesMouseClicks = false; hitmarker.CapturesMouseClicks = false; ammoLabel.CapturesMouseClicks = false; healthLabel.CapturesMouseClicks = false; area.AddTopLevel(ammoLabel, healthLabel, crosshair, hitmarker, intelInHand, intelPickedUpNotification); }
private void Start() { var Controls = GetComponents<GUIControl>().ToList(); GUIArea_1157020965 = (GUIArea)Controls.First(Control => Control.Name == "GUIArea_1157020965"); GUIArea_977234804 = (GUIArea)Controls.First(Control => Control.Name == "GUIArea_977234804"); GUIButton_2085473440 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_2085473440"); GUIButton_955361902 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_955361902"); GUIButton_1226782659 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_1226782659"); GUIButton_444708301 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_444708301"); GUIButton_444708301.Click += Multiplayer; GUIButton_790021684 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_790021684"); GUIButton_520576317 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_520576317"); GUIButton_520576317.Click += Quit; Initialize(); }
private void Start() { var Controls = GetComponents<GUIControl>().ToList(); MainArea = (GUIArea)Controls.First(Control => Control.Name == "MainArea"); CenterArea = (GUIArea)Controls.First(Control => Control.Name == "CenterArea"); ButtonsArea = (GUIArea)Controls.First(Control => Control.Name == "ButtonsArea"); JoinRoomButton = (GUIButton)Controls.First(Control => Control.Name == "JoinRoomButton"); JoinRoomButton.Click += JoinRoom; CreateRoomButton = (GUIButton)Controls.First(Control => Control.Name == "CreateRoomButton"); CreateRoomButton.Click += CreateRoom; ListArea = (GUIArea)Controls.First(Control => Control.Name == "ListArea"); GamesTable = (MultiplayerGUITable)Controls.First(Control => Control.Name == "GamesTable"); BottomArea = (GUIArea)Controls.First(Control => Control.Name == "BottomArea"); BackButton = (GUIButton)Controls.First(Control => Control.Name == "BackButton"); BackButton.Click += SwitchBack; Initialize(); }
public GUIArea(Rect?area) { Rect screenRect = (area == null) ? GUIArea.GetStandardArea() : area.Value; if (GUIArea.rotated > 0) { screenRect.y += screenRect.height; float width = screenRect.width; screenRect.width = screenRect.height; screenRect.height = width; } GUILayout.BeginArea(screenRect); if (GUIArea.rotated > 0) { GUIUtility.RotateAroundPivot(-90f, Vector2.zero); } }
public ScriptEditor() : base("Script Editor", new Rect(16.0f, 16.0f, 640.0f, 480.0f)) { headerArea = new GUIArea(this) .OffsetBy(vertical: 32f) .ChangeSizeRelative(height: 0) .ChangeSizeBy(height: HeaderHeight); editorArea = new GUIArea(this) .OffsetBy(vertical: 32.0f + HeaderHeight) .ChangeSizeBy(height: -(32.0f + HeaderHeight + FooterHeight)); footerArea = new GUIArea(this) .OffsetRelative(vertical: 1f) .OffsetBy(vertical: -FooterHeight) .ChangeSizeRelative(height: 0) .ChangeSizeBy(height: FooterHeight); }
public GUIArea(Rect?area) { var a = area ?? GUIArea.GetStandardArea(); if (rotated > 0) { a.y += a.height; var w = a.width; a.width = a.height; a.height = w; } GUILayout.BeginArea(a); if (rotated > 0) { GUIUtility.RotateAroundPivot(-90f, Vector2.zero); } }
public SceneExplorer() : base(TitleBase, new Rect(128, 440, 800, 500)) { headerArea = new GUIArea(this) .ChangeSizeRelative(height: 0) .OffsetBy(vertical: WindowTopMargin); sceneTreeArea = new GUIArea(this) .ChangeSizeRelative(width: 0) .ChangeSizeBy(width: SceneTreeWidth); componentArea = new GUIArea(this) .OffsetBy(horizontal: SceneTreeWidth) .ChangeSizeBy(width: -SceneTreeWidth); state = new SceneExplorerState(); RecalculateAreas(); }
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 void Add(GUIArea area) { GUISystem.Add(area); }
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 bool HandleGUIEvent(Event ev) { bool used = false; if(visible) { Vector2 localMousePos = ev.mousePosition - new Vector2(bounds.xMin, bounds.yMin) - new Vector2(marginSize, marginSize); Rect sbBounds = new Rect(0, 0, pixelWidth - marginSize * 2 - splitSize, pixelHeight - marginSize * 2 - splitSize); Rect aBounds = new Rect(0, pixelWidth - marginSize - splitSize, pixelHeight - marginSize * 2, splitSize); Rect hBounds = new Rect(pixelWidth - marginSize * 2 - splitSize, 0, splitSize, pixelHeight - marginSize * 2 - splitSize); if(bounds.Contains(ev.mousePosition)) { if(ev.type == EventType.mouseUp) { activeArea = GUIArea.None; used = true; } else if(ev.type == EventType.mouseDown) { if(sbBounds.Contains(localMousePos)) { activeArea = GUIArea.Color; } else if(hBounds.Contains(localMousePos)) { activeArea = GUIArea.Hue; } else if(aBounds.Contains(localMousePos)) { activeArea = GUIArea.Alpha; } else { activeArea = GUIArea.None; } used = true; } } else { if(Event.current.type == EventType.mouseDown) { activeArea = GUIArea.None; } } if((Event.current.type == EventType.mouseDrag || Event.current.type == EventType.mouseDown) && activeArea != GUIArea.None) { RagePixelHSBColor hsbcolor = new RagePixelHSBColor(selectedColor); switch(activeArea) { case GUIArea.Color: hsbcolor.s = Mathf.Clamp(localMousePos.x, 0.001f, sbBounds.width - 0.001f) / (sbBounds.width); hsbcolor.b = 1f - Mathf.Clamp(localMousePos.y, 0.001f, sbBounds.height - 0.001f) / (sbBounds.height); break; case GUIArea.Hue: hsbcolor.h = 1f - Mathf.Clamp(localMousePos.y, 0.001f, hBounds.height - 0.001f) / (hBounds.height); break; case GUIArea.Alpha: hsbcolor.a = Mathf.Clamp(localMousePos.x, 0.001f, aBounds.width - 0.001f) / (aBounds.width); break; } selectedColor = hsbcolor.ToColor(); used = true; } } return used; }
//transition from one GUIArea to Another public static void fadeOutIn(float transTime, ref GUIArea exit, ref GUIArea enter) { exit.exitFade(transTime); enter.enterFade(transTime); }
public static void slideUpOutIn(float transTime, ref GUIArea exit, ref GUIArea enter) { exit.exitTop(transTime); enter.enterTop(transTime); }
public static void slideDownOutIn(float transTime, ref GUIArea exit, ref GUIArea enter) { exit.exitBottom(transTime); enter.enterBottom(transTime); }
public static void slideLeftOutIn(float transTime, ref GUIArea exit, ref GUIArea enter) { exit.exitLeft(transTime); enter.enterLeft(transTime); }
public static void slideRightLeft(float transTime, ref GUIArea exit, ref GUIArea enter) { exit.exitRight(transTime); enter.enterLeft(transTime); }
public static void slideBottomTop(float transTime, ref GUIArea exit, ref GUIArea enter) { exit.exitBottom(transTime); enter.enterTop(transTime); }
public void SetType( string guiName, GUIEditObject.GUITypes guiType ) { // create based on type if ( guiType == GUITypes.Screen ) { guiScreen = new GUIScreen(); guiScreen.name = guiName; } if ( guiType == GUITypes.Area ) { guiObject = new GUIArea(); guiObject.name = guiName; } if ( guiType == GUITypes.Label ) { guiObject = new GUILabel(); guiObject.name = guiName; } if ( guiType == GUITypes.Button ) { guiObject = new GUIButton(); guiObject.name = guiName; } if ( guiType == GUITypes.Horizontal ) { guiObject = new GUIHorizontalCommand(); guiObject.name = guiName; } if ( guiType == GUITypes.Vertical ) { guiObject = new GUIVerticalCommand(); guiObject.name = guiName; } if ( guiType == GUITypes.Scrollview ) { guiObject = new GUIScrollView(); guiObject.name = guiName; } if ( guiType == GUITypes.Toggle ) { guiObject = new GUIToggle(); guiObject.name = guiName; } if ( guiType == GUITypes.Space ) { guiObject = new GUISpace(); guiObject.name = guiName; } if ( guiType == GUITypes.EditBox ) { guiObject = new GUIEditbox(); guiObject.name = guiName; } if ( guiType == GUITypes.Box ) { guiObject = new GUIBox(); guiObject.name = guiName; } if ( guiType == GUITypes.HorizontalSlider ) { guiObject = new GUIHorizontalSlider(); guiObject.name = guiName; } if ( guiType == GUITypes.VerticalSlider ) { guiObject = new GUIVerticalSlider(); guiObject.name = guiName; } if ( guiType == GUITypes.Movie ) { guiObject = new GUIMovie(); guiObject.name = guiName; } }
public void Remove(GUIArea area) { GUISystem.Remove(area); }
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); }
public bool HandleGUIEvent(Event ev) { bool used = false; if (visible) { Vector2 localMousePos = ev.mousePosition - new Vector2(bounds.xMin, bounds.yMin) - new Vector2(marginSize, marginSize); Rect sbBounds = new Rect(0, 0, pixelWidth - marginSize * 2 - splitSize, pixelHeight - marginSize * 2 - splitSize); Rect aBounds = new Rect(0, pixelWidth - marginSize - splitSize, pixelHeight - marginSize * 2, splitSize); Rect hBounds = new Rect(pixelWidth - marginSize * 2 - splitSize, 0, splitSize, pixelHeight - marginSize * 2 - splitSize); if (bounds.Contains(ev.mousePosition)) { if (ev.type == EventType.mouseUp) { activeArea = GUIArea.None; used = true; } else if (ev.type == EventType.mouseDown) { if (sbBounds.Contains(localMousePos)) { activeArea = GUIArea.Color; } else if (hBounds.Contains(localMousePos)) { activeArea = GUIArea.Hue; } else if (aBounds.Contains(localMousePos)) { activeArea = GUIArea.Alpha; } else { activeArea = GUIArea.None; } used = true; } } else { if (Event.current.type == EventType.mouseDown) { activeArea = GUIArea.None; } } if ((Event.current.type == EventType.mouseDrag || Event.current.type == EventType.mouseDown) && activeArea != GUIArea.None) { RagePixelHSBColor hsbcolor = new RagePixelHSBColor(selectedColor); switch (activeArea) { case GUIArea.Color: hsbcolor.s = Mathf.Clamp(localMousePos.x, 0.001f, sbBounds.width - 0.001f) / (sbBounds.width); hsbcolor.b = 1f - Mathf.Clamp(localMousePos.y, 0.001f, sbBounds.height - 0.001f) / (sbBounds.height); break; case GUIArea.Hue: hsbcolor.h = 1f - Mathf.Clamp(localMousePos.y, 0.001f, hBounds.height - 0.001f) / (hBounds.height); break; case GUIArea.Alpha: hsbcolor.a = Mathf.Clamp(localMousePos.x, 0.001f, aBounds.width - 0.001f) / (aBounds.width); break; } selectedColor = hsbcolor.ToColor(); used = true; } } return(used); }
public override void Process(GUIScreen parentScreen, GUIArea container) { base.Process(parentScreen, container); if (scrollMenu != null) { scrollMenu.Process(parentScreen, container); menus = new GUIScrollMenu[4]; menus[0] = new GUIScrollMenu(); menus[1] = new GUIScrollMenu(); menus[2] = new GUIScrollMenu(); menus[3] = new GUIScrollMenu(); menus[0].CopyFrom(scrollMenu); menus[1].CopyFrom(scrollMenu); menus[2].CopyFrom(scrollMenu); menus[3].CopyFrom(scrollMenu); menus[0].buttonTemplate = scrollMenu.buttonTemplate; menus[0].scrollviewTemplate = scrollMenu.scrollviewTemplate; menus[0].Process(parentScreen, container); menus[1].buttonTemplate = scrollMenu.buttonTemplate; menus[1].scrollviewTemplate = scrollMenu.scrollviewTemplate; menus[1].Process(parentScreen, container); menus[2].buttonTemplate = scrollMenu.buttonTemplate; menus[2].scrollviewTemplate = scrollMenu.scrollviewTemplate; menus[2].Process(parentScreen, container); menus[3].buttonTemplate = scrollMenu.buttonTemplate; menus[3].scrollviewTemplate = scrollMenu.scrollviewTemplate; menus[3].Process(parentScreen, container); } if (divider != null) divider.Process(parentScreen, container); }