Skip to content

Commit

Permalink
Fix mingw build, change liquidStats var to unique_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
Makevelli committed Mar 1, 2024
1 parent 4c45eca commit e8efb7a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/hud_elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1205,9 +1205,10 @@ void HudElements::device_battery()

void HudElements::liquid_stats()
{
#ifdef __linux__
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_liquid])
{
std::vector<WatercoolingDevice> devices = liquidStats.GetDevicesData();
std::vector<WatercoolingDevice> devices = liquidStats->GetDevicesData();
const char* liquid_text;
liquid_text = HUDElements.params->liquid_text.c_str();

Expand Down Expand Up @@ -1273,6 +1274,7 @@ void HudElements::liquid_stats()
}
}
}
#endif
}

void HudElements::frame_count(){
Expand Down
9 changes: 8 additions & 1 deletion src/liquid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ bool LiquidStats::Init(std::vector<std::string> tempDevices, std::vector<std::st
if (!this->devices.empty())
return true;

if (tempDevices.empty() && flowDevices.empty() && additionalSensors.empty())
{
liquidStats.reset();
return false;
}

AddDeviceAndSensor(tempDevices, TEMP);
AddDeviceAndSensor(flowDevices, FLOW);
AddAdditionalSensors(additionalSensors);
Expand All @@ -399,6 +405,7 @@ bool LiquidStats::Init(std::vector<std::string> tempDevices, std::vector<std::st
if (this->devices.empty())
{
SPDLOG_ERROR("Could not find watercooling devices");
liquidStats.reset();
return false;
}

Expand Down Expand Up @@ -479,4 +486,4 @@ std::vector< WatercoolingDevice > LiquidStats::GetDevicesData() const
return this->devices;
}

LiquidStats liquidStats;
std::unique_ptr<LiquidStats> liquidStats = std::make_unique<LiquidStats>();
5 changes: 2 additions & 3 deletions src/liquid.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define MANGOHUD_LIQUID_H

#include <cstdio>
#include <memory>
#include "string_utils.h"

enum Type {TEMP, FLOW, POWER, RPM};
Expand Down Expand Up @@ -31,17 +32,15 @@ class LiquidStats
void SortSensors();
bool Init(std::vector<std::string> tempDevices, std::vector<std::string> flowDevices, std::string additionalSensors); //std::vector<std::pair<std::string, std::vector<std::string>>> additionalSensors
bool Update();
bool GetTempFile();
bool ReadInputFile(struct sensor sensor, float &input);
float GetTemp();
std::string& GetDeviceName();
int GetDeviceCount() const;
std::vector<WatercoolingDevice> GetDevicesData() const;

private:
std::vector<WatercoolingDevice> devices;
};

extern LiquidStats liquidStats;
extern std::unique_ptr<LiquidStats> liquidStats;

#endif // MANGOHUD_LIQUID_H
8 changes: 6 additions & 2 deletions src/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ void update_hw_info(const struct overlay_params& params, uint32_t vendorID)
getIoStats(g_io_stats);
#endif

#ifdef __linux__
if(params.enabled[OVERLAY_PARAM_ENABLED_liquid])
liquidStats.Update();
liquidStats->Update();
#endif

currentLogData.gpu_load = gpu_info.load;
currentLogData.gpu_temp = gpu_info.temp;
Expand Down Expand Up @@ -755,9 +757,11 @@ void init_cpu_stats(overlay_params& params)

void init_liquid_stats(overlay_params& params)
{
#ifdef __linux__
auto& enabled = params.enabled;
enabled[OVERLAY_PARAM_ENABLED_liquid] = liquidStats.Init(params.liquid_temp, params.liquid_flow, params.liquid_additional_sensors)
enabled[OVERLAY_PARAM_ENABLED_liquid] = liquidStats->Init(params.liquid_temp, params.liquid_flow, params.liquid_additional_sensors)
&& enabled[OVERLAY_PARAM_ENABLED_liquid];
#endif
}

struct pci_bus {
Expand Down
4 changes: 2 additions & 2 deletions src/overlay_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,15 +719,15 @@ static void set_param_defaults(struct overlay_params *params){
params->fps_color = { 0xb22222, 0xfdfd09, 0x39f900 };
params->fps_value = { 30, 60 };
params->round_corners = 0;
params->battery_color =0xff9078;
params->battery_color = 0xff9078;
params->fsr_steam_sharpness = -1;
params->picmip = -17;
params->af = -1;
params->font_size = 24;
params->table_columns = 3;
params->text_outline_color = 0x000000;
params->text_outline_thickness = 1.5;
params->liquid_color=0x3fcbd4;
params->liquid_color = 0x3fcbd4;
params->liquid_text = "Liquid";
}

Expand Down

0 comments on commit e8efb7a

Please sign in to comment.