Skip to content

Commit

Permalink
refactor: wip xmake work
Browse files Browse the repository at this point in the history
  • Loading branch information
shad0wshayd3 committed Nov 21, 2024
1 parent 34a55c5 commit 041a6d7
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 273 deletions.
12 changes: 6 additions & 6 deletions src/Hooks/Hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Hooks
public:
static bool IsExempt()
{
if (!MCM::Settings::General::bEnable)
if (!MCM::Settings::General::bEnable.GetValue())
{
return true;
}
Expand Down Expand Up @@ -121,7 +121,7 @@ class Hooks
return _SetPowerArmorMode(a_inPowerArmor);
}

if (MCM::Settings::General::bDisableColor)
if (MCM::Settings::General::bDisableColor.GetValue())
{
return;
}
Expand Down Expand Up @@ -178,12 +178,12 @@ class Hooks
return _QActorInPowerArmor(a_actor);
}

if (MCM::Settings::General::bDisableColor)
if (MCM::Settings::General::bDisableColor.GetValue())
{
return _QActorInPowerArmor(a_actor);
}

if (!MCM::Settings::General::bDisablePAColor)
if (!MCM::Settings::General::bDisablePAColor.GetValue())
{
return _QActorInPowerArmor(a_actor);
}
Expand Down Expand Up @@ -249,12 +249,12 @@ class Hooks
return _GetPowerArmorHUDColor();
}

if (MCM::Settings::General::bDisableColor)
if (MCM::Settings::General::bDisableColor.GetValue())
{
return _GetPowerArmorHUDColor();
}

if (!MCM::Settings::General::bDisablePAColor)
if (!MCM::Settings::General::bDisablePAColor.GetValue())
{
return _GetPowerArmorHUDColor();
}
Expand Down
9 changes: 3 additions & 6 deletions src/MCM/MCM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

#include "Menus/PowerArmorConditionMenu.h"

namespace MCM
namespace MCM::Settings
{
void Settings::ResetStatePost()
void Reset()
{
if (RE::PowerArmor::PlayerInPowerArmor())
{
if (General::bEnable)
if (General::bEnable.GetValue())
{
RE::SendHUDMessage::SetPowerArmorMode(false);
Menus::PowerArmorConditionMenu::ShowMenu();
Expand All @@ -19,8 +19,5 @@ namespace MCM
Menus::PowerArmorConditionMenu::HideMenu();
}
}

m_ini_base.Reset();
m_ini_user.Reset();
}
}
95 changes: 20 additions & 75 deletions src/MCM/MCM.h
Original file line number Diff line number Diff line change
@@ -1,83 +1,28 @@
#pragma once

namespace MCM
namespace MCM::Settings
{
class Settings
namespace General
{
public:
class General
{
public:
inline static bool bEnable{ true };
inline static bool bDisablePAColor{ false };
inline static bool bDisableColor{ false };
static REX::INI::Bool bEnable{ "General", "bEnable", true };
static REX::INI::Bool bDisablePAColor{ "General", "bDisablePAColor", false };
static REX::INI::Bool bDisableColor{ "General", "bDisableColor", false };

inline static double fConditionMeterX{ 136.0 };
inline static double fConditionMeterY{ 675.0 };
inline static double fConditionMeterScale{ 1.0 };
};
static REX::INI::F64 fConditionMeterX{ "General", "fConditionMeterX", 136.0 };
static REX::INI::F64 fConditionMeterY{ "General", "fConditionMeterY", 675.0 };
static REX::INI::F64 fConditionMeterScale{ "General", "fConditionMeterScale", 1.0 };
}

static void Update()
{
ResetStateInit();
static void Reset();

GetModSettingBool("General", "bEnable", General::bEnable);
GetModSettingBool("General", "bDisablePAColor", General::bDisablePAColor);
GetModSettingBool("General", "bDisableColor", General::bDisableColor);

GetModSettingDouble("General", "fConditionMeterX", General::fConditionMeterX);
GetModSettingDouble("General", "fConditionMeterY", General::fConditionMeterY);
GetModSettingDouble("General", "fConditionMeterScale", General::fConditionMeterScale);

ResetStatePost();
}

inline static bool m_FirstRun{ true };

private:
static void ResetStateInit()
{
if (m_FirstRun)
{
m_FirstRun = false;
}

m_ini_base.LoadFile("Data/MCM/Config/BakaPowerArmorHUD/settings.ini");
m_ini_user.LoadFile("Data/MCM/Settings/BakaPowerArmorHUD.ini");
}

static void ResetStatePost();

protected:
static void GetModSettingChar(const std::string& a_section, const std::string& a_setting, std::string_view& a_value)
{
auto base = m_ini_base.GetValue(a_section.c_str(), a_setting.c_str(), a_value.data());
auto user = m_ini_user.GetValue(a_section.c_str(), a_setting.c_str(), base);
a_value = user;
}

static void GetModSettingBool(const std::string& a_section, const std::string& a_setting, bool& a_value)
{
auto base = m_ini_base.GetBoolValue(a_section.c_str(), a_setting.c_str(), a_value);
auto user = m_ini_user.GetBoolValue(a_section.c_str(), a_setting.c_str(), base);
a_value = user;
}

static void GetModSettingDouble(const std::string& a_section, const std::string& a_setting, double& a_value)
{
auto base = m_ini_base.GetDoubleValue(a_section.c_str(), a_setting.c_str(), a_value);
auto user = m_ini_user.GetDoubleValue(a_section.c_str(), a_setting.c_str(), base);
a_value = user;
}

static void GetModSettingLong(const std::string& a_section, const std::string& a_setting, std::int32_t& a_value)
{
auto base = m_ini_base.GetLongValue(a_section.c_str(), a_setting.c_str(), a_value);
auto user = m_ini_user.GetLongValue(a_section.c_str(), a_setting.c_str(), base);
a_value = static_cast<std::int32_t>(user);
}

inline static CSimpleIniA m_ini_base{ true };
inline static CSimpleIniA m_ini_user{ true };
};
static void Update()
{
const auto ini = REX::INI::SettingStore::GetSingleton();
ini->Init(
"Data/MCM/Config/BakaPowerArmorHUD/settings.ini",
"Data/MCM/Settings/BakaPowerArmorHUD.ini");
ini->Load();

Reset();
}
}
8 changes: 4 additions & 4 deletions src/Menus/PowerArmorConditionMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Menus
RE::UI_MENU_FLAGS::kAllowSaving,
RE::UI_MENU_FLAGS::kDontHideCursorWhenTopmost,
RE::UI_MENU_FLAGS::kCustomRendering);
depthPriority.set(RE::UI_DEPTH_PRIORITY::kSWFLoader);
depthPriority = RE::UI_DEPTH_PRIORITY::kSWFLoader;

auto MoviePath = "Interface\\PowerArmorConditionMenu.swf"sv;
const auto ScaleformManager = RE::BSScaleformManager::GetSingleton();
Expand Down Expand Up @@ -60,9 +60,9 @@ namespace Menus
if (UI->GetMenuOpen<PowerArmorConditionMenu>())
{
SetConditionMeterVisuals(
static_cast<float>(MCM::Settings::General::fConditionMeterX),
static_cast<float>(MCM::Settings::General::fConditionMeterY),
static_cast<float>(MCM::Settings::General::fConditionMeterScale));
static_cast<float>(MCM::Settings::General::fConditionMeterX.GetValue()),
static_cast<float>(MCM::Settings::General::fConditionMeterY.GetValue()),
static_cast<float>(MCM::Settings::General::fConditionMeterScale.GetValue()));
UpdateBatteryState();
return;
}
Expand Down
37 changes: 0 additions & 37 deletions src/PCH.cpp

This file was deleted.

27 changes: 2 additions & 25 deletions src/PCH.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
#pragma once

#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#pragma once

#include "F4SE/F4SE.h"
#include "RE/Fallout.h"

#include <AutoTOML.hpp>
#include <SimpleIni.h>
#include <spdlog/sinks/basic_file_sink.h>
#include <xbyak/xbyak.h>

#define DLLEXPORT __declspec(dllexport)
#include "REX/REX/INI.h"

using namespace std::literals;

namespace logger = F4SE::log;

namespace stl
{
using namespace F4SE::stl;

void asm_replace(std::uintptr_t a_from, std::size_t a_size, std::uintptr_t a_to);
}

// clang-format off
#include "Version.h"
#include "Settings.h"
// clang-format on
2 changes: 1 addition & 1 deletion src/Scripts/Papyrus.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Papyrus
{
namespace BakaPowerArmorHUD
{
constexpr auto SCRIPT_NAME{ "BakaPowerArmorHUD"sv };
static constexpr auto SCRIPT_NAME{ "BakaPowerArmorHUD"sv };

void UpdateSettings(std::monostate)
{
Expand Down
46 changes: 0 additions & 46 deletions src/Settings.h

This file was deleted.

Loading

0 comments on commit 041a6d7

Please sign in to comment.