Skip to content

Commit c42e5ab

Browse files
committed
SnippetWindow: Hooked up Debugger calls/events.
The Debugger interface is now how the application interacts with the debug session. A 'Resume' button has been introduced. This replaces the 'RunUT' button during an active debug session. 'RunUT' button is now a 'Step' debugger command during a debug session.
1 parent c8080d9 commit c42e5ab

File tree

5 files changed

+104
-17
lines changed

5 files changed

+104
-17
lines changed

Assets/Scenes/UI/Snippet/SnippetToolbar.tscn

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
[gd_scene load_steps=14 format=2]
1+
[gd_scene load_steps=18 format=2]
22

33
[ext_resource path="res://Assets/Scripts/UI/Snippet/SnippetToolbar.gd" type="Script" id=1]
44
[ext_resource path="res://Assets/Textures/Play.png" type="Texture" id=2]
55
[ext_resource path="res://Assets/Textures/PlayUT.png" type="Texture" id=3]
66
[ext_resource path="res://Assets/Textures/Stop.png" type="Texture" id=4]
7+
[ext_resource path="res://Assets/Textures/Resume.png" type="Texture" id=5]
78

89
[sub_resource type="AtlasTexture" id=1]
910
flags = 4
@@ -37,22 +38,37 @@ region = Rect2( 0, 0, 28, 32 )
3738

3839
[sub_resource type="AtlasTexture" id=7]
3940
flags = 4
41+
atlas = ExtResource( 5 )
42+
region = Rect2( 38, 0, 38, 32 )
43+
44+
[sub_resource type="AtlasTexture" id=8]
45+
flags = 4
46+
atlas = ExtResource( 5 )
47+
region = Rect2( 76, 0, 38, 32 )
48+
49+
[sub_resource type="AtlasTexture" id=9]
50+
flags = 4
51+
atlas = ExtResource( 5 )
52+
region = Rect2( 0, 0, 38, 32 )
53+
54+
[sub_resource type="AtlasTexture" id=10]
55+
flags = 4
4056
atlas = ExtResource( 4 )
4157
region = Rect2( 30, 0, 30, 30 )
4258

43-
[sub_resource type="AtlasTexture" id=8]
59+
[sub_resource type="AtlasTexture" id=11]
4460
flags = 4
4561
atlas = ExtResource( 4 )
4662
region = Rect2( 60, 0, 30, 30 )
4763

48-
[sub_resource type="AtlasTexture" id=9]
64+
[sub_resource type="AtlasTexture" id=12]
4965
flags = 4
5066
atlas = ExtResource( 4 )
5167
region = Rect2( 0, 0, 30, 30 )
5268

