Skip to content

Commit

Permalink
Merge pull request #157 from YoYoGames/lts-2022-r3
Browse files Browse the repository at this point in the history
Lts 2022 r3
  • Loading branch information
gurpreetsinghmatharoo authored Nov 20, 2024
2 parents 9c69dc7 + a6c210a commit e75885a
Show file tree
Hide file tree
Showing 828 changed files with 19,249 additions and 14,640 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
name: "RoboHelp"
runs-on: windows-2019
steps:
- uses: aws-actions/configure-aws-credentials@v3
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.REGION }}
- name: Enable git long paths to bypass path limit on Windows
run: git config --system core.longpaths true
- name: Check out the GMS2_Documentation repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: Manual
token: ${{ secrets.GH_TOKEN }}
Expand All @@ -31,7 +31,7 @@ jobs:
shell: cmd
working-directory: Manual
- name: Upload robohelp zip file
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: YoYoStudioRoboHelp
path: output\RoboHelp\*.zip
Expand Down
241 changes: 241 additions & 0 deletions Manual/GenerateKeyboardShortcutTableFromJson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
### Python script to generate copy-pasteable HTML tables from JSON file
###
### Provide the full directory path to the .json file as the command line argument.
### The output HTML file will also be placed there.
### For example: CMD > python GenerateKeyboardShortcutTableFromJson.py "C:/Users/Dev/Documents/GitHub/GameMaker-Manual/Manual/" -name_as_desc -env beta
###
### You can provide a few optional arguments:
###
### -name_as_desc: Add this to write the hotkey's name as the description.
### -env: Provide this, followed by the environment in which you want to look for the JSON file
### (one of: "dev", "lts", "beta", "prod")
### Note: only works on Windows!
### -update_rh_vars: Add this to update the RoboHelp variables
### A RH variable is written (or updated if exists) for every Win/Mac shortcut
### For example: Hotkey_Create_Asset_Win, Hotkey_Create_Asset_Mac
###
### 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 os
import json
import re
from collections import OrderedDict

# Write to RoboHelp variables
import xml.etree.ElementTree as ET

# Unique modifier keys
mods = set()

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):
global mods
if not combo:
combo_string = ""
else:
modifier = [key for key in combo['Modifier'].split(", ") if key != "None"]
mods.update(modifier)
if type(combo['Keys']) is list:
# This is a hotkey chord
mods = " + ".join([*modifier])
combo_string = " => ".join([mods + " + " + key for key in combo['Keys']])
else:
# This is a regular hotkey
combo_string = " + ".join([*modifier, combo['Keys']])
return combo_string

# Default names
fname_hotkeys = "default_hotkeys.json"

install_dirs = {
"dev": "GameMaker-Dev",
"lts": "GameMaker-LTS",
"beta": "GameMaker-Beta",
"prod": "GameMaker"
}

# Handle parameters received from command line
if len(sys.argv) == 1:
print("ERROR - The input/output directory should be provided. Exiting...")
exit()
else:
out_dir = sys.argv[1]
in_dir = out_dir

# Whether to use the shortcut's name as the description
name_as_desc = "-name_as_desc" in sys.argv

# Whether to create new and/or update existing RH hotkey variables
write_update_rh_vars = "-update_rh_vars" in sys.argv

# Use an existing GM installation to get the JSON files, if provided
env = "out_dir"
if "-env" in sys.argv:
ind = sys.argv.index("-env")
env = sys.argv[ind+1]
in_dir = os.environ['ProgramFiles'] + os.sep + install_dirs[env]
if not os.path.isdir(in_dir):
# Revert to out_dir if there's no such directory
in_dir = out_dir

# Check if directories exist
if not os.path.isdir(in_dir) or not os.path.isdir(out_dir):
print("ERROR - One or more directories don't exist. Exiting...")
exit()

# Check if files exist
fpath_win = in_dir + os.sep + fname_hotkeys
if not os.path.isfile(fpath_win):
print("ERROR - Shortcuts file doesn't exist. Exiting...")
exit()

# Data structures
input = [] # input from file
shortcuts = dict() # maps shortcut name => shortcut data
shortcuts_per_location = OrderedDict() # stores shortcuts under locations

# Read the defaults file
with open(fpath_win, 'r', encoding="utf-8") as f:
# Load all the data
# 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:
# Get unique name
name = shortcut['Name']

# Nothing to do for unlisted shortcuts?
#if 'IsUnlisted' in shortcut:
if 'IsListed' in shortcut and shortcut['IsListed'] == False:
continue

# Get this shortcut's combo(s)
cbo = shortcut['Combo']
combos = [cbo] if type(cbo) is not list else cbo
combo_strings = [get_combo_string(combo) for combo in combos]

# Store shortcut data (name as the key)
shortcuts[name] = {
"name": name,
"description": shortcut['Description'] if ('Description' in shortcut) else "",
"win_combo": combo_strings,
"mac_combo": []
# "Localisation": combo['Localisation']
}

# Store platform overrides, if there are any
if 'PlatformOverrides' in shortcut and shortcut['PlatformOverrides']:
for override in shortcut['PlatformOverrides']:
if override['Platform'] != 'MacOs':
continue
cbo = override['Combo']
combos = [cbo] if type(cbo) is not list else cbo
combo_strings = [get_combo_string(combo) for combo in combos]
shortcuts[name]['mac_combo'] = combo_strings

# Store name of shortcut under all its locations
loc = shortcut['Location']
locations = [loc] if (type(loc) == str) else loc

for location in locations:
# Make sure a list exists under the key before writing to it
if location not in shortcuts_per_location:
shortcuts_per_location[location] = OrderedDict()

# Add the shortcut
shortcuts_per_location[location][name] = name

# Generate HTML
html = ""
for location in shortcuts_per_location:
html += "<h2>{0}</h2>".format(location)
html += "<table>\n<tr><th>Windows Key Binding</th><th>macOS Key Binding</th><th>Scope</th><th>Description</th></tr>"

for name in shortcuts_per_location[location].keys():
sc = shortcuts[name]
desc = name if name_as_desc else sc['description']
html += "<tr>"
# html += "<td>" + name + "</td>"
html += "<td>" + "<br />".join(sc['win_combo']) + "</td>"
html += "<td>" + "<br />".join(sc['mac_combo']) + "</td>"
html += "<td>" + location + "</td>"
html += "<td>" + desc + "</td>"
html += "</tr>"

html += "</table>"

# Write to file
fpath_out = out_dir + "/" + "shortcuts.htm"
with open(fpath_out, 'w') as f:
f.write(html)

# Output unique keys
print("Shortcuts of environment " + str(env) + " written to file:")
print(fpath_out)

if not write_update_rh_vars:
print("Not writing RH variables. Exiting...")
exit()

# Optional: write to RH variables
fdir = os.getcwd() + os.sep + "variable"
fpath = fdir + os.sep + "Default.var"
tree = ET.parse(fpath)
root = tree.getroot()
vars = {}
for child in root:
# Skip title tag to avoid parsing issues
if child.tag == "title":
continue

# Reconstruct RH vars mapping
key = child.attrib["keys"]
val = child[0][0][0].text
vars[key] = val

# Update or append shortcuts
for sc in shortcuts:
readable_name = sc.replace("-", "")
readable_name = readable_name.replace("+", "And")

for platform in ["win", "mac"]:
suffix = "_" + platform.capitalize()
key_name = "Hotkey_" + readable_name.replace(" ", "_") + suffix
v = [tag for tag in root.findall('.//keydef[@keys]') if tag.attrib['keys'] == key_name]
sc_key_name = platform + '_combo'
text = ", ".join(shortcuts[sc][sc_key_name])

if v:
# The shortcut already exists!
# Update
e = v[0]
e[0][0][0].text = text
else:
# The shortcut is a new one for the RH variables.
# Create
e = ET.SubElement(root, "keydef", attrib = {"keys": key_name})
ec = ET.SubElement(e, "topicmeta")
ec2 = ET.SubElement(ec, "keywords")
ec3 = ET.SubElement(ec2, "keyword")
ec3.text = text

# Prettify XML to maintain line-by-line diffs
ET.indent(tree, space="\t")

tree.write(fpath, encoding='utf-8', xml_declaration=True)

