Amaraticando

Lsnes beta23: performance test

Jun 22nd, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. local CUSTOM_FONTS = {
  2.         [false] = { file = nil, height = 16, width = 8 }, -- this is lsnes default font
  3.        
  4.         snes9xlua =       { file = [[data/snes9xlua.font]],        height = 16, width = 10 },
  5.         snes9xluaclever = { file = [[data/snes9xluaclever.font]],  height = 16, width = 08 }, -- quite pixelated
  6.         snes9xluasmall =  { file = [[data/snes9xluasmall.font]],   height = 09, width = 05 },
  7.         snes9xtext =      { file = [[data/snes9xtext.font]],       height = 11, width = 08 },
  8.         verysmall =       { file = [[data/verysmall.font]],        height = 08, width = 04 }, -- broken, unless for numerals
  9. }
  10.  
  11. -- Verify whether the fonts exist
  12. for key, value in pairs(CUSTOM_FONTS) do
  13.     if value.file and not io.open(value.file) then
  14.         print("WARNING:", string.format("./%s is missing.", value.file))
  15.         CUSTOM_FONTS[key] = nil
  16.     end
  17. end
  18.  
  19. -- Create a simple function for drawing fonts or the default text
  20. local draw_font = {}
  21. for font_name, value in pairs(CUSTOM_FONTS) do
  22.     draw_font[font_name] = function(x, y, text, color, bg, halo)
  23.         if font_name then
  24.             gui.font.load(value.file)(x, y, text, color, bg, halo)
  25.         else
  26.             gui.text(x, y, text, color, bg, halo)
  27.         end
  28.     end
  29. end
  30.  
  31. function on_paint()
  32.     local f = "snes9xluaclever" -- possible: "snes9xtext" , "snes9xluaclever" , "snes9xluaclever" , "snes9xlua" , false
  33.     draw_font[f](0, 00, "A")
  34.     draw_font[f](0, 16, "B")
  35.     draw_font[f](0, 32, "C")
  36. end
  37.  
  38. gui.repaint()
Advertisement
Add Comment
Please, Sign In to add comment