From 0919e49f351b3965f57f2c31c5c6f445d3295241 Mon Sep 17 00:00:00 2001 From: asheraryam Date: Fri, 3 Sep 2021 18:52:23 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20controls=20for=20zooming=20on?= =?UTF-8?q?=20text=20size=20with=20ctrl=20+/-?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Main.tscn | 4 +++- TextEdit.gd | 17 +++++++++++++++++ project.godot | 13 +++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 TextEdit.gd diff --git a/Main.tscn b/Main.tscn index 14a4c07..246ea44 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://BookOfShaders.gd" type="Script" id=1] [ext_resource path="res://DarkTheme.tres" type="Theme" id=2] [ext_resource path="res://shaders/chapter_12/2d-voronoise.shader" type="Shader" id=3] [ext_resource path="res://Inconsolata.otf" type="DynamicFontData" id=4] +[ext_resource path="res://TextEdit.gd" type="Script" id=5] [sub_resource type="ShaderMaterial" id=1] shader = ExtResource( 3 ) @@ -109,6 +110,7 @@ smooth_scrolling = true minimap_draw = true caret_block_mode = true caret_blink = true +script = ExtResource( 5 ) __meta__ = { "_edit_use_anchors_": false } diff --git a/TextEdit.gd b/TextEdit.gd new file mode 100644 index 0000000..e792616 --- /dev/null +++ b/TextEdit.gd @@ -0,0 +1,17 @@ +extends TextEdit + + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + if Input.is_action_just_pressed("zoom_in"): + var font_resource = get("custom_fonts/font") + font_resource.set_size(font_resource.get_size() + 1) + if Input.is_action_just_pressed("zoom_out"): + var font_resource = get("custom_fonts/font") + font_resource.set_size(font_resource.get_size() - 1) diff --git a/project.godot b/project.godot index 8323658..a78f0d9 100644 --- a/project.godot +++ b/project.godot @@ -27,3 +27,16 @@ run/main_scene="res://Main.tscn" window/size/width=1280 window/size/height=720 + +[input] + +zoom_in={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":61,"unicode":0,"echo":false,"script":null) + ] +} +zoom_out={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":45,"unicode":0,"echo":false,"script":null) + ] +}