print("RoboHelp variables updated.")
10 changes: 5 additions & 5 deletions Manual/_page_generation/Template_Code_Page.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<title>INSERT_TITLE</title>
<meta name="generator" content="Adobe RoboHelp 2020" />
<link rel="stylesheet" type="text/css" href="assets/css/default.css" />
<script src="assets/scripts/main_script.js"></script>
<meta name="rh-authors" content="INSERT_AUTHOR" />
<meta name="topic-comment" content="INSERT_DESCRIPTION" />
<script src="assets/scripts/main_script.js" type="module"></script>
<meta name="rh-authors" content="" />
<meta name="topic-comment" content="" />
<meta name="rh-index-keywords" content="INSERT_INDEX" />
<meta name="search-keywords" content="INSERT_KEYWORDS" />
<meta name="template" content="assets/masterpages/Manual_Keyword_Page.htt" />
Expand All @@ -19,7 +19,7 @@ <h1><span data-field="title" data-format="default">INSERT_TITLE</span></h1>
<p>Additional Information Goes Here.</p>
<p> </p>
<h4>Syntax:</h4>
<p class="code">keyword_name(arguments);</p>
<p class="code"><span data-field="title" data-format="default"></span>(arguments);</p>
<table>
<colgroup>
<col />
Expand Down Expand Up @@ -53,7 +53,7 @@ <h4>Example:</h4>
<div class="footer">
<div class="buttons">
<div class="clear">
<div>Back: </div>
<div>Back: <a data-xref="{title}" href="section_index.htm">Section Index</a></div>
<div>Next: </div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions Manual/_page_generation/Template_Normal_Page.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<title>INSERT_TITLE</title>
<meta name="generator" content="Adobe RoboHelp 2020" />
<link rel="stylesheet" href="assets/css/default.css" type="text/css" />
<script src="assets/scripts/main_script.js"></script>
<meta name="rh-authors" content="INSERT_AUTHOR" />
<meta name="topic-comment" content="INSERT_DESCRIPTION" />
<script src="assets/scripts/main_script.js" type="module"></script>
<meta name="rh-authors" content="" />
<meta name="topic-comment" content="" />
<meta name="rh-index-keywords" content="INSERT_INDEX" />
<meta name="search-keywords" content="INSERT_KEYWORDS" />
<meta name="template" content="assets/masterpages/Manual_Page.htt" />
Expand Down
8 changes: 4 additions & 4 deletions Manual/_page_generation/Template_Visual_Page.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<title>INSERT_TITLE</title>
<meta name="generator" content="Adobe RoboHelp 2020" />
<link rel="stylesheet" type="text/css" href="assets/css/default.css" />
<script src="assets/scripts/main_script.js"></script>
<meta name="rh-authors" content="INSERT_AUTHOR" />
<meta name="topic-comment" content="INSERT_DESCRIPTION" />
<script src="assets/scripts/main_script.js" type="module"></script>
<meta name="rh-authors" content="" />
<meta name="topic-comment" content="" />
<meta name="rh-index-keywords" content="INSERT_INDEX" />
<meta name="search-keywords" content="INSERT_KEYWORDS" />
<meta name="template" content="assets/masterpages/Manual_Keyword_Page.htt" />
Expand Down Expand Up @@ -42,7 +42,7 @@ <h4>Example:</h4>
<div class="footer">
<div class="buttons">
<div class="clear">
<div>Back: </div>
<div>Back: <a data-xref="{title}" href="section_index.htm">Section Index</a></div>
<div>Next: </div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Additional Information</title>
<meta name="generator" content="Adobe RoboHelp 2020" />
<meta name="generator" content="Adobe RoboHelp 2022" />
<link rel="stylesheet" href="../assets/css/default.css" type="text/css" />
<script src="../assets/scripts/main_script.js"></script>
<script src="../assets/scripts/main_script.js" type="module"></script>
<meta name="rh-authors" content="Mark Alexander" />
<meta name="topic-comment" content="Page with additional information about programming features" />
<meta name="rh-index-keywords" content="Additional Information" />
<meta name="search-keywords" content="Additional Information" />
</head>
<body>
<!--<div class="body-scroll" style="top: 150px;">-->
<h1>Additional Information</h1>
<p>This section of the manual contain a collection of miscellaneous articles related to programming and the way the GameMaker Language works. The following articles are designed as companion articles to further expand your understanding of how GameMaker works and how to get the most from the different language features available:</p>
<h1><span data-field="title" data-format="default">Additional Information</span></h1>
<p>This section of the manual contain a collection of miscellaneous articles related to programming and the way the GameMaker Language works. The following articles are designed as companion articles to further expand your understanding of how <span data-keyref="GameMaker Name">GameMaker</span> works and how to get the most from the different language features available:</p>
<ul class="colour">
<li><a href="Best_Practices_When_Programming.htm">Best Practices When Programming</a></li>
<li><a href="The_File_System.htm">The File System</a></li>
<li><a href="Bitwise_Operators.htm">Bitwise Operators</a></li>
<li><a href="Type_Tables.htm">Type Tables</a></li>
<li><a data-xref="{title}" href="Whitespace_Characters.htm">White-space Characters</a></li>
Expand All @@ -28,21 +27,22 @@ <h1>Additional Information</h1>
<li><a href="Guide_To_Using_Shaders.htm">Guide To Using Shaders</a></li>
<li><a href="Guide_To_Primitives_And_Vertex_Building.htm">Guide To Primitives And Vertex Building</a></li>
<li><a href="Guide_To_Using_Blendmodes.htm">Guide To Using Blendmodes</a></li>
<li><a data-xref="{title}" href="Project_Format.htm">Project Format</a></li>
<li><a href="Compatibility_Functions.htm">Compatibility Functions</a></li>
<li><a href="Compatibility_Scripts.htm">Compatibility Scripts</a></li>
<li><a href="Obsolete_Functions.htm">Obsolete Functions</a></li>
<li><a data-xref="{title}" href="../Introduction/The_Marketplace.htm">The Marketplace</a></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<div class="footer">
<div class="buttons">
<div class="clear">
<div style="float:left">Back: <a href="../Content.htm">Index</a></div>
<div style="float:right">Next: <a data-xref="{text}" href="../GameMaker_Language.htm#h">GameMaker Language</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2022 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
Additional Information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ <h1>Compile Errors</h1>
</tr>
<tr>
<td>Calling a function that needs an instance and no instance is available</td>
<td><span>The function or script being called is for acting on an instance, but at the time of running no instances exist</span></td>
<td>The function or script being called is for acting on an instance, but at the time of running no instances exist</td>
</tr>
<tr>
<td>Calling a function that needs an other and no other is available</td>
Expand Down
Loading

0 comments on commit e75885a

Please sign in to comment.