Advertisement
xesharkz

Untitled

Jun 3rd, 2020
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. //dumping font name
  2.  
  3. auto& objs = UObject::GetGlobalObjects();
  4.     for (int i = 0; i < UObject::GetGlobalObjects().Num(); i++) {
  5.         if (auto item = objs.GetByIndex(i).Object) {
  6.             if (item->IsA(UFont::StaticClass()))
  7.                 Log("Font %s", item->GetName().c_str());
  8.         }
  9.     }
  10.  
  11. ..EngineFont
  12.  
  13. class Engine_Font
  14. {
  15. public:
  16.     std::string fontName;
  17.     UFont * pFont;
  18. };
  19. std::vector<Engine_Font> Cached_Fonts;
  20. UFont* DRAWING::find_font(const std::string& name)
  21. {
  22.     /* logged fonts:
  23.     23:10:44 Font Default__Font
  24.     23:10:44 Font RobotoDistanceField
  25.     23:10:44 Font Roboto
  26.     23:10:44 Font 39335_UniversCondensed
  27.     23:10:44 Font Roboto18
  28.     23:10:44 Font digital_display_tfb
  29.     23:10:44 Font hemi_head_bd_it
  30.     23:10:44 Font AgencyFB-Bold
  31.     23:10:44 Font RobotoTiny
  32.     */
  33.     for (auto i = 0; i < Cached_Fonts.size(); i++)
  34.     {
  35.         if (Cached_Fonts.at(i).fontName == name)
  36.         {
  37.             return Cached_Fonts.at(i).pFont;
  38.         }
  39.  
  40.     }
  41.     auto& objs = UObject::GetGlobalObjects();
  42.     for (int i = 0; i < objs.Num(); i++) {
  43.         if (auto item = UObject::GetGlobalObjects().GetByIndex(i).Object) {
  44.             if (item->IsA(UFont::StaticClass()) && item->GetName() == name)
  45.             {
  46.                 Engine_Font temp;
  47.                 temp.fontName = name;
  48.                 temp.pFont = reinterpret_cast<UFont*>(item);
  49.                 Cached_Fonts.push_back(temp);
  50.  
  51.                 return reinterpret_cast<UFont*>(item);
  52.             }
  53.         }
  54.     }
  55.     return nullptr;
  56. }
  57.  
  58. void DRAWING::DrawStringFont(UFont* pFont, int x, int y, float scale, FLinearColor color, FString String)
  59. {
  60.     if (!Memory::IsValidPointer(g_pGlobalCanvas))
  61.         return;
  62.  
  63.     g_pGlobalCanvas->K2_DrawText(pFont, String, FVector2D(x, y), color, 1, color, FVector2D(x, y), true, false, true, colBlack);
  64. }
  65. ..drawing.h
  66. UFont* find_font(const std::string& name);
  67. void DrawStringFont(UFont* pFont, int x, int y, float scale, FLinearColor color, FString String);
  68. .
  69.  
  70. ex:
  71. DRAWING::DrawStringFont(DRAWING::find_font("MapFont"), 500, 50, 1.f, colWhite, FString(L"AddictedCheats"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement