Jump to content

Tooltips with keyboard shortcuts


miguez

Recommended Posts

Hello ladies and gents,

 

I have added all default keyboard shortcuts to the cockpit tooltips. The file can be found here.

 

Since a lot of people might skip the readme file in there, I am posting it here too. Enjoy!

 

WARNING: This was only tested with the English release of DCS: BS, version 1.0, with the option COCKPIT LANGUAGE set to English. I cannot guarantee it will work with the Russian release, or that it will work with the English release with COCKPIT LANGUAGE set to Russian.

 

OVERVIEW

-------------------------------------------------------------------

 

This readme is organized in the following fashion:

 

- INTRODUCTION

- HOW TO MODIFY TOOLTIPS YOURSELF

- EXISTING ISSUES

- INSTALLATION INSTRUCTIONS

- CONTACT

 

INTRODUCTION

-------------------------------------------------------------------

 

Hello and welcome to the world of tooltips!

 

The files in this download were created to add the default keyboard shortcuts to the in-cockpit tooltips that DCS: Black Shark is capable of showing. The reason I decided to do this was simple. I do not own a HOTAS setup (or at least, not yet), and am therefore forced to either use the mouse to click through the cockpit, which I like quite a bit, or to use keyboard shortcuts. For the vast majority of the time I spend in the cockpit, I use my mouse pointer to click on things, but I find that sometimes, especially in the heat of battle, I do not have the time to look around for a switch, never mind move the pointer over it and click it. For these moments, I wanted to learn some of the existing keyboard commands. In reading through the DCS: Black Shark forums (http://forums.eagle.ru/forumdisplay.php?f=72) I bumped onto a message where someone suggested it would be great if keyboard shortcuts were added to tooltips, so i set out to see if it was possible, and the rest is, as they say, history. Here we are.

 

When I polled the members at that forum to see if anyone else would be interested, I got some very positive feedback, and so decided to make this public. At the same time, though, some people brought up really good points and ideas. One of the good points was basically "Well, if the tooltip only shows when your mouse button is over a switch or knob, then what good would this be? Just click on it already!". That's very very true. The intention of this package is not to move your cursor over a switch, read the keyboard shortcut, then use that. It is to help memorize what that shortcut is, so that after several usages of the same switch, by seeing the key combo repeatedly, you will recall it from memory. So, I guess you could see this as a study guide.

 

HOW TO MODIFY TOOLTIPS YOURSELF

-------------------------------------------------------------------

 

I do not intend for this to be a closed effort, and welcome help and questions at any time. I am also showing everyone how they can customize their own tooltips for the benefit of the community. Black Shark itself has a very open architecture, and so in that same spirit, here's how to do this editing.

 

All cockpit tooltips live in a file called clickabledata.lua. This is a text file, written in the lua scripting language (http://www.lua.org). If you are not familiar with editing lua files you should proceed with caution. Information and tips on editing lua files can be found on the above referenced forum in threads such as this: http://forums.eagle.ru/showthread.php?t=35627&highlight=editing+lua

 

First things first: Make a backup of your original file. Copy it to anywhere in your computer you will remember, or keep it in the same directory under a different name. Either way, you need a backup copy because it is not hard to change things by accident and break some or all functionality of DCS: Black Shark.

 

I use Notepad++ to edit them, as the default Windows Notepad will corrupt such files when saving them. Using a proper text editor program, open up clickabledata.lua, which is located at ....\Eagle Dynamics\Ka-50\Scripts\Aircrafts\Ka-50\Cockpit. The first 13 lines or so are default information. The data we are interested in starts at around line 15. In my file, lines 14 and 15 are:

 

--------------------------------------------------------------------------------

-- CPT MECH

 

This is a section header used to organize this lua file into chunks. Each tooltip is on a line of its own. Look right after these two lines, on line 16, and you'll find our first tooltip, in the following format:

 

elements["GEAR-PTR"] = {class = {class_type.TUMB,class_type.TUMB}, hint = LOCALIZE("Gear lever (G)"), device = devices.CPT_MECH, action = {device_commands.Button_1,device_commands.Button_1}, arg = {65,65}, arg_value = {direction*1.0,-direction*1.0}, arg_lim = {{0.0, 1.0},{0.0, 1.0}}, updatable = true, use_OBB = true}

 

As you can tell, this file does more than identify tooltips, but we're not interested in the extra info, all we are looking for is the text inside the quotes, right after the "LOCALIZE" tag. In the above case, it is the following:

 

"Gear lever (G)"

 

The text within these quotes, also referred to as a string, is what will show in the tooltips in the simulation. You can write pretty much anything you want, although some characters are treated differently by lua. For example, if you wanted to print a percent sign, %, you cannot simply add that sign, as lua will recognize it as an operator. What you have to do here is to "escape" that character. This is a programming technique that consists of simply prefixing the special character with an "escape" command. In lua, that escape command is the backslash, \, so in our previous example, if you wanted to add a percent sign to the tooltip right after the word "Gear" you'd simply write it like this:

 

"Gear \% lever (G)"

 

lua has a list of special characters that would need this escaping technique when used in a string. Here they are:

 

"

'

[

]

%

\

 

You may be thinking "Wait a second, one of those special characters is the backslash itself!". Yep, that's right. Why? Well, easy enough, what if you wanted to print a backslash into a string? Simple. Like all other special characters above, just preface it with a blackslash. So, if we wanted to add a backslash in between the words "Gear" and "lever", we'd do the following:

 

"Gear \\ lever (G)"

 

If all of this is not making sense, take a look at the lua website I mentioned above, and read around in the forum.

 

Let's continue. If you are looking for a specific tooltip, you can search this lua file with your editor's search function for some keywords, or scroll down through it looking for the proper section. Once you have located it, change the text inside the quotes right after LOCALIZE, save the file, and you're ready to go.

 

EXISTING ISSUES

-------------------------------------------------------------------

 

I ran into a couple of decisions during this effort, as well as some limitations. They are/were as follows:

 

1 - To avoid confusion I did not use "-" or "=" in between key presses, such as "LShift + G", since sometimes keyboard commands involve the signs "+" or "-". Key presses are simply separated by a space, so the previous example would be "LShift G".

2 - Brackets (either [ or ]) seem to be a problem. In lua, you can "escape" a bracket inside a string or, in other words, tell lua the bracket is not part of opening or closing an array, and is just to be printed as text, by prefixing it with a backslash (see HOW TO MODIFY TOOLTIPS YOURSELF above). I have tried this and still get what looks to be just the upper part of a bracket once in the tooltip. It could be due to my resolution, video card, video drivers, BS itself, or all of the above. If you can resolve this issue, or if you don't have issues at all, please let me know. In my testing, it seems that prefacing a bracket with a backslash did not make any difference, they printed the same way on screen with or without backslashes. Just in case, every bracket I used in tooltips has been prefixed by a backslash.

3 - I could not find keyboard shortcuts for the following, some due to the fact they are "No Function" switches and probably do not have shortcuts. If you know them, please contact me.

 

WALL PANEL

- Radio equipment datalink SA-TLF power switch

- 1st fire warning sensors group BIT

- 2nd fire warning sensors group BIT

- 3rd fire warning sensors group BIT

- Reducing gear box oil pressure indication selector

- Sling load Auto/Manual

- Latitude selection rotaty (it is misspelled as "rotaty")

- North/South latitude selection

 

FORWARD PANEL

- SHKVAL Optics adjustment

 

AUXILIARY PANEL

- ATGM Temperature selector

- Unguided rocket and gun pods ballistics data settings selector

- Systems BIT selector

- Control computers BIT switch

- Self test system push-button

- Emergency INU alignment switch

- Stabilisation and indication of hanger cable switch

- Video Tape Recorder switch

 

OVERHEAD PANEL

- Windshield washer fluid switch

- Brightness

 

4 - For rotating knobs that had two different keyboard shortcuts, one to rotate clockwise, the other to rotate counterclockwise, yet only one tooltip, I added both commands to the same tooltip. I prefaced the clockwise rotation shortcut with the letters "CW", and the counterclockwise one with the letters "CCW", or "DECR" and "INCR" for knobs that decreased or increased settings such as brightness, or "DOWN" and "UP" for rotaries with such motion.

5 - I did not have time to test all keyboard shortcuts. If you find any mistakes, please contact me.

 

INSTALLATION INSTRUCTIONS

-------------------------------------------------------------------

 

1 - Backup (or move to another directory) your original clickabledata.lua, located at ....\Eagle Dynamics\Ka-50\Scripts\Aircrafts\Ka-50\Cockpit

2 - Replace it with the clickabledata.lua file from this package

3 - Make sure that in DCS: Black Shark, under OPTIONS | GAMEPLAY you have TOOL TIPS checked on

 

CONTACT

-------------------------------------------------------------------

 

You can contact me at fabiomiguez@gmail.com

 

 

 

 

Enjoy learning these keyboard shorcuts!

 

Best regards,

 

Fabio Miguez

  • Like 3
Link to comment
Share on other sites

  • ED Team

One usefull note

to avoid hint localization failure just use lua string concatenation with LOCALIZE function

 

 

sample

 hint = LOCALIZE("SOME NAME OF TRIGGER DO NOT CHANGE IT")[color="red"].."( LSHIFT+LCTRL+LWIN+A )"[/color]

 

where '..' is lua string concatenation operator

 

P.S.

all hint internationalization is stored in hint_localizer.lua

 

so will be better rework LOCALIZE function instead of editing clickabledata.lua

 

as

 

function LOCALIZE (key)
   local shortcut = FIND_SHORTCUT_FOR_SWITCH(key)  -- you must make realization 
   
   local localized_name = OLD_LOCALIZE_REALIZATION(key)

   return localized_name..shortcut
end


Edited by Alex O'kean
sigpic2354_5.gif
Link to comment
Share on other sites

One usefull note

to avoid hint localization failure just use lua string concatenation with LOCALIZE function

 

 

sample

 hint = LOCALIZE("SOME NAME OF TRIGGER DO NOT CHANGE IT")[color="red"].."( LSHIFT+LCTRL+LWIN+A )"[/color]

 

where '..' is lua string concatenation operator

 

P.S.

all hint internationalization is stored in hint_localizer.lua

 

so will be better rework LOCALIZE function instead of editing clickabledata.lua

 

as

 

function LOCALIZE (key)
   local shortcut = FIND_SHORTCUT_FOR_SWITCH(key)  -- you must make realization 
   
   local localized_name = OLD_LOCALIZE_REALIZATION(key)

   return localized_name..shortcut
end

 

Hi Alex,

 

That is great news, that this is possible without breaking localization. I have some questions and sent you a PM.

 

Thanks,

Link to comment
Share on other sites

  • ED Team
Hi Alex,

 

That is great news, that this is possible without breaking localization. I have some questions and sent you a PM.

 

Thanks,

 

Ok ,

 

let's make file Hint_shortcut_map.lua stored in the same place as clickabledata.lua and Hint_localizer.lua

 

Hint_shortcut_map.lua sample:


--for example we have shortcut map
--declare shortcut map
shortcuts = {}
-- so we make function
function FIND_SHORTCUT_FOR_SWITCH(key)
   local val = shortcuts[key]
   -- if we have shortcut to this item 
   if val then return " ( "..val.." )" -- return shortcut to this switch
   else        return "" -- otherwise return empty string
   end
end

-- save LOCALIZE function
local OLD_LOCALIZE_REALIZATION = LOCALIZE

-- and then reassign it :
function LOCALIZE(key)
   local shortcut       = FIND_SHORTCUT_FOR_SWITCH(key) 
   local localized_name = OLD_LOCALIZE_REALIZATION(key)
   return localized_name..shortcut
end


---------------SHORTCUT MAP---------------------------
shortcuts["gear lever"] = "G"  -- gear lever mapped to "G"

--just add other shortcuts here 

 

in clickabledata.lua just put line with

"dofile(LockOn_Options.script_path.."Hint_shortcut_map.lua")"

directly after loading Hint_localizer.lua

dofile(LockOn_Options.script_path.."command_defs.lua")
dofile(LockOn_Options.script_path.."devices.lua")
dofile(LockOn_Options.script_path.."Hint_localizer.lua")
[b]--- SHORTCUT MAP 
dofile(LockOn_Options.script_path.."Hint_shortcut_map.lua")
---[/b]

 

that's all , after that you need to modify only your own Hint_shortcut_map


Edited by Alex O'kean
sigpic2354_5.gif
Link to comment
Share on other sites

  • 5 months later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...