Skip to content

Commit 8535bb7

Browse files
committed
desktop: Add custom player version to UI
1 parent 9244d8f commit 8535bb7

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

desktop/assets/texts/en-US/settings.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ scale-mode-force-tooltip =
8484
8585
player-version = Player Version
8686
87+
custom-player-version-string = Custom Player Version
88+
8789
player-runtime = Player Runtime
8890
player-runtime-flash = Flash Player
8991
player-runtime-air = Adobe AIR

desktop/src/gui/dialogs/open_dialog.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub struct OpenDialog {
4343
load_behavior: OptionalField<EnumDropdownField<LoadBehavior>>,
4444
letterbox: OptionalField<EnumDropdownField<Letterbox>>,
4545
player_version: OptionalField<NumberField<u8>>,
46+
custom_player_version_string: OptionalField<SingleLineTextField>,
4647
player_runtime: OptionalField<EnumDropdownField<PlayerRuntime>>,
4748
dummy_external_interface: OptionalField<BooleanDropdownField>,
4849
upgrade_to_https: OptionalField<BooleanDropdownField>,
@@ -229,6 +230,10 @@ impl OpenDialog {
229230
defaults.player.player_version,
230231
NumberField::new(1..=NEWEST_PLAYER_VERSION, DEFAULT_PLAYER_VERSION),
231232
);
233+
let custom_player_version_string = OptionalField::new(
234+
defaults.player.custom_player_version_string.clone(),
235+
SingleLineTextField::new("32,0,0,0"),
236+
);
232237
let player_runtime = OptionalField::new(
233238
defaults.player.player_runtime,
234239
EnumDropdownField::new(
@@ -280,6 +285,7 @@ impl OpenDialog {
280285
load_behavior,
281286
letterbox,
282287
player_version,
288+
custom_player_version_string,
283289
player_runtime,
284290
dummy_external_interface,
285291
upgrade_to_https,
@@ -499,6 +505,14 @@ impl OpenDialog {
499505
.ui(ui, &mut self.options.player.player_version, locale);
500506
ui.end_row();
501507

508+
ui.label(text(locale, "custom-player-version-string"));
509+
self.custom_player_version_string.ui(
510+
ui,
511+
&mut self.options.player.custom_player_version_string,
512+
locale,
513+
);
514+
ui.end_row();
515+
502516
ui.label(text(locale, "player-runtime"));
503517
self.player_runtime
504518
.ui(ui, &mut self.options.player.player_runtime, locale);
@@ -614,6 +628,40 @@ impl InnerField for UrlField {
614628
}
615629
}
616630

631+
struct SingleLineTextField {
632+
hint: &'static str,
633+
}
634+
635+
impl SingleLineTextField {
636+
pub fn new(hint: &'static str) -> Self {
637+
Self { hint }
638+
}
639+
}
640+
641+
impl InnerField for SingleLineTextField {
642+
type Value = String;
643+
type Result = String;
644+
645+
fn value_if_missing(&self) -> Self::Value {
646+
String::new()
647+
}
648+
649+
fn ui(&self, ui: &mut Ui, value: &mut Self::Value, error: bool, _locale: &LanguageIdentifier) {
650+
TextEdit::singleline(value)
651+
.hint_text(self.hint)
652+
.text_color_opt(if error {
653+
Some(ui.style().visuals.error_fg_color)
654+
} else {
655+
None
656+
})
657+
.ui(ui);
658+
}
659+
660+
fn value_to_result(&self, value: &Self::Value) -> Result<Self::Result, ()> {
661+
Ok(value.to_string())
662+
}
663+
}
664+
617665
struct CookieField {
618666
hint: &'static str,
619667
}

0 commit comments

Comments
 (0)