⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guitypes.cc

📁 五行MMORPG引擎系统V1.0
💻 CC
📖 第 1 页 / 共 2 页
字号:
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

#include "platform/platform.h"
#include "platform/types.h"
#include "console/consoleTypes.h"
#include "console/console.h"
#include "dgl/gNewFont.h"
#include "dgl/dgl.h"
#include "gui/core/guiTypes.h"
#include "dgl/gBitmap.h"
#include "dgl/gTexManager.h"
#include "gui/controls/guiCellButtonCtrl.h"

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //
IMPLEMENT_CONOBJECT(GuiCursor);


#ifdef TGE_RPG
IMPLEMENT_CONSOLETYPE(GuiCursor);
IMPLEMENT_SETOBJECTTYPE(GuiCursor);
IMPLEMENT_GETOBJECTTYPE(GuiCursor);
#endif

GuiCursor::GuiCursor()
{
   mHotSpot.set(0,0);
   mRenderOffset.set(0.0f,0.0f);
   mExtent.set(1,1);
#ifdef TGE_RPG_UI
	mBitmapOld	= 0;
	mBitmapName	= 0;
	m_pDragCell	= NULL;
#endif
}

GuiCursor::~GuiCursor()
{
}

void GuiCursor::initPersistFields()
{
   Parent::initPersistFields();
   addField("hotSpot",     TypePoint2I,   Offset(mHotSpot, GuiCursor));
   addField("renderOffset",TypePoint2F,   Offset(mRenderOffset, GuiCursor));
   addField("bitmapName",  TypeFilename,  Offset(mBitmapName, GuiCursor));
}

bool GuiCursor::onAdd()
{
   if(!Parent::onAdd())
      return false;

   Sim::getGuiDataGroup()->addObject(this);

   return true;
}

void GuiCursor::onRemove()
{
   Parent::onRemove();
}


void GuiCursor::render(const Point2I &pos)
{
	//绘画拖拉图标
	if(m_pDragCell)
	{
		m_pDragCell->drawDragCursor(pos);
		return;
	}

#ifdef TGE_RPG_UI
   if (mBitmapOld != mBitmapName)
		setBitmap(mBitmapName);

   if (!mTextureHandle)
		return;
#else
   if (!mTextureHandle && mBitmapName && mBitmapName[0])
   {
      mTextureHandle = TextureHandle(mBitmapName, BitmapTexture);
      if(!mTextureHandle)
         return;
      mExtent.set(mTextureHandle.getWidth(), mTextureHandle.getHeight());
   }
#endif

   // Render the cursor centered according to dimensions of texture
   S32 texWidth = mTextureHandle.getWidth();
   S32 texHeight = mTextureHandle.getWidth();

   Point2I renderPos = pos;
   renderPos.x -= ( texWidth  * mRenderOffset.x );
   renderPos.y -= ( texHeight * mRenderOffset.y );
   
   dglClearBitmapModulation();
   dglDrawBitmap(mTextureHandle, renderPos);
}


#ifdef TGE_RPG_UI

void GuiCursor::setDragCell(GuiCellButtonCtrl	*pDragCell)
{
	m_pDragCell = pDragCell;
}

void GuiCursor::setBitmap(StringTableEntry pName)
{
   if (pName && pName[0])
   {
      mTextureHandle = TextureHandle(pName, BitmapTexture);
      if(mTextureHandle)
			mExtent.set(mTextureHandle.getWidth(), mTextureHandle.getHeight());
   }
	mBitmapName = pName;
	mBitmapOld	= pName;
}


ConsoleMethod(GuiCursor,setBitmap,void,3,3,"setBitmap(pName)")
{
	argc;
	object->setBitmap(argv[2]);
}
#endif


//------------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(GuiControlProfile);

static EnumTable::Enums alignEnums[] =
{
   { GuiControlProfile::LeftJustify,          "left"      },
   { GuiControlProfile::CenterJustify,        "center"    },
   { GuiControlProfile::RightJustify,         "right"     }
};
static EnumTable gAlignTable(3, &alignEnums[0]);

