# Path: font_parser.py
# FONT_DATA = { 1: {}, 2: {} }
# 
# CLT = {
#          0: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#          1: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#          2: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#          3: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#          4: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#          5: {'font': 2, 'hscale': 0.69,       'vscale': 0.69,       'xshift': 0.00,   'yshift': 0.00},
#          6: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#          7: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#          8: {'font': 2, 'hscale': 5.0 / 6.0,  'vscale': 5.0 / 6.0,  'xshift': -1.00,  'yshift': 1.00},
#          9: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         10: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         11: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         12: {'font': 2, 'hscale': 5.0 / 6.0,  'vscale': 5.0 / 6.0,  'xshift': -1.00,  'yshift': 0.00},
#         13: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         14: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         15: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         16: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         17: {'font': 2, 'hscale': 2.0 / 3.0,  'vscale': 2.0 / 3.0,  'xshift': 0.00,   'yshift': 0.00},
#         18: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         19: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         20: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         21: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         22: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         23: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         24: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         25: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         26: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         98: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         99: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#       }


from PyQt4 import QtCore, QtGui, Qt
from PyQt4.QtGui import QImage, QPainter, QColor, QPixmap, QBitmap, QMatrix
from PyQt4.QtCore import QRect, QRectF
from enum import Enum
from font_parser import FONT_DATA, CLT
from text_files import load_text
from sprite import get_sprite_file, SPRITE_TYPE
import ctypes
import os.path
import re
import sys
import time
import common
import font_parser
  if not scene_info.img_filter == IMG_FILTERS.unfiltered:
    painter.end()
    out = filter_image(out, scene_info.img_filter)
    painter = QPainter(out)
    painter.setRenderHint(QPainter.Antialiasing, True)
  
  if show_box:
  
    box = get_box(scene_info)
    painter.drawImage(out.rect(), box, box.rect())
  
  return out

##############################################################################
### @fn   get_letter(clt, char)
### @desc Returns an image containing the letter rendered with the given CLT.
##############################################################################
def get_letter(clt, char):
  
  if not clt in CLT:
    clt = 0
  
  font    = CLT[clt]['font']
  hscale  = CLT[clt]['hscale']
  vscale  = CLT[clt]['vscale']
  
  try:
    info = FONT_DATA[font][char]
  except:
    # This is the character the game replaces unknown characters with.

# Path: font_parser.py
# FONT_DATA = { 1: {}, 2: {} }
# 
# CLT = {
#          0: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#          1: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#          2: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#          3: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#          4: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#          5: {'font': 2, 'hscale': 0.69,       'vscale': 0.69,       'xshift': 0.00,   'yshift': 0.00},
#          6: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#          7: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#          8: {'font': 2, 'hscale': 5.0 / 6.0,  'vscale': 5.0 / 6.0,  'xshift': -1.00,  'yshift': 1.00},
#          9: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         10: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         11: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         12: {'font': 2, 'hscale': 5.0 / 6.0,  'vscale': 5.0 / 6.0,  'xshift': -1.00,  'yshift': 0.00},
#         13: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         14: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         15: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         16: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         17: {'font': 2, 'hscale': 2.0 / 3.0,  'vscale': 2.0 / 3.0,  'xshift': 0.00,   'yshift': 0.00},
#         18: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         19: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         20: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         21: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         22: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         23: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         24: {'font': 1, 'hscale': 0.80,       'vscale': 0.80,       'xshift': -1.00,  'yshift': 0.00},
#         25: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         26: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         98: {'font': 1, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#         99: {'font': 2, 'hscale': 1.00,       'vscale': 1.00,       'xshift': 0.00,   'yshift': 0.00},
#       }


# Path: text_printer.py
from PyQt4 import QtCore, QtGui, Qt
from PyQt4.QtGui import QImage, QPainter, QColor, QPixmap, QBitmap, QMatrix
from PyQt4.QtCore import QRect, QRectF
from enum import Enum
from font_parser import FONT_DATA, CLT
from text_files import load_text
from sprite import get_sprite_file, SPRITE_TYPE
import ctypes
import os.path
import re
import sys
import time
import common
import font_parser

  if not scene_info.img_filter == IMG_FILTERS.unfiltered:
    painter.end()
    out = filter_image(out, scene_info.img_filter)
    painter = QPainter(out)
    painter.setRenderHint(QPainter.Antialiasing, True)
  
  if show_box:
  
    box = get_box(scene_info)
    painter.drawImage(out.rect(), box, box.rect())
  
  return out

##############################################################################
### @fn   get_letter(clt, char)
### @desc Returns an image containing the letter rendered with the given CLT.
##############################################################################
def get_letter(clt, char):
  
  if not clt in CLT:
    clt = 0
  
  font    = CLT[clt]['font']
  hscale  = CLT[clt]['hscale']
  vscale  = CLT[clt]['vscale']
  
  try:
    info = FONT_DATA[font][char]
  except:
    # This is the character the game replaces unknown characters with.

    info = FONT_DATA[font][u'\u2261']