internal void RefreshGrid() { Point currSelection = grid.SelectionIndex; GetSortedGridElements(refreshGrid_scratch); for (int i = 0; i < grid.ActualDimensions.Y; ++i) { UIGridShareHubElement elem = grid.Get(0, i) as UIGridShareHubElement; elem.Selected = false; if (!refreshGrid_scratch.Contains(elem)) { BokuGame.Unload(elem); } } grid.Clear(); for (int i = 0; i < refreshGrid_scratch.Count; ++i) { grid.Add(refreshGrid_scratch[i], 0, grid.ActualDimensions.Y); BokuGame.Load(refreshGrid_scratch[i]); } grid.Dirty = true; // Try to preserve selection index. // We might want to try to relocate the selected element if it moved instead. if (grid.ActualDimensions.Y > currSelection.Y) { grid.SelectionIndex = new Point(0, currSelection.Y); } else if (grid.ActualDimensions.Y > 0) { grid.SelectionIndex = new Point(0, grid.ActualDimensions.Y - 1); } Matrix parentMatrix = Matrix.Identity; grid.Update(ref parentMatrix); }
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 override void Update() { // Our children have input focus but we can still steal away the buttons we care about. GamePadInput pad = GamePadInput.GetGamePad1(); UIGrid curGrid = shared.GetGridFromCurTab(); bool sortNeeded = false; // Do we or our children have input focus? This is so we can steal some inputs from them. if (CommandStack.Peek() == parent.commandMap || (curGrid != null && CommandStack.Peek() == curGrid.commandMap)) { if (pad.RightShoulder.WasPressed || pad.DPadRight.WasPressed || pad.LeftStickRight.WasPressed) { parent.curTab = (Tab)(((int)parent.curTab + 1) % (int)Tab.NumTabs); #if HIDE_MISSIONS if (parent.curTab == Tab.Missions) { parent.curTab = (Tab)(((int)parent.curTab + 1) % (int)Tab.NumTabs); } #endif // Update active state. if (curGrid != null) { curGrid.Active = false; } curGrid = shared.GetGridFromCurTab(); if (curGrid != null) { curGrid.Active = true; } sortNeeded = true; } if (pad.LeftShoulder.WasPressed || pad.DPadLeft.WasPressed || pad.LeftStickLeft.WasPressed) { parent.curTab = (Tab)(((int)parent.curTab + (int)Tab.NumTabs - 1) % (int)Tab.NumTabs); #if HIDE_MISSIONS if (parent.curTab == Tab.Missions) { parent.curTab = (Tab)(((int)parent.curTab + (int)Tab.NumTabs - 1) % (int)Tab.NumTabs); } #endif // Update active state. if (curGrid != null) { curGrid.Active = false; } curGrid = shared.GetGridFromCurTab(); if (curGrid != null) { curGrid.Active = true; } sortNeeded = true; } if (pad.ButtonY.WasPressed) { shared.curSortOrder = (LevelSort.SortBy)(((int)shared.curSortOrder + 1) % (int)LevelSort.SortBy.NumSorts); sortNeeded = true; shared.bottomBarDirty = true; BokuGame.Audio.GetCue("programming add").Play(); } if (shared.curSortOrder == LevelSort.SortBy.UnSorted) { shared.curSortOrder = LevelSort.SortBy.Date; sortNeeded = true; } if (sortNeeded && curGrid != null) { LevelSort.SortGrid(curGrid, shared.curSortOrder); sortNeeded = false; } if (pad.ButtonB.WasPressed) { // Back to Main Menu. parent.Deactivate(); MainMenu.Instance.Activate(); } // Only allow deletions from Downloads or MyWorlds. if (pad.ButtonX.WasPressed && (parent.curTab == Tab.Downloads || parent.curTab == Tab.MyWorlds)) { // TODO delete file. Ask are you sure??? // Delete the file. If curGrid is null then there's no file to delete. if (curGrid != null) { UIGridWorldTile tile = (UIGridWorldTile)curGrid.SelectionElement; String filename = tile.FullPath; if (Storage.Exists(filename)) { // NOTE: It is not safe to delete the following files since they could // be shared by multiple worlds: // // - The "stuff" file // - The terrain heightmap file // - The terrain texture select file // Delete world xml file Storage.Delete(filename); // Delete thumbnail image Storage.TextureDelete(Path.GetDirectoryName(filename) + @"\" + Path.GetFileNameWithoutExtension(filename)); if (InGame.CurrentWorldId.ToString() == Path.GetFileNameWithoutExtension(filename)) { // Reset the current world information InGame.AutoSaved = false; InGame.XmlWorldData = null; } } // Remove the shared render targets from all elements. UIGridWorldTile.SharedRenderTarget.ResetAll(); // Remove the element from the grid. if (curGrid.RemoveAndCollapse(curGrid.SelectionIndex)) { // This was last element in grid. Delete it. // Pop its command map. CommandStack.Pop(curGrid.commandMap); // Remove the grid itself. switch (parent.curTab) { case Tab.Missions: shared.missionsGrid = null; break; case Tab.MyWorlds: shared.myWorldsGrid = null; break; case Tab.StarterWorlds: shared.starterWorldsGrid = null; break; case Tab.Downloads: shared.downloadsGrid = null; break; } curGrid = null; } } // end if curGrid != null } // end if 'X' was pressed. } // end of if we have input focus // If we're not shutting down, update the tabs and the child grids. if (parent.pendingState != States.Inactive) { Matrix world = Matrix.Identity; // Set the backdrop color and unfade current tab. switch (parent.curTab) { case Tab.Missions: shared.missionsTab.Selected = true; shared.myWorldsTab.Selected = false; shared.starterWorldsTab.Selected = false; shared.downloadsTab.Selected = false; break; case Tab.MyWorlds: shared.missionsTab.Selected = false; shared.myWorldsTab.Selected = true; shared.starterWorldsTab.Selected = false; shared.downloadsTab.Selected = false; break; case Tab.StarterWorlds: shared.missionsTab.Selected = false; shared.myWorldsTab.Selected = false; shared.starterWorldsTab.Selected = true; shared.downloadsTab.Selected = false; break; case Tab.Downloads: shared.missionsTab.Selected = false; shared.myWorldsTab.Selected = false; shared.starterWorldsTab.Selected = false; shared.downloadsTab.Selected = true; break; } shared.missionsTab.Update(); shared.myWorldsTab.Update(); shared.starterWorldsTab.Update(); shared.downloadsTab.Update(); shared.UpdateBottomBarTexture(); shared.bottomBar.Update(); if (shared.missionsGrid != null) { shared.missionsGrid.Update(ref world); } if (shared.myWorldsGrid != null) { shared.myWorldsGrid.Update(ref world); } if (shared.starterWorldsGrid != null) { shared.starterWorldsGrid.Update(ref world); } if (shared.downloadsGrid != null) { shared.downloadsGrid.Update(ref world); } // Make sure the visible elements for the current grid have render targets. if (curGrid != null) { int focus = curGrid.SelectionIndex.Y; int start = Math.Max(focus - 3, 0); int end = Math.Min(focus + 3, curGrid.ActualDimensions.Y - 1); for (int i = start; i <= end; i++) { UIGridWorldTile tile = (UIGridWorldTile)curGrid.Get(0, i); if (tile.SRT == null) { // Get a rendertarget and assign to current tile. UIGridWorldTile.SharedRenderTarget srt = UIGridWorldTile.SharedRenderTarget.Get(curGrid); srt.Grid = curGrid; srt.Index = i; tile.SRT = srt; } } } } // end if not shutting down. } // end of Update()
} // end of c'tor public void Update() { changeLanguageMessage.Update(camera); if (active && CommandStack.Peek() == grid.CommandMap) { UIGridElement prevE = grid.SelectionElement; HandleTouchInput(); HandleMouseInput(); HandleGamepadInput(); // Update the grid. grid.Update(ref worldGrid); // If the Update deactived us, bail. if (!active) { return; } // Update help square's positioning to line up with current selection. Vector3 selectionElementOffset = grid.SelectionElement.Position - grid.ScrollOffset; helpSquare.Position = new Vector2(helpSquare.Position.X, selectionElementOffset.Y); // For each element in the grid, calc it's screen space Y position // and give it a slight twist around the Y axis based on this. // Note this assumes that this grid is 1d vertical. for (int j = 0; j < grid.ActualDimensions.Y; j++) { UIGridElement e = grid.Get(0, j); Vector3 pos = Vector3.Transform(e.Position, grid.WorldMatrix); Vector3 rot = Vector3.Zero; float rotationScaling = 0.2f; rot.Y = -rotationScaling * pos.Y; e.Rotation = rot; } if (prevE != grid.SelectionElement) { if (grid.SelectionElement.ShowHelpButton) { helpSquare.Show(); } else { helpSquare.Hide(); } } helpSquare.Update(); GamePadInput.ClearAllWasPressedState(); } // end of if active and have input focus. // Update the text displays. Internally they check if they're active before doing anything. if (active) { InGame.inGame.shared.smallTextDisplay.Update(camera); InGame.inGame.shared.scrollableTextDisplay.Update(camera); } } // end of Update()
} // end of TexturePicker InitFileList() public void Update() { if (active) { GamePadInput pad = GamePadInput.GetGamePad1(); // Switch active grid? bool changed = false; if (pad.LeftStickLeft.WasPressed || pad.DPadLeft.WasPressed) { activeGrid = (activeGrid + 3) % 4; changed = true; Foley.PlayProgrammingClick(); } if (pad.LeftStickRight.WasPressed || pad.DPadRight.WasPressed) { activeGrid = (activeGrid + 1) % 4; changed = true; Foley.PlayProgrammingClick(); } if (changed) { Vector3 newPosition = new Vector3(-2.25f + 1.5f * activeGrid, 0.0f, 0.0f); TwitchManager.GetVector3 get = delegate(Object param) { return(selectionPlate.Position); }; TwitchManager.SetVector3 set = delegate(Vector3 value, Object param) { selectionPlate.Position = value; }; TwitchManager.Vector3Twitch twitch = new TwitchManager.Vector3Twitch(get, set, newPosition, 0.25f, TwitchCurve.Shape.OvershootOut); twitch.Start(); grid0.Active = false; grid1.Active = false; grid2.Active = false; grid3.Active = false; switch (activeGrid) { case 0: grid0.Active = true; break; case 1: grid1.Active = true; break; case 2: grid2.Active = true; break; case 3: grid3.Active = true; break; } changed = false; } backPlate.Update(); selectionPlate.Update(); grid0.Update(ref worldGrid); grid1.Update(ref worldGrid); grid2.Update(ref worldGrid); grid3.Update(ref worldGrid); // See if any of the grids have changed which texture is in focus. // If so, change what the terrain sees. if (grid0.SelectionIndex.Y != curFocusIndex0) { curFocusIndex0 = grid0.SelectionIndex.Y; InGame.inGame.Terrain.ChangeTerrainTexture(0, files[curFocusIndex0]); InGame.inGame.IsLevelDirty = true; } if (grid1.SelectionIndex.Y != curFocusIndex1) { curFocusIndex1 = grid1.SelectionIndex.Y; InGame.inGame.Terrain.ChangeTerrainTexture(1, files[curFocusIndex1]); InGame.inGame.IsLevelDirty = true; } if (grid2.SelectionIndex.Y != curFocusIndex2) { curFocusIndex2 = grid2.SelectionIndex.Y; InGame.inGame.Terrain.ChangeTerrainTexture(2, files[curFocusIndex2]); InGame.inGame.IsLevelDirty = true; } if (grid3.SelectionIndex.Y != curFocusIndex3) { curFocusIndex3 = grid3.SelectionIndex.Y; InGame.inGame.Terrain.ChangeTerrainTexture(3, files[curFocusIndex3]); InGame.inGame.IsLevelDirty = true; } float outerRowAlpha = 0.3f; float innerRowAlpha = 0.7f; // Update the alpha values of the visible tiles. for (int i = 0; i < grid0.ActualDimensions.Y; i++) { UIGrid2DTextureElement e = null; e = grid0.Get(0, i) as UIGrid2DTextureElement; if (e != null) { int delta = Math.Abs(i - grid0.SelectionIndex.Y); if (delta < 2) { e.Alpha = 1.0f; } else if (delta < 3) { e.Alpha = innerRowAlpha; } else { e.Alpha = outerRowAlpha; } } e = grid1.Get(0, i) as UIGrid2DTextureElement; if (e != null) { int delta = Math.Abs(i - grid1.SelectionIndex.Y); if (delta < 2) { e.Alpha = 1.0f; } else if (delta < 3) { e.Alpha = innerRowAlpha; } else { e.Alpha = outerRowAlpha; } } e = grid2.Get(0, i) as UIGrid2DTextureElement; if (e != null) { int delta = Math.Abs(i - grid2.SelectionIndex.Y); if (delta < 2) { e.Alpha = 1.0f; } else if (delta < 3) { e.Alpha = innerRowAlpha; } else { e.Alpha = outerRowAlpha; } } e = grid3.Get(0, i) as UIGrid2DTextureElement; if (e != null) { int delta = Math.Abs(i - grid3.SelectionIndex.Y); if (delta < 2) { e.Alpha = 1.0f; } else if (delta < 3) { e.Alpha = innerRowAlpha; } else { e.Alpha = outerRowAlpha; } } } } } // end of TexturePicker Update()