private static void Migrator_StatusChanged(string[] messages) { foreach (var message in messages) { MessageStack.AppendLine(message); } }
public StatusMessage(string?message, Colour32?colour, TimeSpan?ttl) { m_sb = new StringBuilder(message ?? string.Empty); m_colour = colour ?? DefaultStatusColour; // Add the status message to the stack lock (MessageStack) MessageStack.Add(this); // Notify of new status ValueChanged?.Invoke(this, EventArgs.Empty); // If the status expires after a time, set a timer to remove it if (ttl != null) { m_expire_timer = new Timer(HandleExpire, this, (int)ttl.Value.TotalMilliseconds, -1); void HandleExpire(object?state) { m_expire_timer?.Dispose(); if (state is StatusMessage sm) { sm.Dispose(); } } } }
public ServerState() { if (currentInstance == null) { currentInstance = this; } else { throw new Exception("only one instance of ServerState is allowed"); } flatList = new List<IEntity>(); playerInfo= new Dictionary<int, PlayerInfo>(); _server = new GameServer(); _server.OnClientConnect = new ONet.GameServer.Callback(ClientConnect); _server.OnClientDisconnect = new ONet.GameServer.Callback(ClientDisconnect); _server.OnClientMessage = new ONet.GameServer.Callback(Message); _server.OnError = new ONet.GameServer.ErrorCallback(ErrorMessage); _infoStack = new MessageStack<string>(10); _errorStack = new MessageStack<string>(10); float offset = 150.0f; createdEntities.AddRange(BuildingChunk.CreateBuilding(new Vector2(512.0f, 600.0f))); createdEntities.AddRange(BuildingChunk.CreateBuilding(new Vector2(512.0f + offset, 600.0f))); createdEntities.AddRange(BuildingChunk.CreateBuilding(new Vector2(512.0f + 2 * offset, 600.0f))); createdEntities.AddRange(BuildingChunk.CreateBuilding(new Vector2(512.0f - offset, 600.0f))); createdEntities.AddRange(BuildingChunk.CreateBuilding(new Vector2(512.0f - 2 * offset, 600.0f))); }
internal static void DrawMessageBox(MessageStack mess) { _mess = mess; Console.SetCursorPosition(0, 40); List <String> lines = _mess.Messages(); for (int i = 0; (i < lines.Count && Config.MESSBOX_START_H + i < Config.MESSBOX_END_W); i++) { Console.SetCursorPosition(Config.MESSBOX_START_W, Config.MESSBOX_START_H + i); Console.Write(lines[i]); } }
internal static void Redraw( MessageStack mess, string sysmess, string topInfos ) { Console.Clear(); DrawSystemMessage(sysmess); DrawTopRightLabelBox(topInfos); DrawTheFuckinLine(); DrawMessageBox(mess); ResetCursorToUser(); }
public bool Save() { // Really necessary? var isNewItem = (ArticleId <= 0); MessageStack.Clear(); Model.InsertAndUpdate(MessageStack, true); if (MessageStack.StatusMessage.MessageStatus != P2ValidationStatus.red && !Model.Modified) { return(true); } return(false); }
public void Dispose() { bool notify; lock (MessageStack) { if (MessageStack.Count == 0) { return; } notify = MessageStack.LastOrDefault() == this; MessageStack.Remove(this); } if (notify) { ValueChanged?.Invoke(this, EventArgs.Empty); } }
public ClientState() { _client = new Client(); respawnTimer = new Timer(); respawnTimer.AutoReset = true; respawnTimer.Elapsed += new ElapsedEventHandler(timer_Elapsed); _client.OnMessage = new Client.Callback(MessageCallback); _client.OnError = new Client.ErrorCallback(ErrorCallback); _client.OnConnect = new Client.Callback(ConnectCallback); _client.OnDisconnect = new Client.Callback(DisconnectCallback); _messageStack = new MessageStack<GameMessage>(500); _infoStack = new MessageStack<string>(10); _errorStack = new MessageStack<string>(10); if (currentInstance == null) currentInstance = this; else throw new Exception("only one instance of client state allowed"); }