mirror of
https://github.com/rei-2/Amalgam
synced 2026-10-10 04:43:09 +08:00
menu updates
update imgui to 1.92.7 update texteditor to fa6fd43 of goossens/ImGuiColorTextEdit rework virtualkey2str
This commit is contained in:
@@ -895,7 +895,6 @@
|
||||
<ClCompile Include="include\ImGui\imgui_stdlib.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_tables.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_widgets.cpp" />
|
||||
<ClCompile Include="include\ImGui\LanguageDefinitions.cpp" />
|
||||
<ClCompile Include="include\ImGui\TextEditor.cpp" />
|
||||
<ClCompile Include="include\MinHook\buffer.c" />
|
||||
<ClCompile Include="include\MinHook\hde\hde32.c" />
|
||||
@@ -962,7 +961,7 @@
|
||||
<ClCompile Include="src\Hooks\CBaseAnimating_SetSequence.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseAnimating_SetupBones.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseAnimating_UpdateClientSideAnimation.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseEntity_BaseInterpolatePart1.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseViewModel_Interpolate.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseEntity_EstimateAbsVelocity.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBasePlayer_CalcObserverView.cpp" />
|
||||
<ClCompile Include="src\Hooks\CHLTVCamera_CalcView.cpp" />
|
||||
@@ -977,7 +976,7 @@
|
||||
<ClCompile Include="src\Hooks\CBaseEntity_WorldSpaceCenter.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseHudChatLine_InsertAndColorizeText.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBasePlayer_CalcView.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBasePlayer_CalcViewModelView.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseViewModel_CalcViewModelView.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBasePlayer_ItemPostFrame.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseViewModel_ShouldFlipViewModel.cpp" />
|
||||
<ClCompile Include="src\Hooks\Cbuf_ExecuteCommand.cpp" />
|
||||
@@ -1014,7 +1013,6 @@
|
||||
<ClCompile Include="src\Hooks\CStudioRender_DrawModelStaticProp.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFBadgePanel_SetupBadge.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFClientScoreBoardDialog_UpdatePlayerAvatar.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFGCClientSystem_UpdateAssignedLobby.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFInput_ApplyMouse.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFPlayerInventory_GetMaxItemCount.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFPlayerPanel_GetTeam.cpp" />
|
||||
|
||||
@@ -25,14 +25,6 @@
|
||||
<ClCompile Include="src\Utils\Signatures\Signatures.cpp" />
|
||||
<ClCompile Include="src\Utils\Timer\Timer.cpp" />
|
||||
<ClCompile Include="src\DllMain.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_draw.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_impl_dx9.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_impl_win32.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_stdlib.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_tables.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_widgets.cpp" />
|
||||
<ClCompile Include="include\ImGui\TextEditor.cpp" />
|
||||
<ClCompile Include="include\MinHook\hde\hde32.c" />
|
||||
<ClCompile Include="include\MinHook\hde\hde64.c" />
|
||||
<ClCompile Include="include\MinHook\buffer.c" />
|
||||
@@ -84,10 +76,8 @@
|
||||
<ClCompile Include="src\SDK\Events\Events.cpp" />
|
||||
<ClCompile Include="src\Utils\ExceptionHandler\ExceptionHandler.cpp" />
|
||||
<ClCompile Include="src\BytePatches\BytePatches.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_freetype.cpp" />
|
||||
<ClCompile Include="src\Features\Misc\AutoVote\AutoVote.cpp" />
|
||||
<ClCompile Include="src\Features\Spectate\Spectate.cpp" />
|
||||
<ClCompile Include="include\ImGui\LanguageDefinitions.cpp" />
|
||||
<ClCompile Include="src\Hooks\CHLClient_FrameStageNotify.cpp" />
|
||||
<ClCompile Include="src\Hooks\bf_read_ReadString.cpp" />
|
||||
<ClCompile Include="src\Hooks\CAchievementMgr_CheckAchievementsEnabled.cpp" />
|
||||
@@ -97,7 +87,7 @@
|
||||
<ClCompile Include="src\Hooks\CBaseAnimating_SetSequence.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseAnimating_SetupBones.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseAnimating_UpdateClientSideAnimation.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseEntity_BaseInterpolatePart1.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseViewModel_Interpolate.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseEntity_EstimateAbsVelocity.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFPlayer_FireBullet.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseEntity_ResetLatched.cpp" />
|
||||
@@ -105,7 +95,7 @@
|
||||
<ClCompile Include="src\Hooks\CBaseEntity_WorldSpaceCenter.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseHudChatLine_InsertAndColorizeText.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBasePlayer_CalcView.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBasePlayer_CalcViewModelView.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseViewModel_CalcViewModelView.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBasePlayer_ItemPostFrame.cpp" />
|
||||
<ClCompile Include="src\Hooks\CBaseViewModel_ShouldFlipViewModel.cpp" />
|
||||
<ClCompile Include="src\Hooks\CHLClient_CreateMove.cpp" />
|
||||
@@ -138,7 +128,6 @@
|
||||
<ClCompile Include="src\Hooks\CStudioRender_DrawModelStaticProp.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFBadgePanel_SetupBadge.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFClientScoreBoardDialog_UpdatePlayerAvatar.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFGCClientSystem_UpdateAssignedLobby.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFInput_ApplyMouse.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFPlayer_AvoidPlayers.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFPlayer_BRenderAsZombie.cpp" />
|
||||
@@ -206,6 +195,15 @@
|
||||
<ClCompile Include="src\Features\World\World.cpp" />
|
||||
<ClCompile Include="src\Hooks\CModelLoader_Map_LoadModel.cpp" />
|
||||
<ClCompile Include="src\Hooks\CM_TraceToDispTree.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_draw.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_freetype.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_impl_dx9.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_impl_win32.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_stdlib.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_tables.cpp" />
|
||||
<ClCompile Include="include\ImGui\imgui_widgets.cpp" />
|
||||
<ClCompile Include="include\ImGui\TextEditor.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\Utils\UtlVector\UtlVector.h" />
|
||||
@@ -334,15 +332,6 @@
|
||||
<ClInclude Include="src\Utils\NetVars\NetVars.h" />
|
||||
<ClInclude Include="src\Utils\Signatures\Signatures.h" />
|
||||
<ClInclude Include="src\Utils\Timer\Timer.h" />
|
||||
<ClInclude Include="include\ImGui\imconfig.h" />
|
||||
<ClInclude Include="include\ImGui\imgui.h" />
|
||||
<ClInclude Include="include\ImGui\imgui_impl_dx9.h" />
|
||||
<ClInclude Include="include\ImGui\imgui_impl_win32.h" />
|
||||
<ClInclude Include="include\ImGui\imgui_internal.h" />
|
||||
<ClInclude Include="include\ImGui\imgui_stdlib.h" />
|
||||
<ClInclude Include="include\ImGui\imstb_rectpack.h" />
|
||||
<ClInclude Include="include\ImGui\imstb_textedit.h" />
|
||||
<ClInclude Include="include\ImGui\TextEditor.h" />
|
||||
<ClInclude Include="include\MinHook\hde\hde32.h" />
|
||||
<ClInclude Include="include\MinHook\hde\hde64.h" />
|
||||
<ClInclude Include="include\MinHook\hde\pstdint.h" />
|
||||
@@ -564,13 +553,11 @@
|
||||
<ClInclude Include="include\freetype\ttnameid.h" />
|
||||
<ClInclude Include="include\freetype\tttables.h" />
|
||||
<ClInclude Include="include\freetype\tttags.h" />
|
||||
<ClInclude Include="include\ImGui\imgui_freetype.h" />
|
||||
<ClInclude Include="src\Features\ImGui\Fonts\CascadiaMono\CascadiaMono.h" />
|
||||
<ClInclude Include="src\Features\ImGui\Fonts\MaterialDesign\IconDefinitions.h" />
|
||||
<ClInclude Include="src\Features\ImGui\Fonts\MaterialDesign\MaterialIcons.h" />
|
||||
<ClInclude Include="src\Features\ImGui\Fonts\Roboto\RobotoMedium.h" />
|
||||
<ClInclude Include="src\Features\ImGui\Fonts\Roboto\RobotoBlack.h" />
|
||||
<ClInclude Include="include\ImGui\imstb_truetype.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Main\CEconEntity.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Main\CEconWearable.h" />
|
||||
<ClInclude Include="src\Features\Misc\AutoVote\AutoVote.h" />
|
||||
@@ -611,6 +598,17 @@
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\CDispCollTree.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Misc\TraceInfo.h" />
|
||||
<ClInclude Include="src\Utils\Math\BaseMath.h" />
|
||||
<ClInclude Include="include\ImGui\imconfig.h" />
|
||||
<ClInclude Include="include\ImGui\imgui.h" />
|
||||
<ClInclude Include="include\ImGui\imgui_freetype.h" />
|
||||
<ClInclude Include="include\ImGui\imgui_impl_dx9.h" />
|
||||
<ClInclude Include="include\ImGui\imgui_impl_win32.h" />
|
||||
<ClInclude Include="include\ImGui\imgui_internal.h" />
|
||||
<ClInclude Include="include\ImGui\imgui_stdlib.h" />
|
||||
<ClInclude Include="include\ImGui\imstb_rectpack.h" />
|
||||
<ClInclude Include="include\ImGui\imstb_textedit.h" />
|
||||
<ClInclude Include="include\ImGui\imstb_truetype.h" />
|
||||
<ClInclude Include="include\ImGui\TextEditor.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Misc\IStudioDataCache.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\CMDLCache.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Misc\CDefaultDataCacheClient.h" />
|
||||
|
||||
@@ -1,937 +0,0 @@
|
||||
#include "TextEditor.h"
|
||||
|
||||
static bool TokenizeCStyleString(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end)
|
||||
{
|
||||
const char* p = in_begin;
|
||||
|
||||
if (*p == '"')
|
||||
{
|
||||
p++;
|
||||
|
||||
while (p < in_end)
|
||||
{
|
||||
// handle end of string
|
||||
if (*p == '"')
|
||||
{
|
||||
out_begin = in_begin;
|
||||
out_end = p + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// handle escape character for "
|
||||
if (*p == '\\' && p + 1 < in_end && p[1] == '"')
|
||||
p++;
|
||||
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TokenizeCStyleCharacterLiteral(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end)
|
||||
{
|
||||
const char* p = in_begin;
|
||||
|
||||
if (*p == '\'')
|
||||
{
|
||||
p++;
|
||||
|
||||
// handle escape characters
|
||||
if (p < in_end && *p == '\\')
|
||||
p++;
|
||||
|
||||
if (p < in_end)
|
||||
p++;
|
||||
|
||||
// handle end of character literal
|
||||
if (p < in_end && *p == '\'')
|
||||
{
|
||||
out_begin = in_begin;
|
||||
out_end = p + 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TokenizeCStyleIdentifier(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end)
|
||||
{
|
||||
const char* p = in_begin;
|
||||
|
||||
if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || *p == '_')
|
||||
{
|
||||
p++;
|
||||
|
||||
while ((p < in_end) && ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9') || *p == '_'))
|
||||
p++;
|
||||
|
||||
out_begin = in_begin;
|
||||
out_end = p;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TokenizeCStyleNumber(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end)
|
||||
{
|
||||
const char* p = in_begin;
|
||||
|
||||
const bool startsWithNumber = *p >= '0' && *p <= '9';
|
||||
|
||||
if (*p != '+' && *p != '-' && !startsWithNumber)
|
||||
return false;
|
||||
|
||||
p++;
|
||||
|
||||
bool hasNumber = startsWithNumber;
|
||||
|
||||
while (p < in_end && (*p >= '0' && *p <= '9'))
|
||||
{
|
||||
hasNumber = true;
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
if (hasNumber == false)
|
||||
return false;
|
||||
|
||||
bool isFloat = false;
|
||||
bool isHex = false;
|
||||
bool isBinary = false;
|
||||
|
||||
if (p < in_end)
|
||||
{
|
||||
if (*p == '.')
|
||||
{
|
||||
isFloat = true;
|
||||
|
||||
p++;
|
||||
|
||||
while (p < in_end && (*p >= '0' && *p <= '9'))
|
||||
p++;
|
||||
}
|
||||
else if (*p == 'x' || *p == 'X')
|
||||
{
|
||||
// hex formatted integer of the type 0xef80
|
||||
|
||||
isHex = true;
|
||||
|
||||
p++;
|
||||
|
||||
while (p < in_end && ((*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F')))
|
||||
p++;
|
||||
}
|
||||
else if (*p == 'b' || *p == 'B')
|
||||
{
|
||||
// binary formatted integer of the type 0b01011101
|
||||
|
||||
isBinary = true;
|
||||
|
||||
p++;
|
||||
|
||||
while (p < in_end && (*p >= '0' && *p <= '1'))
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
if (isHex == false && isBinary == false)
|
||||
{
|
||||
// floating point exponent
|
||||
if (p < in_end && (*p == 'e' || *p == 'E'))
|
||||
{
|
||||
isFloat = true;
|
||||
|
||||
p++;
|
||||
|
||||
if (p < in_end && (*p == '+' || *p == '-'))
|
||||
p++;
|
||||
|
||||
bool hasDigits = false;
|
||||
|
||||
while (p < in_end && (*p >= '0' && *p <= '9'))
|
||||
{
|
||||
hasDigits = true;
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
if (hasDigits == false)
|
||||
return false;
|
||||
}
|
||||
|
||||
// single precision floating point type
|
||||
if (p < in_end && *p == 'f')
|
||||
p++;
|
||||
}
|
||||
|
||||
if (isFloat == false)
|
||||
{
|
||||
// integer size type
|
||||
while (p < in_end && (*p == 'u' || *p == 'U' || *p == 'l' || *p == 'L'))
|
||||
p++;
|
||||
}
|
||||
|
||||
out_begin = in_begin;
|
||||
out_end = p;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool TokenizeCStylePunctuation(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end)
|
||||
{
|
||||
(void)in_end;
|
||||
|
||||
switch (*in_begin)
|
||||
{
|
||||
case '[':
|
||||
case ']':
|
||||
case '{':
|
||||
case '}':
|
||||
case '!':
|
||||
case '%':
|
||||
case '^':
|
||||
case '&':
|
||||
case '*':
|
||||
case '(':
|
||||
case ')':
|
||||
case '-':
|
||||
case '+':
|
||||
case '=':
|
||||
case '~':
|
||||
case '|':
|
||||
case '<':
|
||||
case '>':
|
||||
case '?':
|
||||
case ':':
|
||||
case '/':
|
||||
case ';':
|
||||
case ',':
|
||||
case '.':
|
||||
out_begin = in_begin;
|
||||
out_end = in_begin + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TokenizeLuaStyleString(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end)
|
||||
{
|
||||
const char* p = in_begin;
|
||||
|
||||
bool is_single_quote = false;
|
||||
bool is_double_quotes = false;
|
||||
bool is_double_square_brackets = false;
|
||||
|
||||
switch (*p)
|
||||
{
|
||||
case '\'':
|
||||
is_single_quote = true;
|
||||
break;
|
||||
case '"':
|
||||
is_double_quotes = true;
|
||||
break;
|
||||
case '[':
|
||||
p++;
|
||||
if (p < in_end && *(p) == '[')
|
||||
is_double_square_brackets = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_single_quote || is_double_quotes || is_double_square_brackets)
|
||||
{
|
||||
p++;
|
||||
|
||||
while (p < in_end)
|
||||
{
|
||||
// handle end of string
|
||||
if ((is_single_quote && *p == '\'') || (is_double_quotes && *p == '"') || (is_double_square_brackets && *p == ']' && p + 1 < in_end && *(p + 1) == ']'))
|
||||
{
|
||||
out_begin = in_begin;
|
||||
|
||||
if (is_double_square_brackets)
|
||||
out_end = p + 2;
|
||||
else
|
||||
out_end = p + 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// handle escape character for "
|
||||
if (*p == '\\' && p + 1 < in_end && (is_single_quote || is_double_quotes))
|
||||
p++;
|
||||
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TokenizeLuaStyleIdentifier(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end)
|
||||
{
|
||||
const char* p = in_begin;
|
||||
|
||||
if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || *p == '_')
|
||||
{
|
||||
p++;
|
||||
|
||||
while ((p < in_end) && ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9') || *p == '_'))
|
||||
p++;
|
||||
|
||||
out_begin = in_begin;
|
||||
out_end = p;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TokenizeLuaStyleNumber(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end)
|
||||
{
|
||||
const char* p = in_begin;
|
||||
|
||||
const bool startsWithNumber = *p >= '0' && *p <= '9';
|
||||
|
||||
if (*p != '+' && *p != '-' && !startsWithNumber)
|
||||
return false;
|
||||
|
||||
p++;
|
||||
|
||||
bool hasNumber = startsWithNumber;
|
||||
|
||||
while (p < in_end && (*p >= '0' && *p <= '9'))
|
||||
{
|
||||
hasNumber = true;
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
if (hasNumber == false)
|
||||
return false;
|
||||
|
||||
if (p < in_end)
|
||||
{
|
||||
if (*p == '.')
|
||||
{
|
||||
p++;
|
||||
|
||||
while (p < in_end && (*p >= '0' && *p <= '9'))
|
||||
p++;
|
||||
}
|
||||
|
||||
// floating point exponent
|
||||
if (p < in_end && (*p == 'e' || *p == 'E'))
|
||||
{
|
||||
p++;
|
||||
|
||||
if (p < in_end && (*p == '+' || *p == '-'))
|
||||
p++;
|
||||
|
||||
bool hasDigits = false;
|
||||
|
||||
while (p < in_end && (*p >= '0' && *p <= '9'))
|
||||
{
|
||||
hasDigits = true;
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
if (hasDigits == false)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
out_begin = in_begin;
|
||||
out_end = p;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool TokenizeLuaStylePunctuation(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end)
|
||||
{
|
||||
(void)in_end;
|
||||
|
||||
switch (*in_begin)
|
||||
{
|
||||
case '[':
|
||||
case ']':
|
||||
case '{':
|
||||
case '}':
|
||||
case '!':
|
||||
case '%':
|
||||
case '#':
|
||||
case '^':
|
||||
case '&':
|
||||
case '*':
|
||||
case '(':
|
||||
case ')':
|
||||
case '-':
|
||||
case '+':
|
||||
case '=':
|
||||
case '~':
|
||||
case '|':
|
||||
case '<':
|
||||
case '>':
|
||||
case '?':
|
||||
case ':':
|
||||
case '/':
|
||||
case ';':
|
||||
case ',':
|
||||
case '.':
|
||||
out_begin = in_begin;
|
||||
out_end = in_begin + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::Cpp()
|
||||
{
|
||||
static bool inited = false;
|
||||
static LanguageDefinition langDef;
|
||||
if (!inited)
|
||||
{
|
||||
static const char* const cppKeywords[] = {
|
||||
"alignas", "alignof", "and", "and_eq", "asm", "atomic_cancel", "atomic_commit", "atomic_noexcept", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", "char16_t", "char32_t", "class",
|
||||
"compl", "concept", "const", "constexpr", "const_cast", "continue", "decltype", "default", "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float",
|
||||
"for", "friend", "goto", "if", "import", "inline", "int", "long", "module", "mutable", "namespace", "new", "noexcept", "not", "not_eq", "nullptr", "operator", "or", "or_eq", "private", "protected", "public",
|
||||
"register", "reinterpret_cast", "requires", "return", "short", "signed", "sizeof", "static", "static_assert", "static_cast", "struct", "switch", "synchronized", "template", "this", "thread_local",
|
||||
"throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq"
|
||||
};
|
||||
for (auto& k : cppKeywords)
|
||||
langDef.mKeywords.insert(k);
|
||||
|
||||
static const char* const identifiers[] = {
|
||||
"abort", "abs", "acos", "asin", "atan", "atexit", "atof", "atoi", "atol", "ceil", "clock", "cosh", "ctime", "div", "exit", "fabs", "floor", "fmod", "getchar", "getenv", "isalnum", "isalpha", "isdigit", "isgraph",
|
||||
"ispunct", "isspace", "isupper", "kbhit", "log10", "log2", "log", "memcmp", "modf", "pow", "printf", "sprintf", "snprintf", "putchar", "putenv", "puts", "rand", "remove", "rename", "sinh", "sqrt", "srand", "strcat", "strcmp", "strerror", "time", "tolower", "toupper",
|
||||
"std", "string", "vector", "map", "unordered_map", "set", "unordered_set", "min", "max"
|
||||
};
|
||||
for (auto& k : identifiers)
|
||||
{
|
||||
Identifier id;
|
||||
id.mDeclaration = "Built-in function";
|
||||
langDef.mIdentifiers.insert(std::make_pair(std::string(k), id));
|
||||
}
|
||||
|
||||
langDef.mTokenize = [](const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end, PaletteIndex& paletteIndex) -> bool
|
||||
{
|
||||
paletteIndex = PaletteIndex::Max;
|
||||
|
||||
while (in_begin < in_end && isascii(*in_begin) && isblank(*in_begin))
|
||||
in_begin++;
|
||||
|
||||
if (in_begin == in_end)
|
||||
{
|
||||
out_begin = in_end;
|
||||
out_end = in_end;
|
||||
paletteIndex = PaletteIndex::Default;
|
||||
}
|
||||
else if (TokenizeCStyleString(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::String;
|
||||
else if (TokenizeCStyleCharacterLiteral(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::CharLiteral;
|
||||
else if (TokenizeCStyleIdentifier(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::Identifier;
|
||||
else if (TokenizeCStyleNumber(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::Number;
|
||||
else if (TokenizeCStylePunctuation(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::Punctuation;
|
||||
|
||||
return paletteIndex != PaletteIndex::Max;
|
||||
};
|
||||
|
||||
langDef.mCommentStart = "/*";
|
||||
langDef.mCommentEnd = "*/";
|
||||
langDef.mSingleLineComment = "//";
|
||||
|
||||
langDef.mCaseSensitive = true;
|
||||
|
||||
langDef.mName = "C++";
|
||||
|
||||
inited = true;
|
||||
}
|
||||
return langDef;
|
||||
}
|
||||
|
||||
const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::Hlsl()
|
||||
{
|
||||
static bool inited = false;
|
||||
static LanguageDefinition langDef;
|
||||
if (!inited)
|
||||
{
|
||||
static const char* const keywords[] = {
|
||||
"AppendStructuredBuffer", "asm", "asm_fragment", "BlendState", "bool", "break", "Buffer", "ByteAddressBuffer", "case", "cbuffer", "centroid", "class", "column_major", "compile", "compile_fragment",
|
||||
"CompileShader", "const", "continue", "ComputeShader", "ConsumeStructuredBuffer", "default", "DepthStencilState", "DepthStencilView", "discard", "do", "double", "DomainShader", "dword", "else",
|
||||
"export", "extern", "false", "float", "for", "fxgroup", "GeometryShader", "groupshared", "half", "Hullshader", "if", "in", "inline", "inout", "InputPatch", "int", "interface", "line", "lineadj",
|
||||
"linear", "LineStream", "matrix", "min16float", "min10float", "min16int", "min12int", "min16uint", "namespace", "nointerpolation", "noperspective", "NULL", "out", "OutputPatch", "packoffset",
|
||||
"pass", "pixelfragment", "PixelShader", "point", "PointStream", "precise", "RasterizerState", "RenderTargetView", "return", "register", "row_major", "RWBuffer", "RWByteAddressBuffer", "RWStructuredBuffer",
|
||||
"RWTexture1D", "RWTexture1DArray", "RWTexture2D", "RWTexture2DArray", "RWTexture3D", "sample", "sampler", "SamplerState", "SamplerComparisonState", "shared", "snorm", "stateblock", "stateblock_state",
|
||||
"static", "string", "struct", "switch", "StructuredBuffer", "tbuffer", "technique", "technique10", "technique11", "texture", "Texture1D", "Texture1DArray", "Texture2D", "Texture2DArray", "Texture2DMS",
|
||||
"Texture2DMSArray", "Texture3D", "TextureCube", "TextureCubeArray", "true", "typedef", "triangle", "triangleadj", "TriangleStream", "uint", "uniform", "unorm", "unsigned", "vector", "vertexfragment",
|
||||
"VertexShader", "void", "volatile", "while",
|
||||
"bool1","bool2","bool3","bool4","double1","double2","double3","double4", "float1", "float2", "float3", "float4", "int1", "int2", "int3", "int4", "in", "out", "inout",
|
||||
"uint1", "uint2", "uint3", "uint4", "dword1", "dword2", "dword3", "dword4", "half1", "half2", "half3", "half4",
|
||||
"float1x1","float2x1","float3x1","float4x1","float1x2","float2x2","float3x2","float4x2",
|
||||
"float1x3","float2x3","float3x3","float4x3","float1x4","float2x4","float3x4","float4x4",
|
||||
"half1x1","half2x1","half3x1","half4x1","half1x2","half2x2","half3x2","half4x2",
|
||||
"half1x3","half2x3","half3x3","half4x3","half1x4","half2x4","half3x4","half4x4",
|
||||
};
|
||||
for (auto& k : keywords)
|
||||
langDef.mKeywords.insert(k);
|
||||
|
||||
static const char* const identifiers[] = {
|
||||
"abort", "abs", "acos", "all", "AllMemoryBarrier", "AllMemoryBarrierWithGroupSync", "any", "asdouble", "asfloat", "asin", "asint", "asint", "asuint",
|
||||
"asuint", "atan", "atan2", "ceil", "CheckAccessFullyMapped", "clamp", "clip", "cos", "cosh", "countbits", "cross", "D3DCOLORtoUBYTE4", "ddx",
|
||||
"ddx_coarse", "ddx_fine", "ddy", "ddy_coarse", "ddy_fine", "degrees", "determinant", "DeviceMemoryBarrier", "DeviceMemoryBarrierWithGroupSync",
|
||||
"distance", "dot", "dst", "errorf", "EvaluateAttributeAtCentroid", "EvaluateAttributeAtSample", "EvaluateAttributeSnapped", "exp", "exp2",
|
||||
"f16tof32", "f32tof16", "faceforward", "firstbithigh", "firstbitlow", "floor", "fma", "fmod", "frac", "frexp", "fwidth", "GetRenderTargetSampleCount",
|
||||
"GetRenderTargetSamplePosition", "GroupMemoryBarrier", "GroupMemoryBarrierWithGroupSync", "InterlockedAdd", "InterlockedAnd", "InterlockedCompareExchange",
|
||||
"InterlockedCompareStore", "InterlockedExchange", "InterlockedMax", "InterlockedMin", "InterlockedOr", "InterlockedXor", "isfinite", "isinf", "isnan",
|
||||
"ldexp", "length", "lerp", "lit", "log", "log10", "log2", "mad", "max", "min", "modf", "msad4", "mul", "noise", "normalize", "pow", "printf",
|
||||
"Process2DQuadTessFactorsAvg", "Process2DQuadTessFactorsMax", "Process2DQuadTessFactorsMin", "ProcessIsolineTessFactors", "ProcessQuadTessFactorsAvg",
|
||||
"ProcessQuadTessFactorsMax", "ProcessQuadTessFactorsMin", "ProcessTriTessFactorsAvg", "ProcessTriTessFactorsMax", "ProcessTriTessFactorsMin",
|
||||
"radians", "rcp", "reflect", "refract", "reversebits", "round", "rsqrt", "saturate", "sign", "sin", "sincos", "sinh", "smoothstep", "sqrt", "step",
|
||||
"tan", "tanh", "tex1D", "tex1D", "tex1Dbias", "tex1Dgrad", "tex1Dlod", "tex1Dproj", "tex2D", "tex2D", "tex2Dbias", "tex2Dgrad", "tex2Dlod", "tex2Dproj",
|
||||
"tex3D", "tex3D", "tex3Dbias", "tex3Dgrad", "tex3Dlod", "tex3Dproj", "texCUBE", "texCUBE", "texCUBEbias", "texCUBEgrad", "texCUBElod", "texCUBEproj", "transpose", "trunc"
|
||||
};
|
||||
for (auto& k : identifiers)
|
||||
{
|
||||
Identifier id;
|
||||
id.mDeclaration = "Built-in function";
|
||||
langDef.mIdentifiers.insert(std::make_pair(std::string(k), id));
|
||||
}
|
||||
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([ \t]*#[ \t]*[a-zA-Z_]+)##", PaletteIndex::Preprocessor));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(L?\"(\\.|[^\"])*\")##", PaletteIndex::String));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(\'\\?[^\']\')##", PaletteIndex::CharLiteral));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?[fF]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?[0-9]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[0-7]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[xX][0-9a-fA-F]+[uU]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([a-zA-Z_][a-zA-Z0-9_]*)##", PaletteIndex::Identifier));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([\[\]\{\}\!\%\^\&\*\(\)\-\+\=\~\|\<\>\?\/\;\,\.])##", PaletteIndex::Punctuation));
|
||||
|
||||
langDef.mCommentStart = "/*";
|
||||
langDef.mCommentEnd = "*/";
|
||||
langDef.mSingleLineComment = "//";
|
||||
|
||||
langDef.mCaseSensitive = true;
|
||||
|
||||
langDef.mName = "HLSL";
|
||||
|
||||
inited = true;
|
||||
}
|
||||
return langDef;
|
||||
}
|
||||
|
||||
const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::Glsl()
|
||||
{
|
||||
static bool inited = false;
|
||||
static LanguageDefinition langDef;
|
||||
if (!inited)
|
||||
{
|
||||
static const char* const keywords[] = {
|
||||
"auto", "break", "case", "char", "const", "continue", "default", "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "inline", "int", "long", "register", "restrict", "return", "short",
|
||||
"signed", "sizeof", "static", "struct", "switch", "typedef", "union", "unsigned", "void", "volatile", "while", "_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary",
|
||||
"_Noreturn", "_Static_assert", "_Thread_local"
|
||||
};
|
||||
for (auto& k : keywords)
|
||||
langDef.mKeywords.insert(k);
|
||||
|
||||
static const char* const identifiers[] = {
|
||||
"abort", "abs", "acos", "asin", "atan", "atexit", "atof", "atoi", "atol", "ceil", "clock", "cosh", "ctime", "div", "exit", "fabs", "floor", "fmod", "getchar", "getenv", "isalnum", "isalpha", "isdigit", "isgraph",
|
||||
"ispunct", "isspace", "isupper", "kbhit", "log10", "log2", "log", "memcmp", "modf", "pow", "putchar", "putenv", "puts", "rand", "remove", "rename", "sinh", "sqrt", "srand", "strcat", "strcmp", "strerror", "time", "tolower", "toupper"
|
||||
};
|
||||
for (auto& k : identifiers)
|
||||
{
|
||||
Identifier id;
|
||||
id.mDeclaration = "Built-in function";
|
||||
langDef.mIdentifiers.insert(std::make_pair(std::string(k), id));
|
||||
}
|
||||
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([ \t]*#[ \t]*[a-zA-Z_]+)##", PaletteIndex::Preprocessor));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(L?\"(\\.|[^\"])*\")##", PaletteIndex::String));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(\'\\?[^\']\')##", PaletteIndex::CharLiteral));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?[fF]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?[0-9]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[0-7]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[xX][0-9a-fA-F]+[uU]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([a-zA-Z_][a-zA-Z0-9_]*)##", PaletteIndex::Identifier));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([\[\]\{\}\!\%\^\&\*\(\)\-\+\=\~\|\<\>\?\/\;\,\.])##", PaletteIndex::Punctuation));
|
||||
|
||||
langDef.mCommentStart = "/*";
|
||||
langDef.mCommentEnd = "*/";
|
||||
langDef.mSingleLineComment = "//";
|
||||
|
||||
langDef.mCaseSensitive = true;
|
||||
|
||||
langDef.mName = "GLSL";
|
||||
|
||||
inited = true;
|
||||
}
|
||||
return langDef;
|
||||
}
|
||||
|
||||
const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::Python()
|
||||
{
|
||||
static bool inited = false;
|
||||
static LanguageDefinition langDef;
|
||||
if (!inited)
|
||||
{
|
||||
static const char* const keywords[] = {
|
||||
"False", "await", "else", "import", "pass", "None", "break", "except", "in", "raise", "True", "class", "finally", "is", "return", "and", "continue", "for", "lambda", "try", "as", "def", "from", "nonlocal", "while", "assert", "del", "global", "not", "with", "async", "elif", "if", "or", "yield"
|
||||
};
|
||||
for (auto& k : keywords)
|
||||
langDef.mKeywords.insert(k);
|
||||
|
||||
static const char* const identifiers[] = {
|
||||
"abs", "aiter", "all", "any", "anext", "ascii", "bin", "bool", "breakpoint", "bytearray", "bytes", "callable", "chr", "classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "exec", "filter", "float", "format", "frozenset", "getattr", "globals", "hasattr", "hash", "help", "hex", "id", "input", "int", "isinstance", "issubclass", "iter", "len", "list", "locals", "map", "max", "memoryview", "min", "next", "object", "oct", "open", "ord", "pow", "print", "property", "range", "repr", "reversed", "round", "set", "setattr", "slice", "sorted", "staticmethod", "str", "sum", "super", "tuple", "type", "vars", "zip", "__import__"
|
||||
};
|
||||
for (auto& k : identifiers)
|
||||
{
|
||||
Identifier id;
|
||||
id.mDeclaration = "Built-in function";
|
||||
langDef.mIdentifiers.insert(std::make_pair(std::string(k), id));
|
||||
}
|
||||
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##((b|u|f|r)?\"(\\.|[^\"])*\")##", PaletteIndex::String));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##((b|u|f|r)?'(\\.|[^'])*')##", PaletteIndex::String));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?[fF]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?[0-9]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[0-7]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[xX][0-9a-fA-F]+[uU]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([a-zA-Z_][a-zA-Z0-9_]*)##", PaletteIndex::Identifier));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([\[\]\{\}\!\%\^\&\*\(\)\-\+\=\~\|\<\>\?\/\;\,\.\:])##", PaletteIndex::Punctuation));
|
||||
|
||||
langDef.mCommentStart = "\"\"\"";
|
||||
langDef.mCommentEnd = "\"\"\"";
|
||||
langDef.mSingleLineComment = "#";
|
||||
|
||||
langDef.mCaseSensitive = true;
|
||||
|
||||
langDef.mName = "Python";
|
||||
|
||||
inited = true;
|
||||
}
|
||||
return langDef;
|
||||
}
|
||||
|
||||
const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::C()
|
||||
{
|
||||
static bool inited = false;
|
||||
static LanguageDefinition langDef;
|
||||
if (!inited)
|
||||
{
|
||||
static const char* const keywords[] = {
|
||||
"auto", "break", "case", "char", "const", "continue", "default", "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "inline", "int", "long", "register", "restrict", "return", "short",
|
||||
"signed", "sizeof", "static", "struct", "switch", "typedef", "union", "unsigned", "void", "volatile", "while", "_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary",
|
||||
"_Noreturn", "_Static_assert", "_Thread_local"
|
||||
};
|
||||
for (auto& k : keywords)
|
||||
langDef.mKeywords.insert(k);
|
||||
|
||||
static const char* const identifiers[] = {
|
||||
"abort", "abs", "acos", "asin", "atan", "atexit", "atof", "atoi", "atol", "ceil", "clock", "cosh", "ctime", "div", "exit", "fabs", "floor", "fmod", "getchar", "getenv", "isalnum", "isalpha", "isdigit", "isgraph",
|
||||
"ispunct", "isspace", "isupper", "kbhit", "log10", "log2", "log", "memcmp", "modf", "pow", "putchar", "putenv", "puts", "rand", "remove", "rename", "sinh", "sqrt", "srand", "strcat", "strcmp", "strerror", "time", "tolower", "toupper"
|
||||
};
|
||||
for (auto& k : identifiers)
|
||||
{
|
||||
Identifier id;
|
||||
id.mDeclaration = "Built-in function";
|
||||
langDef.mIdentifiers.insert(std::make_pair(std::string(k), id));
|
||||
}
|
||||
|
||||
langDef.mTokenize = [](const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end, PaletteIndex& paletteIndex) -> bool
|
||||
{
|
||||
paletteIndex = PaletteIndex::Max;
|
||||
|
||||
while (in_begin < in_end && isascii(*in_begin) && isblank(*in_begin))
|
||||
in_begin++;
|
||||
|
||||
if (in_begin == in_end)
|
||||
{
|
||||
out_begin = in_end;
|
||||
out_end = in_end;
|
||||
paletteIndex = PaletteIndex::Default;
|
||||
}
|
||||
else if (TokenizeCStyleString(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::String;
|
||||
else if (TokenizeCStyleCharacterLiteral(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::CharLiteral;
|
||||
else if (TokenizeCStyleIdentifier(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::Identifier;
|
||||
else if (TokenizeCStyleNumber(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::Number;
|
||||
else if (TokenizeCStylePunctuation(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::Punctuation;
|
||||
|
||||
return paletteIndex != PaletteIndex::Max;
|
||||
};
|
||||
|
||||
langDef.mCommentStart = "/*";
|
||||
langDef.mCommentEnd = "*/";
|
||||
langDef.mSingleLineComment = "//";
|
||||
|
||||
langDef.mCaseSensitive = true;
|
||||
|
||||
langDef.mName = "C";
|
||||
|
||||
inited = true;
|
||||
}
|
||||
return langDef;
|
||||
}
|
||||
|
||||
const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::Sql()
|
||||
{
|
||||
static bool inited = false;
|
||||
static LanguageDefinition langDef;
|
||||
if (!inited)
|
||||
{
|
||||
static const char* const keywords[] = {
|
||||
"ADD", "EXCEPT", "PERCENT", "ALL", "EXEC", "PLAN", "ALTER", "EXECUTE", "PRECISION", "AND", "EXISTS", "PRIMARY", "ANY", "EXIT", "PRINT", "AS", "FETCH", "PROC", "ASC", "FILE", "PROCEDURE",
|
||||
"AUTHORIZATION", "FILLFACTOR", "PUBLIC", "BACKUP", "FOR", "RAISERROR", "BEGIN", "FOREIGN", "READ", "BETWEEN", "FREETEXT", "READTEXT", "BREAK", "FREETEXTTABLE", "RECONFIGURE",
|
||||
"BROWSE", "FROM", "REFERENCES", "BULK", "FULL", "REPLICATION", "BY", "FUNCTION", "RESTORE", "CASCADE", "GOTO", "RESTRICT", "CASE", "GRANT", "RETURN", "CHECK", "GROUP", "REVOKE",
|
||||
"CHECKPOINT", "HAVING", "RIGHT", "CLOSE", "HOLDLOCK", "ROLLBACK", "CLUSTERED", "IDENTITY", "ROWCOUNT", "COALESCE", "IDENTITY_INSERT", "ROWGUIDCOL", "COLLATE", "IDENTITYCOL", "RULE",
|
||||
"COLUMN", "IF", "SAVE", "COMMIT", "IN", "SCHEMA", "COMPUTE", "INDEX", "SELECT", "CONSTRAINT", "INNER", "SESSION_USER", "CONTAINS", "INSERT", "SET", "CONTAINSTABLE", "INTERSECT", "SETUSER",
|
||||
"CONTINUE", "INTO", "SHUTDOWN", "CONVERT", "IS", "SOME", "CREATE", "JOIN", "STATISTICS", "CROSS", "KEY", "SYSTEM_USER", "CURRENT", "KILL", "TABLE", "CURRENT_DATE", "LEFT", "TEXTSIZE",
|
||||
"CURRENT_TIME", "LIKE", "THEN", "CURRENT_TIMESTAMP", "LINENO", "TO", "CURRENT_USER", "LOAD", "TOP", "CURSOR", "NATIONAL", "TRAN", "DATABASE", "NOCHECK", "TRANSACTION",
|
||||
"DBCC", "NONCLUSTERED", "TRIGGER", "DEALLOCATE", "NOT", "TRUNCATE", "DECLARE", "NULL", "TSEQUAL", "DEFAULT", "NULLIF", "UNION", "DELETE", "OF", "UNIQUE", "DENY", "OFF", "UPDATE",
|
||||
"DESC", "OFFSETS", "UPDATETEXT", "DISK", "ON", "USE", "DISTINCT", "OPEN", "USER", "DISTRIBUTED", "OPENDATASOURCE", "VALUES", "DOUBLE", "OPENQUERY", "VARYING","DROP", "OPENROWSET", "VIEW",
|
||||
"DUMMY", "OPENXML", "WAITFOR", "DUMP", "OPTION", "WHEN", "ELSE", "OR", "WHERE", "END", "ORDER", "WHILE", "ERRLVL", "OUTER", "WITH", "ESCAPE", "OVER", "WRITETEXT"
|
||||
};
|
||||
|
||||
for (auto& k : keywords)
|
||||
langDef.mKeywords.insert(k);
|
||||
|
||||
static const char* const identifiers[] = {
|
||||
"ABS", "ACOS", "ADD_MONTHS", "ASCII", "ASCIISTR", "ASIN", "ATAN", "ATAN2", "AVG", "BFILENAME", "BIN_TO_NUM", "BITAND", "CARDINALITY", "CASE", "CAST", "CEIL",
|
||||
"CHARTOROWID", "CHR", "COALESCE", "COMPOSE", "CONCAT", "CONVERT", "CORR", "COS", "COSH", "COUNT", "COVAR_POP", "COVAR_SAMP", "CUME_DIST", "CURRENT_DATE",
|
||||
"CURRENT_TIMESTAMP", "DBTIMEZONE", "DECODE", "DECOMPOSE", "DENSE_RANK", "DUMP", "EMPTY_BLOB", "EMPTY_CLOB", "EXP", "EXTRACT", "FIRST_VALUE", "FLOOR", "FROM_TZ", "GREATEST",
|
||||
"GROUP_ID", "HEXTORAW", "INITCAP", "INSTR", "INSTR2", "INSTR4", "INSTRB", "INSTRC", "LAG", "LAST_DAY", "LAST_VALUE", "LEAD", "LEAST", "LENGTH", "LENGTH2", "LENGTH4",
|
||||
"LENGTHB", "LENGTHC", "LISTAGG", "LN", "LNNVL", "LOCALTIMESTAMP", "LOG", "LOWER", "LPAD", "LTRIM", "MAX", "MEDIAN", "MIN", "MOD", "MONTHS_BETWEEN", "NANVL", "NCHR",
|
||||
"NEW_TIME", "NEXT_DAY", "NTH_VALUE", "NULLIF", "NUMTODSINTERVAL", "NUMTOYMINTERVAL", "NVL", "NVL2", "POWER", "RANK", "RAWTOHEX", "REGEXP_COUNT", "REGEXP_INSTR",
|
||||
"REGEXP_REPLACE", "REGEXP_SUBSTR", "REMAINDER", "REPLACE", "ROUND", "ROWNUM", "RPAD", "RTRIM", "SESSIONTIMEZONE", "SIGN", "SIN", "SINH",
|
||||
"SOUNDEX", "SQRT", "STDDEV", "SUBSTR", "SUM", "SYS_CONTEXT", "SYSDATE", "SYSTIMESTAMP", "TAN", "TANH", "TO_CHAR", "TO_CLOB", "TO_DATE", "TO_DSINTERVAL", "TO_LOB",
|
||||
"TO_MULTI_BYTE", "TO_NCLOB", "TO_NUMBER", "TO_SINGLE_BYTE", "TO_TIMESTAMP", "TO_TIMESTAMP_TZ", "TO_YMINTERVAL", "TRANSLATE", "TRIM", "TRUNC", "TZ_OFFSET", "UID", "UPPER",
|
||||
"USER", "USERENV", "VAR_POP", "VAR_SAMP", "VARIANCE", "VSIZE"
|
||||
};
|
||||
for (auto& k : identifiers)
|
||||
{
|
||||
Identifier id;
|
||||
id.mDeclaration = "Built-in function";
|
||||
langDef.mIdentifiers.insert(std::make_pair(std::string(k), id));
|
||||
}
|
||||
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(L?\"(\\.|[^\"])*\")##", PaletteIndex::String));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(\'[^\']*\')##", PaletteIndex::String));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?[fF]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?[0-9]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[0-7]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[xX][0-9a-fA-F]+[uU]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([a-zA-Z_][a-zA-Z0-9_]*)##", PaletteIndex::Identifier));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([\[\]\{\}\!\%\^\&\*\(\)\-\+\=\~\|\<\>\?\/\;\,\.])##", PaletteIndex::Punctuation));
|
||||
|
||||
langDef.mCommentStart = "/*";
|
||||
langDef.mCommentEnd = "*/";
|
||||
langDef.mSingleLineComment = "--";
|
||||
|
||||
langDef.mCaseSensitive = false;
|
||||
|
||||
langDef.mName = "SQL";
|
||||
|
||||
inited = true;
|
||||
}
|
||||
return langDef;
|
||||
}
|
||||
|
||||
const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::AngelScript()
|
||||
{
|
||||
static bool inited = false;
|
||||
static LanguageDefinition langDef;
|
||||
if (!inited)
|
||||
{
|
||||
static const char* const keywords[] = {
|
||||
"and", "abstract", "auto", "bool", "break", "case", "cast", "class", "const", "continue", "default", "do", "double", "else", "enum", "false", "final", "float", "for",
|
||||
"from", "funcdef", "function", "get", "if", "import", "in", "inout", "int", "interface", "int8", "int16", "int32", "int64", "is", "mixin", "namespace", "not",
|
||||
"null", "or", "out", "override", "private", "protected", "return", "set", "shared", "super", "switch", "this ", "true", "typedef", "uint", "uint8", "uint16", "uint32",
|
||||
"uint64", "void", "while", "xor"
|
||||
};
|
||||
|
||||
for (auto& k : keywords)
|
||||
langDef.mKeywords.insert(k);
|
||||
|
||||
static const char* const identifiers[] = {
|
||||
"cos", "sin", "tab", "acos", "asin", "atan", "atan2", "cosh", "sinh", "tanh", "log", "log10", "pow", "sqrt", "abs", "ceil", "floor", "fraction", "closeTo", "fpFromIEEE", "fpToIEEE",
|
||||
"complex", "opEquals", "opAddAssign", "opSubAssign", "opMulAssign", "opDivAssign", "opAdd", "opSub", "opMul", "opDiv"
|
||||
};
|
||||
for (auto& k : identifiers)
|
||||
{
|
||||
Identifier id;
|
||||
id.mDeclaration = "Built-in function";
|
||||
langDef.mIdentifiers.insert(std::make_pair(std::string(k), id));
|
||||
}
|
||||
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(L?\"(\\.|[^\"])*\")##", PaletteIndex::String));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(\'\\?[^\']\')##", PaletteIndex::String));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?[fF]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?[0-9]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[0-7]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[xX][0-9a-fA-F]+[uU]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([a-zA-Z_][a-zA-Z0-9_]*)##", PaletteIndex::Identifier));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([\[\]\{\}\!\%\^\&\*\(\)\-\+\=\~\|\<\>\?\/\;\,\.])##", PaletteIndex::Punctuation));
|
||||
|
||||
langDef.mCommentStart = "/*";
|
||||
langDef.mCommentEnd = "*/";
|
||||
langDef.mSingleLineComment = "//";
|
||||
|
||||
langDef.mCaseSensitive = true;
|
||||
|
||||
langDef.mName = "AngelScript";
|
||||
|
||||
inited = true;
|
||||
}
|
||||
return langDef;
|
||||
}
|
||||
|
||||
const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::Lua()
|
||||
{
|
||||
static bool inited = false;
|
||||
static LanguageDefinition langDef;
|
||||
if (!inited)
|
||||
{
|
||||
static const char* const keywords[] = {
|
||||
"and", "break", "do", "else", "elseif", "end", "false", "for", "function", "goto", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while"
|
||||
};
|
||||
|
||||
for (auto& k : keywords)
|
||||
langDef.mKeywords.insert(k);
|
||||
|
||||
static const char* const identifiers[] = {
|
||||
"assert", "collectgarbage", "dofile", "error", "getmetatable", "ipairs", "loadfile", "load", "loadstring", "next", "pairs", "pcall", "print", "rawequal", "rawlen", "rawget", "rawset",
|
||||
"select", "setmetatable", "tonumber", "tostring", "type", "xpcall", "_G", "_VERSION","arshift", "band", "bnot", "bor", "bxor", "btest", "extract", "lrotate", "lshift", "replace",
|
||||
"rrotate", "rshift", "create", "resume", "running", "status", "wrap", "yield", "isyieldable", "debug","getuservalue", "gethook", "getinfo", "getlocal", "getregistry", "getmetatable",
|
||||
"getupvalue", "upvaluejoin", "upvalueid", "setuservalue", "sethook", "setlocal", "setmetatable", "setupvalue", "traceback", "close", "flush", "input", "lines", "open", "output", "popen",
|
||||
"read", "tmpfile", "type", "write", "close", "flush", "lines", "read", "seek", "setvbuf", "write", "__gc", "__tostring", "abs", "acos", "asin", "atan", "ceil", "cos", "deg", "exp", "tointeger",
|
||||
"floor", "fmod", "ult", "log", "max", "min", "modf", "rad", "random", "randomseed", "sin", "sqrt", "string", "tan", "type", "atan2", "cosh", "sinh", "tanh",
|
||||
"pow", "frexp", "ldexp", "log10", "pi", "huge", "maxinteger", "mininteger", "loadlib", "searchpath", "seeall", "preload", "cpath", "path", "searchers", "loaded", "module", "require", "clock",
|
||||
"date", "difftime", "execute", "exit", "getenv", "remove", "rename", "setlocale", "time", "tmpname", "byte", "char", "dump", "find", "format", "gmatch", "gsub", "len", "lower", "match", "rep",
|
||||
"reverse", "sub", "upper", "pack", "packsize", "unpack", "concat", "maxn", "insert", "pack", "unpack", "remove", "move", "sort", "offset", "codepoint", "char", "len", "codes", "charpattern",
|
||||
"coroutine", "table", "io", "os", "string", "utf8", "bit32", "math", "debug", "package"
|
||||
};
|
||||
for (auto& k : identifiers)
|
||||
{
|
||||
Identifier id;
|
||||
id.mDeclaration = "Built-in function";
|
||||
langDef.mIdentifiers.insert(std::make_pair(std::string(k), id));
|
||||
}
|
||||
|
||||
langDef.mTokenize = [](const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end, PaletteIndex& paletteIndex) -> bool
|
||||
{
|
||||
paletteIndex = PaletteIndex::Max;
|
||||
|
||||
while (in_begin < in_end && isascii(*in_begin) && isblank(*in_begin))
|
||||
in_begin++;
|
||||
|
||||
if (in_begin == in_end)
|
||||
{
|
||||
out_begin = in_end;
|
||||
out_end = in_end;
|
||||
paletteIndex = PaletteIndex::Default;
|
||||
}
|
||||
else if (TokenizeLuaStyleString(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::String;
|
||||
else if (TokenizeLuaStyleIdentifier(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::Identifier;
|
||||
else if (TokenizeLuaStyleNumber(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::Number;
|
||||
else if (TokenizeLuaStylePunctuation(in_begin, in_end, out_begin, out_end))
|
||||
paletteIndex = PaletteIndex::Punctuation;
|
||||
|
||||
return paletteIndex != PaletteIndex::Max;
|
||||
};
|
||||
|
||||
langDef.mCommentStart = "--[[";
|
||||
langDef.mCommentEnd = "]]";
|
||||
langDef.mSingleLineComment = "--";
|
||||
|
||||
langDef.mCaseSensitive = true;
|
||||
|
||||
langDef.mName = "Lua";
|
||||
|
||||
inited = true;
|
||||
}
|
||||
return langDef;
|
||||
}
|
||||
|
||||
const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::Cs()
|
||||
{
|
||||
static bool inited = false;
|
||||
static LanguageDefinition langDef;
|
||||
if (!inited)
|
||||
{
|
||||
static const char* const keywords[] = {
|
||||
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "in (generic modifier)", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "out (generic modifier)", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "using static", "void", "volatile", "while"
|
||||
};
|
||||
for (auto& k : keywords)
|
||||
langDef.mKeywords.insert(k);
|
||||
|
||||
static const char* const identifiers[] = {
|
||||
"add", "alias", "ascending", "async", "await", "descending", "dynamic", "from", "get", "global", "group", "into", "join", "let", "orderby", "partial", "remove", "select", "set", "value", "var", "when", "where", "yield"
|
||||
};
|
||||
for (auto& k : identifiers)
|
||||
{
|
||||
Identifier id;
|
||||
id.mDeclaration = "Built-in function";
|
||||
langDef.mIdentifiers.insert(std::make_pair(std::string(k), id));
|
||||
}
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(($|@)?\"(\\.|[^\"])*\")##", PaletteIndex::String));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?[fF]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?[0-9]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[0-7]+[Uu]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(0[xX][0-9a-fA-F]+[uU]?[lL]?[lL]?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([a-zA-Z_][a-zA-Z0-9_]*)##", PaletteIndex::Identifier));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([\[\]\{\}\!\%\^\&\*\(\)\-\+\=\~\|\<\>\?\/\;\,\.])##", PaletteIndex::Punctuation));
|
||||
|
||||
langDef.mCommentStart = "/*";
|
||||
langDef.mCommentEnd = "*/";
|
||||
langDef.mSingleLineComment = "//";
|
||||
|
||||
langDef.mCaseSensitive = true;
|
||||
|
||||
langDef.mName = "C#";
|
||||
|
||||
inited = true;
|
||||
}
|
||||
return langDef;
|
||||
}
|
||||
|
||||
const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::Json()
|
||||
{
|
||||
static bool inited = false;
|
||||
static LanguageDefinition langDef;
|
||||
if (!inited)
|
||||
{
|
||||
langDef.mKeywords.clear();
|
||||
langDef.mIdentifiers.clear();
|
||||
|
||||
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(\"(\\.|[^\"])*\")##", PaletteIndex::String));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?)##", PaletteIndex::Number));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##([\[\]\{\}\!\%\^\&\*\(\)\-\+\=\~\|\<\>\?\/\;\,\.\:])##", PaletteIndex::Punctuation));
|
||||
langDef.mTokenRegexStrings.push_back(std::make_pair<std::string, PaletteIndex>(R"##(false|true)##", PaletteIndex::Keyword));
|
||||
|
||||
langDef.mCommentStart = "/*";
|
||||
langDef.mCommentEnd = "*/";
|
||||
langDef.mSingleLineComment = "//";
|
||||
|
||||
langDef.mCaseSensitive = true;
|
||||
|
||||
langDef.mName = "Json";
|
||||
|
||||
inited = true;
|
||||
}
|
||||
return langDef;
|
||||
}
|
||||
+9370
-2801
File diff suppressed because it is too large
Load Diff
+1330
-431
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,8 @@
|
||||
#pragma once
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
|
||||
// - If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
|
||||
// - Compiling with NDEBUG will usually strip out assert() to nothing, which is NOT recommended because we use asserts to notify of programmer mistakes.
|
||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||
|
||||
@@ -48,7 +49,7 @@
|
||||
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
|
||||
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
|
||||
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
||||
//#define IMGUI_DISABLE_DEFAULT_FONT // Disable default embedded font (ProggyClean.ttf), remove ~9.5 KB from output binary. AddFontDefault() will assert.
|
||||
//#define IMGUI_DISABLE_DEFAULT_FONT // Disable default embedded fonts (ProggyClean/ProggyForever), remove ~9 KB + ~14 KB from output binary. AddFontDefaultXXX() functions will assert.
|
||||
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
|
||||
|
||||
//---- Enable Test Engine / Automation features.
|
||||
@@ -83,13 +84,13 @@
|
||||
|
||||
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
|
||||
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
|
||||
// Note that imgui_freetype.cpp may be used _without_ this define, if you manually call ImFontAtlas::SetFontLoader(). The define is simply a convenience.
|
||||
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
|
||||
//#define IMGUI_ENABLE_FREETYPE
|
||||
|
||||
//---- Use FreeType + plutosvg or lunasvg to render OpenType SVG fonts (SVGinOT)
|
||||
// Only works in combination with IMGUI_ENABLE_FREETYPE.
|
||||
// - lunasvg is currently easier to acquire/install, as e.g. it is part of vcpkg.
|
||||
// - plutosvg will support more fonts and may load them faster. It currently requires to be built manually but it is fairly easy. See misc/freetype/README for instructions.
|
||||
// - plutosvg is currently easier to install, as e.g. it is part of vcpkg. It will support more fonts and may load them faster. See misc/freetype/README for instructions.
|
||||
// - Both require headers to be available in the include path + program to be linked with the library code (not provided).
|
||||
// - (note: lunasvg implementation is based on Freetype's rsvg-port.c which is licensed under CeCILL-C Free Software License Agreement)
|
||||
//#define IMGUI_ENABLE_FREETYPE_PLUTOSVG
|
||||
@@ -130,6 +131,10 @@
|
||||
//#define IM_DEBUG_BREAK IM_ASSERT(0)
|
||||
//#define IM_DEBUG_BREAK __debugbreak()
|
||||
|
||||
//---- Debug Tools: Enable highlight ID conflicts _before_ hovering items. When io.ConfigDebugHighlightIdConflicts is set.
|
||||
// (THIS WILL SLOW DOWN DEAR IMGUI. Only use occasionally and disable after use)
|
||||
//#define IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS
|
||||
|
||||
//---- Debug Tools: Enable slower asserts
|
||||
//#define IMGUI_DEBUG_PARANOID
|
||||
|
||||
|
||||
+2486
-1164
File diff suppressed because it is too large
Load Diff
+911
-429
File diff suppressed because it is too large
Load Diff
+2957
-1056
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,9 @@
|
||||
#ifndef IMGUI_DISABLE
|
||||
|
||||
// Usage:
|
||||
// - Add '#define IMGUI_ENABLE_FREETYPE' in your imconfig to enable support for imgui_freetype in imgui.
|
||||
// - Add '#define IMGUI_ENABLE_FREETYPE' in your imconfig to automatically enable support
|
||||
// for imgui_freetype in imgui. It is equivalent to selecting the default loader with:
|
||||
// io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader())
|
||||
|
||||
// Optional support for OpenType SVG fonts:
|
||||
// - Add '#define IMGUI_ENABLE_FREETYPE_PLUTOSVG' to use plutosvg (not provided). See #7927.
|
||||
@@ -14,44 +16,67 @@
|
||||
|
||||
// Forward declarations
|
||||
struct ImFontAtlas;
|
||||
struct ImFontBuilderIO;
|
||||
struct ImFontLoader;
|
||||
|
||||
// Hinting greatly impacts visuals (and glyph sizes).
|
||||
// - By default, hinting is enabled and the font's native hinter is preferred over the auto-hinter.
|
||||
// - When disabled, FreeType generates blurrier glyphs, more or less matches the stb_truetype.h
|
||||
// - The Default hinting mode usually looks good, but may distort glyphs in an unusual way.
|
||||
// - The Light hinting mode generates fuzzier glyphs but better matches Microsoft's rasterizer.
|
||||
// You can set those flags globaly in ImFontAtlas::FontBuilderFlags
|
||||
// You can set those flags on a per font basis in ImFontConfig::FontBuilderFlags
|
||||
enum ImGuiFreeTypeBuilderFlags
|
||||
// You can set those flags globally in ImFontAtlas::FontLoaderFlags
|
||||
// You can set those flags on a per font basis in ImFontConfig::FontLoaderFlags
|
||||
typedef unsigned int ImGuiFreeTypeLoaderFlags;
|
||||
enum ImGuiFreeTypeLoaderFlags_
|
||||
{
|
||||
ImGuiFreeTypeBuilderFlags_NoHinting = 1 << 0, // Disable hinting. This generally generates 'blurrier' bitmap glyphs when the glyph are rendered in any of the anti-aliased modes.
|
||||
ImGuiFreeTypeBuilderFlags_NoAutoHint = 1 << 1, // Disable auto-hinter.
|
||||
ImGuiFreeTypeBuilderFlags_ForceAutoHint = 1 << 2, // Indicates that the auto-hinter is preferred over the font's native hinter.
|
||||
ImGuiFreeTypeBuilderFlags_LightHinting = 1 << 3, // A lighter hinting algorithm for gray-level modes. Many generated glyphs are fuzzier but better resemble their original shape. This is achieved by snapping glyphs to the pixel grid only vertically (Y-axis), as is done by Microsoft's ClearType and Adobe's proprietary font renderer. This preserves inter-glyph spacing in horizontal text.
|
||||
ImGuiFreeTypeBuilderFlags_MonoHinting = 1 << 4, // Strong hinting algorithm that should only be used for monochrome output.
|
||||
ImGuiFreeTypeBuilderFlags_Bold = 1 << 5, // Styling: Should we artificially embolden the font?
|
||||
ImGuiFreeTypeBuilderFlags_Oblique = 1 << 6, // Styling: Should we slant the font, emulating italic style?
|
||||
ImGuiFreeTypeBuilderFlags_Monochrome = 1 << 7, // Disable anti-aliasing. Combine this with MonoHinting for best results!
|
||||
ImGuiFreeTypeBuilderFlags_LoadColor = 1 << 8, // Enable FreeType color-layered glyphs
|
||||
ImGuiFreeTypeBuilderFlags_Bitmap = 1 << 9 // Enable FreeType bitmap glyphs
|
||||
ImGuiFreeTypeLoaderFlags_NoHinting = 1 << 0, // Disable hinting. This generally generates 'blurrier' bitmap glyphs when the glyph are rendered in any of the anti-aliased modes.
|
||||
ImGuiFreeTypeLoaderFlags_NoAutoHint = 1 << 1, // Disable auto-hinter.
|
||||
ImGuiFreeTypeLoaderFlags_ForceAutoHint = 1 << 2, // Indicates that the auto-hinter is preferred over the font's native hinter.
|
||||
ImGuiFreeTypeLoaderFlags_LightHinting = 1 << 3, // A lighter hinting algorithm for gray-level modes. Many generated glyphs are fuzzier but better resemble their original shape. This is achieved by snapping glyphs to the pixel grid only vertically (Y-axis), as is done by Microsoft's ClearType and Adobe's proprietary font renderer. This preserves inter-glyph spacing in horizontal text.
|
||||
ImGuiFreeTypeLoaderFlags_MonoHinting = 1 << 4, // Strong hinting algorithm that should only be used for monochrome output.
|
||||
ImGuiFreeTypeLoaderFlags_Bold = 1 << 5, // Styling: Should we artificially embolden the font?
|
||||
ImGuiFreeTypeLoaderFlags_Oblique = 1 << 6, // Styling: Should we slant the font, emulating italic style?
|
||||
ImGuiFreeTypeLoaderFlags_Monochrome = 1 << 7, // Disable anti-aliasing. Combine this with MonoHinting for best results!
|
||||
ImGuiFreeTypeLoaderFlags_LoadColor = 1 << 8, // Enable FreeType color-layered glyphs
|
||||
ImGuiFreeTypeLoaderFlags_Bitmap = 1 << 9, // Enable FreeType bitmap glyphs
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
ImGuiFreeTypeBuilderFlags_NoHinting = ImGuiFreeTypeLoaderFlags_NoHinting,
|
||||
ImGuiFreeTypeBuilderFlags_NoAutoHint = ImGuiFreeTypeLoaderFlags_NoAutoHint,
|
||||
ImGuiFreeTypeBuilderFlags_ForceAutoHint = ImGuiFreeTypeLoaderFlags_ForceAutoHint,
|
||||
ImGuiFreeTypeBuilderFlags_LightHinting = ImGuiFreeTypeLoaderFlags_LightHinting,
|
||||
ImGuiFreeTypeBuilderFlags_MonoHinting = ImGuiFreeTypeLoaderFlags_MonoHinting,
|
||||
ImGuiFreeTypeBuilderFlags_Bold = ImGuiFreeTypeLoaderFlags_Bold,
|
||||
ImGuiFreeTypeBuilderFlags_Oblique = ImGuiFreeTypeLoaderFlags_Oblique,
|
||||
ImGuiFreeTypeBuilderFlags_Monochrome = ImGuiFreeTypeLoaderFlags_Monochrome,
|
||||
ImGuiFreeTypeBuilderFlags_LoadColor = ImGuiFreeTypeLoaderFlags_LoadColor,
|
||||
ImGuiFreeTypeBuilderFlags_Bitmap = ImGuiFreeTypeLoaderFlags_Bitmap,
|
||||
#endif
|
||||
};
|
||||
|
||||
// Obsolete names (will be removed)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
typedef ImGuiFreeTypeLoaderFlags_ ImGuiFreeTypeBuilderFlags_;
|
||||
#endif
|
||||
|
||||
namespace ImGuiFreeType
|
||||
{
|
||||
// This is automatically assigned when using '#define IMGUI_ENABLE_FREETYPE'.
|
||||
// If you need to dynamically select between multiple builders:
|
||||
// - you can manually assign this builder with 'atlas->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType()'
|
||||
// - prefer deep-copying this into your own ImFontBuilderIO instance if you use hot-reloading that messes up static data.
|
||||
IMGUI_API const ImFontBuilderIO* GetBuilderForFreeType();
|
||||
// - you can manually assign this builder with 'atlas->SetFontLoader(ImGuiFreeType::GetFontLoader())'
|
||||
// - prefer deep-copying this into your own ImFontLoader instance if you use hot-reloading that messes up static data.
|
||||
IMGUI_API const ImFontLoader* GetFontLoader();
|
||||
|
||||
// Override allocators. By default ImGuiFreeType will use IM_ALLOC()/IM_FREE()
|
||||
// However, as FreeType does lots of allocations we provide a way for the user to redirect it to a separate memory heap if desired.
|
||||
IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = nullptr);
|
||||
|
||||
// Obsolete names (will be removed soon)
|
||||
// Display UI to edit ImFontAtlas::FontLoaderFlags (shared) or ImFontConfig::FontLoaderFlags (single source)
|
||||
IMGUI_API bool DebugEditFontLoaderFlags(ImGuiFreeTypeLoaderFlags* p_font_loader_flags);
|
||||
|
||||
// Obsolete names (will be removed)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//static inline bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int flags = 0) { atlas->FontBuilderIO = GetBuilderForFreeType(); atlas->FontBuilderFlags = flags; return atlas->Build(); } // Prefer using '#define IMGUI_ENABLE_FREETYPE'
|
||||
//IMGUI_API const ImFontBuilderIO* GetBuilderForFreeType(); // Renamed/changed in 1.92. Change 'io.Fonts->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType()' to 'io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader())' if you need runtime selection.
|
||||
//static inline bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int flags = 0) { atlas->FontBuilderIO = GetBuilderForFreeType(); atlas->FontLoaderFlags = flags; return atlas->Build(); } // Prefer using '#define IMGUI_ENABLE_FREETYPE'
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
// This needs to be used along with a Platform Backend (e.g. Win32)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||
// [X] Renderer: IMGUI_USE_BGRA_PACKED_COLOR support, as this is the optimal color encoding for DirectX9.
|
||||
|
||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||
@@ -16,6 +17,9 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2026-03-19: Fixed issue in ImGui_ImplDX9_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295, #9310)
|
||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||
// 2025-06-11: DirectX9: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
||||
// 2024-10-07: DirectX9: Changed default texture sampler to Clamp instead of Repeat/Wrap.
|
||||
// 2024-02-12: DirectX9: Using RGBA format when supported by the driver to avoid CPU side conversion. (#6575)
|
||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||
@@ -44,13 +48,18 @@
|
||||
// DirectX
|
||||
#include <d3d9.h>
|
||||
|
||||
// Clang/GCC warnings with -Weverything
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse.
|
||||
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
|
||||
#endif
|
||||
|
||||
// DirectX data
|
||||
struct ImGui_ImplDX9_Data
|
||||
{
|
||||
LPDIRECT3DDEVICE9 pd3dDevice;
|
||||
LPDIRECT3DVERTEXBUFFER9 pVB;
|
||||
LPDIRECT3DINDEXBUFFER9 pIB;
|
||||
LPDIRECT3DTEXTURE9 FontTexture;
|
||||
int VertexBufferSize;
|
||||
int IndexBufferSize;
|
||||
bool HasRgbaSupport;
|
||||
@@ -163,6 +172,13 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
||||
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||
LPDIRECT3DDEVICE9 device = bd->pd3dDevice;
|
||||
|
||||
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
|
||||
// (This almost always points to ImGui::GetPlatformIO().Textures[] but is part of ImDrawData to allow overriding or disabling texture updates).
|
||||
if (draw_data->Textures != nullptr)
|
||||
for (ImTextureData* tex : *draw_data->Textures)
|
||||
if (tex->Status != ImTextureStatus_OK)
|
||||
ImGui_ImplDX9_UpdateTexture(tex);
|
||||
|
||||
// Create and grow buffers if needed
|
||||
if (!bd->pVB || bd->VertexBufferSize < draw_data->TotalVtxCount)
|
||||
{
|
||||
@@ -214,9 +230,8 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
||||
// FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and
|
||||
// 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
// 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; }
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||
{
|
||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
||||
const ImDrawVert* vtx_src = draw_list->VtxBuffer.Data;
|
||||
for (int i = 0; i < draw_list->VtxBuffer.Size; i++)
|
||||
{
|
||||
@@ -246,9 +261,8 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
||||
int global_vtx_offset = 0;
|
||||
int global_idx_offset = 0;
|
||||
ImVec2 clip_off = draw_data->DisplayPos;
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||
{
|
||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||
@@ -322,6 +336,10 @@ bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
||||
io.BackendRendererUserData = (void*)bd;
|
||||
io.BackendRendererName = "imgui_impl_dx9";
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Renderer_TextureMaxWidth = platform_io.Renderer_TextureMaxHeight = 4096;
|
||||
|
||||
bd->pd3dDevice = device;
|
||||
bd->pd3dDevice->AddRef();
|
||||
@@ -335,17 +353,20 @@ void ImGui_ImplDX9_Shutdown()
|
||||
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
|
||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||
|
||||
io.BackendRendererName = nullptr;
|
||||
io.BackendRendererUserData = nullptr;
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
||||
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
||||
platform_io.ClearRendererHandlers();
|
||||
IM_DELETE(bd);
|
||||
}
|
||||
|
||||
// Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices)
|
||||
static void ImGui_ImplDX9_CopyTextureRegion(bool tex_use_colors, ImU32* src, int src_pitch, ImU32* dst, int dst_pitch, int w, int h)
|
||||
static void ImGui_ImplDX9_CopyTextureRegion(bool tex_use_colors, const ImU32* src, int src_pitch, ImU32* dst, int dst_pitch, int w, int h)
|
||||
{
|
||||
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
||||
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||
@@ -356,8 +377,8 @@ static void ImGui_ImplDX9_CopyTextureRegion(bool tex_use_colors, ImU32* src, int
|
||||
#endif
|
||||
for (int y = 0; y < h; y++)
|
||||
{
|
||||
ImU32* src_p = (ImU32*)((unsigned char*)src + src_pitch * y);
|
||||
ImU32* dst_p = (ImU32*)((unsigned char*)dst + dst_pitch * y);
|
||||
const ImU32* src_p = (const ImU32*)(const void*)((const unsigned char*)src + src_pitch * y);
|
||||
ImU32* dst_p = (ImU32*)(void*)((unsigned char*)dst + dst_pitch * y);
|
||||
if (convert_rgba_to_bgra)
|
||||
for (int x = w; x > 0; x--, src_p++, dst_p++) // Convert copy
|
||||
*dst_p = IMGUI_COL_TO_DX9_ARGB(*src_p);
|
||||
@@ -366,28 +387,62 @@ static void ImGui_ImplDX9_CopyTextureRegion(bool tex_use_colors, ImU32* src, int
|
||||
}
|
||||
}
|
||||
|
||||
static bool ImGui_ImplDX9_CreateFontsTexture()
|
||||
void ImGui_ImplDX9_UpdateTexture(ImTextureData* tex)
|
||||
{
|
||||
// Build texture atlas
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||
unsigned char* pixels;
|
||||
int width, height, bytes_per_pixel;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel);
|
||||
|
||||
// Upload texture to graphics system
|
||||
bd->FontTexture = nullptr;
|
||||
if (bd->pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, bd->HasRgbaSupport ? D3DFMT_A8B8G8R8 : D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bd->FontTexture, nullptr) < 0)
|
||||
return false;
|
||||
D3DLOCKED_RECT tex_locked_rect;
|
||||
if (bd->FontTexture->LockRect(0, &tex_locked_rect, nullptr, 0) != D3D_OK)
|
||||
return false;
|
||||
ImGui_ImplDX9_CopyTextureRegion(io.Fonts->TexPixelsUseColors, (ImU32*)pixels, width * bytes_per_pixel, (ImU32*)tex_locked_rect.pBits, (int)tex_locked_rect.Pitch, width, height);
|
||||
bd->FontTexture->UnlockRect(0);
|
||||
if (tex->Status == ImTextureStatus_WantCreate)
|
||||
{
|
||||
// Create and upload new texture to graphics system
|
||||
//IMGUI_DEBUG_LOG("UpdateTexture #%03d: WantCreate %dx%d\n", tex->UniqueID, tex->Width, tex->Height);
|
||||
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
||||
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
||||
LPDIRECT3DTEXTURE9 dx_tex = nullptr;
|
||||
HRESULT hr = bd->pd3dDevice->CreateTexture(tex->Width, tex->Height, 1, D3DUSAGE_DYNAMIC, bd->HasRgbaSupport ? D3DFMT_A8B8G8R8 : D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &dx_tex, nullptr);
|
||||
if (hr < 0)
|
||||
{
|
||||
IM_ASSERT(hr >= 0 && "Backend failed to create texture!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Store our identifier
|
||||
io.Fonts->SetTexID((ImTextureID)bd->FontTexture);
|
||||
return true;
|
||||
D3DLOCKED_RECT locked_rect;
|
||||
if (dx_tex->LockRect(0, &locked_rect, nullptr, 0) == D3D_OK)
|
||||
{
|
||||
ImGui_ImplDX9_CopyTextureRegion(tex->UseColors, (ImU32*)tex->GetPixels(), tex->Width * 4, (ImU32*)locked_rect.pBits, (ImU32)locked_rect.Pitch, tex->Width, tex->Height);
|
||||
dx_tex->UnlockRect(0);
|
||||
}
|
||||
|
||||
// Store identifiers
|
||||
tex->SetTexID((ImTextureID)(intptr_t)dx_tex);
|
||||
tex->SetStatus(ImTextureStatus_OK);
|
||||
}
|
||||
else if (tex->Status == ImTextureStatus_WantUpdates)
|
||||
{
|
||||
// Update selected blocks. We only ever write to textures regions which have never been used before!
|
||||
// This backend choose to use tex->Updates[] but you can use tex->UpdateRect to upload a single region.
|
||||
LPDIRECT3DTEXTURE9 backend_tex = (LPDIRECT3DTEXTURE9)(intptr_t)tex->TexID;
|
||||
RECT update_rect = { (LONG)tex->UpdateRect.x, (LONG)tex->UpdateRect.y, (LONG)(tex->UpdateRect.x + tex->UpdateRect.w), (LONG)(tex->UpdateRect.y + tex->UpdateRect.h) };
|
||||
D3DLOCKED_RECT locked_rect;
|
||||
if (backend_tex->LockRect(0, &locked_rect, &update_rect, 0) == D3D_OK)
|
||||
for (ImTextureRect& r : tex->Updates)
|
||||
ImGui_ImplDX9_CopyTextureRegion(tex->UseColors, (ImU32*)tex->GetPixelsAt(r.x, r.y), tex->Width * 4,
|
||||
(ImU32*)locked_rect.pBits + (r.x - update_rect.left) + (r.y - update_rect.top) * (locked_rect.Pitch / 4), (int)locked_rect.Pitch, r.w, r.h);
|
||||
backend_tex->UnlockRect(0);
|
||||
tex->SetStatus(ImTextureStatus_OK);
|
||||
}
|
||||
else if (tex->Status == ImTextureStatus_WantDestroy)
|
||||
{
|
||||
if (tex->TexID != ImTextureID_Invalid)
|
||||
if (LPDIRECT3DTEXTURE9 backend_tex = (LPDIRECT3DTEXTURE9)tex->TexID)
|
||||
{
|
||||
IM_ASSERT(tex->TexID == (ImTextureID)(intptr_t)backend_tex);
|
||||
backend_tex->Release();
|
||||
|
||||
// Clear identifiers and mark as destroyed (in order to allow e.g. calling InvalidateDeviceObjects while running)
|
||||
tex->SetTexID(ImTextureID_Invalid);
|
||||
}
|
||||
tex->SetStatus(ImTextureStatus_Destroyed);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGui_ImplDX9_CreateDeviceObjects()
|
||||
@@ -395,8 +450,6 @@ bool ImGui_ImplDX9_CreateDeviceObjects()
|
||||
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||
if (!bd || !bd->pd3dDevice)
|
||||
return false;
|
||||
if (!ImGui_ImplDX9_CreateFontsTexture())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -405,18 +458,23 @@ void ImGui_ImplDX9_InvalidateDeviceObjects()
|
||||
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||
if (!bd || !bd->pd3dDevice)
|
||||
return;
|
||||
|
||||
// Destroy all textures
|
||||
for (ImTextureData* tex : ImGui::GetPlatformIO().Textures)
|
||||
if (tex->RefCount == 1)
|
||||
{
|
||||
tex->SetStatus(ImTextureStatus_WantDestroy);
|
||||
ImGui_ImplDX9_UpdateTexture(tex);
|
||||
}
|
||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||
if (bd->FontTexture) { bd->FontTexture->Release(); bd->FontTexture = nullptr; ImGui::GetIO().Fonts->SetTexID(0); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||
}
|
||||
|
||||
void ImGui_ImplDX9_NewFrame()
|
||||
{
|
||||
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX9_Init()?");
|
||||
|
||||
if (!bd->FontTexture)
|
||||
ImGui_ImplDX9_CreateDeviceObjects();
|
||||
IM_UNUSED(bd);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
// This needs to be used along with a Platform Backend (e.g. Win32)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||
// [X] Renderer: IMGUI_USE_BGRA_PACKED_COLOR support, as this is the optimal color encoding for DirectX9.
|
||||
|
||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||
@@ -30,4 +31,7 @@ IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data);
|
||||
IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects();
|
||||
IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||
|
||||
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
|
||||
IMGUI_IMPL_API void ImGui_ImplDX9_UpdateTexture(ImTextureData* tex);
|
||||
|
||||
#endif // #ifndef IMGUI_DISABLE
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
|
||||
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen.
|
||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values are obsolete since 1.87 and not supported since 1.91.5]
|
||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
// [X] Platform: Gamepad support.
|
||||
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||
|
||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||
@@ -21,6 +21,14 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2026-01-28: Inputs: Minor optimization not submitting gamepad input if packet number has not changed (reworked from 2025-09-23 attempt). (#9202, #8556)
|
||||
// 2025-12-03: Inputs: handle WM_IME_CHAR/WM_IME_COMPOSITION messages to support Unicode inputs on MBCS (non-Unicode) Windows. (#9099, #3653, #5961)
|
||||
// 2025-10-19: Inputs: Revert previous change to allow for io.ClearInputKeys() on focus-out not losing gamepad state.
|
||||
// 2025-09-23: Inputs: Minor optimization not submitting gamepad input if packet number has not changed.
|
||||
// 2025-09-18: Call platform_io.ClearPlatformHandlers() on shutdown.
|
||||
// 2025-04-30: Inputs: Fixed an issue where externally losing mouse capture (due to e.g. focus loss) would fail to claim it again the next subsequent click. (#8594)
|
||||
// 2025-03-10: When dealing with OEM keys, use scancodes instead of translated keycodes to choose ImGuiKey values. (#7136, #7201, #7206, #7306, #7670, #7672, #8468)
|
||||
// 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support.
|
||||
// 2024-07-08: Inputs: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN. (#7768)
|
||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||
// 2023-09-25: Inputs: Synthesize key-down event on key-up for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit it (same behavior as GLFW/SDL).
|
||||
@@ -120,6 +128,7 @@ struct ImGui_ImplWin32_Data
|
||||
HMODULE XInputDLL;
|
||||
PFN_XInputGetCapabilities XInputGetCapabilities;
|
||||
PFN_XInputGetState XInputGetState;
|
||||
DWORD XInputPacketNumber;
|
||||
#endif
|
||||
|
||||
ImGui_ImplWin32_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||
@@ -174,7 +183,7 @@ static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
|
||||
bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
|
||||
ImGui_ImplWin32_UpdateKeyboardCodePage(io);
|
||||
|
||||
// Set platform dependent data in viewport
|
||||
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (void*)bd->hWnd;
|
||||
IM_UNUSED(platform_has_own_dc); // Used in 'docking' branch
|
||||
@@ -190,7 +199,7 @@ static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
|
||||
"xinput1_2.dll", // DirectX SDK
|
||||
"xinput1_1.dll" // DirectX SDK
|
||||
};
|
||||
for (int n = 0; n < IM_ARRAYSIZE(xinput_dll_names); n++)
|
||||
for (int n = 0; n < IM_COUNTOF(xinput_dll_names); n++)
|
||||
if (HMODULE dll = ::LoadLibraryA(xinput_dll_names[n]))
|
||||
{
|
||||
bd->XInputDLL = dll;
|
||||
@@ -219,6 +228,7 @@ void ImGui_ImplWin32_Shutdown()
|
||||
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
|
||||
// Unload XInput library
|
||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||
@@ -229,6 +239,7 @@ void ImGui_ImplWin32_Shutdown()
|
||||
io.BackendPlatformName = nullptr;
|
||||
io.BackendPlatformUserData = nullptr;
|
||||
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad);
|
||||
platform_io.ClearPlatformHandlers();
|
||||
IM_DELETE(bd);
|
||||
}
|
||||
|
||||
@@ -256,6 +267,8 @@ static bool ImGui_ImplWin32_UpdateMouseCursor(ImGuiIO& io, ImGuiMouseCursor imgu
|
||||
case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
|
||||
case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
|
||||
case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break;
|
||||
case ImGuiMouseCursor_Wait: win32_cursor = IDC_WAIT; break;
|
||||
case ImGuiMouseCursor_Progress: win32_cursor = IDC_APPSTARTING; break;
|
||||
case ImGuiMouseCursor_NotAllowed: win32_cursor = IDC_NO; break;
|
||||
}
|
||||
::SetCursor(::LoadCursor(nullptr, win32_cursor));
|
||||
@@ -331,8 +344,6 @@ static void ImGui_ImplWin32_UpdateGamepads(ImGuiIO& io)
|
||||
{
|
||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData(io);
|
||||
//if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
||||
// return;
|
||||
|
||||
// Calling XInputGetState() every frame on disconnected gamepads is unfortunately too slow.
|
||||
// Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE.
|
||||
@@ -349,6 +360,9 @@ static void ImGui_ImplWin32_UpdateGamepads(ImGuiIO& io)
|
||||
if (!bd->HasGamepad || bd->XInputGetState == nullptr || bd->XInputGetState(0, &xinput_state) != ERROR_SUCCESS)
|
||||
return;
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||
if (bd->XInputPacketNumber != 0 && bd->XInputPacketNumber == xinput_state.dwPacketNumber)
|
||||
return;
|
||||
bd->XInputPacketNumber = xinput_state.dwPacketNumber;
|
||||
|
||||
#define IM_SATURATE(V) (V < 0.0f ? 0.0f : V > 1.0f ? 1.0f : V)
|
||||
#define MAP_BUTTON(KEY_NO, BUTTON_ENUM) { io.AddKeyEvent(KEY_NO, (gamepad.wButtons & BUTTON_ENUM) != 0); }
|
||||
@@ -428,6 +442,8 @@ ImGuiKey ImGui_ImplWin32_KeyEventToImGuiKey(WPARAM wParam, LPARAM lParam)
|
||||
if ((wParam == VK_RETURN) && (HIWORD(lParam) & KF_EXTENDED))
|
||||
return ImGuiKey_KeypadEnter;
|
||||
|
||||
const int scancode = (int)LOBYTE(HIWORD(lParam));
|
||||
//IMGUI_DEBUG_LOG("scancode %3d, keycode = 0x%02X\n", scancode, wParam);
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_TAB: return ImGuiKey_Tab;
|
||||
@@ -445,17 +461,17 @@ ImGuiKey ImGui_ImplWin32_KeyEventToImGuiKey(WPARAM wParam, LPARAM lParam)
|
||||
case VK_SPACE: return ImGuiKey_Space;
|
||||
case VK_RETURN: return ImGuiKey_Enter;
|
||||
case VK_ESCAPE: return ImGuiKey_Escape;
|
||||
case VK_OEM_7: return ImGuiKey_Apostrophe;
|
||||
//case VK_OEM_7: return ImGuiKey_Apostrophe;
|
||||
case VK_OEM_COMMA: return ImGuiKey_Comma;
|
||||
case VK_OEM_MINUS: return ImGuiKey_Minus;
|
||||
//case VK_OEM_MINUS: return ImGuiKey_Minus;
|
||||
case VK_OEM_PERIOD: return ImGuiKey_Period;
|
||||
case VK_OEM_2: return ImGuiKey_Slash;
|
||||
case VK_OEM_1: return ImGuiKey_Semicolon;
|
||||
case VK_OEM_PLUS: return ImGuiKey_Equal;
|
||||
case VK_OEM_4: return ImGuiKey_LeftBracket;
|
||||
case VK_OEM_5: return ImGuiKey_Backslash;
|
||||
case VK_OEM_6: return ImGuiKey_RightBracket;
|
||||
case VK_OEM_3: return ImGuiKey_GraveAccent;
|
||||
//case VK_OEM_2: return ImGuiKey_Slash;
|
||||
//case VK_OEM_1: return ImGuiKey_Semicolon;
|
||||
//case VK_OEM_PLUS: return ImGuiKey_Equal;
|
||||
//case VK_OEM_4: return ImGuiKey_LeftBracket;
|
||||
//case VK_OEM_5: return ImGuiKey_Backslash;
|
||||
//case VK_OEM_6: return ImGuiKey_RightBracket;
|
||||
//case VK_OEM_3: return ImGuiKey_GraveAccent;
|
||||
case VK_CAPITAL: return ImGuiKey_CapsLock;
|
||||
case VK_SCROLL: return ImGuiKey_ScrollLock;
|
||||
case VK_NUMLOCK: return ImGuiKey_NumLock;
|
||||
@@ -547,8 +563,29 @@ ImGuiKey ImGui_ImplWin32_KeyEventToImGuiKey(WPARAM wParam, LPARAM lParam)
|
||||
case VK_F24: return ImGuiKey_F24;
|
||||
case VK_BROWSER_BACK: return ImGuiKey_AppBack;
|
||||
case VK_BROWSER_FORWARD: return ImGuiKey_AppForward;
|
||||
default: return ImGuiKey_None;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// Fallback to scancode
|
||||
// https://handmade.network/forums/t/2011-keyboard_inputs_-_scancodes,_raw_input,_text_input,_key_names
|
||||
switch (scancode)
|
||||
{
|
||||
case 41: return ImGuiKey_GraveAccent; // VK_OEM_8 in EN-UK, VK_OEM_3 in EN-US, VK_OEM_7 in FR, VK_OEM_5 in DE, etc.
|
||||
case 12: return ImGuiKey_Minus;
|
||||
case 13: return ImGuiKey_Equal;
|
||||
case 26: return ImGuiKey_LeftBracket;
|
||||
case 27: return ImGuiKey_RightBracket;
|
||||
case 86: return ImGuiKey_Oem102;
|
||||
case 43: return ImGuiKey_Backslash;
|
||||
case 39: return ImGuiKey_Semicolon;
|
||||
case 40: return ImGuiKey_Apostrophe;
|
||||
case 51: return ImGuiKey_Comma;
|
||||
case 52: return ImGuiKey_Period;
|
||||
case 53: return ImGuiKey_Slash;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return ImGuiKey_None;
|
||||
}
|
||||
|
||||
// Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions.
|
||||
@@ -618,8 +655,8 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandlerEx(HWND hwnd, UINT msg, WPA
|
||||
bd->MouseTrackedArea = area;
|
||||
}
|
||||
POINT mouse_pos = { (LONG)GET_X_LPARAM(lParam), (LONG)GET_Y_LPARAM(lParam) };
|
||||
if (msg == WM_NCMOUSEMOVE && ::ScreenToClient(hwnd, &mouse_pos) == FALSE) // WM_NCMOUSEMOVE are provided in absolute coordinates.
|
||||
return 0;
|
||||
if (msg == WM_NCMOUSEMOVE) // WM_NCMOUSEMOVE are absolute coordinates.
|
||||
::ScreenToClient(hwnd, &mouse_pos);
|
||||
io.AddMouseSourceEvent(mouse_source);
|
||||
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
|
||||
return 0;
|
||||
@@ -658,7 +695,10 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandlerEx(HWND hwnd, UINT msg, WPA
|
||||
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; }
|
||||
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
|
||||
if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
||||
if (bd->MouseButtonsDown == 0 && ::GetCapture() == nullptr)
|
||||
HWND hwnd_with_capture = ::GetCapture();
|
||||
if (bd->MouseButtonsDown != 0 && hwnd_with_capture != hwnd) // Did we externally lost capture?
|
||||
bd->MouseButtonsDown = 0;
|
||||
if (bd->MouseButtonsDown == 0 && hwnd_with_capture == nullptr)
|
||||
::SetCapture(hwnd); // Allow us to read mouse coordinates when dragging mouse outside of our window bounds.
|
||||
bd->MouseButtonsDown |= 1 << button;
|
||||
io.AddMouseSourceEvent(mouse_source);
|
||||
@@ -736,6 +776,9 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandlerEx(HWND hwnd, UINT msg, WPA
|
||||
case WM_SETFOCUS:
|
||||
case WM_KILLFOCUS:
|
||||
io.AddFocusEvent(msg == WM_SETFOCUS);
|
||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||
bd->XInputPacketNumber = 0; // FIXME: Technically, calling io.ClearInputKeys() directly would require this as well.
|
||||
#endif
|
||||
return 0;
|
||||
case WM_INPUTLANGCHANGE:
|
||||
ImGui_ImplWin32_UpdateKeyboardCodePage(io);
|
||||
@@ -750,10 +793,28 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandlerEx(HWND hwnd, UINT msg, WPA
|
||||
else
|
||||
{
|
||||
wchar_t wch = 0;
|
||||
::MultiByteToWideChar(bd->KeyboardCodePage, MB_PRECOMPOSED, (char*)&wParam, 1, &wch, 1);
|
||||
::MultiByteToWideChar(bd->KeyboardCodePage, MB_PRECOMPOSED, (char*)&wParam, 2, &wch, 1);
|
||||
io.AddInputCharacter(wch);
|
||||
}
|
||||
return 0;
|
||||
case WM_IME_COMPOSITION:
|
||||
{
|
||||
// Handling WM_IME_COMPOSITION ensure that WM_IME_CHAR value is correct even for MBCS apps.
|
||||
// (see #9099, #3653 and https://stackoverflow.com/questions/77450354 topics)
|
||||
LRESULT result = ::DefWindowProcW(hwnd, msg, wParam, lParam);
|
||||
return (lParam & GCS_RESULTSTR) ? 1 : result;
|
||||
}
|
||||
case WM_IME_CHAR:
|
||||
if (::IsWindowUnicode(hwnd) == FALSE)
|
||||
{
|
||||
if (::IsDBCSLeadByte(HIBYTE(wParam)))
|
||||
wParam = (WPARAM)MAKEWORD(HIBYTE(wParam), LOBYTE(wParam));
|
||||
wchar_t wch = 0;
|
||||
::MultiByteToWideChar(bd->KeyboardCodePage, MB_PRECOMPOSED, (char*)&wParam, 2, &wch, 1);
|
||||
io.AddInputCharacterUTF16(wch);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
case WM_SETCURSOR:
|
||||
// This is required to restore cursor when transitioning from e.g resize borders to client area.
|
||||
if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor(io, bd->LastMouseCursor))
|
||||
@@ -777,7 +838,7 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandlerEx(HWND hwnd, UINT msg, WPA
|
||||
// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps.
|
||||
// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc.
|
||||
// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime,
|
||||
// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
|
||||
// neither of which we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
// This is the scheme successfully used by GLFW (from which we borrowed some of the code) and other apps aiming to be highly portable.
|
||||
// ImGui_ImplWin32_EnableDpiAwareness() is just a helper called by main.cpp, we don't call it automatically.
|
||||
@@ -790,9 +851,9 @@ static BOOL _IsWindowsVersionOrGreater(WORD major, WORD minor, WORD)
|
||||
{
|
||||
typedef LONG(WINAPI* PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*, ULONG, ULONGLONG);
|
||||
static PFN_RtlVerifyVersionInfo RtlVerifyVersionInfoFn = nullptr;
|
||||
if (RtlVerifyVersionInfoFn == nullptr)
|
||||
if (HMODULE ntdllModule = ::GetModuleHandleA("ntdll.dll"))
|
||||
RtlVerifyVersionInfoFn = (PFN_RtlVerifyVersionInfo)GetProcAddress(ntdllModule, "RtlVerifyVersionInfo");
|
||||
if (RtlVerifyVersionInfoFn == nullptr)
|
||||
if (HMODULE ntdllModule = ::GetModuleHandleA("ntdll.dll"))
|
||||
RtlVerifyVersionInfoFn = (PFN_RtlVerifyVersionInfo)GetProcAddress(ntdllModule, "RtlVerifyVersionInfo");
|
||||
if (RtlVerifyVersionInfoFn == nullptr)
|
||||
return FALSE;
|
||||
|
||||
@@ -800,10 +861,10 @@ static BOOL _IsWindowsVersionOrGreater(WORD major, WORD minor, WORD)
|
||||
ULONGLONG conditionMask = 0;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
|
||||
versionInfo.dwMajorVersion = major;
|
||||
versionInfo.dwMinorVersion = minor;
|
||||
VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
||||
VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||
return (RtlVerifyVersionInfoFn(&versionInfo, VER_MAJORVERSION | VER_MINORVERSION, conditionMask) == 0) ? TRUE : FALSE;
|
||||
versionInfo.dwMinorVersion = minor;
|
||||
VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
||||
VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||
return (RtlVerifyVersionInfoFn(&versionInfo, VER_MAJORVERSION | VER_MINORVERSION, conditionMask) == 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
#define _IsWindowsVistaOrGreater() _IsWindowsVersionOrGreater(HIBYTE(0x0600), LOBYTE(0x0600), 0) // _WIN32_WINNT_VISTA
|
||||
@@ -861,16 +922,16 @@ float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
|
||||
UINT xdpi = 96, ydpi = 96;
|
||||
if (_IsWindows8Point1OrGreater())
|
||||
{
|
||||
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
||||
static PFN_GetDpiForMonitor GetDpiForMonitorFn = nullptr;
|
||||
if (GetDpiForMonitorFn == nullptr && shcore_dll != nullptr)
|
||||
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
||||
static PFN_GetDpiForMonitor GetDpiForMonitorFn = nullptr;
|
||||
if (GetDpiForMonitorFn == nullptr && shcore_dll != nullptr)
|
||||
GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor");
|
||||
if (GetDpiForMonitorFn != nullptr)
|
||||
{
|
||||
GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
|
||||
if (GetDpiForMonitorFn != nullptr)
|
||||
{
|
||||
GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
|
||||
IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
|
||||
return xdpi / 96.0f;
|
||||
}
|
||||
return xdpi / 96.0f;
|
||||
}
|
||||
}
|
||||
#ifndef NOGDI
|
||||
const HDC dc = ::GetDC(nullptr);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
|
||||
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen.
|
||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values are obsolete since 1.87 and not supported since 1.91.5]
|
||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
// [X] Platform: Gamepad support.
|
||||
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||
|
||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||
@@ -26,7 +26,7 @@ IMGUI_IMPL_API bool ImGui_ImplWin32_InitForOpenGL(void* hwnd);
|
||||
IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
|
||||
|
||||
// Win32 message handler your application need to call.
|
||||
// Win32 message handler your application needs to call.
|
||||
// - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on <windows.h> from this helper.
|
||||
// - You should COPY the line below into your .cpp code to forward declare the function and then you can call it.
|
||||
// - Call from your application's message handler. Keep calling your message handler unless this function returns TRUE.
|
||||
@@ -40,7 +40,7 @@ extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg
|
||||
// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps.
|
||||
// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc.
|
||||
// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime,
|
||||
// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
|
||||
// neither of which we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
|
||||
IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness();
|
||||
IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd
|
||||
IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,22 @@
|
||||
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
|
||||
|
||||
// This is also an example of how you may wrap your own similar types.
|
||||
// TL;DR; this is using the ImGuiInputTextFlags_CallbackResize facility,
|
||||
// which also demonstrated in 'Dear ImGui Demo->Widgets->Text Input->Resize Callback'.
|
||||
|
||||
// Changelog:
|
||||
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
|
||||
|
||||
// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
|
||||
// Usage:
|
||||
// {
|
||||
// #include "misc/cpp/imgui_stdlib.h"
|
||||
// #include "misc/cpp/imgui_stdlib.cpp" // <-- If you want to include implementation without messing with your project/build.
|
||||
// [...]
|
||||
// std::string my_string;
|
||||
// ImGui::InputText("my string", &my_string);
|
||||
// }
|
||||
|
||||
// See more C++ related extension (fmt, RAII, syntactic sugar) on Wiki:
|
||||
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
|
||||
|
||||
// This is also an example of how you may wrap your own similar types.
|
||||
// TL;DR; this is using the ImGuiInputTextFlags_CallbackResize facility,
|
||||
// which also demonstrated in 'Dear ImGui Demo->Widgets->Text Input->Resize Callback'.
|
||||
|
||||
// Changelog:
|
||||
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
|
||||
|
||||
// Usage:
|
||||
// {
|
||||
// #include "misc/cpp/imgui_stdlib.h"
|
||||
// #include "misc/cpp/imgui_stdlib.cpp" // <-- If you want to include implementation without messing with your project/build.
|
||||
// [...]
|
||||
// std::string my_string;
|
||||
// ImGui::InputText("my string", &my_string);
|
||||
// }
|
||||
|
||||
// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
|
||||
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1216
-778
File diff suppressed because it is too large
Load Diff
@@ -315,7 +315,7 @@ static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0
|
||||
if (node->y > min_y) {
|
||||
// raise min_y higher.
|
||||
// we've accounted for all waste up to min_y,
|
||||
// but we'll now add more waste for everything we've visted
|
||||
// but we'll now add more waste for everything we've visited
|
||||
waste_area += visited_width * (node->y - min_y);
|
||||
min_y = node->y;
|
||||
// the first time through, visited_width might be reduced
|
||||
@@ -470,7 +470,7 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i
|
||||
|
||||
// insert the new node into the right starting point, and
|
||||
// let 'cur' point to the remaining nodes needing to be
|
||||
// stiched back in
|
||||
// stitched back in
|
||||
|
||||
cur = *res.prev_link;
|
||||
if (cur->x < res.x) {
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
// - Fix in stb_textedit_find_charpos to handle last line (see https://github.com/ocornut/imgui/issues/6000 + #6783)
|
||||
// - Added name to struct or it may be forward declared in our code.
|
||||
// - Added UTF-8 support (see https://github.com/nothings/stb/issues/188 + https://github.com/ocornut/imgui/pull/7925)
|
||||
// Grep for [DEAR IMGUI] to find the changes.
|
||||
// - Changed STB_TEXTEDIT_INSERTCHARS() to return inserted count (instead of 0/1 bool), allowing partial insertion.
|
||||
// Grep for [DEAR IMGUI] to find some changes.
|
||||
// - Also renamed macros used or defined outside of IMSTB_TEXTEDIT_IMPLEMENTATION block from STB_TEXTEDIT_* to IMSTB_TEXTEDIT_*
|
||||
|
||||
// stb_textedit.h - v1.14 - public domain - Sean Barrett
|
||||
@@ -39,6 +40,7 @@
|
||||
//
|
||||
// VERSION HISTORY
|
||||
//
|
||||
// !!!! (2025-10-23) changed STB_TEXTEDIT_INSERTCHARS() to return inserted count (instead of 0/1 bool), allowing partial insertion.
|
||||
// 1.14 (2021-07-11) page up/down, various fixes
|
||||
// 1.13 (2019-02-07) fix bug in undo size management
|
||||
// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash
|
||||
@@ -141,12 +143,14 @@
|
||||
// with previous char)
|
||||
// STB_TEXTEDIT_KEYTOTEXT(k) maps a keyboard input to an insertable character
|
||||
// (return type is int, -1 means not valid to insert)
|
||||
// (not supported if you want to use UTF-8, see below)
|
||||
// STB_TEXTEDIT_GETCHAR(obj,i) returns the i'th character of obj, 0-based
|
||||
// STB_TEXTEDIT_NEWLINE the character returned by _GETCHAR() we recognize
|
||||
// as manually wordwrapping for end-of-line positioning
|
||||
//
|
||||
// STB_TEXTEDIT_DELETECHARS(obj,i,n) delete n characters starting at i
|
||||
// STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*)
|
||||
// STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) try to insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*)
|
||||
// returns number of characters actually inserted. [DEAR IMGUI]
|
||||
//
|
||||
// STB_TEXTEDIT_K_SHIFT a power of two that is or'd in to a keyboard input to represent the shift key
|
||||
//
|
||||
@@ -178,6 +182,13 @@
|
||||
// STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text
|
||||
// STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text
|
||||
//
|
||||
// To support UTF-8:
|
||||
//
|
||||
// STB_TEXTEDIT_GETPREVCHARINDEX returns index of previous character
|
||||
// STB_TEXTEDIT_GETNEXTCHARINDEX returns index of next character
|
||||
// Do NOT define STB_TEXTEDIT_KEYTOTEXT.
|
||||
// Instead, call stb_textedit_text() directly for text contents.
|
||||
//
|
||||
// Keyboard input must be encoded as a single integer value; e.g. a character code
|
||||
// and some bitflags that represent shift states. to simplify the interface, SHIFT must
|
||||
// be a bitflag, so we can test the shifted state of cursor movements to allow selection,
|
||||
@@ -250,8 +261,10 @@
|
||||
// if the STB_TEXTEDIT_KEYTOTEXT function is defined, selected keys are
|
||||
// transformed into text and stb_textedit_text() is automatically called.
|
||||
//
|
||||
// text: [DEAR IMGUI] added 2024-09
|
||||
// call this to text inputs sent to the textfield.
|
||||
// text: (added 2025)
|
||||
// call this to directly send text input the textfield, which is required
|
||||
// for UTF-8 support, because stb_textedit_key() + STB_TEXTEDIT_KEYTOTEXT()
|
||||
// cannot infer text length.
|
||||
//
|
||||
//
|
||||
// When rendering, you can read the cursor position and selection state from
|
||||
@@ -400,6 +413,16 @@ typedef struct
|
||||
#define IMSTB_TEXTEDIT_memmove memmove
|
||||
#endif
|
||||
|
||||
// [DEAR IMGUI]
|
||||
// Functions must be implemented for UTF8 support
|
||||
// Code in this file that uses those functions is modified for [DEAR IMGUI] and deviates from the original stb_textedit.
|
||||
// There is not necessarily a '[DEAR IMGUI]' at the usage sites.
|
||||
#ifndef IMSTB_TEXTEDIT_GETPREVCHARINDEX
|
||||
#define IMSTB_TEXTEDIT_GETPREVCHARINDEX(OBJ, IDX) ((IDX) - 1)
|
||||
#endif
|
||||
#ifndef IMSTB_TEXTEDIT_GETNEXTCHARINDEX
|
||||
#define IMSTB_TEXTEDIT_GETNEXTCHARINDEX(OBJ, IDX) ((IDX) + 1)
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -407,7 +430,7 @@ typedef struct
|
||||
//
|
||||
|
||||
// traverse the layout to locate the nearest character to a display position
|
||||
static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
||||
static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y, int* out_side_on_line)
|
||||
{
|
||||
StbTexteditRow r;
|
||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||
@@ -417,6 +440,7 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
||||
r.x0 = r.x1 = 0;
|
||||
r.ymin = r.ymax = 0;
|
||||
r.num_chars = 0;
|
||||
*out_side_on_line = 0;
|
||||
|
||||
// search rows to find one that straddles 'y'
|
||||
while (i < n) {
|
||||
@@ -436,7 +460,10 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
||||
|
||||
// below all text, return 'after' last character
|
||||
if (i >= n)
|
||||
{
|
||||
*out_side_on_line = 1;
|
||||
return n;
|
||||
}
|
||||
|
||||
// check if it's before the beginning of the line
|
||||
if (x < r.x0)
|
||||
@@ -449,6 +476,7 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
||||
for (k=0; k < r.num_chars; k = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, i + k) - i) {
|
||||
float w = STB_TEXTEDIT_GETWIDTH(str, i, k);
|
||||
if (x < prev_x+w) {
|
||||
*out_side_on_line = (k == 0) ? 0 : 1;
|
||||
if (x < prev_x+w/2)
|
||||
return k+i;
|
||||
else
|
||||
@@ -460,6 +488,7 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
||||
}
|
||||
|
||||
// if the last character is a newline, return that. otherwise return 'after' the last character
|
||||
*out_side_on_line = 1;
|
||||
if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE)
|
||||
return i+r.num_chars-1;
|
||||
else
|
||||
@@ -471,6 +500,7 @@ static void stb_textedit_click(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *st
|
||||
{
|
||||
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
|
||||
// goes off the top or bottom of the text
|
||||
int side_on_line;
|
||||
if( state->single_line )
|
||||
{
|
||||
StbTexteditRow r;
|
||||
@@ -478,16 +508,18 @@ static void stb_textedit_click(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *st
|
||||
y = r.ymin;
|
||||
}
|
||||
|
||||
state->cursor = stb_text_locate_coord(str, x, y);
|
||||
state->cursor = stb_text_locate_coord(str, x, y, &side_on_line);
|
||||
state->select_start = state->cursor;
|
||||
state->select_end = state->cursor;
|
||||
state->has_preferred_x = 0;
|
||||
str->LastMoveDirectionLR = (ImS8)(side_on_line ? ImGuiDir_Right : ImGuiDir_Left);
|
||||
}
|
||||
|
||||
// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location
|
||||
static void stb_textedit_drag(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
||||
{
|
||||
int p = 0;
|
||||
int side_on_line;
|
||||
|
||||
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
|
||||
// goes off the top or bottom of the text
|
||||
@@ -501,8 +533,9 @@ static void stb_textedit_drag(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *sta
|
||||
if (state->select_start == state->select_end)
|
||||
state->select_start = state->cursor;
|
||||
|
||||
p = stb_text_locate_coord(str, x, y);
|
||||
p = stb_text_locate_coord(str, x, y, &side_on_line);
|
||||
state->cursor = state->select_end = p;
|
||||
str->LastMoveDirectionLR = (ImS8)(side_on_line ? ImGuiDir_Right : ImGuiDir_Left);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -552,6 +585,8 @@ static void stb_textedit_find_charpos(StbFindState *find, IMSTB_TEXTEDIT_STRING
|
||||
STB_TEXTEDIT_LAYOUTROW(&r, str, i);
|
||||
if (n < i + r.num_chars)
|
||||
break;
|
||||
if (str->LastMoveDirectionLR == ImGuiDir_Right && str->Stb->cursor > 0 && str->Stb->cursor == i + r.num_chars && STB_TEXTEDIT_GETCHAR(str, i + r.num_chars - 1) != STB_TEXTEDIT_NEWLINE) // [DEAR IMGUI] Wrapping point handling
|
||||
break;
|
||||
if (i + r.num_chars == z && z > 0 && STB_TEXTEDIT_GETCHAR(str, z - 1) != STB_TEXTEDIT_NEWLINE) // [DEAR IMGUI] special handling for last line
|
||||
break; // [DEAR IMGUI]
|
||||
prev_start = i;
|
||||
@@ -648,15 +683,33 @@ static void stb_textedit_move_to_last(IMSTB_TEXTEDIT_STRING *str, STB_TexteditSt
|
||||
}
|
||||
}
|
||||
|
||||
// [DEAR IMGUI]
|
||||
// Functions must be implemented for UTF8 support
|
||||
// Code in this file that uses those functions is modified for [DEAR IMGUI] and deviates from the original stb_textedit.
|
||||
// There is not necessarily a '[DEAR IMGUI]' at the usage sites.
|
||||
#ifndef IMSTB_TEXTEDIT_GETPREVCHARINDEX
|
||||
#define IMSTB_TEXTEDIT_GETPREVCHARINDEX(obj, idx) (idx - 1)
|
||||
// [DEAR IMGUI] Extracted this function so we can more easily add support for word-wrapping.
|
||||
#ifndef STB_TEXTEDIT_MOVELINESTART
|
||||
static int stb_textedit_move_line_start(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int cursor)
|
||||
{
|
||||
if (state->single_line)
|
||||
return 0;
|
||||
while (cursor > 0) {
|
||||
int prev = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, cursor);
|
||||
if (STB_TEXTEDIT_GETCHAR(str, prev) == STB_TEXTEDIT_NEWLINE)
|
||||
break;
|
||||
cursor = prev;
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
#define STB_TEXTEDIT_MOVELINESTART stb_textedit_move_line_start
|
||||
#endif
|
||||
#ifndef IMSTB_TEXTEDIT_GETNEXTCHARINDEX
|
||||
#define IMSTB_TEXTEDIT_GETNEXTCHARINDEX(obj, idx) (idx + 1)
|
||||
#ifndef STB_TEXTEDIT_MOVELINEEND
|
||||
static int stb_textedit_move_line_end(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int cursor)
|
||||
{
|
||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||
if (state->single_line)
|
||||
return n;
|
||||
while (cursor < n && STB_TEXTEDIT_GETCHAR(str, cursor) != STB_TEXTEDIT_NEWLINE)
|
||||
cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, cursor);
|
||||
return cursor;
|
||||
}
|
||||
#define STB_TEXTEDIT_MOVELINEEND stb_textedit_move_line_end
|
||||
#endif
|
||||
|
||||
#ifdef STB_TEXTEDIT_IS_SPACE
|
||||
@@ -668,9 +721,9 @@ static int is_word_boundary( IMSTB_TEXTEDIT_STRING *str, int idx )
|
||||
#ifndef STB_TEXTEDIT_MOVEWORDLEFT
|
||||
static int stb_textedit_move_to_word_previous( IMSTB_TEXTEDIT_STRING *str, int c )
|
||||
{
|
||||
--c; // always move at least one character
|
||||
while( c >= 0 && !is_word_boundary( str, c ) )
|
||||
--c;
|
||||
c = IMSTB_TEXTEDIT_GETPREVCHARINDEX( str, c ); // always move at least one character
|
||||
while (c >= 0 && !is_word_boundary(str, c))
|
||||
c = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, c);
|
||||
|
||||
if( c < 0 )
|
||||
c = 0;
|
||||
@@ -684,9 +737,9 @@ static int stb_textedit_move_to_word_previous( IMSTB_TEXTEDIT_STRING *str, int c
|
||||
static int stb_textedit_move_to_word_next( IMSTB_TEXTEDIT_STRING *str, int c )
|
||||
{
|
||||
const int len = STB_TEXTEDIT_STRINGLEN(str);
|
||||
++c; // always move at least one character
|
||||
c = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, c); // always move at least one character
|
||||
while( c < len && !is_word_boundary( str, c ) )
|
||||
++c;
|
||||
c = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, c);
|
||||
|
||||
if( c > len )
|
||||
c = len;
|
||||
@@ -725,7 +778,8 @@ static int stb_textedit_paste_internal(IMSTB_TEXTEDIT_STRING *str, STB_TexteditS
|
||||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_delete_selection(str,state);
|
||||
// try to insert the characters
|
||||
if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) {
|
||||
len = STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len);
|
||||
if (len) {
|
||||
stb_text_makeundo_insert(state, state->cursor, len);
|
||||
state->cursor += len;
|
||||
state->has_preferred_x = 0;
|
||||
@@ -739,6 +793,7 @@ static int stb_textedit_paste_internal(IMSTB_TEXTEDIT_STRING *str, STB_TexteditS
|
||||
#define STB_TEXTEDIT_KEYTYPE int
|
||||
#endif
|
||||
|
||||
// API key: process text input
|
||||
// [DEAR IMGUI] Added stb_textedit_text(), extracted out and called by stb_textedit_key() for backward compatibility.
|
||||
static void stb_textedit_text(IMSTB_TEXTEDIT_STRING* str, STB_TexteditState* state, const IMSTB_TEXTEDIT_CHARTYPE* text, int text_len)
|
||||
{
|
||||
@@ -749,14 +804,15 @@ static void stb_textedit_text(IMSTB_TEXTEDIT_STRING* str, STB_TexteditState* sta
|
||||
if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) {
|
||||
stb_text_makeundo_replace(str, state, state->cursor, 1, 1);
|
||||
STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1);
|
||||
if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, text_len)) {
|
||||
text_len = STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, text_len);
|
||||
if (text_len) {
|
||||
state->cursor += text_len;
|
||||
state->has_preferred_x = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
stb_textedit_delete_selection(str, state); // implicitly clamps
|
||||
if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, text_len)) {
|
||||
text_len = STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, text_len);
|
||||
if (text_len) {
|
||||
stb_text_makeundo_insert(state, state->cursor, text_len);
|
||||
state->cursor += text_len;
|
||||
state->has_preferred_x = 0;
|
||||
@@ -771,6 +827,7 @@ retry:
|
||||
switch (key) {
|
||||
default: {
|
||||
#ifdef STB_TEXTEDIT_KEYTOTEXT
|
||||
// This is not suitable for UTF-8 support.
|
||||
int c = STB_TEXTEDIT_KEYTOTEXT(key);
|
||||
if (c > 0) {
|
||||
IMSTB_TEXTEDIT_CHARTYPE ch = (IMSTB_TEXTEDIT_CHARTYPE)c;
|
||||
@@ -911,15 +968,16 @@ retry:
|
||||
|
||||
// [DEAR IMGUI]
|
||||
// going down while being on the last line shouldn't bring us to that line end
|
||||
if (STB_TEXTEDIT_GETCHAR(str, find.first_char + find.length - 1) != STB_TEXTEDIT_NEWLINE)
|
||||
break;
|
||||
//if (STB_TEXTEDIT_GETCHAR(str, find.first_char + find.length - 1) != STB_TEXTEDIT_NEWLINE)
|
||||
// break;
|
||||
|
||||
// now find character position down a row
|
||||
state->cursor = start;
|
||||
STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
|
||||
x = row.x0;
|
||||
for (i=0; i < row.num_chars; ++i) {
|
||||
for (i=0; i < row.num_chars; ) {
|
||||
float dx = STB_TEXTEDIT_GETWIDTH(str, start, i);
|
||||
int next = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
|
||||
#ifdef IMSTB_TEXTEDIT_GETWIDTH_NEWLINE
|
||||
if (dx == IMSTB_TEXTEDIT_GETWIDTH_NEWLINE)
|
||||
break;
|
||||
@@ -927,10 +985,13 @@ retry:
|
||||
x += dx;
|
||||
if (x > goal_x)
|
||||
break;
|
||||
state->cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
|
||||
i += next - state->cursor;
|
||||
state->cursor = next;
|
||||
}
|
||||
stb_textedit_clamp(str, state);
|
||||
|
||||
if (state->cursor == find.first_char + find.length)
|
||||
str->LastMoveDirectionLR = ImGuiDir_Left;
|
||||
state->has_preferred_x = 1;
|
||||
state->preferred_x = goal_x;
|
||||
|
||||
@@ -980,8 +1041,9 @@ retry:
|
||||
state->cursor = find.prev_first;
|
||||
STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
|
||||
x = row.x0;
|
||||
for (i=0; i < row.num_chars; ++i) {
|
||||
for (i=0; i < row.num_chars; ) {
|
||||
float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i);
|
||||
int next = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
|
||||
#ifdef IMSTB_TEXTEDIT_GETWIDTH_NEWLINE
|
||||
if (dx == IMSTB_TEXTEDIT_GETWIDTH_NEWLINE)
|
||||
break;
|
||||
@@ -989,10 +1051,15 @@ retry:
|
||||
x += dx;
|
||||
if (x > goal_x)
|
||||
break;
|
||||
state->cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
|
||||
i += next - state->cursor;
|
||||
state->cursor = next;
|
||||
}
|
||||
stb_textedit_clamp(str, state);
|
||||
|
||||
if (state->cursor == find.first_char)
|
||||
str->LastMoveDirectionLR = ImGuiDir_Right;
|
||||
else if (state->cursor == find.prev_first)
|
||||
str->LastMoveDirectionLR = ImGuiDir_Left;
|
||||
state->has_preferred_x = 1;
|
||||
state->preferred_x = goal_x;
|
||||
|
||||
@@ -1002,10 +1069,15 @@ retry:
|
||||
// go to previous line
|
||||
// (we need to scan previous line the hard way. maybe we could expose this as a new API function?)
|
||||
prev_scan = find.prev_first > 0 ? find.prev_first - 1 : 0;
|
||||
while (prev_scan > 0 && STB_TEXTEDIT_GETCHAR(str, prev_scan - 1) != STB_TEXTEDIT_NEWLINE)
|
||||
--prev_scan;
|
||||
while (prev_scan > 0)
|
||||
{
|
||||
int prev = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, prev_scan);
|
||||
if (STB_TEXTEDIT_GETCHAR(str, prev) == STB_TEXTEDIT_NEWLINE)
|
||||
break;
|
||||
prev_scan = prev;
|
||||
}
|
||||
find.first_char = find.prev_first;
|
||||
find.prev_first = prev_scan;
|
||||
find.prev_first = STB_TEXTEDIT_MOVELINESTART(str, state, prev_scan);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1079,10 +1151,7 @@ retry:
|
||||
case STB_TEXTEDIT_K_LINESTART:
|
||||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_move_to_first(state);
|
||||
if (state->single_line)
|
||||
state->cursor = 0;
|
||||
else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
|
||||
--state->cursor;
|
||||
state->cursor = STB_TEXTEDIT_MOVELINESTART(str, state, state->cursor);
|
||||
state->has_preferred_x = 0;
|
||||
break;
|
||||
|
||||
@@ -1090,13 +1159,9 @@ retry:
|
||||
case STB_TEXTEDIT_K_LINEEND2:
|
||||
#endif
|
||||
case STB_TEXTEDIT_K_LINEEND: {
|
||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_move_to_first(state);
|
||||
if (state->single_line)
|
||||
state->cursor = n;
|
||||
else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE)
|
||||
++state->cursor;
|
||||
stb_textedit_move_to_last(str, state);
|
||||
state->cursor = STB_TEXTEDIT_MOVELINEEND(str, state, state->cursor);
|
||||
state->has_preferred_x = 0;
|
||||
break;
|
||||
}
|
||||
@@ -1107,10 +1172,7 @@ retry:
|
||||
case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT:
|
||||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_prep_selection_at_cursor(state);
|
||||
if (state->single_line)
|
||||
state->cursor = 0;
|
||||
else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
|
||||
--state->cursor;
|
||||
state->cursor = STB_TEXTEDIT_MOVELINESTART(str, state, state->cursor);
|
||||
state->select_end = state->cursor;
|
||||
state->has_preferred_x = 0;
|
||||
break;
|
||||
@@ -1119,13 +1181,9 @@ retry:
|
||||
case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT:
|
||||
#endif
|
||||
case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: {
|
||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_prep_selection_at_cursor(state);
|
||||
if (state->single_line)
|
||||
state->cursor = n;
|
||||
else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE)
|
||||
++state->cursor;
|
||||
state->cursor = STB_TEXTEDIT_MOVELINEEND(str, state, state->cursor);
|
||||
state->select_end = state->cursor;
|
||||
state->has_preferred_x = 0;
|
||||
break;
|
||||
@@ -1300,7 +1358,7 @@ static void stb_text_undo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
// check type of recorded action:
|
||||
if (u.insert_length) {
|
||||
// easy case: was a deletion, so we need to insert n characters
|
||||
STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length);
|
||||
u.insert_length = STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length);
|
||||
s->undo_char_point -= u.insert_length;
|
||||
}
|
||||
|
||||
@@ -1351,7 +1409,7 @@ static void stb_text_redo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
|
||||
if (r.insert_length) {
|
||||
// easy case: need to insert n characters
|
||||
STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length);
|
||||
r.insert_length = STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length);
|
||||
s->redo_char_point += r.insert_length;
|
||||
}
|
||||
|
||||
|
||||
@@ -886,7 +886,7 @@ STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, fl
|
||||
// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap
|
||||
|
||||
STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
|
||||
// the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel
|
||||
// the same as stbtt_GetCodepointBitmap, but you can specify a subpixel
|
||||
// shift for the character
|
||||
|
||||
STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint);
|
||||
@@ -4516,8 +4516,8 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex
|
||||
q2[0] = (float)x2;
|
||||
q2[1] = (float)y2;
|
||||
if (equal(q0,q1) || equal(q1,q2)) {
|
||||
x0 = (int)verts[i-1].x;
|
||||
y0 = (int)verts[i-1].y;
|
||||
x0 = (int)verts[i-1].x; //-V1048
|
||||
y0 = (int)verts[i-1].y; //-V1048
|
||||
x1 = (int)verts[i ].x;
|
||||
y1 = (int)verts[i ].y;
|
||||
if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
|
||||
|
||||
@@ -123,7 +123,7 @@ void CCore::Loop()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
bool bShouldUnload = U::KeyHandler.Down(VK_F11) && SDK::IsGameWindowInFocus() || m_bUnload;
|
||||
bool bShouldUnload = U::KeyHandler.Down(VK_F11, true) && SDK::IsGameWindowInFocus() || m_bUnload;
|
||||
if (bShouldUnload)
|
||||
break;
|
||||
|
||||
|
||||
@@ -594,7 +594,7 @@ namespace ImGui
|
||||
return Disabled ? false : bReturn;
|
||||
}
|
||||
|
||||
inline bool FBeginPopup(const char* sLabel, ImGuiWindowFlags iFlags = ImGuiWindowFlags_None)
|
||||
inline bool FBeginPopup(const char* sLabel, ImGuiWindowFlags iFlags = ImGuiWindowFlags_NoSavedSettings)
|
||||
{
|
||||
PushStyleColor(ImGuiCol_PopupBg, {});
|
||||
|
||||
@@ -607,7 +607,7 @@ namespace ImGui
|
||||
return bReturn;
|
||||
}
|
||||
|
||||
inline bool FBeginPopupModal(const char* sLabel, bool* pOpen, ImGuiWindowFlags iFlags = ImGuiWindowFlags_None)
|
||||
inline bool FBeginPopupModal(const char* sLabel, bool* pOpen = nullptr, ImGuiWindowFlags iFlags = ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar)
|
||||
{
|
||||
PushStyleColor(ImGuiCol_PopupBg, {});
|
||||
|
||||
@@ -671,7 +671,7 @@ namespace ImGui
|
||||
if (bReturn)
|
||||
RenderBackground(F::Render.Background0p5, F::Render.Background2);
|
||||
|
||||
pDrawList->AddText(F::Render.IconFont, F::Render.IconFont->FontSize, vPos, F::Render.Inactive, ICON_MD_KEYBOARD_ARROW_RIGHT);
|
||||
pDrawList->AddText(F::Render.IconFont, F::Render.IconFont->LegacySize, vPos, F::Render.Inactive, ICON_MD_KEYBOARD_ARROW_RIGHT);
|
||||
return bReturn;
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ namespace ImGui
|
||||
flMinHeight = mLastHeights[uHash];
|
||||
PushStyleVar(ImGuiStyleVar_CellPadding, { 0, 0 });
|
||||
|
||||
bool bReturn = BeginChild(sLabel, { GetColumnWidth(), flMinHeight }, false, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_AlwaysUseWindowPadding);
|
||||
bool bReturn = BeginChild(sLabel, { GetColumnWidth(), flMinHeight }, ImGuiChildFlags_AlwaysUseWindowPadding, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
|
||||
if (bReturn)
|
||||
{
|
||||
if (sLabel[0] != '#')
|
||||
@@ -729,7 +729,7 @@ namespace ImGui
|
||||
PopStyleVar();
|
||||
}
|
||||
|
||||
inline std::vector<WidgetWindow_t> WidgetTable(int iCount, float flHeight, std::vector<float> vWidths = {}, int iWindowFlags = ImGuiWindowFlags_None, int iChildFlags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_AlwaysUseWindowPadding)
|
||||
inline std::vector<WidgetWindow_t> WidgetTable(int iCount, float flHeight, std::vector<float> vWidths = {}, int iWindowFlags = ImGuiChildFlags_AlwaysUseWindowPadding, int iChildFlags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)
|
||||
{
|
||||
std::vector<WidgetWindow_t> vReturn = {};
|
||||
|
||||
@@ -1898,7 +1898,7 @@ namespace ImGui
|
||||
PushStyleColor(ImGuiCol_PopupBg, F::Render.Background0p5.Value);
|
||||
|
||||
ImVec4 tTempColor = ColorToVec(*pColor);
|
||||
bool bReturn = ColorEdit4(std::format("##{}", sLabel).c_str(), &tTempColor.x, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoBorder | ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_LargeAlphaGrid | ImGuiColorEditFlags_NoRoundRestrict, vSize);
|
||||
bool bReturn = ColorEdit4(std::format("##{}", sLabel).c_str(), &tTempColor.x, ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_LargeAlphaGrid | ImGuiColorEditFlags_NoRoundRestrict | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoBorder | ImGuiColorEditFlags_NoTooltip, vSize);
|
||||
if (bReturn)
|
||||
*pColor = VecToColor(tTempColor);
|
||||
if (!Disabled && IsItemHovered())
|
||||
@@ -2018,88 +2018,6 @@ namespace ImGui
|
||||
return bReturn;
|
||||
}
|
||||
|
||||
inline std::string VK2STR(short key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 0x0: return "none";
|
||||
case VK_LBUTTON: return "mouse1";
|
||||
case VK_RBUTTON: return "mouse2";
|
||||
case VK_MBUTTON: return "mouse3";
|
||||
case VK_XBUTTON1: return "mouse4";
|
||||
case VK_XBUTTON2: return "mouse5";
|
||||
case VK_SHIFT: return "shift";
|
||||
case VK_LSHIFT: return "lshift";
|
||||
case VK_RSHIFT: return "rshift";
|
||||
case VK_CONTROL: return "control";
|
||||
case VK_LCONTROL: return "lcontrol";
|
||||
case VK_RCONTROL: return "rcontrol";
|
||||
case VK_MENU: return "alt";
|
||||
case VK_LMENU: return "lalt";
|
||||
case VK_RMENU: return "ralt";
|
||||
case VK_NUMPAD0: return "num0";
|
||||
case VK_NUMPAD1: return "num1";
|
||||
case VK_NUMPAD2: return "num2";
|
||||
case VK_NUMPAD3: return "num3";
|
||||
case VK_NUMPAD4: return "num4";
|
||||
case VK_NUMPAD5: return "num5";
|
||||
case VK_NUMPAD6: return "num6";
|
||||
case VK_NUMPAD7: return "num7";
|
||||
case VK_NUMPAD8: return "num8";
|
||||
case VK_NUMPAD9: return "num9";
|
||||
case VK_ADD: return "num+";
|
||||
case VK_SUBTRACT: return "num-";
|
||||
case VK_MULTIPLY: return "num*";
|
||||
case VK_DIVIDE: return "num/";
|
||||
case VK_DECIMAL: return "num.";
|
||||
case VK_INSERT: return "insert";
|
||||
case VK_DELETE: return "delete";
|
||||
case VK_PRIOR: return "pgup";
|
||||
case VK_NEXT: return "pgdown";
|
||||
case VK_HOME: return "home";
|
||||
case VK_END: return "end";
|
||||
case VK_CLEAR: return "clear";
|
||||
case VK_UP: return "up";
|
||||
case VK_DOWN: return "down";
|
||||
case VK_LEFT: return "left";
|
||||
case VK_RIGHT: return "right";
|
||||
case VK_ESCAPE: return "escape";
|
||||
case VK_F13: return "f13";
|
||||
case VK_F14: return "f14";
|
||||
case VK_F15: return "f15";
|
||||
case VK_F16: return "f16";
|
||||
case VK_F17: return "f17";
|
||||
case VK_F18: return "f18";
|
||||
case VK_F19: return "f19";
|
||||
case VK_F20: return "f20";
|
||||
case VK_F21: return "f21";
|
||||
case VK_F22: return "f22";
|
||||
case VK_F23: return "f23";
|
||||
case VK_F24: return "f24";
|
||||
case VK_LWIN:
|
||||
case VK_RWIN: return "windows";
|
||||
case VK_APPS: return "contextmenu";
|
||||
case VK_PAUSE: return "pause";
|
||||
case VK_VOLUME_MUTE: return "mute";
|
||||
case VK_VOLUME_DOWN: return "volumedown";
|
||||
case VK_VOLUME_UP: return "volumeup";
|
||||
case VK_MEDIA_STOP: return "stop";
|
||||
case VK_MEDIA_PLAY_PAUSE: return "pause";
|
||||
case VK_MEDIA_PREV_TRACK: return "previous";
|
||||
case VK_MEDIA_NEXT_TRACK: return "next";
|
||||
}
|
||||
|
||||
std::string str = "unknown";
|
||||
if (char buffer[16]; GetKeyNameText(MapVirtualKey(key, MAPVK_VK_TO_VSC) << 16, buffer, sizeof(buffer)))
|
||||
{
|
||||
str = buffer;
|
||||
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||
str.erase(std::remove_if(str.begin(), str.end(), ::isspace), str.end());
|
||||
}
|
||||
//else if (Vars::Debug::Info.Value)
|
||||
// str = std::format("{:#x}", key);
|
||||
return str;
|
||||
}
|
||||
inline void FKeybind(const char* sLabel, int& iOutput, int iFlags = FKeybindEnum::None, std::vector<int> vIgnore = { Vars::Menu::PrimaryKey[DEFAULT_BIND], Vars::Menu::SecondaryKey[DEFAULT_BIND] }, ImVec2 vSize = { 0, 30 }, int iSizeOffset = 0, bool* pHovered = nullptr)
|
||||
{
|
||||
ImGuiID uId = GetID(sLabel);
|
||||
@@ -2153,7 +2071,7 @@ namespace ImGui
|
||||
GetCurrentContext()->ActiveIdAllowOverlap = true;
|
||||
}
|
||||
}
|
||||
else if (FButton(std::format("{}: {}", sLabel, VK2STR(iOutput)).c_str(), iFlags | FButtonEnum::NoUpper, vSize, iSizeOffset, nullptr, pHovered))
|
||||
else if (FButton(std::format("{}: {}", sLabel, U::KeyHandler.String(iOutput)).c_str(), iFlags | FButtonEnum::NoUpper, vSize, iSizeOffset, nullptr, pHovered))
|
||||
SetActiveID(uId, GetCurrentWindow());
|
||||
|
||||
PopID();
|
||||
|
||||
@@ -1343,10 +1343,9 @@ void CMenu::MenuMisc(int iTab)
|
||||
} EndSection();
|
||||
if (Section("Game", 8))
|
||||
{
|
||||
FToggle(Vars::Misc::Game::AntiCheatCompatibility, FToggleEnum::Left);
|
||||
FToggle(Vars::Misc::Game::F2PChatBypass, FToggleEnum::Right);
|
||||
FToggle(Vars::Misc::Game::NetworkFix, FToggleEnum::Left);
|
||||
FToggle(Vars::Misc::Game::SetupBonesOptimization, FToggleEnum::Right);
|
||||
FToggle(Vars::Misc::Game::AntiCheatCompatibility);
|
||||
} EndSection();
|
||||
if (Vars::Debug::Options.Value)
|
||||
{
|
||||
@@ -1425,6 +1424,7 @@ void CMenu::MenuLogs(int iTab)
|
||||
|
||||
// tag bar
|
||||
bool bPopup = false;
|
||||
bool bIcon = tPlayer.m_bLocal || F::Spectate.GetTarget(true) == tPlayer.m_iUserID || tPlayer.m_bFriend || tPlayer.m_bParty;
|
||||
float flBarWidth = 0.f;
|
||||
|
||||
if (!tPlayer.m_bFake)
|
||||
@@ -1458,8 +1458,7 @@ void CMenu::MenuLogs(int iTab)
|
||||
flBarWidth += FCalcTextSize(tTag.m_sName.c_str()).x + H::Draw.Scale(14);
|
||||
for (auto& [pTag, iID] : vTags)
|
||||
flBarWidth += FCalcTextSize(pTag->m_sName.c_str()).x + H::Draw.Scale(iID ? 29 : 14);
|
||||
|
||||
flBarWidth = std::min(flBarWidth, flWidth / 2);
|
||||
flBarWidth = std::min(flBarWidth, std::max(flWidth - FCalcTextSize(tPlayer.m_sName.c_str(), F::Render.FontRegular).x - H::Draw.Scale(bIcon ? 33 : 14), flWidth / 2));
|
||||
|
||||
SetCursorPos(vOriginalPos + ImVec2(flWidth - floorf(flBarWidth), 0));
|
||||
if (BeginChild(std::format("TagBar{}", tPlayer.m_iUserID).c_str(), { flBarWidth, flHeight }, ImGuiWindowFlags_None, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoBackground))
|
||||
@@ -1500,7 +1499,7 @@ void CMenu::MenuLogs(int iTab)
|
||||
|
||||
// text + icons
|
||||
int lOffset = H::Draw.Scale(10);
|
||||
if (tPlayer.m_bLocal || F::Spectate.GetTarget(true) == tPlayer.m_iUserID || tPlayer.m_bFriend || tPlayer.m_bParty)
|
||||
if (bIcon)
|
||||
{
|
||||
lOffset += H::Draw.Scale(19);
|
||||
SetCursorPos(vOriginalPos + ImVec2(H::Draw.Scale(7), H::Draw.Scale(6)));
|
||||
@@ -1942,7 +1941,7 @@ void CMenu::MenuLogs(int iTab)
|
||||
PopStyleVar();
|
||||
EndPopup();
|
||||
}
|
||||
else if (FBeginPopupModal(std::format("DeleteTag{}", _iID).c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysUseWindowPadding))
|
||||
else if (FBeginPopupModal(std::format("DeleteTag{}", _iID).c_str()))
|
||||
{
|
||||
FText(std::format("Do you really want to delete '{}'?", _tTag.m_sName).c_str());
|
||||
|
||||
@@ -2169,7 +2168,7 @@ void CMenu::MenuLogs(int iTab)
|
||||
}
|
||||
|
||||
SetNextWindowSize({ H::Draw.Scale(300), 0 });
|
||||
if (FBeginPopupModal("ImportPlayerlist", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysUseWindowPadding))
|
||||
if (FBeginPopupModal("ImportPlayerlist"))
|
||||
{
|
||||
FText("Import");
|
||||
FText("As", FTextEnum::Right | FTextEnum::SameLine);
|
||||
@@ -2563,7 +2562,7 @@ void CMenu::MenuSettings(int iTab)
|
||||
else if (bDelete)
|
||||
OpenPopup(std::format("Remove{}{}", sType, sConfigName).c_str());
|
||||
|
||||
if (FBeginPopupModal(std::format("Save{}{}", sType, sConfigName).c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysUseWindowPadding))
|
||||
if (FBeginPopupModal(std::format("Save{}{}", sType, sConfigName).c_str()))
|
||||
{
|
||||
FText(std::format("Do you really want to override '{}'?", sConfigName).c_str());
|
||||
|
||||
@@ -2580,7 +2579,7 @@ void CMenu::MenuSettings(int iTab)
|
||||
|
||||
EndPopup();
|
||||
}
|
||||
else if (FBeginPopupModal(std::format("Remove{}{}", sType, sConfigName).c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysUseWindowPadding))
|
||||
else if (FBeginPopupModal(std::format("Remove{}{}", sType, sConfigName).c_str()))
|
||||
{
|
||||
FText(std::format("Do you really want to remove '{}'?", sConfigName).c_str());
|
||||
|
||||
@@ -2810,7 +2809,7 @@ void CMenu::MenuSettings(int iTab)
|
||||
case BindEnum::KeyEnum::Toggle: { sType = "toggle"; break; }
|
||||
case BindEnum::KeyEnum::DoubleClick: { sType = "double"; break; }
|
||||
}
|
||||
sInfo = VK2STR(_tBind.m_iKey);
|
||||
sInfo = U::KeyHandler.String(_tBind.m_iKey);
|
||||
break;
|
||||
case BindEnum::Class:
|
||||
sType = "class";
|
||||
@@ -2967,7 +2966,7 @@ void CMenu::MenuSettings(int iTab)
|
||||
iDragging = _iBind, iLayer = iParent;
|
||||
else if (bDelete)
|
||||
{
|
||||
if (U::KeyHandler.Down(VK_SHIFT)) // allow user to quickly remove binds
|
||||
if (_tBind.m_vVars.size() <= 1 && !F::Binds.HasChildren(_iBind) || U::KeyHandler.Down(VK_SHIFT)) // allow user to quickly remove binds
|
||||
F::Binds.RemoveBind(_iBind);
|
||||
else
|
||||
OpenPopup(std::format("DeleteBind{}", _iBind).c_str());
|
||||
@@ -3002,7 +3001,7 @@ void CMenu::MenuSettings(int iTab)
|
||||
PopStyleVar();
|
||||
EndPopup();
|
||||
}
|
||||
else if (FBeginPopupModal(std::format("DeleteBind{}", _iBind).c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysUseWindowPadding))
|
||||
else if (FBeginPopupModal(std::format("DeleteBind{}", _iBind).c_str()))
|
||||
{
|
||||
FText(std::format("Do you really want to delete '{}'{}?", _tBind.m_sName, F::Binds.HasChildren(_iBind) ? " and all of its children" : "").c_str());
|
||||
|
||||
@@ -3051,12 +3050,12 @@ void CMenu::MenuSettings(int iTab)
|
||||
// Materials
|
||||
case 2:
|
||||
{
|
||||
static TextEditor TextEditor;
|
||||
static std::string CurrentMaterial;
|
||||
static bool LockedMaterial;
|
||||
static TextEditor tTextEditor;
|
||||
static std::string sCurrentMaterial;
|
||||
static bool bLockedMaterial;
|
||||
|
||||
bool bTable = false;
|
||||
if (!CurrentMaterial.empty())
|
||||
if (!sCurrentMaterial.empty())
|
||||
bTable = BeginTable("MaterialsTable", 2);
|
||||
{
|
||||
if (bTable)
|
||||
@@ -3120,7 +3119,7 @@ void CMenu::MenuSettings(int iTab)
|
||||
SetCursorPos({ GetWindowWidth() - H::Draw.Scale(iOffset += 25), vOriginalPos.y + H::Draw.Scale(9) });
|
||||
if (IconButton(ICON_MD_DELETE))
|
||||
OpenPopup(std::format("DeleteMat{}", tMaterial.m_sName).c_str());
|
||||
if (FBeginPopupModal(std::format("DeleteMat{}", tMaterial.m_sName).c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysUseWindowPadding))
|
||||
if (FBeginPopupModal(std::format("DeleteMat{}", tMaterial.m_sName).c_str()))
|
||||
{
|
||||
FText(std::format("Do you really want to delete '{}'?", tMaterial.m_sName).c_str());
|
||||
|
||||
@@ -3139,11 +3138,11 @@ void CMenu::MenuSettings(int iTab)
|
||||
SetCursorPos({ GetWindowWidth() - H::Draw.Scale(iOffset += 25), vOriginalPos.y + H::Draw.Scale(9) });
|
||||
if (IconButton(ICON_MD_EDIT))
|
||||
{
|
||||
CurrentMaterial = tMaterial.m_sName;
|
||||
LockedMaterial = tMaterial.m_bLocked;
|
||||
sCurrentMaterial = tMaterial.m_sName;
|
||||
bLockedMaterial = tMaterial.m_bLocked;
|
||||
|
||||
TextEditor.SetText(F::Materials.GetVMT(FNV1A::Hash32(CurrentMaterial.c_str())));
|
||||
TextEditor.SetReadOnlyEnabled(LockedMaterial);
|
||||
tTextEditor.SetText(F::Materials.GetVMT(FNV1A::Hash32(sCurrentMaterial.c_str())));
|
||||
tTextEditor.SetReadOnlyEnabled(bLockedMaterial);
|
||||
}
|
||||
|
||||
SetCursorPos(vOriginalPos); DebugDummy({ 0, H::Draw.Scale(28) });
|
||||
@@ -3158,49 +3157,67 @@ void CMenu::MenuSettings(int iTab)
|
||||
{
|
||||
/* Column 2 */
|
||||
TableNextColumn();
|
||||
if (CurrentMaterial.length())
|
||||
if (sCurrentMaterial.length())
|
||||
{
|
||||
SetCursorPosY(GetScrollY() + GetStyle().WindowPadding.y);
|
||||
if (Section("Editor", 0, GetWindowHeight() - GetStyle().WindowPadding.y * 2, true))
|
||||
{
|
||||
// Toolbar
|
||||
if (!LockedMaterial)
|
||||
if (!bLockedMaterial)
|
||||
{
|
||||
if (FButton("Save", FButtonEnum::Fit))
|
||||
{
|
||||
auto sText = TextEditor.GetText();
|
||||
F::Materials.EditMaterial(CurrentMaterial.c_str(), sText.c_str());
|
||||
auto sText = tTextEditor.GetText();
|
||||
F::Materials.EditMaterial(sCurrentMaterial.c_str(), sText.c_str());
|
||||
}
|
||||
SameLine();
|
||||
}
|
||||
if (FButton("Close", FButtonEnum::Fit))
|
||||
CurrentMaterial = "";
|
||||
sCurrentMaterial = "";
|
||||
SetCursorPosY(H::Draw.Scale(52));
|
||||
PushStyleColor(ImGuiCol_Text, F::Render.Inactive.Value);
|
||||
FText(std::format("{}: {}", LockedMaterial ? "Viewing" : "Editing", CurrentMaterial).c_str(), FTextEnum::Right);
|
||||
FText(std::format("{}: {}", bLockedMaterial ? "Viewing" : "Editing", sCurrentMaterial).c_str(), FTextEnum::Right);
|
||||
PopStyleColor();
|
||||
|
||||
// Text editor
|
||||
DebugDummy({ 0, H::Draw.Scale(8) });
|
||||
|
||||
TextEditor.SetLanguageDefinition(TextEditor::LanguageDefinitionId::Cpp);
|
||||
TextEditor.SetPaletteIndex(TextEditor::PaletteIndex::Background, F::Render.Background1);
|
||||
TextEditor.SetPaletteIndex(TextEditor::PaletteIndex::Default, F::Render.Active);
|
||||
TextEditor.SetPaletteIndex(TextEditor::PaletteIndex::Identifier, F::Render.Active);
|
||||
TextEditor.SetPaletteIndex(TextEditor::PaletteIndex::Cursor, F::Render.Active);
|
||||
TextEditor.SetPaletteIndex(TextEditor::PaletteIndex::LineNumber, F::Render.Inactive);
|
||||
TextEditor.SetPaletteIndex(TextEditor::PaletteIndex::Comment, F::Render.Inactive);
|
||||
TextEditor.SetPaletteIndex(TextEditor::PaletteIndex::MultiLineComment, F::Render.Inactive);
|
||||
TextEditor.SetPaletteIndex(TextEditor::PaletteIndex::Punctuation, F::Render.Inactive);
|
||||
TextEditor.SetPaletteIndex(TextEditor::PaletteIndex::ControlCharacter, ImColor(F::Render.Inactive.Value.x, F::Render.Inactive.Value.y, F::Render.Inactive.Value.z, 0.1f));
|
||||
TextEditor.SetPaletteIndex(TextEditor::PaletteIndex::String, F::Render.Accent);
|
||||
tTextEditor.SetLanguage(TextEditor::Language::Cpp());
|
||||
TextEditor::Palette tPalette = {{
|
||||
F::Render.Active, // text
|
||||
F::Render.Active, // keyword
|
||||
F::Render.Active, // declaration
|
||||
F::Render.Active, // number
|
||||
F::Render.Accent, // string
|
||||
F::Render.Inactive, // punctuation
|
||||
F::Render.Inactive, // preprocessor
|
||||
F::Render.Inactive, // identifier
|
||||
F::Render.Inactive, // known identifier
|
||||
F::Render.Inactive, // comment
|
||||
F::Render.Background1, // background
|
||||
F::Render.Active, // cursor
|
||||
ImColor(F::Render.Inactive.Value.x, F::Render.Inactive.Value.y, F::Render.Inactive.Value.z, 0.5f), // selection
|
||||
ImColor(F::Render.Inactive.Value.x, F::Render.Inactive.Value.y, F::Render.Inactive.Value.z, 0.1f), // whitespace
|
||||
IM_COL32( 70, 70, 70, 255), // matchingBracketBackground
|
||||
IM_COL32(140, 140, 140, 255), // matchingBracketActive
|
||||
IM_COL32(246, 222, 36, 255), // matchingBracketLevel1
|
||||
IM_COL32( 66, 120, 198, 255), // matchingBracketLevel2
|
||||
IM_COL32(213, 96, 213, 255), // matchingBracketLevel3
|
||||
IM_COL32(198, 8, 32, 255), // matchingBracketError
|
||||
F::Render.Inactive, // line number
|
||||
F::Render.Active, // current line number
|
||||
}};
|
||||
tTextEditor.SetPalette(tPalette);
|
||||
//TextEditor.SetShowLineNumbersEnabled(false);
|
||||
|
||||
PushFont(F::Render.FontMono);
|
||||
PushStyleVar(ImGuiStyleVar_ChildBorderSize, H::Draw.Scale(1));
|
||||
ImVec2 vDrawPos = GetDrawPos() + GetCursorPos();
|
||||
TextEditor.Render("TextEditor");
|
||||
tTextEditor.Render("TextEditor");
|
||||
ImVec2 vSize = GetItemRectSize();
|
||||
float flInset = H::Draw.Scale(0.5f) - 0.5f;
|
||||
GetWindowDrawList()->AddRect(vDrawPos + ImVec2(flInset, flInset), vDrawPos + ImVec2(vSize.x - flInset, vSize.y - flInset), F::Render.Background2, H::Draw.Scale(4), ImDrawFlags_None, H::Draw.Scale());
|
||||
PopStyleVar();
|
||||
PopFont();
|
||||
} EndSection();
|
||||
}
|
||||
@@ -3244,7 +3261,7 @@ void CMenu::MenuSettings(int iTab)
|
||||
if (FButton("Lock achievements", FButtonEnum::Right | FButtonEnum::SameLine))
|
||||
OpenPopup("LockAchievements");
|
||||
|
||||
if (FBeginPopupModal("UnlockAchievements", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysUseWindowPadding))
|
||||
if (FBeginPopupModal("UnlockAchievements"))
|
||||
{
|
||||
FText("Do you really want to unlock all achievements?");
|
||||
|
||||
@@ -3258,7 +3275,7 @@ void CMenu::MenuSettings(int iTab)
|
||||
|
||||
EndPopup();
|
||||
}
|
||||
else if (FBeginPopupModal("LockAchievements", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysUseWindowPadding))
|
||||
else if (FBeginPopupModal("LockAchievements"))
|
||||
{
|
||||
FText("Do you really want to lock all achievements?");
|
||||
|
||||
@@ -3680,7 +3697,7 @@ void CMenu::AddDraggable(const char* sLabel, ConfigVar<DragBox_t>& var, bool bSh
|
||||
PushStyleVar(ImGuiStyleVar_WindowRounding, H::Draw.Scale(3));
|
||||
PushStyleVar(ImGuiStyleVar_WindowBorderSize, H::Draw.Scale(1));
|
||||
PushStyleVar(ImGuiStyleVar_WindowMinSize, vSize);
|
||||
if (Begin(sLabel, nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing))
|
||||
if (Begin(sLabel, nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoSavedSettings))
|
||||
{
|
||||
ImVec2 vWindowPos = GetWindowPos();
|
||||
|
||||
@@ -3730,7 +3747,7 @@ void CMenu::AddResizableDraggable(const char* sLabel, ConfigVar<WindowBox_t>& va
|
||||
PushStyleColor(ImGuiCol_Border, F::Render.Active.Value);
|
||||
PushStyleVar(ImGuiStyleVar_WindowRounding, H::Draw.Scale(3));
|
||||
PushStyleVar(ImGuiStyleVar_WindowBorderSize, H::Draw.Scale(1));
|
||||
if (Begin(sLabel, nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing))
|
||||
if (Begin(sLabel, nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoSavedSettings))
|
||||
{
|
||||
ImVec2 vWindowPos = GetWindowPos();
|
||||
ImVec2 vWinSize = GetWindowSize();
|
||||
@@ -3789,7 +3806,7 @@ void CMenu::DrawBinds()
|
||||
case BindEnum::KeyEnum::Toggle: { sType = "toggle"; break; }
|
||||
case BindEnum::KeyEnum::DoubleClick: { sType = "double"; break; }
|
||||
}
|
||||
sInfo = VK2STR(tBind.m_iKey);
|
||||
sInfo = U::KeyHandler.String(tBind.m_iKey);
|
||||
break;
|
||||
case BindEnum::Class:
|
||||
sType = "class";
|
||||
@@ -3880,7 +3897,7 @@ void CMenu::DrawBinds()
|
||||
float flHeight = H::Draw.Scale(18 * vInfo.size() + (Vars::Menu::BindWindowTitle.Value ? 42 : 12));
|
||||
SetNextWindowSize({ flWidth, flHeight });
|
||||
PushStyleVar(ImGuiStyleVar_WindowMinSize, { H::Draw.Scale(40), H::Draw.Scale(40) });
|
||||
if (Begin("Binds", nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing))
|
||||
if (Begin("Binds", nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoSavedSettings))
|
||||
{
|
||||
ImVec2 vWindowPos = GetWindowPos();
|
||||
|
||||
@@ -3956,13 +3973,13 @@ void CMenu::DrawBinds()
|
||||
tBind.m_bNot = !tBind.m_bNot;
|
||||
else if (bDelete)
|
||||
{
|
||||
if (U::KeyHandler.Down(VK_SHIFT)) // allow user to quickly remove binds
|
||||
if (tBind.m_vVars.size() <= 1 && !F::Binds.HasChildren(iBind) || U::KeyHandler.Down(VK_SHIFT)) // allow user to quickly remove binds
|
||||
F::Binds.RemoveBind(iBind);
|
||||
else
|
||||
OpenPopup(std::format("DeleteBind{}", iBind).c_str());
|
||||
}
|
||||
|
||||
if (FBeginPopupModal(std::format("DeleteBind{}", iBind).c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysUseWindowPadding))
|
||||
if (FBeginPopupModal(std::format("DeleteBind{}", iBind).c_str()))
|
||||
{
|
||||
FText(std::format("Do you really want to delete '{}'{}?", tBind.m_sName, F::Binds.HasChildren(iBind) ? " and all of its children" : "").c_str());
|
||||
|
||||
@@ -4011,24 +4028,21 @@ void CMenu::Render()
|
||||
if (!(ImGui::GetIO().DisplaySize.x > 160.f && ImGui::GetIO().DisplaySize.y > 28.f))
|
||||
return;
|
||||
|
||||
m_bInKeybind = m_bWindowHovered = false;
|
||||
m_bInKeybind = false;
|
||||
if (m_bIsOpen)
|
||||
{
|
||||
for (int iKey = 0; iKey < 256; iKey++)
|
||||
for (short iKey = 0; iKey < 256; iKey++)
|
||||
U::KeyHandler.StoreKey(iKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
U::KeyHandler.StoreKey(Vars::Menu::PrimaryKey.Value);
|
||||
U::KeyHandler.StoreKey(Vars::Menu::SecondaryKey.Value);
|
||||
U::KeyHandler.StoreKey(VK_F11);
|
||||
}
|
||||
if (U::KeyHandler.Pressed(Vars::Menu::PrimaryKey.Value) || U::KeyHandler.Pressed(Vars::Menu::SecondaryKey.Value))
|
||||
I::MatSystemSurface->SetCursorAlwaysVisible(m_bIsOpen = !m_bIsOpen);
|
||||
|
||||
PushFont(F::Render.FontRegular);
|
||||
|
||||
DrawBinds();
|
||||
if (m_bIsOpen)
|
||||
{
|
||||
ManageVars();
|
||||
@@ -4059,8 +4073,11 @@ void CMenu::Render()
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mActiveMap.clear();
|
||||
|
||||
m_bWindowHovered = false;
|
||||
}
|
||||
DrawBinds();
|
||||
PopFont();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,10 @@
|
||||
|
||||
void CRender::Render(IDirect3DDevice9* pDevice)
|
||||
{
|
||||
using namespace ImGui;
|
||||
|
||||
static std::once_flag initFlag;
|
||||
std::call_once(initFlag, [&]
|
||||
{
|
||||
Initialize(pDevice);
|
||||
});
|
||||
static std::once_flag tFlag; std::call_once(tFlag, [&]
|
||||
{
|
||||
Initialize(pDevice);
|
||||
});
|
||||
|
||||
LoadColors();
|
||||
{
|
||||
@@ -25,30 +22,25 @@ void CRender::Render(IDirect3DDevice9* pDevice)
|
||||
float flOldScale = flStaticScale;
|
||||
float flNewScale = flStaticScale = Vars::Menu::Scale.Value;
|
||||
if (flNewScale != flOldScale)
|
||||
{
|
||||
LoadFonts();
|
||||
LoadStyle();
|
||||
}
|
||||
Reload();
|
||||
}
|
||||
|
||||
DWORD dwOldRGB; pDevice->GetRenderState(D3DRS_SRGBWRITEENABLE, &dwOldRGB);
|
||||
pDevice->SetRenderState(D3DRS_SRGBWRITEENABLE, false);
|
||||
ImGui_ImplDX9_NewFrame();
|
||||
ImGui_ImplWin32_NewFrame();
|
||||
NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
F::Menu.Render();
|
||||
|
||||
EndFrame();
|
||||
ImGui::EndFrame();
|
||||
ImGui::Render();
|
||||
ImGui_ImplDX9_RenderDrawData(GetDrawData());
|
||||
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
|
||||
pDevice->SetRenderState(D3DRS_SRGBWRITEENABLE, dwOldRGB);
|
||||
}
|
||||
|
||||
void CRender::LoadColors()
|
||||
{
|
||||
using namespace ImGui;
|
||||
|
||||
auto fColorToVec = [](Color_t tColor) -> ImColor
|
||||
{
|
||||
return { tColor.r / 255.f, tColor.g / 255.f, tColor.b / 255.f, tColor.a / 255.f };
|
||||
@@ -64,7 +56,7 @@ void CRender::LoadColors()
|
||||
Inactive = fColorToVec(Vars::Menu::Theme::Inactive.Value);
|
||||
Active = fColorToVec(Vars::Menu::Theme::Active.Value);
|
||||
|
||||
ImVec4* colors = GetStyle().Colors;
|
||||
ImVec4* colors = ImGui::GetStyle().Colors;
|
||||
colors[ImGuiCol_Border] = Background2;
|
||||
colors[ImGuiCol_Button] = {};
|
||||
colors[ImGuiCol_ButtonHovered] = {};
|
||||
@@ -87,49 +79,41 @@ void CRender::LoadColors()
|
||||
|
||||
void CRender::LoadFonts()
|
||||
{
|
||||
static bool bHasLoaded = false;
|
||||
|
||||
auto& io = ImGui::GetIO();
|
||||
if (bHasLoaded)
|
||||
{
|
||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||
io.Fonts->ClearFonts();
|
||||
}
|
||||
|
||||
ImFontConfig fontConfig;
|
||||
fontConfig.OversampleH = 2;
|
||||
constexpr ImWchar fontRange[]{ 0x0020, 0x00FF, 0x0400, 0x044F, 0 }; // Basic Latin, Latin Supplement and Cyrillic
|
||||
if (static bool bLoaded = false; !bLoaded)
|
||||
bLoaded = true;
|
||||
else
|
||||
io.Fonts->Clear();
|
||||
|
||||
ImFontConfig tFontConfig;
|
||||
tFontConfig.OversampleH = 2;
|
||||
#ifndef AMALGAM_CUSTOM_FONTS
|
||||
FontSmall = io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\verdana.ttf)", H::Draw.Scale(11), &fontConfig, fontRange);
|
||||
FontRegular = io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\verdana.ttf)", H::Draw.Scale(13), &fontConfig, fontRange);
|
||||
FontBold = io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\verdanab.ttf)", H::Draw.Scale(13), &fontConfig, fontRange);
|
||||
FontLarge = io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\verdana.ttf)", H::Draw.Scale(14), &fontConfig, fontRange);
|
||||
FontMono = io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\cour.ttf)", H::Draw.Scale(16), &fontConfig, fontRange); // windows mono font installed by default
|
||||
FontSmall = io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\verdana.ttf)", H::Draw.Scale(11), &tFontConfig);
|
||||
FontRegular = io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\verdana.ttf)", H::Draw.Scale(13), &tFontConfig);
|
||||
FontBold = io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\verdanab.ttf)", H::Draw.Scale(13), &tFontConfig);
|
||||
FontLarge = io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\verdana.ttf)", H::Draw.Scale(14), &tFontConfig);
|
||||
FontMono = io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\cour.ttf)", H::Draw.Scale(16), &tFontConfig); // windows mono font installed by default
|
||||
#else
|
||||
FontSmall = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoMedium_compressed_data, RobotoMedium_compressed_size, H::Draw.Scale(12), &fontConfig, fontRange);
|
||||
FontRegular = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoMedium_compressed_data, RobotoMedium_compressed_size, H::Draw.Scale(13), &fontConfig, fontRange);
|
||||
FontBold = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoBlack_compressed_data, RobotoBlack_compressed_size, H::Draw.Scale(13), &fontConfig, fontRange);
|
||||
FontLarge = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoMedium_compressed_data, RobotoMedium_compressed_size, H::Draw.Scale(15), &fontConfig, fontRange);
|
||||
FontMono = io.Fonts->AddFontFromMemoryCompressedTTF(CascadiaMono_compressed_data, CascadiaMono_compressed_size, H::Draw.Scale(15), &fontConfig, fontRange);
|
||||
FontSmall = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoMedium_compressed_data, RobotoMedium_compressed_size, H::Draw.Scale(12), &tFontConfig);
|
||||
FontRegular = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoMedium_compressed_data, RobotoMedium_compressed_size, H::Draw.Scale(13), &tFontConfig);
|
||||
FontBold = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoBlack_compressed_data, RobotoBlack_compressed_size, H::Draw.Scale(13), &tFontConfig);
|
||||
FontLarge = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoMedium_compressed_data, RobotoMedium_compressed_size, H::Draw.Scale(15), &tFontConfig);
|
||||
FontMono = io.Fonts->AddFontFromMemoryCompressedTTF(CascadiaMono_compressed_data, CascadiaMono_compressed_size, H::Draw.Scale(15), &tFontConfig);
|
||||
#endif
|
||||
|
||||
ImFontConfig iconConfig;
|
||||
iconConfig.PixelSnapH = true;
|
||||
constexpr ImWchar iconRange[]{ short(ICON_MIN_MD), short(ICON_MAX_MD), 0 };
|
||||
IconFont = io.Fonts->AddFontFromMemoryCompressedTTF(MaterialIcons_compressed_data, MaterialIcons_compressed_size, H::Draw.Scale(16), &iconConfig, iconRange);
|
||||
ImFontConfig tIconConfig;
|
||||
tIconConfig.PixelSnapH = true;
|
||||
IconFont = io.Fonts->AddFontFromMemoryCompressedTTF(MaterialIcons_compressed_data, MaterialIcons_compressed_size, H::Draw.Scale(16), &tIconConfig);
|
||||
|
||||
io.Fonts->Build();
|
||||
io.ConfigDebugHighlightIdConflicts = false;
|
||||
|
||||
bHasLoaded = true;
|
||||
}
|
||||
|
||||
void CRender::LoadStyle()
|
||||
{
|
||||
using namespace ImGui;
|
||||
|
||||
auto& style = GetStyle();
|
||||
style.ButtonTextAlign = { 0.5f, 0.5f }; // Center button text
|
||||
auto& style = ImGui::GetStyle();
|
||||
style.ButtonTextAlign = { 0.5f, 0.5f };
|
||||
style.CellPadding = { H::Draw.Scale(4), 0 };
|
||||
style.ChildBorderSize = 0.f;
|
||||
style.ChildRounding = H::Draw.Scale(4);
|
||||
@@ -149,7 +133,6 @@ void CRender::LoadStyle()
|
||||
|
||||
void CRender::Initialize(IDirect3DDevice9* pDevice)
|
||||
{
|
||||
// Initialize ImGui and device
|
||||
ImGui::CreateContext();
|
||||
ImGui_ImplWin32_Init(WndProc::hwWindow);
|
||||
ImGui_ImplDX9_Init(pDevice);
|
||||
@@ -160,4 +143,16 @@ void CRender::Initialize(IDirect3DDevice9* pDevice)
|
||||
|
||||
LoadFonts();
|
||||
LoadStyle();
|
||||
|
||||
m_bLoaded = true;
|
||||
}
|
||||
|
||||
void CRender::Reload()
|
||||
{
|
||||
m_bLoaded = false;
|
||||
|
||||
LoadFonts();
|
||||
LoadStyle();
|
||||
|
||||
m_bLoaded = true;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ class CRender
|
||||
public:
|
||||
void Render(IDirect3DDevice9* pDevice);
|
||||
void Initialize(IDirect3DDevice9* pDevice);
|
||||
void Reload();
|
||||
|
||||
void LoadColors();
|
||||
void LoadFonts();
|
||||
@@ -34,6 +35,8 @@ public:
|
||||
ImFont* FontMono = nullptr;
|
||||
|
||||
ImFont* IconFont = nullptr;
|
||||
|
||||
bool m_bLoaded = false;
|
||||
};
|
||||
|
||||
ADD_FEATURE(CRender, Render);
|
||||
@@ -668,7 +668,7 @@ static inline void StoreMisc(CBaseEntity* pEntity, CTFPlayer* pLocal, Group_t* p
|
||||
const char* sName = "Unknown";
|
||||
switch (pEntity->GetClassID())
|
||||
{
|
||||
case ETFClassID::CTFBaseBoss: sName = "Boss"; break;
|
||||
case ETFClassID::CTFBaseBoss: sName = "NPC"; break;
|
||||
case ETFClassID::CTFTankBoss: sName = "Tank"; break;
|
||||
case ETFClassID::CMerasmus: sName = "Merasmus"; break;
|
||||
case ETFClassID::CEyeballBoss: sName = "Monoculus"; break;
|
||||
|
||||
@@ -416,8 +416,8 @@ void CVisuals::DrawDebugInfo(CTFPlayer* pLocal)
|
||||
else if (vPosition2D)
|
||||
H::Draw.StringOutlined(fFont, vPosition2D->x, vPosition2D->y, tColor, Vars::Menu::Theme::Background.Value, ALIGN_TOPLEFT, sString.c_str());
|
||||
else
|
||||
H::Draw.StringOutlined(fFont, x, y += nTall, tColor, Vars::Menu::Theme::Background.Value, ALIGN_TOPLEFT, sString.c_str());
|
||||
}
|
||||
H::Draw.StringOutlined(fFont, x, y += nTall, tColor, Vars::Menu::Theme::Background.Value, ALIGN_TOPLEFT, sString.c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -522,7 +522,8 @@ void CVisuals::DrawEffects()
|
||||
}
|
||||
for (auto& tPath : G::PathStorage)
|
||||
{
|
||||
if (tPath.m_flTime >= 0.f && tPath.m_flTime < I::GlobalVars->curtime)
|
||||
bool bTimed = tPath.m_flTime < 0.f;
|
||||
if (!bTimed && tPath.m_flTime < I::GlobalVars->curtime)
|
||||
continue;
|
||||
|
||||
H::Draw.RenderPath(tPath.m_vPath, tPath.m_tColor, tPath.m_bZBuffer, tPath.m_iStyle, tPath.m_flTime);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "../SDK/SDK.h"
|
||||
|
||||
#include "../Features/Ticks/Ticks.h"
|
||||
|
||||
MAKE_SIGNATURE(CBaseEntity_BaseInterpolatePart1, "client.dll", "48 89 5C 24 ? 56 57 41 55 41 56 41 57 48 83 EC ? 4C 8B BC 24", 0x0);
|
||||
|
||||
MAKE_HOOK(CBaseEntity_BaseInterpolatePart1, S::CBaseEntity_BaseInterpolatePart1(), int,
|
||||
void* rcx, float& currentTime, Vector& oldOrigin, QAngle& oldAngles, Vector& oldVel, int& bNoMoreChanges)
|
||||
{
|
||||
DEBUG_RETURN(CBaseEntity_BaseInterpolatePart1, rcx, currentTime, oldOrigin, oldAngles, oldVel, bNoMoreChanges);
|
||||
|
||||
auto pEntity = reinterpret_cast<CBaseEntity*>(rcx);
|
||||
if (pEntity && pEntity->GetClassID() == ETFClassID::CTFViewModel && F::Ticks.m_bRecharge)
|
||||
{
|
||||
bNoMoreChanges = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return CALL_ORIGINAL(rcx, currentTime, oldOrigin, oldAngles, oldVel, bNoMoreChanges);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "../SDK/SDK.h"
|
||||
|
||||
#include "../Features/Ticks/Ticks.h"
|
||||
|
||||
MAKE_SIGNATURE(CBaseViewModel_Interpolate, "client.dll", "48 8B C4 48 89 58 ? 48 89 68 ? 48 89 70 ? 48 89 78 ? 41 56 48 83 EC ? 0F 29 70 ? 33 FF", 0x0);
|
||||
|
||||
MAKE_HOOK(CBaseViewModel_Interpolate, S::CBaseViewModel_Interpolate(), bool,
|
||||
void* rcx, float& currentTime)
|
||||
{
|
||||
DEBUG_RETURN(CBaseEntity_BaseInterpolatePart1, rcx, currentTime);
|
||||
|
||||
if (F::Ticks.m_bRecharge)
|
||||
return true;
|
||||
|
||||
return CALL_ORIGINAL(rcx, currentTime);
|
||||
}
|
||||
@@ -26,6 +26,7 @@ MAKE_HOOK(IEngineVGui_Paint, U::Memory.GetVirtual(I::EngineVGui, 14), void,
|
||||
{
|
||||
H::Draw.UpdateScreenSize();
|
||||
H::Draw.UpdateW2SMatrix();
|
||||
|
||||
H::Draw.Start(true);
|
||||
if (auto pLocal = H::Entities.GetLocal())
|
||||
{
|
||||
@@ -56,6 +57,8 @@ MAKE_HOOK(IEngineVGui_Paint, U::Memory.GetVirtual(I::EngineVGui, 14), void,
|
||||
if (iMode & PAINT_UIPANELS && !SDK::CleanScreenshot())
|
||||
{
|
||||
H::Draw.UpdateScreenSize();
|
||||
H::Draw.UpdateKeyStrings();
|
||||
|
||||
H::Draw.Start();
|
||||
{
|
||||
F::Notifications.Draw();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../../Definitions/Interfaces.h"
|
||||
#include "../../../Utils/Math/Math.h"
|
||||
#include "../../../Utils/Timer/Timer.h"
|
||||
#include "../../../Features/ImGui/Render.h"
|
||||
|
||||
MAKE_SIGNATURE(CHudBaseDeathNotice_GetIcon, "client.dll", "40 53 48 81 EC ? ? ? ? 48 8B DA", 0x0);
|
||||
MAKE_SIGNATURE(RenderLine, "engine.dll", "48 89 5C 24 ? 48 89 74 24 ? 44 89 44 24", 0x0);
|
||||
@@ -60,6 +61,20 @@ void CDraw::UpdateW2SMatrix()
|
||||
}
|
||||
}
|
||||
|
||||
void CDraw::UpdateKeyStrings()
|
||||
{
|
||||
if (!F::Render.m_bLoaded)
|
||||
return;
|
||||
|
||||
static HKL pLastLayout = nullptr;
|
||||
if (HKL pCurrLayout = GetKeyboardLayout(0); pCurrLayout != pLastLayout)
|
||||
{
|
||||
pLastLayout = pCurrLayout;
|
||||
for (short iKey = 0; iKey < 256; iKey++)
|
||||
U::KeyHandler.String(iKey, true);
|
||||
}
|
||||
}
|
||||
|
||||
Vec2 CDraw::GetTextSize(const char* text, const Font_t& tFont)
|
||||
{
|
||||
int w = 0, h = 0;
|
||||
@@ -486,9 +501,10 @@ void CDraw::RenderPath(const std::vector<Vec3>& vPath, Color_t tColor, bool bZBu
|
||||
if (!tColor.a || iStyle == Vars::Visuals::Path::StyleEnum::Off)
|
||||
return;
|
||||
|
||||
bool bTimed = flTime < 0.f;
|
||||
for (size_t i = 1; i < vPath.size(); i++)
|
||||
{
|
||||
if (flTime < 0.f && vPath.size() - i > -flTime)
|
||||
if (bTimed && vPath.size() - i > -flTime)
|
||||
continue;
|
||||
|
||||
switch (iStyle)
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
|
||||
void UpdateScreenSize();
|
||||
void UpdateW2SMatrix();
|
||||
void UpdateKeyStrings();
|
||||
|
||||
Vec2 GetTextSize(const char* text, const Font_t& tFont);
|
||||
Vec2 GetTextSize(const wchar_t* text, const Font_t& tFont);
|
||||
|
||||
@@ -130,7 +130,7 @@ std::wstring SDK::ConvertUtf8ToWide(const std::string& source)
|
||||
int size = MultiByteToWideChar(CP_UTF8, 0, source.data(), -1, nullptr, 0);
|
||||
std::wstring result(size, 0);
|
||||
MultiByteToWideChar(CP_UTF8, 0, source.data(), -1, result.data(), size);
|
||||
return result;
|
||||
result.pop_back(); return result;
|
||||
}
|
||||
|
||||
std::string SDK::ConvertWideToUTF8(const std::wstring& source)
|
||||
@@ -138,7 +138,7 @@ std::string SDK::ConvertWideToUTF8(const std::wstring& source)
|
||||
int size = WideCharToMultiByte(CP_UTF8, 0, source.data(), -1, nullptr, 0, nullptr, nullptr);
|
||||
std::string result(size, 0);
|
||||
WideCharToMultiByte(CP_UTF8, 0, source.data(), -1, result.data(), size, nullptr, nullptr);
|
||||
return result;
|
||||
result.pop_back(); return result;
|
||||
}
|
||||
|
||||
HWND SDK::GetTeamFortressWindow()
|
||||
|
||||
@@ -757,10 +757,9 @@ NAMESPACE_BEGIN(Vars)
|
||||
NAMESPACE_END(Exploits)
|
||||
|
||||
NAMESPACE_BEGIN(Game)
|
||||
CVar(AntiCheatCompatibility, "Anti-cheat compatibility", false);
|
||||
CVar(F2PChatBypass, "F2P chat bypass", false);
|
||||
CVar(NetworkFix, "Network fix", false);
|
||||
CVar(SetupBonesOptimization, "Bones optimization", false);
|
||||
CVar(AntiCheatCompatibility, "Anti-cheat compatibility", false);
|
||||
|
||||
CVar(AntiCheatCritHack, "Anti-cheat crit hack", false, NOSAVE | DEBUGVAR);
|
||||
NAMESPACE_END(Game)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "KeyHandler.h"
|
||||
|
||||
#include "../../SDK/SDK.h"
|
||||
#include "../../Features/ImGui/Render.h"
|
||||
#include <Windows.h>
|
||||
|
||||
void CKeyHandler::StoreKey(int iKey, KeyStorage* pStorage)
|
||||
void CKeyHandler::StoreKey(byte iKey, KeyStorage* pStorage)
|
||||
{
|
||||
if (!pStorage)
|
||||
pStorage = &m_mKeyStorage[iKey];
|
||||
pStorage = &m_aKeyStorage[iKey];
|
||||
|
||||
// down
|
||||
const bool bDown = iKey && GetAsyncKeyState(iKey) & 0x8000 && SDK::IsGameWindowInFocus();
|
||||
@@ -29,10 +30,10 @@ void CKeyHandler::StoreKey(int iKey, KeyStorage* pStorage)
|
||||
pStorage->m_dPressTime = dFloatTime;
|
||||
}
|
||||
|
||||
bool CKeyHandler::Down(int iKey, const bool bStore, KeyStorage* pStorage)
|
||||
bool CKeyHandler::Down(byte iKey, const bool bStore, KeyStorage* pStorage)
|
||||
{
|
||||
if (!pStorage)
|
||||
pStorage = &m_mKeyStorage[iKey];
|
||||
pStorage = &m_aKeyStorage[iKey];
|
||||
|
||||
if (bStore)
|
||||
StoreKey(iKey, pStorage);
|
||||
@@ -40,10 +41,10 @@ bool CKeyHandler::Down(int iKey, const bool bStore, KeyStorage* pStorage)
|
||||
return pStorage->m_bIsDown;
|
||||
}
|
||||
|
||||
bool CKeyHandler::Pressed(int iKey, const bool bStore, KeyStorage* pStorage)
|
||||
bool CKeyHandler::Pressed(byte iKey, const bool bStore, KeyStorage* pStorage)
|
||||
{
|
||||
if (!pStorage)
|
||||
pStorage = &m_mKeyStorage[iKey];
|
||||
pStorage = &m_aKeyStorage[iKey];
|
||||
|
||||
if (bStore)
|
||||
StoreKey(iKey, pStorage);
|
||||
@@ -51,10 +52,10 @@ bool CKeyHandler::Pressed(int iKey, const bool bStore, KeyStorage* pStorage)
|
||||
return pStorage->m_bIsPressed;
|
||||
}
|
||||
|
||||
bool CKeyHandler::Double(int iKey, const bool bStore, KeyStorage* pStorage)
|
||||
bool CKeyHandler::Double(byte iKey, const bool bStore, KeyStorage* pStorage)
|
||||
{
|
||||
if (!pStorage)
|
||||
pStorage = &m_mKeyStorage[iKey];
|
||||
pStorage = &m_aKeyStorage[iKey];
|
||||
|
||||
if (bStore)
|
||||
StoreKey(iKey, pStorage);
|
||||
@@ -62,13 +63,122 @@ bool CKeyHandler::Double(int iKey, const bool bStore, KeyStorage* pStorage)
|
||||
return pStorage->m_bIsDouble;
|
||||
}
|
||||
|
||||
bool CKeyHandler::Released(int iKey, const bool bStore, KeyStorage* pStorage)
|
||||
bool CKeyHandler::Released(byte iKey, const bool bStore, KeyStorage* pStorage)
|
||||
{
|
||||
if (!pStorage)
|
||||
pStorage = &m_mKeyStorage[iKey];
|
||||
pStorage = &m_aKeyStorage[iKey];
|
||||
|
||||
if (bStore)
|
||||
StoreKey(iKey, pStorage);
|
||||
|
||||
return pStorage->m_bIsReleased;
|
||||
}
|
||||
|
||||
static inline bool VirtualKeyOverride(byte iKey, std::string& sKey)
|
||||
{
|
||||
switch (iKey)
|
||||
{
|
||||
case 0x0: sKey = "none"; return true;
|
||||
case VK_LBUTTON: sKey = "mouse1"; return true;
|
||||
case VK_RBUTTON: sKey = "mouse2"; return true;
|
||||
case VK_MBUTTON: sKey = "mouse3"; return true;
|
||||
case VK_XBUTTON1: sKey = "mouse4"; return true;
|
||||
case VK_XBUTTON2: sKey = "mouse5"; return true;
|
||||
case VK_F13: sKey = "f13"; return true;
|
||||
case VK_F14: sKey = "f14"; return true;
|
||||
case VK_F15: sKey = "f15"; return true;
|
||||
case VK_F16: sKey = "f16"; return true;
|
||||
case VK_F17: sKey = "f17"; return true;
|
||||
case VK_F18: sKey = "f18"; return true;
|
||||
case VK_F19: sKey = "f19"; return true;
|
||||
case VK_F20: sKey = "f20"; return true;
|
||||
case VK_F21: sKey = "f21"; return true;
|
||||
case VK_F22: sKey = "f22"; return true;
|
||||
case VK_F23: sKey = "f23"; return true;
|
||||
case VK_F24: sKey = "f24"; return true;
|
||||
case VK_LWIN:
|
||||
case VK_RWIN: sKey = "windows"; return true;
|
||||
case VK_APPS: sKey = "contextmenu"; return true;
|
||||
case VK_VOLUME_MUTE: sKey = "mute"; return true;
|
||||
case VK_VOLUME_DOWN: sKey = "volumedown"; return true;
|
||||
case VK_VOLUME_UP: sKey = "volumeup"; return true;
|
||||
case VK_MEDIA_STOP: sKey = "stop"; return true;
|
||||
case VK_MEDIA_PLAY_PAUSE: sKey = "playpause"; return true;
|
||||
case VK_MEDIA_PREV_TRACK: sKey = "previous"; return true;
|
||||
case VK_MEDIA_NEXT_TRACK: sKey = "next"; return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
static inline bool VirtualKeyUnicode(byte iKey, std::string& sKey, HKL pKeyboard = nullptr)
|
||||
{
|
||||
if (!F::Render.FontRegular || VK_A > iKey || iKey > VK_Z)
|
||||
return false;
|
||||
|
||||
byte uScanCode = MapVirtualKeyEx(iKey, MAPVK_VK_TO_VSC, pKeyboard);
|
||||
static byte aKeyState[256] = {};
|
||||
if (wchar_t buffer[8]; ToUnicodeEx(iKey, uScanCode, aKeyState, buffer, 8, 4, pKeyboard) > 0 && F::Render.FontRegular->IsGlyphInFont(buffer[0]))
|
||||
{
|
||||
sKey = SDK::ConvertWideToUTF8(buffer);
|
||||
sKey.erase(std::remove_if(sKey.begin(), sKey.end(), ::isspace), sKey.end());
|
||||
std::transform(sKey.begin(), sKey.end(), sKey.begin(), ::tolower);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
static inline bool VirtualKeyText(byte iKey, std::string& sKey, HKL pKeyboard = nullptr)
|
||||
{
|
||||
unsigned uKey = iKey;
|
||||
switch (iKey)
|
||||
{
|
||||
case VK_PAUSE:
|
||||
uKey = VK_NUMLOCK; break;
|
||||
}
|
||||
uKey = MapVirtualKeyEx(uKey, MAPVK_VK_TO_VSC, pKeyboard) << 16 | 1 << 25;
|
||||
switch (iKey)
|
||||
{
|
||||
case VK_UP: case VK_DOWN: case VK_LEFT: case VK_RIGHT:
|
||||
case VK_NUMLOCK: case VK_HOME: case VK_END: case VK_NEXT: case VK_PRIOR:
|
||||
case VK_INSERT: case VK_DELETE: case VK_DIVIDE:
|
||||
uKey |= 1 << 24; break;
|
||||
}
|
||||
if (char buffer[16]; GetKeyNameText(uKey, buffer, sizeof(buffer)))
|
||||
{
|
||||
switch (iKey)
|
||||
{
|
||||
case VK_LSHIFT: case VK_LCONTROL: case VK_LMENU:
|
||||
if (VirtualKeyText(VK_LEFT, sKey)) sKey += buffer; else sKey = buffer; break;
|
||||
case VK_RSHIFT: case VK_RCONTROL: case VK_RMENU:
|
||||
if (VirtualKeyText(VK_RIGHT, sKey)) sKey += buffer; else sKey = buffer; break;
|
||||
default:
|
||||
sKey = buffer;
|
||||
}
|
||||
sKey.erase(std::remove_if(sKey.begin(), sKey.end(), ::isspace), sKey.end());
|
||||
std::transform(sKey.begin(), sKey.end(), sKey.begin(), ::tolower);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
static inline std::string VirtualKey2Str(byte iKey)
|
||||
{
|
||||
std::string sKey = "unknown";
|
||||
if (VirtualKeyOverride(iKey, sKey))
|
||||
return sKey;
|
||||
if (VirtualKeyUnicode(iKey, sKey, GetKeyboardLayout(0)))
|
||||
return sKey;
|
||||
if (VirtualKeyText(iKey, sKey, GetKeyboardLayout(0)))
|
||||
return sKey;
|
||||
return sKey + std::format("{:02x}", iKey);
|
||||
}
|
||||
|
||||
std::string& CKeyHandler::String(byte iKey, const bool bStore)
|
||||
{
|
||||
std::string& sString = m_aStringStorage[iKey];
|
||||
|
||||
if (bStore)
|
||||
sString = VirtualKey2Str(iKey);
|
||||
|
||||
return sString;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "../Macros/Macros.h"
|
||||
#include <unordered_map>
|
||||
#include "../../SDK/Definitions/Types.h"
|
||||
|
||||
struct KeyStorage
|
||||
{
|
||||
@@ -14,21 +14,19 @@ struct KeyStorage
|
||||
class CKeyHandler
|
||||
{
|
||||
public:
|
||||
void StoreKey(int iKey, KeyStorage* pStorage = nullptr);
|
||||
void StoreKey(byte iKey, KeyStorage* pStorage = nullptr);
|
||||
|
||||
// Is the button currently down?
|
||||
bool Down(int iKey, const bool bStore = false, KeyStorage* pStorage = nullptr);
|
||||
bool Down(byte iKey, const bool bStore = false, KeyStorage* pStorage = nullptr);
|
||||
bool Pressed(byte iKey, const bool bStore = false, KeyStorage* pStorage = nullptr);
|
||||
bool Double(byte iKey, const bool bStore = false, KeyStorage* pStorage = nullptr);
|
||||
bool Released(byte iKey, const bool bStore = false, KeyStorage* pStorage = nullptr);
|
||||
|
||||
// Was the button just pressed? This will only be true once.
|
||||
bool Pressed(int iKey, const bool bStore = false, KeyStorage* pStorage = nullptr);
|
||||
std::array<KeyStorage, 256> m_aKeyStorage = {};
|
||||
|
||||
// Was the button double clicked? This will only be true once.
|
||||
bool Double(int iKey, const bool bStore = false, KeyStorage* pStorage = nullptr);
|
||||
public:
|
||||
std::string& String(byte iKey, const bool bStore = false);
|
||||
|
||||
// Was the button just released? This will only be true once.
|
||||
bool Released(int iKey, const bool bStore = false, KeyStorage* pStorage = nullptr);
|
||||
|
||||
std::unordered_map<int, KeyStorage> m_mKeyStorage = {};
|
||||
std::array<std::string, 256> m_aStringStorage = {};
|
||||
};
|
||||
|
||||
ADD_FEATURE_CUSTOM(CKeyHandler, KeyHandler, U);
|
||||
Reference in New Issue
Block a user