beyond-all-reason / Beyond-All-Reason

Main game repository for Beyond All Reason.
https://www.beyondallreason.info/
Other
1.74k stars 291 forks source link

Key Binding Menu #396

Open Damgam opened 3 years ago

Damgam commented 3 years ago

We don't have one, we need one.

FIr3baL commented 2 years ago

Hi @Damgam , a proper key binding menu is a dream :)

Back in 2020 i started a first attempt to write a standalone program for this, but stumbled upon a lot of issues:

In the end i had a nice experience reading code for days and hours, but lost motivation totally.

So, at a first approach, i would suggest making this issue dependent on another issue, that is cleaning up the code to have a single interface, where keys and mouse buttons can be bind to actions or triggers or whatever function needed. This can be uikeys.txt, but doesnt need to. Since players put a lot of work into theirs uikeys.txt, it could be fine to let uikeys.txt functionality untouched and write another independent interface.

Recently @badosu did good effort in this, by replacing keybindings in widgets by actions, which can be bound to keys individually in uikeys.

I would like to help developing this. Is anybody working on this so far ?

badosu commented 2 years ago

It would definitely be a good reason to push for keybinding externalization from my end, happy to focus on any issue you find if you go forward on this path.

I don't think there's anyone working on this at the moment.

WatchTheFort commented 2 years ago

Are keybindings considered part of settings? Eventually, there needs to be only one unified settings interface presented to the player in both game and lobby.

Something to keep in mind with how the keybinding UI and functionality is going to be implemented.

FIr3baL commented 2 years ago

Are keybindings considered part of settings? Eventually, there needs to be only one unified settings interface presented to the player in both game and lobby.

Something to keep in mind with how the keybinding UI and functionality is going to be implemented.

This is so true, but at the same time it is making a gap beetween lobby devs and game devs. If keybinding menu is implemented in the game, it is not accesseble in lobby. But it ishould be available outside of "ingame" AND at the same time available from "ingame". Imho it is best placed at a lobby button, but if it is hardcoded to chobby, all other lobbys are put to struggle. -> Best way imho should be to offer an interface, where all lobbys can make their gui on top of it.

WatchTheFort commented 2 years ago

BAR development should prioritize a seamless experience for the player above third-party application support. We can't fall into the lobby-game mindset where they are treated as separate applications, to the player there is no such thing as the lobby. They start BAR and see the main menu, and to them they are in-game.

badosu commented 2 years ago

Anything that can be springsettings editable should be easily implemented in any lobby, I don't see any blockers here

badosu commented 2 years ago

More importantly BYAR.lua should be easily accessible to chobby (it's the place where settings data are located) though not necessarily something easy to set from a non-lua lobby.

Beherith commented 2 years ago

I would be very partial to having this keybind menu made in chili, as that would guarantee usability in both lobby and game. In fact ZK/TAP/MF alreadyhas a chili based keybinding menu, which would make sense to be used as a basis.

badosu commented 2 years ago

In fact ZK/TAP/MF alreadyhas a chili based keybinding menu

MF? Are you sure?

Beherith commented 2 years ago

Not sure on MF, sure on TAP

Sutrinc commented 2 years ago

Hello. Can possibly do as in this example. The widget registers a click handler below the code. The code is the key in the match table.

like this KeyMapper.SetUserKeyAction('add filter 4', {action = "UI_Lua import('/mods/FilterSelection/modules/FilterSelection.lua').AddFilterSelection(4)", category = 'FilterSelection', order = 424,})

order is key

then the table containing the key codes and the corresponding processing keys is loaded.

it is all.

FIr3baL commented 2 years ago

Hello. Can possibly do as in this example. The widget registers a click handler below the code. The code is the key in the match table.

like this KeyMapper.SetUserKeyAction('add filter 4', {action = "UI_Lua import('/mods/FilterSelection/modules/FilterSelection.lua').AddFilterSelection(4)", category = 'FilterSelection', order = 424,})

order is key

then the table containing the key codes and the corresponding processing keys is loaded.

it is all.

Thx, will keep this in mind.

Current roadmap is:

  1. Change engine to use SDL2 key positions instead of english keyboard layout chars
  2. Remove nearly all keybinds in engine or remove them in bar before processing any other keybinding, so we start with a clean table.
  3. Replace direct keybindings in LUA Widgets with actions (@badosu already did this for all common bindings, i think)
  4. Maybe switch default place for keybindings from uikeys.txt to byar.lua (1 settings file for everything)
  5. Make some fency GUI on top of it , like @Beherith said with chili

My current status in Step 1 is: Got my development environment up working yesterday, ready to compile, code and debug :)

