[SCRIPT] Hotkey Manager : V1.11 : 2010/01/03

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20599
Joined: Mon, 15. Nov 04, 00:26
x4

[SCRIPT] Hotkey Manager : V1.11 : 2010/01/03

Post by Cycrow » Fri, 5. Dec 08, 14:24

=============================================
Script: Hotkey Manager
Created: 03/01/2010
Version: 1.11
Author: Cycrow
Game: X3: Terran Conflict 1.3+
=============================================

:arrow: Installation:
  • Image

    :idea: Requires: Plugin Manager Lite

    Install via the Plugin Manager Lite
    Requires Games Version 1.3+ to function
:arrow: Introduction:
  • This is a library script to make it easier to register and maintain hotkeys.
    The advantage of using this, is that the hotkeys will be saved in memory so can easily be found later
    and they can automatically be removed if the script is no longer available.
    So scripts dont need to create extra uninstall routines for removing the hotkeys
:arrow: Scripters Usage:
  • Using it is fairly straight forward, you simply need to call the add script withint your setup script

    Code: Select all

    = call script 'plugin.hotkeymanager.add' nameid='myhotkey' Display Text='My Hotkey' Hotkey Script='plugin.myscript.hotkey'
    
    The first argument, nameid, is a unique string identifier for your hotkey. If your scripts uses multiple hotkeys, they need to have seperate ids
    The next argument, Display Text, is the text that is display in the controls menu.
    The last argument, Hotkey Script, the string name of the script to run when the hotkey is pressed.

    This is all you need to do, theres no need to remove the hotkey, the manager will take care of this.

    However, unlike with normal hotkeys, you have to register this each time the game loads, ie, in your setup script, you dont need any check, just call the script each time.
    Also, it must not be in an Init script
:arrow: Advanced Usage:
  • The add script will always returns true, this means you can use it to detect if the hotkey manager is installed.
    This will allow you to create a script that can still work without the library, ie

    Code: Select all

    if not [THIS] -> call script 'plugin.hotkeymanager.add'
      $key = register hotkey $text....
    end
    
    This will then use your own hotkey control if the manager is not installed.
:arrow: Technical Information:
  • Now, how the manager actually works.

    The manager maintains a list of all registered hotkeys and thier setings in a global varible.
    There is in init script that is run before all the script setups, this script will go through the whole list and mark all the hotkeys to be deleted
    When the setup scripts are run and they add thier hotkeys, if the hotkey exists, they will be marked not to be deleted.
    The manager then has its own setup script that will run another script that waits for a short time. After this time, it will check all the hotkeys that are still marked as deleted and remove them.
    So any hotkey that hasn't been readded in setup scripts, ie because the setup script no longer exists, will then be removed.
Last edited by Cycrow on Tue, 25. Aug 15, 08:55, edited 4 times in total.

cheata
Posts: 4
Joined: Fri, 16. Mar 07, 01:12

create your own keybindings

Post by cheata » Tue, 16. Dec 08, 14:05

Is it possible to bind keys to scripts?


{Merged to apparently very relevant script thread. jlehtone}

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20599
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Tue, 16. Dec 08, 15:28

yes, just create a hotkey and call the script you want.

for an easier way, you can use my hotkey manager

cheata
Posts: 4
Joined: Fri, 16. Mar 07, 01:12

Post by cheata » Tue, 16. Dec 08, 15:57

lol thanks man.. that will save me a few hours reverse enginering the game code.

I was going Completly the wrong direction :D

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20599
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Fri, 10. Jul 09, 19:02

Updated to fix a few bugs

testmod
Posts: 71
Joined: Fri, 13. Mar 09, 05:59
x3tc

Post by testmod » Sun, 13. Dec 09, 07:41

wow. first search didnt turn this up... if I found this earlier it would have saved me so much trouble. Will use ASAP!

thanks!! :D

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20599
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Mon, 4. Jan 10, 01:10

Updated to 1.11

Repacked for Plugin Manager Lite

Theres been problems with some older versions not being completly up to date

Installing this should make sure its running the correct version and prevent multiple hotkeys appearing

russbo
Posts: 855
Joined: Sat, 12. Nov 05, 22:53
x4

Post by russbo » Mon, 4. Jan 10, 07:39

Can this be installed with the older version of the plug in manager?

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20599
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Mon, 4. Jan 10, 13:27

No it will only work with the new one

Its classed as a dependacy library which doesn't exist in the old version

mark_a_condren
Posts: 1385
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren » Sun, 24. Jan 10, 15:18

When i was adding this to a script recently i thought it would be good if it could use hotkeys from scripts that were installed before Hotkey manager was installed.

for example, add the already installed hotkey to the script call,

Code: Select all

= call script 'plugin.hotkeymanager.add' nameid='myhotkey' Display Text='My Hotkey' Hotkey Script='plugin.myscript.hotkey' Existing Hotkey= 'myexistinghotkey'
And from then on Hotkey manager could take over the management of it.

Just a thought, ment to post about it when i thought of it.

MarCon

MegaBurn
Posts: 224
Joined: Mon, 30. Jan 06, 16:52
xr

Post by MegaBurn » Mon, 3. May 10, 07:24

I know this is beyond the intended scope of the Hotkey Manager, but... I'm working on a massive script build and as this drags on I increasingly feel I should contribute my work back to the community, but being a bit of a perfectionist adds a requirement for reasonable ease of use. Unfortunately I'm finding there is an unmanageable proliferation of new hotkeys, over a 100 when I stopped counting. After thinking about it for a while it seems like the best solution is converting hotkeys into "virtual command slots" which can be accessed through a variety of player defined interface widgets.

