예제 #1
0
        private void RenderRangeButton(RangeButton btn)
        {
            if (State == null || btn.Texture < 0 || State.Axes.Count <= btn.Id)
            {
                return;
            }
            double val = State.Axes[btn.Id] * 128.0;

            if (btn.VisibleFrom <= val && val <= btn.VisibleTo)
            {
                GL.BindTexture(TextureTarget.Texture2D, btn.Texture);
                TextureHelper.RenderTexture(Scale(btn.Location, btn.Size));
            }
        }
예제 #2
0
        void ReleaseDesignerOutlets()
        {
            if (AreaButton != null)
            {
                AreaButton.Dispose();
                AreaButton = null;
            }

            if (BackgroundView != null)
            {
                BackgroundView.Dispose();
                BackgroundView = null;
            }

            if (CastingTimeButton != null)
            {
                CastingTimeButton.Dispose();
                CastingTimeButton = null;
            }

            if (DescriptionButton != null)
            {
                DescriptionButton.Dispose();
                DescriptionButton = null;
            }

            if (DescriptorButton != null)
            {
                DescriptorButton.Dispose();
                DescriptorButton = null;
            }

            if (DismissableButton != null)
            {
                DismissableButton.Dispose();
                DismissableButton = null;
            }

            if (DivineFocusButton != null)
            {
                DivineFocusButton.Dispose();
                DivineFocusButton = null;
            }

            if (DurationButton != null)
            {
                DurationButton.Dispose();
                DurationButton = null;
            }

            if (FocusButton != null)
            {
                FocusButton.Dispose();
                FocusButton = null;
            }

            if (FocusTextButton != null)
            {
                FocusTextButton.Dispose();
                FocusTextButton = null;
            }

            if (LevelsButton != null)
            {
                LevelsButton.Dispose();
                LevelsButton = null;
            }

            if (MaterialButton != null)
            {
                MaterialButton.Dispose();
                MaterialButton = null;
            }

            if (MaterialTextButton != null)
            {
                MaterialTextButton.Dispose();
                MaterialTextButton = null;
            }

            if (NameButton != null)
            {
                NameButton.Dispose();
                NameButton = null;
            }

            if (RangeButton != null)
            {
                RangeButton.Dispose();
                RangeButton = null;
            }

            if (SavingThrowButton != null)
            {
                SavingThrowButton.Dispose();
                SavingThrowButton = null;
            }

            if (SchoolButton != null)
            {
                SchoolButton.Dispose();
                SchoolButton = null;
            }

            if (SomaticButton != null)
            {
                SomaticButton.Dispose();
                SomaticButton = null;
            }

            if (SpellResistanceButton != null)
            {
                SpellResistanceButton.Dispose();
                SpellResistanceButton = null;
            }

            if (SubschoolButton != null)
            {
                SubschoolButton.Dispose();
                SubschoolButton = null;
            }

            if (TargetsButton != null)
            {
                TargetsButton.Dispose();
                TargetsButton = null;
            }

            if (VerbalButton != null)
            {
                VerbalButton.Dispose();
                VerbalButton = null;
            }
        }
