New Tibia Outfitter.php

Discussion in 'Web-development' started by rena.to, Dec 27, 2015.

  1. rena.to

    rena.to TibiaKing Co-founder

    Joined:
    Jul 20, 2010
    Messages:
    57
    Likes Received:
    9
    Best Answers:
    0
    .
    .
    New Tibia Outfitter.php
    .
    .

    Links
    Github: https://github.com/renatorib/tibia-outfitter
    Donwload ZIP: https://github.com/renatorib/tibia-outfitter/archive/master.zip
    Issues?: https://github.com/renatorib/tibia-outfitter/issues

    Why another lib?
    I've refactored an existing lib (by Kamil Karkus, used by Gesior) to implement some new features like consistent image output and standardize all to 64x64 sprites (transform 32x32 to 64x64).

    What is different?
    • Consistent Image Output: all arguments are optional, no exceptions. And all arguments have validations. It means it will never output an inexistent image. For example, if you pass an inexistent looktype to image, it will use our default (that is 128, male citizen, but you can change in options);
    • Configurable: when instantiate Outfit, first argument is an array with settings options. You can configure/change the queries and default values, also you can queriefy by setting "query" => true;
    • 32x32 to 64x64: all 32x32 images are automagically transformed in 64x64 before output. No more different sizes;
    • Colors are sexy: all colors from head, body, legs and feet can be setted by numbers (tibia default colors table), hex (#FFFFFF or FFFFFF) and presetted color names like "red", "magenta", and "flat-clouds" (all flatuicolors.com colors are available by "flat-" + colorname, like "flat-peterriver").
    Usage

    For examples, I'will put the files in my public folder (site root folder) and write in outfit.php file.

    Direct properties

    With all defaults:
    PHP:
    1. <?php
    2. include('Outfit.class.php');
    3. header('Content-type: image/png');
    4.  
    5. $outfit = new Outfit();
    6. $outfit->render();
    [​IMG]

    Lets change looktype:
    PHP:
    1. <?php
    2. include('Outfit.class.php');
    3. header('Content-type: image/png');
    4.  
    5. $outfit = new Outfit();
    6. $outfit->looktype = 129;
    7. $outfit->render();
    [​IMG]

    Lets see preset colors:
    PHP:
    1. <?php
    2. include('Outfit.class.php');
    3. header('Content-type: image/png');
    4.  
    5. $outfit = new Outfit();
    6. $outfit->looktype = 129;
    7. $outfit->addons = 3;
    8. $outfit->body = "red";
    9. $outfit->render();
    [​IMG]

    Now, all properties:
    PHP:
    1. <?php
    2. include('Outfit.class.php');
    3. header('Content-type: image/png');
    4.  
    5. $outfit = new Outfit();
    6. $outfit->looktype = 130;
    7. $outfit->direction = 2;
    8. $outfit->movement = 3;
    9. $outfit->addons = 3;
    10. $outfit->mount = 450;
    11. $outfit->head = "flat-emerald"; // preset color
    12. $outfit->body = "#FF9900"; // css-like hex
    13. $outfit->legs = "4FE7A9"; // hex
    14. $outfit->feet = 4; // tibia color table
    15. $outfit->render();
    [​IMG]

    Enable properties by $_GET with queriefy

    PHP:
    1. <?php
    2. include('Outfit.class.php');
    3. header('Content-type: image/png');
    4.  
    5. $outfit = new Outfit();
    6. $outfit->queriefy();
    7. $outfit->render();
    [​IMG]

    Queriefy enables properties set by $_GET with this params:
    id (looktype), addons, movement, direction, mount, head, body, legs and feet.
    Example: outfit.php?id=128&movement=2&direction=1

    But, its a long query with long words. Fortunately you can change these query names by settings.

    Settings

    Auto Queriefy
    PHP:
    1. <?php
    2. include('Outfit.class.php');
    3. header('Content-type: image/png');
    4.  
    5. $outfit = new Outfit(array('query' => true));
    6. $outfit->render();
    [​IMG]

    Queries
    PHP:
    1. <?php
    2. include('Outfit.class.php');
    3. header('Content-type: image/png');
    4.  
    5. $outfit = new Outfit(array(
    6.     'query' => true,
    7.     'queries' => array(
    8.         'mount' => 'foo'
    9.     )
    10. ));
    11. $outfit->render();
    [​IMG]

    Defaults
    You also can change default values with settings:
    PHP:
    1. <?php
    2. include('Outfit.class.php');
    3. header('Content-type: image/png');
    4.  
    5. $outfit = new Outfit(array(
    6.     'query' => true,
    7.     'defaults' => array(
    8.         'body' => 'red',
    9.         'mount' => 322,
    10.         'direction' => 2
    11.     )
    12. ));
    13. $outfit->render();
    [​IMG]



    Adapting to gesior-style

    Gesior-style, for me, its query arguments with a, b, c, d, e etc.
    You will need to change queries and enable hexmount setting

    PHP:
    1. <?php
    2. include('Outfit.class.php');
    3. header('Content-type: image/png');
    4.  
    5. $outfit = new Outfit(array(
    6.     'query' => true,
    7.     'hexmount' => true,
    8.     'queries' => array(
    9.         'looktype' => 'a',
    10.         'addons' => 'b',
    11.         'head' => 'c',
    12.         'body' => 'd',
    13.         'legs' => 'e',
    14.         'feet' => 'f',
    15.         'mount' => 'g',
    16.         'direction' => 'h',
    17.         'movement' => 'i'
    18.     )
    19. ));
    20. $outfit->render();
    Now you can test
    outfit.php?a=514&b=2&c=45&d=13&e=65&f=1&g=66083&&h=2&i=3

    [​IMG]

    For now it's all.
     
    Last edited: Dec 27, 2015
    MatheusSesso, averatec, ATT3 and 4 others like this.
  2. Wyat

    Wyat New Member

    Joined:
    Aug 30, 2015
    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    how i install this in my site?
     

Share This Page

Loading...