Logo
live-news-icon

Noticias

Tema: [Sources] Layer Shade Font

Applayo

  • *
[Sources] Layer Shade Font | en: Abril 10, 2021, 09:53:06 am »

estaba revisando un par de cosas, y como tengo la SRC del Main vi como hacia el sistema de texto y me di la amabilidad de compartirla con ustedes.

Por:
Eu estava verificando algumas coisas, e como tenho o SRC do Main, vi como ele foi para o sistema de texto e tive a gentileza de compartilhar com vocês.



CGLFont.h
Code:

// GLFont.h: interface for the CGLFont class.
#pragma once

class CGLFont
{
public:
   CGLFont();
   virtual ~CGLFont();
   void ClearFontHdc( );
   void FontHdc(HFONT font);
   void FontColor( GLfloat R, GLfloat G, GLfloat B, GLfloat Alpha);
   void PaintFont(int DirPathX, int DirPathY, LPCSTR lpString, int DirPathW, int DirPathAling);
public:
   HFONT hFont;
   GLfloat ColorFont[4];
};
extern CGLFont CFont;


CGLFont.cpp
Code:

#include "stdafx.h"
#include "GLFont.h"
#include "Import.h"
//#include "CNewFrame.h"

CGLFont CFont;

CGLFont::CGLFont()
{
   this->ColorFont[0] = 1.0;
   this->ColorFont[1] = 1.0;
   this->ColorFont[2] = 1.0;
   this->ColorFont[3] = 1.0;
   this->hFont = CreateFontA ( 14, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH, "Arial" ); // Creamos la Font
}

CGLFont::~CGLFont()
{

}

void CGLFont::ClearFontHdc( )
{
   this->hFont = CreateFontA ( 14, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH, "Arial" ); // Creamos la Font
}

void CGLFont::FontHdc(HFONT font)
{
   this->hFont = font;
}

void CGLFont::FontColor( GLfloat R, GLfloat G, GLfloat B, GLfloat Alpha)
{
   this->ColorFont[0] = R/255;
   this->ColorFont[1] = G/255;
   this->ColorFont[2] = B/255;
   this->ColorFont[3] = Alpha/255;
}

void CGLFont::PaintFont(int DirPathX, int DirPathY, LPCSTR lpString, int DirPathW, int DirPathAling) //平面字符显示,不支持汉字。
{
   HDC hDC = GetDC(*(HWND*)(0x00E8C578));
   struct tagSIZE psizl;
   static SHORT FontWidth[255]; //平面字符显示,不支持汉字。
   static UINT FontListID; //不使用光照
   float v28; // [sp+40h] [bp-34h]@10
   float v29; // [sp+44h] [bp-30h]@10
   signed int v30; // [sp+48h] [bp-2Ch]@14
   signed int v36; // [sp+4Ch] [bp-28h]@46
   float v32; // [sp+50h] [bp-24h]@10
   float v38; // [sp+54h] [bp-20h]@10
   float v34; // [sp+58h] [bp-1Ch]@10
   float v35; // [sp+5Ch] [bp-18h]@10

   float v33; // ST1C_4@5

   if ( !FontListID )
   {
      FontListID = glGenLists ( 256 );

      while ( !wglUseFontBitmapsA ( hDC, 0, 255, FontListID ) )
         Sleep ( 1 );
   }

   SelectObject(hDC, this->hFont);
   GetTextExtentPoint32(hDC, lpString, strlen(lpString), &psizl);

   v28 = (double)DirPathX * pWinWidthReal;
   v29 = (double)DirPathY * pWinHeightReal;
   v32 = (double)DirPathW * pWinWidthReal;
   v34 = (double)(signed int)psizl.cx;
   v35 = (double)(signed int)psizl.cy;
   if ( v32 == 0.0 )
      v32 = (double)(signed int)psizl.cx;
   v36 = 0;
   v30 = 0;

   switch(DirPathAling)
   {
   case 2:
      if ( v32 < (double)v34 )
      {
         v30 = (signed int)(v34 - v32);
         v34 = v32;
      }
      break;
   case 1:
      if ( v32 < (double)v34 )
         v34 = v32;
      break;
   case 3:
      if ( v32 >= (double)v34 )
      {
         v36 = (signed int)((v32 - v34) / 2.0);
      }
      else
      {
         v30 = (signed int)((v34 - v32) / 2.0);
         v34 = v32;
      }
      break;
   case 4:
      if ( v32 >= (double)v34 )
      {
         v36 = (signed int)(v32 - v34);
      }
      else
      {
         v30 = (signed int)(v34 - v32);
         v34 = v32;
      }
      break;
   case 7:
      if ( v32 >= (double)v34 )
      {
         v36 = (signed int)(v32 - v34);
      }
      else
      {
         v30 = (signed int)(v34 - v32);
         v34 = v32;
      }
      v28 = v28 - v32;
      break;
   case 8:
      if ( v32 >= (double)v34 )
      {
         v36 = (signed int)((v32 - v34) / 2.0);
      }
      else
      {
         v30 = (signed int)((v34 - v32) / 2.0);
         v34 = v32;
      }
      v28 = v28 - v32 / 2.0;
      break;
   }

   v33 = (double)pWinHeight - v29;

   GLfloat ColorFont[4];
   glGetFloatv ( GL_CURRENT_COLOR, ColorFont );

   glListBase ( FontListID ); //创建大小为96显示列表,存放字符位图

   glColor4f( 0.0, 0.0, 0.0, 0.8);

   glRasterPos2f( v28 - 0.5, v33 - 0.5 );
   glCallLists( strlen ( lpString ), GL_UNSIGNED_BYTE, lpString ); //保存显示列表位属性

   glRasterPos2f( v28 + 0.5, v33 - 0.5 );
   glCallLists( strlen ( lpString ), GL_UNSIGNED_BYTE, lpString ); //保存显示列表位属性

   glRasterPos2f( v28 + 0.5, v33 + 0.5 );
   glCallLists( strlen ( lpString ), GL_UNSIGNED_BYTE, lpString ); //保存显示列表位属性

   glRasterPos2f( v28 - 0.5, v33 + 0.5 );
   glCallLists( strlen ( lpString ), GL_UNSIGNED_BYTE, lpString ); //保存显示列表位属性

   //-- //获取设置场景
   glColor4fv(this->ColorFont);

   glRasterPos2f( v28, v33 ); //不使用贴图
   glCallLists( strlen ( lpString ), GL_UNSIGNED_BYTE, lpString ); //创建大小为96显示列表,存放字符位图

   glColor4fv(ColorFont);
}



Creditos: @YolaxD e @takumi12
« Última modificación: Abril 10, 2021, 10:11:47 am por Applayo »

robins1998

  • *
Re: [Sources] Layer Shade Font | Respuesta #1 en: Mayo 27, 2021, 02:46:02 am »

Very helpful, thanks for sharing.


Responder Marcar No Leido Enviar Topic Print