Skip to content

Commit

Permalink
Set Game specific path for games
Browse files Browse the repository at this point in the history
  • Loading branch information
llde committed Feb 18, 2024
1 parent 497df85 commit 02011da
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
42 changes: 36 additions & 6 deletions Configurator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ pub static mut CONFIG_TABLE : Option<Table> = None;
pub static mut SHADERS_TABLE : Option<Table> = None;
pub static mut EFFECTS_TABLE : Option<Table> = None;

#[repr(C)]
#[derive(Debug)]
pub enum Game{
Oblivion,NewVegas
}

pub static mut GAME : Option<Game> = None;

pub static mut LOGGER : Option<CFile> = None;

Expand Down Expand Up @@ -118,6 +125,11 @@ pub fn write_config_to_file<T : AsRef<Path>, C>(file : T, config : C) where C :
}
}

#[no_mangle]
pub extern "C" fn SetGame(game : Game){
unsafe { GAME.replace(game); }
}

#[no_mangle]
pub extern "C" fn getConfiguration() -> *mut Config {
unsafe{
Expand Down Expand Up @@ -199,9 +211,18 @@ pub fn load_config<'a, P : AsRef<Path>, C> (path : P) -> C where C : Deserialize

#[no_mangle]
pub extern "C" fn LoadConfiguration() -> (){
let path_main = "./Data/OBSE/Plugins/OblivionReloaded.ini";
let path_effect = "./Data/Shaders/OblivionReloaded/Effects/Effects.ini";
let path_shader = "./Data/Shaders/OblivionReloaded/Shaders/Shaders.ini";
let path_main = match unsafe { GAME.as_ref().unwrap() } {
Game::Oblivion => "./Data/OBSE/Plugins/OblivionReloaded.ini",
Game::NewVegas => "./Data/NVSE/Plugins/NewVegasReloaded.ini",
};

let base_shader = match unsafe { GAME.as_ref().unwrap() } {
Game::Oblivion => "./Data/Shaders/OblivionReloaded",
Game::NewVegas => "./Data/Shaders/NewVegasReloaded",
}.to_owned();

let path_effect = base_shader.clone() + "/Effects/Effects.ini";
let path_shader = base_shader + "/Shaders/Shaders.ini";
let config : Config = load_config(path_main);
let effects : Effects = load_config(path_effect);
let shaders : Shaders = load_config(path_shader);
Expand Down Expand Up @@ -263,9 +284,18 @@ pub extern "C" fn EditActiveSetting(mov : menu::OperationSetting, callback: unsa

#[no_mangle]
pub extern "C" fn SaveConfigurations(){
let path_main = "./Data/OBSE/Plugins/OblivionReloaded.ini";
let path_effect = "./Data/Shaders/OblivionReloaded/Effects/Effects.ini";
let path_shader = "./Data/Shaders/OblivionReloaded/Shaders/Shaders.ini";
let path_main = match unsafe { GAME.as_ref().unwrap() } {
Game::Oblivion => "./Data/OBSE/Plugins/OblivionReloaded.ini",
Game::NewVegas => "./Data/NVSE/Plugins/NewVegasReloaded.ini",
};

let base_shader = match unsafe { GAME.as_ref().unwrap() } {
Game::Oblivion => "./Data/Shaders/OblivionReloaded",
Game::NewVegas => "./Data/Shaders/NewVegasReloaded",
}.to_owned();

let path_effect = base_shader.clone() + "/Effects/Effects.ini";
let path_shader = base_shader + "/Shaders/Shaders.ini";
unsafe{
write_config_to_file(path_main, CONFIG.as_ref().unwrap());
write_config_to_file(path_shader, SHADERS.as_ref().unwrap());
Expand Down
1 change: 1 addition & 0 deletions NewVegasReloaded/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extern "C" {
if (!Interface->IsEditor) {
PluginVersion::CreateVersionString();
SettingManager::Initialize();
TheSettingManager->SetGame(ffi::Game::NewVegas);
TheSettingManager->LoadSettings();
AttachHooks();
}
Expand Down
1 change: 1 addition & 0 deletions OblivionReloaded/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern "C" {
if (!Interface->IsEditor) {
PluginVersion::CreateVersionString();
SettingManager::Initialize();
TheSettingManager->SetGame(ffi::Game::Oblivion);
TheSettingManager->LoadSettings();
AttachHooks();
}
Expand Down
4 changes: 4 additions & 0 deletions TESReloaded/Core/SettingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ void SettingManager::Initialize()
TheSettingManager = new SettingManager();
ffi::SetLogFile(Logger::LogFile);
}

void SettingManager::SetGame(ffi::Game game) {
ffi::SetGame(game);
}
2 changes: 1 addition & 1 deletion TESReloaded/Core/SettingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class SettingManager : public SettingManagerBase {
ffi::Shaders* Shaders;
void LoadSettings();
bool GetMenuShaderEnabled(const char* Name);

void SetGame(ffi::Game game);
static void Initialize();
};
7 changes: 7 additions & 0 deletions TESReloaded/Core/SettingStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ enum class Errors {
InvalidLog,
};

enum class Game {
Oblivion,
NewVegas,
};

enum class MoveCursor {
Up,
Down,
Expand Down Expand Up @@ -466,6 +471,8 @@ struct Shaders {

extern "C" {

void SetGame(Game game);

Config *getConfiguration();

Effects *getEffectsConfiguration();
Expand Down

0 comments on commit 02011da

Please sign in to comment.