示例#1
0
        $existingFontSizeDB = new FontSizeDB(true);
    }
    if (file_exists("data/fontSizes.csv")) {
        echo "Backing up file \"data/fontSizes.csv\" to \"data/fontSizes.csv.bak\"...\n";
        @unlink("data/fontSizes.csv.bak");
        @copy("data/fontSizes.csv", "data/fontSizes.csv.bak");
    }
}
$fontSizesFile = fopen_utf8("data/fontSizes.csv", $existingFontSizeDB ? 'a' : 'w');
if (!$fontSizesFile) {
    error("Unable to write CSV file: data/fontSizes.csv");
}
$config['output.card.set.directories'] = true;
$config['card.flavor.random'] = false;
$writer = new ImageWriter();
$writer->setOutputType(false, false);
echo "Building cache...\n";
foreach ($writer->cardDB->getAllCardTitles() as $title) {
    if ($existingFontSizeDB && $existingFontSizeDB->hasCard($title)) {
        continue;
    }
    $writer->fontSizeDB->reset();
    $writer->addCardByTitle($title);
    foreach ($writer->renderers as $renderer) {
        $renderer->render();
    }
    $fontSizes = $writer->fontSizeDB->getSizes($title);
    if ($fontSizes) {
        foreach ($fontSizes as $hash => $size) {
            writeCsvRow($fontSizesFile, array((string) $title, (string) $hash, (string) $size));
        }
示例#2
0
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////
require_once 'includes/global.php';
$pagedOutput = $argv[1] == 'pagedOutput=true';
$decklistOnlyOutput = $argv[2] == 'decklistOnlyOutput=true';
$fileNames = array_slice($argv, 3);
$mode = 'Generate ';
if ($decklistOnlyOutput) {
    $mode .= 'Decklist ';
}
$mode .= $pagedOutput ? 'Pages' : 'Cards';
echo "Card Generator v{$version} - {$mode}\n\n";
$files = getInputFiles($fileNames, 'Drag and drop a decklist file or directory into this window and press enter...');
configPrompt($decklistOnlyOutput);
cleanOutputDir($pagedOutput);
$writer = new ImageWriter();
$writer->setOutputType($pagedOutput, $decklistOnlyOutput);
foreach ($files as $file) {
    $writer->parseDecklist($file);
}
echo "Generating images...\n";
if ($pagedOutput) {
    $count = $writer->writePages();
    echo "Image generation complete.\n";
    echo $count . " pages written.\n";
} else {
    $count = $writer->writeCards();
    echo "Image generation complete.\n";
    echo $count . " images written.\n";
}