/// <summary> /// Set camera option (auto or manual) /// </summary> public void SetCamera(object sender, EventArgs e) { TickBox tickbox = (TickBox)sender; if (tickbox.IsClicked) { CameraController.autoFollow = true; } else { CameraController.autoFollow = false; } }
/// <summary> /// Mute or not the background music /// </summary> public void SetMusic(object sender, EventArgs e) { TickBox tickbox = (TickBox)sender; if (tickbox.IsClicked) { Audio.SetMusicVolume(.1f); } else { Audio.SetMusicVolume(0); } }
void drawSettings() { // warn people changes can be ignored if (net.Connected) { S.SetShoutyColor(); GUI.Box(new Rect(Screen.width / 3, 0, Screen.width / 3 * 2, 80), "Currently, you have to change AVATAR settings while disconnected \n for changes to be networked"); } menuBegin(); // allow sidestepping to control config screen GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Configure Mouse & Keys, or Controller")) { Mode = HudMode.Controls; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // misc settings // gun bob GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); net.gunBobbing = TickBox.Display(net.gunBobbing, "Gun bobbing"); if (net.gunBobbing) { PlayerPrefs.SetInt("GunBobbing", 1); } else { PlayerPrefs.SetInt("GunBobbing", 0); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // chat fade GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); SizedLabel("Chat/Log fade time: "); Log.FadeTime = (float)S.GetInt(GUILayout.TextField(Log.FadeTime.ToString())); PlayerPrefs.SetFloat("textFadeTime", Log.FadeTime); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // audio //categoryHeader("Audio"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Master Volume: "); Sfx.VolumeMaster = GUILayout.HorizontalSlider(Sfx.VolumeMaster, 0.0f, 1f, GUILayout.MinWidth(128)); PlayerPrefs.SetFloat("MasterVolume", Sfx.VolumeMaster); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // FOV slider GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); var s = "FOV (field of view): "; float wid = GetWidthLabel(s + "188.8"); GUILayout.Label(s + locUser.FOV.ToString("#.#"), GUILayout.MinWidth(wid)); locUser.FOV = GUILayout.HorizontalSlider(locUser.FOV, 50f, 180f, GUILayout.MinWidth(128)); if (net.Connected) { net.LocEnt.Actor.FOV = locUser.FOV; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // graphics //categoryHeader("Graphics"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Full screen")) { Screen.SetResolution(fsWidth, fsHeight, true); } GUILayout.Label("("); fsWidth = S.GetInt(GUILayout.TextField(fsWidth.ToString())); GUILayout.Label("X"); fsHeight = S.GetInt(GUILayout.TextField(fsHeight.ToString())); GUILayout.Label(")"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // avatar settings CategoryHeader("Avatar"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); SizedLabel("Name: "); net.LocEnt.name = GUILayout.TextField(net.LocEnt.name); if (net.LocEnt.name.Length > 20) { net.LocEnt.name = net.LocEnt.name.Substring(0, 20); } net.LocEnt.name = FormatName(net.LocEnt.name); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); innerScrollPos = GUILayout.BeginScrollView(innerScrollPos); // head slider float hss = 1f / (int)Head.Count; // head slider span net.LocEnt.headType = (int)(headSliderPos / hss); GUILayout.BeginHorizontal(); float w = GetWidthLabel(S.GetSpacedOut("" + Head.ElephantHeadMesh)); GUILayout.Label(S.GetSpacedOut("" + (Head)net.LocEnt.headType), GUILayout.MaxWidth(w)); headSliderPos = GUILayout.HorizontalSlider(headSliderPos, 0f, 1f); GUILayout.EndHorizontal(); // colour sliders GUILayout.BeginHorizontal(); GUI.color = net.LocEnt.colA; GUILayout.Box(Pics.White); GUI.color = net.LocEnt.colB; GUILayout.Box(Pics.White); GUI.color = net.LocEnt.colC; GUILayout.Box(Pics.White); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUI.color = net.LocEnt.colA; GUILayout.Box("Colour A"); GUI.color = net.LocEnt.colB; GUILayout.Box("Colour B"); GUI.color = net.LocEnt.colC; GUILayout.Box("Colour C"); GUILayout.EndHorizontal(); colorSliders(); GUI.color = Color.white; GUILayout.EndScrollView(); menuEnd(); // now just save player if (net.LocEnt.name != "" && net.LocEnt.name != " ") { PlayerPrefs.SetString("PlayerName", net.LocEnt.name); } else { PlayerPrefs.SetString("PlayerName", defaultName); } PlayerPrefs.SetFloat("FOV", locUser.FOV); PlayerPrefs.SetInt("PlayerHead", net.LocEnt.headType); // the 3 user chosen colors PlayerPrefs.SetFloat("PlayerColA_R", net.LocEnt.colA.r); PlayerPrefs.SetFloat("PlayerColA_G", net.LocEnt.colA.g); PlayerPrefs.SetFloat("PlayerColA_B", net.LocEnt.colA.b); PlayerPrefs.SetFloat("PlayerColB_R", net.LocEnt.colB.r); PlayerPrefs.SetFloat("PlayerColB_G", net.LocEnt.colB.g); PlayerPrefs.SetFloat("PlayerColB_B", net.LocEnt.colB.b); PlayerPrefs.SetFloat("PlayerColC_R", net.LocEnt.colC.r); PlayerPrefs.SetFloat("PlayerColC_G", net.LocEnt.colC.g); PlayerPrefs.SetFloat("PlayerColC_B", net.LocEnt.colC.b); }
/// <summary> /// Create the menu Panels from files /// </summary> /// <param name="pathName">Path to the file which define the panel</param> /// <param name="panelName">Name of the current panel to contstruct</param> /// <param name="setPanelActive">If true, set the panel to active</param> /// <param name="offsetWidth">Offset by which all components will be shifted (position)</param> /// <param name="idAssociatePlayerScreen">Index of associate player screen, Usefull for split screen menu</param> public void CreatePanel(string pathName, string panelName, bool setPanelActive = false, int offsetWidth = 0, int idAssociatePlayerScreen = 0) { MenuManager.Instance.MenuRect[panelName].active = setPanelActive; // General parse of the file List <MenuStruct> panelObjects = File.ReadMenuPanel(pathName); // Define menu components foreach (MenuStruct MS in panelObjects) { if (MS.menuType == MenuType.Button) { if (MS.Name == "Alphabet") { CreateAlphabetButtons(panelName, offsetWidth, idAssociatePlayerScreen); } else { Button button = new Button(TexturesButtons[MS.TextureName], MS.Position + new Vector2(offsetWidth, 0)); if (MS.TextureInsideName != null) { button.InsideImage = TexturesButtons[MS.TextureInsideName]; } if (MS.Text != null) { button.Text = MS.Text; } if (MS.NameToSwitchTo != null) { button.NameMenuToSwitchTo = MS.NameToSwitchTo; } if (MS.Name != null) { button.nameIdentifier = MS.Name; } if (MS.ScaleHeight != default(float)) { button.ScaleHeight = MS.ScaleHeight; } if (MS.ScaleWidth != default(float)) { button.ScaleWidth = MS.ScaleWidth; } if (MS.ScaleHeightInside != default(float)) { button.ScaleHeightInside = MS.ScaleHeightInside; } if (MS.ScaleWidthInside != default(float)) { button.ScaleWidthInside = MS.ScaleWidthInside; } //if (MS.Index != default(int)) button.Index = MS.Index; if (MS.Color != default(Color)) { button.ImageColor = MS.Color; } if (MS.ColorInside != default(Color)) { button.InsideObjectColor = MS.ColorInside; } if (MS.transparency != default(int)) { button.ImageColor.A = (byte)MS.transparency; } button.IsCurrentSelection = MS.CurrentSelection; button.IsClicked = MS.IsClicked; button.IndexAssociatedPlayerScreen = idAssociatePlayerScreen; button.Index = MS.Index; button.DeSelectOnMove = MS.deSelectOnMove; button.Active = MS.Active; if (MS.UseBigFont) { button.Font = UserInterface.menuBigFont; } MenuManager.Instance.MenuRect[panelName].AddComponent(button); } } else if (MS.menuType == MenuType.Text) { if (MS.Name == "ModelsStats") { CreateTextModelsStats(panelName, offsetWidth, idAssociatePlayerScreen); } else { TextBox textBox = new TextBox(); if (MS.Name != null) { textBox.NameIdentifier = MS.Name; } if (MS.Position != null) { textBox.InitPos = MS.Position + new Vector2(offsetWidth, 0); } if (MS.Text != null) { textBox.Text = MS.Text; } else { textBox.Text = ""; } MenuManager.Instance.MenuRect[panelName].AddComponent(textBox); } } else if (MS.menuType == MenuType.Image) { Image img = new Image(TexturesButtons[MS.TextureName]); if (MS.Position != null) { img.Position = MS.Position + new Vector2(offsetWidth, 0); } if (MS.Name != null) { img.NameIdentifier = MS.Name; } if (MS.ScaleHeight != default(float)) { img.ScaleHeight = MS.ScaleHeight; } if (MS.ScaleWidth != default(float)) { img.ScaleWidth = MS.ScaleWidth; } if (MS.Color != default(Color)) { img.colour = MS.Color; } if (MS.transparency != default(int)) { img.colour.A = (byte)MS.transparency; } img.Active = MS.Active; MenuManager.Instance.MenuRect[panelName].AddComponent(img); } else if (MS.menuType == MenuType.Slider) { Slider slider = new Slider(MS.Position + new Vector2(offsetWidth, 0), TexturesButtons["slider"], TexturesButtons["button"]); if (MS.Name != null) { slider.nameIdentifier = MS.Name; } if (MS.TextureName != null) { slider.Texture = TexturesButtons[MS.TextureName]; } slider.IndexAssociatedPlayerScreen = idAssociatePlayerScreen; MenuManager.Instance.MenuRect[panelName].AddComponent(slider); } else if (MS.menuType == MenuType.TickBox) { TickBox tickBox = new TickBox(MS.Position + new Vector2(offsetWidth, 0), TexturesButtons["buttonCircle"], TexturesButtons["buttonCircle"]); if (MS.Name != null) { tickBox.nameIdentifier = MS.Name; } if (MS.ScaleHeight != default(float)) { tickBox.ScaleHeight = MS.ScaleHeight; } if (MS.ScaleWidth != default(float)) { tickBox.ScaleWidth = MS.ScaleWidth; } if (MS.ScaleHeightInside != default(float)) { tickBox.ScaleHeightClicked = MS.ScaleHeightInside; } if (MS.ScaleWidthInside != default(float)) { tickBox.ScaleWidthClicked = MS.ScaleWidthInside; } tickBox.IsClicked = MS.IsClicked; tickBox.IndexAssociatedPlayerScreen = idAssociatePlayerScreen; MenuManager.Instance.MenuRect[panelName].AddComponent(tickBox); } } // dirty hack :( if (panelName == "play2Shared0" || panelName == "play2Shared1" || panelName == "play2Shared2" || panelName == "play2Shared3") { Button bu = ((Button)FindMenuComponentinPanelWithName("NamePlayer", panelName)); bu.Text = "Player " + (idAssociatePlayerScreen + 1).ToString(); bu.IndexAssociatedPlayerScreen = idAssociatePlayerScreen; switch (panelName) { case "play2Shared0": bu.Text = "Louis"; break; case "play2Shared1": bu.Text = "Ted"; break; } } // Set constraints foreach (MenuStruct MS in panelObjects) { // Up, Down, Left, Right selection change if (MS.Name != null && MS.NeighborsUpDownLeftRight != null) { MenuComponent menuComp = FindMenuComponentinPanelWithName(MS.Name, panelName); if (MS.NeighborsUpDownLeftRight[0] != "null") { menuComp.NeighborUp = FindMenuComponentinPanelWithName(MS.NeighborsUpDownLeftRight[0], panelName); } if (MS.NeighborsUpDownLeftRight[1] != "null") { menuComp.NeighborDown = FindMenuComponentinPanelWithName(MS.NeighborsUpDownLeftRight[1], panelName); } if (MS.NeighborsUpDownLeftRight[2] != "null") { menuComp.NeighborLeft = FindMenuComponentinPanelWithName(MS.NeighborsUpDownLeftRight[2], panelName); } if (MS.NeighborsUpDownLeftRight[3] != "null") { menuComp.NeighborRight = FindMenuComponentinPanelWithName(MS.NeighborsUpDownLeftRight[3], panelName); } } // Set list of component with unique clicked possibility if (MS.Name != null && MS.UniqueChoiceButtonWith != null) { Button bu = (Button)FindMenuComponentinPanelWithName(MS.Name, panelName); foreach (string elem in MS.UniqueChoiceButtonWith) { bu.neighbors.Add((Button)FindMenuComponentinPanelWithName(elem, panelName)); } } // Set actions on pressed if (MS.menuType == MenuType.Button && MS.Name != null && MS.Functions != null) { Button bu = (Button)FindMenuComponentinPanelWithName(MS.Name, panelName); foreach (string elem in MS.Functions) { bu.Click += FunctionsMenu[elem]; } } else if (MS.menuType == MenuType.Slider && MS.Name != null && MS.Functions != null) { Slider sl = (Slider)FindMenuComponentinPanelWithName(MS.Name, panelName); foreach (string elem in MS.Functions) { sl.OnReleaseSlider += FunctionsMenu[elem]; } } else if (MS.menuType == MenuType.TickBox && MS.Name != null && MS.Functions != null) { TickBox tc = (TickBox)FindMenuComponentinPanelWithName(MS.Name, panelName); foreach (string elem in MS.Functions) { tc.Click += FunctionsMenu[elem]; } } } // Dirty hack // Create rankings if (panelName == "ranking") { LoadRankingsText(); } }