Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #18

Merged
merged 7 commits into from
May 6, 2022
Merged

Dev #18

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated FontAwesome from v5 to v6
  • Loading branch information
sammyfreg committed May 5, 2022
commit bd6f7b498d47389cd72042de39b556512a6e5f6c
12 changes: 6 additions & 6 deletions Source/NetImgui.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ public NetImgui(TargetInfo Target)
bool bDemoActor_Enabled = true;

// Will load Japanese font
// Note: If not using Japanese, set this to false, to save on memory (avoids 6MB font data table source include)
// Note: If not using Japanese, set this to false, saves on memory (avoids 6MB font data table source include)
bool bFontJapanese_Enabled = true;

// Will load the 'Kenney Game Icons' font
// For list available icons, see: https://kenney.nl/assets/game-icons and https://kenney.nl/assets/game-icons-expansion
bool bFontIconGameKenney_Enabled = true;

// Will load the 'FontAwesome 5' font ('free' subset)
// Will load the 'FontAwesome 6' font ('free' subset)
// Contains various icons for every use, using only the
// For list of available icons, see: https://fontawesome.com/v5/search?m=free (Regular/Solid)
// For list of available icons, see: https://fontawesome.com/v6/search?m=free (Regular/Solid/Brands)
bool bFontIconAwesome_Enabled = true;

// Will load 'Google Material Designs icons' font
Expand All @@ -113,7 +113,7 @@ public NetImgui(TargetInfo Target)
// Com Port used by this client, to try connecting to the remote NetImgui Server (8888 by default)
// Used when engine is launched with command line parameter 'netimguiserver' to request a connection
// attempt, instead of waiting for server to reach the game
string kRemoteConnectPort = "(NetImgui::kDefaultServerPort)";
string kRemoteConnectPort = "(NetImgui::kDefaultServerPort)";

// Com Port used by Game exe to wait for a connection from netImgui Server (8889 by default)
// NetImgui Server will try to find running game client on this port and connect to them
Expand All @@ -122,11 +122,11 @@ public NetImgui(TargetInfo Target)
// you will need to add their IP in the Server Client list.
// Alternatively, you can modify the connection code in 'FNetImguiModule::StartupModule()'
// to let the client connect directly to NetImGui server using 'NetImgui::ConnectToApp(ServerIP)'
string kGameListenPort = "(NetImgui::kDefaultClientPort)";
string kGameListenPort = "(NetImgui::kDefaultClientPort)";

// Com Port used by Editor exe to wait for a connection from netImgui Server (8890 by default)
// NetImgui Server will try to find running editor client on this port and connect to them
string kEditorListenPort = "(NetImgui::kDefaultClientPort+1)";
string kEditorListenPort = "(NetImgui::kDefaultClientPort+1)";

// Com Port used by Dedicated Server exe to wait for a connection from netImgui Server (8891 by default)
// NetImgui Server will try to find running dedicaed server client on this port and connect to them
Expand Down
456 changes: 0 additions & 456 deletions Source/Private/Fonts/FontAwesome5/FontAwesome_Regular.cpp

This file was deleted.

2,945 changes: 0 additions & 2,945 deletions Source/Private/Fonts/FontAwesome5/FontAwesome_Solid.cpp

This file was deleted.

3,158 changes: 3,158 additions & 0 deletions Source/Private/Fonts/FontAwesome6/fa-brands-400.cpp

Large diffs are not rendered by default.

741 changes: 741 additions & 0 deletions Source/Private/Fonts/FontAwesome6/fa-regular-400.cpp

Large diffs are not rendered by default.

4,973 changes: 4,973 additions & 0 deletions Source/Private/Fonts/FontAwesome6/fa-solid-900.cpp

Large diffs are not rendered by default.

1,012 changes: 0 additions & 1,012 deletions Source/Private/Fonts/IconFontCppHeader/IconsFontAwesome5.h

This file was deleted.

1,395 changes: 1,395 additions & 0 deletions Source/Private/Fonts/IconFontCppHeader/IconsFontAwesome6.h

Large diffs are not rendered by default.

471 changes: 471 additions & 0 deletions Source/Private/Fonts/IconFontCppHeader/IconsFontAwesome6Brands.h

Large diffs are not rendered by default.

53 changes: 30 additions & 23 deletions Source/Private/NetImguiModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
#include "Fonts/FontKenney/KenneyIcon.cpp"
#endif

#if NETIMGUI_FONT_ICON_AWESOME
#include "Fonts/FontAwesome5/FontAwesome_Regular.cpp"
#include "Fonts/FontAwesome5/FontAwesome_Solid.cpp"
#if NETIMGUI_FONT_ICON_AWESOME
#include "Fonts/FontAwesome6/fa-solid-900.cpp"
#include "Fonts/FontAwesome6/fa-regular-400.cpp"
#include "Fonts/FontAwesome6/fa-brands-400.cpp"
#endif

