private void ChangeMapTypeFilter(EFilter_MapType newMapType) { if (mapType == newMapType) { return; } switch (mapType) { case EFilter_MapType.any: TypeAnyLabel.TextColor = untappedTextColor; break; case EFilter_MapType.linear: TypeLinearLabel.TextColor = untappedTextColor; break; case EFilter_MapType.staged: TypeStagedLabel.TextColor = untappedTextColor; break; default: break; } switch (newMapType) { case EFilter_MapType.any: TypeAnyLabel.TextColor = tappedTextColor; break; case EFilter_MapType.linear: TypeLinearLabel.TextColor = tappedTextColor; break; case EFilter_MapType.staged: TypeStagedLabel.TextColor = tappedTextColor; break; } resetType = (newMapType != EFilter_MapType.any); checkReset(); BaseViewModel.vibrate(allowVibrate); mapType = newMapType; }
public static string CPRZoneFormatter(string z, EFilter_MapType mapType) { string zoneString = ""; int zone = int.Parse(z); if (zone == 1) { return("Start"); } else if (zone == 0) { return("End"); } if (mapType == EFilter_MapType.staged) { zoneString = "Stage " + zone; } else if (mapType == EFilter_MapType.linear) { zoneString = "Checkpoint " + (zone - 1); } return(zoneString); }
// Loading KSF map list -------------------------------------------------------------------------------------------------------------------- #region ksf private async Task <List <string> > LoadMaps(EFilter_Game game, EFilter_Sort sort, int minTier, int maxTier, EFilter_MapType mapType) { // minTier options: 1-8 // maxTier options: 1-8 maps_list = new List <string>(); try { if (game != currentGame || sort != currentSort) { DetailedMapsRootObject dmro = await mapsViewModel.GetDetailedMapsList(game, sort); if (dmro == null) { Console.WriteLine("KSF Server Request returned NULL (MapsPage)"); MapsCollectionEmptyViewLabel.Text = "Could not reach KSF servers :("; return(maps_list); } MapsCollectionEmptyViewLabel.Text = "No maps matched your filter"; MapsTab.Title = "Maps [" + EFilter_ToString.toString2(game) + "]"; detailed_mapData = new List <DetailedMapDatum>(dmro.data); currentGame = game; currentSort = sort; } currentMinTier = minTier; currentMaxTier = maxTier; currentMapType = mapType; foreach (DetailedMapDatum datum in detailed_mapData) { int tier = int.Parse(datum.tier); int type = int.Parse(datum.maptype); if (mapType != EFilter_MapType.any && type != (int)mapType) { continue; } else if (tier < minTier) { continue; } else if (tier > maxTier) { continue; } maps_list.Add(datum.name); } } catch (FormatException) { Console.WriteLine("Problem parsing KSFDetailedMapDatum.data field (MapsPage)"); } return(maps_list); }
// UI -------------------------------------------------------------------------------------------------------------------------------------- #region UI private async Task LoadMapInfo() { string mapName = map; if (mapName.Length > 18) { mapName = mapName.Substring(0, 18) + "..."; } MapsMap.Title = mapName + " [" + EFilter_ToString.toString2(game) + "]"; // running query and assigning to map information objects var mapInfoDatum = await mapsViewModel.GetMapInfo(game, map); mapInfoData = mapInfoDatum?.data; if (mapInfoData is null) { return; } var mapPointsDatum = await mapsViewModel.GetMapPoints(game, map); pointsData = mapPointsDatum?.data; if (pointsData is null) { return; } mapSettings = mapInfoData.MapSettings; mappers = mapInfoData.Mappers; mapType = (EFilter_MapType)int.Parse(mapSettings.maptype); // filling in UI and setting zone options LayoutGeneralMapInfo(); LayoutMappers(); LayoutStats(); stageCount = int.Parse(mapSettings.cp_count); bonusCount = int.Parse(mapSettings.b_count); if ((int)mapType == 1) { stageCount = 0; } else { for (int i = 1; i <= stageCount; i++) { zonePickerList.Add("S" + i); } } for (int i = 1; i <= bonusCount; i++) { zonePickerList.Add("B" + i); } LayoutPoints(); }
public static string toString(EFilter_MapType type) { string typeString = ""; switch (type) { case EFilter_MapType.linear: typeString = "Linear"; break; case EFilter_MapType.staged: typeString = "Staged"; break; default: break; } return(typeString); }
// UI ----------------------------------------------------------------------------------------------- #region UI private async Task ChangePRDetails() { var cprDatum = await mapsViewModel.GetMapCPR(game, mode, map, EFilter_PlayerType.steamid, playerSteamID); CPRDetails = cprDatum?.data.CPR; if (CPRDetails is null || CPRDetails.Count < 1) { return; } mapType = (EFilter_MapType)int.Parse(cprDatum.data.mapType); WRPlayer.Text = "PR vs " + String_Formatter.toEmoji_Country(cprDatum.data.basicInfoWR.country) + " " + cprDatum.data.basicInfoWR.name; LayoutPRDetails(); }
public MapsFilterPage(Action <EFilter_Game, EFilter_Sort, int, int, EFilter_MapType> FilterApplier, EFilter_Game currentGame, EFilter_Sort currentSort, int currentMinTier, int currentMaxTier, EFilter_MapType currentMapType, EFilter_Game defaultGame) { this.FilterApplier = FilterApplier; this.defaultGame = defaultGame; InitializeComponent(); ChangeGameFilter(currentGame); ChangeSortFilter(currentSort); ChangeMapTypeFilter(currentMapType); allowVibrate = true; minTier = currentMinTier; maxTier = currentMaxTier; MaxTierSlider.Value = maxTier; MinTierSlider.Value = minTier; }
// Dispaying Changes ------------------------------------------------------------------------------- private void LayoutRecords() { if (list_index != 1) { CompletionStack.Children.Add(new BoxView { Style = App.Current.Resources["SeparatorStyle"] as Style }); } int i = 0; int length = recordsData.Count; foreach (PlayerCompletionRecord datum in recordsData) { if (datum.completedZones is null) { datum.completedZones = "0"; } CompletionStack.Children.Add(new Label { Text = datum.mapName + " (" + datum.completedZones + "/" + datum.totalZones + ")", Style = App.Current.Resources["RRLabelStyle"] as Style }); EFilter_MapType mapType = (EFilter_MapType)int.Parse(datum.mapType); string cptype = (mapType == EFilter_MapType.linear) ? "CPs" : "Stages"; string rrinfo = datum.cp_count + " " + cptype + ", " + datum.b_count + " Bonus"; if (datum.b_count != "1") { rrinfo += "es"; } CompletionStack.Children.Add(new Label { Text = "Tier " + datum.tier + " " + EFilter_ToString.toString(mapType) + " - " + rrinfo, Style = App.Current.Resources["TimeLabelStyle"] as Style }); if (++i != length) { CompletionStack.Children.Add(new BoxView { Style = App.Current.Resources["SeparatorStyle"] as Style }); } } moreRecords = (i == LIST_LIMIT); MoreFrame.IsVisible = moreRecords; if (i == 0) // no (in)complete maps { string text = "None ! " + ((completionType == EFilter_PlayerCompletionType.complete) ? ":(" : ":)"); CompletionStack.Children.Add(new Label { Text = text, Style = App.Current.Resources["LeftColStyle"] as Style, HorizontalOptions = LayoutOptions.Center }); } }
internal async void ApplyFilters(EFilter_Game game, EFilter_Sort sort, int minTier, int maxTier, EFilter_MapType mapType) { if (BaseViewModel.hasConnection()) { MapsSearchBar.Text = ""; LoadingAnimation.IsRunning = true; ChangeDisplayList(await LoadMaps(game, sort, minTier, maxTier, mapType)); LoadingAnimation.IsRunning = false; MapsCollectionView.ScrollTo(0); } else { await DisplayAlert("Could not connect to KSF servers :(", "Please connect to the Internet.", "OK"); } }