Автор Тема: Загрузка шрифтов loadFontsTextures()  (Прочитано 5961 раз)

Оффлайн Sektor

  • Администратор
  • Постоялец
  • *****
  • Сообщений: 521
  • Репутация: +34/-0
    • Просмотр профиля
Загрузка шрифтов loadFontsTextures()
« : Март 31, 2014, 05:23:57 pm »
И так, привет всем! Вообщем по занимался реверсивной инженерией, вот что получилось:

Код: C++
  1. char fonts_name[] = "fonts";
  2. char fonts_path[] = "MODELS/FONTS.TXD";
  3.  
  4. char aFont2m[]  = "font2m";
  5. char aFont2[]   = "font2";
  6.  
  7. char aFont1m[]  = "font1m";
  8. char aFont1[]   = "font1";
  9.  
  10. void CFont__SetColor(RwRGBA * fontRGBA) {
  11.      auto __CFont_setColor = (void (__cdecl*)(RwRGBA * fontRGBA))0x0550170;
  12.          __CFont_setColor(fontRGBA);
  13. };
  14.  
  15.  
  16. void SetTextBackgroundColor(RwRGBA * bgRGBA) {
  17.         auto _SetTextBackgroundColor = (void (__cdecl*)(RwRGBA * fontRGBA))0x05500A0;
  18.         _SetTextBackgroundColor(bgRGBA);
  19. }
  20.  
  21. void restoreTexDictionary(){
  22.         auto _restoreTexDictionar = (void (__cdecl*)())0x0580AA0;
  23.         _restoreTexDictionar();
  24. }
  25.  
  26. void SetFontStyle(int fontIndex) {
  27.         auto _SetFontStyle = (void (__cdecl*)(int fontIndex))0x054FFE0;
  28.         _SetFontStyle(fontIndex);
  29. }
  30.  
  31.  
  32. //00552530
  33. auto _texFont2 = (CSprite2D*)0x0A108B4;
  34. auto _texFont1 = (CSprite2D*)0x0A108B8;
  35.  
  36. auto rsGlobal = (RsGlobalType*)0x09B48D8;
  37.  
  38. auto letterWidth  = (float*)0x097F824;
  39. auto letterHeight = (float*)0x097F828;
  40. auto flt_97F830   = (float*)0x097F830;
  41.  
  42. auto flt_97F834   = (float*)0x097F834;
  43. auto flt_97F82C   = (float*)0x097F82C;
  44.  
  45. auto textWidthAdjustment    = (char*)0x097F838;
  46. auto textCentered           = (char*)0x097F839;
  47. auto textAlignment          = (char*)0x097F83A;
  48. auto textDrawBox            = (char*)0x097F83B;
  49.  
  50. auto textBackgroundEnabled  = (char*)0x097F83C;
  51. auto textProportional       = (char*)0x097F83D;
  52.  
  53. auto _textLineWidth  = (float*)0x097F84C;
  54. auto fontStyle       = (WORD*)0x097F858;
  55. auto baseCharset     = (BYTE*)0x097F85A;
  56. auto fTextHTab       = (DWORD*)0x097F854;
  57. auto flt_97F844      = (float*)0x097F844;
  58.  
  59. auto word_97F860       = (WORD*)0x097F860;
  60.  
  61. auto textCenteredWidth = (float*)0x097F850;
  62.  
  63.                                              
  64. void EnableTextProportional() {
  65.         *textProportional = 1;
  66. };
  67.  
  68. void DisableTextProportional(){
  69.         *textProportional = 0;
  70. };
  71.  
  72. void SetTextDrawLeftAlignment(){
  73.         *textAlignment       = 0;
  74.         *textWidthAdjustment = 0;
  75.         *textCentered        = 0;
  76. };
  77.  
  78. void SetTextDrawRightAlignment() {
  79.         *textAlignment       = 1;
  80.         *textWidthAdjustment = 0;
  81.         *textCentered        = 0;
  82. };
  83.  
  84. void  DisableTextBackground(){
  85.         *textBackgroundEnabled = 0;
  86. };
  87.  
  88. void  EnableTextBackground() {
  89.         *textBackgroundEnabled = 1;
  90. };
  91.  
  92. void DisableTextDrawInBox(){
  93.         *textDrawBox = 0;
  94. };
  95.  
  96. void EnableTextDrawInBox(){
  97.         *textDrawBox = 1;
  98. };
  99.  
  100. void SetTextCenteredWidth(float textWidth){
  101.         *textCenteredWidth = textWidth;
  102. };
  103.  
  104. void SetTextLineWidth(float textWidth){
  105.         *_textLineWidth = textWidth;
  106. };
  107.  
  108. void DisableTextDrawCentered(){
  109.         *textCentered = 0;
  110. };
  111.  
  112. void EnableTextDrawCentered(){
  113.    *textCentered = 1;
  114.    *textWidthAdjustment = 0;
  115.    *textAlignment = 0;
  116. };
  117.  
  118. void DisableTextWidthAdjustment(){
  119.         *textWidthAdjustment = 0;
  120.         *textAlignment       = 0;
  121. };
  122.  
  123. void EnableTextWidthAdjustment(){
  124.         *textWidthAdjustment = 1;
  125.         *textCentered        = 0;
  126.         *textAlignment       = 0;
  127. };
  128.  
  129.  
  130. void SetLetterSize(float width, float height){
  131.         *letterWidth  = width;
  132.         *letterHeight = height;
  133. };
  134.  
  135.  
  136. void loadFontsTextures() {
  137.  RwRGBA rgbaFont;
  138.  RwRGBA rgbaFont2;
  139.  DWORD refTex = txdAdd(fonts_name);
  140.  
  141.  txdLoad(refTex, fonts_path);
  142.  txdAddRef(refTex);
  143.  saveTexDictionary();
  144.  txdSetCurrent(refTex);
  145.  
  146.  _texFont2->readTexture(aFont2, aFont2m);
  147.  _texFont1->readTexture(aFont1, aFont1m);
  148.  
  149.  *letterWidth  = 1.0f;
  150.  *letterHeight = 1.0f;
  151.  
  152.  *flt_97F830 = rsGlobal->w;
  153.  *flt_97F834 = 0;
  154.  *flt_97F82C = 0;
  155.  
  156.  rgbaFont.alpha = 0;
  157.  rgbaFont.red   = 255;
  158.  rgbaFont.green = 255;
  159.  rgbaFont.blue  = 255;
  160.  CFont__SetColor(&rgbaFont);
  161.  
  162.  *textWidthAdjustment = 0;  //
  163.  *textAlignment = 0;        //
  164.  *textCentered  = 0;        //
  165.  
  166.  *_textLineWidth = rsGlobal->w;
  167.  
  168.  rgbaFont2.alpha = 128;
  169.  rgbaFont2.blue  = 128;
  170.  rgbaFont2.green = 128;
  171.  rgbaFont2.red   = 128;
  172.  SetTextBackgroundColor(&rgbaFont2);
  173.  
  174.  *textBackgroundEnabled = 0;
  175.  *textProportional      = 1;
  176.  *fontStyle             = 0;
  177.  *baseCharset           = 0;
  178.  *fTextHTab             = 0;
  179.  *flt_97F844            = 255.0;
  180.  *word_97F860           = 0;
  181.  restoreTexDictionary();
  182. }


