Skip to content

Commit

Permalink
rename issue to requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
Sevii77 committed Nov 12, 2024
1 parent a967108 commit 0a8461a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions aetherment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ pub struct Core {

#[cfg(any(feature = "plugin", feature = "client"))]
impl Core {
pub fn new(log: fn(log::LogType, String), backend_initializers: modman::backend::BackendInitializers, issue_initializers: modman::issue::IssueInitializers, optional_initializers: modman::meta::OptionalInitializers) -> Self {
pub fn new(log: fn(log::LogType, String), backend_initializers: modman::backend::BackendInitializers, requirement_initializers: modman::requirement::RequirementInitializers, optional_initializers: modman::meta::OptionalInitializers) -> Self {
unsafe {
log::LOG = log;
// BACKEND = Some(std::sync::Mutex::new(modman::backend::new_backend(backend_initializers)));
BACKEND = Some(modman::backend::new_backend(backend_initializers));
modman::issue::initialize(issue_initializers);
modman::requirement::initialize(requirement_initializers);

if let Some(dalamud) = optional_initializers.dalamud {
modman::meta::dalamud::SETSTYLE = dalamud;
Expand Down
4 changes: 2 additions & 2 deletions aetherment/src/modman/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct Meta {

pub plugin_settings: PluginSettings,

pub issues: Vec<super::issue::Issue>,
pub requirements: Vec<super::requirement::Requirement>,
}

impl Default for Meta {
Expand All @@ -48,7 +48,7 @@ impl Default for Meta {

plugin_settings: PluginSettings::default(),

issues: Vec::new(),
requirements: Vec::new(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion aetherment/src/modman/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub mod settings;
// pub mod priority;
// pub mod enabled;
pub mod composite;
pub mod issue;
pub mod requirement;

// ----------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
#[cfg(any(feature = "plugin", feature = "client"))] use crate::render_helper::EnumTools;

#[derive(Debug, Clone, Deserialize, Serialize)]
pub enum Issue {
pub enum Requirement {
UiResolution(String),
UiTheme(String),
Collection(String),
Expand All @@ -15,12 +15,12 @@ pub enum Status {
}

#[cfg(any(feature = "plugin", feature = "client"))]
impl Issue {
impl Requirement {
pub fn get_status(&self) -> Status {
let funcs = unsafe{FUNCS.as_ref().unwrap()};

match self {
Issue::UiResolution(res) =>
Requirement::UiResolution(res) =>
if match res.to_ascii_lowercase().as_str() {
"standard" => Some(0),
"high" => Some(1),
Expand All @@ -33,7 +33,7 @@ impl Issue {
and set 'UI Resolution' (2nd option) to {res}. Restart your game after."))
}

Issue::UiTheme(theme) =>
Requirement::UiTheme(theme) =>
if match theme.to_ascii_lowercase().as_str() {
"dark" => Some(0),
"light" => Some(1),
Expand All @@ -48,7 +48,7 @@ impl Issue {
and select {theme} from the dropdown. Restart your game after."))
}

Issue::Collection(collection_type_name) =>
Requirement::Collection(collection_type_name) =>
if super::backend::CollectionType::iter()
.find(|v| v.to_str().to_ascii_lowercase() == collection_type_name.to_ascii_lowercase())
.map_or(false, |v| (funcs.collection)(v).is_valid()) {
Expand All @@ -65,15 +65,15 @@ impl Issue {
// ----------

#[cfg(any(feature = "plugin", feature = "client"))]
pub struct IssueInitializers {
pub struct RequirementInitializers {
pub ui_resolution: Box<dyn Fn() -> u8>,
pub ui_theme: Box<dyn Fn() -> u8>,
pub collection: Box<dyn Fn(super::backend::CollectionType) -> super::backend::Collection>,
}

#[cfg(any(feature = "plugin", feature = "client"))]
static mut FUNCS: Option<IssueInitializers> = None;
static mut FUNCS: Option<RequirementInitializers> = None;
#[cfg(any(feature = "plugin", feature = "client"))]
pub(crate) fn initialize(funcs: IssueInitializers) {
pub(crate) fn initialize(funcs: RequirementInitializers) {
unsafe{FUNCS = Some(funcs)}
}
6 changes: 3 additions & 3 deletions aetherment/src/view/mods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ impl Mods {

let mut changed = false;

let warnings = meta.issues.iter().filter_map(|v| match v.get_status() {
crate::modman::issue::Status::Ok => None,
crate::modman::issue::Status::Warning(msg) => Some(msg),
let warnings = meta.requirements.iter().filter_map(|v| match v.get_status() {
crate::modman::requirement::Status::Ok => None,
crate::modman::requirement::Status::Warning(msg) => Some(msg),
}).collect::<Vec<_>>();
if warnings.len() > 0 {
for msg in warnings {
Expand Down
2 changes: 1 addition & 1 deletion client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() {
let _backend = cc.wgpu_render_state.as_ref().unwrap().adapter.get_info().backend;
Box::new(CoreWrapper(aetherment::Core::new(log,
aetherment::modman::backend::BackendInitializers::None,
aetherment::modman::issue::IssueInitializers {
aetherment::modman::requirement::RequirementInitializers {
ui_resolution: Box::new(|| 255),
ui_theme: Box::new(|| 255),
collection: Box::new(|_| aetherment::modman::backend::Collection{name: "None".to_string(), id: "00000000-0000-0000-0000-000000000000".to_string()}),
Expand Down
14 changes: 7 additions & 7 deletions plugin/plugin/Aetherment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ public class Aetherment: IDalamudPlugin {
private static string? error;
private static Dalamud.Interface.IReadOnlyTitleScreenMenuEntry? titleEntry;

private Issue issue;
private Requirement requirement;
private Penumbra penumbra;
private DalamudStyle dalamud;
private TexFinder texfinder;

[StructLayout(LayoutKind.Sequential)]
private unsafe struct Initializers {
public nint log;
public IssueFunctions issue;
public RequirementFunctions requirement;
public PenumbraFunctions penumbra;
public nint dalamud_add_style;
}

[StructLayout(LayoutKind.Sequential)]
private unsafe struct IssueFunctions {
private unsafe struct RequirementFunctions {
public nint ui_resolution;
public nint ui_theme;
}
Expand Down Expand Up @@ -74,16 +74,16 @@ public unsafe Aetherment() {
// }

log = Log;
issue = new();
requirement = new();
penumbra = new();
dalamud = new();
texfinder = new();

var init = new Initializers {
log = Marshal.GetFunctionPointerForDelegate(log),
issue = new IssueFunctions {
ui_resolution = Marshal.GetFunctionPointerForDelegate(issue.getUiResolution),
ui_theme = Marshal.GetFunctionPointerForDelegate(issue.getUiTheme),
requirement = new RequirementFunctions {
ui_resolution = Marshal.GetFunctionPointerForDelegate(requirement.getUiResolution),
ui_theme = Marshal.GetFunctionPointerForDelegate(requirement.getUiTheme),
},
penumbra = new PenumbraFunctions {
// config_dir = Interface.ConfigDirectory.Parent! + "/Penumbra/",
Expand Down
4 changes: 2 additions & 2 deletions plugin/plugin/Issue.cs → plugin/plugin/Requirement.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace Aetherment;

public class Issue {
public class Requirement {
private byte uires;
private byte theme;

public Issue() {
public Requirement() {
// we get these now since they require a restart, we dont want the live value
// might still break if aetherment is loaded after the user changed the setting
// without restarting but oh well.
Expand Down
8 changes: 4 additions & 4 deletions plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub extern fn initialize(init: Initializers) -> *mut State {
};

let funcs = init.penumbra_functions;
let issue_funcs = init.issue_functions;
let requirement_funcs = init.issue_functions;

let get_collection = Box::new(move |collection_type| {
let v = (funcs.get_collection)(collection_type as _).to_string();
Expand Down Expand Up @@ -168,9 +168,9 @@ pub extern fn initialize(init: Initializers) -> *mut State {

// default_collection: Box::new(move || (funcs.default_collection)().to_string()),
// get_collections: Box::new(move || (funcs.get_collections)().to_string_vec()),
}), aetherment::modman::issue::IssueInitializers {
ui_resolution: Box::new(issue_funcs.ui_resolution),
ui_theme: Box::new(issue_funcs.ui_theme),
}), aetherment::modman::requirement::RequirementInitializers {
ui_resolution: Box::new(requirement_funcs.ui_resolution),
ui_theme: Box::new(requirement_funcs.ui_theme),
collection: get_collection,
}, aetherment::modman::meta::OptionalInitializers {
dalamud: Some(dalamud_add_style)
Expand Down

0 comments on commit 0a8461a

Please sign in to comment.