예제 #1
0
 public KeySelector(string name, Microsoft.Xna.Framework.Input.Keys @default)
 {
     InitializeComponent();
     label.Text   = name;
     value        = @default;
     textBox.Text = value.ToString();
 }
        public void DrawRebind(SpriteBatch sb, OptionsMenu.OptionsPage op)
        {
            Rectangle titlePos     = new Rectangle(0, 30, op.getDrawPos().Width, 60);
            Rectangle textPos      = new Rectangle(0, 100, op.getDrawPos().Width, 300);
            Rectangle textUnderPos = new Rectangle(0, 420, op.getDrawPos().Width, 70);
            String    title        = "Default '" + keyAction.actionIndentifierString + "' button is: " + keyAction.defaultKey;
            String    under        = "LMB to confirm change, RMB to cancel change.\nPress LMB without a key to unassign a key.";
            String    text         = "";
            String    warning      = "";

            if (newKey != (default(Microsoft.Xna.Framework.Input.Keys)))
            {
                text = newKey.ToString();
                var replaceKey = Game1.actionKeyList.Find(ak => ak.assignedActionKey == newKey);
                if (replaceKey != null && Game1.actionList.Find(a => a.actionIndentifierString.Equals(replaceKey.actionIndentifierString)).bUsed)
                {
                    warning += "\n\n\nWarning will replace '" + replaceKey.actionIndentifierString + "' Keybind " + (replaceKey.column + 1);
                }
            }
            if (!text.Equals(""))
            {
                TextUtility.Draw(sb, text, font, textPos, TextUtility.OutLining.Center, Color.Gold, 1f, false, default(Matrix), Color.Silver, false);
                if (!warning.Equals(""))
                {
                    TextUtility.Draw(sb, warning, font, textPos, TextUtility.OutLining.Center, Color.Gold, 1f, false, default(Matrix), Color.Silver, false);
                }
            }

            TextUtility.Draw(sb, title, font, titlePos, TextUtility.OutLining.Center, Color.Gold, 1f, false, default(Matrix), Color.Silver, false);
            TextUtility.Draw(sb, under, font, textUnderPos, TextUtility.OutLining.Center, Color.Gold, 1f, false, default(Matrix), Color.Silver, false);
        }
예제 #3
0
 private void InputKeyForm_KeyDown(object sender, KeyEventArgs e)
 {
     if (Enum.TryParse(e.KeyCode.ToString(), out lastKey))
     {
         LabelKey.Text = "Key: " + lastKey.ToString();
     }
 }
예제 #4
0
 private void CatchKeyTextBoxEntered(object sender, EventArgs e)
 {
     using (KeyReader kr = new KeyReader(label.Text))
     {
         value        = kr.ShowSelectDialog();
         textBox.Text = value.ToString();
     }
 }
예제 #5
0
        public static void onKeyPress(Microsoft.Xna.Framework.Input.Keys key)
        {
            if (key.ToString().Equals(CJBCheatsMenu.config.openMenuKey))
            {
                if (Game1.hasLoadedGame && Game1.activeClickableMenu == null)
                {
                    CheatsMenu.Open();
                }
                return;
            }

            if (key.ToString().Equals(CJBCheatsMenu.config.freezeTimeKey))
            {
                if (Game1.hasLoadedGame && Game1.activeClickableMenu == null)
                {
                    CJBCheatsMenu.config.freezeTime = !CJBCheatsMenu.config.freezeTime;
                }
                return;
            }

            if (key.ToString().Equals(CJBCheatsMenu.config.growTreeKey))
            {
                if (Game1.hasLoadedGame && Game1.activeClickableMenu == null)
                {
                    GrowTree();
                }
                return;
            }

            if (key.ToString().Equals(CJBCheatsMenu.config.growCropsKey))
            {
                if (Game1.hasLoadedGame && Game1.activeClickableMenu == null)
                {
                    GrowCrops();
                }
                return;
            }
        }
예제 #6
0
 /// <summary>
 /// Returns the name of a key.
 /// </summary>
 /// <param name="key">The key to get the name for.</param>
 /// <remarks>Returns String.Empty by default.</remarks>
 public static string GetKeyName(Keys key) => key.ToString();
예제 #7
0
        private string getCodeFor(object val)
        {
            if (val == null)
            {
                return("null");
            }

            string typeName = val.GetType().Name;

            if (typeName.Equals(typeof(int).Name) ||
                typeName.Equals(typeof(string).Name) ||
                typeName.Equals(typeof(bool).Name) ||
                typeName.Equals(typeof(float).Name) ||
                typeName.Equals(typeof(double).Name) ||
                typeName.Equals(typeof(Single).Name) ||
                typeName.Equals(typeof(byte).Name) ||
                typeName.Equals(typeof(Int16).Name) ||
                typeName.Equals(typeof(Int32).Name)
                )
            {
                return(stringify(val));
            }

            else if (typeName.Equals(typeof(Vector).Name))
            {
                Vector vec = (Vector)val;
                return("new Vector(" + vec.X + "f, " + vec.Y + "f)");
            }
            else if (typeName.Equals(typeof(Sprite).Name))
            {
                Sprite spr = (Sprite)val;
                return("new Sprite(" + getCodeFor(spr.ImagePath) + ", " + getCodeFor(spr.Scale) + ", " + getCodeFor(spr.Offset) + ", " + getCodeFor(spr.Depth) + ", " + getCodeFor(spr.Color) + ", " + getCodeFor(spr.Rotation) + ")");
            }
            else if (typeName.Equals(typeof(Light).Name))
            {
                Light light = (Light)val;
                return("new Light(" + getCodeFor(light.Position) + ", " + getCodeFor(light.Color) + ", " + getCodeFor(light.Radius) + ", " + getCodeFor(light.Visible) + ")");
            }
            else if (typeName.Equals(typeof(ShadowProperties).Name))
            {
                ShadowProperties shadows = (ShadowProperties)val;
                return("new ShadowProperties(" + getCodeFor(shadows.CastsShadows) + ", " + getCodeFor(shadows.IncludeLight) + ", " + getCodeFor(shadows.SelfShadows) + ", " + getCodeFor(shadows.Solidness) + ", " + getCodeFor(shadows.Height) + ")");
            }
            else if (typeName.Equals(typeof(Color).Name))
            {
                Color col = (Color)val;
                return("new Color(" + col.R + ", " + col.G + ", " + col.B + ", " + col.A + ")");
            }
            else if (typeName.Equals(typeof(Microsoft.Xna.Framework.Input.Keys).Name))
            {
                Microsoft.Xna.Framework.Input.Keys k = (Microsoft.Xna.Framework.Input.Keys)val;
                return("Microsoft.Xna.Framework.Input.Keys." + k.ToString());
            }

            else
            {
                //assume that the val is an instance desc
                return("null");

                //  throw new WhiskeyException("Property is not of supported type: " + val.GetType().Name);
            }
        }