YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

Code Snippets: Keybindings on custom code snippets aren't being used in 2023.11 #2284

Closed SmithTom6304 closed 9 months ago

SmithTom6304 commented 11 months ago

Description

In Beta IDE v2023.1100.0.444 Beta Runtime v2023.1100.0.455, custom code snippets aren't being loaded with their supplied hotkey. Default code snippets are loaded correctly.

Contact Us Package

Expected Change

Custom code snippets should have a default keybinding that matches the key specified in the snippets file

Steps To Reproduce

  1. Create a custom code snippets file following the provided steps
  2. Paste the following snippet in the file: I - Instance Create:instance_create_layer(x, y, |layer|, object);.
  3. Note the snippet starts with an I - this should be the default keybinding
  4. Open GameMaker
  5. Open a text editor
  6. Press F4 to open the snippets menu
  7. Observe the Instance Create snippet appears without it's provided hotkey
  8. Press I to insert the snippet
  9. Observe nothing happens

How reliably can you recreate this issue using your steps above?

Always

Which version of GameMaker are you reporting this issue for?

Beta (Please put the exact version number in your Description)

Which operating system(s) are you seeing the problem on?

macOS Ventura

Are you running GameMaker from inside your Steam library?

No

Contact Us Package Attached?

Sample Project Added?

SmithTom6304 commented 11 months ago

The recent change to our hotkeys system means code snippets need to be updated to provide a hotkey name rather than a raw keybinding. This requires a breaking change to the code snippets format. See YoYoGames/YoYoStudio#8972 for more information.

SmithTom6304 commented 11 months ago

Since the snippets format will change, this will require different steps to verify. We'll also need to verify remapping custom snippets works correctly. I'll provide verification steps for the new format once it's been decided on.

dicksonlaw583 commented 11 months ago

I am seeing this issue on 2023.11.0.121 as well. The hotkeys for built-in snippets appear to work just fine using the same format as before, but the hotkeys for custom snippets are not working at all. Because I use snippets extensively while working (see Speedcoding with Snippets), this and other hotkey-related bugs has left my workflow incompatible with the 2023.11.0.121 release.

dicksonlaw583 commented 11 months ago

@SmithTom6304

Do you have information on how the new hotkey names work? I don't have access to that YoYoGames/YoYoStudio project from your previous reply, but I would love to try the new format just to get it working again.

SmithTom6304 commented 11 months ago

Proper support for defining custom code snippet mappings will be available in 2024.2. However, there is a workaround for now:

  1. Create a custom code snippet in your snippets.txt file. ie. I - Instance Create:instance_create_layer(x, y, |layer|, object);
  2. Note that the name of the snippet here is just Instance Create - the leading I key will be ignored by the new system, and has no effect.
  3. Navigate to the default_hotkeys.json file included with your IDE install. 3.1. On Windows, this is in %programfiles%\GameMaker Studio 2[-Beta/etc..]. You should be able to find the default_hotkeys.json file from there - I don't have access to a Windows PC right now, so I can't give you the exact path. 3.2. On mac this is /Applications/GameMaker.app/Contents/MacOS/{arch}/default_hotkeys.json.
  4. Insert a new hotkey JSON entry:
    {
    "Name": "Insert Instance Create Snippet",
    "Description": "",
    "Combo": {
      "Modifier": "None",
      "Keys": "I"
    },
    "Location": "Text Editor"
    },
  5. There are a couple things to note here: 5.1. The Name property should be of the format "Insert {Snippet Name} Snippet". Since this example is for the Instance Create snippet (see step 2), this is "Insert Instance Create Snippet" 5.2. The "Keys" and "Modifiers" properties specify the combo, and doesn't necessarily match up with the code snippet format. See the other hotkeys in this file for examples. 5.2.1. Mac users can also check out the mac_hotkeys.json file, for some mac specific examples. 5.3. The "Location" and "Localisation" fields are used in the Redefine Keys menu. I've omitted the "Localisation" field for this example, as there will not be a localisation value for you to use in our localisation files. 5.4. Finally - this file is included with the IDE, and will be replaced if you update GameMaker. ! IF YOU UPDATE GAMEMAKER, THIS FILE WILL BE OVERWRITTEN !

I'm away on holiday for the remainder of the year, so I won't be around to answer any questions - hopefully these instructions are clear enough, and you're able to figure anything out I've missed. And just to be clear, this is a workaround. You're on your own if anything goes wrong, make sure to back things up that you don't want to lose. Proper support will be included in the 2024.2 release.

SmithTom6304 commented 11 months ago

@dicksonlaw583 See above - hopefully this should get you running again, and apologies for not having proper support in for 2023.11.

muddrox commented 9 months ago

I have been staring at my snippets file for the past hour and a half trying to figure out why it no longer works. Glad I stumbled upon this because I thought I was going crazy.

SmithTom6304 commented 9 months ago

Support for creating empty hotkeys from custom snippets has been implemented. Still need to add a conversion step from existing keybinds to our new hotkey format. This will require modifying users snippets file in place (to remove the leading character), and so will need a dialog warning.

SmithTom6304 commented 9 months ago

Added conversion step. From the PR:

Conversion step

For each snippet found in snippets.txt, an empty hotkey is created and added to the KeyboardShortcutManager. When a snippet is found in the old format (ie. with a leading key bind):

I - Instance Create:instance_create_layer(x, y, |layer|, object);

we prompt the user if they want to update their snippets. If they select no, the snippets aren't loaded. If they select yes, we:

There is a slight issue here, in that remapped hotkeys are stored per user in the user settings folder but code snippets are stored globally in the system-wide settings folder. To accomodate this, we save these remapped snippets hotkeys for any user who logs in during the session where the conversion takes place. Once GameMaker is closed, these bindings will be loaded from the users remaps file rather than the snippets file (which has had its bindings removed) - meaning if a user wants to add a binding for a snippet after GameMaker has been closed, it must be done through Redefine Keys rather than done automatically.

mgeddesGM commented 9 months ago

verified for win on IDE v2024.200.0.476 Runtime v2024.200.0.491. Issue can be verified once Mac is tested

Emc1923 commented 9 months ago

Verified also for Mac. Thanks!

SmithTom6304 commented 8 months ago

For any users wondering how to remap a snippet after the conversion has taken place: this should now be done via the Preferences -> Redefine Keys menu.