Skip to content

Commit

Permalink
Merge pull request #13 from RaidcoreGG/dev
Browse files Browse the repository at this point in the history
various fixes
  • Loading branch information
DeltaGW2 authored Nov 16, 2023
2 parents 92e9533 + dcdb864 commit f61d04e
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 168 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,4 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/
src/Branch.h
src/Version.h
23 changes: 0 additions & 23 deletions src/GUI/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,29 +190,6 @@ namespace GUI
ImGui::NewFrame();
/* new frame end */

//#define WATERMARK
#ifdef WATERMARK
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::SetNextWindowPos(ImVec2(16.0f, Renderer::Height != 0 ? Renderer::Height - ImGui::GetTextLineHeight() - 16.0f : 0));
if (ImGui::Begin("NEXUS_BUILDINFO", (bool*)0, WindowFlags_Watermark))
{
ImGui::SetCursorPos(ImVec2(0, 0));
ImGui::TextOutlined("Limited Test");
ImGui::SameLine();
ImGui::TextOutlined(__DATE__ " " __TIME__);
ImGui::SameLine();
ImGui::TextOutlined(("(v" + Version->ToString() + ")").c_str());
ImGui::SameLine();
#ifdef _DEBUG
ImGui::TextOutlined("debug/" BRANCH_NAME);
#else
ImGui::TextOutlined("release/" BRANCH_NAME);
#endif
};
ImGui::End();
ImGui::PopStyleVar();
#endif

/* draw overlay */
if (IsUIVisible)
{
Expand Down
6 changes: 4 additions & 2 deletions src/GUI/Widgets/About/AboutBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ namespace GUI
ImGui::TextDisabled("Version:");
ImGui::Text(""); ImGui::SameLine(); ImGui::Text(Version->ToString().c_str());
#ifdef _DEBUG
ImGui::SameLine(); ImGui::TextDisabled("[DEBUG BUILD]");
ImGui::SameLine(); ImGui::TextDisabled("debug/" BRANCH_NAME);
#else
ImGui::SameLine(); ImGui::TextDisabled("release/" BRANCH_NAME);
#endif
ImGui::TextDisabled("Location:");
ImGui::Text(""); ImGui::SameLine(); ImGui::Text(Path::F_HOST_DLL);
if (ImGui::Tooltip())
{
for (std::string param : Parameters)
{
ImGui::TextDisabled(("-" + param).c_str());
ImGui::TextDisabled(param.c_str());
}

ImGui::EndTooltip();
Expand Down
1 change: 1 addition & 0 deletions src/GUI/Widgets/About/AboutBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../../../Shared.h"
#include "../../../Paths.h"
#include "../../../State.h"
#include "../../../Branch.h"

#include "../../../imgui/imgui.h"
#include "../../../imgui/imgui_extensions.h"
Expand Down
10 changes: 9 additions & 1 deletion src/Loader/AddonDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ bool operator>(AddonVersion lhs, AddonVersion rhs)
}
bool operator<(AddonVersion lhs, AddonVersion rhs)
{
return !(lhs > rhs);
if ((lhs.Major < rhs.Major) ||
(lhs.Major == rhs.Major && lhs.Minor < rhs.Minor) ||
(lhs.Major == rhs.Major && lhs.Minor == rhs.Minor && lhs.Build < rhs.Build) ||
(lhs.Major == rhs.Major && lhs.Minor == rhs.Minor && lhs.Build == rhs.Build && lhs.Revision < rhs.Revision))
{
return true;
}

return false;
}

bool AddonDefinition::HasMinimumRequirements()
Expand Down
9 changes: 9 additions & 0 deletions src/Loader/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ namespace Loader

/* why has god forsaken me */
AddonDefinition* tmpDefs = getAddonDef();

if (tmpDefs == nullptr)
{
LogDebug(CH_LOADER, "\"%s\" is Nexus-compatible but returned a nullptr. Incompatible I guess?", path);
addon->State = EAddonState::Incompatible;
FreeLibrary(hMod);
return;
}

AddonDefinition* defs = new AddonDefinition();
memcpy(defs, tmpDefs, sizeof(AddonDefinition));
defs->Name = new char[strlen(tmpDefs->Name) + 1];
Expand Down
11 changes: 7 additions & 4 deletions src/Nexus.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Microsoft Visual C++ generated resource script.
//
#include "Version.h"
#include "resource.h"
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -51,8 +54,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEVERSION V_MAJOR,V_MINOR,V_BUILD,V_REVISION
PRODUCTVERSION V_MAJOR,V_MINOR,V_BUILD,V_REVISION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -69,11 +72,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "Raidcore"
VALUE "FileDescription", "Unofficial Guild Wars 2 Addon Host"
VALUE "FileVersion", "1.0.0.1"
VALUE "FileVersion", TOSTRING(V_MAJOR) "." TOSTRING(V_MINOR) "." TOSTRING(V_BUILD) "." TOSTRING(V_REVISION)
VALUE "InternalName", "nexus.dll"
VALUE "LegalCopyright", "� 2023 Raidcore"
VALUE "ProductName", "Nexus"
VALUE "ProductVersion", "1.0.0.1"
VALUE "ProductVersion", TOSTRING(V_MAJOR) "." TOSTRING(V_MINOR) "." TOSTRING(V_BUILD) "." TOSTRING(V_REVISION)
END
END
BLOCK "VarFileInfo"
Expand Down
71 changes: 69 additions & 2 deletions src/Nexus.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
<ClInclude Include="Textures\TextureLoader.h" />
<ClInclude Include="types.h" />
<ClInclude Include="Updater\Updater.h" />
<ClInclude Include="Version.h" />
<ClInclude Include="WndProc\FuncDefs.h" />
<ClInclude Include="WndProc\WndProcHandler.h" />
</ItemGroup>
Expand Down Expand Up @@ -392,7 +393,40 @@ set /p branchname=&lt;temp_file.h
set branchmacro=#define BRANCH_NAME "%branchname%"
echo #pragma once &gt; Branch.h
echo %branchmacro% &gt;&gt; Branch.h
del temp_file.h</Command>
del temp_file.h

:: Check WMIC is available
WMIC.EXE Alias /? &gt;NUL 2&gt;&amp;1 || GOTO s_error

:: Use WMIC to retrieve date and time
FOR /F "skip=1 tokens=1-6" %%G IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
IF "%%~L"=="" goto s_done
Set _yyyy=%%L
Set _mm=00%%J
Set _dd=00%%G
Set _hour=00%%H
SET _minute=00%%I
)
:s_done

