Changes

Jump to navigation Jump to search
ZH link
Line 48: Line 48:     
===Check cursor position===
 
===Check cursor position===
The <samp>GetCursorPosition()</samp> method provides the [[#ICursorPosition|cursor position in three coordinate systems|ICursorPosition]].
+
The <samp>GetCursorPosition()</samp> method provides the [[#ICursorPosition|cursor position in three coordinate systems]].
    
For example:
 
For example:
Line 107: Line 107:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
You can also convert <samp>SButton</samp> to the other constants. This uses a <samp>TryGet</samp> approach since <samp>SButton</samp> is a superset of the others (e.g. you can't convert <samp>SButton.ControllerA</samp> to a keyboard value):
+
You can also convert <samp>SButton</samp> to the other constants. This uses a <samp>TryGet</samp> approach since <samp>SButton</samp> is a superset of the others (''e.g.,'' you can't convert <samp>SButton.ControllerA</samp> to a keyboard value):
 
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
 
SButton value = SButton.A;
 
SButton value = SButton.A;
Line 143: Line 143:  
class ModConfig
 
class ModConfig
 
{
 
{
   public KeybindList ToggleKey { get; set; } = KeybindList.Parse("Shift + F2");
+
   public KeybindList ToggleKey { get; set; } = KeybindList.Parse("LeftShift + F2");
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 149: Line 149:  
| <syntaxhighlight lang="json">
 
| <syntaxhighlight lang="json">
 
{
 
{
   "ToggleKey": "Shift + F2"
+
   "ToggleKey": "LeftShift + F2"
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 183: Line 183:  
|-
 
|-
 
| <code>GetState()</code>
 
| <code>GetState()</code>
| Get the overall [[#Check button state|keybind state relative to the previous tick]]. This state is transitive across keybinds; ''e.g.'',if the player releases one keybind and immediately presses another within the list, the overall state is <samp>Held</samp>.
+
| Get the overall [[#Check button state|keybind state relative to the previous tick]]. This state is transitive across keybinds; ''e.g.,'' if the player releases one keybind and immediately presses another within the list, the overall state is <samp>Held</samp>.
 
|-
 
|-
 
| <code>IsDown()</code>
 
| <code>IsDown()</code>
| Get whether any keybind in the list is currently down (i.e. the player pressed or is holding down the keys).
+
| Get whether any keybind in the list is currently down (''i.e.,'' the player pressed or is holding down the keys).
 
|-
 
|-
 
| <code>JustPressed()</code>
 
| <code>JustPressed()</code>
| Get whether the player just activated the keybind during the current tick (i.e. <code>GetState()</code> returns <samp>Pressed</samp> instead of <samp>Held</samp>).
+
| Get whether the player just activated the keybind during the current tick (''i.e.,'' <code>GetState()</code> returns <samp>Pressed</samp> instead of <samp>Held</samp>).
 
|-
 
|-
 
| <code>GetKeybindCurrentlyDown()</code>
 
| <code>GetKeybindCurrentlyDown()</code>
Line 195: Line 195:  
|-
 
|-
 
| <code>ToString()</code>
 
| <code>ToString()</code>
| Get a string representation of the input binding (e.g. <code>"F2, LeftShift + S"</code>).
+
| Get a string representation of the input binding (''e.g.,'' <code>"F2, LeftShift + S"</code>).
 
|}
 
|}
   Line 210: Line 210:  
This is returned by the <samp>this.Helper.Input.GetCursorPosition()</samp> method and in the event args for some input events.
 
This is returned by the <samp>this.Helper.Input.GetCursorPosition()</samp> method and in the event args for some input events.
   −
'''The pixel positions are ''not'' adjusted for [[Modding:Modder Guide/Game Fundamentals#UI scaling|UI scaling]]''' (i.e. they're non-UI mode). Whether you need UI or non-UI positions depends how you're using them, so you can use <samp>cursorPos.GetScaledAbsolutePixels()</samp> or <samp>cursorPos.GetScaledScreenPixels()</samp> to adjust them automatically for the current mode or <samp>Utility.ModifyCoordinatesForUIScale</samp> to always get UI mode coordinates.
+
'''The pixel positions are ''not'' adjusted for [[Modding:Modder Guide/Game Fundamentals#UI scaling|UI scaling]]''' (''i.e.,'' they're non-UI mode). Whether you need UI or non-UI positions depends how you're using them, so you can use <samp>cursorPos.GetScaledAbsolutePixels()</samp> or <samp>cursorPos.GetScaledScreenPixels()</samp> to adjust them automatically for the current mode or <samp>Utility.ModifyCoordinatesForUIScale</samp> to always get UI mode coordinates.
    
==See also==
 
==See also==
 
* [[../Events#Input|Input events]]
 
* [[../Events#Input|Input events]]
 
* [[Modding:Player Guide/Key Bindings]] for a list of valid <samp>SButton</samp> values
 
* [[Modding:Player Guide/Key Bindings]] for a list of valid <samp>SButton</samp> values
 +
 +
[[zh:模组:制作指南/APIs/Input]]
106,354

edits

Navigation menu