// c'tor public EditPathsTool() { HelpOverlayID = @"EditPaths"; // We don't want to see any brush rendered for this tool. prevBrushIndex = -1; // Get references. inGame = Boku.InGame.inGame; shared = inGame.shared; SetUpMenus(); // Set up blob for slider. blob.width = 512.0f / 96.0f; blob.height = blob.width / 5.0f; blob.edgeSize = 0.06f; blob.Font = UI2D.Shared.GetGameFont24Bold; blob.textColor = new Color(20, 20, 20); blob.normalMapName = @"Slant0Smoothed5NormalMap"; blob.justify = UIGridElement.Justification.Center; slider = new UIGridModularFloatSliderElement(blob, "To Be Replaced"); slider.OnChange = SliderOnChange; Matrix mat = Matrix.CreateTranslation(new Vector3(0.0f, -4.0f, 0.0f)); slider.WorldMatrix = mat; } // end of c'tor
private void InitGrid() { grid = new UIGrid(OnSelect, OnCancel, new Point(1, 10), "OptionsMenuGrid"); grid.LocalMatrix = Matrix.CreateTranslation(0.25f / 96.0f, 0.25f / 96.0f, 0.0f); grid.RenderEndsIn = true; grid.UseMouseScrollWheel = true; // Create a blob of common parameters. UIGridElement.ParamBlob blob = new UIGridElement.ParamBlob(); //blob.width = 5.0f; //blob.height = 1.0f; blob.width = 512.0f / 96.0f; blob.height = blob.width / 5.0f; blob.edgeSize = 0.06f; blob.Font = UI2D.Shared.GetGameFont24Bold; blob.textColor = Color.White; blob.dropShadowColor = Color.Black; blob.useDropShadow = true; blob.invertDropShadow = false; blob.unselectedColor = new Color(new Vector3(4, 100, 90) / 255.0f); blob.selectedColor = new Color(new Vector3(5, 180, 160) / 255.0f); blob.normalMapName = @"Slant0Smoothed5NormalMap"; blob.justify = UIGridModularCheckboxElement.Justification.Left; // // Create elements here. // int index = 0; { showToolTips = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.showToolTips")); showToolTips.OnCheck = delegate() { XmlOptionsData.ShowToolTips = true; }; showToolTips.OnClear = delegate() { XmlOptionsData.ShowToolTips = false; }; showToolTips.HelpID = "ShowToolTips"; // Add to grid. grid.Add(showToolTips, 0, index++); } { showHints = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.showHints")); showHints.OnCheck = delegate() { XmlOptionsData.ShowHints = true; }; showHints.OnClear = delegate() { XmlOptionsData.ShowHints = false; }; showHints.HelpID = "ShowHints"; // Add to grid. grid.Add(showHints, 0, index++); } { restoreDisabledHints = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.restoreDisabledHints")); restoreDisabledHints.OnCheck = delegate() { XmlOptionsData.RestoreDisabledHints(); }; restoreDisabledHints.OnClear = delegate() { restoreDisabledHints.Check = true; }; restoreDisabledHints.HelpID = "RestoreDisabledHints"; // Add to grid. grid.Add(restoreDisabledHints, 0, index++); } { showFramerate = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.showFramerate")); showFramerate.OnCheck = delegate() { XmlOptionsData.ShowFramerate = true; }; showFramerate.OnClear = delegate() { XmlOptionsData.ShowFramerate = false; }; showFramerate.HelpID = "ShowFramerate"; // Add to grid. grid.Add(showFramerate, 0, index++); } /* * { * helpLevel = new UIGridModularRadioBoxElement(blob, Strings.Localize("optionsParams.helpLevel")); * helpLevel.AddText(Strings.Localize("optionsParams.lowHelp")); * helpLevel.AddText(Strings.Localize("optionsParams.midHelp")); * helpLevel.AddText(Strings.Localize("optionsParams.highHelp")); * helpLevel.CurIndex = XmlOptionsData.HelpLevel; * helpLevel.OnChange = delegate(UIGridModularRadioBoxElement.ListEntry entry) * { * XmlOptionsData.HelpLevel = helpLevel.CurIndex; * }; * helpLevel.HelpID = "HelpOverlayAmount"; * // Add to grid. * grid.Add(helpLevel, 0, index++); * } */ { float oldWidth = blob.width; blob.width += 0.5f; language = new UIGridModularRadioBoxElement(blob, Strings.Localize("optionsParams.language")); blob.width = oldWidth; IEnumerable <LocalizationResourceManager.SupportedLanguage> langs = LocalizationResourceManager.SupportedLanguages; // Copy to a List so we can sort. List <LocalizationResourceManager.SupportedLanguage> languageList = new List <LocalizationResourceManager.SupportedLanguage>(); foreach (LocalizationResourceManager.SupportedLanguage lang in langs) { languageList.Add(lang); } languageList.Sort(LanguageSortComp); // Add the sorted languages to the UI element. foreach (LocalizationResourceManager.SupportedLanguage lang in languageList) { #if NETFX_CORE if (lang.NameInEnglish.Equals("hebrew", StringComparison.OrdinalIgnoreCase)) #else if (lang.NameInEnglish.Equals("hebrew", StringComparison.InvariantCultureIgnoreCase)) #endif { // RtoL code seems to have trouble with NSM characters 0x05b0 and 0x05b4. // Strip them out. string native = ""; char[] a = lang.NameInNative.ToCharArray(); foreach (char c in a) { if (c != 0x05b0 && c != 0x05b4) { native += c; } } language.AddText(lang.NameInEnglish + " : " + native, lang.Language); } else { language.AddText(lang.NameInEnglish + " : " + lang.NameInNative, lang.Language); } } language.NumColumns = 2; language.SetValueByKey(XmlOptionsData.Language); language.OnChange = delegate(UIGridModularRadioBoxElement.ListEntry entry) { // Note we can only get away with this since the language won't change for real until restart. XmlOptionsData.Language = language.CurKey; }; language.HelpID = "Language"; // Add to grid. grid.Add(language, 0, index++); } { modalToolMenu = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.ModalToolMenu")); modalToolMenu.OnCheck = delegate() { XmlOptionsData.ModalToolMenu = true; }; modalToolMenu.OnClear = delegate() { XmlOptionsData.ModalToolMenu = false; }; modalToolMenu.HelpID = "ModalToolMenu"; // Add to grid. grid.Add(modalToolMenu, 0, index++); } #region Stick Inverting { invertYAxis = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.invertYAxis")); invertYAxis.OnCheck = delegate() { PlayerIndex lastTouched = GamePadInput.RealToLogical(GamePadInput.LastTouched); GamePadInput.SetInvertYAxis(lastTouched, true); }; invertYAxis.OnClear = delegate() { PlayerIndex lastTouched = GamePadInput.RealToLogical(GamePadInput.LastTouched); GamePadInput.SetInvertYAxis(lastTouched, false); }; invertYAxis.HelpID = "InvertYAxis"; grid.Add(invertYAxis, 0, index++); } { invertXAxis = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.invertXAxis")); invertXAxis.OnCheck = delegate() { PlayerIndex lastTouched = GamePadInput.RealToLogical(GamePadInput.LastTouched); GamePadInput.SetInvertXAxis(lastTouched, true); }; invertXAxis.OnClear = delegate() { PlayerIndex lastTouched = GamePadInput.RealToLogical(GamePadInput.LastTouched); GamePadInput.SetInvertXAxis(lastTouched, false); }; invertXAxis.HelpID = "InvertXAxis"; grid.Add(invertXAxis, 0, index++); } { invertCamY = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.invertCamY")); invertCamY.OnCheck = delegate() { PlayerIndex lastTouched = GamePadInput.RealToLogical(GamePadInput.LastTouched); GamePadInput.SetInvertCamY(lastTouched, true); }; invertCamY.OnClear = delegate() { PlayerIndex lastTouched = GamePadInput.RealToLogical(GamePadInput.LastTouched); GamePadInput.SetInvertCamY(lastTouched, false); }; invertCamY.HelpID = "InvertCamY"; grid.Add(invertCamY, 0, index++); } { invertCamX = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.invertCamX")); invertCamX.OnCheck = delegate() { PlayerIndex lastTouched = GamePadInput.RealToLogical(GamePadInput.LastTouched); GamePadInput.SetInvertCamX(lastTouched, true); }; invertCamX.OnClear = delegate() { PlayerIndex lastTouched = GamePadInput.RealToLogical(GamePadInput.LastTouched); GamePadInput.SetInvertCamX(lastTouched, false); }; invertCamX.HelpID = "InvertCamX"; grid.Add(invertCamX, 0, index++); } #endregion Stick Inverting #region Terrain Edit Speed { // Restore default. blob.height = blob.width / 5.0f; terrainSpeed = new UIGridModularFloatSliderElement(blob, Strings.Localize("optionsParams.terrainSpeed")); terrainSpeed.MinValue = 0.25f; terrainSpeed.MaxValue = 4.0f; terrainSpeed.IncrementByAmount = 0.25f; terrainSpeed.NumberOfDecimalPlaces = 2; terrainSpeed.OnChange = delegate(float speed) { XmlOptionsData.TerrainSpeed = speed; }; terrainSpeed.HelpID = "TerrainSpeed"; grid.Add(terrainSpeed, 0, index++); } #endregion Terrain Edit Speed #region Audio Volumes { // Restore default. blob.height = blob.width / 5.0f; uiVolume = new UIGridModularFloatSliderElement(blob, Strings.Localize("optionsParams.uiVolume")); uiVolume.MinValue = 0.0f; uiVolume.MaxValue = 100.0f; uiVolume.IncrementByAmount = 5.0f; uiVolume.NumberOfDecimalPlaces = 0; uiVolume.OnChange = delegate(float volume) { XmlOptionsData.UIVolume = volume * 0.01f; }; uiVolume.HelpID = "UIVolume"; grid.Add(uiVolume, 0, index++); } { foleyVolume = new UIGridModularFloatSliderElement(blob, Strings.Localize("optionsParams.foleyVolume")); foleyVolume.MinValue = 0.0f; foleyVolume.MaxValue = 100.0f; foleyVolume.IncrementByAmount = 5.0f; foleyVolume.NumberOfDecimalPlaces = 0; foleyVolume.OnChange = delegate(float volume) { XmlOptionsData.FoleyVolume = volume * 0.01f; }; foleyVolume.HelpID = "EffectsVolume"; grid.Add(foleyVolume, 0, index++); } { musicVolume = new UIGridModularFloatSliderElement(blob, Strings.Localize("optionsParams.musicVolume")); musicVolume.MinValue = 0.0f; musicVolume.MaxValue = 100.0f; musicVolume.IncrementByAmount = 5.0f; musicVolume.NumberOfDecimalPlaces = 0; musicVolume.OnChange = delegate(float volume) { XmlOptionsData.MusicVolume = volume * 0.01f; }; musicVolume.HelpID = "MusicVolume"; grid.Add(musicVolume, 0, index++); } #endregion Audio Volumes #region Privacy Settings { checkForUpdates = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.checkForUpdates")); checkForUpdates.OnCheck = delegate() { XmlOptionsData.CheckForUpdates = true; }; checkForUpdates.OnClear = delegate() { XmlOptionsData.CheckForUpdates = false; }; checkForUpdates.HelpID = "CheckForUpdates"; // Add to grid. grid.Add(checkForUpdates, 0, index++); } { sendInstrumentation = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.sendInstrumentation")); sendInstrumentation.OnCheck = delegate() { XmlOptionsData.SendInstrumentation = true; }; sendInstrumentation.OnClear = delegate() { XmlOptionsData.SendInstrumentation = false; }; sendInstrumentation.HelpID = "SendInstrumentation"; // Add to grid. grid.Add(sendInstrumentation, 0, index++); } { UIGridModularButtonElement.UIButtonElementEvent onA = delegate() { Process.Start(Program2.SiteOptions.KGLUrl + @"/EULA#code_of_conduct"); }; showCodeOfConduct = new UIGridModularButtonElement(blob, Strings.Localize("optionsParams.viewCodeOfConduct"), Strings.Localize("optionsParams.viewButtonLabel"), onA, null, null); showCodeOfConduct.HelpID = "ShowCodeOfConduct"; grid.Add(showCodeOfConduct, 0, index++); } { UIGridModularButtonElement.UIButtonElementEvent onA = delegate() { Process.Start(Program2.SiteOptions.KGLUrl + @"/privacy"); }; showPrivacyStatement = new UIGridModularButtonElement(blob, Strings.Localize("optionsParams.viewPrivacyStatement"), Strings.Localize("optionsParams.viewButtonLabel"), onA, null, null); showPrivacyStatement.HelpID = "ShowPrivacyStatement"; grid.Add(showPrivacyStatement, 0, index++); } { UIGridModularButtonElement.UIButtonElementEvent onA = delegate() { Process.Start(Program2.SiteOptions.KGLUrl + @"/EULA#eula"); }; showEULA = new UIGridModularButtonElement(blob, Strings.Localize("optionsParams.viewEULA"), Strings.Localize("optionsParams.viewButtonLabel"), onA, null, null); showEULA.HelpID = "ShowEULA"; grid.Add(showEULA, 0, index++); } #endregion #region ShowIntroVideo { showIntroVideo = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.showIntroVideo")); showIntroVideo.OnCheck = delegate() { XmlOptionsData.ShowIntroVideo = true; }; showIntroVideo.OnClear = delegate() { XmlOptionsData.ShowIntroVideo = false; }; showIntroVideo.HelpID = "ShowIntroVideo"; // Add to grid. grid.Add(showIntroVideo, 0, index++); } #endregion #region ShowTutorialDebug { showTutorialDebug = new UIGridModularCheckboxElement(blob, Strings.Localize("optionsParams.showTutorialDebug")); showTutorialDebug.OnCheck = delegate() { XmlOptionsData.ShowTutorialDebug = true; }; showTutorialDebug.OnClear = delegate() { XmlOptionsData.ShowTutorialDebug = false; }; showTutorialDebug.HelpID = "ShowTutorialDebug"; // Add to grid. grid.Add(showTutorialDebug, 0, index++); } #endregion showVersion = new UIGridModularButtonElement(blob, Strings.Localize("shareHub.appName") + " (" + Program2.ThisVersion.ToString() + ", " + Program2.SiteOptions.Product + ")", null, null, null, null); showVersion.HelpID = "Version"; grid.Add(showVersion, 0, index++); // // Set grid properties. // grid.Spacing = new Vector2(0.0f, 0.1f); // The first number doesn't really matter since we're doing a 1d column. grid.Scrolling = true; grid.Wrap = false; grid.LocalMatrix = Matrix.Identity; // Loop over al the elements in the grid. For any that have // help, set the flag so they display Y button for help. for (int i = 0; i < grid.ActualDimensions.Y; i++) { UIGridElement e = grid.Get(0, i); string helpID = e.HelpID; string helpText = TweakScreenHelp.GetHelp(helpID); if (helpText != null) { e.ShowHelpButton = true; } } } // end of InitGrid
public MicrobitPatternEditor() { // Create a blob of common parameters. UIGridElement.ParamBlob blob = new UIGridElement.ParamBlob(); blob.width = 512.0f / 96.0f; // 5.33333 blob.height = blob.width / 5.0f; // 1.06667 blob.edgeSize = 0.06f; blob.Font = UI2D.Shared.GetGameFont24Bold; blob.textColor = Color.White; blob.dropShadowColor = Color.Black; blob.useDropShadow = true; blob.invertDropShadow = false; blob.unselectedColor = new Color(new Vector3(4, 100, 90) / 255.0f); blob.selectedColor = new Color(new Vector3(5, 180, 160) / 255.0f); blob.normalMapName = @"Slant0Smoothed5NormalMap"; blob.justify = UIGridModularCheckboxElement.Justification.Left; brightnessSlider = new UIGridModularIntegerSliderElement(blob, Strings.Localize("microbitPatternEditor.brightness")); brightnessSlider.Position = new Vector3(1.06667f, 1.01f, 0); brightnessSlider.MinValue = 0; brightnessSlider.MaxValue = 255; brightnessSlider.IncrementByAmount = 1; brightnessSlider.FastScrollScalar = 10; brightnessSlider.UseRightStick = true; brightnessSlider.OnChange = delegate(int brightness) { pattern.Brightness = brightness; }; brightnessSlider.SetHelpOverlay = false; durationSlider = new UIGridModularFloatSliderElement(blob, Strings.Localize("microbitPatternEditor.duration")); durationSlider.Position = new Vector3(1.06667f, 0.0f, 0); durationSlider.MinValue = 0.0f; durationSlider.MaxValue = 5.0f; durationSlider.IncrementByAmount = 0.1f; durationSlider.CurrentValueImmediate = 0.1f; durationSlider.UseRightStick = true; durationSlider.OnChange = delegate(float duration) { pattern.Duration = duration; }; durationSlider.SetHelpOverlay = false; blob.width = 2.06777f; blob.height = blob.width; ledGrid = new UIGrid2DLEDArrayElement(blob); ledGrid.Position = new Vector3(-2.58f, 0.51f, 0); ledGrid.SetHelpOverlay = false; blob.width = brightnessSlider.Width + ledGrid.Width - 0.04f; blob.height = brightnessSlider.Height * 0.75f; bar = new UIGrid2DButtonBarElement(blob); bar.Position = new Vector3(0.055f, -0.875f, 0); bar.SetHelpOverlay = false; camera = new PerspectiveUICamera(); leftStickPosition = new Vector2(-3.9f, 0.5f); rightStickPositionBrightness = new Vector2(4.0f, 1.0f); rightStickPositionDuration = new Vector2(4.0f, 0.0f); rightStickPosition = rightStickPositionBrightness; // Buttons { GetTexture getTexture = delegate() { return(ButtonTextures.BButton); }; cancelButton = new Button(Strings.Localize("saveLevelDialog.cancel"), labelColor, getTexture, UI2D.Shared.GetGameFont20); } { GetTexture getTexture = delegate() { return(ButtonTextures.AButton); }; saveButton = new Button(Strings.Localize("saveLevelDialog.save"), labelColor, getTexture, UI2D.Shared.GetGameFont20); } { GetTexture getTexture = delegate() { return(ButtonTextures.YButton); }; toggleLEDButton = new Button(Strings.Localize("microbitPatternEditor.toggleLED"), labelColor, getTexture, UI2D.Shared.GetGameFont20); } } // end of c'tor