public static GumpInfo GetInfo(Mobile m, Type type) { if (s_ForceMenu) { if (s_ForceInfos[type] == null) { s_ForceInfos[type] = new GumpInfo(null, type); } return((GumpInfo)s_ForceInfos[type]); } if (s_Infos[m] == null) { s_Infos[m] = new Hashtable(); } Hashtable table = (Hashtable)s_Infos[m]; if (table[type] == null) { table[type] = new GumpInfo(m, type); } return((GumpInfo)table[type]); }
private static void OnSave(WorldSaveEventArgs args) { DateTime time = DateTime.Now; if (Data.Debug) { Console.WriteLine(""); Console.WriteLine(General.Local(241)); } Data.Save(); Channel.Save(); GumpInfo.Save(); foreach (Data data in Data.Datas.Values) { if (data.SevenDays) { foreach (Message msg in new ArrayList(data.Messages)) { if (msg.Received < DateTime.Now - TimeSpan.FromDays(7)) { data.Messages.Remove(msg); } } } } if (Data.Debug) { TimeSpan elapsed = DateTime.Now - time; Console.WriteLine(General.Local(240) + " {0}", (elapsed.Minutes != 0 ? elapsed.Minutes + " minutes" : "") + (elapsed.Seconds != 0 ? elapsed.Seconds + " seconds" : "") + elapsed.Milliseconds + " milliseconds"); } }
private static void OnLoad() { LoadLocalFile(); LoadHelpFile(); LoadFilterFile(); Data.Load(); Channel.Load(); GumpInfo.Load(); if (Data.IrcAutoConnect) { IrcConnection.Connection.Connect(); } }
private void ModifyGump() { try { AddPage(0); int maxWidth = 0; int maxHeight = 0; GumpBackground bg; foreach (GumpEntry entry in Entries) { if (entry is GumpBackground) { bg = (GumpBackground)entry; if (bg.X + bg.Width > maxWidth) { maxWidth = bg.X + bg.Width; } if (bg.Y + bg.Height > maxHeight) { maxHeight = bg.Y + bg.Height; } } } if (Owner.AccessLevel >= AccessLevel.Administrator || !GumpInfo.ForceMenu) { AddImage(maxWidth, maxHeight, 0x28DC, GumpInfo.ForceMenu ? 0x26 : 0x387); AddButton(maxWidth + 10, maxHeight + 4, 0x93A, 0x93A, "Transparency", new GumpCallback(Trans)); AddButton(maxWidth + 10, maxHeight + 15, 0x938, 0x938, "Default", new GumpCallback(Default)); if (Owner.AccessLevel >= AccessLevel.Administrator) { AddButton(maxWidth + 10, maxHeight + 26, 0x82C, 0x82C, "ForceMenu", new GumpCallback(Force)); } AddButton(maxWidth - 5, maxHeight + 2, 0x2626, 0x2627, "BackgroundDown", new GumpCallback(BackDown)); AddButton(maxWidth + 19, maxHeight + 2, 0x2622, 0x2623, "BackgroundUp", new GumpCallback(BackUp)); AddButton(maxWidth - 5, maxHeight + 13, 0x2626, 0x2627, "TextColorDown", new GumpCallback(TextDown)); AddButton(maxWidth + 19, maxHeight + 13, 0x2622, 0x2623, "TextColorUp", new GumpCallback(TextUp)); } if (!GumpInfo.HasMods(c_Owner, GetType())) { return; } ArrayList backs = new ArrayList(); foreach (GumpEntry entry in new ArrayList(Entries)) { if (entry is GumpBackground) { if (entry is BackgroundPlus && !((BackgroundPlus)entry).Override) { continue; } if (Info.Background != -1) { ((GumpBackground)entry).GumpID = Info.Background; } backs.Add(entry); } else if (entry is GumpAlphaRegion && !Info.DefaultTrans && !Info.Transparent) { ((GumpAlphaRegion)entry).Width = 0; ((GumpAlphaRegion)entry).Height = 0; } else if (entry is HtmlPlus) { if (!((HtmlPlus)entry).Override || Info.TextColorRGB == "") { continue; } string text = ((HtmlPlus)entry).Text; int num = 0; int length = 0; char[] chars; if (text == null) { continue; } while ((num = text.ToLower().IndexOf("<basefont")) != -1 || (num = text.ToLower().IndexOf("</font")) != -1) { length = 0; chars = text.ToCharArray(); for (int i = num; i < chars.Length; ++i) { if (chars[i] == '>') { length = i - num + 1; break; } } if (length == 0) { break; } text = text.Substring(0, num) + text.Substring(num + length, text.Length - num - length); } ((HtmlPlus)entry).Text = Info.TextColor + text; } } if (!Info.DefaultTrans && Info.Transparent) { foreach (GumpBackground back in backs) { AddAlphaRegion(back.X, back.Y, back.Width, back.Height); } } SortEntries(); } catch { Errors.Report("GumpPlus-> ModifyGump-> " + GetType()); } }
public static GumpInfo GetInfo( Mobile m, Type type ) { if (s_ForceMenu) { if (s_ForceInfos[type] == null) s_ForceInfos[type] = new GumpInfo(null, type); return (GumpInfo)s_ForceInfos[type]; } if (s_Infos[m] == null) s_Infos[m] = new Hashtable(); Hashtable table = (Hashtable)s_Infos[m]; if (table[type] == null) table[type] = new GumpInfo( m, type ); return (GumpInfo)table[type]; }
public static void Load() { try { if (!File.Exists(Path.Combine(General.SavePath, "Gumps.bin"))) return; using (FileStream bin = new FileStream(Path.Combine(General.SavePath, "Gumps.bin"), FileMode.Open, FileAccess.Read, FileShare.Read)) { GenericReader reader = new BinaryFileReader(new BinaryReader(bin)); int version = reader.ReadInt(); if (version >= 0) { s_ForceMenu = reader.ReadBool(); int count = reader.ReadInt(); GumpInfo info; for (int i = 0; i < count; ++i) { info = new GumpInfo(); info.Load(reader); if (info.Type == null) continue; s_ForceInfos[info.Type] = info; } count = reader.ReadInt(); for (int i = 0; i < count; ++i) { info = new GumpInfo(); info.Load(reader); if (info.Mobile == null || info.Type == null) continue; if (s_Infos[info.Mobile] == null) s_Infos[info.Mobile] = new Hashtable(); ((Hashtable)s_Infos[info.Mobile])[info.Type] = info; } } reader.End(); } } catch (Exception e) { Errors.Report(General.Local(198)); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }
public static void Load() { try { if (!File.Exists(Path.Combine(General.SavePath, "Gumps.bin"))) { return; } using (FileStream bin = new FileStream(Path.Combine(General.SavePath, "Gumps.bin"), FileMode.Open, FileAccess.Read, FileShare.Read)) { GenericReader reader = new BinaryFileReader(new BinaryReader(bin)); int version = reader.ReadInt(); if (version >= 0) { s_ForceMenu = reader.ReadBool(); int count = reader.ReadInt(); GumpInfo info; for (int i = 0; i < count; ++i) { info = new GumpInfo(); info.Load(reader); if (info.Type == null) { continue; } s_ForceInfos[info.Type] = info; } count = reader.ReadInt(); for (int i = 0; i < count; ++i) { info = new GumpInfo(); info.Load(reader); if (info.Mobile == null || info.Type == null) { continue; } if (s_Infos[info.Mobile] == null) { s_Infos[info.Mobile] = new Hashtable(); } ((Hashtable)s_Infos[info.Mobile])[info.Type] = info; } } reader.End(); } } catch (Exception e) { Errors.Report(General.Local(198)); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }