Skip to content

Commit

Permalink
Merge pull request #167 from YoYoGames/develop
Browse files Browse the repository at this point in the history
2024.8 monthly
  • Loading branch information
gurpreetsinghmatharoo authored Sep 3, 2024
2 parents 93dbeb8 + 1e36e5a commit 7dbcd43
Show file tree
Hide file tree
Showing 467 changed files with 10,303 additions and 5,716 deletions.
78 changes: 29 additions & 49 deletions Manual/GenerateKeyboardShortcutTableFromJson.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
### Python script to generate copy-pasteable HTML tables from JSON files
### Python script to generate copy-pasteable HTML tables from JSON file
###
### Provide the full directory path to the .json files as the command line argument.
### 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/ameMaker-Manual/Manual/" -name_as_desc -env beta -update_rh_vars
### 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 files
### -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
Expand All @@ -30,18 +27,8 @@
# 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):
def get_combo_string(combo, replace_in_names=[]):
global mods
if not combo:
combo_string = ""
Expand All @@ -55,11 +42,14 @@ def get_combo_string(combo):
else:
# This is a regular hotkey
combo_string = " + ".join([*modifier, combo['Keys']])

if replace_in_names:
for item in replace_in_names:
combo_string = combo_string.replace(item[0], item[1])
return combo_string

# Default names
fname_win_hotkeys = "default_hotkeys.json"
fname_mac_hotkeys = "mac_hotkeys.json"
fname_hotkeys = "default_hotkeys.json"

