mirror of
https://github.com/HIllya51/LunaHook.git
synced 2025-01-12 21:04:00 +08:00
length
This commit is contained in:
parent
4bf962f8a1
commit
a9dc4b4e7d
@ -153,6 +153,28 @@ std::wstring adjustSpacesSTD(const std::wstring& text,HookParam hp)
|
|||||||
default:return text;
|
default:return text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::wstring limitTextWidth(const std::wstring& text, int size)
|
||||||
|
{
|
||||||
|
auto lines=strSplit(text,L"\n");
|
||||||
|
std::for_each(lines.begin(),lines.end(),[=](auto &line){
|
||||||
|
if(line.size()<=size)
|
||||||
|
return;
|
||||||
|
std::wstring ret;
|
||||||
|
for(int i=0;i<line.size();i++){
|
||||||
|
ret+=line[i];
|
||||||
|
if((i<line.size()-1) &&( ((1+i)%size)==0)){
|
||||||
|
ret+=L'\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line=ret;
|
||||||
|
});
|
||||||
|
std::wstring ret;
|
||||||
|
for(int i=0;i<lines.size();i++){
|
||||||
|
ret+=lines[i];
|
||||||
|
if(i<lines.size()-1)ret+=L'\n';
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
bool isPauseKeyPressed()
|
bool isPauseKeyPressed()
|
||||||
{
|
{
|
||||||
return WinKey::isKeyControlPressed()
|
return WinKey::isKeyControlPressed()
|
||||||
@ -239,6 +261,7 @@ bool TextHook::waitfornotify(TextOutput_T* buffer,void*data ,size_t*len,ThreadPa
|
|||||||
if((translate.size()==0))return false;
|
if((translate.size()==0))return false;
|
||||||
translatecache.insert(std::make_pair(hash,translate));
|
translatecache.insert(std::make_pair(hash,translate));
|
||||||
}
|
}
|
||||||
|
if(embedsharedmem->line_text_length_limit)translate=limitTextWidth(translate,embedsharedmem->line_text_length_limit);
|
||||||
if(hp.newlineseperator)strReplace(translate,L"\n",hp.newlineseperator);
|
if(hp.newlineseperator)strReplace(translate,L"\n",hp.newlineseperator);
|
||||||
translate=adjustSpacesSTD(translate,hp);
|
translate=adjustSpacesSTD(translate,hp);
|
||||||
if(embedsharedmem->keeprawtext)translate=origin+L" "+translate;
|
if(embedsharedmem->keeprawtext)translate=origin+L" "+translate;
|
||||||
|
@ -115,7 +115,7 @@ C_LUNA_API void Luna_FindHooks(DWORD pid, SearchParam sp, findhookcallback_t fin
|
|||||||
wcscpy_s(hookcode,HOOKCODE_LEN, hp.hookcode);
|
wcscpy_s(hookcode,HOOKCODE_LEN, hp.hookcode);
|
||||||
findhookcallback(hookcode,text.c_str()); });
|
findhookcallback(hookcode,text.c_str()); });
|
||||||
}
|
}
|
||||||
C_LUNA_API void Luna_EmbedSettings(DWORD pid, UINT32 waittime, UINT8 fontCharSet, bool fontCharSetEnabled, wchar_t *fontFamily, UINT32 spaceadjustpolicy, UINT32 keeprawtext, bool fastskipignore)
|
C_LUNA_API void Luna_EmbedSettings(DWORD pid, UINT32 waittime, UINT8 fontCharSet, bool fontCharSetEnabled, wchar_t *fontFamily, UINT32 spaceadjustpolicy, UINT32 keeprawtext, bool fastskipignore, UINT32 line_text_length_limit)
|
||||||
{
|
{
|
||||||
auto sm = Host::GetEmbedSharedMem(pid);
|
auto sm = Host::GetEmbedSharedMem(pid);
|
||||||
if (!sm)
|
if (!sm)
|
||||||
@ -127,6 +127,7 @@ C_LUNA_API void Luna_EmbedSettings(DWORD pid, UINT32 waittime, UINT8 fontCharSet
|
|||||||
sm->spaceadjustpolicy = spaceadjustpolicy;
|
sm->spaceadjustpolicy = spaceadjustpolicy;
|
||||||
sm->keeprawtext = keeprawtext;
|
sm->keeprawtext = keeprawtext;
|
||||||
sm->fastskipignore = fastskipignore;
|
sm->fastskipignore = fastskipignore;
|
||||||
|
sm->line_text_length_limit=line_text_length_limit;
|
||||||
}
|
}
|
||||||
C_LUNA_API bool Luna_checkisusingembed(DWORD pid, uint64_t address, uint64_t ctx1, uint64_t ctx2)
|
C_LUNA_API bool Luna_checkisusingembed(DWORD pid, uint64_t address, uint64_t ctx1, uint64_t ctx2)
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,7 @@ struct EmbedSharedMem{
|
|||||||
wchar_t fontFamily[100];
|
wchar_t fontFamily[100];
|
||||||
UINT codepage;
|
UINT codepage;
|
||||||
bool fastskipignore;
|
bool fastskipignore;
|
||||||
|
UINT32 line_text_length_limit;
|
||||||
};
|
};
|
||||||
class TextHook
|
class TextHook
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user