5369
[node name="SnippetToolbar" type="HBoxContainer"]
5470
anchor_right = 1.0
55-
margin_right = -958.0
71+
margin_right = -906.0
5672
margin_bottom = 24.0
5773
script = ExtResource( 1 )
5874
__meta__ = {
@@ -83,14 +99,27 @@ texture_disabled = SubResource( 6 )
8399
expand = true
84100
stretch_mode = 5
85101

86-
[node name="Stop" type="TextureButton" parent="."]
102+
[node name="Resume" type="TextureButton" parent="."]
87103
margin_left = 44.0
88-
margin_right = 66.5
104+
margin_right = 71.75
89105
margin_bottom = 24.0
90-
rect_min_size = Vector2( 22.5, 22.5 )
106+
rect_min_size = Vector2( 27.75, 24 )
107+
hint_tooltip = "Resume a paused debug session."
91108
disabled = true
92109
texture_normal = SubResource( 7 )
93110
texture_hover = SubResource( 8 )
94111
texture_disabled = SubResource( 9 )
95112
expand = true
96113
stretch_mode = 5
114+
115+
[node name="Stop" type="TextureButton" parent="."]
116+
margin_left = 75.0
117+
margin_right = 97.5
118+
margin_bottom = 22.5
119+
rect_min_size = Vector2( 22.5, 22.5 )
120+
disabled = true
121+
texture_normal = SubResource( 10 )
122+
texture_hover = SubResource( 11 )
123+
texture_disabled = SubResource( 12 )
124+
expand = true
125+
stretch_mode = 5

Assets/Scripts/UI/Snippet/SnippetToolbar.gd

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ signal OnAction(Action)
3232
enum ACTION {
3333
RUN,
3434
RUNUT,
35+
RESUME,
3536
STOP
3637
}
3738

@@ -47,6 +48,9 @@ onready var Run: TextureButton = $Run
4748
# The 'Run Unit Tests' button.
4849
onready var RunUT: TextureButton = $RunUT
4950

51+
# The 'Resume' button used to continue a paused debug execution.
52+
onready var Resume: TextureButton = $Resume
53+
5054
# The 'Stop' button.
5155
onready var Stop: TextureButton = $Stop
5256

@@ -62,6 +66,7 @@ func _ready() -> void:
6266
# Begin game initialization only.
6367
_Error = Run.connect("pressed", self, "OnRun")
6468
_Error = RunUT.connect("pressed", self, "OnRunUT")
69+
_Error = Resume.connect("pressed", self, "OnResume")
6570
_Error = Stop.connect("pressed", self, "OnStop")
6671

6772
RunUTTooltip = RunUT.hint_tooltip
@@ -105,11 +110,16 @@ func OnRunUT() -> void:
105110
emit_signal("OnAction", ACTION.RUNUT)
106111

107112

113+
func OnResume() -> void:
114+
emit_signal("OnAction", ACTION.RESUME)
115+
116+
108117
func OnStop() -> void:
109118
emit_signal("OnAction", ACTION.STOP)
110119

111120

112-
func Resume(Enabled: bool) -> void:
121+
func SetResume(Enabled: bool) -> void:
113122
RunUT.disabled = not Enabled
114-
RunUT.hint_tooltip = "Resume" if Enabled else RunUTTooltip
123+
RunUT.hint_tooltip = "Step" if Enabled else RunUTTooltip
124+
Resume.disabled = not Enabled
115125

Assets/Scripts/UI/Snippet/SnippetWindow.gd

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func _ready() -> void:
8282
_Error = Runtime.connect("OnStart", self, "OnRuntimeStart")
8383
_Error = Runtime.connect("OnBreak", self, "OnRuntimeBreak")
8484
_Error = Runtime.connect("OnEnd", self, "OnRuntimeEnd")
85+
_Error = Debugger.connect("OnStateChange", self, "OnDebuggerStateChange")
8586

8687
Status.text = ""
8788
Editor.HoverWordTimer.paused = true
@@ -114,21 +115,28 @@ func Show(InSnippet: Snippet) -> void:
114115

115116

116117
func OnAction(Action: int) -> void:
118+
var Launched = false
117119
match (Action):
118120
SnippetToolbar.ACTION.RUN:
119-
Runtime.Execute()
120-
SnippetToolbar.ACTION.RUNUT:
121+
Launched = Debugger.Launch()
122+
SnippetToolbar.ACTION.RUNUT, SnippetToolbar.ACTION.RESUME:
121123
if Runtime.IsRunning():
122-
Runtime.Resume()
123-
Toolbar.Resume(false)
124+
if Action == SnippetToolbar.ACTION.RUNUT:
125+
Debugger.Step()
126+
else:
127+
Debugger.Resume()
128+
Toolbar.SetResume(false)
124129
Editor.ClearLineStates()
125130
Editor.HoverWordTimer.paused = true
126131
else:
127-
RunUnitTest()
132+
Launched = Debugger.Launch(This.Data.Name)
128133
SnippetToolbar.ACTION.STOP:
129-
Runtime.Stop()
134+
Debugger.Stop()
130135
Editor.ClearLineStates()
131136

137+
if Launched:
138+
OnRuntimeStart()
139+
132140

133141
func UpdateStatusBar(Success: bool, Error: String) -> void:
134142
Status.text = "Success" if Success else Error
@@ -318,7 +326,7 @@ func OnRuntimeStart() -> void:
318326

319327
func OnRuntimeBreak(Line: int) -> void:
320328
Toolbar.Stop.disabled = false
321-
Toolbar.Resume(true)
329+
Toolbar.SetResume(true)
322330
if Runtime.IsActiveSnippet(This.Data):
323331
Editor.SetLineState(Line + 1, BaseTextEdit.LINE_STATE.ERROR)
324332
Editor.HoverWordTimer.stop()
@@ -337,7 +345,7 @@ func OnBreakpointToggled(_Row: int) -> void:
337345

338346

339347
func OnHoverWord(Word: String) -> void:
340-
var Variables: Dictionary = Runtime.GetVariables()
348+
var Variables: Dictionary = Debugger.FrameData
341349
if not Variables.has(Word):
342350
return
343351

@@ -355,3 +363,9 @@ func OnClosePressed() -> void:
355363

356364
.OnClosePressed()
357365

366+
367+
func OnDebuggerStateChange(State: int) -> void:
368+
match (State):
369+
Debugger.STATE.FINISHED, Debugger.STATE.FAILED_TO_CONNECT:
370+
OnRuntimeEnd()
371+

Assets/Textures/Resume.png

1.14 KB
Loading

Assets/Textures/Resume.png.import

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/Resume.png-ee87bd34f381248683996ca544a353ed.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://Assets/Textures/Resume.png"
13+
dest_files=[ "res://.import/Resume.png-ee87bd34f381248683996ca544a353ed.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

0 commit comments

Comments
 (0)