mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2025-10-30 07:01:10 +00:00
ui: add dll and preset field
This commit is contained in:
parent
8bf5eba479
commit
0003cd6eb2
8 changed files with 75 additions and 12 deletions
|
|
@ -26,8 +26,26 @@
|
||||||
<property name="margin-top">32</property>
|
<property name="margin-top">32</property>
|
||||||
<property name="margin-bottom">32</property>
|
<property name="margin-bottom">32</property>
|
||||||
<property name="spacing">32</property>
|
<property name="spacing">32</property>
|
||||||
|
<!-- General Properties -->
|
||||||
<child>
|
<child>
|
||||||
|
<object class="AdwPreferencesGroup">
|
||||||
|
<property name="title">General Properties</property>
|
||||||
|
<!--General Properties: Path to Lossless.dll -->
|
||||||
|
<child>
|
||||||
|
<object class="LSPrefEntry" id="dll">
|
||||||
|
<property name="opt-name">Path to Lossless.dll</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<!--General Properties: Preset name -->
|
||||||
|
<child>
|
||||||
|
<object class="LSPrefEntry" id="preset_name">
|
||||||
|
<property name="opt-name">Preset name</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<!-- Frame Generation -->
|
<!-- Frame Generation -->
|
||||||
|
<child>
|
||||||
<object class="AdwPreferencesGroup">
|
<object class="AdwPreferencesGroup">
|
||||||
<property name="title">Frame Generation</property>
|
<property name="title">Frame Generation</property>
|
||||||
<!-- Frame Generation: Multiplier -->
|
<!-- Frame Generation: Multiplier -->
|
||||||
|
|
@ -49,10 +67,10 @@
|
||||||
<property name="default-state">false</property>
|
<property name="default-state">false</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<!-- Misc -->
|
<!-- Misc -->
|
||||||
|
<child>
|
||||||
<object class="AdwPreferencesGroup">
|
<object class="AdwPreferencesGroup">
|
||||||
<property name="title">Misc</property>
|
<property name="title">Misc</property>
|
||||||
<!-- Misc: HDR Mode -->
|
<!-- Misc: HDR Mode -->
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,9 @@
|
||||||
bind-source="LSPrefEntry" bind-property="default-text" bind-flags="sync-create"/>
|
bind-source="LSPrefEntry" bind-property="default-text" bind-flags="sync-create"/>
|
||||||
<property name="placeholder-text"
|
<property name="placeholder-text"
|
||||||
bind-source="LSPrefEntry" bind-property="tooltip-text" bind-flags="sync-create"/>
|
bind-source="LSPrefEntry" bind-property="tooltip-text" bind-flags="sync-create"/>
|
||||||
<property name="input-purpose">number</property>
|
|
||||||
<property name="css-classes">compact</property>
|
<property name="css-classes">compact</property>
|
||||||
|
<property name="width-chars">60</property>
|
||||||
|
<property name="max-width-chars">60</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
<interface>
|
<interface>
|
||||||
<template class="LSApplicationWindow" parent="AdwApplicationWindow">
|
<template class="LSApplicationWindow" parent="AdwApplicationWindow">
|
||||||
<property name="title">lsfg-vk Configuration Window</property>
|
<property name="title">lsfg-vk Configuration Window</property>
|
||||||
<property name="default-width">800</property>
|
<property name="default-width">1000</property>
|
||||||
<property name="default-height">600</property>
|
<property name="default-height">700</property>
|
||||||
<property name="content">
|
<property name="content">
|
||||||
<!-- Split View -->
|
<!-- Split View -->
|
||||||
<object class="AdwNavigationSplitView">
|
<object class="AdwNavigationSplitView">
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ const APP_ID: &str = "gay.pancake.lsfg-vk.ConfigurationUi";
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct State {
|
struct State {
|
||||||
// ui state
|
|
||||||
selected_game: Option<usize>
|
selected_game: Option<usize>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
13
ui/src/ui.rs
13
ui/src/ui.rs
|
|
@ -1,5 +1,5 @@
|
||||||
use adw::{self, subclass::prelude::ObjectSubclassIsExt};
|
use adw::{self, subclass::prelude::ObjectSubclassIsExt};
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::{WidgetExt, EditableExt, GtkWindowExt};
|
||||||
|
|
||||||
use crate::config;
|
use crate::config;
|
||||||
use crate::wrapper;
|
use crate::wrapper;
|
||||||
|
|
@ -22,11 +22,20 @@ pub fn build(app: &adw::Application) {
|
||||||
entry_handler::add_entry(entry, imp.sidebar.imp().profiles.clone());
|
entry_handler::add_entry(entry, imp.sidebar.imp().profiles.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(dll_path) = config.global.dll {
|
||||||
|
imp.main.imp().dll.imp().entry.set_text(&dll_path);
|
||||||
|
}
|
||||||
|
|
||||||
// register handlers on sidebar pane.
|
// register handlers on sidebar pane.
|
||||||
sidebar_handler::register_signals(&imp.sidebar, imp.main.clone());
|
sidebar_handler::register_signals(&imp.sidebar, imp.main.clone());
|
||||||
|
|
||||||
// register handlers on main pane.
|
// register handlers on main pane.
|
||||||
main_handler::register_signals(&imp.main);
|
main_handler::register_signals(imp.sidebar.clone(), &imp.main);
|
||||||
|
|
||||||
|
// activate the first profile if available
|
||||||
|
if let Some(entry) = imp.sidebar.imp().profiles.row_at_index(0) {
|
||||||
|
entry.activate();
|
||||||
|
}
|
||||||
|
|
||||||
// present the window
|
// present the window
|
||||||
window.present();
|
window.present();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||||
use gtk::prelude::RangeExt;
|
use gtk::{glib::object::CastNone, prelude::{EditableExt, RangeExt}};
|
||||||
|
|
||||||
use crate::{config, wrapper::pane, STATE};
|
use crate::{config, wrapper::{pane, entry}, STATE};
|
||||||
|
|
||||||
// update the currently selected game configuration
|
// update the currently selected game configuration
|
||||||
fn update_game<F: FnOnce(&mut config::TomlGame)>(update: F) {
|
fn update_game<F: FnOnce(&mut config::TomlGame)>(update: F) {
|
||||||
|
|
@ -17,14 +17,32 @@ fn update_game<F: FnOnce(&mut config::TomlGame)>(update: F) {
|
||||||
///
|
///
|
||||||
/// Register signals for preset preferences.
|
/// Register signals for preset preferences.
|
||||||
///
|
///
|
||||||
pub fn register_signals(main: &pane::PaneMain) {
|
pub fn register_signals(sidebar_: pane::PaneSidebar, main: &pane::PaneMain) {
|
||||||
let main = main.imp();
|
let main = main.imp();
|
||||||
|
let exe = main.preset_name.imp();
|
||||||
let multiplier = main.multiplier.imp();
|
let multiplier = main.multiplier.imp();
|
||||||
let flow_scale = main.flow_scale.imp();
|
let flow_scale = main.flow_scale.imp();
|
||||||
let performance_mode = main.performance_mode.imp();
|
let performance_mode = main.performance_mode.imp();
|
||||||
let hdr_mode = main.hdr_mode.imp();
|
let hdr_mode = main.hdr_mode.imp();
|
||||||
let experimental_present_mode = main.experimental_present_mode.imp();
|
let experimental_present_mode = main.experimental_present_mode.imp();
|
||||||
|
|
||||||
|
let sidebar = sidebar_.clone();
|
||||||
|
exe.entry.connect_changed(move |entry| {
|
||||||
|
let mut exe = entry.text().to_string();
|
||||||
|
if exe.trim().is_empty() {
|
||||||
|
exe = "new preset".to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
// rename list entry
|
||||||
|
let row = sidebar.imp().profiles.selected_row()
|
||||||
|
.and_downcast::<entry::Entry>().unwrap();
|
||||||
|
row.set_exe(exe.clone());
|
||||||
|
|
||||||
|
// update the game configuration
|
||||||
|
update_game(|conf| {
|
||||||
|
conf.exe = exe;
|
||||||
|
});
|
||||||
|
});
|
||||||
multiplier.number.connect_value_changed(|dropdown| {
|
multiplier.number.connect_value_changed(|dropdown| {
|
||||||
update_game(|conf| {
|
update_game(|conf| {
|
||||||
conf.multiplier = (dropdown.value() as i64).into();
|
conf.multiplier = (dropdown.value() as i64).into();
|
||||||
|
|
@ -55,4 +73,16 @@ pub fn register_signals(main: &pane::PaneMain) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let dll = main.dll.imp();
|
||||||
|
dll.entry.connect_changed(|entry| {
|
||||||
|
let _ = config::edit_config(|config| {
|
||||||
|
let text = entry.text().to_string();
|
||||||
|
if text.trim().is_empty() {
|
||||||
|
config.global.dll = None;
|
||||||
|
} else {
|
||||||
|
config.global.dll = Some(text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||||
use gtk::prelude::{ButtonExt, ListBoxRowExt, RangeExt, WidgetExt};
|
use gtk::prelude::{ButtonExt, EditableExt, ListBoxRowExt, RangeExt, WidgetExt};
|
||||||
|
|
||||||
use crate::{config, ui::entry_handler, wrapper::{pane, entry}, STATE};
|
use crate::{config, ui::entry_handler, wrapper::{pane, entry}, STATE};
|
||||||
|
|
||||||
|
|
@ -21,6 +21,7 @@ pub fn register_signals(sidebar_: &pane::PaneSidebar, main: pane::PaneMain) {
|
||||||
|
|
||||||
// update main pane
|
// update main pane
|
||||||
let main = main.imp();
|
let main = main.imp();
|
||||||
|
let exe = main.preset_name.imp();
|
||||||
let multiplier = main.multiplier.imp();
|
let multiplier = main.multiplier.imp();
|
||||||
let flow_scale = main.flow_scale.imp();
|
let flow_scale = main.flow_scale.imp();
|
||||||
let performance_mode = main.performance_mode.imp();
|
let performance_mode = main.performance_mode.imp();
|
||||||
|
|
@ -29,6 +30,7 @@ pub fn register_signals(sidebar_: &pane::PaneSidebar, main: pane::PaneMain) {
|
||||||
|
|
||||||
// (lock state early, so the ui update doesn't override the config)
|
// (lock state early, so the ui update doesn't override the config)
|
||||||
if let Ok(mut state) = state.write() {
|
if let Ok(mut state) = state.write() {
|
||||||
|
exe.entry.set_text(&conf.exe);
|
||||||
multiplier.number.set_value(conf.multiplier.into());
|
multiplier.number.set_value(conf.multiplier.into());
|
||||||
flow_scale.slider.set_value(Into::<f64>::into(conf.flow_scale) * 100.0);
|
flow_scale.slider.set_value(Into::<f64>::into(conf.flow_scale) * 100.0);
|
||||||
performance_mode.switch.set_active(conf.performance_mode);
|
performance_mode.switch.set_active(conf.performance_mode);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@ use crate::wrapper::pref::*;
|
||||||
#[derive(gtk::CompositeTemplate, Default)]
|
#[derive(gtk::CompositeTemplate, Default)]
|
||||||
#[template(resource = "/gay/pancake/lsfg-vk/pane/main.ui")]
|
#[template(resource = "/gay/pancake/lsfg-vk/pane/main.ui")]
|
||||||
pub struct PaneMain {
|
pub struct PaneMain {
|
||||||
|
#[template_child]
|
||||||
|
pub dll: TemplateChild<PrefEntry>,
|
||||||
|
#[template_child]
|
||||||
|
pub preset_name: TemplateChild<PrefEntry>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub multiplier: TemplateChild<PrefNumber>,
|
pub multiplier: TemplateChild<PrefNumber>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue