Skip to content

Commit

Permalink
Merge pull request #39 from RaidcoreGG/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DeltaGW2 authored Apr 21, 2024
2 parents f3f2d48 + 7f00597 commit bff1ac8
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 34 deletions.
8 changes: 5 additions & 3 deletions src/GUI/Widgets/Addons/AddonItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ namespace GUI
if (ImGui::GW2::Button((Language.Translate(aAddon->IsFlaggedForEnable ? "((000020))" : "((000024))") + sig).c_str(), ImVec2(btnWidth * ImGui::GetFontSize(), btnHeight)))
{
aAddon->IsFlaggedForEnable = !aAddon->IsFlaggedForEnable;
Loader::SaveAddonConfig();

if (aAddon->IsFlaggedForEnable)
{
std::string msg = aAddon->Definitions->Name;
Expand Down Expand Up @@ -282,7 +284,7 @@ namespace GUI
}
}

void AddonItem(LibraryAddon* aAddon, bool aInstalled)
void AddonItem(LibraryAddon* aAddon, bool aInstalled, bool aIsArcPlugin)
{
float btnHeight = 22.0f * Renderer::Scaling;
float itemWidthScaled = itemWidth * Renderer::Scaling;
Expand Down Expand Up @@ -364,9 +366,9 @@ namespace GUI
{
if (!aAddon->IsInstalling)
{
std::thread([aAddon]()
std::thread([aAddon, aIsArcPlugin]()
{
Loader::Library::InstallAddon(aAddon);
Loader::Library::InstallAddon(aAddon, aIsArcPlugin);
aAddon->IsInstalling = false;
})
.detach();
Expand Down
2 changes: 1 addition & 1 deletion src/GUI/Widgets/Addons/AddonItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace GUI
{
void AddonItem(std::filesystem::path aPath, Addon* aAddon);
void AddonItem(LibraryAddon* aAddon, bool aInstalled = false);
void AddonItem(LibraryAddon* aAddon, bool aInstalled = false, bool aIsArcPlugin = false);
}

#endif
2 changes: 1 addition & 1 deletion src/GUI/Widgets/Addons/CAddonsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ namespace GUI
}
if (false == exists || true == showInstalled)
{
AddonItem(arclibAddon, exists);
AddonItem(arclibAddon, exists, true);
downloadable++;
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/Loader/ArcDPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ namespace ArcDPS

IsPluginAtlasBuilt = true;
}
void AddToAtlasBySig(unsigned int aArcSignature)
{
const std::lock_guard<std::mutex> lock(Mutex);
if (std::find(Plugins.begin(), Plugins.end(), aArcSignature) == Plugins.end())
{
Plugins.push_back(aArcSignature);
}

IsPluginAtlasBuilt = true;
}
void Add(HMODULE aModule)
{
if (exp_addextension2)
Expand Down
2 changes: 2 additions & 0 deletions src/Loader/ArcDPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace ArcDPS
void GetPlugins();
/* Callback to receive arcdps plugins. */
void AddToAtlas(arcdps_exports* aArcdpsExports);
/* Callback to receive arcdps plugins. */
void AddToAtlasBySig(unsigned int aArcSignature);
/* Add extension to arcdps. */
void Add(HMODULE aModule);
}
Expand Down
12 changes: 10 additions & 2 deletions src/Loader/Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Library.h"

#include "Loader.h"
#include "ArcDPS.h"

#include "core.h"
#include "Consts.h"
Expand Down Expand Up @@ -62,7 +63,7 @@ namespace Loader
}
}

void InstallAddon(LibraryAddon* aAddon)
void InstallAddon(LibraryAddon* aAddon, bool aIsArcPlugin)
{
aAddon->IsInstalling = true;

Expand Down Expand Up @@ -251,7 +252,14 @@ namespace Loader
}

LogInfo(CH_LOADER, "Successfully installed %s.", aAddon->Name.c_str());
Loader::QueueAddon(ELoaderAction::Reload, installPath);
if (aIsArcPlugin)
{
ArcDPS::AddToAtlasBySig(aAddon->Signature);
}
else
{
Loader::QueueAddon(ELoaderAction::Reload, installPath);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Loader/Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Loader
/// InstallAddon:
/// Installs an addon and notifies the Loader.
///----------------------------------------------------------------------------------------------------
void InstallAddon(LibraryAddon* aAddon);
void InstallAddon(LibraryAddon* aAddon, bool aIsArcPlugin = false);
}
}

Expand Down
30 changes: 4 additions & 26 deletions src/Loader/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,16 +582,7 @@ namespace Loader
/* doesn't have GetAddonDef */
if (FindFunction(addon->Module, &getAddonDef, "GetAddonDef") == false)
{
/* if it is an arc plugin, tell arc to load it */
void* exp_get_init_addr = nullptr;
if (FindFunction(addon->Module, &exp_get_init_addr, "get_init_addr") == true)
{
ArcDPS::Add(addon->Module);
}
else
{
LogWarning(CH_LOADER, "\"%s\" is not a Nexus-compatible library. Incompatible.", strFile.c_str());
}
LogWarning(CH_LOADER, "\"%s\" is not a Nexus-compatible library. Incompatible.", strFile.c_str());
FreeLibrary(addon->Module);
addon->State = EAddonState::NotLoadedIncompatible;
addon->Module = nullptr;
Expand Down Expand Up @@ -962,23 +953,10 @@ namespace Loader
return;
}

int freeCalls = 0;

while (FreeLibrary(addon->Module))
/* sanity check */
if (addon->Module)
{
freeCalls++;

if (freeCalls >= 10)
{
LogWarning(CH_LOADER, "Aborting unload of \"%s\". Called FreeLibrary() 10 times.", strFile.c_str());
break;
}
}

if (freeCalls == 0)
{
LogWarning(CH_LOADER, "Couldn't unload \"%s\". FreeLibrary() call failed.", strFile.c_str());
return;
FreeLibrary(addon->Module);
}

addon->Module = nullptr;
Expand Down

0 comments on commit bff1ac8

Please sign in to comment.