Advertisement
jewalky

Untitled

Feb 5th, 2017
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.75 KB | None | 0 0
  1. class MyHandler : StaticEventHandler
  2. {
  3.     bool InLevel;
  4.  
  5.     override void OnRegister()
  6.     {
  7.         InLevel = false;
  8.     }
  9.    
  10.     override void WorldLoaded(WorldEvent e)
  11.     {
  12.         InLevel = true;
  13.     }
  14.    
  15.     override void WorldUnloaded(WorldEvent e)
  16.     {
  17.         InLevel = false;
  18.     }
  19.    
  20.     override void WorldTick(WorldEvent e)
  21.     {
  22.         //Console.Printf("MyHandler - world tick");
  23.     }
  24.    
  25.     private int VirtualWidth;
  26.     private int VirtualHeight;
  27.     private Font SMALLFNT;
  28.     private Font BIGFONT;
  29.    
  30.     private void DrawText(Font font, string text, double x, double y, int color) // align right!
  31.     {
  32.         int wd = font.StringWidth(text);
  33.         Screen.DrawText(font, color, x-wd, y, text, DTA_Alpha, 1.0, DTA_VirtualWidth, VirtualWidth, DTA_VirtualHeight, VirtualHeight, DTA_KeepRatio, true, 0);
  34.     }
  35.    
  36.     override void RenderOverlay(RenderEvent e)
  37.     {
  38.         if (!InLevel)
  39.             return;
  40.    
  41.         VirtualWidth = Screen.GetWidth()/3;
  42.         VirtualHeight = Screen.GetHeight()/3;
  43.         SMALLFNT = Font.GetFont("SMALLFONT");
  44.         BIGFONT = Font.GetFont("BIGFONT");
  45.        
  46.         //Screen.DrawText(f, Screen.CR_RED, vw/2-wd/2, 16, "Totally meow here", DTA_Alpha, (sin(level.time*8)/2)+0.5, DTA_VirtualWidth, vw, DTA_VirtualHeight, vh, 0);
  47.         DrawText(SMALLFNT, "Current map is:", VirtualWidth-8, 8, Screen.CR_RED);
  48.         DrawText(BIGFONT, String.Format("%s - %s", level.MapName, level.LevelName), VirtualWidth-8, 16, Screen.CR_GOLD);
  49.        
  50.         VirtualWidth = Screen.GetWidth();
  51.         VirtualHeight = Screen.GetHeight();
  52.         //DrawText(SMALLFNT, "(overlay message powered by bleeding edge ZScript event system)", VirtualWidth-32, 96, Screen.CR_DARKRED);
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement