mirror of
https://codeberg.org/sunder/sunder.git
synced 2026-07-15 22:14:33 +00:00
upgrade gut
This commit is contained in:
parent
6e724f67fe
commit
82aeebfd35
201 changed files with 8547 additions and 3871 deletions
|
|
@ -1,4 +1,5 @@
|
|||
## Static class full of helper methods to make InputEvent instances
|
||||
class_name GutInputFactory
|
||||
## Static class full of helper methods to make InputEvent instances.
|
||||
##
|
||||
## This thing makes InputEvents. Enjoy.
|
||||
|
||||
|
|
@ -25,8 +26,8 @@ static func _to_scancode(which):
|
|||
return key_code
|
||||
|
||||
|
||||
## Creates a new button with the properties given
|
||||
static func new_mouse_button_event(position, global_position, pressed, button_index):
|
||||
## Creates a new button with the given propoerties.
|
||||
static func new_mouse_button_event(position, global_position, pressed, button_index) -> InputEventMouseButton:
|
||||
var event = InputEventMouseButton.new()
|
||||
event.position = position
|
||||
if(global_position != null):
|
||||
|
|
@ -37,28 +38,32 @@ static func new_mouse_button_event(position, global_position, pressed, button_in
|
|||
return event
|
||||
|
||||
|
||||
static func key_up(which):
|
||||
## Returns an [InputEventKey] event with [code]pressed = false[/code]. [param which] can be a character or a [code]KEY_*[/code] constant.
|
||||
static func key_up(which) -> InputEventKey:
|
||||
var event = InputEventKey.new()
|
||||
event.keycode = _to_scancode(which)
|
||||
event.pressed = false
|
||||
return event
|
||||
|
||||
|
||||
static func key_down(which):
|
||||
## Returns an [InputEventKey] event with [code]pressed = true[/code]. [param which] can be a character or a [code]KEY_*[/code] constant.
|
||||
static func key_down(which) -> InputEventKey:
|
||||
var event = InputEventKey.new()
|
||||
event.keycode = _to_scancode(which)
|
||||
event.pressed = true
|
||||
return event
|
||||
|
||||
|
||||
static func action_up(which, strength=1.0):
|
||||
## Returns an "action up" [InputEventAction] instance. [param which] is the name of the action defined in the Key Map.
|
||||
static func action_up(which, strength=1.0) -> InputEventAction:
|
||||
var event = InputEventAction.new()
|
||||
event.action = which
|
||||
event.strength = strength
|
||||
return event
|
||||
|
||||
|
||||
static func action_down(which, strength=1.0):
|
||||
## Returns an "action down" [InputEventAction] instance. [param which] is the name of the action defined in the Key Map.
|
||||
static func action_down(which, strength=1.0) -> InputEventAction:
|
||||
var event = InputEventAction.new()
|
||||
event.action = which
|
||||
event.strength = strength
|
||||
|
|
@ -66,33 +71,39 @@ static func action_down(which, strength=1.0):
|
|||
return event
|
||||
|
||||
|
||||
static func mouse_left_button_down(position, global_position=null):
|
||||
## Returns a "button down" [InputEventMouseButton] for the left mouse button.
|
||||
static func mouse_left_button_down(position, global_position=null) -> InputEventMouseButton:
|
||||
var event = new_mouse_button_event(position, global_position, true, MOUSE_BUTTON_LEFT)
|
||||
return event
|
||||
|
||||
|
||||
static func mouse_left_button_up(position, global_position=null):
|
||||
## Returns a "button up" [InputEventMouseButton] for the left mouse button.
|
||||
static func mouse_left_button_up(position, global_position=null) -> InputEventMouseButton:
|
||||
var event = new_mouse_button_event(position, global_position, false, MOUSE_BUTTON_LEFT)
|
||||
return event
|
||||
|
||||
|
||||
static func mouse_double_click(position, global_position=null):
|
||||
## Returns a "double click" [InputEventMouseButton] for the left mouse button.
|
||||
static func mouse_double_click(position, global_position=null) -> InputEventMouseButton:
|
||||
var event = new_mouse_button_event(position, global_position, false, MOUSE_BUTTON_LEFT)
|
||||
event.double_click = true
|
||||
return event
|
||||
|
||||
|
||||
static func mouse_right_button_down(position, global_position=null):
|
||||
## Returns a "button down" [InputEventMouseButton] for the right mouse button.
|
||||
static func mouse_right_button_down(position, global_position=null) -> InputEventMouseButton:
|
||||
var event = new_mouse_button_event(position, global_position, true, MOUSE_BUTTON_RIGHT)
|
||||
return event
|
||||
|
||||
|
||||
static func mouse_right_button_up(position, global_position=null):
|
||||
## Returns a "button up" [InputEventMouseButton] for the right mouse button.
|
||||
static func mouse_right_button_up(position, global_position=null) -> InputEventMouseButton:
|
||||
var event = new_mouse_button_event(position, global_position, false, MOUSE_BUTTON_RIGHT)
|
||||
return event
|
||||
|
||||
|
||||
static func mouse_motion(position, global_position=null):
|
||||
## Returns a [InputEventMouseMotion] to move the mouse the specified positions.
|
||||
static func mouse_motion(position, global_position=null) -> InputEventMouseMotion:
|
||||
var event = InputEventMouseMotion.new()
|
||||
event.position = position
|
||||
if(global_position != null):
|
||||
|
|
@ -100,7 +111,9 @@ static func mouse_motion(position, global_position=null):
|
|||
return event
|
||||
|
||||
|
||||
static func mouse_relative_motion(offset, last_motion_event=null, speed=Vector2(0, 0)):
|
||||
## Returns an [InputEventMouseMotion] that moves the mouse [param offset]
|
||||
## from the last [method mouse_motion] or [method mouse_motion] call.
|
||||
static func mouse_relative_motion(offset, last_motion_event=null, speed=Vector2(0, 0)) -> InputEventMouseMotion:
|
||||
var event = null
|
||||
if(last_motion_event == null):
|
||||
event = mouse_motion(offset)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue