Skip to content

Commit

Permalink
Version 0.1.3 - outfit images generator PHP code compatible with PHP …
Browse files Browse the repository at this point in the history
…8.0, fix mount animation
  • Loading branch information
gesior committed Sep 19, 2021
1 parent 8bd7f6f commit 7c8cb47
Show file tree
Hide file tree
Showing 9 changed files with 7,070 additions and 277 deletions.
6,803 changes: 6,785 additions & 18 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "open-tibia-library",
"version": "0.1.2",
"version": "0.1.3",
"description": "OpenTibiaLibrary",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
4 changes: 3 additions & 1 deletion tools/colored-outfit-images-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ In this folder are PHP files to generate colored outfit images from outfit image

Unzip generated `outfits.zip` to this folder and put all files on web server.

Set write file permissions to unzipped folder for PHP. It will generate cache files in folders with images on first run.
Set write file permissions to unzipped folder for PHP. It will generate cache files in folders with images on first run.

You can generate `outfits.zip` using official host of OpenTibiaLibrary: https://outfit-images.ots.me/generator/
17 changes: 3 additions & 14 deletions tools/colored-outfit-images-generator/animoutfit.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,9 @@
exit;
}

$walkSpeeds = [
1 => 50,
2 => 35,
3 => 30,
4 => 15,
5 => 15,
6 => 15,
7 => 15,
8 => 8,
9 => 8
];

header('Cache-control: max-age=' . (60 * 60 * 24 * 365));
header('Expires: ' . gmdate(DATE_RFC1123, time() + 60 * 60 * 24 * 365));
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', 1337) . ' GMT'); // date in 1970
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', 1337) . ' GMT');
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
header('HTTP/1.0 304 Not Modified');
header('Cache-Control: public');
Expand All @@ -43,6 +31,7 @@
require('libs/gifCreator.php');

Outfitter::$outfitPath = $outfitImagesPath;
Outfitter::setResizeAllOutfitsTo64px($resizeAllOutfitsTo64px);

$id = 0;
if (isset($_GET['id'])) {
Expand Down Expand Up @@ -74,7 +63,7 @@
}
$feet = 0;
if (isset($_GET['feet'])) {
$addons = (int)$_GET['feet'];
$feet = (int)$_GET['feet'];
}
$addons = 0;
if (isset($_GET['addons'])) {
Expand Down
2 changes: 1 addition & 1 deletion tools/colored-outfit-images-generator/cacheGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

// CODE TO CHECK WHAT VALUES OF 'framesNumber' ARE POSSIBLE FOR YOUR OUTFITS
$frameNumbers = [];
$frameNumbers = [0,0,0,0,0,0,0,0,0,0];
foreach($outfits as $outfitId => $outfit)
{
if (!file_put_contents($outfitImagesPath . '/' . $outfitId . '/outfit.data.txt', serialize($outfit))) {
Expand Down
16 changes: 16 additions & 0 deletions tools/colored-outfit-images-generator/config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
<?php

$outfitImagesPath = './outfits_anim/';
// resize all outfits to 64x64 pixels, place smaller outfits in bottom-right corner
$resizeAllOutfitsTo64px = false;

// animation speeds: number of animation frames => time in 0.01 of second
$walkSpeeds = [
1 => 50,
2 => 35,
3 => 30,
4 => 15,
5 => 15,
6 => 15,
7 => 15,
8 => 10,
9 => 8
];

/*
some server configurations may print warnings from graphics library
these warnings are interpreted as part of image and make image unreadable for web browsers
Expand Down
Loading

0 comments on commit 7c8cb47

Please sign in to comment.