Beispiel #1
0
int main(int argc, char *argv[])
{
    int radky = 0;
    int sloupce = 0;
    int squareMode = 0;
    int hlineMode = 0;
    int vlineMode = 0;
    int testMode = 0;
    if (parametrCheck(argc, argv, &testMode, &hlineMode, &vlineMode, &squareMode) == 1) //pokud uzivatel chtel jen napovedy skonci
        return 1;


    FILE *soubor;
    if( (soubor = fopen(argv[2], "r")) == NULL) //otevreni souboru a kontrola zda probehlo otevreni uspesne
	{
        fprintf(stderr, "Chyba pri otevreni souboru\n");
		return 2;
	}
    fscanf(soubor, "%d",&(radky)); //nacti radky
    fscanf(soubor, "%d",&(sloupce)); //nacti sloupce
    if( (radky < 1) || (sloupce < 2)) //kontrola zda je matice vhodna podle zadani. Viz printf.
        fprintf(stderr, "Matice je chybne zadana. Nejmensi sirka by mela byt dva a nejmensi delka by mela byt 1\n");
    modeSelect(&testMode, &hlineMode, &vlineMode, &squareMode, soubor, &radky, &sloupce); //modSelect si prebere rizeni a podle modu vybere akci
    fclose(soubor); //zavreni souboru, dulezite
    return 0;
}
Beispiel #2
0
int main(int argc, char *argv[])
{
    putenv("UNICODEMAP_JP=cp932"); //Encoder needs this to encode in the correct varient of S-JIS

    if(argc < 2)
    {
        fprintf(stderr, "\nERR: No parameters! See usage info below.\n\n");
        printHelp();
    }

    if(strncmp(argv[1], "--help", strlen("--help")) == 0)
    {
        printf("\n");
        printHelp();
    }
    else if(strncmp(argv[1], "--decode-pac", strlen("--decode-pac")) == 0)
    {
        if(argc != 4)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString inputFilePath(argv[2]);
        QString outputFilePath(argv[3]);

        packer.unpack(inputFilePath, outputFilePath);
    }
    else if (strncmp(argv[1], "--encode-pac", strlen("--encode-pac")) == 0)
    {
        if(argc != 4)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString inputFilePath(argv[2]);
        QString outputFilePath(argv[3]);

        packer.pack(inputFilePath, outputFilePath);
    }
    else if (strncmp(argv[1], "--encode-arc", strlen("--encode-arc")) == 0)
    {
        if(argc != 5)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString inputDirPath(argv[2]);
        QString inputStructureFile(argv[3]);
        QString outputFilePath(argv[4]);

        writer.loadStructure(inputStructureFile);
        writer.buildArchive(inputDirPath, outputFilePath);
    }
    else if (strncmp(argv[1], "--decode-arc", strlen("--decode-arc")) == 0)
    {
        if(argc != 5)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString inputFilePath(argv[2]);
        QString outputDirPath(argv[3]);
        QString outputStructureFile(argv[4]);

        reader.open(inputFilePath);
        reader.decode();
        reader.extract(outputDirPath);
        reader.saveStructure(outputStructureFile);
    }
    else if(strncmp(argv[1], "--decode-scf", strlen("--decode-scf")) == 0)
    {
        if(argc < 4)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString inputFilePath(argv[2]);
        QString outputFilePath(argv[3]);

        scf2xml.load(inputFilePath);
        scf2xml.saveXml(outputFilePath);
    }
    else if(strncmp(argv[1], "--encode-scf", strlen("--encode-scf")) == 0)
    {
        if(argc < 4)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        int nextParam = 2;
        if(strncmp(argv[2], "--translate", strlen("--translate")) == 0)
        {
            lang_id translateTo = getLangIdByName(argv[3]);
            if(translateTo == LANGUAGE_UNKNOWN)
            {
                fprintf(stderr, "\nERR: Unknown translation language! See usage info below.\n\n");
                printHelp();
            }

            xml2scf.setLanguage(translateTo);
        }

        QString inputFilePath(argv[nextParam]);
        QString outputFilePath(argv[nextParam + 1]);

        xml2scf.load(inputFilePath);
        xml2scf.saveScf(outputFilePath);
    }

    else if(strncmp(argv[1], "--rename-scf", strlen("--rename-scf")) == 0)
    {
        if(argc != 4)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString dirPath(argv[3]);

        if (strnicmp(argv[2], "--toReal", strlen("--toReal")) == 0)
        {
            printf("toReal...\n");
            scfrename.numToReal(dirPath);
        }
        else if (strnicmp(argv[2], "--toNum", strlen("--toNum")) == 0)
        {
            printf("toNum...\n");
            scfrename.realToNum(dirPath);
        }
        else
        {
            printHelp();
        }
    }
    else if(strncmp(argv[1], "--rename-xml", strlen("--rename-xml")) == 0)
    {
        if(argc != 4)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString dirPath(argv[3]);

        if (strnicmp(argv[2], "--toReal", strlen("--toReal")) == 0)
        {
            printf("toReal...\n");
            xmlrename.numToReal(dirPath);
        }
        else if (strnicmp(argv[2], "--toNum", strlen("--toNum")) == 0)
        {
            printf("toNum...\n");
            xmlrename.realToNum(dirPath);
        }
        else
        {
            printHelp();
        }
    }

    else if(strncmp(argv[1], "--alphafix", strlen("--alphafix")) == 0)
    {
        if(argc != 4)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString modeSelect(argv[2]);
        QString inputFilePath(argv[3]);

        if (modeSelect == "-u")
        {
            alphafix.fixalpha(inputFilePath, 2);
        }
        else if (modeSelect == "-d")
        {
            alphafix.fixalpha(inputFilePath, 1);
        }
        else
        {
            fprintf(stderr, "\nERR: Incorrect mode imput! See usage info below.\n\n");
            printHelp();
        }
    }
    else if(strncmp(argv[1], "--cltappend", strlen("--cltappend")) == 0)
    {
        if(argc != 5)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        char *inputFilePath=argv[2];
        char *inputCLTFilePath=argv[3];
        char *outputFilePath=argv[4];

        cltprocessor.appendClut(inputFilePath, inputCLTFilePath, outputFilePath);
    }
    else if(strncmp(argv[1], "--cltremove", strlen("--cltremove")) == 0)
    {
        if(argc != 4)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        char *inputFilePath=argv[2];
        char *outputFilePath=argv[3];

        cltprocessor.removeClut(inputFilePath, outputFilePath);
    }
    else if (strncmp(argv[1], "--extract-img", strlen("--extract-img")) == 0)
    {
        if(argc != 5)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString inputFilePath(argv[2]);
        QString outputDirPath(argv[3]);
        QString outputStructureFile(argv[4]);

        extractor.extract(inputFilePath, outputDirPath, outputStructureFile);
    }
    else if(strncmp(argv[1], "--sync-xml", strlen("--sync-xml")) == 0)
    {
        if(argc < 5)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString inputFilePath(argv[2]); //source file: containing newest strings
        QString templateFilePath(argv[3]); //template file: new strings applied to this
        QString outputFilePath(argv[4]); //output file: new file for updated template

        xmlsync.load(inputFilePath, 0);
        xmlsync.load(templateFilePath, 1);

        if(argc == 6 && (strncmp(argv[5], "-2", strlen("-2")) == 0))
        {
            xmlsync.syncStrings(2); //Slower, brute-force scan
        }
        else if(argc == 6 && (strncmp(argv[5], "-1", strlen("-1")) == 0))
        {
            xmlsync.syncStrings(1); //Faster, one-to-one scan
        }
        else
        {
            xmlsync.syncStrings(0); //Automatically pick mode
        }

        xmlsync.saveXml(outputFilePath);
    }
    else if(strncmp(argv[1], "--swizzleprocess", strlen("--swizzleprocess")) == 0)
    {
        if(argc != 5)
        {
            fprintf(stderr, "\nERR: Incorrect amount of parameters! See usage info below.\n\n");
            printHelp();
        }

        QString modeSelect(argv[2]);
        QString inputFilePath(argv[3]);
        QString outputFilePath(argv[4]);

        if (modeSelect == "-d")
        {
            swizzleprocessor.swizzleProcess(inputFilePath, outputFilePath, 0);
        }
        else if (modeSelect == "-r")
        {
            swizzleprocessor.swizzleProcess(inputFilePath, outputFilePath, 1);
        }
        else
        {
            fprintf(stderr, "\nERR: Incorrect mode imput! See usage info below.\n\n");
            printHelp();
        }
    }
    else if (argc == 3)
    {
        QString inputFilePath(argv[2]);

        if(inputFilePath.endsWith(".xml"))
        {
            QString outputFilePath = inputFilePath.replace(inputFilePath.length() - 4, 3, "scf");
            xml2scf.load(inputFilePath);
            xml2scf.saveScf(outputFilePath);
        }
        else if(inputFilePath.endsWith(".scf"))
        {
            QString outputFilePath = inputFilePath.replace(inputFilePath.length() - 4, 3, "xml");
            scf2xml.load(inputFilePath);
            scf2xml.saveXml(outputFilePath);
        }
        else if(inputFilePath.endsWith(".pac"))
        {
            QString outputFilePath = inputFilePath.replace(inputFilePath.length() - 4, 3, "arc");
            packer.unpack(inputFilePath, outputFilePath);
        }
        else
        {
            fprintf(stderr, "\nERR: Incorrect input file extension! See usage info below.\n\n");
            printHelp();
        }
    }
    else
    {
        fprintf(stderr, "\nERR: Unknown command! See usage info below.\n\n");
        printHelp();
    }

    fprintf(stderr, "\nDone!\n");
    return 0;
}
Beispiel #3
0
void title::update() {
  sceneChange();
  if (clickStart()) { return; }
  modeSelect();
}