public virtual SizeF MeasureTextSize(string text, FontCi fontci) { using (Font font = new Font(fontci.GetFontFamily(), fontci.GetFontSize(), (FontStyle)fontci.GetFontStyle())) { return(MeasureTextSize(text, font)); } }
internal void DrawAmmo(Game game) { Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial]; if (item != null && item.ItemClass == Packet_ItemClassEnum.Block) { if (game.blocktypes[item.BlockId].IsPistol) { int loaded = game.LoadedAmmo[item.BlockId]; int total = game.TotalAmmo[item.BlockId]; string s = game.platform.StringFormat2("{0}/{1}", game.platform.IntToString(loaded), game.platform.IntToString(total - loaded)); FontCi font = new FontCi(); font.family = "Arial"; font.size = 18; game.Draw2dText(s, font, game.Width() - game.TextSizeWidth(s, 18) - 50, game.Height() - game.TextSizeHeight(s, 18) - 50, loaded == 0 ? IntRef.Create(Game.ColorFromArgb(255, 255, 0, 0)) : IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)), false); if (loaded == 0) { font.size = 14; string pressR = "Press R to reload"; game.Draw2dText(pressR, font, game.Width() - game.TextSizeWidth(pressR, 14) - 50, game.Height() - game.TextSizeHeight(s, 14) - 80, IntRef.Create(Game.ColorFromArgb(255, 255, 0, 0)), false); } } } }
internal void DrawEnemyHealthUseInfo(Game game, string name, float progress, bool useInfo) { int y = useInfo ? 55 : 35; game.Draw2dTexture(game.WhiteTexture(), game.xcenter(300), 40, 300, y, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false); game.Draw2dTexture(game.WhiteTexture(), game.xcenter(300), 40, 300 * progress, y, null, 0, Game.ColorFromArgb(255, 255, 0, 0), false); FontCi font = new FontCi(); font.family = "Arial"; font.size = 14; IntRef w = new IntRef(); IntRef h = new IntRef(); game.platform.TextSize(name, 14, w, h); game.Draw2dText(name, font, game.xcenter(w.value), 40, null, false); if (useInfo) { name = game.platform.StringFormat(game.language.PressToUse(), "E"); game.platform.TextSize(name, 10, w, h); FontCi font2 = new FontCi(); font2.family = "Arial"; font2.size = 10; game.Draw2dText(name, font2, game.xcenter(w.value), 70, null, false); } }
public ModFpsHistoryGraph() { one = 1; ENABLE_STATS = false; DRAW_FPS_TEXT = false; DRAW_FPS_GRAPH = false; DRAW_POSITION = false; dtHistory = new float[MaxCount]; for (int i = 0; i < MaxCount; i++) { dtHistory[i] = 0; } chunkUpdateHistory = new float[MaxCount]; for (int i = 0; i < MaxCount; i++) { chunkUpdateHistory[i] = 0; } pingHistory = new float[MaxCount]; for (int i = 0; i < MaxCount; i++) { pingHistory[i] = 0; } todraw = new Draw2dData[MaxCount]; for (int i = 0; i < MaxCount; i++) { todraw[i] = new Draw2dData(); } StatsLines = new string[StatsMaxLineCount]; displayFont = new FontCi(); displayFont.size = 10; displayFontHeadings = new FontCi(); displayFontHeadings.size = 10; displayFontHeadings.style = 1; PositionLines = new string[PositionLinesCount]; }
void SetEscapeMenuState(EscapeMenuState state) { LanguageCi language = game.language; escapemenustate = state; WidgetsClear(); if (state == EscapeMenuState.Main) { MainSet(); MakeSimpleOptions(fontEscapeMenu, 50); } else if (state == EscapeMenuState.Options) { OptionsSet(); MakeSimpleOptions(fontEscapeMenu, 50); } else if (state == EscapeMenuState.Graphics) { GraphicsSet(); MakeSimpleOptions(fontEscapeMenu, 50); } else if (state == EscapeMenuState.Other) { OtherSet(); MakeSimpleOptions(fontEscapeMenu, 50); } else if (state == EscapeMenuState.Keys) { KeysSet(); FontCi fontKeys = FontCi.Create("Arial", 12, 0); int textheight = 20; MakeSimpleOptions(fontKeys, textheight); } }
void MakeSimpleOptions(FontCi font, int textheight) { int starty = game.ycenter(widgetsCount * textheight); for (int i = 0; i < widgetsCount; i++) { string s = widgets[i].Text; float sizeWidth = game.TextSizeWidth(s, font); float sizeHeight = game.TextSizeHeight(s, font); int Width = game.platform.FloatToInt(sizeWidth) + 10; int Height = game.platform.FloatToInt(sizeHeight); int X = game.xcenter(sizeWidth); int Y = starty + textheight * i; widgets[i].x = X; widgets[i].y = Y; widgets[i].width = Width; widgets[i].height = Height; widgets[i].font = font; if (i == keyselectid) { widgets[i].fontcolor = Game.ColorFromArgb(255, 0, 255, 0); widgets[i].fontcolorselected = Game.ColorFromArgb(255, 0, 255, 0); } } }
void DrawItem(int screenposX, int screenposY, Packet_Item item, int drawsizeX, int drawsizeY) { if (item == null) { return; } int sizex = dataItems.ItemSizeX(item); int sizey = dataItems.ItemSizeY(item); if (drawsizeX == 0 || drawsizeX == -1) { drawsizeX = CellDrawSize * sizex; drawsizeY = CellDrawSize * sizey; } if (item.ItemClass == Packet_ItemClassEnum.Block) { if (item.BlockId == 0) { return; } game.Draw2dTexture(game.terrainTexture, screenposX, screenposY, drawsizeX, drawsizeY, IntRef.Create(dataItems.TextureIdForInventory()[item.BlockId]), game.texturesPacked(), Game.ColorFromArgb(255, 255, 255, 255), false); if (item.BlockCount > 1) { FontCi font = new FontCi(); font.size = 8; game.Draw2dText(game.platform.IntToString(item.BlockCount), font, screenposX, screenposY, null, false); } } else { game.Draw2dBitmapFile(dataItems.ItemGraphics(item), screenposX, screenposY, drawsizeX, drawsizeY); } }
public ScreenSingleplayer() { play = new MenuWidget(); play.text = "Play"; newWorld = new MenuWidget(); newWorld.text = "New World"; modify = new MenuWidget(); modify.text = "Modify"; back = new MenuWidget(); back.text = "Back"; back.type = WidgetType.Button; open = new MenuWidget(); open.text = "Create or open..."; open.type = WidgetType.Button; title = "Singleplayer"; fontDefault = new FontCi(); fontDefault.size = 16; widgets[0] = play; widgets[1] = newWorld; widgets[2] = modify; widgets[3] = back; widgets[4] = open; worldButtons = new MenuWidget[10]; for (int i = 0; i < 10; i++) { worldButtons[i] = new MenuWidget(); worldButtons[i].visible = false; widgets[5 + i] = worldButtons[i]; } }
public MenuWidget() { visible = true; font = new FontCi(); font.size = 14; nextWidget = -1; hasKeyboardFocus = false; }
internal void DrawButton(string text, FontCi font, float dx, float dy, float dw, float dh, bool pressed) { Draw2dQuad(pressed ? GetTexture("button_sel.png") : GetTexture("button.png"), dx, dy, dw, dh); if ((text != null) && (text != "")) { DrawText(text, font, dx + dw / 2, dy + dh / 2, TextAlign.Center, TextBaseline.Middle); } }
public ModGuiChat() { one = 1; ChatFontSize = 11; ChatScreenExpireTimeSeconds = 20; ChatLinesMaxToDraw = 10; font = new FontCi(); font.family = "Arial"; font.size = ChatFontSize; chatlines2 = new Chatline[1024]; }
public ModGuiChat() { one = 1; ChatFontSize = 11; ChatScreenExpireTimeSeconds = 20; ChatLinesMaxToDraw = 10; font = new FontCi(); font.family = "Arial"; font.size = ChatFontSize; chatlines2 = new Chatline[1024]; }
internal void DrawScreenshotFlash(Game game) { game.Draw2dTexture(game.WhiteTexture(), 0, 0, game.platform.GetCanvasWidth(), game.platform.GetCanvasHeight(), null, 0, Game.ColorFromArgb(255, 255, 255, 255), false); string screenshottext = "&0Screenshot"; IntRef textWidth = new IntRef(); IntRef textHeight = new IntRef(); FontCi font = new FontCi(); font.size = 50; game.platform.TextSize(screenshottext, font, textWidth, textHeight); game.Draw2dText(screenshottext, font, game.xcenter(textWidth.value), game.ycenter(textHeight.value), null, false); }
internal void DrawScreenshotFlash(Game game) { game.Draw2dTexture(game.WhiteTexture(), 0, 0, game.platform.GetCanvasWidth(), game.platform.GetCanvasHeight(), null, 0, Game.ColorFromArgb(255, 255, 255, 255), false); string screenshottext = "&0Screenshot"; IntRef textWidth = new IntRef(); IntRef textHeight = new IntRef(); game.platform.TextSize(screenshottext, 50, textWidth, textHeight); FontCi font = new FontCi(); font.family = "Arial"; font.size = 50; game.Draw2dText(screenshottext, font, game.xcenter(textWidth.value), game.ycenter(textHeight.value), null, false); }
public ModGuiChat() { one = 1; ChatFontSize = 11; ChatScreenExpireTimeSeconds = 20; ChatLinesMaxToDraw = 10; font = new FontCi(); font.family = "Arial"; font.size = ChatFontSize; chatlines2 = new Chatline[1024]; color_background = Game.ColorFromArgb(80, 0, 0, 0); }
public ScreenMain() { singleplayer = new MenuWidget(); multiplayer = new MenuWidget(); exit = new MenuWidget(); widgets[0] = singleplayer; widgets[1] = multiplayer; widgets[2] = exit; queryStringChecked = false; cursorLoaded = false; fontDefault = new FontCi(); fontDefault.size = 20; }
public ModGuiTextEditor() { buffer = new int[maxLines][]; for (int i = 0; i < maxLines; i++) { buffer[i] = new int[maxColumns]; } startX = 100; startY = 100; charSize = 12; font = new FontCi(); font.family = "Courier New"; font.size = 12; }
public ModGuiTextEditor() { buffer = new int[maxLines][]; for (int i = 0; i < maxLines; i++) { buffer[i] = new int[maxColumns]; } startX = 100; startY = 100; charSize = 12; font = new FontCi(); font.family = "Courier New"; font.size = 12; }
public MainMenu() { one = 1; textures = new DictionaryStringInt1024(); textTextures = new TextTexture[256]; textTexturesCount = 0; screen = new ScreenMain(); screen.menu = this; loginClient = new LoginClientCi(); assets = new AssetList(); assetsLoadProgress = new FloatRef(); fontMenuHeading = new FontCi(); fontMenuHeading.size = 20; }
public override void OnNewFrameDraw3d(Game game, float deltaTime) { for (int i = 0; i < game.entitiesCount; i++) { Entity e = game.entities[i]; if (e == null) { continue; } if (e.drawText == null) { continue; } if (e.networkPosition != null && (!e.networkPosition.PositionLoaded)) { continue; } int kKey = i; EntityDrawText p = game.entities[i].drawText; float posX = - game.platform.MathSin(e.position.roty) * p.dx + e.position.x; float posY = p.dy + e.position.y; float posZ = game.platform.MathCos(e.position.roty) * p.dz + e.position.z; //todo if picking if ((game.Dist(game.player.position.x, game.player.position.y, game.player.position.z, posX, posY, posZ) < 20) || game.keyboardState[Game.KeyAltLeft] || game.keyboardState[Game.KeyAltRight]) { string text = p.text; { float shadow = (game.one * game.GetLight(game.platform.FloatToInt(posX), game.platform.FloatToInt(posZ), game.platform.FloatToInt(posY))) / Game.maxlight; game.GLPushMatrix(); game.GLTranslate(posX, posY, posZ); game.GLRotate(180, 1, 0, 0); game.GLRotate(e.position.roty * 360 / (2 * Game.GetPi()), 0, 1, 0); float scale = game.one * 5 / 1000; game.GLScale(scale, scale, scale); FontCi font = new FontCi(); font.family = "Arial"; font.size = 14; game.Draw2dText(text, font, -game.TextSizeWidth(text, 14) / 2, 0, IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)), true); game.GLPopMatrix(); } } } }
void DrawDisconnected(Game game) { float one = 1; float lagSeconds = one * (game.platform.TimeMillisecondsFromStart() - game.LastReceivedMilliseconds) / 1000; if ((lagSeconds >= Game.DISCONNECTED_ICON_AFTER_SECONDS && lagSeconds < 60 * 60 * 24) && game.invalidVersionDrawMessage == null && !(game.issingleplayer && (!game.platform.SinglePlayerServerLoaded()))) { game.Draw2dBitmapFile("disconnected.png", game.Width() - 100, 50, 50, 50); FontCi font = new FontCi(); font.size = 12; game.Draw2dText(game.platform.IntToString(game.platform.FloatToInt(lagSeconds)), font, game.Width() - 100, 50 + 50 + 10, null, false); game.Draw2dText("Press F6 to reconnect", font, game.Width() / 2 - 200 / 2, 50, null, false); } }
public override void OnNewFrameDraw3d(Game game, float deltaTime) { for (int i = 0; i < game.entitiesCount; i++) { Entity e = game.entities[i]; if (e == null) { continue; } if (e.drawText == null) { continue; } if (e.networkPosition != null && (!e.networkPosition.PositionLoaded)) { continue; } int kKey = i; EntityDrawText p = game.entities[i].drawText; float posX = -game.platform.MathSin(e.position.roty) * p.dx + e.position.x; float posY = p.dy + e.position.y; float posZ = game.platform.MathCos(e.position.roty) * p.dz + e.position.z; //todo if picking if ((game.Dist(game.player.position.x, game.player.position.y, game.player.position.z, posX, posY, posZ) < 20) || game.keyboardState[Game.KeyAltLeft] || game.keyboardState[Game.KeyAltRight]) { string text = p.text; { float shadow = (game.one * game.GetLight(game.platform.FloatToInt(posX), game.platform.FloatToInt(posZ), game.platform.FloatToInt(posY))) / Game.maxlight; game.GLPushMatrix(); game.GLTranslate(posX, posY, posZ); game.GLRotate(180, 1, 0, 0); game.GLRotate(e.position.roty * 360 / (2 * Game.GetPi()), 0, 1, 0); float scale = game.one * 5 / 1000; game.GLScale(scale, scale, scale); FontCi font = new FontCi(); font.family = "Arial"; font.size = 14; game.Draw2dText(text, font, -game.TextSizeWidth(text, 14) / 2, 0, IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)), true); game.GLPopMatrix(); } } } }
TextTexture GetTextTexture(string text, FontCi font) { for (int i = 0; i < textTexturesCount; i++) { TextTexture t = textTextures[i]; if (t == null) { continue; } if (t.text == text && t.font.size == font.size && t.font.family == font.family && t.font.style == font.style) { return(t); } } TextTexture textTexture = new TextTexture(); Text_ text_ = new Text_(); text_.text = text; text_.font = font; text_.color = Game.ColorFromArgb(255, 255, 255, 255); BitmapCi textBitmap = textColorRenderer.CreateTextTexture(text_); int texture = p.LoadTextureFromBitmap(textBitmap); IntRef textWidth = new IntRef(); IntRef textHeight = new IntRef(); p.TextSize(text, font, textWidth, textHeight); textTexture.texture = texture; textTexture.texturewidth = p.FloatToInt(p.BitmapGetWidth(textBitmap)); textTexture.textureheight = p.FloatToInt(p.BitmapGetHeight(textBitmap)); textTexture.text = text; textTexture.font = font; textTexture.textwidth = textWidth.value; textTexture.textheight = textHeight.value; p.BitmapDelete(textBitmap); textTextures[textTexturesCount++] = textTexture; return(textTexture); }
public ModGuiEscapeMenu() { one = 1; fonts = new string[4]; fonts[0] = "Nice"; fonts[1] = "Simple"; fonts[2] = "BlackBackground"; fonts[3] = "Default"; fontsLength = 4; fontValues = new int[4]; fontValues[0] = 0; fontValues[1] = 1; fontValues[2] = 2; fontValues[3] = 3; widgets = new Button[1024]; keyselectid = -1; fontEscapeMenu = FontCi.Create("Arial", 20, 0); }
public ModGuiTouchButtons() { touchButtonsEnabled = false; buttonMenu = new MenuWidget(); buttonMenu.image = "TouchMenu.png"; buttonInventory = new MenuWidget(); buttonInventory.image = "TouchInventory.png"; buttonTalk = new MenuWidget(); buttonTalk.image = "TouchTalk.png"; buttonCamera = new MenuWidget(); buttonCamera.image = "TouchCamera.png"; widgets[0] = buttonMenu; widgets[1] = buttonInventory; widgets[2] = buttonTalk; widgets[3] = buttonCamera; touchIdMove = -1; touchIdRotate = -1; fontGuiTouchButtons = new FontCi(); }
public void DrawItemInfo(int screenposX, int screenposY, Packet_Item item) { int sizex = dataItems.ItemSizeX(item); int sizey = dataItems.ItemSizeY(item); IntRef tw = new IntRef(); IntRef th = new IntRef(); float one = 1; game.platform.TextSize(dataItems.ItemInfo(item), 11 + one / 2, tw, th); tw.value += 6; th.value += 4; int w = game.platform.FloatToInt(tw.value + CellDrawSize * sizex); int h = game.platform.FloatToInt(th.value < CellDrawSize * sizey ? CellDrawSize * sizey + 4 : th.value); if (screenposX < w + 20) { screenposX = w + 20; } if (screenposY < h + 20) { screenposY = h + 20; } if (screenposX > game.Width() - (w + 20)) { screenposX = game.Width() - (w + 20); } if (screenposY > game.Height() - (h + 20)) { screenposY = game.Height() - (h + 20); } game.Draw2dTexture(game.WhiteTexture(), screenposX - w, screenposY - h, w, h, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false); game.Draw2dTexture(game.WhiteTexture(), screenposX - w + 2, screenposY - h + 2, w - 4, h - 4, null, 0, Game.ColorFromArgb(255, 105, 105, 105), false); FontCi font = new FontCi(); font.family = "Arial"; font.size = 10; game.Draw2dText(dataItems.ItemInfo(item), font, screenposX - tw.value + 4, screenposY - h + 2, null, false); Packet_Item item2 = new Packet_Item(); item2.BlockId = item.BlockId; DrawItem(screenposX - w + 2, screenposY - h + 2, item2, 0, 0); }
void DrawLocalPosition(Game game) { float one = 1; if (game.ENABLE_DRAWPOSITION) { float heading = one * game.HeadingByte(game.player.position.rotx, game.player.position.roty, game.player.position.rotz); float pitch = one * game.PitchByte(game.player.position.rotx, game.player.position.roty, game.player.position.rotz); string postext = game.platform.StringFormat("X: {0}", game.platform.IntToString(game.MathFloor(game.player.position.x))); postext = StringTools.StringAppend(game.platform, postext, ",\tY: "); postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(game.player.position.z))); postext = StringTools.StringAppend(game.platform, postext, ",\tZ: "); postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(game.player.position.y))); postext = StringTools.StringAppend(game.platform, postext, "\nHeading: "); postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(heading))); postext = StringTools.StringAppend(game.platform, postext, "\nPitch: "); postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(pitch))); FontCi font = new FontCi(); font.family = "Arial"; font.size = Game.ChatFontSize; game.Draw2dText(postext, font, 100, 460, null, false); } }
internal void DrawText(string text, FontCi font, float x, float y, TextAlign align, TextBaseline baseline) { TextTexture t = GetTextTexture(text, font); int dx = 0; int dy = 0; if (align == TextAlign.Center) { dx -= t.textwidth / 2; } if (align == TextAlign.Right) { dx -= t.textwidth; } if (baseline == TextBaseline.Middle) { dy -= t.textheight / 2; } if (baseline == TextBaseline.Bottom) { dy -= t.textheight; } Draw2dQuad(t.texture, x + dx, y + dy, t.texturewidth, t.textureheight); }
internal void DrawEnemyHealthUseInfo(Game game, string name, float progress, bool useInfo) { int y = useInfo ? 55 : 35; game.Draw2dTexture(game.WhiteTexture(), game.xcenter(300), 40, 300, y, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false); game.Draw2dTexture(game.WhiteTexture(), game.xcenter(300), 40, 300 * progress, y, null, 0, Game.ColorFromArgb(255, 255, 0, 0), false); FontCi font = new FontCi(); font.family = "Arial"; font.size = 14; IntRef w = new IntRef(); IntRef h = new IntRef(); game.platform.TextSize(name, 14, w, h); game.Draw2dText(name, font, game.xcenter(w.value), 40, null, false); if (useInfo) { name = game.platform.StringFormat(game.language.PressToUse(), "E"); game.platform.TextSize(name, 10, w, h); FontCi font2 = new FontCi(); font2.family = "Arial"; font2.size = 10; game.Draw2dText(name, font2, game.xcenter(w.value), 70, null, false); } }
public Button() { fontcolor = Game.ColorFromArgb(255, 255, 255, 255); fontcolorselected = Game.ColorFromArgb(255, 255, 0, 0); font = new FontCi(); }
public ScreenLogin() { login = new MenuWidget(); login.text = "Login"; login.type = WidgetType.Button; login.nextWidget = 9; loginUsername = new MenuWidget(); loginUsername.type = WidgetType.Textbox; loginUsername.text = ""; loginUsername.description = "Username"; loginUsername.nextWidget = 2; loginPassword = new MenuWidget(); loginPassword.type = WidgetType.Textbox; loginPassword.text = ""; loginPassword.description = "Password"; loginPassword.password = true; loginPassword.nextWidget = 3; loginRememberMe = new MenuWidget(); loginRememberMe.text = "Yes"; loginRememberMe.type = WidgetType.Button; loginRememberMe.description = "Remember me"; loginRememberMe.nextWidget = 0; createAccount = new MenuWidget(); createAccount.text = "Create account"; createAccount.type = WidgetType.Button; createAccountUsername = new MenuWidget(); createAccountUsername.text = ""; createAccountUsername.type = WidgetType.Textbox; createAccountUsername.description = "Username"; createAccountPassword = new MenuWidget(); createAccountPassword.text = ""; createAccountPassword.type = WidgetType.Textbox; createAccountPassword.description = "Password"; createAccountPassword.password = true; createAccountRememberMe = new MenuWidget(); createAccountRememberMe.text = "Yes"; createAccountRememberMe.type = WidgetType.Button; createAccountRememberMe.description = "Remember me"; back = new MenuWidget(); back.text = "Back"; back.type = WidgetType.Button; back.nextWidget = 1; fontLoginMessage = new FontCi(); fontLoginMessage.size = 14; title = "Login"; widgets[0] = login; widgets[1] = loginUsername; widgets[2] = loginPassword; widgets[3] = loginRememberMe; widgets[4] = createAccount; widgets[5] = createAccountUsername; widgets[6] = createAccountPassword; widgets[7] = createAccountRememberMe; widgets[9] = back; loginUsername.GetFocus(); loginResult = new LoginResultRef(); }
internal void Draw2dText1(string text, int x, int y, int fontsize, IntRef color, bool enabledepthtest) { FontCi font = new FontCi(); font.family = "Arial"; font.size = fontsize; Draw2dText(text, font, x, y, color, enabledepthtest); }
public override void OnNewFrameDraw3d(Game game, float deltaTime) { for (int i = 0; i < game.entitiesCount; i++) { Entity e = game.entities[i]; if (e == null) { continue; } if (e.drawName == null) { continue; } if (i == game.LocalPlayerId) { continue; } if (e.networkPosition != null && (!e.networkPosition.PositionLoaded)) { continue; } int kKey = i; DrawName p = game.entities[i].drawName; if (p.OnlyWhenSelected) { continue; } float posX = p.TextX + e.position.x; float posY = p.TextY + e.position.y + e.drawModel.ModelHeight + game.one * 7 / 10; float posZ = p.TextZ + e.position.z; //todo if picking if ((game.Dist(game.player.position.x, game.player.position.y, game.player.position.z, posX, posY, posZ) < 20) || game.keyboardState[Game.KeyAltLeft] || game.keyboardState[Game.KeyAltRight]) { string name = p.Name; { float shadow = (game.one * game.GetLight(game.platform.FloatToInt(posX), game.platform.FloatToInt(posZ), game.platform.FloatToInt(posY))) / Game.maxlight; //do not interpolate player position if player is controlled by game world //if (EnablePlayerUpdatePositionContainsKey(kKey) && !EnablePlayerUpdatePosition(kKey)) //{ // posX = p.NetworkX; // posY = p.NetworkY; // posZ = p.NetworkZ; //} game.GLPushMatrix(); game.GLTranslate(posX, posY, posZ); //if (p.Type == PlayerType.Monster) //{ // GLTranslate(0, 1, 0); //} ModDrawSprites.Billboard(game); float scale = game.one * 2 / 100; game.GLScale(scale, scale, scale); //Color c = Color.FromArgb((int)(shadow * 255), (int)(shadow * 255), (int)(shadow * 255)); //Todo: Can't change text color because text has outline anyway. if (p.DrawHealth) { game.Draw2dTexture(game.WhiteTexture(), -26, -11, 52, 12, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false); game.Draw2dTexture(game.WhiteTexture(), -25, -10, 50 * (game.one * p.Health), 10, null, 0, Game.ColorFromArgb(255, 255, 0, 0), false); } FontCi font = new FontCi(); font.family = "Arial"; font.size = 14; game.Draw2dText(name, font, -game.TextSizeWidth(name, 14) / 2, 0, IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)), true); // GL.Translate(0, 1, 0); game.GLPopMatrix(); } } } }
public void DrawItemInfo(int screenposX, int screenposY, Packet_Item item) { int sizex = dataItems.ItemSizeX(item); int sizey = dataItems.ItemSizeY(item); IntRef tw = new IntRef(); IntRef th = new IntRef(); float one = 1; game.platform.TextSize(dataItems.ItemInfo(item), 11 + one / 2, tw, th); tw.value += 6; th.value += 4; int w = game.platform.FloatToInt(tw.value + CellDrawSize * sizex); int h = game.platform.FloatToInt(th.value < CellDrawSize * sizey ? CellDrawSize * sizey + 4 : th.value); if (screenposX < w + 20) { screenposX = w + 20; } if (screenposY < h + 20) { screenposY = h + 20; } if (screenposX > game.Width() - (w + 20)) { screenposX = game.Width() - (w + 20); } if (screenposY > game.Height() - (h + 20)) { screenposY = game.Height() - (h + 20); } game.Draw2dTexture(game.WhiteTexture(), screenposX - w, screenposY - h, w, h, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false); game.Draw2dTexture(game.WhiteTexture(), screenposX - w + 2, screenposY - h + 2, w - 4, h - 4, null, 0, Game.ColorFromArgb(255, 105, 105, 105), false); FontCi font = new FontCi(); font.family = "Arial"; font.size = 10; game.Draw2dText(dataItems.ItemInfo(item), font, screenposX - tw.value + 4, screenposY - h + 2, null, false); Packet_Item item2 = new Packet_Item(); item2.BlockId = item.BlockId; DrawItem(screenposX - w + 2, screenposY - h + 2, item2, 0, 0); }
public override void Draw2dText(string text, float x, float y, float fontsize) { FontCi font = new FontCi(); font.family = "Arial"; font.size = fontsize; game.Draw2dText(text, font, x, y, null, false); }
public ScreenMultiplayer() { WidgetCount = 64 + serverButtonsCount; widgets = new MenuWidget[WidgetCount]; back = new MenuWidget(); back.text = "Back"; back.type = WidgetType.Button; back.nextWidget = 1; connect = new MenuWidget(); connect.text = "Connect"; connect.type = WidgetType.Button; connect.nextWidget = 3; connectToIp = new MenuWidget(); connectToIp.text = "Connect to IP"; connectToIp.type = WidgetType.Button; connectToIp.nextWidget = 2; refresh = new MenuWidget(); refresh.text = "Refresh"; refresh.type = WidgetType.Button; refresh.nextWidget = 0; page = 0; pageUp = new MenuWidget(); pageUp.text = ""; pageUp.type = WidgetType.Button; pageUp.buttonStyle = ButtonStyle.Text; pageUp.visible = false; pageDown = new MenuWidget(); pageDown.text = ""; pageDown.type = WidgetType.Button; pageDown.buttonStyle = ButtonStyle.Text; pageDown.visible = false; loggedInName = new MenuWidget(); loggedInName.text = ""; loggedInName.type = WidgetType.Button; loggedInName.buttonStyle = ButtonStyle.Text; logout = new MenuWidget(); logout.text = ""; logout.type = WidgetType.Button; //logout.image = "serverlist_entry_background.png"; logout.buttonStyle = ButtonStyle.Button; title = "Multiplayer"; fontServerHeading = new FontCi(); fontServerHeading.style = 1; fontServerHeading.size = 14; fontServerDescription = new FontCi(); fontDefault = new FontCi(); fontDefault.size = 14; widgets[0] = back; widgets[1] = connect; widgets[2] = refresh; widgets[3] = connectToIp; widgets[4] = pageUp; widgets[5] = pageDown; widgets[6] = loggedInName; widgets[7] = logout; serverListAddress = new HttpResponseCi(); serverListCsv = new HttpResponseCi(); serversOnList = new ServerOnList[serversOnListCount]; thumbResponses = new ThumbnailResponseCi[serversOnListCount]; serverButtons = new MenuWidget[serverButtonsCount]; for (int i = 0; i < serverButtonsCount; i++) { MenuWidget b = new MenuWidget(); b = new MenuWidget(); b.text = "Invalid"; b.type = WidgetType.Button; b.visible = false; b.image = "serverlist_entry_noimage.png"; serverButtons[i] = b; widgets[8 + i] = b; } loading = true; }
public ModGuiCrafting() { handler = new PacketHandlerCraftingRecipes(); handler.mod = this; fontCraftingGui = new FontCi(); }
public void Draw2dText(string text, FontCi font, float x, float y, IntRef color, bool enabledepthtest) { if (text == null || platform.StringTrim(text) == "") { return; } if (color == null) { color = IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)); } Text_ t = new Text_(); t.text = text; t.color = color.value; t.fontsize = font.size; t.fontfamily = font.family; t.fontstyle = font.style; CachedTexture ct; if (GetCachedTextTexture(t) == null) { ct = MakeTextTexture(t); if (ct == null) { return; } for (int i = 0; i < cachedTextTexturesMax; i++) { if (cachedTextTextures[i] == null) { CachedTextTexture ct1 = new CachedTextTexture(); ct1.text = t; ct1.texture = ct; cachedTextTextures[i] = ct1; break; } } } ct = GetCachedTextTexture(t); ct.lastuseMilliseconds = platform.TimeMillisecondsFromStart(); platform.GLDisableAlphaTest(); Draw2dTexture(ct.textureId, x, y, ct.sizeX, ct.sizeY, null, 0, Game.ColorFromArgb(255, 255, 255, 255), enabledepthtest); platform.GLEnableAlphaTest(); DeleteUnusedCachedTextTextures(); }
void DrawLocalPosition(Game game) { float one = 1; if (game.ENABLE_DRAWPOSITION) { float heading = one * game.HeadingByte(game.player.position.rotx, game.player.position.roty, game.player.position.rotz); float pitch = one * game.PitchByte(game.player.position.rotx, game.player.position.roty, game.player.position.rotz); string postext = game.platform.StringFormat("X: {0}", game.platform.IntToString(game.MathFloor(game.player.position.x))); postext = StringTools.StringAppend(game.platform, postext, ",\tY: "); postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(game.player.position.z))); postext = StringTools.StringAppend(game.platform, postext, ",\tZ: "); postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(game.player.position.y))); postext = StringTools.StringAppend(game.platform, postext, "\nHeading: "); postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(heading))); postext = StringTools.StringAppend(game.platform, postext, "\nPitch: "); postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(pitch))); FontCi font = new FontCi(); font.family = "Arial"; font.size = Game.ChatFontSize; game.Draw2dText(postext, font, 100, 460, null, false); } }
public abstract void TextSize(string text, FontCi font, IntRef outWidth, IntRef outHeight);
void DrawItem(int screenposX, int screenposY, Packet_Item item, int drawsizeX, int drawsizeY) { if (item == null) { return; } int sizex = dataItems.ItemSizeX(item); int sizey = dataItems.ItemSizeY(item); if (drawsizeX == 0 || drawsizeX == -1) { drawsizeX = CellDrawSize * sizex; drawsizeY = CellDrawSize * sizey; } if (item.ItemClass == Packet_ItemClassEnum.Block) { if (item.BlockId == 0) { return; } game.Draw2dTexture(game.terrainTexture, screenposX, screenposY, drawsizeX, drawsizeY, IntRef.Create(dataItems.TextureIdForInventory()[item.BlockId]), game.texturesPacked(), Game.ColorFromArgb(255, 255, 255, 255), false); if (item.BlockCount > 1) { FontCi font = new FontCi(); font.size = 8; font.family = "Arial"; game.Draw2dText(game.platform.IntToString(item.BlockCount), font, screenposX, screenposY, null, false); } } else { game.Draw2dBitmapFile(dataItems.ItemGraphics(item), screenposX, screenposY, drawsizeX, drawsizeY); } }
public void MapLoadingStart() { guistate = GuiState.MapLoading; SetFreeMouse(true); maploadingprogress = new MapLoadingProgressEventArgs(); fontMapLoading = FontCi.Create("Arial", 14, 0); }
public override void OnNewFrameDraw3d(Game game, float deltaTime) { for (int i = 0; i < game.entitiesCount; i++) { Entity e = game.entities[i]; if (e == null) { continue; } if (e.drawName == null) { continue; } if (i == game.LocalPlayerId) { continue; } if (e.networkPosition != null && (!e.networkPosition.PositionLoaded)) { continue; } int kKey = i; DrawName p = game.entities[i].drawName; if (p.OnlyWhenSelected) { continue; } float posX = p.TextX + e.position.x; float posY = p.TextY + e.position.y + e.drawModel.ModelHeight + game.one * 7 / 10; float posZ = p.TextZ + e.position.z; //TODO: if picking if ((game.Dist(game.player.position.x, game.player.position.y, game.player.position.z, posX, posY, posZ) < 20) || game.keyboardState[Game.KeyAltLeft] || game.keyboardState[Game.KeyAltRight]) { string name = p.Name; { float shadow = (game.one * game.GetLight(game.platform.FloatToInt(posX), game.platform.FloatToInt(posZ), game.platform.FloatToInt(posY))) / Game.maxlight; //do not interpolate player position if player is controlled by game world //if (EnablePlayerUpdatePositionContainsKey(kKey) && !EnablePlayerUpdatePosition(kKey)) //{ // posX = p.NetworkX; // posY = p.NetworkY; // posZ = p.NetworkZ; //} game.GLPushMatrix(); game.GLTranslate(posX, posY, posZ); //if (p.Type == PlayerType.Monster) //{ // GLTranslate(0, 1, 0); //} ModDrawSprites.Billboard(game); float scale = game.one * 2 / 100; game.GLScale(scale, scale, scale); //Color c = Color.FromArgb((int)(shadow * 255), (int)(shadow * 255), (int)(shadow * 255)); //TODO: Can't change text color because text has outline anyway. if (p.DrawHealth) { game.Draw2dTexture(game.WhiteTexture(), -26, -11, 52, 12, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false); game.Draw2dTexture(game.WhiteTexture(), -25, -10, 50 * (game.one * p.Health), 10, null, 0, Game.ColorFromArgb(255, 255, 0, 0), false); } FontCi font = new FontCi(); font.size = 14; game.Draw2dText(name, font, -game.TextSizeWidth(name, font) / 2, 0, IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)), true); // GL.Translate(0, 1, 0); game.GLPopMatrix(); } } } }
internal void DrawAmmo(Game game) { Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial]; if (item != null && item.ItemClass == Packet_ItemClassEnum.Block) { if (game.blocktypes[item.BlockId].IsPistol) { int loaded = game.LoadedAmmo[item.BlockId]; int total = game.TotalAmmo[item.BlockId]; string s = game.platform.StringFormat2("{0}/{1}", game.platform.IntToString(loaded), game.platform.IntToString(total - loaded)); FontCi font = new FontCi(); font.family = "Arial"; font.size = 18; game.Draw2dText(s, font, game.Width() - game.TextSizeWidth(s, 18) - 50, game.Height() - game.TextSizeHeight(s, 18) - 50, loaded == 0 ? IntRef.Create(Game.ColorFromArgb(255, 255, 0, 0)) : IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)), false); if (loaded == 0) { font.size = 14; string pressR = "Press R to reload"; game.Draw2dText(pressR, font, game.Width() - game.TextSizeWidth(pressR, 14) - 50, game.Height() - game.TextSizeHeight(s, 14) - 80, IntRef.Create(Game.ColorFromArgb(255, 255, 0, 0)), false); } } } }
void DrawDisconnected(Game game) { float one = 1; float lagSeconds = one * (game.platform.TimeMillisecondsFromStart() - game.LastReceivedMilliseconds) / 1000; if ((lagSeconds >= Game.DISCONNECTED_ICON_AFTER_SECONDS && lagSeconds < 60 * 60 * 24) && game.invalidVersionDrawMessage == null && !(game.issingleplayer && (!game.platform.SinglePlayerServerLoaded()))) { game.Draw2dBitmapFile("disconnected.png", game.Width() - 100, 50, 50, 50); FontCi font = new FontCi(); font.family = "Arial"; font.size = 12; game.Draw2dText(game.platform.IntToString(game.platform.FloatToInt(lagSeconds)), font, game.Width() - 100, 50 + 50 + 10, null, false); game.Draw2dText("Press F6 to reconnect", font, game.Width() / 2 - 200 / 2, 50, null, false); } }
internal static FontCi Create(string family_, float size_, int style_) { FontCi f = new FontCi(); f.family = family_; f.size = size_; f.style = style_; return f; }