I think the best way to make this work is expand the Hotkey Manager, essentially bolt on a set of front-end menus and functions to dynamically change which script is triggered by a bound hotkey. From what i understand, I'm assuming this can be done transparently to both players and third-party scripts, players would only have to upgrade to take advantage of the new functionality, the back-end library aspect would remain the same.

From there the focus would turn towards converting wayward scripts. Is it possible for a script to trigger (or copy) a hotkey defined by another script without binding it to a physical key? If so, third-party scripts could be integrated transparently into the front-end, regardless of if they use the library back-end aspect.

Ideas for the virtual command slot interface widgets:
-- Single large dynamic menu of everything available via the hotkey manager. By default it should serve as a sort of quick reference, like a color-coded multi-column layout to easy see whats assigned where. Could have an alternate view to scroll and trigger any virtual command slot available.

-- "Quick Menus", simple ten item dynamic menu with a common set of global hotkeys to trigger quick menu items one through ten. Would require a config menu to review, create, edit, and remove quick menus. Each quick menu would have a virtual command slot, so it could be assigned to a hotkey or another nested quick menu.

-- "Multi Tap", triggers different virtual command slots depending on a hotkey single, double, or triple tab. Each virtual command slot trigger should include an option for subtitle feedback, that way less used commands or those with no immediately apparent effect can give confirmation.

-- Combo Keys, similar to multi tap but uses two or more different keys within a given time period (not to be confused with keys pressed simultaneously). Should include options for subtitle and auto feedback as confirmation. Could include an option to copy combos from a quick menu, allowing the player to avoid displaying the menus they have memorized.

-- Contextual Key, add basic conditional checks for different types/classes of player ship and player target, and target race/IFF. Can't make it too complicated if players have to define it via a config menu.

-- Macros keys, a player defined interface widget that triggers a series of virtual command slots. Could readily be expanded into a full macro system, with a quick menu to select macros and a multi-tap to record, run, and save macros.


Thoughts?

I lack the X3 scripting experience to do this on my own but I'll try to help if I can...
"Only the dead have seen the end of war." -Plato

User avatar
AtomicDryad
Posts: 209
Joined: Sat, 19. Jan 08, 02:04

Post by AtomicDryad » Mon, 3. May 10, 09:12

Those are good ideas, some of which I've considered looking into awhile bback. They sound feasable but I'd need to look into hotkey mgr code to verify.
This may warrant a seperate thread, especially if it becomes a collaborative project.
Using SVN for scripts might help, though the weird structure might make unified diffs a pain.

MegaBurn
Posts: 224
Joined: Mon, 30. Jan 06, 16:52
xr

Post by MegaBurn » Tue, 4. May 10, 12:37

This should not be big enough to warrant SVN but that does make me wonder why the community doesn't have an integrated asset pipeline established. Never cases to amaze me how game modding communities get the complete ass end of the game development "deal" yet they produce an incredible amount of content. Just imagine what this place would look like if engine modules and scripts could be written in Eclipse and the community were hosted on a FusionForge site with all the server side "bells & whistles" (better than SourceForge).

Anyway, hopefully Cycrow can find some time to weigh in on this and coordinate the work. To be effective it must be based around his Hotkey Manager just to get the third-party script "market penetration" - that is unless there is a way to either hijack the hotkey manager or intercept script defined hotkeys (no clue there). I've almost completed my final sweep through my massive script/mod build list, last count is 94 plus 45 "major tweaks", should be a large enough sample for compatibility testing, but I won't be testing anything until after the DDTC1.1 final release (and a fresh X3TC install).

Another thing to consider is saving and loading hotkey condigs including defined widgets from files, theres a JSON library around somewhere that might be useful.
"Only the dead have seen the end of war." -Plato

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20599
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Tue, 4. May 10, 14:46

there are a few problems with the suggestions.

the main would be, that scripted hotkeys only work in open space, so if you press a hotkey to open a menu, you can no longer use hotkeys until that menu closes, so you cant select items from the menu using hotkeys.

best you can get as far as hotkey menus go, would be my community config plugin

MegaBurn
Posts: 224
Joined: Mon, 30. Jan 06, 16:52
xr

Post by MegaBurn » Tue, 4. May 10, 21:16

Well for the quick menus it could use a ten item dummy comm menu, those support the 1-0 row keys to select entries but the t-files would be a real pain... Even without that, the rest should work as intended, except the "quick menus" wouldn't be as quick. People could focus on multi-tap or combo keys instead, might increase the focus on using subtitles as remainders too.

Any idea how the game settings control profile menu is built? If it uses script accessible global variables with the target script, description, and hotkey ID's that might work for hijacking hotkeys defined by other scripts, just load the target script and description ID's into an array for reassignment via the hotkey config menu, and removed the existing hotkey. I can't see any other way to get the target script of a defined hotkey. Could hotkey ID's in profileX.xpf be back traced to some script accessible global variable?

EDIT: I did some searching around and came up with a few more ideas... Looks like an incoming question pop-up will work fine, annoying aspects can be disabled, and only needs a few t-files for menu templates. Didn't find anything to help with hijacking hotkeys from other scripts but I could use my script/mod list to index most of them, and investigate any special handling needed (e.g. breaking up existing multi-tap hotkeys). Some more "yet another thing to consider", add most stock commands/utilities to hotkey config menu for easy assignment, design widgets with consideration for use as a general library, and merge in some of the older hotkey scripts. Any other issues?
"Only the dead have seen the end of war." -Plato

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”