mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-29 03:33:48 +00:00
Fix some regressions + improvements:
- ACTION_MENU* not sent - allow using the game UI with keyboard only - allow mapping ACTION_MENU to controller inputs - fix joystick axis (-) not working due to typo
This commit is contained in:
parent
bf94d541cd
commit
671d0ace1b
8 changed files with 71 additions and 40 deletions
|
@ -89,7 +89,7 @@ void AquariaGuiElement::setFocus(bool v)
|
|||
if (v)
|
||||
{
|
||||
currentFocus = this;
|
||||
if (dsq->inputMode == INPUT_JOYSTICK)
|
||||
if (dsq->inputMode == INPUT_JOYSTICK || dsq->inputMode == INPUT_KEYBOARD)
|
||||
core->setMousePosition(getGuiPosition());
|
||||
|
||||
AquariaGuiElement *gui=0, *guiThis = (AquariaGuiElement*)this;
|
||||
|
@ -162,7 +162,13 @@ void AquariaGuiElement::UpdateGlobalFocus(float dt)
|
|||
Direction AquariaGuiElement::GetDirection()
|
||||
{
|
||||
Direction dir = DIR_NONE;
|
||||
Vector p;
|
||||
|
||||
// This joystick code is already supposed to send ACTION_MENU*.
|
||||
// Actually some places depend on the actions to be sent,
|
||||
// So checking this here might work for a few cases,
|
||||
// but others will break.
|
||||
// I'll leave this in here for now -- fg
|
||||
/*Vector p;
|
||||
for(size_t i = 0; i < core->getNumJoysticks(); ++i)
|
||||
if(Joystick *j = core->getJoystick(i))
|
||||
if(j->isEnabled())
|
||||
|
@ -189,9 +195,9 @@ Direction AquariaGuiElement::GetDirection()
|
|||
dir = DIR_UP;
|
||||
}
|
||||
}
|
||||
else
|
||||
else*/
|
||||
{
|
||||
StateObject *obj = dsq->getTopStateObject();
|
||||
StateObject *obj = dsq->getTopStateObject(); // usually Game...
|
||||
if (obj)
|
||||
{
|
||||
if (obj->isActing(ACTION_MENULEFT, -1)) dir = DIR_LEFT;
|
||||
|
@ -205,8 +211,6 @@ Direction AquariaGuiElement::GetDirection()
|
|||
|
||||
AquariaGuiElement *AquariaGuiElement::FindClosestTo(AquariaGuiElement *cur, Vector pos, Direction dir)
|
||||
{
|
||||
|
||||
debugLog("updating closest");
|
||||
int smallDist = -1, dist = 0;
|
||||
|
||||
AquariaGuiElement *gui = 0, *closest = 0;
|
||||
|
@ -214,7 +218,7 @@ AquariaGuiElement *AquariaGuiElement::FindClosestTo(AquariaGuiElement *cur, Vect
|
|||
for (GuiElements::iterator i = guiElements.begin(); i != guiElements.end(); i++)
|
||||
{
|
||||
gui = (*i);
|
||||
if (gui != cur && gui->isGuiVisible() && gui->canDirMove)
|
||||
if (gui != cur && gui->isGuiVisible() && gui->canDirMove && gui->hasInput())
|
||||
{
|
||||
int go = 0;
|
||||
Vector p1 = pos;
|
||||
|
|
|
@ -3877,7 +3877,7 @@ void DSQ::onUpdate(float dt)
|
|||
|
||||
// HACK: not optimal
|
||||
|
||||
if (inputMode != INPUT_KEYBOARD && game->isActive())
|
||||
if (/*inputMode != INPUT_KEYBOARD &&*/ game->isActive())
|
||||
{
|
||||
for(size_t i = 0; i < almb.size(); ++i)
|
||||
if (ActionMapper::getKeyState(almb[i]->key[0]) || ActionMapper::getKeyState(almb[i]->key[1]))
|
||||
|
|
|
@ -3256,6 +3256,11 @@ void Game::bindInput()
|
|||
as.importAction(this, "SwimLeft", ACTION_SWIMLEFT, sourceID);
|
||||
as.importAction(this, "SwimRight", ACTION_SWIMRIGHT, sourceID);
|
||||
|
||||
as.importAction(this, "MenuUp", ACTION_MENUUP, sourceID);
|
||||
as.importAction(this, "MenuDown", ACTION_MENUDOWN, sourceID);
|
||||
as.importAction(this, "MenuLeft", ACTION_MENULEFT, sourceID);
|
||||
as.importAction(this, "MenuRight", ACTION_MENURIGHT, sourceID);
|
||||
|
||||
as.importAction(this, "PrevPage", ACTION_PREVPAGE, sourceID);
|
||||
as.importAction(this, "NextPage", ACTION_NEXTPAGE, sourceID);
|
||||
as.importAction(this, "CookFood", ACTION_COOKFOOD, sourceID);
|
||||
|
|
|
@ -2062,26 +2062,25 @@ void InGameMenu::create()
|
|||
RenderObject *kk = createBasicKeyConfig();
|
||||
group_keyConfig[0] = kk;
|
||||
|
||||
int y = 0;
|
||||
int y = offy;
|
||||
|
||||
addKeyConfigLine(kk, SB(2107), "PrimaryAction", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2108), "SecondaryAction", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2109), "SwimUp", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2110), "SwimDown", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2111), "SwimLeft", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2112), "SwimRight", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2113), "Roll", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2114), "Revert", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2115), "WorldMap", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2127), "Look", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2132), "Screenshot", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2107), "PrimaryAction", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2108), "SecondaryAction", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2109), "SwimUp", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2110), "SwimDown", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2111), "SwimLeft", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2112), "SwimRight", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2113), "Roll", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2114), "Revert", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2115), "WorldMap", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2127), "Look", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2132), "Screenshot", offx, y+=yi);
|
||||
|
||||
y+=yi+yi/2;
|
||||
AquariaKeyConfig* s1x = addAxesConfigLine(kk, SB(2117), "s1ax", offx, y+offy);
|
||||
AquariaKeyConfig* s1y = addAxesConfigLine(kk, SB(2118), "s1ay", offx+130, y+offy);
|
||||
AquariaKeyConfig* s2x = addAxesConfigLine(kk, SB(2119), "s2ax", offx+260, y+offy);
|
||||
AquariaKeyConfig* s2y = addAxesConfigLine(kk, SB(2120), "s2ay", offx+380, y+offy);
|
||||
y+=yi;
|
||||
AquariaKeyConfig* s1x = addAxesConfigLine(kk, SB(2117), "s1ax", offx, y);
|
||||
AquariaKeyConfig* s1y = addAxesConfigLine(kk, SB(2118), "s1ay", offx+130, y);
|
||||
AquariaKeyConfig* s2x = addAxesConfigLine(kk, SB(2119), "s2ax", offx+260, y);
|
||||
AquariaKeyConfig* s2y = addAxesConfigLine(kk, SB(2120), "s2ay", offx+380, y);
|
||||
|
||||
s1x->setDirMove(DIR_LEFT, s1x);
|
||||
s1x->setDirMove(DIR_RIGHT, s1y);
|
||||
|
@ -2101,15 +2100,19 @@ void InGameMenu::create()
|
|||
RenderObject *kk = createBasicKeyConfig();
|
||||
group_keyConfig[1] = kk;
|
||||
|
||||
int y = 0;
|
||||
int y = offy;
|
||||
|
||||
addKeyConfigLine(kk, SB(2121), "PrevPage", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2122), "NextPage", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2123), "CookFood", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2124), "FoodLeft", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2125), "FoodRight", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2126), "FoodDrop", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2128), "ToggleHelp", offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, SB(2135), "MenuUp", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2136), "MenuDown", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2137), "MenuLeft", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2138), "MenuRight", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2121), "PrevPage", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2122), "NextPage", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2123), "CookFood", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2124), "FoodLeft", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2125), "FoodRight", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2126), "FoodDrop", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2128), "ToggleHelp", offx, y+=yi);
|
||||
}
|
||||
|
||||
// PART 2
|
||||
|
@ -2117,7 +2120,7 @@ void InGameMenu::create()
|
|||
RenderObject *kk = createBasicKeyConfig();
|
||||
group_keyConfig[2] = kk;
|
||||
|
||||
int y = 0;
|
||||
int y = offy;
|
||||
std::string slotstr = SB(2129);
|
||||
for(unsigned i = 1; i <= 10; ++i) // SongSlot starts at 1
|
||||
{
|
||||
|
@ -2125,7 +2128,7 @@ void InGameMenu::create()
|
|||
osname << slotstr << ' ' << i;
|
||||
std::ostringstream osac;
|
||||
osac << "SongSlot" << i;
|
||||
addKeyConfigLine(kk, osname.str(), osac.str(), offx, offy+(y+=yi));
|
||||
addKeyConfigLine(kk, osname.str(), osac.str(), offx, y+=yi);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3743,6 +3746,8 @@ void InGameMenu::toggleKeyConfigMenu(bool f)
|
|||
opt_save->position = opt_save_original + Vector(0, 120);
|
||||
opt_cancel->position = opt_cancel_original + Vector(0, 120);
|
||||
|
||||
opt_cancel->setDirMove(DIR_UP, NULL);
|
||||
opt_save->setDirMove(DIR_UP, NULL);
|
||||
opt_cancel->setFocus(true);
|
||||
|
||||
menuIconGlow->alpha = 0;
|
||||
|
|
|
@ -280,6 +280,10 @@ static void ensureDefaultActions(ActionSet& as)
|
|||
as.addActionInput("SwimDown");
|
||||
as.addActionInput("SwimLeft");
|
||||
as.addActionInput("SwimRight");
|
||||
as.addActionInput("MenuUp");
|
||||
as.addActionInput("MenuDown");
|
||||
as.addActionInput("MenuLeft");
|
||||
as.addActionInput("MenuRight");
|
||||
as.addActionInput("Roll");
|
||||
as.addActionInput("Revert");
|
||||
as.addActionInput("WorldMap");
|
||||
|
|
|
@ -108,7 +108,7 @@ std::string getInputCodeToString(int k)
|
|||
|
||||
std::string getInputCodeToUserString(int k, int joystickID)
|
||||
{
|
||||
const char *pretty = NULL;
|
||||
const char *pretty = NULL, *tail = NULL;
|
||||
|
||||
// Special case keyboard input:
|
||||
// Return key name for current keyboard layout!
|
||||
|
@ -120,14 +120,25 @@ std::string getInputCodeToUserString(int k, int joystickID)
|
|||
pretty = SDL_GetKeyName(kcode);
|
||||
}
|
||||
if(k >= JOY_AXIS_0_POS && k < JOY_AXIS_END_POS)
|
||||
{
|
||||
pretty = jaxisname(joystickID, k - JOY_AXIS_0_POS);
|
||||
tail = "(+)";
|
||||
}
|
||||
else if(k >= JOY_AXIS_0_NEG && k < JOY_AXIS_END_NEG)
|
||||
{
|
||||
pretty = jaxisname(joystickID, k - JOY_AXIS_0_NEG);
|
||||
tail = "(-)";
|
||||
}
|
||||
else if(k >= JOY_BUTTON_0 && k < JOY_BUTTON_END)
|
||||
pretty = jbtnname(joystickID, k - JOY_BUTTON_0);
|
||||
|
||||
if(pretty && *pretty)
|
||||
return pretty;
|
||||
{
|
||||
std::string s = pretty;
|
||||
if(tail)
|
||||
s += tail;
|
||||
return s;
|
||||
}
|
||||
|
||||
return inputcode2string(k);
|
||||
}
|
||||
|
|
|
@ -156,6 +156,9 @@ bool ActionMapper::_pollActionData(const ActionData& ad)
|
|||
|
||||
bool ActionMapper::getKeyState(int k)
|
||||
{
|
||||
if(!k)
|
||||
return false;
|
||||
|
||||
bool keyState = false;
|
||||
if (k >= 0 && k < KEY_MAXARRAY)
|
||||
{
|
||||
|
@ -203,7 +206,7 @@ bool ActionMapper::getKeyState(int k)
|
|||
}
|
||||
else if (k >= JOY_AXIS_0_NEG && k < JOY_AXIS_END_NEG)
|
||||
{
|
||||
int v = k - JOY_AXIS_END_NEG;
|
||||
int v = k - JOY_AXIS_0_NEG;
|
||||
|
||||
for(size_t i = 0; i < core->getNumJoysticks(); ++i)
|
||||
if(Joystick *j = core->getJoystick(i))
|
||||
|
@ -254,7 +257,7 @@ void ActionMapper::onUpdate (float dt)
|
|||
}
|
||||
else
|
||||
{
|
||||
action(ad->id, keyState, -1); // FG: FIXME
|
||||
action(ad->id, keyState, ad->source);
|
||||
}
|
||||
if (core->loopDone) goto out;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,6 @@ void ActionSet::importAction(ActionMapper *mapper, const std::string &name, int
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ActionSet::importAction(ActionMapper *mapper, const std::string &name, Event *event, int state) const
|
||||
|
|
Loading…
Reference in a new issue