Skip to content

Commit

Permalink
Add configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
server-imp committed Sep 23, 2023
1 parent 8b6c927 commit ccf7449
Show file tree
Hide file tree
Showing 10 changed files with 639 additions and 105 deletions.
2 changes: 2 additions & 0 deletions DLLProxy.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="asi.h" />
<ClInclude Include="cfg.h" />
<ClInclude Include="log.h" />
<ClInclude Include="memory.h" />
<ClInclude Include="util.h" />
<ClInclude Include="sfae.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions DLLProxy.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
<ClInclude Include="log.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="cfg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="util.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
Expand Down
26 changes: 13 additions & 13 deletions asi.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@
#define WindowTitle "Starfield"
#define WindowClass "Starfield"

// Reload key and optional modifier key
#define RELOAD_KEY VK_F11
#define RELOAD_MOD VK_LSHIFT // 0 for no modifier key

// Relative directory to load .ASI and .DLL files from
#define PLUGIN_DIRECTORY "SFAE ASIL";

namespace asi
{
uint32_t reloadKey = VK_F11;
uint32_t reloadKeyModifier = VK_LSHIFT;
std::string relativePath = "SFAE ASIL";

std::atomic_bool want_reload = false;

fs::path plugin_directory;
Expand Down Expand Up @@ -107,12 +104,11 @@ namespace asi
switch (uMsg)
{
case WM_KEYDOWN:
switch (wParam)
{
// If the key down is our RELOAD_KEY
case RELOAD_KEY:
if (reloadKey == wParam)
{
// And if we have a modifier key it must be pressed also
if (RELOAD_MOD && !(GetAsyncKeyState(RELOAD_MOD) & 0x8000))
if (reloadKeyModifier && !(GetAsyncKeyState(reloadKeyModifier) & 0x8000))
break;

want_reload = true;
Expand All @@ -126,13 +122,17 @@ namespace asi
return CallWindowProcW((WNDPROC)orgWndProc, hWnd, uMsg, wParam, lParam);
}

void start()
void start(std::string relativePath, uint32_t reloadKey, uint32_t reloadKeyModifier)
{
asi::reloadKey = reloadKey;
asi::reloadKeyModifier = reloadKeyModifier;
asi::relativePath = relativePath;

CreateThread(
0, 0,
[](PVOID)->DWORD
{
plugin_directory = fs::current_path() / PLUGIN_DIRECTORY;
plugin_directory = fs::current_path() / asi::relativePath;

load_plugins();

Expand Down
Loading

0 comments on commit ccf7449

Please sign in to comment.