Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
YYBartT authored and gurpreetsinghmatharoo committed Aug 8, 2024
1 parent 27777c3 commit a92165a
Showing 1 changed file with 123 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>dbg_button</title>
<meta name="generator" content="Adobe RoboHelp 2022" />
<link rel="stylesheet" type="text/css" href="../../../assets/css/default.css" />
<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="" />
<meta name="search-keywords" content="" />
<meta name="template" content="assets/masterpages/Manual_Keyword_Page.htt" />
</head>
<body>
<h1><span data-field="title" data-format="default">dbg_button</span></h1>
<p>This function creates a button control within the current debug section. Clicking the button executes a <span data-keyref="Type_Function"><a href="../../GML_Overview/Script_Functions.htm" target="_blank">Function</a></span>.</p>
<p>The current debug section is the one last created using <span class="inline3_func"><a data-xref="{title}" href="dbg_section.htm">dbg_section</a></span>.</p>
<div data-conref="../../../assets/snippets/Note_Debug_Control_Single_Column.hts"> </div>
<p> </p>
<h4>Syntax:</h4>
<p class="code"><span data-field="title" data-format="default">dbg_button</span>(label, ref[, width, height]);</p>
<p> </p>
<table>
<colgroup>
<col />
<col />
<col />
</colgroup>
<tbody>
<tr>
<th>Argument</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>label</td>
<td><span data-keyref="Type_String"><a href="../../GML_Overview/Data_Types.htm" target="_blank">String</a></span></td>
<td>The button text</td>
</tr>
<tr>
<td>ref</td>
<td><span data-keyref="Type_DbgRef"><a href="../Variable_Functions/ref_create.htm" target="_blank">Reference</a></span> or <span data-keyref="Type_Function_Script"><a href="../../GML_Overview/Script_Functions.htm" target="_blank">Script Function</a></span> or <span data-keyref="Type_Function"><a href="../../GML_Overview/Script_Functions.htm" target="_blank">Function</a></span></td>
<td>A <span data-keyref="Type_Function"><a href="../../GML_Overview/Script_Functions.htm" target="_blank">Function</a></span> or <span data-keyref="Type_Function_Script"><a href="../../GML_Overview/Script_Functions.htm" target="_blank">Script Function</a></span> or a reference to one (created with <span class="inline3_func"><a data-xref="{title}" href="../Variable_Functions/ref_create.htm">ref_create</a></span>)</td>
</tr>
<tr>
<td>width</td>
<td><span data-keyref="Type_Real"><a href="../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td><span data-conref="../../../assets/snippets/Tag_optional.hts"> </span> The width of the button in pixels</td>
</tr>
<tr>
<td>height</td>
<td><span data-keyref="Type_Real"><a href="../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td><span data-conref="../../../assets/snippets/Tag_optional.hts"> </span> The height of the button in pixels</td>
</tr>
</tbody>
</table>
<p> </p>
<h4>Returns:</h4>
<p class="code"><span data-keyref="Type_Void">N/A</span></p>
<p> </p>
<h4>Example 1: Basic Use</h4>
<p class="code_heading">Create Event</p>
<p class="code">my_method = function()<br />
{<br />
    show_debug_message(&quot;Clicked the button!&quot;<br />
};<br />
<span data-field="title" data-format="default">dbg_button</span>(&quot;Click me!&quot;, my_method);
</p>
<p>The above code creates a button control in an <a href="../Asset_Management/Objects/Objects.htm">object</a>&#39;s Create event using <span class="inline3_func"><span data-field="title" data-format="default">dbg_button</span></span>. Since no calls are made to <span class="inline3_func"><a data-xref="{title}" href="dbg_view.htm">dbg_view</a></span> or <span class="inline3_func"><a data-xref="{title}" href="dbg_section.htm">dbg_section</a></span>, the button is added to a new debug section named <span data-keyref="DebugSection_Name_Default">&quot;Default&quot;</span> in a new debug view named <span data-keyref="DebugView_Name_Default">&quot;Default&quot;</span>. Clicking the button calls a function that shows a debug message using <span class="inline3_func"><a data-xref="{title}" href="show_debug_message.htm">show_debug_message</a></span>.</p>
<p> </p>
<h4>Example 2: Extended Example</h4>
<p class="code_heading">Script Asset</p>
<p class="code">/// Script Asset<br />
<br />
function script_function()<br />
{<br />
    show_message(&quot;Called the script function!&quot;);<br />
}
</p>
<p class="code_heading">Create Event</p>
<p class="code">my_method = function()<br />
{<br />
    show_message(&quot;Called the method!&quot;);<br />
}<br />
<br />
ref_to_method = ref_create(self, &quot;my_method&quot;);<br />
ref_to_script_function_global = ref_create(global, &quot;script_function&quot;);<br />
func = script_function;<br />
ref_to_script_function = ref_create(self, &quot;func&quot;);<br />
<br />
dbg_section(&quot;Function Calls&quot;);<br />
dbg_button(&quot;Call the Script Function&quot;, script_function, 400);<br />
dbg_button(&quot;Call the Script Function through the Reference&quot;, ref_to_script_function, 400);<br />
dbg_button(&quot;Call the Script Function through the Reference (Global)&quot;, ref_to_script_function_global, 400);<br />
dbg_button(&quot;Call the Method&quot;, my_method, 400);<br />
dbg_button(&quot;Call the Method through the Reference&quot;, ref_to_method, 400);<br />
dbg_section(&quot;Game&quot;);<br />
dbg_button(&quot;End the Game&quot;, game_end);
</p>
<p>The code example above shows a variety of ways to add button controls that execute functions to the debug overlay.</p>
<p>First, a script function is defined in a script asset as well as a method in an object&#39;s Create event. Then, also in the Create event, various references to the script function and to the method are created. Note that in case of <span class="inline2">ref_to_script_function</span>, you can change the function to be executed by simply assigning a new value to the instance variable <span class="inline2">func</span>. After that, two sections are added to the debug overlay. Several buttons are added to the first section, where each of them calls the script function or the method through a different path. One more button is added to the second section. Clicking this button executes the built-in function <span class="inline3_func"><a data-xref="{title}" href="../General_Game_Control/game_end.htm">game_end</a></span>, which can be called because it takes no (mandatory) arguments.</p>
<p>When the code has executed, <a data-xref="{title}" href="The_Debug_Overlay.htm">The Debug Overlay</a> is shown as any call to the <span class="inline2">dbg_*</span> functions will bring up the overlay.</p>
<p> </p>
<p> </p>
<div class="footer">
<div class="buttons">
<div class="clear">
<div>Back: <a data-xref="{title}" href="The_Debug_Overlay.htm">The Debug Overlay</a></div>
<div>Next: <a data-xref="{title}" href="dbg_checkbox.htm">dbg_checkbox</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2023 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
dbg_button
-->
<!-- TAGS
dbg_button
-->
</body>
</html>

0 comments on commit a92165a

Please sign in to comment.