adding screenshot and update for feature #1 & #5

This commit is contained in:
AleaJactaEst 2022-03-07 22:58:16 +01:00
parent d26ec0da5c
commit a1940e3d45
6 changed files with 63 additions and 34 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -365,19 +365,8 @@ func _input_player(event):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
# if Input.is_action_just_pressed ( "ui_strafe" ):
# reconciliate_rotate_camera_player = false
# Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
# elif Input.is_action_just_released ( "ui_strafe" ):
# reconciliate_rotate_camera_player = true
# Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
# if Input.is_action_just_pressed( "move_run" ):
# is_run = true
# elif Input.is_action_just_released( "move_run" ):
# is_run = false
if Input.is_action_just_released("INPUT_ACTION_RUN", true):
is_run = !is_run
if tps:
var camx = (Input.get_action_strength("INPUT_VIEW_CAMERA_UP", true) - Input.get_action_strength("INPUT_VIEW_CAMERA_DOWN", true)) * CAMERA_ROTATE_STEP_X
var new_camera_rotate_x = camera_rotate_x + camx
@ -393,7 +382,6 @@ func _input_player(event):
$camera_root/horizontal_root.rotate_y( -camy )
if Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW") or Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY"):
# if Input.is_mouse_button_pressed( 2 ):
if event is InputEventMouseMotion:
if tps:
camera_rotate_y -= event.relative.x *0.01
@ -525,7 +513,7 @@ func _physics_process_walk(delta):
player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt )
if Input.is_action_pressed("INPUT_ACTION_UP"):
if Input.is_action_pressed("INPUT_ACTION_UP") or (Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW") and Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY")):
input_y = 1.0
move_up = true
player_automove = false
@ -686,7 +674,7 @@ func _physics_process_walk_water(delta):
player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt )
if Input.is_action_pressed("INPUT_ACTION_UP"):
if Input.is_action_pressed("INPUT_ACTION_UP") or (Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW") and Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY")):
input_y = 1.0
move_up = true
player_automove = false
@ -817,7 +805,7 @@ func _physics_process_fly(delta):
player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt )
if Input.is_action_pressed("INPUT_ACTION_UP"):
if Input.is_action_pressed("INPUT_ACTION_UP") or (Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW") and Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY")):
input_y = 1.0
input_z = 1.0
move_up = true
@ -957,7 +945,7 @@ func _physics_process_swim(delta):
player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt )
if Input.is_action_pressed("INPUT_ACTION_UP"):
if Input.is_action_pressed("INPUT_ACTION_UP") or (Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW") and Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY")):
input_y = 1.0
input_z = 1.0
move_up = true

View file

@ -19,6 +19,7 @@ config/features=PackedStringArray("4.0", "Vulkan Clustered")
Themes="*res://scripts/themes.gd"
Common="*res://scripts/common.gd"
Screenshot="*res://scripts/screenshot.gd"
[input]
@ -211,6 +212,7 @@ INPUT_VIEW_CAMERA_FPS_TPS={
INPUT_VIEW_SCREENSHOT={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777226,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":16777243,"unicode":0,"echo":false,"script":null)
]
}
INPUT_VIEW_ZOOM_IN={

39
scripts/screenshot.gd Normal file
View file

@ -0,0 +1,39 @@
extends Node
# Ref : https://github.com/Maujoe/godot-simlpe-screenshot-script/blob/master/scripts/screenshot.gd
var file_prefix = "khanat"
var output_path:String = "user://screenshot"
var index = 0
func _ready():
check_path(output_path)
if not output_path[-1] == "/":
output_path += "/"
set_process_input(true)
func _input(event):
if event.is_action_pressed("INPUT_VIEW_SCREENSHOT", true):
make_screenshot()
func make_screenshot():
var filename: String
var img = get_viewport().get_texture().get_image()
var time = Time.get_datetime_dict_from_system()
filename = "%s%s_%s_%02d_%02d_%02d_%02d_%02d_%s_%s.png" % [
output_path, file_prefix, time['year'], time['month'], time['day'],
time['hour'], time['minute'], time['second'],
str(OS.get_process_id()), str(index)]
Common.msg_debug("Create screenshot: " + filename)
index += 1
img.save_png(filename)
func check_path(path):
var dir = Directory.new()
dir.open(path)
if not dir.dir_exists(path):
Common.msg_info("Create direcotory %s" % path)
dir.make_dir(path)