Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Extensions (WIP) #35

Merged
merged 7 commits into from
Jul 1, 2023
Merged

Add Extensions (WIP) #35

merged 7 commits into from
Jul 1, 2023

Conversation

rkusa
Copy link
Owner

@rkusa rkusa commented Sep 10, 2022

⚠️ This is work in progress. I am mostly exploring whether this is a useful addition. I am not yet committed to actually add this. Also keep in mind that the API exposed to extensions is subject to change.

With this PR, the Scratchpad can be extended with additional buttons, by simply adding a Lua script to DCS\Scripts\Scratchpad\Extensions\{extension_name}.lua.

This PR includes a couple of examples in Scripts/Scratchpad/Extensions.

Screenshot 2022-09-10 175359

The exmaple extensions are:

  • clear.lua: add a button to clear the current page (fixes Feature request: Add In-Game Button to Clear the Current Scratch Pad... #32)
  • keypad.lua: add a small keypad with enough buttons to insert coordinates
  • ns430.lua: listen foor coordinates and add the NS430 FIX format (as a possible replacement for having this built in)
  • sitrep.lua: add a button to copy the current mission's situation to the top of the current page

The available API to the plugins in a nutshell (proper docs are still to do):

log(text)
formatCoord(format, isLat, d, opts)
addCoordinateListener(listener(text, lat, lon, alt))
addButton(left, top, width, height, title, onClick(text))

text:getText()
text:setText(text)
text:insertAtCursor(text)
text:insertBelowCursor(text)
text:insertTop(text)
text:insertBottom(text)

Open questions:

  • How to handle the order of extensions?
  • Allow adding buttons to existing rows instead of always adding a new new for each extension?
  • Call them Extensions or Plugins?

Todos:

  • Document Plugin API

I'll keep this is a draft PR for a while to explore whether it ends up being useful for people and to gather some feedback about the API. If you want to try it out, you can download the version of this PR here: https://github.com/rkusa/dcs-scratchpad/archive/refs/heads/extensions.zip

If I end up adding this extensions feature, I'll be accepting community extensions into this repo. They will just not be included in the default-installation and they will rely on community contributions for maintanance.

@rkusa

This comment was marked as resolved.

@rkusa

This comment was marked as resolved.

@speed-of-heat

This comment was marked as resolved.

@rkusa

This comment was marked as resolved.

@speed-of-heat
Copy link

speed-of-heat commented Sep 12, 2022

for extension/plugin ordering, the default to alpha ordering, adding a numeral to the front of the name will allow it to be ordered as desired

@rkusa
Copy link
Owner Author

rkusa commented Oct 12, 2022

The above commits contain the following API changes for extensions:

  • addRow removed, addButton can now be called directly
  • insertAtCursor renamed to insert
  • insertBelowCursor renamed to insertBelow

Furthermore, the built-in extensions included in this PR have been disabled by default (moved to DCS\Scripts\Scratchpad\Extensions\Disabled\). They have be manually copied to DCS\Scripts\Scratchpad\Extensions\ to enable (and update them).

@rkusa
Copy link
Owner Author

rkusa commented Oct 13, 2022

for extension/plugin ordering, the default to alpha ordering, adding a numeral to the front of the name will allow it to be ordered as desired

I was thinking about this too. However, I am a bit concerned about the process of updating extensions. If people have to manually copy them into the Extensions directory, and maybe even rename them, they have to repeat those steps each time there is an update.

At least for the update part, it might be better to have everything in the Extensions directory by default, but disabled, and enable plugins via the Config/ScratchpadConfig.lua, e.g.:

{
  plugins = { "ns430", "keypad" },
}

This is return makes the initial installation/activation of extensions more difficult. I am not sure yet what to make easier. Initial installation, or updates.

@aeronautes
Copy link
Collaborator

for extension/plugin ordering, the default to alpha ordering, adding a numeral to the front of the name will allow it to be ordered as desired

This is return makes the initial installation/activation of extensions more difficult. I am not sure yet what to make easier. Initial installation, or updates.

How about an extension for configuring scratchpad. It could just be button interface for the config lua file. Along those lines an extension for scratchpad help that's just the help/docs for scratchpad that can be read from within scratchpad. There seems to be many uses for extensions. That said how likely is extensions to go in main, especially for those considering making extensions.

@bellaevio
Copy link

hello could you please add as extension buttons like delete page copy page, paste page and bookmarks thanks

@rkusa rkusa marked this pull request as ready for review July 1, 2023 09:01
@rkusa
Copy link
Owner Author

rkusa commented Jul 1, 2023

hello could you please add as extension buttons like delete page copy page, paste page and bookmarks thanks

@bellaevio Hi, the extensions are a way so that I don't have to implement every use-case, so I'll not add that myself. You'll have to rely on others to jump in and add things like that - sorry.

@rkusa rkusa merged commit 664f89d into main Jul 1, 2023
@rkusa rkusa deleted the extensions branch July 1, 2023 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add In-Game Button to Clear the Current Scratch Pad...
4 participants