def loadScpStringList(self, paramList):
     return [ed6fc.ScpString(**p) for p in paramList]
def main():
    global textPosTable, replaceOption

    #os.chdir(os.path.dirname(__file__))

    #if not ExtractText:
    #    textPosTable = json.load(open('fc_sn_text_final.json', 'r', encoding = 'utf-8-sig'))
    #    replaceOption = json.load(open('replace_option.json', 'r', encoding = 'utf-8-sig'))

    cp = 'gbk'
    gp = r'D:\Steam\steamapps\common\Trails in the Sky FC'
    files = []
    i = 1
    append_place_name = False
    use_index_lable = False

    while i < len(sys.argv):
        if sys.argv[i].startswith('--cp='):
            cp = sys.argv[i][5:]
        elif sys.argv[i].startswith('--cppy='):
            cppy = os.path.abspath(sys.argv[i][7:])
            ccode = importlib.machinery.SourceFileLoader(os.path.basename(cppy).split('.')[0], cppy).load_module()
            ccode.register()
            cp = ccode.get_name()
        elif sys.argv[i].startswith('--gp='):
            gp = os.path.abspath(sys.argv[i][5:])
        elif sys.argv[i].lower() == '--append_place_name=true':
            append_place_name = True
        elif sys.argv[i].lower() == '--indexlabel=true':
            use_index_lable = True
        else:
            files.extend(iterlib.forEachGetFiles(sys.argv[i], '*._SN'))

        i += 1

    global CODE_PAGE
    CODE_PAGE = cp
    ed6fc.CODE_PAGE = cp
    ed6fc.ed6fc_op_table.CodePage = cp
    setCodePage(cp);

    global GAME_PATH
    GAME_PATH = gp
    setGamePath(gp)
    initDatFileNameTable(GAME_PATH)

    global USE_INDEX_LABEL_NAME
    if use_index_lable:
        USE_INDEX_LABEL_NAME = True
        ed6fc.USE_INDEX_LABEL_NAME = True
        ed6fc.UseIndexLabelName()
    
    #Log.OpenLog(sys.argv[start_argv] + '\..\log.txt')

    global LAMBDA_INDEX
    for file in files:
        plog('START %s' % file)
        ed6fc.ResetIndex()
        ed6fc.ResetLabmdaIndex()
        procfile(file, append_place_name)
        plog('FINISHED %s' % file)

    if ExtractText:
        open('fc_sn_text.json', 'wb').write(json.dumps(textPosTable, indent = 2, ensure_ascii = False).encode('utf_8_sig'))