mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Setup/Images
* fixed error, causing everything to be displayed as not dound if anything was missing * added readable output to source finding stage * should now be obvious if something is missing
This commit is contained in:
@@ -48,12 +48,15 @@ if (!CLI)
|
||||
$threshold = 95; // alpha threshold to define subZones: set it too low and you have unspawnable areas inside a zone; set it too high and the border regions overlap
|
||||
$runTime = ini_get('max_execution_time');
|
||||
$locStr = null;
|
||||
$dbcPath = CLISetup::$srcDir.'%sDBFilesClient/';
|
||||
$imgPath = CLISetup::$srcDir.'%sInterface/';
|
||||
$destDir = 'static/images/wow/';
|
||||
$success = true;
|
||||
$paths = ['WorldMap/', 'TalentFrame/', 'Glues/Credits/'];
|
||||
$modeMask = 0x7; // talentBGs, regular maps, spawn-related alphaMaps
|
||||
$paths = array(
|
||||
0x16 => ['WorldMap/', true, null],
|
||||
0x01 => ['TalentFrame/', false, null],
|
||||
0x08 => ['Glues/Credits/',false, null]
|
||||
);
|
||||
|
||||
$createAlphaImage = function($w, $h)
|
||||
{
|
||||
@@ -185,66 +188,93 @@ if (!CLI)
|
||||
imagedestroy($tmp);
|
||||
};
|
||||
|
||||
$checkSourceDirs = function($sub, &$missing = []) use ($imgPath, $dbcPath, $paths, &$modeMask)
|
||||
$checkSourceDirs = function($sub) use ($imgPath, &$paths, $modeMask)
|
||||
{
|
||||
$hasMissing = false;
|
||||
foreach ($paths as $idx => $subDir)
|
||||
foreach ($paths as $idx => list($subDir, $isLocalized, $realPath))
|
||||
{
|
||||
if ($idx == 0 && !($modeMask & 0x16)) // map related
|
||||
continue;
|
||||
else if ($idx == 1 && !($modeMask & 0x1)) // talentBGs
|
||||
continue;
|
||||
else if ($idx == 2 && !($modeMask & 0x8)) // artwork
|
||||
if ($realPath && !$isLocalized)
|
||||
continue;
|
||||
|
||||
$p = sprintf($imgPath, $sub).$subDir;
|
||||
if (!CLISetup::fileExists($p))
|
||||
if (CLISetup::fileExists($p))
|
||||
{
|
||||
if ($isLocalized)
|
||||
$paths[$idx][2][substr($sub, 0, -1)] = $p;
|
||||
else
|
||||
$paths[$idx][2] = $p;
|
||||
}
|
||||
else
|
||||
$hasMissing = true;
|
||||
$missing[] = $p;
|
||||
}
|
||||
}
|
||||
|
||||
if ($modeMask & 0x17)
|
||||
{
|
||||
$p = sprintf($dbcPath, $sub);
|
||||
if (!CLISetup::fileExists($p))
|
||||
{
|
||||
$hasMissing = true;
|
||||
$missing[] = $p;
|
||||
}
|
||||
}
|
||||
|
||||
return !$hasMissing;
|
||||
};
|
||||
|
||||
|
||||
// do not change order of params!
|
||||
if ($_ = FileGen::hasOpt('talentbgs', 'maps', 'spawn-maps', 'artwork', 'area-maps'))
|
||||
$modeMask = $_;
|
||||
|
||||
foreach ($paths as $mode => $__)
|
||||
if (!($mode & $modeMask))
|
||||
unset($paths[$mode]);
|
||||
|
||||
foreach (CLISetup::$expectedPaths as $xp => $__)
|
||||
{
|
||||
if (!in_array($locId, CLISetup::$localeIds))
|
||||
continue;
|
||||
|
||||
if ($xp) // if in subDir add trailing slash
|
||||
$xp .= '/';
|
||||
|
||||
if ($checkSourceDirs($xp, $missing))
|
||||
$checkSourceDirs($xp); // do not break; maps are localized
|
||||
}
|
||||
|
||||
$locList = [];
|
||||
foreach (CLISetup::$expectedPaths as $xp => $locId)
|
||||
if (in_array($locId, CLISetup::$localeIds))
|
||||
$locList[] = $xp;
|
||||
|
||||
CLISetup::log('required resources overview:', CLISetup::LOG_INFO);
|
||||
foreach ($paths as list($path, $isLocalized, $realPath))
|
||||
{
|
||||
$locStr = $xp;
|
||||
break;
|
||||
if (!$realPath)
|
||||
CLISetup::log(CLISetup::red('MISSING').' - '.str_pad($path, 14).' @ '.sprintf($imgPath, '['.implode(',', $locList).']/').$path);
|
||||
else if ($isLocalized)
|
||||
{
|
||||
$foundLoc = [];
|
||||
foreach (CLISetup::$localeIds as $locId)
|
||||
foreach (CLISetup::$expectedPaths as $xp => $lId)
|
||||
if ($locId == $lId && isset($realPath[$xp]) && !isset($foundLoc[$locId]))
|
||||
$foundLoc[$locId] = $xp;
|
||||
|
||||
if ($diff = array_diff(CLISetup::$localeIds, array_keys($foundLoc)))
|
||||
{
|
||||
$buff = [];
|
||||
foreach ($diff as $d)
|
||||
$buff[] = CLISetup::yellow(Util::$localeStrings[$d]);
|
||||
foreach ($foundLoc as $str)
|
||||
$buff[] = CLISetup::green($str);
|
||||
|
||||
CLISetup::log(CLISetup::yellow('PARTIAL').' - '.str_pad($path, 14).' @ '.sprintf($imgPath, '['.implode(',', $buff).']/').$path);
|
||||
}
|
||||
else
|
||||
CLISetup::log(CLISetup::green(' FOUND ').' - '.str_pad($path, 14).' @ '.sprintf($imgPath, '['.implode(',', $foundLoc).']/').$path);
|
||||
}
|
||||
else
|
||||
CLISetup::log(CLISetup::green(' FOUND ').' - '.str_pad($path, 14).' @ '.$realPath);
|
||||
}
|
||||
|
||||
CLISetup::log();
|
||||
|
||||
// if no subdir had sufficient data, diaf
|
||||
if ($locStr === null)
|
||||
if (count(array_filter(array_column($paths, 2))) != count($paths))
|
||||
{
|
||||
CLISetup::log('one or more required directories are missing:', CLISetup::LOG_ERROR);
|
||||
foreach ($missing as $m)
|
||||
CLISetup::log(' - '.$m, CLISetup::LOG_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
sleep(1);
|
||||
|
||||
/**************/
|
||||
/* TalentTabs */
|
||||
@@ -291,7 +321,7 @@ if (!CLI)
|
||||
continue;
|
||||
}
|
||||
|
||||
$im = $assembleImage(sprintf($imgPath, $locStr).'TalentFrame/'.$tt['textureFile'], $order, 256 + 44, 256 + 75);
|
||||
$im = $assembleImage($paths[0x1][2].'/'.$tt['textureFile'], $order, 256 + 44, 256 + 75);
|
||||
if (!$im)
|
||||
{
|
||||
CLISetup::log(' - could not assemble file '.$tt['textureFile'], CLISetup::LOG_ERROR);
|
||||
@@ -390,17 +420,13 @@ if (!CLI)
|
||||
$locDirs = array_reverse(array_filter(CLISetup::$expectedPaths, function($var) use ($l) { return !$var || $var == $l; }), true);
|
||||
foreach ($locDirs as $mapLoc => $__)
|
||||
{
|
||||
if ($mapLoc) // and trailing slash again
|
||||
$mapLoc .= '/';
|
||||
if(!isset($paths[0x16][2][$mapLoc]))
|
||||
continue;
|
||||
|
||||
$p = sprintf($imgPath, $mapLoc).$paths[0];
|
||||
if (CLISetup::fileExists($p))
|
||||
{
|
||||
CLISetup::log(' - using files from '.($mapLoc ?: '/').' for locale '.Util::$localeStrings[$l], CLISetup::LOG_INFO);
|
||||
$mapSrcDir = $p.'/';
|
||||
$mapSrcDir = $paths[0x16][2][$mapLoc].'/';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($mapSrcDir === null)
|
||||
{
|
||||
@@ -654,8 +680,7 @@ if (!CLI)
|
||||
);
|
||||
|
||||
$imgGroups = [];
|
||||
$srcPath = sprintf($imgPath, $locStr).'Glues/Credits/';
|
||||
$files = CLISetup::filesInPath($srcPath);
|
||||
$files = CLISetup::filesInPath('/'.str_replace('/', '\\/', $paths[0x8][2]).'/i', true);
|
||||
foreach ($files as $f)
|
||||
{
|
||||
if (preg_match('/([^\/]+)(\d).blp/i', $f, $m))
|
||||
@@ -699,7 +724,7 @@ if (!CLI)
|
||||
continue;
|
||||
}
|
||||
|
||||
$im = $assembleImage($srcPath.$file, $order[$fmt], count($order[$fmt][0]) * 256, count($order[$fmt]) * 256);
|
||||
$im = $assembleImage($paths[0x8][2].'/'.$file, $order[$fmt], count($order[$fmt][0]) * 256, count($order[$fmt]) * 256);
|
||||
if (!$im)
|
||||
{
|
||||
CLISetup::log(' - could not assemble file '.$name, CLISetup::LOG_ERROR);
|
||||
|
||||
@@ -53,9 +53,7 @@ if (!CLI)
|
||||
return true;
|
||||
}
|
||||
|
||||
$locStr = null;
|
||||
$groups = [];
|
||||
$dbcPath = CLISetup::$srcDir.'%sDBFilesClient/';
|
||||
$imgPath = CLISetup::$srcDir.'%sInterface/';
|
||||
$destDir = 'static/images/wow/';
|
||||
$success = true;
|
||||
@@ -77,19 +75,19 @@ if (!CLI)
|
||||
['loadingscreens/original/', '.png', 0, 0, 0],
|
||||
['loadingscreens/small/', '.jpg', 0, 244, 0]
|
||||
);
|
||||
$paths = array( // src, [dest, ext, srcSize, destSize, borderOffset], pattern, isIcon, tileSize
|
||||
0 => ['Icons/', $iconDirs, '/*.[bB][lL][pP]', true, 0],
|
||||
1 => ['Spellbook/', [['Interface/Spellbook/', '.png', 0, 0, 0]], '/UI-Glyph-Rune*.blp', true, 0],
|
||||
2 => ['PaperDoll/', array_slice($iconDirs, 0, 3), '/UI-{Backpack,PaperDoll}-*.blp', true, 0],
|
||||
3 => ['GLUES/CHARACTERCREATE/UI-CharacterCreate-Races.blp', $iconDirs, '', true, 64],
|
||||
4 => ['GLUES/CHARACTERCREATE/UI-CharacterCreate-CLASSES.blp', $iconDirs, '', true, 64],
|
||||
5 => ['GLUES/CHARACTERCREATE/UI-CharacterCreate-Factions.blp', $iconDirs, '', true, 64],
|
||||
// 6 => ['Minimap/OBJECTICONS.BLP', [['icons/tiny/', '.gif', 0, 16, 2]], '', true, 32],
|
||||
7 => ['FlavorImages/', [['Interface/FlavorImages/', '.png', 0, 0, 0]], '/*.[bB][lL][pP]', false, 0],
|
||||
8 => ['Pictures/', [['Interface/Pictures/', '.png', 0, 0, 0]], '/*.[bB][lL][pP]', false, 0],
|
||||
9 => ['PvPRankBadges/', [['Interface/PvPRankBadges/', '.png', 0, 0, 0]], '/*.[bB][lL][pP]', false, 0],
|
||||
10 => ['Calendar/Holidays/', $calendarDirs, '/*{rt,a,y,h,s}.[bB][lL][pP]', true, 0],
|
||||
11 => ['GLUES/LOADINGSCREENS/', $loadScreenDirs, '/[lL][oO]*.[bB][lL][pP]', false, 0]
|
||||
$paths = array( // src, [dest, ext, srcSize, destSize, borderOffset], pattern, isIcon, tileSize, resourcePath
|
||||
0 => ['Icons/', $iconDirs, '/.*\.blp$', true, 0, null],
|
||||
1 => ['Spellbook/', [['Interface/Spellbook/', '.png', 0, 0, 0]], '/UI-Glyph-Rune-?\d+.blp$', true, 0, null],
|
||||
2 => ['PaperDoll/', array_slice($iconDirs, 0, 3), '/UI-(Backpack|PaperDoll)-.*\.blp$', true, 0, null],
|
||||
3 => ['GLUES/CHARACTERCREATE/UI-CharacterCreate-Races.blp', $iconDirs, '', true, 64, null],
|
||||
4 => ['GLUES/CHARACTERCREATE/UI-CharacterCreate-CLASSES.blp', $iconDirs, '', true, 64, null],
|
||||
5 => ['GLUES/CHARACTERCREATE/UI-CharacterCreate-Factions.blp', $iconDirs, '', true, 64, null],
|
||||
// 6 => ['Minimap/OBJECTICONS.BLP', [['icons/tiny/', '.gif', 0, 16, 2]], '', true, 32, null],
|
||||
7 => ['FlavorImages/', [['Interface/FlavorImages/', '.png', 0, 0, 0]], '/.*\.blp$', false, 0, null],
|
||||
8 => ['Pictures/', [['Interface/Pictures/', '.png', 0, 0, 0]], '/.*\.blp$', false, 0, null],
|
||||
9 => ['PvPRankBadges/', [['Interface/PvPRankBadges/', '.png', 0, 0, 0]], '/.*\.blp$', false, 0, null],
|
||||
10 => ['Calendar/Holidays/', $calendarDirs, '/.*(start|[ayhs])\.blp$', true, 0, null],
|
||||
11 => ['GLUES/LOADINGSCREENS/', $loadScreenDirs, '/lo.*\.blp$', false, 0, null]
|
||||
);
|
||||
// textures are composed of 64x64 icons
|
||||
// numeric indexed arrays mimick the position on the texture
|
||||
@@ -192,24 +190,19 @@ if (!CLI)
|
||||
return $ok;
|
||||
};
|
||||
|
||||
$checkSourceDirs = function($sub, &$missing = []) use ($imgPath, $dbcPath, $paths)
|
||||
$checkSourceDirs = function($sub) use ($imgPath, &$paths)
|
||||
{
|
||||
$hasMissing = false;
|
||||
foreach (array_column($paths, 0) as $subDir)
|
||||
foreach ($paths as $pathIdx => list($subDir, , , , , $realPath))
|
||||
{
|
||||
$p = sprintf($imgPath, $sub).$subDir;
|
||||
if (!CLISetup::fileExists($p))
|
||||
{
|
||||
$hasMissing = true;
|
||||
$missing[] = $p;
|
||||
}
|
||||
}
|
||||
if ($realPath)
|
||||
continue;
|
||||
|
||||
$p = sprintf($dbcPath, $sub);
|
||||
if (!CLISetup::fileExists($p))
|
||||
{
|
||||
$p = sprintf($imgPath, $sub).$subDir;
|
||||
if (CLISetup::fileExists($p))
|
||||
$paths[$pathIdx][5] = $p;
|
||||
else
|
||||
$hasMissing = true;
|
||||
$missing[] = $p;
|
||||
}
|
||||
|
||||
return !$hasMissing;
|
||||
@@ -232,27 +225,42 @@ if (!CLI)
|
||||
if (!in_array($k, $groups))
|
||||
unset($paths[$k]);
|
||||
|
||||
foreach (CLISetup::$expectedPaths as $xp => $__)
|
||||
foreach (CLISetup::$expectedPaths as $xp => $locId)
|
||||
{
|
||||
if (!in_array($locId, CLISetup::$localeIds))
|
||||
continue;
|
||||
|
||||
if ($xp) // if in subDir add trailing slash
|
||||
$xp .= '/';
|
||||
|
||||
if ($checkSourceDirs($xp, $missing))
|
||||
{
|
||||
$locStr = $xp;
|
||||
if ($checkSourceDirs($xp))
|
||||
break;
|
||||
}
|
||||
|
||||
$locList = [];
|
||||
foreach (CLISetup::$expectedPaths as $xp => $locId)
|
||||
if (in_array($locId, CLISetup::$localeIds))
|
||||
$locList[] = $xp;
|
||||
|
||||
CLISetup::log('required resources overview:', CLISetup::LOG_INFO);
|
||||
foreach ($paths as list($path, , , , , $realPath))
|
||||
{
|
||||
if ($realPath)
|
||||
CLISetup::log(CLISetup::green(' FOUND ').' - '.str_pad($path, 53).' @ '.$realPath);
|
||||
else
|
||||
CLISetup::log(CLISetup::red('MISSING').' - '.str_pad($path, 53).' @ '.sprintf($imgPath, '['.implode(',', $locList).']/').$path);
|
||||
}
|
||||
|
||||
CLISetup::log();
|
||||
|
||||
// if no subdir had sufficient data, diaf
|
||||
if ($locStr === null)
|
||||
if (count(array_filter(array_column($paths, 5))) != count($paths))
|
||||
{
|
||||
CLISetup::log('one or more required directories are missing:', CLISetup::LOG_ERROR);
|
||||
foreach ($missing as $m)
|
||||
CLISetup::log(' - '.$m, CLISetup::LOG_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
sleep(1);
|
||||
|
||||
// init directories
|
||||
foreach (array_column($paths, 1) as $subDirs)
|
||||
@@ -276,31 +284,36 @@ if (!CLI)
|
||||
$siRows = DB::Aowow()->selectCol('SELECT iconPath FROM dbc_spellicon');
|
||||
|
||||
foreach ($siRows as $icon)
|
||||
$dbcEntries[] = strtolower(sprintf('setup/mpqdata/%s', $locStr).strtr($icon, ['\\' => '/']).'.blp');
|
||||
{
|
||||
if (stristr($icon, $paths[0][0])) // Icons/
|
||||
$dbcEntries[] = strtolower($paths[0][5].substr(strrchr($icon, '\\'), 1));
|
||||
else if (stristr($icon, $paths[1][0])) // Spellbook/
|
||||
$dbcEntries[] = strtolower($paths[1][5].substr(strrchr($icon, '\\'), 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($paths[0]))
|
||||
{
|
||||
$itemIcons = DB::Aowow()->selectCol('SELECT inventoryIcon1 FROM dbc_itemdisplayinfo WHERE inventoryIcon1 <> ""');
|
||||
foreach ($itemIcons as $icon)
|
||||
$dbcEntries[] = strtolower(sprintf($imgPath, $locStr).'Icons/'.$icon.'.blp');
|
||||
$dbcEntries[] = strtolower($paths[0][5].'/'.$icon.'.blp');
|
||||
|
||||
$eventIcons = DB::Aowow()->selectCol('SELECT textureString FROM dbc_holidays WHERE textureString <> ""');
|
||||
foreach ($eventIcons as $icon)
|
||||
$dbcEntries[] = strtolower(sprintf($imgPath, $locStr).'Calendar/Holidays/'.$icon.'Start.blp');
|
||||
$dbcEntries[] = strtolower($paths[10][5].'/'.$icon.'Start.blp');
|
||||
}
|
||||
|
||||
// case-insensitive array_unique *vomits silently into a corner*
|
||||
$dbcEntries = array_intersect_key($dbcEntries, array_unique($dbcEntries));
|
||||
|
||||
$allPaths = [];
|
||||
foreach ($paths as $i => list($inPath, $outInfo, $pattern, $isIcon, $tileSize))
|
||||
foreach ($paths as $i => list($inPath, $outInfo, $pattern, $isIcon, $tileSize, $path))
|
||||
{
|
||||
$path = sprintf($imgPath, $locStr).$inPath;
|
||||
if (!CLISetup::fileExists($path))
|
||||
continue;
|
||||
$search = $path.$pattern;
|
||||
if ($pattern)
|
||||
$search = '/'.str_replace('/', '\\/', $search).'/i';
|
||||
|
||||
$files = glob($path.$pattern, GLOB_BRACE);
|
||||
$files = CLISetup::filesInPath($search, !!$pattern);
|
||||
$allPaths = array_merge($allPaths, $files);
|
||||
|
||||
CLISetup::log('processing '.count($files).' files in '.$path.'...');
|
||||
|
||||
Reference in New Issue
Block a user