feat(dtmm): Add Nexus API key setting
This commit is contained in:
parent
e51ac19a26
commit
13d36c4947
6 changed files with 27 additions and 3 deletions
|
@ -91,6 +91,7 @@ fn main() -> Result<()> {
|
|||
config.path,
|
||||
game_dir.unwrap_or_default(),
|
||||
config.data_dir.unwrap_or_default(),
|
||||
config.nexus_api_key.unwrap_or_default(),
|
||||
);
|
||||
state.mods = load_mods(state.get_mod_dir(), config.mod_order.iter())
|
||||
.wrap_err("Failed to load mods")?;
|
||||
|
|
|
@ -128,6 +128,7 @@ pub(crate) struct State {
|
|||
pub is_next_save_pending: bool,
|
||||
pub game_dir: Arc<PathBuf>,
|
||||
pub data_dir: Arc<PathBuf>,
|
||||
pub nexus_api_key: Arc<String>,
|
||||
pub log: Arc<String>,
|
||||
|
||||
#[lens(ignore)]
|
||||
|
@ -145,7 +146,12 @@ impl State {
|
|||
#[allow(non_upper_case_globals)]
|
||||
pub const selected_mod: SelectedModLens = SelectedModLens;
|
||||
|
||||
pub fn new(config_path: PathBuf, game_dir: PathBuf, data_dir: PathBuf) -> Self {
|
||||
pub fn new(
|
||||
config_path: PathBuf,
|
||||
game_dir: PathBuf,
|
||||
data_dir: PathBuf,
|
||||
nexus_api_key: String,
|
||||
) -> Self {
|
||||
let ctx = sdk::Context::new();
|
||||
|
||||
Self {
|
||||
|
@ -161,6 +167,7 @@ impl State {
|
|||
config_path: Arc::new(config_path),
|
||||
game_dir: Arc::new(game_dir),
|
||||
data_dir: Arc::new(data_dir),
|
||||
nexus_api_key: Arc::new(nexus_api_key),
|
||||
log: Arc::new(String::new()),
|
||||
windows: HashMap::new(),
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ pub(crate) struct ActionState {
|
|||
pub mod_dir: Arc<PathBuf>,
|
||||
pub config_path: Arc<PathBuf>,
|
||||
pub ctx: Arc<sdk::Context>,
|
||||
pub nexus_api_key: Arc<String>,
|
||||
}
|
||||
|
||||
impl From<State> for ActionState {
|
||||
|
@ -67,6 +68,7 @@ impl From<State> for ActionState {
|
|||
data_dir: state.data_dir,
|
||||
config_path: state.config_path,
|
||||
ctx: state.ctx,
|
||||
nexus_api_key: state.nexus_api_key,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ impl<W: Widget<State>> Controller<State, W> for DirtyStateController {
|
|||
data: &State,
|
||||
env: &Env,
|
||||
) {
|
||||
if compare_state_fields!(old_data, data, mods, game_dir, data_dir) {
|
||||
if compare_state_fields!(old_data, data, mods, game_dir, data_dir, nexus_api_key) {
|
||||
ctx.submit_command(ACTION_START_SAVE_SETTINGS);
|
||||
}
|
||||
|
||||
|
|
|
@ -359,12 +359,22 @@ fn build_view_settings() -> impl Widget<State> {
|
|||
)
|
||||
.expand_width();
|
||||
|
||||
let nexus_apy_key_setting = Flex::row()
|
||||
.must_fill_main_axis(true)
|
||||
.main_axis_alignment(MainAxisAlignment::Start)
|
||||
.with_child(Label::new("Nexus API Key:"))
|
||||
.with_default_spacer()
|
||||
.with_flex_child(TextBox::new().expand_width().lens(State::nexus_api_key), 1.)
|
||||
.expand_width();
|
||||
|
||||
let content = Flex::column()
|
||||
.must_fill_main_axis(true)
|
||||
.cross_axis_alignment(CrossAxisAlignment::Start)
|
||||
.with_child(data_dir_setting)
|
||||
.with_default_spacer()
|
||||
.with_child(game_dir_setting);
|
||||
.with_child(game_dir_setting)
|
||||
.with_default_spacer()
|
||||
.with_child(nexus_apy_key_setting);
|
||||
|
||||
SizedBox::new(content)
|
||||
.width(800.)
|
||||
|
|
|
@ -28,6 +28,7 @@ impl<'a> From<&'a ModInfo> for LoadOrderEntrySerialize<'a> {
|
|||
pub(crate) struct ConfigSerialize<'a> {
|
||||
game_dir: &'a Path,
|
||||
data_dir: &'a Path,
|
||||
nexus_api_key: &'a String,
|
||||
mod_order: Vec<LoadOrderEntrySerialize<'a>>,
|
||||
}
|
||||
|
||||
|
@ -36,6 +37,7 @@ impl<'a> From<&'a ActionState> for ConfigSerialize<'a> {
|
|||
Self {
|
||||
game_dir: &state.game_dir,
|
||||
data_dir: &state.data_dir,
|
||||
nexus_api_key: &state.nexus_api_key,
|
||||
mod_order: state
|
||||
.mods
|
||||
.iter()
|
||||
|
@ -58,6 +60,7 @@ pub(crate) struct Config {
|
|||
pub path: PathBuf,
|
||||
pub data_dir: Option<PathBuf>,
|
||||
pub game_dir: Option<PathBuf>,
|
||||
pub nexus_api_key: Option<String>,
|
||||
#[serde(default)]
|
||||
pub mod_order: Vec<LoadOrderEntry>,
|
||||
}
|
||||
|
@ -140,6 +143,7 @@ where
|
|||
path: default_path,
|
||||
data_dir: Some(get_default_data_dir()),
|
||||
game_dir: None,
|
||||
nexus_api_key: None,
|
||||
mod_order: Vec::new(),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue