Skip to content

Commit ab8ea12

Browse files
committed
Clean up add to steam, make it clear when shortcut has actually been added, add back restart hint
1 parent ef667a7 commit ab8ea12

15 files changed

+200
-97
lines changed

gui/godot/scripts/Main.gd

+14-10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ var INFO_WINDOW = preload("res://scenes/info_window.tscn")
2222

2323
signal restart_steam_hint
2424

25+
func send_steam_restart_hint():
26+
print("Sending restart hint")
27+
emit_signal("restart_steam_hint")
28+
2529
func initialize_action_button(
2630
action_button: ActionButton,
2731
):
@@ -47,11 +51,15 @@ func update_action_button(
4751
display_text: String,
4852
is_available: bool,
4953
is_ongoing: bool,
54+
is_completed: bool,
5055
) -> void:
5156
action_button.set_name(identifier)
5257
action_button.set_text(display_text)
5358
action_button.set_visible(is_available)
5459

60+
if is_completed:
61+
action_button.modulate = Color.DARK_GRAY
62+
5563
# TODO: make not clickable while running
5664
if is_ongoing:
5765
if not action_button.button_known_ongoing_state:
@@ -124,13 +132,13 @@ func _input(event: InputEvent) -> void:
124132
get_tree().quit()
125133

126134
# NOTE: could focus the first element of the first subtab here if desired
127-
if event.is_action_pressed("ui_next_main_tab"):
135+
if event.is_action_pressed("ui_next_main_tab"):
128136
var did_change_tab = %MainTabs.select_next_available()
129137
if did_change_tab:
130138
%MainTabs.get_tab_bar().grab_focus()
131139
elif $UpdateButton.visible:
132140
$UpdateButton.grab_focus()
133-
141+
134142
if event.is_action_pressed("ui_prev_main_tab"):
135143
if not $UpdateButton.has_focus():
136144
%MainTabs.select_previous_available()
@@ -150,7 +158,7 @@ func _ready():
150158
dd.context_was_updated.connect(_on_context_was_updated)
151159
dd.update_action_button.connect(update_action_button.call_deferred)
152160
dd.initialize_action_button.connect(initialize_action_button.call_deferred)
153-
dd.added_to_steam.connect(func (): emit_signal("restart_steam_hint"))
161+
dd.added_to_steam.connect(send_steam_restart_hint.call_deferred)
154162

155163
var should_test = OS.get_environment("DECKTRICKS_GUI_TEST_COMMAND_ONLY")
156164
var should_exit = OS.get_environment("DECKTRICKS_GUI_EXIT_IMMEDIATELY")
@@ -162,14 +170,14 @@ func _ready():
162170

163171
%LogContainer.populate_logs()
164172
dd.populate_categories(%Categories)
165-
173+
166174
%Categories.select_next_available()
167175
%Categories.get_tab_control(1).find_child("ActionButton")
168-
176+
169177
var main_tab_bar: TabBar = %MainTabs.get_tab_bar()
170178
main_tab_bar.set_focus_neighbor(SIDE_RIGHT, $UpdateButton.get_path())
171179
$UpdateButton.set_focus_neighbor(SIDE_LEFT, main_tab_bar.get_path())
172-
$UpdateButton.set_focus_neighbor(SIDE_RIGHT, '')
180+
$UpdateButton.set_focus_neighbor(SIDE_RIGHT, '')
173181

174182
var first_button = get_tree().get_nodes_in_group("first_button").pop_front()
175183
if first_button:
@@ -184,7 +192,3 @@ func _ready():
184192

185193
if should_exit:
186194
get_tree().quit()
187-
188-
189-
190-

gui/rust/src/action_button.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use godot::prelude::*;
1515
// NOTE: This should not be initialized directly, use the factory functions below
1616
// This is only class(init) because class(no_init) breaks hot reloading right now:
1717
// https://github.com/godot-rust/gdext/issues/539
18+
//
19+
// looks like adding "reloadable = true" to the gdextension file will fix that, from ^
1820

1921
#[derive(GodotClass)]
2022
#[class(init,base=Button)]
@@ -52,11 +54,9 @@ impl IButton for ActionButton {
5254
return;
5355
}
5456

55-
// TODO: This doesn't work because of the way button text is updated from Godot, fix it:
56-
// if matches!(action, SpecificAction::AddToSteam { .. }) {
57-
// self.base_mut().call_deferred("set_text", &[Variant::from("Added to Steam...")]);
58-
// DecktricksDispatcher::emit_added_to_steam();
59-
//}
57+
if matches!(action, SpecificAction::AddToSteam { .. }) {
58+
DecktricksDispatcher::emit_added_to_steam();
59+
}
6060

6161
spawn(move || {
6262
// TODO: run DecktricksCommand instead of SpecificAction just to have access to flags?
@@ -96,17 +96,19 @@ impl ActionButton {
9696

9797
fn update_appearance(&mut self) {
9898
let info = &self.info;
99-
let display_text = info.action_id.get_display_name(info.is_ongoing);
100-
let action_id = info.action_id.to_string();
10199
let is_available = info.is_available;
102100
let is_ongoing = info.is_ongoing;
101+
let is_completed = info.is_completed;
102+
let display_text = info.action_id.get_display_name(is_ongoing, is_completed);
103+
let action_id = info.action_id.to_string();
103104

104105
DecktricksDispatcher::emit_update_action_button(
105106
self.to_gd(),
106107
action_id,
107108
display_text.into(),
108109
is_available,
109110
is_ongoing,
111+
is_completed,
110112
);
111113

112114
// let mut base = self.base_mut();

gui/rust/src/dispatcher.rs

+2
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ impl DecktricksDispatcher {
290290
display_text: String,
291291
is_available: bool,
292292
is_ongoing: bool,
293+
is_completed: bool,
293294
) {
294295
let mut singleton = Self::get_singleton();
295296
singleton.emit_signal(
@@ -300,6 +301,7 @@ impl DecktricksDispatcher {
300301
Variant::from(GString::from(display_text)),
301302
Variant::from(is_available),
302303
Variant::from(is_ongoing),
304+
Variant::from(is_completed),
303305
],
304306
);
305307
}

gui/rust/tests/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static GODOT_BINARY_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
6868
Command::new("godot")
6969
.current_dir(GODOT_BASE_DIR)
7070
.args(["--import"])
71+
.args(["--headless"])
7172
.output()
7273
.unwrap();
7374

src/actions/general.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ impl GeneralAction {
6464
runner.clone(),
6565
current_log_level,
6666
logger.clone(),
67-
// Whether or not we're currently installing doesn't matter here:
67+
// Whether or not we're currently installing or added to Steam doesn't matter here:
68+
// TODO: code smell
69+
false,
6870
false,
6971
);
7072
let provider = DynTrickProvider::new(&trick_ctx, full_ctx);
@@ -166,6 +168,7 @@ struct SpecificActionContext {
166168
trick_id: String,
167169
is_installing: bool,
168170
is_running: bool,
171+
is_added_to_steam: bool,
169172
available_actions: Vec<String>,
170173
}
171174

@@ -205,16 +208,16 @@ fn get_action_context_for_trick(
205208
runner.clone(),
206209
current_log_level,
207210
logger,
208-
full_ctx
209-
.procs_ctx
210-
.tricks_to_installing_pids
211-
.contains_key(&trick.id),
211+
full_ctx.is_installing(&trick.id),
212+
full_ctx.is_added_to_steam(&trick.id),
212213
);
213214
let provider = DynTrickProvider::new(&ctx, full_ctx);
214215

215216
// TODO: unit/integration test that this all works as expected
216217
let is_installing = provider.is_installing();
217218
let is_running = provider.is_running();
219+
let is_added_to_steam = provider.is_added_to_steam();
220+
218221
let available_actions = provider
219222
.get_available_actions()
220223
.iter()
@@ -224,6 +227,7 @@ fn get_action_context_for_trick(
224227
trick_id: trick.id.clone(),
225228
is_installing,
226229
is_running,
230+
is_added_to_steam,
227231
available_actions,
228232
}
229233
}

src/actions/specific.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ impl Default for SpecificActionID {
5050

5151
impl SpecificActionID {
5252
#[must_use]
53-
pub fn get_display_name(&self, is_ongoing: bool) -> &'static str {
53+
pub fn get_display_name(&self, is_ongoing: bool, is_completed: bool) -> &'static str {
5454
match self {
5555
Self::Run => if is_ongoing { "Running" } else { "Run" },
56-
Self::AddToSteam => "Add To Steam",
56+
Self::AddToSteam => if is_completed { "Added To Steam" } else { "Add To Steam" },
5757
Self::Install => if is_ongoing { "Installing" } else { "Install" },
5858
Self::Uninstall => if is_ongoing { "Uninstalling" } else { "Uninstall" },
5959
Self::Update => if is_ongoing { "Updating" } else { "Update" },
@@ -68,7 +68,7 @@ impl SpecificActionID {
6868
all_vars
6969
.into_iter()
7070
.map(|v| {
71-
let dname = v.get_display_name(false);
71+
let dname = v.get_display_name(false, false);
7272
(v.to_string(), dname)
7373
})
7474
.collect()
@@ -156,8 +156,10 @@ impl SpecificAction {
156156
runner.clone(),
157157
current_log_level,
158158
logger,
159-
// In the context of actually taking an action, we don't care if we're installing,
160-
// since at the moment is_installing is purely for cosmetic purposes
159+
// In the context of actually taking an action, we don't care if we're installing
160+
// or added to Steam, since at the moment these are purely for cosmetic purposes
161+
// TODO: code smell
162+
false,
161163
false,
162164
);
163165
let provider = DynTrickProvider::new(&ctx, full_ctx);

0 commit comments

Comments
 (0)