示例#1
0
 public void Clear()
 {
     Arguments.Clear();
     Switches.Clear();
     ArgumentMap.Clear();
     SwitchMap.Clear();
 }
示例#2
0
        public override void Dispose()
        {
            ButtonMap.Clear();
            ButtonMap = null;

            SwitchMap.Clear();
            SwitchMap = null;

            TextMap.Clear();
            TextMap = null;

            Desktop = null;

            _Compiled = null;
            _Buffer   = null;

            _TypeID  = -1;
            _Handler = null;

            base.Dispose();
        }
示例#3
0
        public static SwitchMap <T, U> Map <T, U>(this T input, T key, U output)
        {
            var dict = new SwitchMap <T, U>(input);

            return(dict.Map(key, output));
        }
示例#4
0
        public DesktopGumpEntry(DesktopGump dt, Gump gump, bool focus)
        {
            Desktop = dt;

            _TypeID  = gump.TypeID;
            _Handler = gump.OnResponse;

            if (focus)
            {
                ButtonMap = new Dictionary <int, int>();
                SwitchMap = new Dictionary <int, int>();
                TextMap   = new Dictionary <int, int>();
            }

            var entries = gump.Entries.Not(e => e is GumpModal).ToList();

            var esc = false;

            foreach (var e in entries)
            {
                bool pos;
                int  x, y;

                if (e.TryGetPosition(out x, out y))
                {
                    pos = true;
                    e.TrySetPosition(gump.X + x, gump.Y + y);
                }
                else
                {
                    pos = false;
                }

                e.Parent = Desktop;

                try
                {
                    if (e is GumpButton)
                    {
                        var b = (GumpButton)e;

                        if (focus && b.Type == GumpButtonType.Reply)
                        {
                            ButtonMap[Desktop.NewButtonID()] = b.ButtonID;

                            b.ButtonID = ButtonMap.GetKey(b.ButtonID);
                            _Compiled += b.Compile();
                            b.ButtonID = ButtonMap[b.ButtonID];
                        }
                        else
                        {
                            _Compiled += new GumpImage(b.X, b.Y, b.NormalID)
                            {
                                Parent = Desktop
                            }.Compile();
                        }
                    }
                    else if (e is GumpImageTileButton)
                    {
                        var b = (GumpImageTileButton)e;

                        if (focus && b.Type == GumpButtonType.Reply)
                        {
                            ButtonMap[Desktop.NewButtonID()] = b.ButtonID;

                            b.ButtonID = ButtonMap.GetKey(b.ButtonID);
                            _Compiled += b.Compile();
                            b.ButtonID = ButtonMap[b.ButtonID];
                        }
                        else
                        {
                            _Compiled += new GumpImage(b.X, b.Y, b.NormalID)
                            {
                                Parent = Desktop
                            }.Compile();
                        }
                    }
                    else if (e is GumpCheck)
                    {
                        var c = (GumpCheck)e;

                        if (focus)
                        {
                            SwitchMap[Desktop.NewSwitchID()] = c.SwitchID;

                            c.SwitchID = SwitchMap.GetKey(c.SwitchID);
                            _Compiled += c.Compile();
                            c.SwitchID = SwitchMap[c.SwitchID];
                        }
                        else
                        {
                            _Compiled += new GumpImage(c.X, c.Y, c.InitialState ? c.ActiveID : c.InactiveID)
                            {
                                Parent = Desktop
                            }.Compile();
                        }
                    }
                    else if (e is GumpRadio)
                    {
                        var r = (GumpRadio)e;

                        if (focus)
                        {
                            SwitchMap[Desktop.NewSwitchID()] = r.SwitchID;

                            r.SwitchID = SwitchMap.GetKey(r.SwitchID);
                            _Compiled += r.Compile();
                            r.SwitchID = SwitchMap[r.SwitchID];
                        }
                        else
                        {
                            _Compiled += new GumpImage(r.X, r.Y, r.InitialState ? r.ActiveID : r.InactiveID)
                            {
                                Parent = Desktop
                            }.Compile();
                        }
                    }
                    else if (e is GumpTextEntry)
                    {
                        var t = (GumpTextEntry)e;

                        if (focus)
                        {
                            TextMap[Desktop.NewTextEntryID()] = t.EntryID;

                            t.EntryID  = TextMap.GetKey(t.EntryID);
                            _Compiled += t.Compile();
                            t.EntryID  = TextMap[t.EntryID];
                        }
                        else
                        {
                            _Compiled += new GumpLabelCropped(t.X, t.Y, t.Width, t.Height, t.Hue, t.InitialText)
                            {
                                Parent = Desktop
                            }.Compile();
                        }
                    }
                    else if (e is GumpTextEntryLimited)
                    {
                        var t = (GumpTextEntryLimited)e;

                        if (focus)
                        {
                            TextMap[Desktop.NewTextEntryID()] = t.EntryID;

                            t.EntryID  = TextMap.GetKey(t.EntryID);
                            t.Parent   = Desktop;
                            _Compiled += t.Compile();
                            t.EntryID  = TextMap[t.EntryID];
                        }
                        else
                        {
                            _Compiled += new GumpLabelCropped(t.X, t.Y, t.Width, t.Height, t.Hue, t.InitialText)
                            {
                                Parent = Desktop
                            }.Compile();
                        }
                    }
                    else if (e is GumpPage)
                    {
                        var p = (GumpPage)e;

                        if (p.Page > 0)
                        {
                            esc = true;
                        }
                    }
                    else
                    {
                        _Compiled += e.Compile();
                    }
                }
                catch
                { }

                e.Parent = gump;

                if (pos)
                {
                    e.TrySetPosition(x, y);
                }

                if (esc)
                {
                    break;
                }
            }

            entries.Free(true);

            if (String.IsNullOrWhiteSpace(_Compiled))
            {
                _Compiled = "{{ gumptooltip -1 }}";
            }

            _Buffer = Gump.StringToBuffer(_Compiled);
        }
示例#5
0
 private static void OnFinishLevel(ColliderBase sender, ColliderBase collider)
 {
     CurrentLevel++;
     SwitchMap?.Invoke(null, EventArgs.Empty);
 }