Skip to content

Commit

Permalink
Merge pull request #42 from RaidcoreGG/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DeltaGW2 authored Apr 27, 2024
2 parents dea6aff + 2caaa9a commit c15814d
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/CrashHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void create_minidump(struct _EXCEPTION_POINTERS* apExceptionInfo)

LONG WINAPI UnhandledExcHandler(struct _EXCEPTION_POINTERS* aExceptionInfoPtr)
{
MessageBoxA(NULL, "I'M CRASHING BROOOO.", "Unhandled Exception", 0);
MessageBoxA(NULL, "Unhandled Exception", "Unhandled Exception", 0);
create_minidump(aExceptionInfoPtr);
return EXCEPTION_CONTINUE_SEARCH;
}
2 changes: 2 additions & 0 deletions src/GUI/EFontIdentifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace GUI

User,

Monospace,

Menomonia_Small,
MenomoniaBig_Small,
Trebuchet_Small,
Expand Down
80 changes: 57 additions & 23 deletions src/GUI/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Shared.h"
#include "Consts.h"
#include "Branch.h"
#include "Version.h"

#include "Mumble/Mumble.h"

Expand Down Expand Up @@ -40,6 +41,17 @@
#include "resource.h"
#include "Textures/Texture.h"

#ifndef STRINGIFY
#define STRINGIFY(x) #x
#endif
#ifndef TOSTRING
#define TOSTRING(x) STRINGIFY(x)
#endif

#ifndef WATERMARK
#define WATERMARK __DATE__ " " __TIME__ " (v" TOSTRING(V_MAJOR) "." TOSTRING(V_MINOR) "." TOSTRING(V_BUILD) "." TOSTRING(V_REVISION) ") [" BRANCH_NAME "]"
#endif

namespace GUI
{
/* internal forward declarations */
Expand Down Expand Up @@ -284,6 +296,21 @@ namespace GUI
}
/* draw overlay end */

#ifdef _DEBUG
ImGui::PushFont(MonospaceFont);
ImVec2 sz = ImGui::CalcTextSize(WATERMARK);

ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::SetNextWindowPos(ImVec2((Renderer::Width - sz.x) / 2, 0));
if (ImGui::Begin("NEXUS_BUILDINFO", (bool*)0, WindowFlags_Watermark))
{
ImGui::TextOutlined(WATERMARK);
};
ImGui::End();
ImGui::PopStyleVar();
ImGui::PopFont();
#endif

/* end frame */
ImGui::EndFrame();
ImGui::Render();
Expand Down Expand Up @@ -326,26 +353,34 @@ namespace GUI

ImGuiStyle* style = &ImGui::GetStyle();

while (std::getline(arcIni, line))
try
{
if (line.find(styleKey, 0) != line.npos)
while (std::getline(arcIni, line))
{
line = line.substr(styleKey.length());
std::string decode = Base64::Decode(&line[0], line.length());
memcpy(style, &decode[0], decode.length());
}
else if (line.find(coloursKey, 0) != line.npos)
{
line = line.substr(coloursKey.length());
std::string decode = Base64::Decode(&line[0], line.length());
memcpy(&style->Colors[0], &decode[0], decode.length());
}
else if (line.find(fontSizeKey, 0) != line.npos)
{
line = line.substr(fontSizeKey.length());
FontSize = std::stof(line);
if (line.find(styleKey, 0) != line.npos)
{
line = line.substr(styleKey.length());
std::string decode = Base64::Decode(&line[0], line.length());
memcpy(style, &decode[0], decode.length());
}
else if (line.find(coloursKey, 0) != line.npos)
{
line = line.substr(coloursKey.length());
std::string decode = Base64::Decode(&line[0], line.length());
memcpy(&style->Colors[0], &decode[0], decode.length());
}
else if (line.find(fontSizeKey, 0) != line.npos)
{
line = line.substr(fontSizeKey.length());
FontSize = std::stof(line);
}
}
}
catch (...)
{
LogDebug(CH_CORE, "Couldn't parse ArcDPS style.");
}

arcIni.close();
}
}
Expand Down Expand Up @@ -654,24 +689,23 @@ namespace GUI
rb.AddRanges(io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
rb.BuildRanges(&ranges);

/* add user font, or fallback to default */
/* add user font */
if (!LinkArcDPSStyle && std::filesystem::exists(Path::F_FONT))
{
fontPath = Path::F_FONT;
std::string strFont = Path::F_FONT.string();
io.Fonts->AddFontFromFileTTF(strFont.c_str(), FontSize, nullptr, ranges.Data);
UserFont = io.Fonts->AddFontFromFileTTF(strFont.c_str(), FontSize, nullptr, ranges.Data);
}
else if (LinkArcDPSStyle && std::filesystem::exists(Path::D_GW2_ADDONS / "arcdps" / "arcdps_font.ttf"))
{
fontPath = Path::D_GW2_ADDONS / "arcdps" / "arcdps_font.ttf";
std::string strFont = (Path::D_GW2_ADDONS / "arcdps" / "arcdps_font.ttf").string();
io.Fonts->AddFontFromFileTTF(strFont.c_str(), FontSize, nullptr, ranges.Data);
}
else
{
io.Fonts->AddFontDefault();
UserFont = io.Fonts->AddFontFromFileTTF(strFont.c_str(), FontSize, nullptr, ranges.Data);
}

/* add default font */
MonospaceFont = io.Fonts->AddFontDefault();

/* load gw2 fonts */
LPVOID resM{}; DWORD szM{};
GetResource(NexusHandle, MAKEINTRESOURCE(RES_FONT_MENOMONIA), RT_FONT, &resM, &szM);
Expand Down
21 changes: 21 additions & 0 deletions src/GUI/Widgets/Addons/AddonItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,26 @@ namespace GUI
aAddon->Definitions->UpdateLink != nullptr ? aAddon->Definitions->UpdateLink : ""))
{
Loader::QueueAddon(ELoaderAction::Reload, tmpPath);

std::string notification = aAddon->Definitions->Name;
if (aAddon->State == EAddonState::LoadedLOCKED)
{
notification.append(Language.Translate("((000079))"));
}
else
{
notification.append(" ");
notification.append(Language.Translate("((000081))"));
}

GUI::Alerts::Notify(notification.c_str());
}
else
{
std::string notification = aAddon->Definitions->Name;
notification.append(" ");
notification.append(Language.Translate("((000082))"));
GUI::Alerts::Notify(notification.c_str());
}
Sleep(1000); // arbitrary sleep otherwise the user never even sees "is checking..."
aAddon->IsCheckingForUpdates = false;
Expand All @@ -159,6 +179,7 @@ namespace GUI
CtxMenuBullet->Resource, CtxMenuHighlight->Resource, ImVec2(btnWidth * ImGui::GetFontSize(), btnHeight)))
{
aAddon->IsPausingUpdates = !aAddon->IsPausingUpdates;
Loader::SaveAddonConfig();
}

ImGui::Separator();
Expand Down
3 changes: 2 additions & 1 deletion src/GUI/Widgets/Options/COptionsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ namespace GUI

ImGui::EndCombo();
}

ImGui::Text(Language.Translate("((000051))"));
if (ImGui::InputFloat2("##qaoffset", (float*)&QuickAccess::Offset))
if (ImGui::DragFloat2("##qaoffset", (float*)&QuickAccess::Offset, 1.0f, ((int)Renderer::Height) * -1, (int)Renderer::Height))
{
Settings::Settings[OPT_QAOFFSETX] = QuickAccess::Offset.x;
Settings::Settings[OPT_QAOFFSETY] = QuickAccess::Offset.y;
Expand Down
6 changes: 5 additions & 1 deletion src/GUI/Widgets/Overlay/CMumbleOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ namespace GUI
{
if (!Visible) { return; }

ImGui::PushFont(MonospaceFont);

ImVec2 pos = ImVec2(16.0f, 16.0f);
ImVec2 size = ImVec2(ImGui::GetFontSize() * 10.0f, 0.0f);
ImVec2 size = ImVec2(ImGui::CalcTextSize("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx").x, 0.0f);

ImGui::SetNextWindowBgAlpha(0.35f);
ImGui::SetNextWindowPos(pos);
Expand Down Expand Up @@ -282,5 +284,7 @@ namespace GUI
}
ImGui::End();
}

ImGui::PopFont();
}
}
2 changes: 1 addition & 1 deletion src/GUI/Widgets/QuickAccess/QuickAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace GUI
bool AlwaysShow = false;
bool VerticalLayout = false;
EQAPosition Location = EQAPosition::Extend;
ImVec2 Offset = ImVec2(((size + 1) * Renderer::Scaling) * 9, 0.0f);
ImVec2 Offset = ImVec2(0, 0);

Texture* IconNotification = nullptr;

Expand Down
5 changes: 1 addition & 4 deletions src/Loader/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,9 @@ namespace Loader
catch (std::filesystem::filesystem_error fErr)
{
LogDebug(CH_LOADER, "%s", fErr.what());
return;
}
}

if (path.extension() == extOld)
else if (path.extension() == extOld)
{
try
{
Expand All @@ -523,7 +521,6 @@ namespace Loader
catch (std::filesystem::filesystem_error fErr)
{
LogDebug(CH_LOADER, "%s", fErr.what());
return;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Locales
Submodule Locales updated 1 files
+4 −1 en_Main.json
2 changes: 2 additions & 0 deletions src/Shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ NexusLinkData* NexusLink = nullptr;

CLocalization& Language = CLocalization::GetInstance();

ImFont* MonospaceFont = nullptr;
ImFont* UserFont = nullptr;
ImFont* Font = nullptr;
ImFont* FontBig = nullptr;
ImFont* FontUI = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions src/Shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ extern NexusLinkData* NexusLink;

extern CLocalization& Language;

extern ImFont* MonospaceFont; /* default/monospace/console font */
extern ImFont* UserFont; /* custom user font */
extern ImFont* Font; /* Menomonia */
extern ImFont* FontBig; /* Menomonia, but slightly bigger */
extern ImFont* FontUI; /* Trebuchet */
Expand Down

0 comments on commit c15814d

Please sign in to comment.