:: Pad digits with leading zeros
Set _mm=%_mm:~-2%
Set _dd=%_dd:~-2%
Set _hour=%_hour:~-2%
Set _minute=%_minute:~-2%

:: Display the date/time in ISO 8601 format:
Set _isodate=%_yyyy%-%_mm%-%_dd% %_hour%:%_minute%
Echo %_isodate%

echo #pragma once &gt; Version.h
echo #define V_MAJOR %_isodate:~0,4% &gt;&gt; Version.h
echo #define V_MINOR %_isodate:~5,2% &gt;&gt; Version.h
echo #define V_BUILD %_isodate:~8,2% &gt;&gt; Version.h
SET /A var_hours = %_isodate:~11,2%
SET /A var_minutes = %_isodate:~14,2%
SET /A var_res = %var_hours% * 60 + %var_minutes%
echo #define V_REVISION %var_res% &gt;&gt; Version.h</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>mkdir $(TargetDir)$(API_BUILDER_TARGET_DIR)
Expand Down Expand Up @@ -429,7 +463,40 @@ set /p branchname=&lt;temp_file.h
set branchmacro=#define BRANCH_NAME "%branchname%"
echo #pragma once &gt; Branch.h
echo %branchmacro% &gt;&gt; Branch.h
del temp_file.h</Command>
del temp_file.h

:: Check WMIC is available
WMIC.EXE Alias /? &gt;NUL 2&gt;&amp;1 || GOTO s_error

:: Use WMIC to retrieve date and time
FOR /F "skip=1 tokens=1-6" %%G IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
IF "%%~L"=="" goto s_done
Set _yyyy=%%L
Set _mm=00%%J
Set _dd=00%%G
Set _hour=00%%H
SET _minute=00%%I
)
:s_done

:: Pad digits with leading zeros
Set _mm=%_mm:~-2%
Set _dd=%_dd:~-2%
Set _hour=%_hour:~-2%
Set _minute=%_minute:~-2%

:: Display the date/time in ISO 8601 format:
Set _isodate=%_yyyy%-%_mm%-%_dd% %_hour%:%_minute%
Echo %_isodate%

