public bool SupportsExpansion(ExpansionInfo info) { return(SupportsExpansion(info, true)); }
public SIMGumpChat(Mobile from, NetState state, string initialText) : base(30, 20) { if (state == null) { return; } m_State = state; AddPage(0); //AddBackground(0, 0, 400, 274, 5054); AddBackground(0, 0, 400, 274, 5054); AddImageTiled(10, 10, 380, 19, 0xA40); AddAlphaRegion(10, 10, 380, 19); AddImageTiled(10, 32, 380, 232, 0xA40); AddAlphaRegion(10, 32, 380, 232); AddHtml(10, 10, 380, 20, Color(Center("User Information"), LabelColor32), false, false); int line = 0; if (from.AccessLevel >= AccessLevel.GameMaster) { AddHtml(14, 36 + (line * 20), 200, 20, Color("Address:", LabelColor32), false, false); AddHtml(70, 36 + (line++ *20), 200, 20, Color(state.ToString(), LabelColor32), false, false); } AddHtml(14, 36 + (line * 20), 200, 20, Color("Client:", LabelColor32), false, false); AddHtml(70, 36 + (line++ *20), 200, 20, Color(state.Version == null ? "(null)" : state.Version.ToString(), LabelColor32), false, false); AddHtml(14, 36 + (line * 20), 200, 20, Color("Version:", LabelColor32), false, false); ExpansionInfo info = state.ExpansionInfo; string expansionName = info.Name; if (info.ID == (int)Expansion.None) { expansionName = (((state.Flags & 0x04) != 0) ? "Blackthorn's Revenge" : ((state.Flags & 0x02) != 0) ? "Third Dawn" : ((state.Flags & 0x01) != 0) ? "Renaissance" : "The Second Age"); } AddHtml(70, 36 + (line++ *20), 200, 20, Color(expansionName, LabelColor32), false, false); Account a = state.Account as Account; Mobile m = state.Mobile; if (from.AccessLevel >= AccessLevel.GameMaster && a != null) { AddHtml(14, 36 + (line * 20), 200, 20, Color("Account:", LabelColor32), false, false); AddHtml(70, 36 + (line++ *20), 200, 20, Color(a.Username, LabelColor32), false, false); } if (m != null) { AddHtml(14, 36 + (line * 20), 200, 20, Color("Mobile:", LabelColor32), false, false); AddHtml(70, 36 + (line++ *20), 200, 20, Color(String.Format("{0} (0x{1:X})", m.Name, m.Serial.Value), LabelColor32), false, false); AddHtml(14, 36 + (line * 20), 200, 20, Color("Location:", LabelColor32), false, false); AddHtml(70, 36 + (line++ *20), 200, 20, Color(String.Format("{0} [{1}]", m.Location, m.Map), LabelColor32), false, false); AddButton(13, 157, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0); AddHtml(48, 158, 200, 20, Color("Send Message", LabelColor32), false, false); AddImageTiled(12, 182, 376, 80, 0xA40); AddImageTiled(13, 183, 374, 78, 0xBBC); AddTextEntry(15, 183, 372, 78, 0x480, 0, ""); AddImageTiled(245, 35, 142, 144, 5058); AddImageTiled(246, 36, 140, 142, 0xA40); AddAlphaRegion(246, 36, 140, 142); line = 0; if (BaseCommand.IsAccessible(from, m) && (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > m.AccessLevel)) { AddButton(246, 36 + (line * 20), 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0); AddHtml(280, 38 + (line++ *20), 100, 20, Color("Properties", LabelColor32), false, false); } if (from != m && (from.AccessLevel >= AccessLevel.Counselor && from.AccessLevel > m.AccessLevel)) { AddButton(246, 36 + (line * 20), 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0); AddHtml(280, 38 + (line++ *20), 100, 20, Color("Go to them", LabelColor32), false, false); } if (from != m && (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > m.AccessLevel)) { AddButton(246, 36 + (line * 20), 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0); AddHtml(280, 38 + (line++ *20), 100, 20, Color("Bring them here", LabelColor32), false, false); } if (from.AccessLevel >= AccessLevel.Counselor && from.AccessLevel > m.AccessLevel) { AddButton(246, 36 + (line * 20), 0xFA5, 0xFA7, 7, GumpButtonType.Reply, 0); AddHtml(280, 38 + (line++ *20), 100, 20, Color("Move to target", LabelColor32), false, false); } if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > m.AccessLevel) { AddButton(246, 36 + (line * 20), 0xFA5, 0xFA7, 8, GumpButtonType.Reply, 0); AddHtml(280, 38 + (line++ *20), 100, 20, Color("Disconnect", LabelColor32), false, false); } if (m.Alive && (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > m.AccessLevel)) { AddButton(246, 36 + (line * 20), 0xFA5, 0xFA7, 9, GumpButtonType.Reply, 0); AddHtml(280, 38 + (line++ *20), 100, 20, Color("Kill", LabelColor32), false, false); } else { if (from.AccessLevel >= AccessLevel.Counselor && from.AccessLevel > m.AccessLevel) { AddButton(246, 36 + (line * 20), 0xFA5, 0xFA7, 10, GumpButtonType.Reply, 0); AddHtml(280, 38 + (line++ *20), 100, 20, Color("Resurrect", LabelColor32), false, false); } } if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > m.AccessLevel) { AddButton(246, 36 + (line * 20), 0xFA5, 0xFA7, 11, GumpButtonType.Reply, 0); AddHtml(280, 38 + (line++ *20), 100, 20, Color("Skills browser", LabelColor32), false, false); } } }
public void TestCharacterListOld() { var firstMobile = new Mobile(0x1); firstMobile.DefaultMobileInit(); firstMobile.Name = "Test Mobile"; var account = new TestAccount(new[] { firstMobile, null, null, null, null }); var info = new[] { new CityInfo("Test City", "Test Building", 50, 100, 10, -10) }; var data = new CharacterListOld(account, info).Compile(); Span <byte> expectedData = stackalloc byte[9 + account.Length * 60 + info.Length * 63]; var pos = 0; expectedData.Write(ref pos, (byte)0xA9); // Packet ID expectedData.Write(ref pos, (ushort)expectedData.Length); // Length var highSlot = -1; for (var i = account.Length - 1; i >= 0; i--) { if (account[i] != null) { highSlot = i; break; } } var count = Math.Max(Math.Max(highSlot + 1, account.Limit), 5); expectedData.Write(ref pos, (byte)count); for (var i = 0; i < count; i++) { var m = account[i]; if (m != null) { expectedData.WriteAsciiFixed(ref pos, m.Name, 30); #if NO_LOCAL_INIT expectedData.Write(ref pos, (ulong)0); expectedData.Write(ref pos, (ulong)0); expectedData.Write(ref pos, (ulong)0); expectedData.Write(ref pos, 0); expectedData.Write(ref pos, (ushort)0); #else pos += 30; #endif } else { #if NO_LOCAL_INIT expectedData.Write(ref pos, (ulong)0); expectedData.Write(ref pos, (ulong)0); expectedData.Write(ref pos, (ulong)0); expectedData.Write(ref pos, (ulong)0); expectedData.Write(ref pos, (ulong)0); expectedData.Write(ref pos, (ulong)0); expectedData.Write(ref pos, (ulong)0); expectedData.Write(ref pos, 0); #else pos += 60; #endif } } expectedData.Write(ref pos, (byte)info.Length); for (var i = 0; i < info.Length; i++) { var ci = info[i]; expectedData.Write(ref pos, (byte)i); expectedData.WriteAsciiFixed(ref pos, ci.City, 31); expectedData.WriteAsciiFixed(ref pos, ci.Building, 31); } var flags = ExpansionInfo.GetInfo(Expansion.EJ).CharacterListFlags; if (count > 6) { flags |= CharacterListFlags.SeventhCharacterSlot | CharacterListFlags.SixthCharacterSlot; // 7th Character Slot } else if (count == 6) { flags |= CharacterListFlags.SixthCharacterSlot; // 6th Character Slot } else if (account.Limit == 1) { flags |= CharacterListFlags.SlotLimit & CharacterListFlags.OneCharacterSlot; // Limit Characters & One Character } expectedData.Write(ref pos, (int)flags); AssertThat.Equal(data, expectedData); }
public bool SupportsExpansion(Expansion ex, bool checkCoreExpansion) { return(SupportsExpansion(ExpansionInfo.GetInfo(ex), checkCoreExpansion)); }
public ClientGump(Mobile from, NetState state, string initialText) : base(30, 20) { if (state == null) { return; } m_State = state; AddPage(0); AddBackground(0, 0, 400, 274, 5054); AddImageTiled(10, 10, 380, 19, 0xA40); AddAlphaRegion(10, 10, 380, 19); AddImageTiled(10, 32, 380, 232, 0xA40); AddAlphaRegion(10, 32, 380, 232); AddHtml(10, 10, 380, 20, Color(Center("User Information"), LabelColor32), false, false); int line = 0; AddHtml(14, 36 + line * 20, 200, 20, Color("Address:", LabelColor32), false, false); AddHtml(70, 36 + line++ *20, 200, 20, Color(state.ToString(), LabelColor32), false, false); AddHtml(14, 36 + line * 20, 200, 20, Color("Client:", LabelColor32), false, false); AddHtml(70, 36 + line++ *20, 200, 20, Color(state.Version == null ? "(null)" : state.Version.ToString(), LabelColor32), false, false); AddHtml(14, 36 + line * 20, 200, 20, Color("Version:", LabelColor32), false, false); ExpansionInfo info = state.ExpansionInfo; string expansionName = info.Name; AddHtml(70, 36 + line++ *20, 200, 20, Color(expansionName, LabelColor32), false, false); Account a = state.Account as Account; Mobile m = state.Mobile; if (from.AccessLevel >= AccessLevel.GameMaster && a != null) { AddHtml(14, 36 + line * 20, 200, 20, Color("Account:", LabelColor32), false, false); AddHtml(70, 36 + line++ *20, 200, 20, Color(a.Username, LabelColor32), false, false); } if (m != null) { AddHtml(14, 36 + line * 20, 200, 20, Color("Mobile:", LabelColor32), false, false); AddHtml(70, 36 + line++ *20, 200, 20, Color($"{m.Name} (0x{m.Serial.Value:X})", LabelColor32), false, false); AddHtml(14, 36 + line * 20, 200, 20, Color("Location:", LabelColor32), false, false); AddHtml(70, 36 + line++ *20, 200, 20, Color($"{m.Location} [{m.Map}]", LabelColor32), false, false); AddButton(13, 157, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0); AddHtml(48, 158, 200, 20, Color("Send Message", LabelColor32), false, false); AddImageTiled(12, 182, 376, 80, 0xA40); AddImageTiled(13, 183, 374, 78, 0xBBC); AddTextEntry(15, 183, 372, 78, 0x480, 0, ""); AddImageTiled(245, 35, 142, 144, 5058); AddImageTiled(246, 36, 140, 142, 0xA40); AddAlphaRegion(246, 36, 140, 142); line = 0; if (BaseCommand.IsAccessible(from, m)) { AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0); AddHtml(280, 38 + line++ *20, 100, 20, Color("Properties", LabelColor32), false, false); } if (from != m) { AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0); AddHtml(280, 38 + line++ *20, 100, 20, Color("Go to them", LabelColor32), false, false); AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0); AddHtml(280, 38 + line++ *20, 100, 20, Color("Bring them here", LabelColor32), false, false); } AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 7, GumpButtonType.Reply, 0); AddHtml(280, 38 + line++ *20, 100, 20, Color("Move to target", LabelColor32), false, false); if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > m.AccessLevel) { AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 8, GumpButtonType.Reply, 0); AddHtml(280, 38 + line++ *20, 100, 20, Color("Disconnect", LabelColor32), false, false); if (m.Alive) { AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 9, GumpButtonType.Reply, 0); AddHtml(280, 38 + line++ *20, 100, 20, Color("Kill", LabelColor32), false, false); } else { AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 10, GumpButtonType.Reply, 0); AddHtml(280, 38 + line++ *20, 100, 20, Color("Resurrect", LabelColor32), false, false); } } if (from.AccessLevel >= AccessLevel.Counselor && from.AccessLevel > m.AccessLevel) { AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 11, GumpButtonType.Reply, 0); AddHtml(280, 38 + line++ *20, 100, 20, Color("Skills browser", LabelColor32), false, false); } } }
private object RequiredExpansionMessage(Expansion expansion) //Eventually convert to TextDefinition, but that requires that we convert all the gumps to ues it too. Not that it wouldn't be a bad idea. { switch (expansion) { case Expansion.SE: return(1063307); // The "Samurai Empire" expansion is required to attempt this item. case Expansion.ML: return(1072650); // The "Mondain's Legacy" expansion is required to attempt this item. default: return(String.Format("The \"{0}\" expansion is required to attempt this item.", ExpansionInfo.GetInfo(expansion).Name)); } }
public bool SupportsExpansion(Expansion ex) { return(SupportsExpansion(ExpansionInfo.GetInfo(ex))); }
// ReSharper disable once UnusedMethodReturnValue.Local private bool UploadApk(string apkFileName, string expansionFileName, string track, List <UpdateInfo> apkChanges) { if (_serviceThread != null) { return(false); } if (!File.Exists(apkFileName)) { UpdateStatus("Apk file not existing"); return(false); } if (!string.IsNullOrEmpty(expansionFileName)) { if (expansionFileName != ExpansionKeep) { if (!File.Exists(expansionFileName)) { UpdateStatus("Expansion file not existing"); return(false); } } } UpdateStatus(string.Empty); _cts = new CancellationTokenSource(); _serviceThread = new Thread(async() => { UpdateStatus(string.Empty); StringBuilder sb = new StringBuilder(); try { if (apkChanges != null) { sb.Append("Changes info for languages: "); foreach (UpdateInfo updateInfo in apkChanges) { sb.Append($"{updateInfo.Language} "); } sb.AppendLine(); UpdateStatus(sb.ToString()); } UserCredential credential = await GetCredatials(); using (AndroidPublisherService service = new AndroidPublisherService(GetInitializer(credential))) { EditsResource edits = service.Edits; EditsResource.InsertRequest editRequest = edits.Insert(null, PackageName); AppEdit appEdit = await editRequest.ExecuteAsync(_cts.Token); bool reuseExpansion = false; ExpansionInfo expansionInfo = await GetNewestExpansionFile(edits, appEdit); if (expansionInfo != null) { sb.AppendLine($"Latest expansion: apk version={expansionInfo.ApkVersion}, expansion version={expansionInfo.ExpansionVersion}, size={expansionInfo.FileSize}"); if (!string.IsNullOrEmpty(expansionFileName)) { if (expansionFileName == ExpansionKeep) { sb.AppendLine("Reusing old expansion file"); reuseExpansion = true; } else { FileInfo fileInfo = new FileInfo(expansionFileName); if (fileInfo.Exists && fileInfo.Length == expansionInfo.FileSize) { sb.AppendLine("Size unchanged, reusing old expansion file"); reuseExpansion = true; } } } } Apk apkUploaded = null; using (FileStream apkStream = new FileStream(apkFileName, FileMode.Open, FileAccess.Read)) { long fileLength = (apkStream.Length > 0) ? apkStream.Length : 1; EditsResource.ApksResource.UploadMediaUpload upload = edits.Apks.Upload(PackageName, appEdit.Id, apkStream, "application/vnd.android.package-archive"); upload.ChunkSize = ResumableUpload.MinimumChunkSize; upload.ProgressChanged += progress => { UpdateStatus(sb.ToString() + $"Apk progress: {100 * progress.BytesSent / fileLength}%"); }; upload.ResponseReceived += apk => { apkUploaded = apk; }; IUploadProgress uploadProgress = await upload.UploadAsync(_cts.Token); sb.AppendLine($"Upload status: {uploadProgress.Status.ToString()}"); UpdateStatus(sb.ToString()); if (uploadProgress.Exception != null) { throw uploadProgress.Exception; } } int?versionCode = apkUploaded?.VersionCode; if (!versionCode.HasValue) { throw new Exception("No apk version code"); } sb.AppendLine($"Version code uploaded: {versionCode.Value}"); UpdateStatus(sb.ToString()); if (!string.IsNullOrEmpty(expansionFileName) && !reuseExpansion) { using (FileStream expansionStream = new FileStream(expansionFileName, FileMode.Open, FileAccess.Read)) { long fileLength = (expansionStream.Length > 0) ? expansionStream.Length : 1; EditsResource.ExpansionfilesResource.UploadMediaUpload upload = edits.Expansionfiles.Upload(PackageName, appEdit.Id, versionCode.Value, EditsResource.ExpansionfilesResource.UploadMediaUpload.ExpansionFileTypeEnum.Main, expansionStream, "application/octet-stream"); upload.ChunkSize = ResumableUpload.MinimumChunkSize; upload.ProgressChanged += progress => { UpdateStatus(sb.ToString() + $"Expansion progress: {100 * progress.BytesSent / fileLength}%"); }; IUploadProgress uploadProgress = await upload.UploadAsync(_cts.Token); sb.AppendLine($"Upload status: {uploadProgress.Status.ToString()}"); UpdateStatus(sb.ToString()); if (uploadProgress.Exception != null) { throw uploadProgress.Exception; } } } else { if (expansionInfo != null) { ExpansionFile expansionRef = new ExpansionFile { ReferencesVersion = expansionInfo.ExpansionVersion }; await edits.Expansionfiles.Update(expansionRef, PackageName, appEdit.Id, versionCode.Value, EditsResource.ExpansionfilesResource.UpdateRequest.ExpansionFileTypeEnum.Main).ExecuteAsync(_cts.Token); sb.AppendLine($"Expansion version {expansionInfo.ExpansionVersion} assigned"); } else { sb.AppendLine("No existing expansion found!"); } } Track updateTrack = new Track { VersionCodes = new List <int?> { versionCode.Value } }; EditsResource.TracksResource.UpdateRequest updateRequest = edits.Tracks.Update(updateTrack, PackageName, appEdit.Id, track); Track updatedTrack = await updateRequest.ExecuteAsync(_cts.Token); sb.AppendLine($"Track updated: {updatedTrack.TrackValue}"); UpdateStatus(sb.ToString()); if (apkChanges != null) { foreach (UpdateInfo updateInfo in apkChanges) { ApkListing apkListing = new ApkListing { RecentChanges = updateInfo.Changes }; await edits.Apklistings.Update(apkListing, PackageName, appEdit.Id, versionCode.Value, updateInfo.Language).ExecuteAsync(_cts.Token); sb.AppendLine($"Changes for language {updateInfo.Language} updated"); UpdateStatus(sb.ToString()); } } EditsResource.CommitRequest commitRequest = edits.Commit(PackageName, appEdit.Id); AppEdit appEditCommit = await commitRequest.ExecuteAsync(_cts.Token); sb.AppendLine($"App edit committed: {appEditCommit.Id}"); UpdateStatus(sb.ToString()); } } catch (Exception e) { sb.AppendLine($"Exception: {e.Message}"); } finally { _serviceThread = null; _cts.Dispose(); UpdateStatus(sb.ToString()); } }); _serviceThread.Start(); return(true); }
protected override void OnExpansionChanged(Expansion old) { base.OnExpansionChanged(old); if (ExpansionInfo.GetInfo(Expansion).Name != "Third Dawn") { this.SendNotification <ExpansionNotifyGump>( String.Format( "You are now bound by the rules and physics of the [b]{0}[/b] era!", ExpansionInfo.GetInfo(Expansion).Name), true, 1.0, 10.0, Color.LawnGreen); } else { this.SendNotification <ExpansionNotifyGump>( String.Format( "Welcome to Zombie Land!"), true, 1.0, 10.0, Color.LawnGreen); } if (Expansion <= Expansion.T2A && AccessLevel < AccessLevel.Counselor || Expansion == Expansion.UOTD && AccessLevel < AccessLevel.Counselor) { BaseMount.SetMountPrevention(this, BlockMountType.MapRestricted, TimeSpan.FromDays(365)); } else { BaseMount.ClearMountPrevention(this); } if (!Snapshot.Pull(old)) { return; } var leaveEquip = new List <Item>(); if (Alive) { leaveEquip.AddRange( Items.Where(i => i != null && !i.Deleted && i.IsPhased && i != BankBox && i != Backpack)); } foreach (Item item in leaveEquip) { Backpack.DropItem(item); } Item holding = Holding; if (holding != null) { if (!holding.Deleted && holding.HeldBy == this && holding.Map == Map.Internal) { Backpack.DropItem(holding); } Holding = null; holding.ClearBounce(); } Dictionary <Item, Point3D> takePack = Backpack.FindItemsByType <Item>(true, i => i != null && !i.Deleted && !i.IsPhased) .ToDictionary(i => i, i => i.Location); if (!Snapshot.Push(Expansion)) { foreach (Item item in leaveEquip) { EquipItem(item); } return; } foreach (Item item in leaveEquip) { Send(item.RemovePacket); } foreach (KeyValuePair <Item, Point3D> kv in takePack) { Backpack.DropItem(kv.Key); kv.Key.Location = kv.Value; } UpdateTotals(); ProcessDelta(); SendMessage(0x22, "Character snapshots synced successfully."); }