mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-06-28 10:15:31 +02:00
Godot 4 automatic changes
This commit is contained in:
parent
8b5caafbc7
commit
cdbf3f2adc
75 changed files with 1034 additions and 952 deletions
|
@ -1,4 +1,4 @@
|
|||
tool
|
||||
@tool
|
||||
extends Control
|
||||
# This scene demonstrates how we can control the Terminal node directly by
|
||||
# sending and receiving strings and ANSI escape sequences to the terminal
|
||||
|
@ -38,15 +38,15 @@ var row: int
|
|||
var menu_start_row: int
|
||||
var offset: int
|
||||
|
||||
onready var tput = TPut.new($Terminal)
|
||||
@onready var tput = TPut.new($Terminal)
|
||||
|
||||
|
||||
func _ready():
|
||||
if not $Terminal.is_connected("key_pressed", self, "_on_Terminal_key_pressed"):
|
||||
if not $Terminal.is_connected("key_pressed",Callable(self,"_on_Terminal_key_pressed")):
|
||||
# warning-ignore:return_value_discarded
|
||||
$Terminal.connect("key_pressed", self, "_on_Terminal_key_pressed")
|
||||
$Terminal.connect("key_pressed",Callable(self,"_on_Terminal_key_pressed"))
|
||||
# warning-ignore:return_value_discarded
|
||||
$Terminal.connect("size_changed", self, "draw_all")
|
||||
$Terminal.connect("size_changed",Callable(self,"draw_all"))
|
||||
$Terminal.grab_focus()
|
||||
draw_all()
|
||||
|
||||
|
@ -132,12 +132,12 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
|
|||
|
||||
match item.name:
|
||||
"Asciicast":
|
||||
var scene = item.scene.instance()
|
||||
var scene = item.scene.instantiate()
|
||||
var animation_player: AnimationPlayer = scene.get_node("AnimationPlayer")
|
||||
scene.connect("key_pressed", self, "_on_Asciicast_key_pressed", [animation_player])
|
||||
scene.connect("key_pressed",Callable(self,"_on_Asciicast_key_pressed").bind(animation_player))
|
||||
add_child(scene)
|
||||
scene.grab_focus()
|
||||
yield(animation_player, "animation_finished")
|
||||
await animation_player.animation_finished
|
||||
remove_child(scene)
|
||||
$Terminal.grab_focus()
|
||||
scene.queue_free()
|
||||
|
@ -148,15 +148,15 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
|
|||
(
|
||||
"Psuedoterminal node currently"
|
||||
+ " uses pty.h but needs to use either winpty or conpty"
|
||||
+ " to work on Windows."
|
||||
+ " to work checked Windows."
|
||||
),
|
||||
"Terminal not Supported on Windows"
|
||||
"Terminal not Supported checked Windows"
|
||||
)
|
||||
var scene = item.scene.instance()
|
||||
var scene = item.scene.instantiate()
|
||||
var pty = scene if OS.has_feature("JavaScript") else scene.get_node("PTY")
|
||||
add_child(scene)
|
||||
scene.grab_focus()
|
||||
yield(pty, "exited")
|
||||
await pty.exited
|
||||
$Terminal.grab_focus()
|
||||
scene.queue_free()
|
||||
"Exit":
|
||||
|
|
|
@ -20,14 +20,14 @@ shader_type canvas_item;
|
|||
// - If you are using this shader as an overlay, and want the shader to affect the nodes below in the Scene hierarchy,
|
||||
// set 'overlay' to true (checked in the inspector).
|
||||
// On Mac there is potentially a bug causing this to not work properly. If that is the case and you want to use the shader as an overlay
|
||||
// change all \"overlay ? SCREEN_TEXTURE : TEXTURE\" to only \"SCREEN_TEXTURE\" on lines 129-140, and \"vec2 uv = overlay ? warp(SCREEN_UV) : warp(UV);\"
|
||||
// to \"vec2 uv = warp(SCREEN_UV);\" on line 98.
|
||||
// change all \"overlay ? SCREEN_TEXTURE : TEXTURE\" to only \"SCREEN_TEXTURE\" checked lines 129-140, and \"vec2 uv = overlay ? warp(SCREEN_UV) : warp(UV);\"
|
||||
// to \"vec2 uv = warp(SCREEN_UV);\" checked line 98.
|
||||
uniform bool overlay = false;
|
||||
|
||||
uniform float scanlines_opacity : hint_range(0.0, 1.0) = 0.4;
|
||||
uniform float scanlines_width : hint_range(0.0, 0.5) = 0.25;
|
||||
uniform float grille_opacity : hint_range(0.0, 1.0) = 0.3;
|
||||
uniform vec2 resolution = vec2(640.0, 480.0); // Set the number of rows and columns the texture will be divided in. Scanlines and grille will make a square based on these values
|
||||
uniform vec2 resolution = vec2(640.0, 480.0); // Set the number of rows and columns the texture will be divided in. Scanlines and grille will make a square based checked these values
|
||||
|
||||
uniform bool pixelate = true; // Fill each square (\"pixel\") with a sampled color, creating a pixel look and a more accurate representation of how a CRT monitor would work.
|
||||
|
||||
|
@ -42,7 +42,7 @@ uniform float noise_speed = 5.0; // There is a movement in the noise pattern tha
|
|||
|
||||
uniform float static_noise_intensity : hint_range(0.0, 1.0) = 0.06;
|
||||
|
||||
uniform float aberration : hint_range(-1.0, 1.0) = 0.03; // Chromatic aberration, a distortion on each color channel.
|
||||
uniform float aberration : hint_range(-1.0, 1.0) = 0.03; // Chromatic aberration, a distortion checked each color channel.
|
||||
uniform float brightness = 1.4; // When adding scanline gaps and grille the image can get very dark. Brightness tries to compensate for that.
|
||||
uniform bool discolor = true; // Add a discolor effect simulating a VHS
|
||||
|
||||
|
@ -107,7 +107,7 @@ void fragment()
|
|||
float time = roll ? TIME : 0.0;
|
||||
|
||||
|
||||
// Pixelate the texture based on the given resolution.
|
||||
// Pixelate the texture based checked the given resolution.
|
||||
if (pixelate)
|
||||
{
|
||||
text_uv = ceil(uv * resolution) / resolution;
|
||||
|
@ -174,7 +174,7 @@ void fragment()
|
|||
text.g = clamp(g * brightness, 0.0, 1.0);
|
||||
text.b = clamp(b * brightness, 0.0, 1.0);
|
||||
|
||||
// Scanlines are the horizontal lines that make up the image on a CRT monitor.
|
||||
// Scanlines are the horizontal lines that make up the image checked a CRT monitor.
|
||||
// Here we are actual setting the black gap between each line, which I guess is not the right definition of the word, but you get the idea
|
||||
float scanlines = 0.5;
|
||||
if (scanlines_opacity > 0.0)
|
||||
|
@ -190,13 +190,13 @@ void fragment()
|
|||
// Generate a noise pattern that is very stretched horizontally, and animate it with noise_speed
|
||||
float noise = smoothstep(0.4, 0.5, noise(uv * vec2(2.0, 200.0) + vec2(10.0, (TIME * (noise_speed))) ) );
|
||||
|
||||
// We use roll_line (set above) to define how big the noise should be vertically (multiplying cuts off all black parts).
|
||||
// We use roll_line (set above) to define how big the noise should be vertically (multiplying cuts unchecked all black parts).
|
||||
// We also add in some basic noise with random() to break up the noise pattern above. The noise is sized according to
|
||||
// the resolution value set in the inspector. If you don't like this look you can
|
||||
// change \"ceil(uv * resolution) / resolution\" to only \"uv\" to make it less pixelated. Or multiply resolution with som value
|
||||
// greater than 1.0 to make them smaller.
|
||||
roll_line *= noise * scanlines * clamp(random((ceil(uv * resolution) / resolution) + vec2(TIME * 0.8, 0.0)).x + 0.8, 0.0, 1.0);
|
||||
// Add it to the texture based on noise_opacity
|
||||
// Add it to the texture based checked noise_opacity
|
||||
text.rgb = clamp(mix(text.rgb, text.rgb + roll_line, noise_opacity), vec3(0.0), vec3(1.0));
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ void fragment()
|
|||
// Also apply the vignette
|
||||
text.rgb *= border(uv);
|
||||
text.rgb *= vignette(uv);
|
||||
// Hides the black border and make that area transparent. Good if you want to add the the texture on top an image of a TV or monitor.
|
||||
// Hides the black border and make that area transparent. Good if you want to add the the texture checked top an image of a TV or monitor.
|
||||
if (clip_warp)
|
||||
{
|
||||
text.a = border(uv);
|
||||
|
@ -283,8 +283,8 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="Menu" parent="." instance=ExtResource( 1 )]
|
||||
margin_left = 30.0
|
||||
margin_top = 30.0
|
||||
offset_left = 30.0
|
||||
offset_top = 30.0
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
extends "res://addons/godot_xterm/terminal.gd"
|
||||
|
||||
export(String) var exec_path := "bash"
|
||||
export(String) var socat_path := "socat" # E.g. /usr/bin/socat
|
||||
export(int) var port := 2023
|
||||
export(bool) var verbose := false
|
||||
@export var exec_path: String := "bash"
|
||||
@export var socat_path: String := "socat" # E.g. /usr/bin/socat
|
||||
@export var port: int := 2023
|
||||
@export var verbose: bool := false
|
||||
|
||||
var _timeout = 30
|
||||
var _pid: int
|
||||
|
@ -31,7 +31,7 @@ func _process(delta):
|
|||
|
||||
StreamPeerTCP.STATUS_CONNECTED:
|
||||
var avail = _stream.get_available_bytes()
|
||||
var data = PoolByteArray()
|
||||
var data = PackedByteArray()
|
||||
for i in range(avail):
|
||||
data.append(_stream.get_u8())
|
||||
call_deferred("write", data)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
extends "res://addons/godot_xterm/terminal.gd"
|
||||
|
||||
onready var pty = $PTY
|
||||
@onready var pty = $PTY
|
||||
|
||||
|
||||
func _ready():
|
||||
|
|
|
@ -7,8 +7,8 @@ signal exited(status)
|
|||
var line := ""
|
||||
var _tput
|
||||
|
||||
onready var terminal = $Terminal
|
||||
onready var _has_js: bool = OS.has_feature("JavaScript")
|
||||
@onready var terminal = $Terminal
|
||||
@onready var _has_js: bool = OS.has_feature("JavaScript")
|
||||
|
||||
|
||||
func prompt(prompt: String):
|
||||
|
@ -42,7 +42,7 @@ func _on_Terminal_key_pressed(_data, event: InputEventKey):
|
|||
if not event:
|
||||
return
|
||||
|
||||
# For some reason, data String is malformed on HTML5, so only use event.unicode.
|
||||
# For some reason, data String is malformed checked HTML5, so only use event.unicode.
|
||||
var data = char(event.unicode)
|
||||
|
||||
match event.scancode:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue