Add fonticon autocomplete for chat

This commit is contained in:
Jan 2021-09-08 01:53:25 +02:00
parent 59e1099c06
commit 7b70a1c62c
6 changed files with 42 additions and 6 deletions

View File

@ -71,10 +71,10 @@ namespace Components
}
}
void ServerInfo::DrawScoreboardInfo(void* a1)
void ServerInfo::DrawScoreboardInfo(int localClientNum)
{
Game::Font_s* font = Game::R_RegisterFont("fonts/bigfont", 0);
void* cxt = Game::UI_GetContext(a1);
void* cxt = Game::ScrPlace_GetActivePlacement(localClientNum);
std::string addressText = Network::Address(*Game::connectedHost).getString();
if (addressText == "0.0.0.0:0" || addressText == "loopback") addressText = "Listen Server";

View File

@ -36,7 +36,7 @@ namespace Components
static const char* GetPlayerText(unsigned int index, int column);
static void SelectPlayer(unsigned int index);
static void DrawScoreboardInfo(void* a1);
static void DrawScoreboardInfo(int localClientNum);
static void DrawScoreboardStub();
};
}

View File

@ -245,6 +245,20 @@ namespace Components
void TextRenderer::Field_Draw_Say(const int localClientNum, Game::field_t* edit, const int x, const int y, const int horzAlign, const int vertAlign)
{
Game::Field_Draw(localClientNum, edit, x, y, horzAlign, vertAlign);
auto& autocompleteContext = autocompleteContextArray[FONT_ICON_ACI_CHAT];
UpdateAutocompleteContext(autocompleteContext, edit, Game::cls->consoleFont);
if (autocompleteContext.autocompleteActive)
{
auto* screenPlacement = Game::ScrPlace_GetActivePlacement(localClientNum);
auto xx = static_cast<float>(x);
auto yy = static_cast<float>(y);
auto ww = 0.0f;
auto hh = 0.0f;
Game::ScrPlace_ApplyRect(screenPlacement, &xx, &yy, &ww, &hh, horzAlign, vertAlign);
yy += static_cast<float>(2 * Game::R_TextHeight(Game::cls->consoleFont));
DrawAutocomplete(autocompleteContext, std::floor(xx), std::floor(yy), Game::cls->consoleFont);
}
}
float TextRenderer::GetMonospaceWidth(Game::Font_s* font, int rendererFlags)

View File

@ -323,9 +323,10 @@ namespace Game
UI_UpdateArenas_t UI_UpdateArenas = UI_UpdateArenas_t(0x4A95B0);
UI_SortArenas_t UI_SortArenas = UI_SortArenas_t(0x630AE0);
UI_DrawHandlePic_t UI_DrawHandlePic = UI_DrawHandlePic_t(0x4D0EA0);
UI_GetContext_t UI_GetContext = UI_GetContext_t(0x4F8940);
ScrPlace_GetActivePlacement_t ScrPlace_GetActivePlacement = ScrPlace_GetActivePlacement_t(0x4F8940);
UI_TextWidth_t UI_TextWidth = UI_TextWidth_t(0x6315C0);
UI_DrawText_t UI_DrawText = UI_DrawText_t(0x49C0D0);
ScrPlace_ApplyRect_t ScrPlace_ApplyRect = ScrPlace_ApplyRect_t(0x454E20);
Win_GetLanguage_t Win_GetLanguage = Win_GetLanguage_t(0x45CBA0);

View File

@ -759,8 +759,8 @@ namespace Game
typedef void(__cdecl * UI_DrawHandlePic_t)(/*ScreenPlacement*/void *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Material *material);
extern UI_DrawHandlePic_t UI_DrawHandlePic;
typedef void* (__cdecl * UI_GetContext_t)(void*);
extern UI_GetContext_t UI_GetContext;
typedef ScreenPlacement* (__cdecl * ScrPlace_GetActivePlacement_t)(int localClientNum);
extern ScrPlace_GetActivePlacement_t ScrPlace_GetActivePlacement;
typedef int(__cdecl * UI_TextWidth_t)(const char *text, int maxChars, Font_s *font, float scale);
extern UI_TextWidth_t UI_TextWidth;
@ -768,6 +768,9 @@ namespace Game
typedef void(__cdecl * UI_DrawText_t)(void* scrPlace, const char *text, int maxChars, Font_s *font, float x, float y, int horzAlign, int vertAlign, float scale, const float *color, int style);
extern UI_DrawText_t UI_DrawText;
typedef void(__cdecl* ScrPlace_ApplyRect_t)(ScreenPlacement* a1, float* x, float* y, float* w, float* h, int horzAlign, int vertAlign);
extern ScrPlace_ApplyRect_t ScrPlace_ApplyRect;
typedef const char * (__cdecl * Win_GetLanguage_t)();
extern Win_GetLanguage_t Win_GetLanguage;

View File

@ -5413,6 +5413,24 @@ namespace Game
float fontHeight;
};
struct ScreenPlacement
{
float scaleVirtualToReal[2];
float scaleVirtualToFull[2];
float scaleRealToVirtual[2];
float realViewportPosition[2];
float realViewportSize[2];
float virtualViewableMin[2];
float virtualViewableMax[2];
float realViewableMin[2];
float realViewableMax[2];
float virtualAdjustableMin[2];
float virtualAdjustableMax[2];
float realAdjustableMin[2];
float realAdjustableMax[2];
float subScreenLeft;
};
#pragma endregion
#ifndef IDA