static EnumTable::Enums charsetEnums[]=
{
    { TGE_ANSI_CHARSET,         "ANSI" },
    { TGE_SYMBOL_CHARSET,       "SYMBOL" },
    { TGE_SHIFTJIS_CHARSET,     "SHIFTJIS" },
    { TGE_HANGEUL_CHARSET,      "HANGEUL" },
    { TGE_HANGUL_CHARSET,       "HANGUL" },
    { TGE_GB2312_CHARSET,       "GB2312" },
    { TGE_CHINESEBIG5_CHARSET,  "CHINESEBIG5" },
    { TGE_OEM_CHARSET,          "OEM" },
    { TGE_JOHAB_CHARSET,        "JOHAB" },
    { TGE_HEBREW_CHARSET,       "HEBREW" },
    { TGE_ARABIC_CHARSET,       "ARABIC" },
    { TGE_GREEK_CHARSET,        "GREEK" },
    { TGE_TURKISH_CHARSET,      "TURKISH" },
    { TGE_VIETNAMESE_CHARSET,   "VIETNAMESE" },
    { TGE_THAI_CHARSET,         "THAI" },
    { TGE_EASTEUROPE_CHARSET,   "EASTEUROPE" },
    { TGE_RUSSIAN_CHARSET,      "RUSSIAN" },
    { TGE_MAC_CHARSET,          "MAC" },
    { TGE_BALTIC_CHARSET,       "BALTIC" },
};

#define NUMCHARSETENUMS     (sizeof(charsetEnums) / sizeof(EnumTable::Enums))

static EnumTable gCharsetTable(NUMCHARSETENUMS, &charsetEnums[0]);

StringTableEntry GuiControlProfile::sFontCacheDirectory = "";

GuiControlProfile::GuiControlProfile(void) :
   mFontColor(mFontColors[BaseColor]),
   mFontColorHL(mFontColors[ColorHL]),
   mFontColorNA(mFontColors[ColorNA]),
   mFontColorSEL(mFontColors[ColorSEL])
{
   mRefCount = 0;
   mBitmapArrayRects.clear();
   mBorderThickness = 1;
   mMouseOverSelected = false;
   mBitmapName = NULL;
   mFontCharset   = TGE_ANSI_CHARSET;
   mOldBitmapName = NULL;		/// TGE_Theme

   GuiControlProfile *def = dynamic_cast<GuiControlProfile*>(Sim::findObject("GuiDefaultProfile"));
   if (def)
   {
      mTabable       = def->mTabable;
      mCanKeyFocus   = def->mCanKeyFocus;

      mOpaque        = def->mOpaque;
      mFillColor     = def->mFillColor;
      mFillColorHL   = def->mFillColorHL;
      mFillColorNA   = def->mFillColorNA;

      mBorder        = def->mBorder;
      mBorderThickness = def->mBorderThickness;
      mBorderColor   = def->mBorderColor;
      mBorderColorHL = def->mBorderColorHL;
      mBorderColorNA = def->mBorderColorNA;

      mBevelColorHL = def->mBevelColorHL;
      mBevelColorLL = def->mBevelColorLL;

      // default font
      mFontType      = def->mFontType;
      mFontSize      = def->mFontSize;
      mFontCharset   = def->mFontCharset;

      for(U32 i = 0; i < 10; i++)
         mFontColors[i] = def->mFontColors[i];

      // default bitmap
      mBitmapName    = def->mBitmapName;
      mTextOffset    = def->mTextOffset;

      // default sound
      mSoundButtonDown = def->mSoundButtonDown;
      mSoundButtonOver = def->mSoundButtonOver;

      //used by GuiTextCtrl
      mModal         = def->mModal;
      mAlignment     = def->mAlignment;
      mAutoSizeWidth = def->mAutoSizeWidth;
      mAutoSizeHeight= def->mAutoSizeHeight;
      mReturnTab     = def->mReturnTab;
      mNumbersOnly   = def->mNumbersOnly;
      mCursorColor   = def->mCursorColor;

#ifdef TGE_RPG_UI
	   mOldBitmapName = 0;//def->mBitmapName;  //TGE_Theme
		//mTextureHandle	= def->mTextureHandle;
		//if(bool(mTextureHandle))
		//{	
		//	mBitmapArrayRects.setSize(def->mBitmapArrayRects.size());
		//	for(U32 n=0; n < mBitmapArrayRects.size(); n++)
		//		mBitmapArrayRects[n] = def->mBitmapArrayRects[n];
		//}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -