Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
3vcloud committed Nov 22, 2023
2 parents b79b560 + 3cbecf5 commit fac9cda
Show file tree
Hide file tree
Showing 87 changed files with 803 additions and 579 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "Dependencies/GWCA"]
path = Dependencies/GWCA
url = https://github.com/GregLando113/GWCA.git
url = https://github.com/gwdevhub/GWCA.git
2 changes: 1 addition & 1 deletion Dependencies/GWCA
Submodule GWCA updated from d85f7c to 124690
3 changes: 2 additions & 1 deletion GWToolbox/Download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bool Download(std::string& content, const char* url)
{
RestClient client;
client.SetUrl(url);
client.SetFollowLocation(true);
client.SetVerifyPeer(false);
client.SetTimeoutSec(5);
client.SetUserAgent("curl/7.71.1");
Expand Down Expand Up @@ -170,7 +171,7 @@ std::string GetDllRelease(const std::filesystem::path& dllpath)
bool DownloadWindow::DownloadAllFiles()
{
std::string content;
if (!Download(content, "https://api.github.com/repos/HasKha/GWToolboxpp/releases/latest")) {
if (!Download(content, "https://api.github.com/repos/gwdevhub/GWToolboxpp/releases/latest")) {
fprintf(stderr, "Couldn't download the latest release of GWToolboxpp\n");
// @Remark:
// We may not be able to grep Github api. (For instance, if we spam it)
Expand Down
13 changes: 8 additions & 5 deletions GWToolboxdll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ set_target_properties(GWToolboxdll PROPERTIES
VS_GLOBAL_EnableClangTidyCodeAnalysis false
)

target_link_options(GWToolboxdll PRIVATE /WX /OPT:REF /OPT:ICF /SAFESEH:NO)
target_link_options(GWToolboxdll PRIVATE $<$<NOT:$<CONFIG:Debug>>:/LTCG /INCREMENTAL:NO>)
target_link_options(GWToolboxdll PRIVATE $<$<CONFIG:Debug>:/IGNORE:4098 /OPT:NOREF /OPT:NOICF>)
target_link_options(GWToolboxdll PRIVATE $<$<CONFIG:RelWithDebInfo>:/OPT:NOICF>)
target_link_options(GWToolboxdll PRIVATE /IGNORE:4099) # pdb not found for github action
target_link_options(GWToolboxdll PRIVATE
/WX /OPT:REF /OPT:ICF /SAFESEH:NO
$<$<NOT:$<CONFIG:Debug>>:/LTCG /INCREMENTAL:NO>
$<$<CONFIG:Debug>:/IGNORE:4098 /OPT:NOREF /OPT:NOICF>
$<$<CONFIG:RelWithDebInfo>:/OPT:NOICF>
$<$<CONFIG:DEBUG>:/NODEFAULTLIB:LIBCMT>
/IGNORE:4099 # pdb not found for github action
)

target_include_directories(GWToolboxdll PRIVATE
"${PROJECT_SOURCE_DIR}/Dependencies"
Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/Defines.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#define GWTOOLBOX_WEBSITE "https://www.gwtoolbox.com"
#define RESOURCES_DOWNLOAD_URL "https://raw.githubusercontent.com/HasKha/GWToolboxpp/master/resources/"
#define RESOURCES_DOWNLOAD_URL "https://raw.githubusercontent.com/gwdevhub/GWToolboxpp/master/resources/"

#define DIRECTX_REDIST_WEBSITE "https://www.microsoft.com/en-us/download/details.aspx?id=35"

Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/GWToolbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace {

Resources::EnsureFileExists(
Resources::GetPath(L"Font.ttf"),
"https://raw.githubusercontent.com/HasKha/GWToolboxpp/master/resources/Font.ttf",
"https://raw.githubusercontent.com/gwdevhub/GWToolboxpp/master/resources/Font.ttf",
[](const bool success, const std::wstring& error) {
if (success) {
GuiUtils::LoadFonts();
Expand Down
61 changes: 0 additions & 61 deletions GWToolboxdll/GWToolbox.rc
Original file line number Diff line number Diff line change
Expand Up @@ -47,67 +47,6 @@ END

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

IDB_Missions_MissionIconIncomplete RCDATA "..\\resources\\missions\\MissionIconIncomplete.png"

IDB_Missions_MissionIconBonus RCDATA "..\\resources\\missions\\MissionIconBonus.png"

IDB_Missions_MissionIconPrimary RCDATA "..\\resources\\missions\\MissionIconPrimary.png"

IDB_Missions_MissionIcon RCDATA "..\\resources\\missions\\MissionIcon.png"

IDB_Missions_FactionsMissionIconIncomplete RCDATA "..\\resources\\missions\\FactionsMissionIconIncomplete.png"

IDB_Missions_FactionsMissionIconExpert RCDATA "..\\resources\\missions\\FactionsMissionIconExpert.png"

IDB_Missions_FactionsMissionIconPrimary RCDATA "..\\resources\\missions\\FactionsMissionIconPrimary.png"

IDB_Missions_FactionsMissionIcon RCDATA "..\\resources\\missions\\FactionsMissionIcon.png"

IDB_Missions_NightfallMissionIconIncomplete RCDATA "..\\resources\\missions\\NightfallMissionIconIncomplete.png"

IDB_Missions_NightfallMissionIconExpert RCDATA "..\\resources\\missions\\NightfallMissionIconExpert.png"

IDB_Missions_NightfallMissionIconPrimary RCDATA "..\\resources\\missions\\NightfallMissionIconPrimary.png"

IDB_Missions_NightfallMissionIcon RCDATA "..\\resources\\missions\\NightfallMissionIcon.png"

IDB_Missions_NightfallTormentMissionIconIncomplete RCDATA "..\\resources\\missions\\NightfallTormentMissionIconIncomplete.png"

IDB_Missions_NightfallTormentMissionIconExpert RCDATA "..\\resources\\missions\\NightfallTormentMissionIconExpert.png"

IDB_Missions_NightfallTormentMissionIconPrimary RCDATA "..\\resources\\missions\\NightfallTormentMissionIconPrimary.png"

IDB_Missions_NightfallTormentMissionIcon RCDATA "..\\resources\\missions\\NightfallTormentMissionIcon.png"

IDB_Missions_EOTNMissionIncomplete RCDATA "..\\resources\\missions\\EOTNMissionIncomplete.png"

IDB_Missions_EOTNMission RCDATA "..\\resources\\missions\\EOTNMission.png"

IDB_Missions_EOTNDungeonIncomplete RCDATA "..\\resources\\missions\\EOTNDungeonIncomplete.png"

IDB_Missions_EOTNDungeon RCDATA "..\\resources\\missions\\EOTNDungeon.png"

IDB_Missions_HardModeMissionIconIncomplete RCDATA "..\\resources\\missions\\HardModeMissionIconIncomplete.png"

IDB_Missions_HardModeMissionIcon1 RCDATA "..\\resources\\missions\\HardModeMissionIcon1.png"

IDB_Missions_HardModeMissionIcon1b RCDATA "..\\resources\\missions\\HardModeMissionIcon1b.png"

IDB_Missions_HardModeMissionIcon2 RCDATA "..\\resources\\missions\\HardModeMissionIcon2.png"

IDB_Missions_HardModeMissionIcon RCDATA "..\\resources\\missions\\HardModeMissionIcon.png"

IDB_Missions_EOTNHardModeMissionIncomplete RCDATA "..\\resources\\missions\\EOTNHardModeMissionIncomplete.png"

IDB_Missions_EOTNHardModeMission RCDATA "..\\resources\\missions\\EOTNHardModeMission.png"

IDB_Missions_EOTNHardModeDungeonIncomplete RCDATA "..\\resources\\missions\\EOTNHardModeDungeonIncomplete.png"

IDB_Missions_Vanquish RCDATA "..\\resources\\missions\\HardModeMissionIcon1.png"

IDB_Missions_VanquishIncomplete RCDATA "..\\resources\\missions\\HardModeMissionIconIncomplete.png"

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down
75 changes: 56 additions & 19 deletions GWToolboxdll/ImGuiAddons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ namespace ImGui {
}
return *confirm_bool;
}

bool IconButton(const char* label, const ImTextureID icon, const ImVec2& size, const ImGuiButtonFlags flags, const ImVec2& icon_size)
bool CompositeIconButton(const char* label, const ImTextureID* icons, size_t icons_len, const ImVec2& size, const ImGuiButtonFlags flags, const ImVec2& icon_size, const ImVec2& uv0, ImVec2 uv1)
{
char button_id[128];
sprintf(button_id, "###icon_button_%s", label);
Expand All @@ -118,22 +117,17 @@ namespace ImGui {

const ImVec2& button_size = GetItemRectSize();
ImVec2 img_size = icon_size;
if (!icon) {
img_size = {0.f, 0.f};
if (icon_size.x > 0.f) {
img_size.x = icon_size.x;
}
else {
if (icon_size.x > 0.f) {
img_size.x = icon_size.x;
}
if (icon_size.y > 0.f) {
img_size.y = icon_size.y;
}
if (img_size.y == 0.f) {
img_size.y = button_size.y - 2.f;
}
if (img_size.x == 0.f) {
img_size.x = img_size.y;
}
if (icon_size.y > 0.f) {
img_size.y = icon_size.y;
}
if (img_size.y == 0.f) {
img_size.y = button_size.y - 2.f;
}
if (img_size.x == 0.f) {
img_size.x = img_size.y;
}
const ImGuiStyle& style = GetStyle();
const float content_width = img_size.x + textsize.x + style.FramePadding.x * 2.f;
Expand All @@ -146,14 +140,27 @@ namespace ImGui {
const float img_y = pos.y + (button_size.y - img_size.y) / 2.f;
const float text_x = img_x + img_size.x + 3.f;
const float text_y = pos.y + (button_size.y - textsize.y) * style.ButtonTextAlign.y;
if (img_size.x) {
AddImageCropped(icon, ImVec2(img_x, img_y), ImVec2(img_x + img_size.x, img_y + img_size.y));
const auto top_left = ImVec2(img_x, img_y);
const auto bottom_right = ImVec2(img_x + img_size.x, img_y + img_size.y);
for (size_t i = 0; i < icons_len; i++) {
if (!icons[i])
continue;
if (uv0.x == uv1.x && uv0.y == uv1.y) {
GetWindowDrawList()->AddImage(icons[i], top_left, bottom_right, uv0, CalculateUvCrop(icons[i], img_size));
}
else {
GetWindowDrawList()->AddImage(icons[i], top_left, bottom_right, uv0, uv1);
}
}
if (label) {
GetWindowDrawList()->AddText(ImVec2(text_x, text_y), ImColor(GetStyle().Colors[ImGuiCol_Text]), label);
}
return clicked;
}
bool IconButton(const char* label, const ImTextureID icon, const ImVec2& size, const ImGuiButtonFlags flags, const ImVec2& icon_size)
{
return CompositeIconButton(label, &icon, 1, size, flags, icon_size);
}

bool ColorButtonPicker(const char* label, Color* imcol, const ImGuiColorEditFlags flags)
{
Expand Down Expand Up @@ -300,6 +307,36 @@ namespace ImGui {
}
return uv1;
}
// Given a texture, sprite size in px and the offset of the sprite we want, fill out uv0 and uv1 coords for percentage offsets. False on failure.
bool GetSpriteUvCoords(const ImTextureID user_texture_id, const ImVec2& single_sprite_size, uint32_t sprite_offset[2], ImVec2* uv0_out, ImVec2* uv1_out) {
if (!user_texture_id)
return false;
const auto texture = static_cast<IDirect3DTexture9*>(user_texture_id);
D3DSURFACE_DESC desc;
const HRESULT res = texture->GetLevelDesc(0, &desc);
if (!SUCCEEDED(res)) {
return false; // Don't throw anything into the log here; this function is called every frame by modules that use it!
}

ImVec2 img_dimensions = { static_cast<float>(desc.Width), static_cast<float>(desc.Height) };

ImVec2 start_px_offset = { single_sprite_size.x * sprite_offset[0], single_sprite_size.y * sprite_offset[1] };
if (start_px_offset.x >= img_dimensions.x
|| start_px_offset.y >= img_dimensions.y) {
return false;
}
ImVec2 end_px_offset = { start_px_offset.x + single_sprite_size.x, start_px_offset.y + single_sprite_size.y };
if (end_px_offset.x >= img_dimensions.x
|| end_px_offset.y >= img_dimensions.y) {
return false;
}
uv0_out->x = start_px_offset.x / img_dimensions.x;
uv0_out->y = end_px_offset.y / img_dimensions.y;

uv1_out->x = end_px_offset.x / img_dimensions.x;
uv1_out->x = end_px_offset.y / img_dimensions.y;
return true;
}

void ImageCropped(const ImTextureID user_texture_id, const ImVec2& size)
{
Expand Down
4 changes: 4 additions & 0 deletions GWToolboxdll/ImGuiAddons.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ namespace ImGui {

IMGUI_API bool ConfirmButton(const char* label, bool* confirm_bool, const char* confirm_content = "Are you sure you want to continue?");

// Button with single icon texture
IMGUI_API bool IconButton(const char* label, ImTextureID icon, const ImVec2& size, ImGuiButtonFlags flags = ImGuiButtonFlags_None, const ImVec2& icon_size = {0.f, 0.f});

// Button with 1 or more icon textures overlaid
IMGUI_API bool CompositeIconButton(const char* label, const ImTextureID* icons, size_t icons_len, const ImVec2& size, ImGuiButtonFlags flags = ImGuiButtonFlags_None, const ImVec2& icon_size = {0.f, 0.f}, const ImVec2& uv0 = {0.f, 0.f}, ImVec2 uv1 = {0.f, 0.f});

IMGUI_API bool ColorButtonPicker(const char*, Color*, ImGuiColorEditFlags = 0);
// Add cropped image to current window
IMGUI_API void ImageCropped(ImTextureID user_texture_id, const ImVec2& size);
Expand Down
4 changes: 1 addition & 3 deletions GWToolboxdll/Modules/ChatCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1462,9 +1462,7 @@ void ChatCommands::CmdChest(const wchar_t*, int, LPWSTR*)
if (!IsMapReady()) {
return;
}
if (GW::Map::GetInstanceType() == GW::Constants::InstanceType::Outpost) {
GW::Items::OpenXunlaiWindow();
}
GW::Items::OpenXunlaiWindow();
}

void ChatCommands::CmdTB(const wchar_t* message, const int argc, LPWSTR* argv)
Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/Modules/DiscordModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void DiscordModule::Initialize()
dll_location = Resources::GetPath(L"discord_game_sdk.dll");
// NOTE: We're using the one we know matches our API version, not checking for any other discord dll on the machine.
Resources::EnsureFileExists(dll_location,
"https://raw.githubusercontent.com/HasKha/GWToolboxpp/master/resources/discord_game_sdk.dll",
"https://raw.githubusercontent.com/gwdevhub/GWToolboxpp/master/resources/discord_game_sdk.dll",
[&](const bool success, const std::wstring& error) {
if (!success || !LoadDll()) {
Log::LogW(L"Failed to load discord_game_sdk.dll. To try again, please restart GWToolbox\n%s", error.c_str());
Expand Down
31 changes: 4 additions & 27 deletions GWToolboxdll/Modules/GameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ namespace {
bool drop_ua_on_cast = false;

bool focus_window_on_launch = true;
bool flash_window_on_party_invite = false;
bool flash_window_on_zoning = false;
bool focus_window_on_zoning = false;
bool flash_window_on_cinematic = true;
Expand Down Expand Up @@ -526,7 +525,7 @@ namespace {

GW::MemoryPatcher skip_map_entry_message_patch;

// Refresh agent name tags when allegiance changes ( https://github.com/HasKha/GWToolboxpp/issues/781 )
// Refresh agent name tags when allegiance changes ( https://github.com/gwdevhub/GWToolboxpp/issues/781 )
void OnAgentAllegianceChanged(GW::HookStatus*, GW::Packet::StoC::AgentUpdateAllegiance*)
{
// Backup the current name tag flag state, then "flash" nametags to update.
Expand Down Expand Up @@ -975,9 +974,6 @@ namespace {
ImGui::Indent();
ImGui::StartSpacedElements(checkbox_w);
ImGui::NextSpacedElement();
ImGui::NextSpacedElement();
ImGui::Checkbox("Receiving a party invite", &flash_window_on_party_invite);
ImGui::NextSpacedElement();
ImGui::Checkbox("Zoning in a new map", &flash_window_on_zoning);
ImGui::NextSpacedElement();
ImGui::Checkbox("Cinematic start/end", &flash_window_on_cinematic);
Expand All @@ -1001,7 +997,7 @@ namespace {
ImGui::Checkbox("A player starts trade with you###focus_window_on_trade", &focus_window_on_trade);
ImGui::Unindent();

ImGui::Text("Show a message when a friend:");
ImGui::Text("Show a chat message when a friend:");
ImGui::Indent();
ImGui::StartSpacedElements(checkbox_w);
ImGui::NextSpacedElement();
Expand All @@ -1014,7 +1010,7 @@ namespace {
ImGui::Checkbox("Leaves your outpost###notify_when_friends_leave_outpost", &notify_when_friends_leave_outpost);
ImGui::Unindent();

ImGui::Text("Show a message when a player:");
ImGui::Text("Show a chat message when a player:");
ImGui::Indent();
ImGui::StartSpacedElements(checkbox_w);
ImGui::NextSpacedElement();
Expand Down Expand Up @@ -1549,7 +1545,6 @@ void GameSettings::LoadSettings(ToolboxIni* ini)
LOAD_BOOL(move_item_to_current_storage_pane);
LOAD_BOOL(move_materials_to_current_storage_pane);

LOAD_BOOL(flash_window_on_party_invite);
LOAD_BOOL(flash_window_on_zoning);
LOAD_BOOL(flash_window_on_cinematic);
LOAD_BOOL(focus_window_on_launch);
Expand Down Expand Up @@ -1710,7 +1705,6 @@ void GameSettings::SaveSettings(ToolboxIni* ini)
SAVE_BOOL(move_materials_to_current_storage_pane);
SAVE_BOOL(stop_screen_shake);

SAVE_BOOL(flash_window_on_party_invite);
SAVE_BOOL(flash_window_on_zoning);
SAVE_BOOL(focus_window_on_launch);
SAVE_BOOL(focus_window_on_zoning);
Expand Down Expand Up @@ -2240,32 +2234,15 @@ void GameSettings::OnPartyInviteReceived(const GW::HookStatus* status, const GW:
GW::PartyMgr::RespondToPartyRequest(packet->target_party_id, true);
}
}
if (flash_window_on_party_invite) {
FlashWindow();
}
}

// Flash window on player added
void GameSettings::OnPartyPlayerJoined(const GW::HookStatus*, const GW::Packet::StoC::PartyPlayerAdd* packet)
void GameSettings::OnPartyPlayerJoined(const GW::HookStatus*, const GW::Packet::StoC::PartyPlayerAdd*)
{
if (GW::Map::GetInstanceType() != GW::Constants::InstanceType::Outpost) {
return;
}
check_message_on_party_change = true;
if (flash_window_on_party_invite) {
const GW::PartyInfo* current_party = GW::PartyMgr::GetPartyInfo();
if (!current_party) {
return;
}
const GW::AgentLiving* me = GW::Agents::GetPlayerAsAgentLiving();
if (!me) {
return;
}
if (packet->player_id == me->login_number
|| (packet->party_id == current_party->party_id && GW::PartyMgr::GetIsLeader())) {
FlashWindow();
}
}
}

// Block overhead arrow marker for zaishen scout
Expand Down
Loading

0 comments on commit fac9cda

Please sign in to comment.