Input: Integer button codes are still allowed in RGSS3
This commit is contained in:
parent
6c92101e05
commit
685f8b63b3
|
@ -38,17 +38,22 @@ static int getButtonArg(int argc, VALUE *argv)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
if (rgssVer >= 3)
|
rb_check_argc(argc, 1);
|
||||||
{
|
|
||||||
ID sym;
|
|
||||||
rb_get_args(argc, argv, "n", &sym RB_ARG_END);
|
|
||||||
|
|
||||||
|
if (FIXNUM_P(argv[0]))
|
||||||
|
{
|
||||||
|
num = FIX2INT(argv[0]);
|
||||||
|
}
|
||||||
|
else if (SYMBOL_P(argv[0]) && rgssVer >= 3)
|
||||||
|
{
|
||||||
VALUE symHash = getRbData()->buttoncodeHash;
|
VALUE symHash = getRbData()->buttoncodeHash;
|
||||||
num = FIX2INT(rb_hash_lookup2(symHash, ID2SYM(sym), INT2FIX(Input::None)));
|
num = FIX2INT(rb_hash_lookup2(symHash, argv[0], INT2FIX(Input::None)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rb_get_args(argc, argv, "i", &num RB_ARG_END);
|
// FIXME: RMXP allows only few more types that
|
||||||
|
// don't make sense (symbols in pre 3, floats)
|
||||||
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
|
|
|
@ -40,20 +40,26 @@ MRB_FUNCTION(inputUpdate)
|
||||||
static mrb_int getButtonArg(mrb_state *mrb)
|
static mrb_int getButtonArg(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
mrb_int num;
|
mrb_int num;
|
||||||
|
mrb_value arg;
|
||||||
|
|
||||||
if (rgssVer >= 3)
|
mrb_get_args(mrb, "o", &arg);
|
||||||
|
|
||||||
|
if (mrb_fixnum_p(arg))
|
||||||
|
{
|
||||||
|
num = mrb_fixnum(arg);
|
||||||
|
}
|
||||||
|
else if (mrb_symbol_p(arg) && rgssVer >= 3)
|
||||||
{
|
{
|
||||||
mrb_sym sym;
|
|
||||||
mrb_get_args(mrb, "n", &sym);
|
|
||||||
|
|
||||||
mrb_value symHash = getMrbData(mrb)->buttoncodeHash;
|
mrb_value symHash = getMrbData(mrb)->buttoncodeHash;
|
||||||
mrb_value numVal = mrb_hash_fetch(mrb, symHash, mrb_symbol_value(sym),
|
mrb_value numVal = mrb_hash_fetch(mrb, symHash, arg,
|
||||||
mrb_fixnum_value(Input::None));
|
mrb_fixnum_value(Input::None));
|
||||||
num = mrb_fixnum(numVal);
|
num = mrb_fixnum(numVal);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mrb_get_args(mrb, "i", &num);
|
// FIXME: RMXP allows only few more types that
|
||||||
|
// don't make sense (symbols in pre 3, floats)
|
||||||
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
|
|
Loading…
Reference in New Issue