예제 #3
0
        public void Load(string xmlPath)
        {
            this.Path  = xmlPath;
            LoadResult = SkinLoadResult.Fail;
            try {
                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(xmlPath);
                WorkingDir = System.IO.Path.GetDirectoryName(xmlPath);
                var xroot = xdoc["skin"];

                this.Name = xroot.Attributes["name"].Value;

                string cTypeStr = xroot.Attributes["type"].Value;
                // see if a mapping is defined for this controller type
                if (!NintendoSpyMapping.TypeMap.ContainsKey(cTypeStr))
                {
                    return;
                }

                // retrieve the mapping to munia indices
                var cType = NintendoSpyMapping.TypeMap[cTypeStr];
                Controllers.Add(cType);
                var mapping = NintendoSpyMapping.ControllerMaps[cType];

                foreach (XmlNode xnode in xroot)
                {
                    // read the background
                    if (xnode.Name == "background")
                    {
                        var bg = new NSpyBackground();
                        bg.Name              = xnode.Attributes["name"].Value;
                        bg.ImagePath         = System.IO.Path.Combine(WorkingDir, xnode.Attributes["image"].Value);
                        Backgrounds[bg.Name] = bg;
                    }

                    // read the buttons
                    else if (xnode.Name == "button")
                    {
                        var btn = new Button();
                        btn.Id = mapping.ButtonMap[xnode.Attributes["name"].Value];
                        btn.ReadConfig(this, xnode);
                        Buttons.Add(btn);
                    }

                    else if (xnode.Name == "rangebutton")
                    {
                        var btn = new RangeButton();
                        btn.Id = mapping.ButtonMap[xnode.Attributes["name"].Value];
                        btn.ReadConfig(this, xnode);
                        btn.VisibleFrom = double.Parse(xnode.Attributes["from"].Value);
                        btn.VisibleTo   = double.Parse(xnode.Attributes["to"].Value);
                        RangeButtons.Add(btn);
                    }

                    // read the triggers
                    else if (xnode.Name == "analog")
                    {
                        var trigg = new Trigger();
                        trigg.Id = mapping.AxisMap[xnode.Attributes["name"].Value];
                        trigg.ReadConfig(this, xnode);
                        string direction = xnode.Attributes["direction"].Value.ToLower();

                        // nspy reverse/inverse is slightly different, mapping below makes rendering identical to SvgSkin
                        trigg.Orientation = direction == "left" || direction == "right" ? TriggerOrientation.Horizontal : TriggerOrientation.Vertical;

                        // our reverse means filling from left-to-right or bottom-to-top
                        trigg.Reverse = direction == "left" || direction == "up";

                        if (xnode.Attributes["reverse"] != null)
                        {
                            bool rev = bool.Parse(xnode.Attributes["reverse"].Value);
                            // nspy 'reverse' is our inverse, but should be considered as another flip for right-to-left or bottom-to-top
                            trigg.Reverse ^= rev;
                            trigg.Inverse  = rev;
                        }
                        Triggers.Add(trigg);
                    }

                    // read the sticks
                    else if (xnode.Name == "stick")
                    {
                        var stick = new Stick();
                        if (mapping.AxisMap.ContainsKey(xnode.Attributes["xname"].Value))
                        {
                            stick.HorizontalAxis = mapping.AxisMap[xnode.Attributes["xname"].Value];
                        }
                        if (mapping.AxisMap.ContainsKey(xnode.Attributes["yname"].Value))
                        {
                            stick.VerticalAxis = mapping.AxisMap[xnode.Attributes["yname"].Value];
                        }

                        stick.ReadConfig(this, xnode);
                        stick.XReverse = bool.Parse(xnode.Attributes["xreverse"]?.Value ?? "false");
                        stick.YReverse = bool.Parse(xnode.Attributes["yreverse"]?.Value ?? "false");
                        stick.XRange   = int.Parse(xnode.Attributes["xrange"].Value);
                        stick.YRange   = int.Parse(xnode.Attributes["yrange"].Value);
                        Sticks.Add(stick);
                    }

                    // read the detail items
                    else if (xnode.Name == "detail")
                    {
                        var detail = new Detail();
                        detail.ReadConfig(this, xnode);
                        detail.Targets = xnode.Attributes["target"].Value.Split(';').ToList();
                        Details.Add(detail);
                    }
                }

                SelectedBackground = Backgrounds.First().Value;

                LoadResult = SkinLoadResult.Ok;
            }
            catch {
            }
        }
예제 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.SpellEditor);

            OKButton.Click     += OKButton_Click;
            CancelButton.Click += CancelButton_Click;

            NameText.AttachEditTextString(spell, "Name");
            MaterialText.AttachEditTextString(spell.Adjuster, "MaterialText");
            FocusText.AttachEditTextString(spell.Adjuster, "FocusText");
            DescriptionText.AttachEditTextString(spell, "description");

            DismissibleCheckbox.AttachBool(spell.Adjuster, "Dismissible");
            VerbalCheckbox.AttachBool(spell.Adjuster, "Verbal");
            SomaticCheckbox.AttachBool(spell.Adjuster, "Somatic");
            FocusCheckbox.AttachBool(spell.Adjuster, "Focus");
            DivineFocusCheckbox.AttachBool(spell.Adjuster, "DivineFocus");

            SchoolButton.AttachButtonStringList(spell, "school", Spell.Schools);
            SubschoolButton.AttachTextCombo(spell, "subschool", Spell.Subschools);
            DescriptorButton.AttachTextCombo(spell, "descriptor", Spell.Descriptors);

            CastingTimeButton.AttachTextCombo(spell, "casting_time", Spell.CastingTimeOptions);
            RangeButton.AttachTextCombo(spell, "range", Spell.RangeOptions);
            AreaButton.AttachTextCombo(spell, "area", Spell.AreaOptions);
            TargetsButton.AttachTextCombo(spell, "targets", Spell.TargetsOptions);
            DurationButton.AttachTextCombo(spell, "duration", Spell.DurationOptions);
            SavingThrowButton.AttachTextCombo(spell, "saving_throw", Spell.SavingThrowOptions);
            SpellResistanceButton.AttachTextCombo(spell, "spell_resistence", Spell.SpellResistanceOptions);


            SpellLevelListView.Adapter = new SpellLevelAdapter(this, SpellLevelListView.Context);

            AddSpellLevelButton.Click += (sender, e) =>
            {
                var avList = from className in Spell.SpellAdjuster.Classes.Values
                             where !spell.Adjuster.ContainsClass(className)
                             select className;

                List <string> availableLevels = new List <string>();
                availableLevels.AddRange(avList);
                availableLevels.Sort();

                UIUtils.ShowListPopover(AddSpellLevelButton, "Class", availableLevels, (item) =>
                {
                    String newClass = availableLevels[item];
                    var lai         = new Spell.SpellAdjuster.LevelAdjusterInfo()
                    {
                        Class = newClass, Level = 1
                    };
                    spell.Adjuster.Levels.Add(lai);

                    SpellLevelListView.Adapter = new SpellLevelAdapter(this, SpellLevelListView.Context);
                });
            };

            spell.PropertyChanged += (sender, e) =>
            {
                UpdateOK();
            };
            spell.Adjuster.PropertyChanged += (sender, e) =>
            {
                UpdateOK();
            };

            UpdateOK();
        }