echo #pragma once &gt; Version.h
echo #define V_MAJOR %_isodate:~0,4% &gt;&gt; Version.h
echo #define V_MINOR %_isodate:~5,2% &gt;&gt; Version.h
echo #define V_BUILD %_isodate:~8,2% &gt;&gt; Version.h
SET /A var_hours = %_isodate:~11,2%
SET /A var_minutes = %_isodate:~14,2%
SET /A var_res = %var_hours% * 60 + %var_minutes%
echo #define V_REVISION %var_res% &gt;&gt; Version.h</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>mkdir $(TargetDir)$(API_BUILDER_TARGET_DIR)
Expand Down
3 changes: 3 additions & 0 deletions src/Nexus.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,9 @@
<ClInclude Include="Updater\Updater.h">
<Filter>Updater</Filter>
</ClInclude>
<ClInclude Include="Version.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Nexus.rc">
Expand Down
52 changes: 26 additions & 26 deletions src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,50 @@ namespace State
bool first = true;
bool customMumble = false;

std::string cmdline = GetCommandLineA();
cmdline.append(" -;"); // append another space, so the last substring can be ignored
std::string delimiter = " -";
int argc;
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);

size_t pos = 0;
std::string token;
while ((pos = cmdline.find(delimiter)) != std::string::npos)
for (int i = 0; i < argc; i++)
{
token = cmdline.substr(0, pos);
std::wstring paramW = argv[i];
std::string token = WStrToStr(paramW);

std::string cmp = token;
cmdline.erase(0, pos + delimiter.length());

if (first) { first = false; continue; } // skip location param

Parameters.push_back(token);
std::transform(cmp.begin(), cmp.end(), cmp.begin(), ::tolower);

//Log("dbg", "token: \"%s\" @ %d", token.c_str(), pos);

// token -> is the unmodified string as from the commandline
// cmp -> same as token, except it's been normalised (aka written in lowercase)

if (cmp == "ggdev") { IsDeveloperMode = true; }
if (cmp == "ggconsole") { IsConsoleEnabled = true; }
if (cmp == "ggvanilla") { IsVanilla = true; }
if (cmp == "sharearchive") { MultiboxState = MultiboxState | EMultiboxState::ARCHIVE_SHARED; }
if (cmp == "multi") { MultiboxState = MultiboxState | EMultiboxState::LOCAL_SHARED; }
if (cmp == "-ggdev") { IsDeveloperMode = true; }
if (cmp == "-ggconsole") { IsConsoleEnabled = true; }
if (cmp == "-ggvanilla") { IsVanilla = true; }
if (cmp == "-sharearchive") { MultiboxState = MultiboxState | EMultiboxState::ARCHIVE_SHARED; }
if (cmp == "-multi") { MultiboxState = MultiboxState | EMultiboxState::LOCAL_SHARED; }

size_t subpos = 0;
std::string subtoken;
if ((subpos = cmp.find("mumble ")) != std::string::npos)
if (cmp == "-mumble" && i + 1 <= argc)
{
subtoken = token.substr(7, token.length() - subpos);
if (std::regex_match(subtoken, std::regex("\"(.*?)\"")))
{
subtoken = subtoken.substr(1, subtoken.length() - 2);
}
//Log("dbg", "subtoken: \"%s\" @ %d", subtoken.c_str(), subpos);
std::wstring mumbleNameW = argv[i + 1];
std::string mumbleName = WStrToStr(mumbleNameW);

customMumble = true;
MumbleLink = (LinkedMem*)DataLink::ShareResource(DL_MUMBLE_LINK, sizeof(LinkedMem), subtoken.c_str());
MumbleLink = (LinkedMem*)DataLink::ShareResource(DL_MUMBLE_LINK, sizeof(LinkedMem), mumbleName.c_str());

token.append(" ");
token.append(mumbleName);
Parameters.push_back(token);
i++; // manual increment to skip
}
else
{
Parameters.push_back(token);
}
}

///////////////////////////////////

if (!customMumble)
{
MumbleLink = (LinkedMem*)DataLink::ShareResource(DL_MUMBLE_LINK, sizeof(LinkedMem), "MumbleLink");
Expand Down
1 change: 1 addition & 0 deletions src/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <shellapi.h>
#include <regex>

#include "core.h"
#include "Consts.h"
#include "Shared.h"

Expand Down
Loading

0 comments on commit f61d04e

Please sign in to comment.