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

📄 guimltextctrl.cc

📁 五行MMORPG引擎系统V1.0
💻 CC
📖 第 1 页 / 共 5 页
字号:
				else if(bool(mCurStyle->font->fontRes))
				{
					mCurTabStop++;
					nWidth = mCurTabStop * mCurStyle->font->fontRes->getHeight()*2;
					if(mCurX - mCurLMargin < nWidth)
						mCurX = mCurLMargin + nWidth;
				}
			}
			else
			{
				mCurTabStop++;
				nWidth = mCurTabStop * m_nFontDefaultHeight*2;
				if(mCurX - mCurLMargin < nWidth)
					mCurX = mCurLMargin + nWidth;
			}
#else
         if(mTabStopCount)
         {
            if(mCurTabStop < mTabStopCount)
            {
               if(mCurX < mTabStops[mCurTabStop])
                  mCurX = mTabStops[mCurTabStop];
            }
            mCurTabStop++;
         }
#endif
         continue;
      }

      if(curChar == '<')
      {
         // it's probably some kind of tag:

         // Get the next few bytes so we have enough space to
         // parse things...
         FrameTemp<UTF8> silly(1024);
         StringBuffer sillyBuf = mTextBuffer.substring(mScanPos, getMin((S32)1024, (S32)(mTextBuffer.length() - mScanPos)));
         sillyBuf.get(silly, 1023);

         char *str = silly;
#ifdef TGE_CHINESE
			U32  nGBNum(0);
#endif

         //  And go!

#ifdef TGE_RPG
         if ( !dStrnicmp( str + 1, "lnheight:", 9 ) )
         {
            idx = 10;
            if ( !scanforchar( str, idx, '>' ) )
               goto textemit;
            m_nLineHeightMin = dAtoi( str + 10 );
				if(m_nLineHeightMin < 0)
					m_nLineHeightMin = 0;

            mScanPos += idx + 1;
            continue;
         }

         if ( !dStrnicmp( str + 1, "charWidth:", 10 ) )
         {
            idx = 11;
            if ( !scanforchar( str, idx, '>' ) )
               goto textemit;
            m_nFontDefaultHeight = dAtoi( str + 11 );
				if(m_nFontDefaultHeight < 0)
					m_nFontDefaultHeight = 0;

            mScanPos += idx + 1;
            continue;
         }
#endif

         if(!dStrnicmp(str + 1, "br>", 3))
         {
            mScanPos += 4;
            len = 4;
            textStart = mScanPos + 4;
            processEmitAtoms();
            emitNewLine(textStart);
            mCurDiv = 0;
            continue;
         }

         if(!dStrnicmp(str + 1, "font:", 5))
         {
            // scan for the second colon...
            // at each level it should drop out to the text case below...
            idx = 6;
#ifdef TGE_CHINESE
            if(!scanforchar(str, idx, ':',&nGBNum))
               goto textemit;

            sizidx = idx + 1;
            if(!scanforchar(str, sizidx, '>',&nGBNum))
               goto textemit;
#else
            if(!scanforchar(str, idx, ':'))
               goto textemit;

            sizidx = idx + 1;
            if(!scanforchar(str, sizidx, '>'))
               goto textemit;
#endif

            U32 size = dAtoi(str + idx + 1);
            if(!size || size > 64)
               goto textemit;
            textStart = mScanPos + 6;
            len = idx - 6;

#ifdef TGE_CHINESE
            mScanPos += sizidx + 1 - nGBNum;
#else
            mScanPos += sizidx + 1;
#endif

            nextFont = allocFont(str + 6, len, size);
            if(nextFont)
            {
               if(mCurStyle->used)
                  mCurStyle = allocStyle(mCurStyle);
               mCurStyle->font = nextFont;
            }
            continue;
         }

         if ( !dStrnicmp( str + 1, "tag:", 4 ) )
         {
            idx = 5;
            if ( !scanforchar( str, idx, '>' ) )
               goto textemit;
            U32 tagId = dAtoi( str + 5 );
            nextTag = allocLineTag( tagId );

            mScanPos += idx + 1;
            continue;
         }

         if(!dStrnicmp(str +1, "color:", 6))
         {
            idx = 7;
            if(!scanforchar(str, idx, '>'))
               goto textemit;
            if(idx != 13 && idx != 15)
               goto textemit;
            ColorI color;

            color.red = getHexVal(str[7]) * 16 + getHexVal(str[8]);
            color.green = getHexVal(str[9]) * 16 + getHexVal(str[10]);
            color.blue = getHexVal(str[11]) * 16 + getHexVal(str[12]);
            if(idx == 15)
               color.alpha = getHexVal(str[13]) * 16 + getHexVal(str[14]);
            else
               color.alpha = 255;
            mScanPos += idx + 1;

            if(mCurStyle->used)
               mCurStyle = allocStyle(mCurStyle);
            mCurStyle->color = color;

            continue;
         }

         if(!dStrnicmp(str +1, "shadowcolor:", 12))
         {
            idx = 13;
            if(!scanforchar(str, idx, '>'))
               goto textemit;
            if(idx != 19 && idx != 21)
               goto textemit;
            ColorI color;

            color.red = getHexVal(str[13]) * 16 + getHexVal(str[14]);
            color.green = getHexVal(str[15]) * 16 + getHexVal(str[16]);
            color.blue = getHexVal(str[17]) * 16 + getHexVal(str[18]);
            if(idx == 21)
               color.alpha = getHexVal(str[19]) * 16 + getHexVal(str[20]);
            else
               color.alpha = 255;
            mScanPos += idx + 1;

            if(mCurStyle->used)
               mCurStyle = allocStyle(mCurStyle);
            mCurStyle->shadowColor = color;

            continue;
         }

         if(!dStrnicmp(str +1, "linkcolor:", 10))
         {
            idx = 11;
            if(!scanforchar(str, idx, '>'))
               goto textemit;
            if(idx != 17 && idx != 19)
               goto textemit;
            ColorI color;

            color.red = getHexVal(str[11]) * 16 + getHexVal(str[12]);
            color.green = getHexVal(str[13]) * 16 + getHexVal(str[14]);
            color.blue = getHexVal(str[15]) * 16 + getHexVal(str[16]);
            if(idx == 19)
               color.alpha = getHexVal(str[17]) * 16 + getHexVal(str[18]);
            else
               color.alpha = 255;
            mScanPos += idx + 1;

            if(mCurStyle->used)
               mCurStyle = allocStyle(mCurStyle);
            mCurStyle->linkColor = color;

            continue;
         }

         if(!dStrnicmp(str +1, "linkcolorhl:", 12))
         {
            idx = 13;
            if(!scanforchar(str, idx, '>'))
               goto textemit;
            if(idx != 19 && idx != 21)
               goto textemit;
            ColorI color;

            color.red = getHexVal(str[13]) * 16 + getHexVal(str[14]);
            color.green = getHexVal(str[15]) * 16 + getHexVal(str[16]);
            color.blue = getHexVal(str[17]) * 16 + getHexVal(str[18]);
            if(idx == 21)
               color.alpha = getHexVal(str[19]) * 16 + getHexVal(str[20]);
            else
               color.alpha = 255;
            mScanPos += idx + 1;

            if(mCurStyle->used)
               mCurStyle = allocStyle(mCurStyle);
            mCurStyle->linkColorHL = color;

            continue;
         }
         if(!dStrnicmp(str +1, "shadow:", 7))
         {
            idx = 8;
            if(!scanforchar(str, idx, ':'))
               goto textemit;
            U32 yidx = idx + 1;
            if(!scanforchar(str, yidx, '>'))
               goto textemit;
            mScanPos += yidx + 1;
            Point2I offset;
            offset.x = dAtoi(str + 8);
            offset.y = dAtoi(str + idx + 1);
            if(mCurStyle->used)
               mCurStyle = allocStyle(mCurStyle);
            mCurStyle->shadowOffset = offset;
            continue;
         }

#ifdef TGE_RPG
			if(!dStrnicmp(str +1, "icon:", 5))
         {
				S32 start = 6;
				idx = start;
            if(!scanforchar(str, idx, '>',&nGBNum))
               goto textemit;
            textStart = mScanPos + start;
            len = idx - start;

            mScanPos += idx + 1 - nGBNum;

            processEmitAtoms();
            Bitmap *bmp;
            bmp = allocIcon(str + 6, len);
            if(bmp)
               emitBitmapToken(bmp, textStart, false);
            continue;
         }
#endif

         if(!dStrnicmp(str +1, "bitmap", 6))
         {
            S32 start = 8;
            bool bitBrk = false;
            if(str[7] == 'k' && str[8] == ':')
            {
               bitBrk = true;
               start = 9;
            }
            else if(str[7] != ':')
               goto textemit;
#ifdef TGE_CHINESE
            idx = start;
            if(!scanforchar(str, idx, '>',&nGBNum))
               goto textemit;
            textStart = mScanPos + start;
            len = idx - start;

            mScanPos += idx + 1 - nGBNum;
#else
            idx = start;
            if(!scanforchar(str, idx, '>'))
               goto textemit;
            textStart = mScanPos + start;
            len = idx - start;

            mScanPos += idx + 1;
#endif

            processEmitAtoms();
            Bitmap *bmp;
            bmp = allocBitmap(str + 8, len);
            if(bmp)
               emitBitmapToken(bmp, textStart, bitBrk);
            continue;
         }

         if(!dStrnicmp(str +1, "spush>", 6))
         {
            mScanPos += 7;
            newStyle = allocStyle(mCurStyle); // copy out all the attributes...
            newStyle->next = mCurStyle;
            mCurStyle = newStyle;
            continue;
         }

         if(!dStrnicmp(str +1, "spop>", 5))
         {
            mScanPos += 6;
            if(mCurStyle->next)
               mCurStyle = mCurStyle->next;
            continue;
         }

         if(!dStrnicmp(str +1, "sbreak>", 7))
         {
            mScanPos += 8;
            processEmitAtoms();
            while(mBlockList != &mSentinel)
               emitNewLine(mScanPos);
            continue;
         }

         if(!dStrnicmp(str +1, "just:left>", 10))
         {
            processEmitAtoms();
            mCurJustify = LeftJustify;
            mScanPos += 11;
            continue;
         }

         if(!dStrnicmp(str +1, "just:right>", 11))
         {
            processEmitAtoms();
            mCurJustify = RightJustify;
            mScanPos += 12;
            continue;
         }

         if(!dStrnicmp(str +1, "just:center>", 12))
         {
            processEmitAtoms();
            mCurJustify = CenterJustify;
            mScanPos += 13;
            continue;
         }

         if(!dStrnicmp(str +1, "a:", 2))
         {
            idx = 3;
#ifdef TGE_CHINESE
            if(!scanforchar(str, idx, '>',&nGBNum))
               goto textemit;
#else
            if(!scanforchar(str, idx, '>'))
               goto textemit;
#endif
            mCurURL = (URL *) mViewChunker.alloc(sizeof(URL));
            mCurURL->mouseDown = false;
            mCurURL->textStart = mScanPos + 3;
            mCurURL->len = idx - 3;
            mCurURL->noUnderline = false;

            //if the URL is a "gamelink", don't underline...
#ifdef TGE_RPG
				if (str[3] == '@' || !dStrnicmp(str + 3, "gamelink", 8))
#else
            if (!dStrnicmp(str + 3, "gamelink", 8))
#endif
               mCurURL->noUnderline = true;


#ifdef TGE_CHINESE
            mScanPos += idx + 1 - nGBNum;
#else
            mScanPos += idx + 1;
#endif
            continue;
         }

         if(!dStrnicmp(str+1, "/a>", 3))
         {
            mCurURL = NULL;
            mScanPos += 4;
            continue;
         }

         U32 margin;

         if(!dStrnicmp(str + 1, "lmargin%:", 9))
         {
            idx = 10;
            if(!scanforchar(str, idx, '>'))
               goto textemit;
            margin = (mBounds.extent.x * dAtoi(str + 10)) / 100;
            mScanPos += idx + 1;
            goto setleftmargin;
         }

         if(!dStrnicmp(str + 1, "lmargin:", 8))
         {
            idx = 9;
            if(!scanforchar(str, idx, '>'))
               goto textemit;
            margin = dAtoi(str + 9);
            mScanPos += idx + 1;
setleftmargin:
            processEmitAtoms();
            U32 oldLMargin;
            oldLMargin = mCurLMargin;
            mCurLMargin = margin;
            if(mCurLMargin >= width)
               mCurLMargin = width - 1;
            if(mCurX == oldLMargin)
               mCurX = mCurLMargin;
            if(mCurX < mCurLMargin)
               mCu

⌨️ 快捷键说明

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