internal async Task <string> GetTopCountry(EFilter_Game game, EFilter_Mode mode) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); if (gameString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/top/countries/1,1/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { TopCountriesRootObject tcro = JsonConvert.DeserializeObject <TopCountriesRootObject>(response.Content); return(tcro.data[0]?.country); } else { return(null); } }
// UI ----------------------------------------------------------------------------------------------- #region UI private async Task ChangePR(EFilter_Mode newMode, EFilter_PlayerType newPlayerType, string newPlayerValue) { if (currentMode == newMode && newPlayerType == playerType && newPlayerValue == playerValue) { return; } var prInfoDatum = await mapsViewModel.GetMapPRInfo(game, newMode, map, newPlayerType, newPlayerValue); prInfoData = prInfoDatum?.data; if (prInfoData is null || prInfoData.basicInfo is null) { hidePR(); await DisplayAlert("Could not find player profile!", "Invalid SteamID or rank.", "OK"); return; } currentMode = newMode; playerType = newPlayerType; playerValue = newPlayerValue; playerSteamID = prInfoData.basicInfo.steamID; Title = mapsMapTitle + " " + EFilter_ToString.toString(currentMode) + "]"; PRTitleLabel.Text = String_Formatter.toEmoji_Country(prInfoData.basicInfo.country) + " " + prInfoData.basicInfo.name; if (prInfoData.time is null || prInfoData.time == "0") // no main completion { hidePR(); return; } displayPR(); playerRank = prInfoData.rank.ToString(); LayoutPRInfo(); }
public PlayerFilterPage(Action <EFilter_Game, EFilter_Mode, EFilter_PlayerType, string> FilterApplier, EFilter_Game currentGame, EFilter_Mode currentMode, EFilter_PlayerType currentPlayerType, string currentPlayerSteamId, string currentPlayerRank, EFilter_Game defaultGame, EFilter_Mode defaultMode, string meSteamId) { this.FilterApplier = FilterApplier; this.defaultGame = defaultGame; this.defaultMode = defaultMode; this.meSteamId = meSteamId; InitializeComponent(); ChangeGameFilter(currentGame); ChangeModeFilter(currentMode); ChangePlayerFilter(currentPlayerType); PlayerMeIDLabel.Text = " " + meSteamId; playerRank = currentPlayerRank; RankEntry.Text = playerRank; playerSteamId = currentPlayerSteamId; SteamIdEntry.Text = playerSteamId; allowVibrate = true; }
internal async Task <RR10RootObject> GetRecentRecords10(EFilter_Game game, EFilter_Mode mode) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); if (gameString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/recentrecords/server/top10/1,10/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <RR10RootObject>(response.Content)); } else { return(null); } }
internal async Task <MapPRInfoRootObject> GetMapPRInfo(EFilter_Game game, EFilter_Mode mode, string map, EFilter_PlayerType playerType, string playerValue) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); string playerTypeString = EFilter_ToString.toString(playerType); if (gameString == "" || map == "" || playerValue == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/map/" + map + "/zone/0/" + playerTypeString + "/" + playerValue + "/recordinfo/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <MapPRInfoRootObject>(response.Content)); } else { return(null); } }
internal static EFilter_Mode propertiesDict_getMode() { EFilter_Mode mode = EFilter_Mode.fw; if (App.Current.Properties.ContainsKey("mode")) { string modeString = App.Current.Properties["mode"] as string; switch (modeString) { case "FW": mode = EFilter_Mode.fw; break; case "HSW": mode = EFilter_Mode.hsw; break; case "SW": mode = EFilter_Mode.sw; break; case "BW": mode = EFilter_Mode.bw; break; default: goto case "FW"; } } else { App.Current.Properties.Add("mode", EFilter_ToString.toString(mode)); App.Current.SavePropertiesAsync(); } return(mode); }
internal async Task <PlayerWRsRootObject> GetPlayerWRs(EFilter_Game game, EFilter_Mode mode, EFilter_PlayerWRsType wrType, EFilter_PlayerType playerType, string playerValue, int startIndex) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); string wrString = EFilter_ToString.toString(wrType); string playerTypeString = EFilter_ToString.toString(playerType); if (gameString == "" || playerValue == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/" + playerTypeString + "/" + playerValue + "/" + wrString + "/" + startIndex + ",10/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <PlayerWRsRootObject>(response.Content)); } else { return(null); } }
internal async Task <CountryTopRootObject> GetCountryTop(EFilter_Game game, EFilter_Mode mode, string country, int start_index) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); if (gameString == "" || country == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/top/country/" + country + "/" + start_index + ",25/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <CountryTopRootObject>(response.Content)); } else { return(null); } }
public RecordsTopCountriesPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; InitializeComponent(); Title = title; }
public RecordsCountryTopPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; InitializeComponent(); Title = title; CountryPicker.ItemsSource = EFilter_ToString.ctopCountries; }
public RecordsOldestPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; this.oldestType = EFilter_ORType.map; InitializeComponent(); Title = title; }
public RecordsPage() { recordsViewModel = new RecordsViewModel(); InitializeComponent(); game = BaseViewModel.propertiesDict_getGame(); defaultGame = game; mode = BaseViewModel.propertiesDict_getMode(); defaultMode = mode; recentRecordsType = EFilter_RRType.map; }
public PlayerRecentRecordsPage(string title, PlayerViewModel playerViewModel, EFilter_Game game, EFilter_Mode mode, EFilter_PlayerType playerType, string playerValue) { this.playerViewModel = playerViewModel; this.game = game; this.mode = mode; this.playerType = playerType; this.playerValue = playerValue; InitializeComponent(); Title = title; }
public MapsMapCPRPage(string title, MapsViewModel mapsViewModel, EFilter_Game game, EFilter_Mode mode, string map, string playerSteamID) { this.mapsViewModel = mapsViewModel; this.game = game; this.mode = mode; this.map = map; this.playerSteamID = playerSteamID; InitializeComponent(); Title = title; }
public RecordsMostPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; mostType = EFilter_MostType.wr; mostTypeString = "Current WRs"; InitializeComponent(); Title = title; MostTypePicker.ItemsSource = EFilter_ToString.mosttype_arr; }
public MapsMapPRDetailsPage(string title, MapsViewModel mapsViewModel, EFilter_Game game, EFilter_Mode mode, EFilter_Mode defaultMode, string map, string playerSteamID) { mapsMapTitle = title; this.mapsViewModel = mapsViewModel; this.game = game; this.mode = (mode == EFilter_Mode.none)? defaultMode : mode; this.map = map; this.playerSteamID = playerSteamID; InitializeComponent(); Title = title; }
private async void StyleOptionLabel_Tapped(object sender, EventArgs e) { List <string> modes = new List <string>(); string currentModeString = EFilter_ToString.toString(currentMode); foreach (string mode in EFilter_ToString.modes_arr) { if (mode != currentModeString) { modes.Add(mode); } } string newStyle = await DisplayActionSheet("Choose a different style", "Cancel", null, modes.ToArray()); EFilter_Mode newCurrentMode = EFilter_Mode.fw; switch (newStyle) { case "Cancel": return; case "HSW": newCurrentMode = EFilter_Mode.hsw; break; case "SW": newCurrentMode = EFilter_Mode.sw; break; case "BW": newCurrentMode = EFilter_Mode.bw; break; } LoadingAnimation.IsRunning = true; var newTopDatum = await mapsViewModel.GetMapTop(game, map, newCurrentMode, currentZone, 1); List <TopDatum> newTopData = newTopDatum?.data; if (newTopData is null) { LoadingAnimation.IsRunning = false; await DisplayAlert("No " + newStyle + " " + currentZoneString + " completions.", "Be the first!", "OK"); return; } topData = newTopData; currentMode = newCurrentMode; list_index = 1; ClearTopGrid(); LayoutTop(newStyle, currentZoneString); LoadingAnimation.IsRunning = false; }
public PlayerMapsCompletionPage(string title, PlayerViewModel playerViewModel, EFilter_Game game, EFilter_Mode mode, EFilter_PlayerCompletionType completionType, EFilter_PlayerType playerType, string playerValue) { this.playerViewModel = playerViewModel; this.game = game; this.mode = mode; this.playerType = playerType; this.playerValue = playerValue; this.completionType = completionType; InitializeComponent(); Title = title; HeaderLabel.Text = EFilter_ToString.toString2(completionType); }
public RecordsFilterPage(Action <EFilter_Game, EFilter_Mode> FilterApplier, EFilter_Game currentGame, EFilter_Mode currentMode, EFilter_Game defaultGame, EFilter_Mode defaultMode) { this.FilterApplier = FilterApplier; this.defaultGame = defaultGame; this.defaultMode = defaultMode; InitializeComponent(); ChangeGameFilter(currentGame); ChangeModeFilter(currentMode); allowVibrate = true; }
internal async void ApplyFilters(EFilter_Game newGame, EFilter_Mode newMode, EFilter_PlayerType newPlayerType, string newPlayerValue) { if (BaseViewModel.hasConnection()) { LoadingAnimation.IsRunning = true; await ChangePlayerInfo(newGame, newMode, newPlayerType, newPlayerValue); LoadingAnimation.IsRunning = false; } else { await DisplayNoConnectionAlert(); } await PlayerPageScrollView.ScrollToAsync(0, 0, true); }
public SettingsPage() { InitializeComponent(); EFilter_Game currentGame = BaseViewModel.propertiesDict_getGame(); EFilter_Mode currentMode = BaseViewModel.propertiesDict_getMode(); playerSteamID = BaseViewModel.propertiesDict_getSteamID(); ChangeGameFilter(currentGame); ChangeModeFilter(currentMode); SteamIdEntry.Text = playerSteamID; allowVibrate = true; }
public PlayerOldestRecordsPage(string title, PlayerViewModel playerViewModel, EFilter_Game game, EFilter_Mode mode, EFilter_PlayerType playerType, string playerValue, EFilter_PlayerWRsType wrsType, bool hasTop) { this.playerViewModel = playerViewModel; this.game = game; this.mode = mode; this.playerType = playerType; this.playerValue = playerValue; this.wrsType = wrsType; this.hasTop = hasTop; oldRecordsOptionStrings = new List <string>(EFilter_ToString.ortype_arr); InitializeComponent(); Title = title; }
public static string toString(EFilter_Mode mode) { string modeString = ""; switch (mode) { case EFilter_Mode.fw: modeString = modes_arr[0]; break; case EFilter_Mode.hsw: modeString = modes_arr[1]; break; case EFilter_Mode.sw: modeString = modes_arr[2]; break; case EFilter_Mode.bw: modeString = modes_arr[3]; break; default: break; } return(modeString); }
public MapsMapTopPage(string title, MapsViewModel mapsViewModel, EFilter_Game game, string map, int stageCount, int bonusCount, List <string> zonePickerList) { this.mapsViewModel = mapsViewModel; this.game = game; this.map = map; currentMode = BaseViewModel.propertiesDict_getMode(); this.stageCount = stageCount; this.bonusCount = bonusCount; this.zonePickerList = zonePickerList; currentZone = 0; currentZoneString = "Main"; InitializeComponent(); Title = title; ZonePicker.ItemsSource = zonePickerList; }
// UI ----------------------------------------------------------------------------------------------- #region UI private async Task ChangePlayerInfo(EFilter_Game newGame, EFilter_Mode newMode, EFilter_PlayerType newPlayerType, string newPlayerValue) { if (newGame == game && newMode == mode && newPlayerValue == playerValue) { return; } var playerInfoDatum = await playerViewModel.GetPlayerInfo(newGame, newMode, newPlayerType, newPlayerValue); playerInfoData = playerInfoDatum?.data; if (playerInfoData is null || playerInfoData.basicInfo is null) { await DisplayAlert("Could not find player profile!", "Invalid SteamID or rank.", "OK"); return; } playerType = newPlayerType; playerValue = newPlayerValue; game = newGame; mode = newMode; playerSteamId = playerInfoData.basicInfo.steamID; playerRank = playerInfoData.SurfRank; string playerName = playerInfoData.basicInfo.name; if (playerName.Length > 18) { playerName = playerName.Substring(0, 13) + "..."; } Title = playerName + " [" + EFilter_ToString.toString2(game) + ", " + EFilter_ToString.toString(mode) + "]"; var PlayerSteamDatum = await playerViewModel.GetPlayerSteamProfile(playerSteamId); playerSteamProfile = PlayerSteamDatum?.response.players[0]; wrsType = EFilter_PlayerWRsType.none; LayoutPlayerInfo(); LayoutPlayerProfile(); }
private void ChangeModeFilter(EFilter_Mode newMode) { if (mode == newMode) { return; } switch (mode) { case EFilter_Mode.fw: ModeFWLabel.TextColor = untappedTextColor; break; case EFilter_Mode.hsw: ModeHSWLabel.TextColor = untappedTextColor; break; case EFilter_Mode.sw: ModeSWLabel.TextColor = untappedTextColor; break; case EFilter_Mode.bw: ModeBWLabel.TextColor = untappedTextColor; break; default: break; } switch (newMode) { case EFilter_Mode.fw: ModeFWLabel.TextColor = tappedTextColor; break; case EFilter_Mode.hsw: ModeHSWLabel.TextColor = tappedTextColor; break; case EFilter_Mode.sw: ModeSWLabel.TextColor = tappedTextColor; break; case EFilter_Mode.bw: ModeBWLabel.TextColor = tappedTextColor; break; default: break; } resetMode = (newMode != defaultMode); checkReset(); BaseViewModel.vibrate(allowVibrate); mode = newMode; }
internal async void ApplyFilters(EFilter_Game newGame, EFilter_Mode newMode) { if (BaseViewModel.hasConnection()) { if (newGame == game && newMode == mode) { return; } game = newGame; mode = newMode; LoadingAnimation.IsRunning = true; await ChangeRecentRecords(game, recentRecordsType, mode); LoadingAnimation.IsRunning = false; } else { await DisplayNoConnectionAlert(); } await RecordsPageScrollView.ScrollToAsync(0, 0, true); }
// UI ----------------------------------------------------------------------------------------------- #region UI private async Task ChangeMostByType(EFilter_Game game, EFilter_MostType type, EFilter_Mode mode, bool clearGrid) { string rightColString = "Player"; string leftColString = ""; List <string> players = new List <string>(); List <string> values = new List <string>(); switch (type) { case EFilter_MostType.pc: { var mostPCDatum = await recordsViewModel.GetMostPC(game, mode, list_index); mostPCData = mostPCDatum?.data; if (mostPCData is null || mostPCData.Count < 1) { MoreFrame.IsVisible = false; return; } leftColString = "Total"; foreach (MostPCDatum datum in mostPCData) { players.Add(String_Formatter.toEmoji_Country(datum.country) + " " + datum.name); values.Add((double.Parse(datum.percentCompletion) * 100).ToString("0.00") + "%"); } break; } case EFilter_MostType.wr: case EFilter_MostType.wrcp: case EFilter_MostType.wrb: case EFilter_MostType.mostwr: case EFilter_MostType.mostwrcp: case EFilter_MostType.mostwrb: { var mostCountDatum = await recordsViewModel.GetMostCount(game, type, mode, list_index); mostCountData = mostCountDatum?.data; if (mostCountData is null || mostCountData.Count < 1) { MoreFrame.IsVisible = false; return; } leftColString = "Total"; foreach (MostCountDatum datum in mostCountData) { players.Add(String_Formatter.toEmoji_Country(datum.country) + " " + datum.name); values.Add(String_Formatter.toString_Int(datum.total)); } break; } case EFilter_MostType.top10: { var mostTopDatum = await recordsViewModel.GetMostTop(game, mode, list_index); mostTopData = mostTopDatum?.data; if (mostTopData is null || mostTopData.Count < 1) { MoreFrame.IsVisible = false; return; } leftColString = "Points"; foreach (MostTopDatum datum in mostTopData) { players.Add(String_Formatter.toEmoji_Country(datum.country) + " " + datum.name); values.Add(String_Formatter.toString_Points(datum.top10Points)); } break; } case EFilter_MostType.group: { var mostGroupDatum = await recordsViewModel.GetMostGroup(game, mode, list_index); mostGroupData = mostGroupDatum?.data; if (mostGroupData is null || mostGroupData.Count < 1) { MoreFrame.IsVisible = false; return; } leftColString = "Points"; foreach (MostGroupDatum datum in mostGroupData) { players.Add(String_Formatter.toEmoji_Country(datum.country) + " " + datum.name); values.Add(String_Formatter.toString_Points(datum.groupPoints)); } break; } case EFilter_MostType.mostcontestedwr: { var mostContWrDatum = await recordsViewModel.GetMostContWr(game, mode, list_index); mostContWrData = mostContWrDatum?.data; if (mostContWrData is null || mostContWrData.Count < 1) { MoreFrame.IsVisible = false; return; } rightColString = "Map"; leftColString = "Beaten"; foreach (MostContWrDatum datum in mostContWrData) { players.Add(datum.mapName); values.Add(String_Formatter.toString_Int(datum.total)); } break; } case EFilter_MostType.mostcontestedwrcp: case EFilter_MostType.mostcontestedwrb: { var mostContZoneDatum = await recordsViewModel.GetMostContZone(game, type, mode, list_index); mostContZoneData = mostContZoneDatum?.data; if (mostContZoneData is null || mostContZoneData.Count < 1) { MoreFrame.IsVisible = false; return; } rightColString = "Zone"; leftColString = "Beaten"; foreach (MostContZoneDatum datum in mostContZoneData) { string zoneString = EFilter_ToString.zoneFormatter(datum.zoneID, false, false); players.Add(datum.mapName + " " + zoneString); values.Add(String_Formatter.toString_Int(datum.total)); } break; } case EFilter_MostType.playtimeday: case EFilter_MostType.playtimeweek: case EFilter_MostType.playtimemonth: { var mostTimeDatum = await recordsViewModel.GetMostTime(game, type, mode, list_index); mostTimeData = mostTimeDatum?.data; if (mostTimeData is null || mostTimeData.Count < 1) { return; } rightColString = "Map"; leftColString = "Time"; foreach (MostTimeDatum datum in mostTimeData) { players.Add(datum.mapName); values.Add(String_Formatter.toString_PlayTime(datum.totalplaytime.ToString(), true)); } break; } default: return; } MostTypeOptionLabel.Text = "Type: " + EFilter_ToString.toString2(type); if (clearGrid) { ClearMostByTypeGrid(rightColString, leftColString); } LayoutMostByType(type, players, values); }
internal async Task <OldestRecordsRootObject> GetOldestRecords(EFilter_Game game, EFilter_ORType type, EFilter_Mode mode, int start_index) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string typeString = EFilter_ToString.toString(type); string modeString = ((int)mode).ToString(); if (gameString == "" || typeString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/oldestrecords/server/" + typeString + "/" + start_index + ",10/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <OldestRecordsRootObject>(response.Content)); } else { return(null); } }
// UI --------------------------------------------------------------------------------------------------------- #region UI private async Task ChangeRecentRecords(EFilter_Game game, EFilter_RRType type, EFilter_Mode mode) { if (type == EFilter_RRType.top) { var recentRecords10Datum = await recordsViewModel.GetRecentRecords10(game, mode); recentRecords10Data = recentRecords10Datum?.data; if (recentRecords10Data is null) { return; } LayoutRecentRecords10(); } else { var recentRecordsDatum = await recordsViewModel.GetRecentRecords(game, type, mode); recentRecordsData = recentRecordsDatum?.data; if (recentRecordsData is null) { return; } LayoutRecentRecords(EFilter_ToString.toString2(type)); } lastRefresh = DateTime.Now; }