public void AddClient(ClientState State) { GameCanvas Canvas = new GameCanvas(State); AddSubview(Canvas); ActiveCanvas = Canvas; InsertTab(Tabs.Count - 1, State.Viewport.Player.Name + "(" + State.HostName + ")"); }
public GameCanvas(ClientState State) : base(null, UIElementType.Window) { Protocol = State.Protocol; Viewport = State.Viewport; RegisterEvents(); UpdateName(); }
public void OnNewState(ClientState NewState) { Visible = (NewState.Viewport == Viewport); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Initialize the context UIContext.Initialize(Window, Graphics, Content); UIContext.Load(); // Create the game frame Desktop = new GameDesktop(); Desktop.Load(); Desktop.CreatePanels(); // Initial layout of all views Desktop.LayoutSubviews(); Desktop.NeedsLayout = true; /////////////////////////////////////////////////////////////////// // For debugging read a TMV file as input FileInfo file = new FileInfo("./Test.tmv"); Stream virtualStream = null; FileStream fileStream = file.OpenRead(); if (file.Extension == ".tmv") virtualStream = new System.IO.Compression.GZipStream(fileStream, System.IO.Compression.CompressionMode.Decompress); else virtualStream = fileStream; // Add the initial state TibiaMovieStream MovieStream = new TibiaMovieStream(virtualStream, file.Name); ClientState State = new ClientState(MovieStream); MovieStream.PlaybackSpeed = 50; State.ForwardTo(new TimeSpan(0, 30, 0)); // If fast-forwarded, client tab immediately, // otherwise delay until we receive the login packet. if (State.Viewport.Player == null) { State.Viewport.Login += delegate(ClientViewport Viewport) { Desktop.AddClient(State); }; } else { Desktop.AddClient(State); } State.Update(new GameTime()); /* while (MS.Elapsed.TotalMinutes < 0 || MS.Elapsed.Seconds < 0) Protocol.parsePacket(InStream.Read()); */ }
// Methods public void AddClient(ClientState State) { Clients.Add(State); ActiveClient = State; // Read in some state (in case the game was fast-forwarded) foreach (ClientContainer Container in State.Viewport.Containers.Values) OnOpenContainer(State.Viewport, Container); // Hook up handlers for some events State.Viewport.OpenContainer += OnOpenContainer; State.Viewport.CloseContainer += OnCloseContainer; Frame.AddClient(State); }