public override SearchErrorInfo GetStatus(SearchId searchId, out SearchStatus searchStatus) { MailboxSearchServer.Tracer.TraceFunction <string>((long)this.GetHashCode(), "MailboxSearchServer.GetStatus {0}", searchId.SearchName); SearchErrorInfo errorInfo = null; searchStatus = null; SearchStatus theSearchStatus = null; SearchUtils.ExWatsonWrappedCall(delegate() { MailboxSearchWorkItem mailboxSearchWorkItem = null; if (!this.searchWorkItemMap.TryGetValue(searchId, out mailboxSearchWorkItem)) { MailboxSearchServer.Tracer.TraceWarning <string>((long)this.GetHashCode(), "The search {0} is not started", searchId.SearchName); errorInfo = new SearchErrorInfo(262658, Strings.SearchNotStarted); return; } try { theSearchStatus = mailboxSearchWorkItem.GetStatus(); } catch (ExportException ex) { MailboxSearchServer.Tracer.TraceError <ExportException>((long)this.GetHashCode(), "MailboxSearchServer.GetStatus error {0}", ex); errorInfo = new SearchErrorInfo(-2147220991, ex); } }); searchStatus = theSearchStatus; if (errorInfo != null && errorInfo.Failed) { MailboxSearchServer.LogErrorInfo("Error occured when trying to get the status of the search workitem", searchId, errorInfo); } return(errorInfo); }
public async Task SaveSearchResult( int sourceId, Guid fileId, SearchStatus resultStatus, int?fileIdFromSource, string errorText) { ArgumentValidator.IsEnumDefined(() => resultStatus); ArgumentValidator.Requires(() => fileId != default, nameof(fileId)); var parsingStatus = await _parsingStatusRepository.Get(fileId, (MetadataSource)sourceId); switch (resultStatus) { case SearchStatus.NotFound: parsingStatus.SetSearchNotFound(); break; case SearchStatus.Success: ArgumentValidator.NotNull(fileIdFromSource, nameof(fileIdFromSource)); parsingStatus.SetSearchFound(fileIdFromSource.Value); break; case SearchStatus.Error: parsingStatus.SetSearchFailed(errorText); break; default: throw new ArgumentOutOfRangeException(nameof(resultStatus), resultStatus, null); } }
public bool NextIteration() { if (status == SearchStatus.Complete) { return(true); } List <uint> nextNodes = graph.NextNodes(currentNode); // Select the best next node. bool wasFound = false; for (int i = 0; i < nextNodes.Count; i++) { float res = eval(nextNodes[i]); if (res > currentResult) { currentResult = res; currentNode = nextNodes[i]; wasFound = true; } } // Check if no better found. if (!wasFound) { status = SearchStatus.Complete; return(true); } backtrace.Add(currentNode); return(false); }
private void Game_OnSearchProgress(SearchStatus status) { label1.Text = "best: " + status.BestMoveSoFar.BestMove.ToString() + " score: " + status.BestMoveSoFar.Score + " nps: " + status.NodesPerSecond.ToString("0") + " pv: " + status.BestMoveSoFar.PrimaryVariation; }
public bool NextIteration() { if (status == SearchStatus.Complete) { return(true); } int count = (int)graph.Count; int k = currentIndex; for (int i = 0; i < count; i++) { for (int j = 0; j < count; j++) { path[i, j] = MathHelper.Min(path[i, j], path[i, k] + path[k, j]); } } // We may need to finish. if (++currentIndex >= (int)graph.Count) { status = SearchStatus.Complete; } return(false); }
private void LoadArticleNumberSearchInformation() { if (SearchStatus == SearchStatus.NoResult) { _isArticleNumberSearch = false; _articleNumberSearchStatus = SearchStatus.NoResult; return; } switch ((string)JsonData.searchResult.resultArticleNumberStatus) { case "nothingFound": _isArticleNumberSearch = true; _articleNumberSearchStatus = SearchStatus.EmptyResult; break; case "resultsFound": _isArticleNumberSearch = true; _articleNumberSearchStatus = SearchStatus.ResultsFound; break; case "noArticleNumberSearch": default: _isArticleNumberSearch = false; _articleNumberSearchStatus = SearchStatus.NoResult; break; } }
private async Task PrivateSearchCallback() { SearchStatus = SearchStatus.Searching; await SearchCallback(); SearchStatus = SearchStatus.Idle; }
public void EndSearch(SearchStatus status, bool showExitRoomView) { var timerView = FindObjectOfType <SearchTimerView>(); timerView.isBreaked = true; int searchTime = 0; if (timerView) { searchTime = Mathf.RoundToInt(timerView.searchTime); ravenhillGameModeService.searchSession.AddPoints(timerView.SessionPoints); } else { searchTime = ravenhillGameModeService.searchSession.roomInfo.currentRoomSetting.searchTime; } engine.Cast <RavenhillEngine>().EndSearchSession(status, searchTime); viewService.RemoveView(RavenhillViewType.pause_timer_view); if (status == SearchStatus.success || showExitRoomView) { StartCoroutine(CorShowExitRoomView()); } else { Exit(); } }
private static void logOnSearchError(SearchStatus searchStatus) { Log.Info(TAG, "Error Code:" + searchStatus.ErrorCode + "Error Message: " + searchStatus.ErrorMessage); }
void qsUpdate(SearchStatus status, bool cancellationPending) { if (!cancellationPending) { this.quickSearchControl.UpdateSearchStatus(status); } }
/// <summary> /// Creates a new CouchbaseSearchResponseException. /// </summary> /// <param name="message">Error message.</param> /// <param name="status"><see cref="SearchStatus"/> returned from Couchbase.</param> /// <param name="errors">Errors returned from Couchbase.</param> /// <param name="innerException">Exception included in the response from Couchbase.</param> public CouchbaseSearchResponseException(string message, SearchStatus status, IList <string> errors, Exception innerException) : base(message, innerException) { Status = status; Errors = new ReadOnlyCollection <string>(errors ?? new string[] {}); }
public void UpdateSearches() { if (SearchRequests.Count < 1) { return; } int NoOfCyclesPerRequest = (int)Math.Max(Math.Floor((double)(NumSearchCyclesPerUpdate / Math.Min(SearchRequests.Count, MaxRequestsHandledPerUpdate))), 1d); int requestsHandled = 0; foreach (var searchRequest in SearchRequests) { SearchStatus status = SearchStatus.NO_STATUS; for (int cycles = 0; cycles < NoOfCyclesPerRequest; cycles++) { status = searchRequest.CycleOnce(); if (status == SearchStatus.TARGET_FOUND || status == SearchStatus.SEARCH_INCOMPLETED) { CompletedRequests.Add(searchRequest); } } if (++requestsHandled > MaxRequestsHandledPerUpdate) { break; } } // Remove all requests that are done. foreach (var completedRequest in CompletedRequests) { SearchRequests.Remove(completedRequest); } CompletedRequests.Clear(); }
void RefreshServerList() { // Query in progress if (currentQuery != null) { return; } searchStatus = SearchStatus.Fetching; Action <DownloadDataCompletedEventArgs, bool> onComplete = (i, cancelled) => { currentQuery = null; if (i.Error != null || cancelled) { RefreshServerListInner(null); return; } var data = Encoding.UTF8.GetString(i.Result); var yaml = MiniYaml.FromString(data); var games = yaml.Select(a => new GameServer(a.Value)) .Where(gs => gs.Address != null); Game.RunAfterTick(() => RefreshServerListInner(games)); }; currentQuery = new Download(Game.Settings.Server.MasterServer + "games", _ => { }, onComplete); }
public void EndSession(SearchStatus status, int time, List <InventoryItem> drops) { if (isStarted) { OnEndSession(status, time, drops); } }
public void OnSearchError(SearchStatus searchStatus) { Log.Info(TAG, "Error Code:" + searchStatus.ErrorCode + "Error Message: " + searchStatus.ErrorMessage); }
public CncServerBrowserLogic([ObjectCreator.Param] Widget widget, [ObjectCreator.Param] Action openLobby, [ObjectCreator.Param] Action onExit) { var panel = widget.GetWidget("SERVERBROWSER_PANEL"); var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST"); // Menu buttons var refreshButton = panel.GetWidget<ButtonWidget>("REFRESH_BUTTON"); refreshButton.IsDisabled = () => refreshing; refreshButton.OnClick = () => { searchStatus = SearchStatus.Fetching; sl.RemoveChildren(); currentServer = null; ServerList.Query(games => RefreshServerList(panel, games)); refreshing = true; }; var join = panel.GetWidget<ButtonWidget>("JOIN_BUTTON"); join.IsDisabled = () => currentServer == null || !ServerBrowserLogic.CanJoin(currentServer); join.OnClick = () => { if (currentServer == null) return; string host = currentServer.Address.Split(':')[0]; int port = int.Parse(currentServer.Address.Split(':')[1]); Widget.CloseWindow(); CncConnectingLogic.Connect(host, port, openLobby, onExit); }; panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; // Server list serverTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE"); // Display the progress label over the server list // The text is only visible when the list is empty var progressText = panel.GetWidget<LabelWidget>("PROGRESS_LABEL"); progressText.IsVisible = () => searchStatus != SearchStatus.Hidden; progressText.GetText = ProgressLabelText; // Map preview var preview = panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW"); preview.Map = () => CurrentMap(); preview.IsVisible = () => CurrentMap() != null; // Server info var infoPanel = panel.GetWidget("SERVER_INFO"); infoPanel.IsVisible = () => currentServer != null; infoPanel.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address; infoPanel.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => ServerBrowserLogic.GenerateModsLabel(currentServer); infoPanel.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown"; infoPanel.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () => GetPlayersLabel(currentServer); refreshing = true; ServerList.Query(games => RefreshServerList(panel, games)); }
/// <summary> /// This method find the next path node to visit, puts that node on the /// closed list and adds any nodes adjacent to the visited node to the /// open list. /// </summary> private void DoSearchStep() { SearchNode newOpenListNode; bool foundNewNode = SelectNodeToVisit(out newOpenListNode); if (foundNewNode) { Point currentPos = newOpenListNode.Position; foreach (Point point in map.OpenMapTiles(currentPos)) { SearchNode mapTile = new SearchNode(point, map.StepDistanceToEnd(point), newOpenListNode.DistanceTraveled + 1); if (!InList(openList, point) && !InList(closedList, point)) { openList.Add(mapTile); paths[point] = newOpenListNode.Position; } } if (currentPos == map.EndTile) { searchStatus = SearchStatus.PathFound; } openList.Remove(newOpenListNode); closedList.Add(newOpenListNode); } else { searchStatus = SearchStatus.NoPath; } }
public void AlterStatus(int id, SearchStatus searchStatus) { this.Sessao .CreateQuery("update Documento set SearchStatus = :searchStatus where Id = :id") .SetParameter("searchStatus", searchStatus) .SetParameter("id", id) .ExecuteUpdate(); }
/// <summary> /// Setup search /// </summary> /// <param name="mazeMap">Map to search</param> public void Initialize(Map mazeMap) { searchStatus = SearchStatus.Stopped; openList = new List <SearchNode>(); closedList = new List <SearchNode>(); paths = new Dictionary <Point, Point>(); map = mazeMap; }
public void ResetSearchData() { SearchStatus = SearchStatus.None; parent = null; gCost = Mathf.Infinity; hCost = Mathf.Infinity; fCost = Mathf.Infinity; }
/// <summary> /// Остановить поиск /// </summary> public void Stop() { if (SearchStatus == SearchStatus.Pause) { Resume(); } SearchStatus = SearchStatus.NotRun; CancellationTokenSource.Cancel(); }
public virtual void Read(PackFileDeserializer des, BinaryReaderEx br) { m_numIterations = br.ReadInt32(); m_goalIndex = br.ReadInt32(); m_pathLength = br.ReadSingle(); m_status = (SearchStatus)br.ReadByte(); m_terminationCause = (TerminationCause)br.ReadByte(); br.ReadUInt16(); }
/// <summary> /// Dont call (only for debug) /// </summary> /// <param name="status"></param> /// <param name="time"></param> /// <param name="drops"></param> internal void OnEndSession(SearchStatus status, int time, List <InventoryItem> drops) { SetSearchStatus(status); SetSearchTime(time); roomDropList.Clear(); roomDropList.AddRange(drops); isStarted = false; RavenhillEvents.OnSearchSessionEnded(this); }
/// <summary> /// Changes the status of the search job, and updates /// the DB to match. /// </summary> /// <param name="newStatus">The new status</param> private void ChangeStatus(SearchStatus newStatus) { using (DbModelContainer db = new DbModelContainer()) { db.SearchJobs.Attach(this); this.Status = newStatus; db.SaveChanges(); } }
public ActionResult Search(SearchViewModel view) { if (ModelState.IsValid) { SearchStatus rslt = qMgr.DiscountLookup(view); if (rslt == SearchStatus.NotFound) { ModelState.AddModelError("EmpId", ApplicationVariable.GetBrandConfig().SearchPage.NoResultFound.Value); } } return(View(view)); }
/// <summary> /// Reset the search /// </summary> public void Reset() { searchStatus = SearchStatus.Stopped; totalSearchSteps = 0; Scale = map.Scale; openList.Clear(); closedList.Clear(); paths.Clear(); openList.Add(new SearchNode(map.StartTile, Map.StepDistance(map.StartTile, map.EndTile) , 0)); }
public SearchCompleteCommand( int sourceId, Guid fileId, SearchStatus resultStatus, string errorText, int?fileIdFromSource) { SourceId = sourceId; ResultStatus = resultStatus; ErrorText = errorText; FileIdFromSource = fileIdFromSource; FileId = fileId; }
/// <summary> /// Default constructor /// </summary> public HttpMap() { Documents = new ThreadSafeList <string>(); Files = new ThreadSafeList <string>(); BackupModifiedFilenames = new ThreadSafeList <string>(); Folders = new ThreadSafeList <string>(); Parametrized = new ThreadSafeList <string>(); SearchingAllLinks = SearchStatus.NotInitialized; SearchingMethods = SearchStatus.NotInitialized; SearchingOpenFolders = SearchStatus.NotInitialized; SearchingTechnology = SearchStatus.NotInitialized; SearchingMutexFuzz = SearchStatus.NotInitialized; }
async private void GetItemTreeAsync(SearchFilterOptions criteria) { logger.Info("GetItemTreeAsync"); await Task.Factory.StartNew(() => { try { logger.Info("GetItemTreeAsync query"); var db = DataRepository.GetDataRepository; var items = db.GetItemTree(resultEntitySelector, criteria, out GenericItemResult item); // update the view, but do so in WPF dispatcher thread //Dispatcher.BeginInvoke((Action)(() => { searchResultViewModel.Items = items; })); logger.Info($"GetItemTreeAsync:returned {items.Count} items."); searchResultViewModel.Items = items; // set selected item if one was returned to be selected if (item == null) { logger.Info("GetItemTreeAsync: No item auto-selected."); } else { logger.Info($"GetItemTreeAsync: Auto-selected {item.ToString()}"); } searchResultViewModel.SelectedItem = item; // updated returned count if (items.Count > 0) { searchResultViewModel.StatusMessage = $"Found {items.First().resultTotal} results."; } else { searchResultViewModel.StatusMessage = "No matches found."; } } catch (Exception e) { logger?.Error(e, $"Failed to load item tree! criteria:{criteria}"); return; } finally { searchStatus = SearchStatus.Complete; } }); logger.Info("GetItemTreeAsync end"); }
public BuscarArchivo() { InitializeComponent(); GenerateHashQuery("INIT"); searchStatus = SearchStatus.NEW; serverListReceivedDelegate = new ClientHandler.ServerListReceivedDelegate(EventServerListReceivedResponse); ClientHandler.GetInstance().ServerListReceivedEvent += serverListReceivedDelegate; searchFilesReceivedDelegate = new ClientHandler.SearchFilesReceivedDelegate(OnSearchFilesResultReceived); ClientHandler.GetInstance().SearchFilesReceivedEvent += searchFilesReceivedDelegate; lvwColumnSorter = new ListViewColumnSorter(); listaArchivos.ListViewItemSorter = lvwColumnSorter; }
public bool NextIteration() { if (status != SearchStatus.Running) { return(true); } // We do next full iteration. for (int i = 0; i < allEdges.Count; i++) { BFEdge edge = allEdges[i]; if (distance[edge.NodeFrom] + edge.Cost < distance[edge.NodeTo]) { distance[edge.NodeTo] = distance[edge.NodeFrom] + edge.Cost; bestPrevious[edge.NodeTo] = edge.NodeFrom; } } // We do next iteration. if (++currentIndex >= (int)graph.Count) { // Make sure we do not have negative cycles. for (int j = 0; j < allEdges.Count; j++) { BFEdge edge = allEdges[j]; if (distance[edge.NodeTo] > distance[edge.NodeFrom] + edge.Cost) { status = SearchStatus.NotFound; break; } } // We have a negative loop. if (status == SearchStatus.NotFound) { return(true); } // We check if solution was found. status = SearchStatus.Complete; if (Result == null) { status = SearchStatus.NotFound; } return(true); } return(false); }
private void changeStatusTo( SearchStatus newStatus) { searchStatus = newStatus; currentTime = 0; if (newStatus == SearchStatus.Searching) { initialRotation = transform.localRotation; photoArea.SetActive(true); float random = Random.value; currentSearchTimeMax = averageSearchTimeRange * random + averageSearchTimeMin; }else if (newStatus == SearchStatus.NotSearching) { photoArea.SetActive(false); }else if (newStatus == SearchStatus.ChaseingPlayer) { focusScript.Activate(true); } if (newStatus != SearchStatus.ChaseingPlayer) { focusScript.Activate(false); } }
public ServerBrowserLogic(Widget widget, Action openLobby, Action onExit) { var panel = widget; var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST"); // Menu buttons var refreshButton = panel.GetWidget<ButtonWidget>("REFRESH_BUTTON"); refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching; refreshButton.OnClick = () => { searchStatus = SearchStatus.Fetching; sl.RemoveChildren(); currentServer = null; ServerList.Query(games => RefreshServerList(panel, games)); }; var join = panel.GetWidget<ButtonWidget>("JOIN_BUTTON"); join.IsDisabled = () => currentServer == null || !currentServer.CanJoin(); join.OnClick = () => { if (currentServer == null) return; var host = currentServer.Address.Split(':')[0]; var port = int.Parse(currentServer.Address.Split(':')[1]); Ui.CloseWindow(); ConnectionLogic.Connect(host, port, openLobby, onExit); }; panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; // Server list serverTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE"); // Display the progress label over the server list // The text is only visible when the list is empty var progressText = panel.GetWidget<LabelWidget>("PROGRESS_LABEL"); progressText.IsVisible = () => searchStatus != SearchStatus.Hidden; progressText.GetText = ProgressLabelText; ServerList.Query(games => RefreshServerList(panel, games)); }
void RefreshServerList() { // Query in progress if (currentQuery != null) return; searchStatus = SearchStatus.Fetching; Action<DownloadDataCompletedEventArgs, bool> onComplete = (i, cancelled) => { currentQuery = null; if (i.Error != null || cancelled) { RefreshServerListInner(null); return; } var data = Encoding.UTF8.GetString(i.Result); var yaml = MiniYaml.FromString(data); var games = yaml.Select(a => FieldLoader.Load<GameServer>(a.Value)) .Where(gs => gs.Address != null); RefreshServerListInner(games); Game.RunAfterTick(() => RefreshServerListInner(games)); }; currentQuery = new Download(Game.Settings.Server.MasterServer + "list.php", _ => {}, onComplete); }
public void NoteSearchFailure() { if (Status == SearchStatus.unsearched) Status = SearchStatus.failure; }
public void RefreshServerList(Widget panel, IEnumerable<GameServer> games) { var sl = panel.Get<ScrollPanelWidget>("SERVER_LIST"); searchStatus = SearchStatus.Fetching; sl.RemoveChildren(); currentServer = null; if (games == null) { searchStatus = SearchStatus.Failed; return; } if (!games.Any()) { searchStatus = SearchStatus.NoGames; return; } searchStatus = SearchStatus.Hidden; currentServer = games.FirstOrDefault(); foreach (var loop in games.OrderByDescending(g => g.CanJoin()).ThenByDescending(g => g.Players)) { var game = loop; var canJoin = game.CanJoin(); var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game, () => Join(game)); var map = Game.modData.MapCache[game.Map]; var preview = item.Get<MapPreviewWidget>("MAP_PREVIEW"); preview.Preview = () => map; var title = item.Get<LabelWidget>("TITLE"); title.GetText = () => game.Name; // TODO: Use game.MapTitle once the server supports it var maptitle = item.Get<LabelWidget>("MAP"); maptitle.GetText = () => map.Title; // TODO: Use game.MaxPlayers once the server supports it var players = item.Get<LabelWidget>("PLAYERS"); players.GetText = () => GetPlayersLabel(game); var state = item.Get<LabelWidget>("STATE"); state.GetText = () => GetStateLabel(game); var ip = item.Get<LabelWidget>("IP"); ip.GetText = () => game.Address; var version = item.Get<LabelWidget>("VERSION"); version.GetText = () => GenerateModLabel(game); version.IsVisible = () => !game.CompatibleVersion(); var location = item.Get<LabelWidget>("LOCATION"); var cachedServerLocation = LobbyUtils.LookupCountry(game.Address.Split(':')[0]); location.GetText = () => cachedServerLocation; location.IsVisible = () => game.CompatibleVersion(); if (!canJoin) { title.GetColor = () => Color.Gray; maptitle.GetColor = () => Color.Gray; players.GetColor = () => Color.Gray; state.GetColor = () => Color.Gray; ip.GetColor = () => Color.Gray; version.GetColor = () => Color.Gray; location.GetColor = () => Color.Gray; } if (!Filtered(game)) sl.AddChild(item); } }
public void RefreshServerListInner(IEnumerable<GameServer> games) { if (games == null) return; List<Widget> rows = new List<Widget>(); foreach (var loop in games.OrderByDescending(g => g.CanJoin()).ThenByDescending(g => g.Players)) { var game = loop; if (game == null) continue; var canJoin = game.CanJoin(); var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game, () => Join(game)); var map = Game.modData.MapCache[game.Map]; var preview = item.GetOrNull<MapPreviewWidget>("MAP_PREVIEW"); if (preview != null) preview.Preview = () => map; var title = item.GetOrNull<LabelWidget>("TITLE"); if (title != null) { title.GetText = () => game.Name; title.GetColor = () => canJoin ? title.TextColor : Color.Gray; } var maptitle = item.GetOrNull<LabelWidget>("MAP"); if (title != null) { maptitle.GetText = () => map.Title; maptitle.GetColor = () => canJoin ? maptitle.TextColor : Color.Gray; } var players = item.GetOrNull<LabelWidget>("PLAYERS"); if (players != null) { players.GetText = () => "{0} / {1}".F(game.Players, map.PlayerCount); players.GetColor = () => canJoin ? players.TextColor : Color.Gray; } var state = item.GetOrNull<LabelWidget>("STATE"); if (state != null) { state.GetText = () => GetStateLabel(game); state.GetColor = () => canJoin ? state.TextColor : Color.Gray; } var ip = item.GetOrNull<LabelWidget>("IP"); if (ip != null) { ip.GetText = () => game.Address; ip.GetColor = () => canJoin ? ip.TextColor : Color.Gray; } var version = item.GetOrNull<LabelWidget>("VERSION"); if (version != null) { version.GetText = () => GenerateModLabel(game); version.IsVisible = () => !game.CompatibleVersion(); version.GetColor = () => canJoin ? version.TextColor : Color.Gray; } var location = item.GetOrNull<LabelWidget>("LOCATION"); if (location != null) { var cachedServerLocation = LobbyUtils.LookupCountry(game.Address.Split(':')[0]); location.GetText = () => cachedServerLocation; location.IsVisible = () => game.CompatibleVersion(); location.GetColor = () => canJoin ? location.TextColor : Color.Gray; } if (!Filtered(game)) rows.Add(item); } Game.RunAfterTick(() => { serverList.RemoveChildren(); currentServer = null; if (games == null) { searchStatus = SearchStatus.Failed; return; } if (!games.Any()) { searchStatus = SearchStatus.NoGames; return; } currentServer = games.FirstOrDefault(); searchStatus = SearchStatus.Hidden; // Search for any unknown maps if (Game.Settings.Game.AllowDownloading) Game.modData.MapCache.QueryRemoteMapDetails(games.Where(g => !Filtered(g)).Select(g => g.Map)); foreach (var row in rows) serverList.AddChild(row); }); }
public void RefreshServerList(Widget panel, IEnumerable<GameServer> games) { var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST"); sl.RemoveChildren(); currentServer = null; if (games == null) { searchStatus = SearchStatus.Failed; return; } var gamesWaiting = games.Where(g => g.CanJoin()); if (gamesWaiting.Count() == 0) { searchStatus = SearchStatus.NoGames; return; } searchStatus = SearchStatus.Hidden; currentServer = gamesWaiting.FirstOrDefault(); foreach (var loop in gamesWaiting) { var game = loop; var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game); item.GetWidget<LabelWidget>("TITLE").GetText = () => game.Name; // TODO: Use game.MapTitle once the server supports it item.GetWidget<LabelWidget>("MAP").GetText = () => { var map = Game.modData.FindMapByUid(game.Map); return map == null ? "Unknown" : map.Title; }; // TODO: Use game.MaxPlayers once the server supports it item.GetWidget<LabelWidget>("PLAYERS").GetText = () => GetPlayersLabel(game); item.GetWidget<LabelWidget>("IP").GetText = () => game.Address; sl.AddChild(item); } }
/// <summary> /// Reset the search /// </summary> public void Reset() { searchStatus = SearchStatus.Stopped; totalSearchSteps = 0; Scale = map.Scale; openList.Clear(); closedList.Clear(); paths.Clear(); openList.Add(new SearchNode(map.StartTile, Map.StepDistance(map.StartTile, map.EndTile) , 0)); }
public void ProcessSearch() { if (destination == player || destination.X < 0 || destination.Y < 0 || width <= destination.X || height <= destination.Y || map[(int) Destination.Y, (int) Destination.X] == (int) CollisionValues.Impassable) { SearchStatus = SearchStatus.NoPath; } var steps = 0; do { if (openList.Count == 0) { var playerNode = new Node(player) {ParentNode = new Vector2(-1, -1)}; openList.Add(playerNode); CheckAdjascentNodes(playerNode); openList.Remove(playerNode); closedList.Add(playerNode); } else { AddEnemyNodesToClosedList(); openList.Remove(currentNode); CheckAdjascentNodes(currentNode); closedList.Add(currentNode); if (currentNode.nodePosition == destination) searchStatus = SearchStatus.PathFound; } steps++; } while (searchStatus == SearchStatus.Searching && steps < stepsPerUpdate); if (searchStatus == SearchStatus.PathFound) { Node n = GetFromClosedList(destination); path.Add(n.nodePosition); do { n = GetFromClosedList(n.ParentNode); path.Add(n.nodePosition); } while (n.ParentNode != player && !n.Equals(new Node()) && n.ParentNode != new Vector2(-1, -1)); } }
void RefreshServerListInner(IEnumerable<GameServer> games) { if (games == null) return; var mods = games.GroupBy(g => g.Mods) .OrderByDescending(g => GroupSortOrder(g.First())) .ThenByDescending(g => g.Count()); ScrollItemWidget nextServerRow = null; var rows = new List<Widget>(); foreach (var modGames in mods) { if (modGames.All(Filtered)) continue; var header = ScrollItemWidget.Setup(headerTemplate, () => true, () => { }); var headerTitle = modGames.First().ModLabel; header.Get<LabelWidget>("LABEL").GetText = () => headerTitle; rows.Add(header); Func<GameServer, int> listOrder = g => { // Servers waiting for players are always first if (g.State == (int)ServerState.WaitingPlayers && g.Players > 0) return 0; // Then active games if (g.State >= (int)ServerState.GameStarted) return 1; // Empty servers are shown at the end because a flood of empty servers // at the top of the game list make the community look dead return 2; }; foreach (var loop in modGames.OrderBy(listOrder).ThenByDescending(g => g.Players)) { var game = loop; if (game == null || Filtered(game)) continue; var canJoin = game.IsJoinable; var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => SelectServer(game), () => Join(game)); var title = item.GetOrNull<LabelWidget>("TITLE"); if (title != null) { var font = Game.Renderer.Fonts[title.Font]; var label = WidgetUtils.TruncateText(game.Name, title.Bounds.Width, font); title.GetText = () => label; title.GetColor = () => canJoin ? title.TextColor : incompatibleGameColor; } var password = item.GetOrNull<ImageWidget>("PASSWORD_PROTECTED"); if (password != null) { password.IsVisible = () => game.Protected; password.GetImageName = () => canJoin ? "protected" : "protected-disabled"; } var players = item.GetOrNull<LabelWidget>("PLAYERS"); if (players != null) { players.GetText = () => "{0} / {1}".F(game.Players, game.MaxPlayers) + (game.Spectators > 0 ? " + {0}".F(game.Spectators) : ""); players.GetColor = () => canJoin ? players.TextColor : incompatibleGameColor; } var state = item.GetOrNull<LabelWidget>("STATUS"); if (state != null) { var label = game.State >= (int)ServerState.GameStarted ? "Playing" : "Waiting"; state.GetText = () => label; var color = GetStateColor(game, state, !canJoin); state.GetColor = () => color; } var location = item.GetOrNull<LabelWidget>("LOCATION"); if (location != null) { var font = Game.Renderer.Fonts[location.Font]; var cachedServerLocation = GeoIP.LookupCountry(game.Address.Split(':')[0]); var label = WidgetUtils.TruncateText(cachedServerLocation, location.Bounds.Width, font); location.GetText = () => label; location.GetColor = () => canJoin ? location.TextColor : incompatibleGameColor; } if (currentServer != null && game.Address == currentServer.Address) nextServerRow = item; rows.Add(item); } } Game.RunAfterTick(() => { serverList.RemoveChildren(); SelectServer(null); if (games == null) { searchStatus = SearchStatus.Failed; return; } if (!rows.Any()) { searchStatus = SearchStatus.NoGames; return; } searchStatus = SearchStatus.Hidden; // Search for any unknown maps if (Game.Settings.Game.AllowDownloading) modData.MapCache.QueryRemoteMapDetails(games.Where(g => !Filtered(g)).Select(g => g.Map)); foreach (var row in rows) serverList.AddChild(row); if (nextServerRow != null) nextServerRow.OnClick(); }); }
/// <summary> /// This method find the next path node to visit, puts that node on the /// closed list and adds any nodes adjacent to the visited node to the /// open list. /// </summary> private void DoSearchStep() { SearchNode newOpenListNode; bool foundNewNode = SelectNodeToVisit(out newOpenListNode); if (foundNewNode) { Point currentPos = newOpenListNode.Position; foreach (Point point in board.OpenMapTiles(currentPos)) { SearchNode mapTile = new SearchNode(point, StepDistanceToEnd(point), newOpenListNode.DistanceTraveled + 1); if (!InList(openList,point) && !InList(closedList,point)) { openList.Add(mapTile); paths[point] = newOpenListNode.Position; } } if (currentPos == EndTile) { searchStatus = SearchStatus.PathFound; } openList.Remove(newOpenListNode); closedList.Add(newOpenListNode); } else { searchStatus = SearchStatus.NoPath; } }
public void UpdateSearchStatus(SearchStatus status) { switch (status) { case SearchStatus.Success: this.setBackColorSuccess(); break; case SearchStatus.Error: this.setBackColorError(); break; case SearchStatus.Pending: this.setBackColorSearching(); break; case SearchStatus.Normal: this.setBackColorNormal(); break; default: break; } }
/// <summary> /// Reset the search /// </summary> public void Reset(Point boardstartTile, Point boardendTile) { searchStatus = SearchStatus.Stopped; totalSearchSteps = 0; // Scale = map.Scale; openList.Clear(); closedList.Clear(); paths.Clear(); startTile = boardstartTile; endTile = boardendTile; openList.Add(new SearchNode(StartTile,StepDistance(StartTile, EndTile), 0)); }
/// <summary> /// Setup search /// </summary> /// <param name="mazeMap">Map to search</param> public void Initialize(HackGameBoard gameboard) { searchStatus = SearchStatus.Stopped; openList = new List<SearchNode>(); closedList = new List<SearchNode>(); paths = new Dictionary<Point, Point>(); board = gameboard; }
void RefreshServerList() { // Query in progress if (currentQuery != null) return; searchStatus = SearchStatus.Fetching; Action<DownloadDataCompletedEventArgs> onComplete = i => { currentQuery = null; if (i.Error != null) { RefreshServerListInner(null); return; } var data = Encoding.UTF8.GetString(i.Result); var yaml = MiniYaml.FromString(data); var games = yaml.Select(a => new GameServer(a.Value)) .Where(gs => gs.Address != null); Game.RunAfterTick(() => RefreshServerListInner(games)); }; var queryURL = Game.Settings.Server.MasterServer + "games?version={0}&mod={1}&modversion={2}".F( Uri.EscapeUriString(Game.Mods["modchooser"].Metadata.Version), Uri.EscapeUriString(Game.ModData.Manifest.Id), Uri.EscapeUriString(Game.ModData.Manifest.Metadata.Version)); currentQuery = new Download(queryURL, _ => { }, onComplete); }
/// <summary> /// Setup search /// </summary> /// <param name="mazeMap">Map to search</param> public void Initialize(Map mazeMap) { searchStatus = SearchStatus.Stopped; openList = new List<SearchNode>(); closedList = new List<SearchNode>(); paths = new Dictionary<Point, Point>(); map = mazeMap; }
void RefreshServerListInner(IEnumerable<GameServer> games) { if (games == null) return; var mods = games.GroupBy(g => g.Mods) .OrderByDescending(g => GroupSortOrder(g.First())) .ThenByDescending(g => g.Count()); var rows = new List<Widget>(); foreach (var modGames in mods) { if (modGames.All(Filtered)) continue; var header = ScrollItemWidget.Setup(headerTemplate, () => true, () => { }); var headerTitle = modGames.First().ModLabel; header.Get<LabelWidget>("LABEL").GetText = () => headerTitle; rows.Add(header); foreach (var loop in modGames.OrderByDescending(g => g.IsJoinable).ThenByDescending(g => g.Players)) { var game = loop; if (game == null || Filtered(game)) continue; var canJoin = game.IsJoinable; var compatible = game.IsCompatible; var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game, () => Join(game)); var map = Game.ModData.MapCache[game.Map]; var preview = item.GetOrNull<MapPreviewWidget>("MAP_PREVIEW"); if (preview != null) preview.Preview = () => map; var title = item.GetOrNull<LabelWidget>("TITLE"); if (title != null) { title.GetText = () => game.Name; title.GetColor = () => !compatible ? incompatibleGameColor : !canJoin ? cantJoinGameColor : title.TextColor; } var maptitle = item.GetOrNull<LabelWidget>("MAP"); if (maptitle != null) { maptitle.GetText = () => map.Title; maptitle.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : maptitle.TextColor; } var players = item.GetOrNull<LabelWidget>("PLAYERS"); if (players != null) { players.GetText = () => "{0} / {1}".F(game.Players, game.MaxPlayers) + (game.Spectators > 0 ? " ({0} Spectator{1})".F(game.Spectators, game.Spectators > 1 ? "s" : "") : ""); players.GetColor = () => !compatible ? incompatibleGameColor : !canJoin ? cantJoinGameColor : players.TextColor; } var state = item.GetOrNull<LabelWidget>("STATE"); if (state != null) { state.GetText = () => GetStateLabel(game); state.GetColor = () => GetStateColor(game, state, !compatible || !canJoin); } var ip = item.GetOrNull<LabelWidget>("IP"); if (ip != null) { ip.GetText = () => game.Address; ip.GetColor = () => !compatible ? incompatibleGameColor : !canJoin ? cantJoinGameColor : ip.TextColor; } var location = item.GetOrNull<LabelWidget>("LOCATION"); if (location != null) { var cachedServerLocation = GeoIP.LookupCountry(game.Address.Split(':')[0]); location.GetText = () => cachedServerLocation; location.GetColor = () => !compatible ? incompatibleGameColor : !canJoin ? cantJoinGameColor : location.TextColor; } rows.Add(item); } } Game.RunAfterTick(() => { serverList.RemoveChildren(); currentServer = null; if (games == null) { searchStatus = SearchStatus.Failed; return; } if (!games.Any()) { searchStatus = SearchStatus.NoGames; return; } currentServer = games.FirstOrDefault(); searchStatus = SearchStatus.Hidden; // Search for any unknown maps if (Game.Settings.Game.AllowDownloading) Game.ModData.MapCache.QueryRemoteMapDetails(games.Where(g => !Filtered(g)).Select(g => g.Map)); foreach (var row in rows) serverList.AddChild(row); }); }
internal void UpdateUIAboutScheduledSearch(SearchStatus searchStatus) { if (searchStatus == SearchStatus.Busy) { buttonCommitSearch.Enabled = false; buttonCommitSearch.Text = "Busy, please wait..."; } else if (searchStatus == SearchStatus.Searching) { buttonCommitSearch.Enabled = false; buttonCommitSearch.Text = "Searching..."; } }
void qsUpdate(SearchStatus status, bool cancellationPending) { if (!cancellationPending) { this.quickSearchControl.UpdateSearchStatus(status); } }
public void RefreshServerList(Widget panel, IEnumerable<GameServer> games) { var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST"); sl.RemoveChildren(); currentServer = null; if (games == null) { searchStatus = SearchStatus.Failed; return; } if (games.Count() == 0) { searchStatus = SearchStatus.NoGames; return; } searchStatus = SearchStatus.Hidden; currentServer = games.FirstOrDefault(); foreach (var loop in games) { var game = loop; var canJoin = game.CanJoin(); var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game); var preview = item.GetWidget<MapPreviewWidget>("MAP_PREVIEW"); preview.Map = () => GetMapPreview(game); preview.IsVisible = () => GetMapPreview(game) != null; var title = item.GetWidget<LabelWidget>("TITLE"); title.GetText = () => game.Name; // TODO: Use game.MapTitle once the server supports it var maptitle = item.GetWidget<LabelWidget>("MAP"); maptitle.GetText = () => { var map = Game.modData.FindMapByUid(game.Map); return map == null ? "Unknown Map" : map.Title; }; // TODO: Use game.MaxPlayers once the server supports it var players = item.GetWidget<LabelWidget>("PLAYERS"); players.GetText = () => GetPlayersLabel(game); var state = item.GetWidget<LabelWidget>("STATE"); state.GetText = () => GetStateLabel(game); var ip = item.GetWidget<LabelWidget>("IP"); ip.GetText = () => game.Address; var version = item.GetWidget<LabelWidget>("VERSION"); version.GetText = () => GenerateModsLabel(game); version.IsVisible = () => !game.CompatibleVersion(); if (!canJoin) { title.GetColor = () => Color.Gray; maptitle.GetColor = () => Color.Gray; players.GetColor = () => Color.Gray; state.GetColor = () => Color.Gray; ip.GetColor = () => Color.Gray; version.GetColor = () => Color.Gray; } sl.AddChild(item); } }
private void LoadArticleNumberSearchInformation() { if (SearchStatus == SearchStatus.NoResult) { _isArticleNumberSearch = false; _articleNumberSearchStatus = SearchStatus.NoResult; return; } switch ((string)JsonData.searchResult.resultArticleNumberStatus) { case "nothingFound": _isArticleNumberSearch = true; _articleNumberSearchStatus = SearchStatus.EmptyResult; break; case "resultsFound": _isArticleNumberSearch = true; _articleNumberSearchStatus = SearchStatus.ResultsFound; break; case "noArticleNumberSearch": default: _isArticleNumberSearch = false; _articleNumberSearchStatus = SearchStatus.NoResult; break; } }