public void DeleteMapset(IMapset mapset) { if (mapset == null) { Logger.LogWarning("Attempted to delete a null mapset."); return; } // If this mapset is currently selected, make it select the previous mapset. var selectedMapset = selection.Mapset.Value; if (selectedMapset == mapset) { // If there is only one mapset left in all mapsets, just remove selection. if (allMapsets.Count <= 1) { selection.SelectMapset(null); } else { // Determine which mapset list to choose the previous map from. var mapsetsList = ( (displayedMapsets.Contains(mapset) && displayedMapsets.Count == 1) || displayedMapsets.Count == 0 ? allMapsets : displayedMapsets ); selection.SelectMapset(mapsetsList.GetPrevious(mapset)); } } store.Delete(mapset as Mapset); allMapsets.Remove(mapset); displayedMapsets.Remove(mapset); OnDeleteMapset?.Invoke(mapset); }
/// <summary> /// Triggers the dropdown menu to show for specified mapset. /// </summary> public void TriggerDropdown(IMapset mapset, Vector2 worldPos) { if (mapset == null) { return; } mapsetForDropdown = mapset; DropdownProvider.OpenAt(dropdownContext, worldPos); }
/// <summary> /// Centers the listview on selected mapset. /// </summary> private void CenterOnSelection(IMapset mapset) { // If the selected mapset currently exists in the new list, focus on that area. int mapsetIndex = Model.GetSelectedMapsetIndex(); if (mapsetIndex >= 0) { // Smooth transition to selection position. ScrollTo(CalculateSelectionPos(mapsetIndex)); } }
public void Add(IMapset mapset) { mapsets.Add(mapset); if (implicitSort) { Sort(sortMethod); } else { InvokeChange(); } }
/// <summary> /// Sets current mapset state. /// </summary> private void SetCurMapset(IMapset mapset, bool onlyIfDifferent) { var previousMapset = bindableMapset.Value; if (onlyIfDifferent && previousMapset == mapset) { return; } bindableMapset.SetWithoutTrigger(mapset); this.MapsetConfig.Value = mapsetConfiguration?.GetConfig(mapset); bindableMapset.TriggerWithPrevious(previousMapset); }
/// <summary> /// Sets the mapset which the item should represent. /// </summary> public void SetMapset(IMapset mapset) { this.Mapset = mapset; SetLabelText(); SetMapTags(); // Start loading mapset backgrond. LoadBackground(); // Set mapset focus. SetFocus(Model.SelectedMapset.Value != null && this.Mapset == Model.SelectedMapset.Value); }
public void AddOrReplace(IMapset mapset) { // Try replace first for (int i = 0; i < mapsets.Count; i++) { if (mapsets[i].Id == mapset.Id) { mapsets[i] = mapset; return; } } // Else, add Add(mapset); }
public void Focus(IMapset mapset) { if (mapset == selectedMapset.Value) { return; } for (int i = 0; i < playlist.Count; i++) { if (playlist[i] == mapset) { index = i; selectedMapset.Value = playlist[i]; break; } } }
public IMapset GetNext(IMapset mapset) { if (mapsets.Count == 0) { return(null); } if (mapset == null) { return(null); } var index = mapsets.IndexOf(mapset); if (index < 0) { return(mapsets[0]); } return(mapsets[index >= mapsets.Count - 1 ? 0 : index + 1]); }
public Task <IMapset> Load(Guid id, TaskListener <IMapset> listener = null) { return(Task.Run(() => { IMapset mapset = store.Load(id); UnityThread.Dispatch(() => { // If already loaded within all mapsets, replace it. allMapsets.AddOrReplace(mapset); // Search again. Search(lastSearch); // Finished. listener?.SetFinished(mapset); return null; }); return mapset; })); }
public IMapset GetPrevious(IMapset mapset) { if (mapsets.Count == 0) { return(null); } if (mapset == null) { return(null); } var index = mapsets.IndexOf(mapset); if (index < 0) { return(mapsets[0]); } return(mapsets[index <= 0 ? mapsets.Count - 1 : index - 1]); }
public void SelectMapset(IMapset mapset, IPlayableMap map = null) { if (mapset == null) { UnloadMusic(); UnloadBackground(); return; } // Apply default map. if (map == null) { // Make sure the maps are sorted for the current game mode. mapset.SortMapsByMode(currentMode); map = mapset.Maps[0].GetPlayable(currentMode); } // Set mapset only if different. SetCurMapset(mapset, true); // Select the map. SelectMap(map); }
/// <summary> /// Event called on mapset selection change. /// </summary> private void OnMapsetChanged(IMapset mapset) { SetFocus(mapset != null && this.Mapset == mapset); }
/// <summary> /// Selects the specified mapset. /// </summary> public void SelectMapset(IMapset mapset) => MapSelection.SelectMapset(mapset);
/// <summary> /// Event called when the selected mapset has changed. /// </summary> private void OnMapsetChange(IMapset mapset) { DisposeMapsetConfig(); }
/// <summary> /// Sets the map to modify the offset for. /// </summary> public void SetMap(IMapset mapset, IPlayableMap map = null) { // Simply select the map and let the bindables retrieve the map/mapset configurations. MapSelection.SelectMapset(mapset, map); }
public void Remove(IMapset mapset) { mapsets.Remove(mapset); InvokeChange(); }
/// <summary> /// Event called on current mapset change. /// </summary> private void OnMapsetChange(IMapset mapset) { SetMapList(); RequestMapsetDescription(); }
/// <summary> /// Event called when the selected mapset have been changed. /// </summary> private void OnMapsetChange(IMapset mapset) { CenterOnSelection(mapset); }
public MapsetConfig GetConfig(IMapset mapset) => mapset == null ? null : GetConfig(mapset.HashCode);