#if NETIMGUI_FONT_ICON_MATERIALDESIGN
Expand Down Expand Up @@ -140,7 +141,7 @@ void AddFontGroup(FString name, float pxSize, const uint32_t* pFontData, uint32_
ImFontAtlas* pFontAtlas = ImGui::GetIO().Fonts;
name += FString::Printf(TEXT(" (%ipx)"), static_cast<int>(pxSize));
FPlatformString::Strcpy(Config.Name, sizeof(Config.Name), TCHAR_TO_UTF8(name.GetCharArray().GetData()));
pFontAtlas->AddFontFromMemoryCompressedTTF(pFontData, FontDataSize, pxSize, &Config, pGlyphRange);
pFontAtlas->AddFontFromMemoryCompressedTTF(pFontData, FontDataSize, pxSize, &Config, pGlyphRange);

Config.MergeMode = true;
#if NETIMGUI_FONT_JAPANESE
Expand All @@ -160,8 +161,10 @@ void AddFontGroup(FString name, float pxSize, const uint32_t* pFontData, uint32_
#endif
#if NETIMGUI_FONT_ICON_AWESOME
static const ImWchar iconFontAwesome_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
pFontAtlas->AddFontFromMemoryCompressedTTF(FontAwesome_Regular_compressed_data, FontAwesome_Regular_compressed_size, pxSize, &Config, iconFontAwesome_ranges);
pFontAtlas->AddFontFromMemoryCompressedTTF(FontAwesome_Solid_compressed_data, FontAwesome_Solid_compressed_size, pxSize, &Config, iconFontAwesome_ranges);
static const ImWchar iconFontAwesomeBrands_ranges[] = { ICON_MIN_FAB, ICON_MAX_FAB, 0 };
pFontAtlas->AddFontFromMemoryCompressedTTF(fa_solid_900_compressed_data, fa_solid_900_compressed_size, pxSize, &Config, iconFontAwesome_ranges);
pFontAtlas->AddFontFromMemoryCompressedTTF(fa_regular_400_compressed_data, fa_regular_400_compressed_size, pxSize, &Config, iconFontAwesome_ranges);
pFontAtlas->AddFontFromMemoryCompressedTTF(fa_brands_400_compressed_data, fa_brands_400_compressed_size, pxSize, &Config, iconFontAwesomeBrands_ranges);
#endif
#if NETIMGUI_FONT_ICON_MATERIALDESIGN
static const ImWchar iconMaterialDesign_ranges[] = { ICON_MIN_MD, ICON_MAX_MD, 0 };
Expand Down Expand Up @@ -260,13 +263,34 @@ void FNetImguiModule::Update()
ImGui::NewLine();
ImGui::TextColored(kColorHighlight, "Usage example");
ImGui::TextWrapped( "Samples for using Dear ImGui with the NetImgui plugin, can be found in 'UnrealNetImgui/Source/Sample/NetImguiDemoActor.cpp'. "
#if NETIMGUI_DEMO_ACTOR_ENABLED
"The Actor can be dropped in your scene to show a demo window (NetImgui->Demo: DemoActor' to view it). "
"To add the actor : [Quickly add to the project] button(top of viewport, cube with '+' icon) then type 'Net Imgui Demo Actor' to find it. "
#else
"This Demo actor isn't enable in the build. To active it, set 'bDemoActor_Enabled' to true in 'NetImgui.Build.cs'"
#endif
"Demo Actor source code is also is also a good demonstration of how to integrate the plugin to your project");
}
ImGui::End();
}

//----------------------------------------------------------------------------
// Display a 'Unreal Console Command' menu entry in MainMenu bar, and the
// 'Unreal Console command' window itself when requested
//----------------------------------------------------------------------------
#if IMGUI_UNREAL_COMMAND_ENABLED
if (ImGui::BeginMainMenuBar()) {
if( ImGui::BeginMenu("NetImgui") ){
ImGui::MenuItem("Unreal-Commands", nullptr, &ImUnrealCommand::IsVisible(spImUnrealCommandContext) );
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}

// Always try displaying the 'Unreal Command Imgui' Window (handle Window visibility internally)
ImUnrealCommand::Show(spImUnrealCommandContext);
#endif

//----------------------------------------------------------------------------
// Display a 'Dear Imgui Demo' menu entry in MainMenu bar, and the
// demo window itself when requested
Expand All @@ -287,23 +311,6 @@ void FNetImguiModule::Update()
}
#endif

//----------------------------------------------------------------------------
// Display a 'Unreal Console Command' menu entry in MainMenu bar, and the
// 'Unreal Console command' window itself when requested
//----------------------------------------------------------------------------
#if IMGUI_UNREAL_COMMAND_ENABLED
if (ImGui::BeginMainMenuBar()) {
if( ImGui::BeginMenu("NetImgui") ){
ImGui::MenuItem("Unreal-Commands", nullptr, &ImUnrealCommand::IsVisible(spImUnrealCommandContext) );
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}

// Always try displaying the 'Unreal Command Imgui' Window (handle Window visibility internally)
ImUnrealCommand::Show(spImUnrealCommandContext);
#endif

//----------------------------------------------------------------------------
// Ask all listener to draw their Dear ImGui content
//----------------------------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions Source/Public/NetImguiModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
#endif

// List of defines to easily use Icons available in 'Font Awesome Icons' (only the 'free' subset is made available)
// For list of available icons, see: https://fontawesome.com/v5/search?m=free (Regular/Solid)
// For list of available icons, see: https://fontawesome.com/v6/search?m=free (Regular/Solid/Brands)
#if NETIMGUI_FONT_ICON_AWESOME
#include "../Private/Fonts/IconFontCppHeader/IconsFontAwesome5.h"
#include "../Private/Fonts/IconFontCppHeader/IconsFontAwesome6.h"
#include "../Private/Fonts/IconFontCppHeader/IconsFontAwesome6Brands.h"
#endif

// List of defines to easily use Icons available in 'Google's Material Design Icons'
Expand Down
9 changes: 5 additions & 4 deletions Source/Sample/NetImguiDemoActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ static bool sbShowDemoNetImgui = false;
static const ImVec4 kColorHighlight = ImVec4(0.1f, 0.85f, 0.1f, 1.0f);

#if NETIMGUI_FONT_ICON_AWESOME
#define CLIENTSTRING_NAME ICON_FA_INFO_CIRCLE " Name"
#define CLIENTSTRING_NAME ICON_FA_CIRCLE_INFO " Name"
#define CLIENTSTRING_SHOW ICON_FA_EYE
#define CLIENTSTRING_POS ICON_FA_MAP_MARKER_ALT " Position"
#define CLIENTSTRING_POS ICON_FA_LOCATION_DOT " Position"

#elif NETIMGUI_FONT_ICON_MATERIALDESIGN
#define CLIENTSTRING_NAME ICON_MD_INFO " Name"
Expand Down Expand Up @@ -149,15 +149,16 @@ void MethodA_DrawImgui_FrameCallback()

#if NETIMGUI_FONT_ICON_AWESOME
//--- Showcase using a FString to mix icon and text together ---
FString titleAwesome = FString::Format(TEXT("{0} Font Awesome Icons"), {UTF8_TO_TCHAR(ICON_FA_INFO_CIRCLE)});
FString titleAwesome = FString::Format(TEXT("{0} Font Awesome Icons"), {UTF8_TO_TCHAR(ICON_FA_CIRCLE_INFO)});
ImGui::TextColored(kColorHighlight, TCHAR_TO_UTF8(*titleAwesome));

//--- Showcase using a utf8 string with icons inserted in it as a regular printf string constant ---
ImGui::Text(u8"I %s icons in my text.", ICON_FA_HEART);
{
NetImguiScopedFont iconFont(FNetImguiModule::eFont::kIcons64);
const char* zAnimation[]={ICON_FA_BATTERY_EMPTY, ICON_FA_BATTERY_QUARTER, ICON_FA_BATTERY_HALF, ICON_FA_BATTERY_THREE_QUARTERS, ICON_FA_BATTERY_FULL };
ImGui::Text(ICON_FA_SMILE " " ICON_FA_EXPAND_ARROWS_ALT " " ICON_FA_COGS " " ICON_FA_ARROW_ALT_CIRCLE_LEFT " " ICON_FA_ARROW_ALT_CIRCLE_RIGHT " %s", zAnimation[iconAnimFrame%UE_ARRAY_COUNT(zAnimation)]);
ImGui::Text(ICON_FA_FACE_SMILE " " ICON_FA_MINIMIZE " " ICON_FA_GEAR " " ICON_FA_ARROW_ROTATE_LEFT " " ICON_FA_ARROW_ROTATE_RIGHT " %s", zAnimation[iconAnimFrame%UE_ARRAY_COUNT(zAnimation)]); // Font awesome standard icons
ImGui::Text(ICON_FA_CANADIAN_MAPLE_LEAF " " ICON_FA_JIRA " " ICON_FA_ATLASSIAN " " ICON_FA_ANDROID); // Font Awesome free icons examples
}
#endif

Expand Down