install_dirs = {
"dev": "GameMaker-Dev",
Expand Down Expand Up @@ -98,22 +88,20 @@ def get_combo_string(combo):
exit()

# Check if files exist
fpath_win = in_dir + os.sep + fname_win_hotkeys
fpath_mac = in_dir + os.sep + fname_mac_hotkeys
if not os.path.isfile(fpath_win) or not os.path.isfile(fpath_mac):
print("ERROR - One or more files doesn't exist. Exiting...")
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

# First read the Windows defaults file
# 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
input = json.load(f) # risk of errors if trailing commas are present

# Add items under their respective locations (i.e. "group" per location)
for shortcut in input:
Expand All @@ -139,6 +127,20 @@ def get_combo_string(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

# Get this shortcut's Mac combo(s)
cbo = override['Combo']
combos = [cbo] if type(cbo) is not list else cbo
combo_strings = [get_combo_string(combo, replace_in_names=[("Windows", "Command")]) for combo in combos]

# Assign to final output
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
Expand All @@ -151,28 +153,6 @@ def get_combo_string(combo):
# Add the shortcut
shortcuts_per_location[location][name] = name

# Then add the combos in the macOS defaults file
with open(fpath_mac, 'r') as f:
# Load all the data
input = yy_load(f)

# Add items under their respective locations
for shortcut in input:
# Get unique name
name = shortcut['Name']

# Nothing to do for unlisted shortcuts
if name not in shortcuts:
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]

# Just overwrite the macOS combo under the right name here
shortcuts[name]['mac_combo'] = combo_strings

# Generate HTML
html = ""
for location in shortcuts_per_location:
Expand Down
1 change: 0 additions & 1 deletion Manual/_page_generation/Template_Code_Page.htm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<body>
<h1><span data-field="title" data-format="default">INSERT_TITLE</span></h1>
<p>Keyword Description Goes Here.</p>
<p>Additional Information Goes Here.</p>
<p> </p>
<h4>Syntax:</h4>
<p class="code"><span data-field="title" data-format="default"></span>(arguments);</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h1><span data-field="title" data-format="default">Additional Information</span>
<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 data-xref="{title}" href="Objects_vs_Instances.htm">Objects vs. Instances</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 @@ -32,6 +33,7 @@ <h1><span data-field="title" data-format="default">Additional Information</span>
<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>
Expand All @@ -42,7 +44,7 @@ <h1><span data-field="title" data-format="default">Additional Information</span>
<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. 2023 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 @@ -24,7 +24,7 @@ <h1>Best Practices When Programming</h1>
<p><a class="dropspot" data-rhwidget="DropSpot" data-target="drop-down" href="#">Programming Style</a></p>
<div class="droptext" data-targetname="drop-down">
<p class="dropspot">When it comes to writing code everyone has a <em>style</em>. The style you program in is the way you place your brackets, how you indent the lines, and how you declare and name variables, etc., and is essential to making your code clear and readable to other people (and to your future self, when you have to come back to this project after a time on something else).</p>
<p class="dropspot">There are many, many <a href="http://en.wikipedia.org/wiki/Programming_style">programming styles</a>, and some would argue that theirs is the best one to use, but the truth is that almost any style is fine as long as you are <strong>consistent </strong>when using it and it is <em>clear </em>and <em>obvious </em>what everything is and does.</p>
<p class="dropspot">There are many, many <a href="https://en.wikipedia.org/wiki/Programming_style">programming styles</a>, and some would argue that theirs is the best one to use, but the truth is that almost any style is fine as long as you are <strong>consistent </strong>when using it and it is <em>clear </em>and <em>obvious </em>what everything is and does.</p>
<p class="dropspot"><img alt="Code Style Example" class="center" src="../assets/Images/Scripting_Reference/Additional_Information/BestPractice_Style_Example.png" />The above image is an example of a function declaration in a script to illustrate the above points. You can see that it uses the JSDoc style comments to clearly explain what it all does, and the coding style is consistent, with 4 space indents, underscores used for local vars, logged output, etc...</p>
<p class="dropspot">Also note that while the script editor permits you to fold code at each of the open/close brackets, you can use <span class="inline">#region</span> and <span class="inline">#endregion</span> tags to section off parts of your code and greatly enhance readability, especially when dealing with larger scripts which contain multiple functions. Regions can be commented, too - see the Editing section of this page in the manual):</p>
<p class="dropspot"><img alt="Example Of Using Regions" class="center" src="../assets/Images/Scripting_Reference/Additional_Information/BestPractice_Regions.png" />When writing code, you should be aware that when compiling your final game, <span data-keyref="GameMaker Name">GameMaker</span> strips out comments, removes unnecessary line breaks and whitespace, substitutes in constant/macro/enum values, and generally compresses your code down as part of the process. This means that you can add as much whitespace around your code as required and you don&#39;t need to worry about keeping your comments short or only using them sparingly.</p>
Expand Down Expand Up @@ -122,7 +122,7 @@ <h1>Best Practices When Programming</h1>
<p> </p>
<p>Apart from the main things mentioned above, there are other more general things that can help with performance and that are considered &quot;good practices&quot; too:</p>
<ul class="colour">
<li>don&#39;t be afraid to use the trigonometric functions as (contrary to popular belief) they are pretty fast, especially when compared to particles, collisions, strings, etc...</li>
<li>don&#39;t be afraid to use the trigonometric functions as (contrary to popular belief) they are pretty fast, especially when compared to particles, collisions, strings, etc.</li>
<li>don&#39;t put code that is not for drawing things in the Draw events</li>
<li>use an alarm to call any code that doesn&#39;t have to be called every step (rather than just adding this into the Step event anyway)</li>
</ul>
Expand All @@ -134,10 +134,10 @@ <h1>Best Practices When Programming</h1>
<div class="buttons">
<div class="clear">
<div style="float:left">Back: <a href="Additional_Information.htm">Additional Information</a></div>
<div style="float:right">Next: <a href="Bitwise_Operators.htm">Bitwise Operators</a></div>
<div style="float:right">Next: <a data-xref="{title}" href="Objects_vs_Instances.htm">Objects vs. Instances</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2023 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
Nest Practices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Compiler Errors</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" type="module"></script>
<meta name="rh-authors" content="Mark Alexander" />
Expand Down Expand Up @@ -45,15 +45,15 @@ <h1>Compile Errors</h1>
</tr>
<tr>
<td>Fatal Error while compiling <i>[name]</i> - bailing details below</td>
<td>This message simply means that some error has been discovered but the compiler cannot place what or where (if this happens consistently you may wish to contact <a href="https://accounts.yoyogames.com/contact-us" target="_blank">support</a> and supply the details that the compiler output window shows)</td>
<td>This message simply means that some error has been discovered but the compiler cannot place what or where (if this happens consistently you may wish to contact <a href="https://gamemaker.io/en/contact-us" target="_blank">support</a> and supply the details that the compiler output window shows)</td>
</tr>
<tr>
<td>Recursive macro expansion is not supported</td>
<td>You have used recursive macros that refer to each other and constantly expand</td>
</tr>
<tr>
<td>Unable to find TextureGroup <span class="inline">[group]</span></td>
<td>This error is usually only found from trying to run a malformed project file (if this happens consistently you may wish to contact <a href="https://accounts.yoyogames.com/contact-us" target="_blank">support</a> and supply the details that the compiler output window shows)</td>
<td>This error is usually only found from trying to run a malformed project file (if this happens consistently you may wish to contact <a href="https://gamemaker.io/en/contact-us" target="_blank">support</a> and supply the details that the compiler output window shows)</td>
</tr>
<tr>
<td>Wrong to convert <span class="inline">[value]</span> to number</td>
Expand Down Expand Up @@ -483,7 +483,7 @@ <h1>Compile Errors</h1>
<div style="float:right">Next: <a href="Runner_Errors.htm">Runner Errors</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
Compiler Errors
Expand Down
Loading

0 comments on commit 7dbcd43

Please sign in to comment.