public void RenderText(string text, float x, float y, float scale, vec3 color) { TextRender.BeginBatch(); float c_Char = x; foreach (char c in text) { if (!Characters.ContainsKey(c)) { continue; } Character ch = Characters[c]; float xpos = c_Char + ch.bearing.x * scale; float ypos = y - (ch.size.y - ch.bearing.y) * scale; float w = ch.size.x * scale; float h = ch.size.y * scale; TextRender.DrawText(new vec2(xpos, ypos + h), new vec2(w, -h), ch.textureID, color); // TODO: Do a decent bit shift and remove this Gap multiplication c_Char += ((ch.Advance * Gap) >> 6) * scale; } TextRender.EndBatch(); TextRender.Flush(); }
/// <summary> /// 战斗胜利消息界面 /// </summary> /// <param name="context"></param> /// <param name="top">消息显示Y坐标</param> /// <param name="msg"></param> public MsgScreen(SimulatorContext context, int top, string msg) : base(context) { byte[] msgData; try { msgData = msg.GetBytes(); } catch (Exception ex) { Debug.WriteLine(ex); msgData = new byte[0]; } ResImage side = Context.LibData.GetImage(2, 8); _messageImg = Context.GraphicsFactory.NewImageBuilder(msgData.Length * 8 + 8, 24); ICanvas canvas = Context.GraphicsFactory.NewCanvas(_messageImg);; canvas.DrawColor(Constants.COLOR_WHITE); side.Draw(canvas, 1, 0, 0); side.Draw(canvas, 2, _messageImg.Width - 3, 0); Paint paint = new Paint(PaintStyle.FILL_AND_STROKE, Constants.COLOR_BLACK); canvas.DrawLine(0, 1, _messageImg.Width, 1, paint); canvas.DrawLine(0, 22, _messageImg.Width, 22, paint); TextRender.DrawText(canvas, msgData, 4, 4); _left = (160 - _messageImg.Width) / 2; _top = top; }
public override void Draw(ICanvas canvas) { canvas.DrawColor(Constants.COLOR_WHITE); canvas.DrawBitmap(Context.Util.bmpChuandai, 160 - Context.Util.bmpChuandai.Width, 0); // 画装备 for (int i = 0; i < 8; i++) { if (_curEquipments[i] != null) { _curEquipments[i].Draw(canvas, _pos[i].X + 1, _pos[i].Y + 1); } } canvas.DrawRect(_pos[_curItemIndex].X, _pos[_curItemIndex].Y, _pos[_curItemIndex].X + 25, _pos[_curItemIndex].Y + 25, Context.Util.sBlackPaint); TextRender.DrawText(canvas, _itemNames[_curItemIndex], 120, 80); // 画人物头像、姓名 if (_curCharacterIndex >= 0) { PlayerCharacter p = Context.PlayContext.PlayerCharacters[_curCharacterIndex]; p.DrawHead(canvas, 44, 12); TextRender.DrawText(canvas, p.Name, 30, 40); } if (_showingDesc) { canvas.DrawBitmap(_nameImg, 9, 10); canvas.DrawBitmap(_descImg, 9, 28); TextRender.DrawText(canvas, _nameText, 9 + 3, 10 + 3); _nextToDraw = TextRender.DrawText(canvas, _descText, _toDraw, _rectDesc); } }
public override void Draw(ICanvas canvas) { canvas.DrawBitmap(_background, 12, 21); TextRender.DrawText(canvas, "金钱:" + _money, 15, 24); TextRender.DrawText(canvas, _goods.Name, 15, 40); TextRender.DrawText(canvas, ": " + (_goods.GoodsNum - _saleCount), 93, 40); TextRender.DrawText(canvas, "卖出个数 :" + _saleCount, 15, 56); }
public override void Draw(ICanvas canvas) { canvas.DrawColor(Constants.COLOR_WHITE); TextRender.DrawText(canvas, _magic.Name, 0, _nameRect); PlayerCharacter character = Context.PlayContext.PlayerCharacters[_selectedCharacterIndex]; character.DrawState(canvas, _curStatePageIndex); character.DrawHead(canvas, 5, 60); }
public override void Draw(ICanvas canvas) { canvas.DrawBitmap(_background, 39, 29); TextRender.DrawText(canvas, _operateItems[_firstIndex], _strX, _strY); TextRender.DrawText(canvas, _operateItems[_firstIndex + 1], _strX, _strY + 16); TextRender.DrawText(canvas, _operateItems[_firstIndex + 2], _strX, _strY + 32); TextRender.DrawSelText(canvas, _operateItems[_selectedIndex], _strX, _selectedY); canvas.DrawBitmap(_arrowImgs[_arrowImgIndex], _arrowX, _arrowY); }
public override void Draw(ICanvas canvas) { canvas.DrawBitmap(_rectangleTopImg, 9, 3); TextRender.DrawText(canvas, "金钱:" + Context.PlayContext.Money, 9 + 3, 3 + 3); canvas.DrawBitmap(_rectangleLeftImg, 9, 3 + 16 + 6 - 1); TextRender.DrawText(canvas, _menuItemsText, 0, _menuItemsRect); TextRender.DrawSelText(canvas, _operateItems[_selectIndex], _menuItemsRect.Left, _menuItemsRect.Top + _selectIndex * 16); }
public override void Draw(ICanvas canvas) { canvas.DrawColor(Constants.COLOR_WHITE); Context.PlayContext.PlayerCharacters[_characterIndex].DrawState(canvas, _statePageIndex); Context.PlayContext.PlayerCharacters[_characterIndex].DrawHead(canvas, 5, 60); if (_medicine.GoodsNum > 0) { _medicine.Draw(canvas, 5, 10); TextRender.DrawText(canvas, "" + _medicine.GoodsNum, 13, 35); } }
public override void Draw(ICanvas canvas) { canvas.DrawBitmap(_background, 39, 39); if (_selectedId == 0) { TextRender.DrawSelText(canvas, _operateItems[0], 39 + 3, 39 + 3); TextRender.DrawText(canvas, _operateItems[1], 39 + 3, 39 + 3 + 16); } else if (_selectedId == 1) { TextRender.DrawText(canvas, _operateItems[0], 39 + 3, 39 + 3); TextRender.DrawSelText(canvas, _operateItems[1], 39 + 3, 39 + 3 + 16); } }
public void DrawState(ICanvas canvas, int page) { canvas.DrawLine(37, 10, 37, 87, Context.Util.sBlackPaint); if (page == 0) { TextRender.DrawText(canvas, "等级 " + Level, 41, 4); TextRender.DrawText(canvas, "生命 " + HP + "/" + MaxHP, 41, 23); TextRender.DrawText(canvas, "真气 " + MP + "/" + MaxMP, 41, 41); TextRender.DrawText(canvas, "攻击力 " + Attack, 41, 59); TextRender.DrawText(canvas, "防御力 " + Defend, 41, 77); } else if (page == 1) { TextRender.DrawText(canvas, "经验值", 41, 4); int w = Context.Util.DrawSmallNum(canvas, CurrentExp, 97, 4); TextRender.DrawText(canvas, "/", 97 + w + 2, 4); Context.Util.DrawSmallNum(canvas, LevelupChain.GetNextLevelExp(Level), 97 + w + 9, 10); TextRender.DrawText(canvas, "身法 " + Speed, 41, 23); TextRender.DrawText(canvas, "灵力 " + Lingli, 41, 41); TextRender.DrawText(canvas, "幸运 " + Luck, 41, 59); StringBuilder sb = new StringBuilder("免疫 "); StringBuilder tmp = new StringBuilder(); if (HasBuff(CombatBuff.BUFF_MASK_DU)) { tmp.Append('毒'); } if (HasBuff(CombatBuff.BUFF_MASK_LUAN)) { tmp.Append('乱'); } if (HasBuff(CombatBuff.BUFF_MASK_FENG)) { tmp.Append('封'); } if (HasBuff(CombatBuff.BUFF_MASK_MIAN)) { tmp.Append('眠'); } if (tmp.Length > 0) { sb.Append(tmp); } else { sb.Append('无'); } TextRender.DrawText(canvas, sb.ToString(), 41, 77); } }
public override void Draw(ICanvas canvas) { canvas.DrawBitmap(_background, 50, 14); for (int i = 0; i < _names.Length; i++) { if (i != _selectedIndex) { TextRender.DrawText(canvas, _names[i], 50 + 3, 14 + 3 + 16 * i); } else { TextRender.DrawSelText(canvas, _names[i], 50 + 3, 14 + 3 + 16 * i); } } }
public override void Draw(ICanvas canvas) { canvas.DrawBitmap(this._frameImg, this._frameRect.Left, this._frameRect.Top); for (int i = 0; i < _characterCount; i++) { if (i == _selectedIndex) { TextRender.DrawSelText(canvas, _names[i], this._frameRect.Left + 3, this._frameRect.Top + 3 + 16 * i); } else { TextRender.DrawText(canvas, _names[i], this._frameRect.Left + 3, this._frameRect.Top + 3 + 16 * i); } } }
public override void Draw(ICanvas canvas) { canvas.DrawBitmap(_background, 27, 15); TextRender.DrawText(canvas, _message, 33, 23); if (_selectedIndex == 0) { TextRender.DrawSelText(canvas, "是 ", 45, 53); TextRender.DrawText(canvas, "否 ", 93, 53); } else if (_selectedIndex == 1) { TextRender.DrawText(canvas, "是 ", 45, 53); TextRender.DrawSelText(canvas, "否 ", 93, 53); } }
public override void Draw(ICanvas canvas) { canvas.DrawBitmap(bg, 50, 14); for (int i = 0; i < itemsText.Length; i++) { if (i != curSel) { TextRender.DrawText(canvas, itemsText[i], 50 + 3, 14 + 3 + 16 * i); } else { TextRender.DrawSelText(canvas, itemsText[i], 50 + 3, 14 + 3 + 16 * i); } } }
public override void Draw(ICanvas canvas) { canvas.DrawBitmap(_background, _menuItemsRect.Left - Padx, _menuItemsRect.Top - Pady); for (int i = 0; i < _menuItems.Count; i++) { if (i != _selectIndex) { TextRender.DrawText(canvas, _menuItems[i], _menuItemsRect.Left, _menuItemsRect.Top + 16 * i); } else { TextRender.DrawSelText(canvas, _menuItems[i], _menuItemsRect.Left, _menuItemsRect.Top + 16 * i); } } }
public override void Draw(ICanvas canvas) { canvas.DrawColor(Constants.COLOR_WHITE); canvas.DrawRect(_topRectangle, _paint); canvas.DrawRect(_bottomRectangle, _paint); TextRender.DrawText(canvas, _magicChain[_firstIndex].Name, _topRectangle.Left + 1, _topRectangle.Top + 1); if (_firstIndex + 1 < _magicChain.LearnCount) { TextRender.DrawText(canvas, _magicChain[_firstIndex + 1].Name, _topRectangle.Left + 1, _topRectangle.Top + 1 + 16); } _nextToDraw = TextRender.DrawText(canvas, _magicChain[_selectedIndex].MagicDescription, _toDraw, _descriptionRectangle); TextRender.DrawText(canvas, "耗真气:" + _magicChain[_selectedIndex].CostMp, _textPos.X, _textPos.Y); canvas.DrawBitmap(_cursor, 100, _firstIndex == _selectedIndex ? 10 : 26); canvas.DrawBitmap(_firstIndex == 0 ? _marker : _marker2, 135, 6); canvas.DrawBitmap(_marker, 135, 6 + 8); canvas.DrawBitmap(_marker, 135, 6 + 16); canvas.DrawBitmap(_firstIndex + 2 < _magicChain.LearnCount ? _marker2 : _marker, 135, 6 + 24); }
public override void Draw(ICanvas canvas) { _backgroudImage.Draw(canvas, 1, 0, 0); for (int i = 0; i < _headImgs.Count; i++) { for (int j = 0; j < _headImgs[i].Count; j++) { ResImage img = _headImgs[i][j]; if (img != null) { img.Draw(canvas, 7, 8 + 20 * j, _textPos[i, 1] - 6); } } } TextRender.DrawText(canvas, _texts[0], _textPos[0, 0], _textPos[0, 1]); TextRender.DrawText(canvas, _texts[1], _textPos[1, 0], _textPos[1, 1]); TextRender.DrawText(canvas, _texts[2], _textPos[2, 0], _textPos[2, 1]); TextRender.DrawSelText(canvas, _texts[_index], _textPos[_index, 0], _textPos[_index, 1]); }
/// <summary> /// 绘制图片到画布 /// </summary> /// <param name="canvas">目标画布</param> /// <param name="num">要画的切片编号,>0</param> /// <param name="left">画到画布的最左端位置</param> /// <param name="top">画到画布的最上端位置</param> public void Draw(ICanvas canvas, int num, int left, int top) { if (num <= Number) { canvas.DrawBitmap(_bitmaps[num - 1], left, top); } else { if (Number > 0) { //TODO 这里需要与原版确认 canvas.DrawBitmap(_bitmaps[0], left, top); } else { TextRender.DrawText(canvas, "烫", left, top); } } }
public void DrawWholeMap(ICanvas canvas, int x, int y) { if (_tiles == null) { _tiles = new Tiles(Context, _tilIndex); } for (int ty = 0; ty < MapHeight; ty++) { for (int tx = 0; tx < MapWidth; tx++) { int sx = tx * Tiles.WIDTH + x; int sy = ty * Tiles.HEIGHT + y; _tiles.Draw(canvas, sx, sy, GetTileIndex(tx, ty)); int events = GetEventNum(tx, ty); if (events != 0) { TextRender.DrawText(canvas, events.ToString(), sx, sy); } } } }
/// <summary> /// 习得魔法界面 /// </summary> /// <param name="context"></param> /// <param name="characterName">角色名称</param> /// <param name="magicName">魔法名称</param> public LearnMagicScreen(SimulatorContext context, string characterName, string magicName) : base(context) { _infoImg = Context.LibData.GetImage(2, 10)[0]; byte[] nameData; byte[] magicNameData; try { nameData = characterName.GetBytes(); magicNameData = magicName.GetBytes(); } catch (Exception ex) { Debug.WriteLine(ex); nameData = new byte[0]; magicNameData = new byte[0]; } ICanvas canvas = Context.GraphicsFactory.NewCanvas(_infoImg);; TextRender.DrawText(canvas, nameData, (_infoImg.Width - nameData.Length * 8) / 2, 8); TextRender.DrawText(canvas, magicNameData, (_infoImg.Width - magicNameData.Length * 8) / 2, 42); }
public override void Draw(ICanvas canvas) { canvas.DrawBitmap(_background, 29, 14); TextRender.DrawText(canvas, _menuItems, 0, _showRectangle); TextRender.DrawSelText(canvas, _menuSelectItems[_curSelectedIndex], _showRectangle.Left, _showRectangle.Top + 16 * _curSelectedIndex); }