Плюс входят следующие прототипы-обвертки и структуры:

Код: C++
  1. int txdAdd(char *name){
  2.     auto _txdAdd    = (int (__cdecl*)(char *name) )0x0580F00;
  3.         return _txdAdd(name);
  4. };
  5.  
  6. int txdLoad(int a, char *FileName) {
  7.         auto _txdLoad  = (int (__cdecl*)(int a, char *Pathname) )0x0580CD0;
  8.     return _txdLoad(a, FileName);
  9. };
  10.  
  11. int txdAddRef(int a) {
  12.         auto _txdAddRef = (int (__cdecl*)(int a) )0x0580A60;
  13.     return _txdAddRef(a);
  14. };
  15.  
  16. int txdIndexByName(char *name) {
  17.    auto _txdIndexByName = (int (__cdecl*)(char *name) )0x0580D70;
  18.    return _txdIndexByName(name);
  19. };
  20.  
  21.  
  22. int txdSetCurrent(int index) {
  23.    auto _txdSetCurrent = (int (__cdecl*)(int index) )0x0580AD0;
  24.    return _txdSetCurrent(index);
  25. };
  26.  
  27. CTexture * RwReadTexture(char *name, int a2){
  28.     auto  _RwReadTexture = ( CTexture * (__cdecl*)(char *name, int a2) )0x064E110;
  29.         return _RwReadTexture(name, a2);
  30. }
  31.  
  32. //.text:00580AC0   ; void __cdecl saveTexDictionary
  33.  
  34. void saveTexDictionary(){
  35.         auto _saveTexDictionary = (void (__cdecl*)() )0x0580AC0;
  36.         _saveTexDictionary();
  37. }
  38.  


Код: C++
  1. #pragma pack (push, 1)
  2.  
  3.  
  4. struct RsInputDevice {
  5.  DWORD inputDeviceType;
  6.  DWORD used;
  7.  DWORD inputEventHandler;
  8. };
  9.  
  10.  
  11. struct RsGlobalType{
  12.  DWORD AppName;
  13.  DWORD MaximumWidth;
  14.  DWORD MaximumHeight;
  15.  DWORD w;
  16.  DWORD h;
  17.  DWORD frameLimit;
  18.  DWORD quit;
  19.  DWORD ps;
  20.  RsInputDevice keyboard;
  21.  RsInputDevice mouse;
  22.  RsInputDevice pad;
  23. };
  24.  
  25.  
  26. #pragma pack ( pop)
  27.  
  28.  
  29. void loadFontsTextures();
  30.  


и другие с RWG модуля...
Далее, вы знаете что делать в плагине:

Код: C++
  1. injectFunction(0x0552310, (DWORD)loadFontsTextures);

Таким образом можно внедрить свой код в загрузку фонтов, или во все изменить загружаемые фонты...

Оффлайн mfisto

  • Скриптер
  • Главный Модератор
  • Новичок
  • *****
  • Сообщений: 176
  • Репутация: +19/-0
  • Не пью, не курю, за компьютером сижу...
    • mfistof
    • Просмотр профиля
    • Empire of CJ
Re: Загрузка шрифтов loadFontsTextures()
« Ответ #1 : Апрель 01, 2014, 05:20:19 am »
Т. е. ты имеешь ввиду, что можно поступить так же, как Бука поступила с GTA III -> расширить таблицу символов и добавить полноценную кириллицу?
I know everything and nothing...

Оффлайн Sektor

  • Администратор
  • Постоялец
  • *****
  • Сообщений: 521
  • Репутация: +34/-0
    • Просмотр профиля
Re: Загрузка шрифтов loadFontsTextures()
« Ответ #2 : Апрель 01, 2014, 05:27:28 am »
Пока еще нет, много чего не до деланно, например есть еще где-то функции отрисовки и прочие...