[1.7.3] Roster Tooltip Mod for Gems and Enchants (v1.3)

Item tooltips with Gem Sockets and Enchantment coloring

Moderator: ds

Re: [1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby Diska » Thu Feb 22, 2007 10:31 am

Subxero wrote:Because some people get these errors ?

Failed to match enchant_txt from db
enchant txt: +9 Stamina
on tooltip show: Stamina +9

And others like HP +100 / +100 HP

+20 Fire Spell Damage / +20 Fire Damage
+20 Shadow Spell Damage / +20 Shadow Damage

etc..

inversed order 8(


They changed the text of enchants in some patch...think it was 2.01. I think you'll find that every person with these errors uploaded their data before that time, so get those lazy people to update their data :P
Might be worth to mention this somewhere because people are obviously going to ask this very same question a couple of more times :)
Last edited by Diska on Thu Feb 22, 2007 10:32 am, edited 1 time in total.
User avatar
Diska
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 179
Joined: Tue Jul 04, 2006 2:05 pm

[1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby Yoshette » Thu Feb 22, 2007 10:19 pm

I'm trying to translate the list in french. But I think that I'm going to shoot me before I finish. They exist no database in French.

I need to translate one by one. If someone want to help me, contact me.
Yoshette
WR.net Apprentice
WR.net Apprentice
 
Posts: 41
Joined: Fri Oct 06, 2006 2:14 am
Location: Boston, MA, USA

[1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby robojerk » Fri Feb 23, 2007 1:52 am

This hack seems to have broken my recipe page in WoWRosterDF..

http://blacktemplars.org/index.php?name ... on=recipes

I did fix it however

change
Code: Select all
     <th class="membersHeader">'.$url.'&action=recipes&s=item">'.$wordings[$lang]['item'].'</a></th>
     <th class="membersHeader">'.$url.'&action=recipes&s=name">'.$wordings[$lang]['name'].'</a></th>
     <th class="membersHeader">'.$url.'&action=recipes&s=difficulty">'.$wordings[$lang]['difficulty'].'</a></th>
     <th class="membersHeader">'.$url.'&action=recipes&s=type">'.$wordings[$lang]['type'].'</a></th>
     <th class="membersHeader">'.$url.'&action=recipes&s=level">'.$wordings[$lang]['level'].'</a></th>
     <th class="membersHeaderRight">'.$url.'&action=recipes&s=reagents">'.$wordings[$lang]['reagents'].'</a></th>


To this
Code: Select all
     <td class="membersHeader"><a href="'.getlink($url.'&amp;s=item').'">'.$wordings[$lang]['item'].'</a></td>
     <td class="membersHeader"><a href="'.getlink($url.'&amp;s=name').'">'.$wordings[$lang]['name'].'</a></td>
     <td class="membersHeader"><a href="'.getlink($url.'&amp;s=difficulty').'">'.$wordings[$lang]['difficulty'].'</a></td>
     <td class="membersHeader"><a href="'.getlink($url.'&amp;s=type').'">'.$wordings[$lang]['type'].'</a></td>
     <td class="membersHeader"><a href="'.getlink($url.'&amp;s=level').'">'.$wordings[$lang]['level'].'</a></td>
     <td class="membersHeaderRight"><a href="'.getlink($url.'&amp;s=reagents').'">'.$wordings[$lang]['reagents'].'</a></td>
Image
For the Horde!
Image
User avatar
robojerk
WR.net Master
WR.net Master
 
Posts: 484
Joined: Wed Jul 05, 2006 12:17 am
Location: -The OmniMatrix- Web 3.0

[1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby DiscoWay » Fri Feb 23, 2007 2:07 am

Aah thanks robojerk, i was just about to go into the /lib/char.php file to see how to fix this, uber =)
User avatar
DiscoWay
WR.net Apprentice
WR.net Apprentice
 
Posts: 25
Joined: Mon Feb 12, 2007 11:40 pm

[1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby robojerk » Fri Feb 23, 2007 3:00 am

Yeah, I made a diff comparing the wowrosterdf and this char.php and just used the code from the wowrosterdf version..

I also moved the socket.png files to {roster icons config location}/Interface/ItemSocketingFrame/ and changed line 487 of commonfunctions.lib.php to this.

Code: Select all
$parsedToolTip = preg_replace('/(Yellow|Blue|Red|Meta)\sSocket/i', '<img src="'.$roster_conf['interface_url'].'Interface/ItemSocketingFrame/${1}socket.'.$roster_conf['img_suffix'].'" alt="">  $1 Socket', $parsedToolTip);


and 497 to this

Code: Select all
$parsedToolTip = str_replace($gem_ids[$id]['txt'], '<img width="16px" height="16px" src="'.$roster_conf['interface_url'].'Interface/Icons/'.$gem_ids[$id]['img'].'.'.$roster_conf['img_suffix'].'"><span style="color:#00ff00;">  '.$gem_ids[$id]['txt'].'</span>', $parsedToolTip);


I also replaced the png files with these ones.. The ones that are included with this hack are not uniform, the blue one looks off centered and they are also of low quality. Maybe I'm just anal. I also added jpg.
Attachments
sockets.zip
(5.13 KiB) Downloaded 367 times
diffs.zip
Diff files
(3.25 KiB) Downloaded 373 times
Last edited by robojerk on Fri Feb 23, 2007 4:13 am, edited 3 times in total.
Image
For the Horde!
Image
User avatar
robojerk
WR.net Master
WR.net Master
 
Posts: 484
Joined: Wed Jul 05, 2006 12:17 am
Location: -The OmniMatrix- Web 3.0

[1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby ds » Fri Feb 23, 2007 3:10 am

Looks like I made a mistake and included char.php in the original version of this Mod. I did not make any changes to char.php.
Image
ds
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 297
Joined: Sat Jul 08, 2006 9:58 am

[1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby robojerk » Fri Feb 23, 2007 4:06 am

lol, you serious?

Let me upload the DF version of char.php and see if I get any errors.
Image
For the Horde!
Image
User avatar
robojerk
WR.net Master
WR.net Master
 
Posts: 484
Joined: Wed Jul 05, 2006 12:17 am
Location: -The OmniMatrix- Web 3.0

[1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby robojerk » Fri Feb 23, 2007 4:12 am

Yeah, uploaded the original DF version of /lib/char.php and it works w/o errors. =)

IMO the socket images need to be included with the interface image pack which is why I put them in there..
If you wanted to keep the images named correctly they also need to be renamed to something like "UI-EmptySocket-Blue"
Image
For the Horde!
Image
User avatar
robojerk
WR.net Master
WR.net Master
 
Posts: 484
Joined: Wed Jul 05, 2006 12:17 am
Location: -The OmniMatrix- Web 3.0

[1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby zanix » Fri Feb 23, 2007 5:10 am

I agree with robojerk
I believe the icons need to go here
Code: Select all
Interface
     ItemSocketingFrame
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: [1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby ds » Fri Feb 23, 2007 8:09 pm

Uploaded v1.2 of this mod (please see my first message in this thread).

This is a rewrite of the old code with all the suggestions people gave me.

[FIXED] The problem with some gems getting placed in line with another on the same line.
[FIXED] Will no longer color non enchantment/gem texts.
[ADDED] 2 levels of debugging information.
Debug level 1 will provide information of missing gems or enchantments only.
Debug level 2 is very verbose and will return all ItemIDs, GemIDs, EnchantIDs. You normally dont want this level and Debug level 1 is default.
[CHANGED] The location of empty Sockets has changed to %roster_interface_url%/Interface/ItemSocketingFrame/
Changed the name of the empty socket icons to match Blizzards names.
I also re-extracted and saved the Icons for .jpg and .png both versions are included in the zip file.

Remember this should only be used on WoW Roster Version 1.7.3! WoWRosterDF users SHOULD NOT just overwrite your files with my files!

On that note; I hope to follow up this thread today with .diff files or a post with manual changes to the code for modified version of WoW Roster.
Image
ds
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 297
Joined: Sat Jul 08, 2006 9:58 am

Re: [1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby ds » Fri Feb 23, 2007 9:53 pm

Here is a list of code replacements for modified WoW Roster users:

Find In File: settings.php
Code: Select all
require_once (ROSTER_LIB.'commonfunctions.lib.php');


Add BEFORE
Code: Select all
require_once (ROSTER_LIB.'WoW_IDs.php');  // include before common functions because of a define used in functions file.




Find In File: lib/item.php
Code: Select all
                $tooltip = makeOverlib($this->data['item_tooltip'],'',$this->data['item_color'],0,$lang);

CHANGE to
Code: Select all
                $tooltip = makeOverlib($this->data['item_tooltip'],'',$this->data['item_color'],0,$lang,'',$this->data['item_id']);




Find In File: lib/commonfunctions.lib.php
Code: Select all
function makeOverlib( $tooltip , $caption='' , $caption_color='' , $mode=0 , $locale='' , $extra_parameters='')

CHANGE to
Code: Select all
function makeOverlib( $tooltip , $caption='' , $caption_color='' , $mode=0 , $locale='' , $extra_parameters='', $itemid='' )


Find In File: lib/commonfunctions.lib.php
Code: Select all
        switch ($mode)
        {
                case 0:
                        $tooltip = colorTooltip($tooltip,$caption_color,$locale,$caption_mode);
                        break;

                case 1:
                        $tooltip = cleanTooltip($tooltip,$caption_color,$caption_mode);
                        break;

                case 2:
                        break;

                default:
                        $tooltip = colorTooltip($tooltip,$caption_color,$locale,$caption_mode);
                        break;
        }

CHANGE to
Code: Select all
        switch ($mode)
        {
                case 0:
                        $tooltip = colorTooltip($tooltip,$caption_color,$locale,$caption_mode,$itemid);
                        break;

                case 1:
                        $tooltip = cleanTooltip($tooltip,$caption_color,$caption_mode);
                        break;

                case 2:
                        break;

                default:
                        $tooltip = colorTooltip($tooltip,$caption_color,$locale,$caption_mode,$itemid);
                        break;
        }

Find In File: lib/commonfunctions.lib.php
Code: Select all
        setTooltip($num_of_tips,$tooltip);

        return 'onmouseover="return overlib(overlib_'.$num_of_tips.$caption.$extra_parameters.');" onmouseout="return nd();"';
}

CHANGE to
Code: Select all
        setTooltip($num_of_tips,$tooltip);

        return 'onmouseover="return overlib(overlib_'.$num_of_tips.$caption.$extra_parameters.', WIDTH, '.OVERLIB_WIDTH.');" onmouseout="return nd();"';
}

Find In File: lib/commonfunctions.lib.php
Code: Select all
/**
 * Tooltip colorizer function with string cleaning
 * Use only with makeOverlib
 *
 * @param string $tooltip | Tooltip as a string (delimited by "\n" character)
 * @param string $caption_color | (optional) Color for the caption
 * Default is 'ffffff' - white
 * @param string $locale | (optional) Locale so color parser can work correctly
 * Default is $roster_conf['roster_lang']
 * @param bool $inline_caption | (optional)
 * Default is true
 * @return string | Formatted tooltip
 */
function colorTooltip( $tooltip , $caption_color='' , $locale='' , $inline_caption=1 )
{

REPLACE THIS FUNCTION WITH THE FOLLOWING THREE FUNCTIONS!
Code: Select all
function parseItemId($itemid)
{
   if(empty($itemid))
   {
      return false;
   }

   list ($item_id, $enchant_id, $gem_id_1, $gem_id_2, $gem_id_3, $gem_id_4, $suffix_id, $unique_id) = explode(':', $itemid);
   $return = array
   (
   'item_id' => $item_id,
   'enchant_id' => $enchant_id,
   'gem1' => $gem_id_1,
   'gem2' => $gem_id_2,
   'gem3' => $gem_id_3,
   'gem4' => $gem_id_4,
   'suffix_id' => $suffix_id,
   'unique_id' => $unique_id
   );

   return $return;
}

function parseTooltipEnchantments($searchLine, $search_IDs, $searchEnchants=false, $searchGems=false)
{
   if(empty($searchLine) OR empty($search_IDs))  // did this function get called correctly?
   {
      return false;
   }

   global $enchantment_ids;
   global $gem_ids;
   global $roster_conf;

   //init return array
   $return = array
   (
   'matched_enchant'   => false,   // true if enchant is found in line
   'matched_gem'       => false,   // true if a gem is found in line
   'txt'             => '',      // converted text to return
   'debug'          => '',      // debug level 1 messages
   'debug_2'          => '',      // debug level 2 messages
   );

   if ($searchEnchants) // the searchLine might include an enchantment so look for one.
   {
      if(strstr($searchLine, $enchantment_ids[$search_IDs['enchant_id']]))
      {
         $return['txt'] = '<span style="color:#00ff00;">'.$searchLine.'</span>';
         $return['matched_enchant'] = true;
         $return['debug_2'] = 'Found Enchantment: "'.$enchantment_ids[$search_IDs['enchant_id']].'"';
      }
   }

   if($search_IDs['gid1'] <> 0)
   {
      $gemlist = array($search_IDs['gid1'], $search_IDs['gid2'], $search_IDs['gid3'], $search_IDs['gid4']);

      foreach($gemlist as $id)
      {
         if(strstr($searchLine, $gem_ids[$id]['txt']))
         {
            $return['txt'] = '<img width="16px" height="16px" src="'.$roster_conf['interface_url'].'Interface/Icons/'.$gem_ids[$id]['img'].'.'.$roster_conf['img_suffix'].'" alt="" /><span style="color:#00ff00;">  '.$gem_ids[$id]['txt'].'</span>';
            $return['debug_2'] = 'Found gem id: '.$id.'<br />';
            $return['matched_gem'] = true;
            $return['found_id'] = $id;
            break; // found a match... break out of loop
         }
      }
   }

   return $return;
}


/**
 * Tooltip colorizer function with string cleaning
 * Use only with makeOverlib
 *
 * @param string $tooltip | Tooltip as a string (delimited by "\n" character)
 * @param string $caption_color | (optional) Color for the caption
 * Default is 'ffffff' - white
 * @param string $locale | (optional) Locale so color parser can work correctly
 * Default is $roster_conf['roster_lang']
 * @param bool $inline_caption | (optional)
 * Default is true
 * @param string $itemid | (optional) will parse enchantments and gems if passed
 * @return string | Formatted tooltip
 */
function colorTooltip( $tooltip , $caption_color='' , $locale='' , $inline_caption=1, $itemid='' )
{
   global $wordings, $roster_conf, $enchantment_ids;

   // Use main locale if one is not specified
   if( $locale == '' )
   $locale = $roster_conf['roster_lang'];

   // Initialize tooltip_out
   $tooltip_out = array();
   $current_line = 0;
   $out = array();
   // Standardize for conversion
   $tooltip = str_replace("\n\n", '<br>', $tooltip);    // cheap hack to fix double line breaks in tooltip
   $tooltip = str_replace('<br>', "\n", $tooltip);
   $tooltip = str_replace('<br />', "\n", $tooltip);

   //convert tooltip to array
   $tooltip = explode("\n", $tooltip);
   //how many lines is the tooltip?
   $tooltip_lines = count($tooltip);
   //reverse the array to process last first
   $tooltip = array_reverse($tooltip);
   $tooltip_debug = '';  // quiet
   $tooltip_debug_2 = ''; // verbose

   if(!empty($itemid))
   {
      // itemid was passed
      $itemid = parseItemId($itemid);
      $doEnchants = (empty($itemid['enchant_id']) ? false : true);
      $doGems = (empty($itemid['gem1']) ? false : true);

      $search_IDs = array
      (
      'enchant_id'=> $itemid['enchant_id'],
      'gid1'       => $itemid['gem1'],
      'gid2'       => $itemid['gem2'],
      'gid3'       => $itemid['gem3'],
      'gid4'       => $itemid['gem4'],
      );
   }

   foreach ( $tooltip as $line )
   {
      //foreach loop counter
      $current_line++;

      $color = '';

      if( !empty($line) )
      {
         $line = preg_replace('|\\>|','›', $line );
         $line = preg_replace('|\\<|','&#8249;', $line );
         $line = preg_replace('/\|c[a-f0-9]{2}([a-f0-9]{6})(.+?)\|r/i','<span style="color:#$1;">$2</span>',$line);

         // Do this on the last line (first line when reversed again)
         // This is performed when $caption_color is set
         if( ($inline_caption == 1) && ($current_line == $tooltip_lines) )
         {
            if( $caption_color == '' )
            $caption_color = 'ffffff';

            if( strlen($caption_color) > 6 )
            $color = substr( $caption_color, 2, 6 ) . ';font-size:12px;font-weight:bold';
            else
            $color = $caption_color . ';font-size:12px;font-weight:bold';
         }
         else
         {
            if ( ereg('^'.$wordings[$locale]['tooltip_use'],$line) )
            $color = '00ff00';
            elseif ( ereg('^'.$wordings[$locale]['tooltip_requires'],$line) )
            $color = 'ff0000';
            elseif ( ereg('^'.$wordings[$locale]['tooltip_reinforced'],$line) )
            $color = '00ff00';
            elseif ( ereg('^'.$wordings[$locale]['tooltip_equip'],$line) )
            $color = '00ff00';
            elseif ( ereg('^'.$wordings[$locale]['tooltip_chance'],$line) )
            $color = '00ff00';
            elseif ( ereg('^'.$wordings[$locale]['tooltip_enchant'],$line) )
            $color = '00ff00';
            elseif ( ereg('^'.$wordings[$locale]['tooltip_soulbound'],$line) )
            $color = '00bbff';
            elseif ( ereg('^'.$wordings[$locale]['tooltip_set'],$line) )
            $color = '00ff00';
            elseif ( preg_match('|\([a-f0-9]\).'.$wordings[$locale]['tooltip_set'].'|',$line) )
            $color = '666666';
            elseif ( ereg('^"',$line) )
            $color = 'ffd517';
            elseif (ereg('Shift Right Click', $line))
            $line = '';
         }

         // Convert tabs to a formated table
         if( strpos($line,"\t") )
         {
            $line = str_replace("\t",'</td><td align="right" class="overlib_maintext">', $line);
            $line = '<table width="100%" cellspacing="0" cellpadding="0"><tr><td class="overlib_maintext">'.$line.'</td></tr></table>';
            $tooltip_out[] = $line;
         }

         elseif (preg_match('/(Yellow|Blue|Red|Meta)\sSocket/', $line))
         {
            $tooltip_out[] = preg_replace('/(Yellow|Blue|Red|Meta)\sSocket/', '<img src="'.$roster_conf['interface_url'].'Interface/ItemSocketingFrame/UI-EmptySocket-$1.'.$roster_conf['img_suffix'].'">  $1 Socket', $line);
         }

         elseif( !empty($color) )
         {
            $tooltip_out[] = '<span style="color:#'.$color.';">'.$line.'</span><br />';
         }
         elseif(!empty($itemid))  // nothing else matched lets try to match enchantments and gems if we have an ItemID string
         {
            $out = parseTooltipEnchantments($line, $search_IDs, $doEnchants, $doGems);
            if ($out['matched_enchant'] == true)
            {
               $line = $out['txt'];
               $doEnchants = false;
               if(TOOLTIP_DEBUG == 2)
               $toolip_debug_2 .= $out['debug_2'];
               if(TOOLTIP_DEBUG == 1)
               $toolip_debug .= $out['debug'];
            }
            elseif ($out['matched_gem'] == true)
            {
               // matched gem
               $line = $out['txt'];
               if(TOOLTIP_DEBUG == 2)
               $toolip_debug_2 .= $out['debug_2'];
            }
            $tooltip_out[] = $line.'<br />';
         }
      }
      else
      {
         $tooltip_out[] = '<br />';
      }
   }

   // convert tooltip back to a sting and re-reverse
   $tooltip_out = implode('', array_reverse($tooltip_out));

   if (TOOLTIP_DEBUG == 2) // display verbose debugging info in tooltip
   {
      $tooltip_out .= '<hr><br />itemid: '.$itemid['item_id'].' enchantid: '.$itemid['enchant_id'].'<br />';
      $tooltip_out .= 'gem1: '.$itemid['gem1'].' gem2: '.$itemid['gem2'].' gem3: '.$itemid['gem3'].' gem4: '.$itemid['gem4'].'<br />';
      $tooltip_out .= $toolip_debug_2;
   }
   if (TOOLTIP_DEBUG >= 1) // display quiet debugging info, just parsing errors / unmatched texts.
   {
      if($itemid['enchant_id'] <> 0 && $doEnchants == true)
      {
         if(TOOLTIP_DEBUG == 1)
         {
            $tooltip_out .= '<hr>';
         }
         $tooltip_out .= 'Failed to match enchant_id: <b>'.$itemid['enchant_id'].'</b> to tooltip text!<br />"'.$enchantment_ids[$itemid['enchant_id']].'" was searched for.<br />';
      }
   }
   return $tooltip_out;
}
Image
ds
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 297
Joined: Sat Jul 08, 2006 9:58 am

Re: [1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby ds » Fri Feb 23, 2007 9:53 pm

You will still need to download the WoW_IDs.php file. No point in pasting the contents of that file here.

I hope I didn't forget any replacements! :) I'm sure you'll let me know if I did. :twisted:
Last edited by ds on Fri Feb 23, 2007 9:55 pm, edited 1 time in total.
Image
ds
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 297
Joined: Sat Jul 08, 2006 9:58 am

Re: [1.7.3] Roster Mod for Enchantment coloring and Sockets

Postby ds » Tue Feb 27, 2007 3:20 am

Updated this MOD to version v1.3; download the files here: http://www.wowroster.net/Forums/viewtop ... html#16149

This is a fix for version 1.2 of the mod. Fixes all known issues and should be the final version of this MOD.

[ADDED] An option to show Icons to the left of the tooltip. This looks great if you use 64px Icons!
[ADDED] Many more Gems and Enchantments
[Fixed] Empty sockets showing on one line.
[Fixed] Missed matching on Gem Texts with spaces at the end.

This version has been reported DF Safe (It's OK to replace your files with these) but you need move/extract the Icons to: %root Dragonfly dir%/images/wowrosterdf/Interface/ItemSocketingFrame
Attachments
dstooltip_ss_1.jpg
Screen Shot of v1.3
dstooltip_ss_1.jpg (80.2 KiB) Viewed 1165 times
Image
ds
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 297
Joined: Sat Jul 08, 2006 9:58 am

[1.7.3] Roster Tooltip Mod for Gems and Enchants (v1.3)

Postby Diska » Wed Feb 28, 2007 10:34 am

Hey DS,

Your mod seems to break some items. Take a look at: http://www.unbridled.eu/roster/char.php ... er=Arathor
The chest, legs, cloak and boots do not display any stats. If I remove your mod all stats do show up.
Now I showed you this same character before and you said the item id's were not passed. I looked the items up in the database and you're completely right, no item id's are registered for these items. I'll ask this person to purge his CP data and reupload to fix this, but in the meanwhile you might want to look if there's a way the item display won't break if there's no ID.
User avatar
Diska
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 179
Joined: Tue Jul 04, 2006 2:05 pm

Previous

Return to Gem Sockets and Enchants (Roster Tooltip Mod)

Who is online

Users browsing this forum: No registered users and 0 guests

cron