Sutrinc commented 2 years ago

English is not my native language. sorry. You are a game developer. I want to express my admiration for the great work that you have done.

I would like to take this opportunity to ask you a couple of questions. I am not a professional programmer and I don’t know how the game works. Therefore, I use the method of trial and error.

1. there is such a command Specific Unit Reclaimer Area its work by widget help. unit_specific_unit_reclaimer.lua areaUnits = spGetUnitsInCylinder(cx ,cz , cr, team) get units then filter then order

but you dont have Specific Unit Resurrect Area

i would like add this command by change widget is there a function that returns debris in the area and their type? i found this, but i dont know it work or not. Spring.GetFeaturesInRectangle ( number xMin, number zMin, number xMax, number zMax ) return: nil | table featureTable = { [1] = number featureID, etc... } how do you think it will work?

2. I believe that the game lacks the order to select the priority of targets. I am thinking of trying to write a widget that will assign an order to attack by setting a target te Spring.GetUnitsInCylinder ( number x, number z, number radius [, number teamID ] ) return: nil | table unitTable = { [1] = number unitID, etc... }

end set default target

how do you think it will work? won't slow down the game?

badosu commented 2 years ago

Hi @Sutrinc , for suggestions and general help we use discord, you can join with https://discord.gg/N968ddE.

badosu commented 2 years ago
  1. You can make rezzers reclaim debris and ressurrect units with alt+f I think
  2. Settings -> Game -> Set target as default, or use Y key to set target
Sutrinc commented 2 years ago

I know. but discort is more like a chat. if you ask a question and return to it in a week, the answer cannot be found. It is also difficult to understand which question was answered. I suggested making a forum. so I have to ask here.

badosu commented 2 years ago

I guess we could make a mailing list

badosu commented 2 years ago

Or you can post on one of these subforums

FIr3baL commented 2 years ago

Since i use my free time to learn for a certificate, my engagement on this topic will be back on january.

Beherith commented 2 years ago

Good luck on the Cert Fireball! And Sutrinc, you can find the answer easily, as you have a notifications inbox for any time someone replied to you.

FIr3baL commented 2 years ago

Update: Found a workaround to get keyboard physical position keys match to us layout keybindings. In testing now...

FIr3baL commented 2 years ago

Testing didn´t result in any usable case so far. This spring engine already uses SDL2 as the main interface, but still got functions like SDL21_keysyms, which translate back to SDL1. At this time i think this is needed for interface to lua. But i need more time to understand. To perfectly rely on SDL2 tables back and forth, there should be no translations to SDL1 key tables in between. I think, SDL1 should be left behind to make things easier.

FIr3baL commented 2 years ago

Update: Nothing new for readers of discord ...

Updating above roadmap...

In the next 2 weeks i will do a PR enabling positional binding inside engine, in uikeys.txt and in lua scripts. SpringKeyBindings_KeyPressSC

Since i´m just a contributor and not a dev, things can change a lot. Following lines are just a draft.

uikeys.txt could look like this:

before:

bind        r               repair
bind        Shift+esc           quitmenu

after:

bind        SC_R                repair
bind        Shift+SC_Escape         quitmenu

a widget function could look liks this:

include("keyscancode.h.lua")

function widget:KeyPressSC(key, modifier, isRepeat)
    if key == KEYSCANCODE.SC_LEFTBRACKET then
        spEcho("[ pressed");
    else
        spEcho("[ not pressed");
    end
    return true;
end

best regards Fireball

MasterBel2 commented 1 year ago

Might be worth noting I've made an ingame keybind editor and progress towards mouse bindings (with some lua-side work also) - just in case anyone stumbles across this and is wondering

SethDGamre commented 4 days ago

Requesting review session to figure out the best way to accomplish this, and to get firm confirmation it is approved.

badosu commented 3 days ago

It's not a single point of work. First effort must be a declaration of a widgets actions and exporting those in a format that can be reused in such a widget