Skip to content

Commit

Permalink
Merge pull request #101 from YoYoGames/develop.bart
Browse files Browse the repository at this point in the history
Develop.bart
  • Loading branch information
gurpreetsinghmatharoo authored Feb 29, 2024
2 parents dbe93f7 + 0013d14 commit 5ca13db
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
26 changes: 21 additions & 5 deletions Manual/GenerateKeyboardShortcutTableFromJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,30 @@
### Provide the full directory path to the .json files as the command line argument.
### The output HTML file will also be placed there.
### For example: CMD > python GenerateKeyboardShortcutTableFromJson.py "C:/Users/Dev/Documents/Manual/" -name_as_desc
###
### You can provide an optional argument:
###
### -name_as_desc: Add this to write the hotkey's name as the description.
###
### Important: The JSON cannot contain trailing commas, this isn't supported
### using the built-in json module.
### Important: Technically, the JSON cannot contain trailing commas, this isn't supported
### using the built-in json module. Though it is supported through the yy_load function.
###

import sys
import json
import re
from collections import OrderedDict

def yy_load(file):
""" Load json from a file that possibly contains trailing commas """
# Do some tricky regex substitution
# so we can use the json module
data_string = ''.join(file.readlines())
data_string = re.sub("(,)(\s*[]}])","\g<2>", data_string)

# Now we can import using the json module
return json.loads(data_string)

# Utility functions
def get_combo_string(combo):
if not combo:
Expand Down Expand Up @@ -42,9 +57,10 @@ def get_combo_string(combo):
shortcuts_per_location = OrderedDict() # stores shortcuts under locations

# First read the Windows defaults file
with open(fdir + "/" + fname_win_hotkeys, 'r') as f:
with open(fdir + "/" + fname_win_hotkeys, 'r', encoding="utf-8") as f:
# Load all the data
input = json.load(f)
# input = json.load(f) # risk of errors if trailing commas are present
input = yy_load(f) # regex-replace variety that fixes things

# Add items under their respective locations (i.e. "group" per location)
for shortcut in input:
Expand Down Expand Up @@ -84,7 +100,7 @@ def get_combo_string(combo):
# Then add the combos in the macOS defaults file
with open(fdir + "/" + fname_mac_hotkeys, 'r') as f:
# Load all the data
input = json.load(f)
input = yy_load(f)

# Add items under their respective locations
for shortcut in input:
Expand Down
26 changes: 18 additions & 8 deletions Manual/contents/IDE_Navigation/Keyboard_Shortcuts.htm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h2>Global</h2>
<th>Scope</th>
<th>Description</th>
</tr>
<tr>
<tr class="rh-cursor-row">
<td>Control + Equals</td>
<td>Command + Equals</td>
<td>Global</td>
Expand Down Expand Up @@ -702,7 +702,7 @@ <h2>Room Editor</h2>
<th>Scope</th>
<th>Description</th>
</tr>
<tr>
<tr class="rh-cursor-row">
<td>Control + R</td>
<td>Command + R</td>
<td>Room Editor</td>
Expand Down Expand Up @@ -891,8 +891,12 @@ <h2>Room Editor</h2>
<td>Paint With Resource</td>
</tr>
<tr>
<td>Control + Alt</td>
<td>Command + Alt</td>
<td>Control + Left<br />
Control + Right<br />
Control + Up<br />
Control + Down</td>
<td>Command + Alt<br />
Alt + Command</td>
<td>Room Editor</td>
<td>Paint With Resource Precise Item Placement</td>
</tr>
Expand All @@ -908,6 +912,12 @@ <h2>Room Editor</h2>
<td>Room Editor</td>
<td>Select Override</td>
</tr>
<tr>
<td>Shift</td>
<td> </td>
<td>Room Editor</td>
<td>Select Tile Brush Subsection</td>
</tr>
</tbody>
</table>
<h2>Sequence Editor</h2>
Expand Down Expand Up @@ -1308,7 +1318,7 @@ <h2>Image Editor</h2>
<th>Scope</th>
<th>Description</th>
</tr>
<tr>
<tr class="rh-cursor-row">
<td>Space</td>
<td> </td>
<td>Image Editor</td>
Expand Down Expand Up @@ -1657,7 +1667,7 @@ <h2>Sprite Editor</h2>
<th>Scope</th>
<th>Description</th>
</tr>
<tr>
<tr class="rh-cursor-row">
<td>Space</td>
<td> </td>
<td>Sprite Editor</td>
Expand Down Expand Up @@ -1716,7 +1726,7 @@ <h2>Object Editor</h2>
<th>Scope</th>
<th>Description</th>
</tr>
<tr>
<tr class="rh-cursor-row">
<td>Space</td>
<td> </td>
<td>Object Editor</td>
Expand Down Expand Up @@ -1946,7 +1956,7 @@ <h2>Tile Set Editor</h2>
<th>Scope</th>
<th>Description</th>
</tr>
<tr>
<tr class="rh-cursor-row">
<td>Control + Shift + I</td>
<td>Command + Shift + I</td>
<td>Tile Set Editor</td>
Expand Down

0 comments on commit 5ca13db

Please sign in to comment.