/// <summary> /// Sends a CharacterCreate packet to a CityServer. /// </summary> /// <param name="LoginArgs">Arguments used to log onto the CityServer.</param> /// <param name="Character">The character to create on the CityServer.</param> public static void SendCharacterCreateCity(NetworkClient Client, UISim Character) { PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_CREATE_CITY, 0); MemoryStream PacketData = new MemoryStream(); BinaryWriter Writer = new BinaryWriter(PacketData); Writer.Write((byte)Client.ClientEncryptor.Username.Length); Writer.Write(Encoding.ASCII.GetBytes(Client.ClientEncryptor.Username), 0, Encoding.ASCII.GetBytes(Client.ClientEncryptor.Username).Length); Writer.Write(PlayerAccount.CityToken); Writer.Write(Character.Timestamp); Writer.Write(Character.Name); Writer.Write(Character.Sex); Writer.Write(Character.Description); Writer.Write((ulong)Character.HeadOutfitID); Writer.Write((ulong)Character.BodyOutfitID); Writer.Write((byte)Character.Avatar.Appearance); Packet.WriteBytes(PacketData.ToArray()); Writer.Close(); Client.SendEncrypted((byte)PacketType.CHARACTER_CREATE_CITY, Packet.ToArray()); }
/// <summary> /// Requests a token from the LoginServer, that can be used to log into a CityServer. /// </summary> /// <param name="Client">A NetworkClient instance.</param> public static void RequestCityToken(NetworkClient Client, UISim SelectedCharacter) { PacketStream Packet = new PacketStream((byte)PacketType.REQUEST_CITY_TOKEN, 0); Packet.WriteString(Client.ClientEncryptor.Username); Packet.WriteString(SelectedCharacter.ResidingCity.UUID); Packet.WriteString(SelectedCharacter.GUID.ToString()); Client.SendEncrypted((byte)PacketType.REQUEST_CITY_TOKEN, Packet.ToArray()); }
/// <summary> /// Sends a CharacterCreate packet to the LoginServer. /// </summary> /// <param name="Character">The character to create.</param> /// <param name="TimeStamp">The timestamp of when this character was created.</param> public static void SendCharacterCreate(UISim Character, string TimeStamp) { PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_CREATE, 0); Packet.WriteString(NetworkFacade.Client.ClientEncryptor.Username); Packet.WriteString(TimeStamp); Packet.WriteString(Character.Name); Packet.WriteString(Character.Sex); Packet.WriteString(Character.Description); Packet.WriteUInt64(Character.HeadOutfitID); Packet.WriteUInt64(Character.BodyOutfitID); Packet.WriteByte((byte)Character.Avatar.Appearance); Packet.WriteString(Character.ResidingCity.Name); Packet.WriteUInt64(Character.ResidingCity.Thumbnail); Packet.WriteString(Character.ResidingCity.UUID); Packet.WriteUInt64(Character.ResidingCity.Map); Packet.WriteString(Character.ResidingCity.IP); Packet.WriteInt32(Character.ResidingCity.Port); byte[] PacketData = Packet.ToArray(); NetworkFacade.Client.SendEncrypted((byte)PacketType.CHARACTER_CREATE, PacketData); }
public PersonSelectionEdit() { /** * Data */ MaleHeads = new Collection(ContentManager.GetResourceFromLongID((ulong)FileIDs.CollectionsFileIDs.ea_male_heads)); MaleOutfits = new Collection(ContentManager.GetResourceFromLongID((ulong)FileIDs.CollectionsFileIDs.ea_male)); FemaleHeads = new Collection(ContentManager.GetResourceFromLongID((ulong)FileIDs.CollectionsFileIDs.ea_female_heads)); FemaleOutfits = new Collection(ContentManager.GetResourceFromLongID((ulong)FileIDs.CollectionsFileIDs.ea_female)); /** * UI */ UIScript ui = null; if (GlobalSettings.Default.ScaleUI) { ui = this.RenderScript("personselectionedit.uis"); this.Scale800x600 = true; } else { ui = this.RenderScript("personselectionedit" + (ScreenWidth == 1024 ? "1024" : "") + ".uis"); } DescriptionTextEdit.CurrentText = ui.GetString("DefaultAvatarDescription"); DescriptionSlider.AttachButtons(DescriptionScrollUpButton, DescriptionScrollDownButton, 1); DescriptionTextEdit.AttachSlider(DescriptionSlider); NameTextEdit.OnChange += new ChangeDelegate(NameTextEdit_OnChange); AcceptButton.Disabled = true; AcceptButton.OnButtonClick += new ButtonClickDelegate(AcceptButton_OnButtonClick); /** Appearance **/ SkinLightButton.OnButtonClick += new ButtonClickDelegate(SkinButton_OnButtonClick); SkinMediumButton.OnButtonClick += new ButtonClickDelegate(SkinButton_OnButtonClick); SkinDarkButton.OnButtonClick += new ButtonClickDelegate(SkinButton_OnButtonClick); SelectedAppearanceButton = SkinLightButton; SkinLightButton.Selected = true; HeadSkinBrowser = ui.Create<UICollectionViewer>("HeadSkinBrowser"); HeadSkinBrowser.OnChange += new ChangeDelegate(HeadSkinBrowser_OnChange); HeadSkinBrowser.Init(); this.Add(HeadSkinBrowser); BodySkinBrowser = ui.Create<UICollectionViewer>("BodySkinBrowser"); BodySkinBrowser.Init(); this.Add(BodySkinBrowser); FemaleButton.OnButtonClick += new ButtonClickDelegate(GenderButton_OnButtonClick); MaleButton.OnButtonClick += new ButtonClickDelegate(GenderButton_OnButtonClick); /** Backgrounds **/ var bg = new UIImage(BackgroundImage); this.AddAt(0, bg); var offset = new Vector2(0, 0); if (BackgroundImageDialog != null) { offset = new Vector2(112, 84); this.AddAt(1, new UIImage(BackgroundImageDialog) { X = 112, Y = 84 }); } /** * Music */ PlayBackgroundMusic( GameFacade.GameFilePath("music\\modes\\create\\tsocas1_v2.mp3") ); SimBox = new UISim(); SimBox.SimScale = 0.8f; SimBox.Position = new Microsoft.Xna.Framework.Vector2(offset.X + 140, offset.Y + 130); this.Add(SimBox); Sim = new Sim(new Guid().ToString()); /** * Init state */ RefreshCollections(); HeadSkinBrowser.SelectedIndex = 0; BodySkinBrowser.SelectedIndex = 0; FemaleButton.Selected = true; }
public UIGizmo() { var ui = this.RenderScript("gizmo.uis"); BackgroundImageGizmo = ui.Create<UIImage>("BackgroundImageGizmo"); this.AddAt(0, BackgroundImageGizmo); BackgroundImageGizmoPanel = ui.Create<UIImage>("BackgroundImageGizmoPanel"); this.AddAt(0, BackgroundImageGizmoPanel); BackgroundImagePanel = ui.Create<UIImage>("BackgroundImagePanel"); this.AddAt(0, BackgroundImagePanel); UIUtils.MakeDraggable(BackgroundImageGizmo, this); UIUtils.MakeDraggable(BackgroundImageGizmoPanel, this); UIUtils.MakeDraggable(BackgroundImagePanel, this); ButtonContainer = new UIContainer(); this.Remove(ExpandButton); ButtonContainer.Add(ExpandButton); this.Remove(ContractButton); ButtonContainer.Add(ContractButton); this.Remove(FiltersButton); ButtonContainer.Add(FiltersButton); this.Remove(SearchButton); ButtonContainer.Add(SearchButton); this.Remove(Top100ListsButton); ButtonContainer.Add(Top100ListsButton); this.Add(ButtonContainer); FiltersProperty = new UIGizmoPropertyFilters(ui, this); FiltersProperty.Visible = false; this.Add(FiltersProperty); Search = new UIGizmoSearch(ui, this); Search.Visible = false; this.Add(Search); Top100 = new UIGizmoTop100(ui, this); Top100.Visible = false; Top100.Background.Visible = false; this.Add(Top100); ExpandButton.OnButtonClick += new ButtonClickDelegate(ExpandButton_OnButtonClick); ContractButton.OnButtonClick += new ButtonClickDelegate(ContractButton_OnButtonClick); PeopleTabButton.OnButtonClick += new ButtonClickDelegate(PeopleTabButton_OnButtonClick); HousesTabButton.OnButtonClick += new ButtonClickDelegate(HousesTabButton_OnButtonClick); FiltersButton.OnButtonClick += new ButtonClickDelegate(FiltersButton_OnButtonClick); SearchButton.OnButtonClick += new ButtonClickDelegate(SearchButton_OnButtonClick); Top100ListsButton.OnButtonClick += new ButtonClickDelegate(Top100ListsButton_OnButtonClick); SimBox = new UISim(); //var sim = new Sim(Guid.NewGuid().ToString()); //var maleHeads = new Collection(ContentManager.GetResourceFromLongID((ulong)FileIDs.CollectionsFileIDs.ea_male_heads)); //SimCatalog.LoadSim3D(sim, maleHeads.First().PurchasableObject.Outfit, AppearanceType.Light); // //sim.HeadOutfitID = 4853313044493; //sim.AppearanceType = AppearanceType.Light; //sim.BodyOutfitID = 5394478923789; //SimCatalog.LoadSim3D(sim); //SimCatalog.LoadSim3D(sim, SimCatalog.GetOutfit(4462471020557), AppearanceType.Light); //SimBox.Sim = sim; //SimBox.SimScale = 0.4f; //SimBox.Position = new Microsoft.Xna.Framework.Vector2(60, 60); //this.Add(SimBox); SetOpen(false); }
/// <summary> /// Caches sims received from the LoginServer to the disk. /// </summary> /// <param name="FreshSims">A list of the sims received by the LoginServer.</param> public static void CacheSims(List<UISim> FreshSims) { if (!Directory.Exists(CacheDir)) Directory.CreateDirectory(CacheDir); using(BinaryWriter Writer = new BinaryWriter(File.Create(CacheDir + "\\Sims.tempcache"))) { //Last time these sims were cached. Writer.Write(DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss", CultureInfo.InvariantCulture)); Writer.Write(FreshSims.Count); foreach (UISim S in FreshSims) { //Length of the current entry, so its skippable... Writer.Write((int)4 + S.GUID.ToString().Length + 4 + S.Timestamp.Length + S.Name.Length + S.Sex.Length + S.Description.Length + 17 + S.ResidingCity.Name.Length + 8 + S.ResidingCity.UUID.ToString().Length + 8 + S.ResidingCity.IP.Length + 4); Writer.Write(S.GUID.ToString()); Writer.Write(S.CharacterID); Writer.Write(S.Timestamp); Writer.Write(S.Name); Writer.Write(S.Sex); Writer.Write(S.Description); Writer.Write(S.HeadOutfitID); Writer.Write(S.BodyOutfitID); Writer.Write((byte)S.Avatar.Appearance); Writer.Write(S.ResidingCity.Name); Writer.Write(S.ResidingCity.Thumbnail); Writer.Write(S.ResidingCity.UUID); Writer.Write(S.ResidingCity.Map); Writer.Write(S.ResidingCity.IP); Writer.Write(S.ResidingCity.Port); } if (File.Exists(CacheDir + "\\Sims.cache")) { using (BinaryReader Reader = new BinaryReader(File.Open(CacheDir + "\\Sims.cache", FileMode.Open))) { //Last time these sims were cached. Reader.ReadString(); int NumSims = Reader.ReadInt32(); List<UISim> UnchangedSims = new List<UISim>(); if (NumSims > FreshSims.Count) { if (NumSims == 2) { //Skips the first entry. Reader.BaseStream.Position = Reader.ReadInt32(); Reader.ReadInt32(); //Length of second entry. string GUID = Reader.ReadString(); UISim S = new UISim(GUID, false); S.CharacterID = Reader.ReadInt32(); S.Timestamp = Reader.ReadString(); S.Name = Reader.ReadString(); S.Sex = Reader.ReadString(); S.Description = Reader.ReadString(); S.HeadOutfitID = Reader.ReadUInt64(); S.BodyOutfitID = Reader.ReadUInt64(); S.Avatar.Appearance = (AppearanceType)Reader.ReadByte(); S.ResidingCity = new ProtocolAbstractionLibraryD.CityInfo(false); S.ResidingCity.Name = Reader.ReadString(); S.ResidingCity.Thumbnail = Reader.ReadUInt64(); S.ResidingCity.UUID = Reader.ReadString(); S.ResidingCity.Map = Reader.ReadUInt64(); S.ResidingCity.IP = Reader.ReadString(); S.ResidingCity.Port = Reader.ReadInt32(); UnchangedSims.Add(S); } else if (NumSims == 3) { //Skips the first entry. Reader.BaseStream.Position = Reader.ReadInt32(); Reader.ReadInt32(); //Length of second entry. string GUID = Reader.ReadString(); UISim S = new UISim(GUID, false); S.CharacterID = Reader.ReadInt32(); S.Timestamp = Reader.ReadString(); S.Name = Reader.ReadString(); S.Sex = Reader.ReadString(); S.Description = Reader.ReadString(); S.HeadOutfitID = Reader.ReadUInt64(); S.BodyOutfitID = Reader.ReadUInt64(); S.Avatar.Appearance = (AppearanceType)Reader.ReadByte(); S.ResidingCity = new ProtocolAbstractionLibraryD.CityInfo(false); S.ResidingCity.Name = Reader.ReadString(); S.ResidingCity.Thumbnail = Reader.ReadUInt64(); S.ResidingCity.UUID = Reader.ReadString(); S.ResidingCity.Map = Reader.ReadUInt64(); S.ResidingCity.IP = Reader.ReadString(); S.ResidingCity.Port = Reader.ReadInt32(); UnchangedSims.Add(S); Reader.ReadInt32(); //Length of third entry. S.CharacterID = Reader.ReadInt32(); S.Timestamp = Reader.ReadString(); S.Name = Reader.ReadString(); S.Sex = Reader.ReadString(); S.Description = Reader.ReadString(); S.HeadOutfitID = Reader.ReadUInt64(); S.BodyOutfitID = Reader.ReadUInt64(); S.Avatar.Appearance = (AppearanceType)Reader.ReadByte(); S.ResidingCity = new ProtocolAbstractionLibraryD.CityInfo(false); S.ResidingCity.Name = Reader.ReadString(); S.ResidingCity.Thumbnail = Reader.ReadUInt64(); S.ResidingCity.UUID = Reader.ReadString(); S.ResidingCity.Map = Reader.ReadUInt64(); S.ResidingCity.IP = Reader.ReadString(); S.ResidingCity.Port = Reader.ReadInt32(); UnchangedSims.Add(S); } Reader.Close(); foreach (UISim S in UnchangedSims) { //Length of the current entry, so its skippable... Writer.Write((int)4 + S.GUID.ToString().Length + 4 + S.Timestamp.Length + S.Name.Length + S.Sex.Length + S.Description.Length + 17 + S.ResidingCity.Name.Length + 8 + S.ResidingCity.UUID.ToString().Length + 8 + S.ResidingCity.IP.Length + 4); Writer.Write(S.GUID.ToString()); Writer.Write(S.CharacterID); Writer.Write(S.Timestamp); Writer.Write(S.Name); Writer.Write(S.Sex); Writer.Write(S.Description); Writer.Write(S.HeadOutfitID); Writer.Write(S.BodyOutfitID); Writer.Write((byte)S.Avatar.Appearance); Writer.Write(S.ResidingCity.Name); Writer.Write(S.ResidingCity.Thumbnail); Writer.Write(S.ResidingCity.UUID); Writer.Write(S.ResidingCity.Map); Writer.Write(S.ResidingCity.IP); Writer.Write(S.ResidingCity.Port); } } } } Writer.Flush(); Writer.Close(); } if (File.Exists(CacheDir + "\\Sims.cache")) { File.Delete(CacheDir + "\\Sims.cache"); File.Move(CacheDir + "\\Sims.tempcache", CacheDir + "\\Sims.cache"); } else File.Move(CacheDir + "\\Sims.tempcache", CacheDir + "\\Sims.cache"); }
/// <summary> /// Loads all sims from the player's cache. /// </summary> /// <returns>List of cached sims. Will be empty if no cache existed.</returns> public static List<UISim> LoadAllSims() { List<UISim> CachedSims = new List<UISim>(); if (!Directory.Exists(CacheDir)) { Directory.CreateDirectory(CacheDir); return CachedSims; } if (!File.Exists(CacheDir + "\\Sims.cache")) return CachedSims; using (BinaryReader Reader = new BinaryReader(File.Open(CacheDir + "\\Sims.cache", FileMode.Open))) { //Last time these sims were cached. Reader.ReadString(); int NumSims = Reader.ReadInt32(); for (int i = 0; i < NumSims; i++) { Reader.ReadInt32(); //Length of entry. string GUID = Reader.ReadString(); UISim S = new UISim(GUID, false); S.CharacterID = Reader.ReadInt32(); S.Timestamp = Reader.ReadString(); S.Name = Reader.ReadString(); S.Sex = Reader.ReadString(); S.Description = Reader.ReadString(); S.HeadOutfitID = Reader.ReadUInt64(); S.BodyOutfitID = Reader.ReadUInt64(); S.Avatar.Appearance = (AppearanceType)Reader.ReadByte(); S.ResidingCity = new ProtocolAbstractionLibraryD.CityInfo(false); S.ResidingCity.Name = Reader.ReadString(); S.ResidingCity.Thumbnail = Reader.ReadUInt64(); S.ResidingCity.UUID = Reader.ReadString(); S.ResidingCity.Map = Reader.ReadUInt64(); S.ResidingCity.IP = Reader.ReadString(); S.ResidingCity.Port = Reader.ReadInt32(); CachedSims.Add(S); } Reader.Close(); } return CachedSims; }
/// <summary> /// A player joined a session (game) in progress. /// </summary> public static LotTileEntry OnPlayerJoinedSession(NetworkClient Client, ProcessedPacket Packet) { LotTileEntry TileEntry = new LotTileEntry(0, "", 0, 0, 0, 0); UISim Avatar = new UISim(Packet.ReadString()); Avatar.Name = Packet.ReadString(); Avatar.Sex = Packet.ReadString(); Avatar.Description = Packet.ReadString(); Avatar.HeadOutfitID = Packet.ReadUInt64(); Avatar.BodyOutfitID = Packet.ReadUInt64(); Avatar.Avatar.Appearance = (AppearanceType)Packet.ReadInt32(); byte HasHouse = (byte)Packet.ReadByte(); if (HasHouse != 0) { TileEntry = new LotTileEntry(Packet.ReadInt32(), Packet.ReadString(), (short)Packet.ReadUInt16(), (short)Packet.ReadUInt16(), (byte)Packet.ReadByte(), Packet.ReadInt32()); Avatar.LotID = TileEntry.lotid; Avatar.HouseX = TileEntry.x; Avatar.HouseY = TileEntry.y; LotTileEntry[] TileEntries = new LotTileEntry[TSOClient.Code.GameFacade.CDataRetriever.LotTileData.Length + 1]; TileEntries[0] = TileEntry; TSOClient.Code.GameFacade.CDataRetriever.LotTileData.CopyTo(TileEntries, 1); } lock (NetworkFacade.AvatarsInSession) { NetworkFacade.AvatarsInSession.Add(Avatar); } return TileEntry; }
/// <summary> /// LoginServer sent information about the player's characters. /// </summary> /// <param name="Packet">The packet that was received.</param> public static void OnCharacterInfoResponse(ProcessedPacket Packet, NetworkClient Client) { byte NumCharacters = (byte)Packet.ReadByte(); byte NewCharacters = (byte)Packet.ReadByte(); List<UISim> FreshSims = new List<UISim>(); for (int i = 0; i < NewCharacters; i++) { int CharacterID = Packet.ReadInt32(); UISim FreshSim = new UISim(Packet.ReadString(), false); FreshSim.CharacterID = CharacterID; FreshSim.Timestamp = Packet.ReadString(); FreshSim.Name = Packet.ReadString(); FreshSim.Sex = Packet.ReadString(); FreshSim.Description = Packet.ReadString(); FreshSim.HeadOutfitID = Packet.ReadUInt64(); FreshSim.BodyOutfitID = Packet.ReadUInt64(); FreshSim.Avatar.Appearance = (AppearanceType)Packet.ReadByte(); FreshSim.ResidingCity = new CityInfo(false); FreshSim.ResidingCity.Name = Packet.ReadString(); FreshSim.ResidingCity.Thumbnail = Packet.ReadUInt64(); FreshSim.ResidingCity.UUID = Packet.ReadString(); FreshSim.ResidingCity.Map = Packet.ReadUInt64(); FreshSim.ResidingCity.IP = Packet.ReadString(); FreshSim.ResidingCity.Port = Packet.ReadInt32(); FreshSims.Add(FreshSim); } lock (NetworkFacade.Avatars) { if ((NumCharacters < 3) && (NewCharacters > 0)) { FreshSims = Cache.LoadCachedSims(FreshSims); NetworkFacade.Avatars = FreshSims; Cache.CacheSims(FreshSims); } if (NewCharacters == 0 && NumCharacters > 0) NetworkFacade.Avatars = Cache.LoadAllSims(); else if (NewCharacters == 3 && NumCharacters == 3) { NetworkFacade.Avatars = FreshSims; Cache.CacheSims(FreshSims); } else if (NewCharacters == 0 && NumCharacters == 0) { //Make sure if sims existed in the cache, they are deleted (because they didn't exist in DB). Cache.DeleteCache(); } else if (NumCharacters == 3 && NewCharacters == 3) { NetworkFacade.Avatars = FreshSims; } } PacketStream CityInfoRequest = new PacketStream(0x06, 0); CityInfoRequest.WriteByte(0x00); //Dummy Client.SendEncrypted((byte)PacketType.CITY_LIST, CityInfoRequest.ToArray()); }
private void AcceptButton_OnButtonClick(UIElement button) { var sim = new UISim(Guid.NewGuid(), false); sim.Name = NameTextEdit.CurrentText; sim.Sex = System.Enum.GetName(typeof(Gender), Gender); sim.Description = DescriptionTextEdit.CurrentText; sim.Timestamp = DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss", CultureInfo.InvariantCulture); sim.ResidingCity = SelectedCity; var selectedHead = (CollectionItem)((UIGridViewerItem)m_HeadSkinBrowser.SelectedItem).Data; var selectedBody = (CollectionItem)((UIGridViewerItem)m_BodySkinBrowser.SelectedItem).Data; var headPurchasable = Content.Get().AvatarPurchasables.Get(selectedHead.PurchasableOutfitId); var bodyPurchasable = Content.Get().AvatarPurchasables.Get(selectedBody.PurchasableOutfitId); sim.Head = Content.Get().AvatarOutfits.Get(headPurchasable.OutfitID); sim.HeadOutfitID = headPurchasable.OutfitID; sim.Body = Content.Get().AvatarOutfits.Get(bodyPurchasable.OutfitID); sim.BodyOutfitID = bodyPurchasable.OutfitID; sim.Handgroup = Content.Get().AvatarOutfits.Get(bodyPurchasable.OutfitID); sim.Avatar.Appearance = this.AppearanceType; PlayerAccount.CurrentlyActiveSim = sim; if (NetworkFacade.Avatars.Count <= 3) { lock(NetworkFacade.Avatars) NetworkFacade.Avatars.Add(sim); } else { UIAlertOptions Options = new UIAlertOptions(); Options.Message = "You've already created three characters!"; Options.Title = "Too Many Avatars"; Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); return; } //DateTime.Now.ToString() requires extremely specific formatting. UIPacketSenders.SendCharacterCreate(sim, DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss", CultureInfo.InvariantCulture)); }
public PersonSelection() { UIScript ui = null; if (GlobalSettings.Default.ScaleUI) { ui = this.RenderScript("personselection.uis"); this.Scale800x600 = true; } else { ui = this.RenderScript("personselection" + (ScreenWidth == 1024 ? "1024" : "") + ".uis"); } var numSlots = 3; PersonSlots = new List<PersonSlot>(); for (var i = 0; i < numSlots; i++) { var index = (i + 1).ToString(); /** Tab Background **/ var tabBackground = ui.Create<UIImage>("TabBackgroundImage" + index); this.Add(tabBackground); var enterTabImage = ui.Create<UIImage>("EnterTabImage" + index); this.Add(enterTabImage); var descTabImage = ui.Create<UIImage>("DescriptionTabImage" + index); this.Add(descTabImage); var descTabBgImage = ui.Create<UIImage>("DescriptionTabBackgroundImage" + index); var enterIcons = ui.Create<UIImage>("EnterTabBackgroundImage" + index); var personSlot = new PersonSlot(this) { AvatarButton = (UIButton)ui["AvatarButton" + index], CityButton = (UIButton)ui["CityButton" + index], HouseButton = (UIButton)ui["HouseButton" + index], EnterTabButton = (UIButton)ui["EnterTabButton" + index], DescTabButton = (UIButton)ui["DescriptionTabButton" + index], NewAvatarButton = (UIButton)ui["NewAvatarButton" + index], DeleteAvatarButton = (UIButton)ui["DeleteAvatarButton" + index], PersonNameText = (UILabel)ui["PersonNameText" + index], PersonDescriptionScrollUpButton = (UIButton)ui["PersonDescriptionScrollUpButton" + index], PersonDescriptionScrollDownButton = (UIButton)ui["PersonDescriptionScrollDownButton" + index], PersonDescriptionSlider = (UISlider)ui["PersonDescriptionSlider" + index], CityNameText = (UILabel)ui["CityNameText" + index], HouseNameText = (UILabel)ui["HouseNameText" + index], PersonDescriptionText = (UITextEdit)ui["PersonDescriptionText" + index], DescriptionTabBackgroundImage = descTabBgImage, EnterTabBackgroundImage = enterIcons, TabBackground = tabBackground, TabEnterBackground = enterTabImage, TabDescBackground = descTabImage }; this.AddBefore(descTabBgImage, personSlot.PersonDescriptionText); this.AddBefore(enterIcons, personSlot.CityButton); personSlot.Init(); personSlot.SetSlotAvaliable(true); PersonSlots.Add(personSlot); if (i < NetworkFacade.Avatars.Count) { personSlot.DisplayAvatar(NetworkFacade.Avatars[i]); } } this.AddAt(0, new UIImage(BackgroundImage)); if (BackgroundImageDialog != null) { this.AddAt(1, new UIImage(BackgroundImageDialog) { X = 112, Y = 84 }); } /** * Button plumbing */ CreditsButton.OnButtonClick += new ButtonClickDelegate(CreditsButton_OnButtonClick); /** * Music */ var tracks = new string[]{ //"music\\modes\\select\\tsosas1_v2.mp3", "music\\modes\\select\\tsosas2_v2.mp3", //"music\\modes\\select\\tsosas3.mp3", //"music\\modes\\select\\tsosas4.mp3", //"music\\modes\\select\\tsosas5.mp3" }; PlayBackgroundMusic( GameFacade.GameFilePath(tracks.RandomItem()) ); var simBox = new UISim(); var sim = new Sim(Guid.NewGuid().ToString()); var maleHeads = new Collection(ContentManager.GetResourceFromLongID((ulong)FileIDs.CollectionsFileIDs.ea_male_heads)); SimCatalog.LoadSim3D(sim, SimCatalog.GetOutfit(4462471020557), AppearanceType.Light); simBox.Sim = sim; simBox.Position = PersonSlots[0].AvatarButton.Position + new Vector2(70, 40); simBox.Size = PersonSlots[0].AvatarButton.Size; this.Add(simBox); }
public UIGizmo() { var ui = this.RenderScript("gizmo.uis"); BackgroundImageGizmo = ui.Create<UIImage>("BackgroundImageGizmo"); this.AddAt(0, BackgroundImageGizmo); BackgroundImageGizmoPanel = ui.Create<UIImage>("BackgroundImageGizmoPanel"); this.AddAt(0, BackgroundImageGizmoPanel); BackgroundImagePanel = ui.Create<UIImage>("BackgroundImagePanel"); this.AddAt(0, BackgroundImagePanel); UIUtils.MakeDraggable(BackgroundImageGizmo, this); UIUtils.MakeDraggable(BackgroundImageGizmoPanel, this); UIUtils.MakeDraggable(BackgroundImagePanel, this); ButtonContainer = new UIContainer(); this.Remove(ExpandButton); ButtonContainer.Add(ExpandButton); this.Remove(ContractButton); ButtonContainer.Add(ContractButton); this.Remove(FiltersButton); ButtonContainer.Add(FiltersButton); this.Remove(SearchButton); ButtonContainer.Add(SearchButton); this.Remove(Top100ListsButton); ButtonContainer.Add(Top100ListsButton); this.Add(ButtonContainer); FiltersProperty = new UIGizmoPropertyFilters(ui, this); FiltersProperty.Visible = false; this.Add(FiltersProperty); Search = new UIGizmoSearch(ui, this); Search.Visible = false; this.Add(Search); Top100 = new UIGizmoTop100(ui, this); Top100.Visible = false; this.Add(Top100); ExpandButton.OnButtonClick += new ButtonClickDelegate(ExpandButton_OnButtonClick); ContractButton.OnButtonClick += new ButtonClickDelegate(ContractButton_OnButtonClick); PeopleTabButton.OnButtonClick += new ButtonClickDelegate(PeopleTabButton_OnButtonClick); HousesTabButton.OnButtonClick += new ButtonClickDelegate(HousesTabButton_OnButtonClick); FiltersButton.OnButtonClick += new ButtonClickDelegate(FiltersButton_OnButtonClick); SearchButton.OnButtonClick += new ButtonClickDelegate(SearchButton_OnButtonClick); Top100ListsButton.OnButtonClick += new ButtonClickDelegate(Top100ListsButton_OnButtonClick); SimBox = new UISim(); var sim = new Sim(Guid.NewGuid().ToString()); var maleHeads = new Collection(ContentManager.GetResourceFromLongID((ulong)FileIDs.CollectionsFileIDs.ea_male_heads)); if (PlayerAccount.CurrentlyActiveSim != null) sim = PlayerAccount.CurrentlyActiveSim; else //Debugging purposes... { sim.HeadOutfitID = 4462471020557; sim.AppearanceType = AppearanceType.Light; sim.BodyOutfitID = 1507533520909; } SimCatalog.LoadSim3D(sim); //SimCatalog.LoadSim3D(sim, SimCatalog.GetOutfit(4462471020557), AppearanceType.Light); SimBox.Sim = sim; SimBox.SimScale = 0.4f; SimBox.Position = new Microsoft.Xna.Framework.Vector2(60, 153); this.Add(SimBox); SetOpen(false); }
/// <summary> /// Sends a CharacterRetirement packet to the LoginServer, retiring a specific character. /// </summary> /// <param name="Character">The character to retire.</param> public static void SendCharacterRetirement(UISim Character) { PacketStream Packet = new PacketStream((byte)PacketType.RETIRE_CHARACTER, 0); Packet.WriteString(PlayerAccount.Username); Packet.WriteString(Character.GUID.ToString()); NetworkFacade.Client.SendEncrypted((byte)PacketType.RETIRE_CHARACTER, Packet.ToArray()); }
public PersonSelection() { UIScript ui = null; if (GlobalSettings.Default.ScaleUI) { ui = this.RenderScript("personselection.uis"); this.Scale800x600 = true; } else { ui = this.RenderScript("personselection" + (ScreenWidth == 1024 ? "1024" : "") + ".uis"); } m_ExitButton = (UIButton)ui["ExitButton"]; var numSlots = 3; m_PersonSlots = new List<PersonSlot>(); for (var i = 0; i < numSlots; i++) { var index = (i + 1).ToString(); /** Tab Background **/ var tabBackground = ui.Create<UIImage>("TabBackgroundImage" + index); this.Add(tabBackground); var enterTabImage = ui.Create<UIImage>("EnterTabImage" + index); this.Add(enterTabImage); var descTabImage = ui.Create<UIImage>("DescriptionTabImage" + index); this.Add(descTabImage); var descTabBgImage = ui.Create<UIImage>("DescriptionTabBackgroundImage" + index); var enterIcons = ui.Create<UIImage>("EnterTabBackgroundImage" + index); var personSlot = new PersonSlot(this) { AvatarButton = (UIButton)ui["AvatarButton" + index], CityButton = (UIButton)ui["CityButton" + index], HouseButton = (UIButton)ui["HouseButton" + index], EnterTabButton = (UIButton)ui["EnterTabButton" + index], DescTabButton = (UIButton)ui["DescriptionTabButton" + index], NewAvatarButton = (UIButton)ui["NewAvatarButton" + index], DeleteAvatarButton = (UIButton)ui["DeleteAvatarButton" + index], PersonNameText = (UILabel)ui["PersonNameText" + index], PersonDescriptionScrollUpButton = (UIButton)ui["PersonDescriptionScrollUpButton" + index], PersonDescriptionScrollDownButton = (UIButton)ui["PersonDescriptionScrollDownButton" + index], PersonDescriptionSlider = (UISlider)ui["PersonDescriptionSlider" + index], CityNameText = (UILabel)ui["CityNameText" + index], HouseNameText = (UILabel)ui["HouseNameText" + index], PersonDescriptionText = (UITextEdit)ui["PersonDescriptionText" + index], DescriptionTabBackgroundImage = descTabBgImage, EnterTabBackgroundImage = enterIcons, TabBackground = tabBackground, TabEnterBackground = enterTabImage, TabDescBackground = descTabImage }; this.AddBefore(descTabBgImage, personSlot.PersonDescriptionText); this.AddBefore(enterIcons, personSlot.CityButton); personSlot.Init(); personSlot.SetSlotAvailable(true); m_PersonSlots.Add(personSlot); lock (NetworkFacade.Avatars) { if (i < NetworkFacade.Avatars.Count) { personSlot.DisplayAvatar(NetworkFacade.Avatars[i]); personSlot.AvatarButton.OnButtonClick += new ButtonClickDelegate(AvatarButton_OnButtonClick); var SimBox = new UISim(NetworkFacade.Avatars[i].GUID); SimBox.Avatar.Body = NetworkFacade.Avatars[i].Body; SimBox.Avatar.Head = NetworkFacade.Avatars[i].Head; SimBox.Avatar.Handgroup = NetworkFacade.Avatars[i].Body; SimBox.Avatar.Appearance = NetworkFacade.Avatars[i].Avatar.Appearance; SimBox.Position = m_PersonSlots[i].AvatarButton.Position + new Vector2(70, (m_PersonSlots[i].AvatarButton.Size.Y - 35)); SimBox.Size = m_PersonSlots[i].AvatarButton.Size; SimBox.Name = NetworkFacade.Avatars[i].Name; m_UISims.Add(SimBox); this.Add(SimBox); } } } this.AddAt(0, new UIImage(BackgroundImage)); if (BackgroundImageDialog != null) { this.AddAt(1, new UIImage(BackgroundImageDialog) { X = 112, Y = 84 }); } /** * Button plumbing */ CreditsButton.OnButtonClick += new ButtonClickDelegate(CreditsButton_OnButtonClick); m_ExitButton.OnButtonClick += new ButtonClickDelegate(m_ExitButton_OnButtonClick); /** * Music */ var tracks = new string[]{ GlobalSettings.Default.StartupPath + "\\music\\modes\\select\\tsosas1_v2.mp3", GlobalSettings.Default.StartupPath + "\\music\\modes\\select\\tsosas2_v2.mp3", GlobalSettings.Default.StartupPath + "\\music\\modes\\select\\tsosas3.mp3", GlobalSettings.Default.StartupPath + "\\music\\modes\\select\\tsosas4.mp3", GlobalSettings.Default.StartupPath + "\\music\\modes\\select\\tsosas5.mp3" }; PlayBackgroundMusic( tracks ); NetworkFacade.Controller.OnCityToken += new OnCityTokenDelegate(Controller_OnCityToken); NetworkFacade.Controller.OnPlayerAlreadyOnline += new OnPlayerAlreadyOnlineDelegate(Controller_OnPlayerAlreadyOnline); NetworkFacade.Controller.OnCharacterRetirement += new OnCharacterRetirementDelegate(Controller_OnCharacterRetirement); }
/// <summary> /// Display an avatar /// </summary> /// <param name="avatar"></param> public void DisplayAvatar(UISim avatar) { this.Avatar = avatar; SetSlotAvailable(false); PersonNameText.Caption = avatar.Name; PersonDescriptionText.CurrentText = avatar.Description; AvatarButton.Texture = Screen.SimSelectButtonImage; CityNameText.Caption = avatar.ResidingCity.Name; String gamepath = GameFacade.GameFilePath(""); int CityNum = GameFacade.GetCityNumber(avatar.ResidingCity.Name); string CityStr = gamepath + "cities\\" + ((CityNum >= 10) ? "city_00" + CityNum.ToString() : "city_000" + CityNum.ToString()); var stream = new FileStream(CityStr + "\\Thumbnail.bmp", FileMode.Open); Texture2D cityThumbTex = TextureUtils.Resize(GameFacade.GraphicsDevice, ImageLoader.FromStream( GameFacade.Game.GraphicsDevice, stream), 78, 58); stream.Close(); TextureUtils.CopyAlpha(ref cityThumbTex, Screen.CityHouseButtonAlpha); CityThumb.Texture = cityThumbTex; SetTab(PersonSlotTab.EnterTab); }