run menu buttons

This commit is contained in:
Matt Parker
2025-08-25 18:35:54 +10:00
parent f15cfdac86
commit 8826c31a63
5 changed files with 68 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Godot;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
@@ -8,12 +9,32 @@ public partial class RunMenuItem : HBoxContainer
public SharpIdeProjectModel Project { get; set; } = null!;
private Label _label = null!;
private Button _runButton = null!;
private Button _stopButton = null!;
public override void _Ready()
{
_label = GetNode<Label>("Label");
_label.Text = Project.Name;
_runButton = GetNode<Button>("RunButton");
_runButton.Pressed += OnRunButtonPressed;
_label.Text = Project.Name;
_stopButton = GetNode<Button>("StopButton");
_stopButton.Pressed += OnStopButtonPressed;
Project.ProjectStartedRunning += OnProjectStartedRunning;
}
private async Task OnProjectStartedRunning()
{
await this.InvokeAsync(() =>
{
_runButton.Visible = false;
_stopButton.Visible = true;
});
}
private async void OnStopButtonPressed()
{
await Singletons.RunService.CancelRunningProject(Project);
_stopButton.Visible = false;
_runButton.Visible = true;
}
private async void OnRunButtonPressed()

View File

@@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=3 uid="uid://d2ewm2lajutpv"]
[gd_scene load_steps=4 format=3 uid="uid://d2ewm2lajutpv"]
[ext_resource type="Script" uid="uid://btsnapfx0dlbb" path="res://Features/Run/RunMenuItem.cs" id="1_syj0f"]
[ext_resource type="Texture2D" uid="uid://bnprs1lvjyaji" path="res://Features/Run/Play.png" id="1_xfxpu"]
[ext_resource type="Texture2D" uid="uid://csj1r7s3u10ch" path="res://Features/Run/Stop.png" id="4_cd138"]
[node name="RunMenuItem" type="HBoxContainer"]
offset_right = 40.0
@@ -19,3 +20,8 @@ size_flags_horizontal = 3
[node name="RunButton" type="Button" parent="."]
layout_mode = 2
icon = ExtResource("1_xfxpu")
[node name="StopButton" type="Button" parent="."]
visible = false
layout_mode = 2
icon = ExtResource("4_cd138")

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 B

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://csj1r7s3u10ch"
path="res://.godot/imported/Stop.png-369cb830460ee73ee5ab96abbb3f5c92.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Features/Run/Stop.png"
dest_files=["res://.godot/imported/Stop.png-369cb830460ee73ee5ab96abbb3f5c92.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1