Gear-Planer Guide: [[Item:Name]] bzw. [[Fluegel:Name]] (oder die aion2hub-ID) zeigt einen Gegenstand mit Bild, Name in der Farbe der Seltenheit und Info-Blase; nachgeschlagen bei aion2hub beim Speichern des Guides
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
70bc1aa4f7
commit
4fdae3f244
4 changed files with 156 additions and 1 deletions
|
|
@ -6800,6 +6800,13 @@ button.gear-guide-skill:hover { border-color: var(--gold); transform: translateY
|
||||||
.gear-guide-skill-chip:hover, .gear-guide-skill-chip:focus-visible { outline: none; text-decoration: underline; text-decoration-color: rgba(227, 189, 110, 0.55); text-underline-offset: 3px; }
|
.gear-guide-skill-chip:hover, .gear-guide-skill-chip:focus-visible { outline: none; text-decoration: underline; text-decoration-color: rgba(227, 189, 110, 0.55); text-underline-offset: 3px; }
|
||||||
.gear-guide-skill-chip.is-stigma { color: #c9adf5; }
|
.gear-guide-skill-chip.is-stigma { color: #c9adf5; }
|
||||||
.gear-guide-skill-chip.is-stigma img { box-shadow: 0 0 0 1px rgba(160, 120, 230, 0.6); }
|
.gear-guide-skill-chip.is-stigma img { box-shadow: 0 0 0 1px rgba(160, 120, 230, 0.6); }
|
||||||
|
/* [[Item:...]] / [[Flügel:...]]: Bild und Name in der Farbe der Seltenheit, Info-Blase wie im Lagerhaus */
|
||||||
|
.gear-guide-item-chip { display: inline; color: var(--grade, #e3bd6e); font-weight: 600; white-space: nowrap; cursor: help; }
|
||||||
|
.gear-guide-item-chip img { width: 1.3em; height: 1.3em; margin-right: 0.25em; border-radius: 3px; object-fit: contain; vertical-align: -0.28em; background: #10131a; box-shadow: 0 0 0 1px color-mix(in srgb, var(--grade, #c9a227) 60%, transparent); }
|
||||||
|
.gear-guide-item-chip:hover, .gear-guide-item-chip:focus-visible { outline: none; text-decoration: underline; text-underline-offset: 3px; }
|
||||||
|
.gear-guide-item-chip.is-missing { color: var(--text-muted); font-weight: 400; text-decoration: underline dotted; cursor: default; }
|
||||||
|
.gear-tip .item-tip-head { margin-bottom: 0.2rem; }
|
||||||
|
.gear-guide-item-tip-icon { flex-shrink: 0; border-radius: 8px; background: #10131a; }
|
||||||
/* [[Skillname:2]]: Symbol der Spezialisierung und ihr Text; beim Drueberfahren die Skill-Info mit hervorgehobener Zeile */
|
/* [[Skillname:2]]: Symbol der Spezialisierung und ihr Text; beim Drueberfahren die Skill-Info mit hervorgehobener Zeile */
|
||||||
.gear-guide-spec-ref { display: inline; color: #e8dcc0; font-weight: 600; cursor: help; text-decoration: underline dotted rgba(227, 189, 110, 0.55); text-underline-offset: 3px; }
|
.gear-guide-spec-ref { display: inline; color: #e8dcc0; font-weight: 600; cursor: help; text-decoration: underline dotted rgba(227, 189, 110, 0.55); text-underline-offset: 3px; }
|
||||||
.gear-guide-spec-ref:hover, .gear-guide-spec-ref:focus-visible { outline: none; color: #f1d98a; text-decoration-style: solid; }
|
.gear-guide-spec-ref:hover, .gear-guide-spec-ref:focus-visible { outline: none; color: #f1d98a; text-decoration-style: solid; }
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,22 @@ $setCount = static function () use ($pdo, $userId): int {
|
||||||
return (int) $count->fetchColumn();
|
return (int) $count->fetchColumn();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Guide-Texte: [[Item:...]] bei aion2hub nachschlagen (includes/gear_guide.php) und Bescheid geben, was es nicht gibt
|
||||||
|
$itemNote = static function (string $text): void {
|
||||||
|
if (!preg_match(gear_guide_item_pattern(), $text)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
session_write_close(); // ein Abruf bei aion2hub dauert - andere Seiten sollen nicht warten
|
||||||
|
$result = gear_guide_items_lookup($text);
|
||||||
|
@session_start();
|
||||||
|
if ($result['missing']) {
|
||||||
|
set_flash('info', 'Bei aion2hub nicht gefunden: ' . implode(', ', $result['missing']) . ' – schreib den Namen bzw. die ID wie dort (englisch).');
|
||||||
|
}
|
||||||
|
if ($result['later']) {
|
||||||
|
set_flash('info', 'Noch nicht nachgeschlagen (aion2hub-Tempolimit): ' . implode(', ', $result['later']) . ' – speichere den Guide gleich noch einmal.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'create':
|
case 'create':
|
||||||
$name = $cleanName((string) ($_POST['name'] ?? ''));
|
$name = $cleanName((string) ($_POST['name'] ?? ''));
|
||||||
|
|
@ -677,6 +693,8 @@ switch ($action) {
|
||||||
$pdo->prepare('UPDATE gear_sets SET description = ?, guide = ?, updated_at = NOW() WHERE id = ?')
|
$pdo->prepare('UPDATE gear_sets SET description = ?, guide = ?, updated_at = NOW() WHERE id = ?')
|
||||||
->execute([$description !== '' ? $description : null, gear_guide_json($guide), $set['id']]);
|
->execute([$description !== '' ? $description : null, gear_guide_json($guide), $set['id']]);
|
||||||
set_flash('success', 'Guide gespeichert.');
|
set_flash('success', 'Guide gespeichert.');
|
||||||
|
$itemNote($description . "
|
||||||
|
" . (string) gear_guide_json($guide));
|
||||||
redirect($back);
|
redirect($back);
|
||||||
|
|
||||||
case 'save_guide_notes':
|
case 'save_guide_notes':
|
||||||
|
|
@ -693,6 +711,7 @@ switch ($action) {
|
||||||
]));
|
]));
|
||||||
$pdo->prepare('UPDATE gear_sets SET guide = ?, updated_at = NOW() WHERE id = ?')->execute([gear_guide_json($guide), $set['id']]);
|
$pdo->prepare('UPDATE gear_sets SET guide = ?, updated_at = NOW() WHERE id = ?')->execute([gear_guide_json($guide), $set['id']]);
|
||||||
set_flash('success', 'Erklärungen gespeichert.');
|
set_flash('success', 'Erklärungen gespeichert.');
|
||||||
|
$itemNote((string) gear_guide_json($guide));
|
||||||
redirect('/gear.php?set=' . (int) $set['id'] . '&tab=guide');
|
redirect('/gear.php?set=' . (int) $set['id'] . '&tab=guide');
|
||||||
|
|
||||||
case 'save_guide_stats':
|
case 'save_guide_stats':
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ const GEAR_GUIDE_STAT_GROUPS = [
|
||||||
const GEAR_GUIDE_SLOT_GROUPS = ['Waffen' => 'weapon', 'Rüstung' => 'armor', 'Schmuck' => 'jewelry'];
|
const GEAR_GUIDE_SLOT_GROUPS = ['Waffen' => 'weapon', 'Rüstung' => 'armor', 'Schmuck' => 'jewelry'];
|
||||||
const GEAR_GUIDE_STATS_MAX = 6; // Werte je Gruppe
|
const GEAR_GUIDE_STATS_MAX = 6; // Werte je Gruppe
|
||||||
const GEAR_GUIDE_STAT_LENGTH = 40;
|
const GEAR_GUIDE_STAT_LENGTH = 40;
|
||||||
|
// Gegenstaende in Guide-Texten: [[Item:Name]] bzw. [[Item:ID]] (Name/ID wie bei aion2hub), auch mit "Flügel:" -
|
||||||
|
// beim Speichern nachgeschlagen (hoechstens so viele neue je Speichern, aion2hub hat ein Tempolimit)
|
||||||
|
const GEAR_GUIDE_ITEM_PREFIXES = ['item', 'gegenstand', 'flügel', 'fluegel', 'wings', 'wing'];
|
||||||
|
const GEAR_GUIDE_ITEM_LOOKUPS = 8;
|
||||||
const GEAR_GUIDE_STAT_NOTE_LENGTH = 80;
|
const GEAR_GUIDE_STAT_NOTE_LENGTH = 80;
|
||||||
|
|
||||||
/** Einzeiliger Text: Leerraum zusammengefasst und gekuerzt. */
|
/** Einzeiliger Text: Leerraum zusammengefasst und gekuerzt. */
|
||||||
|
|
@ -323,6 +327,119 @@ function gear_guide_spec_chip(array $skill, int $no): ?string
|
||||||
. $icon . '<span class="gear-guide-spec-ref-text">' . e($part['text']) . '</span></span>';
|
. $icon . '<span class="gear-guide-spec-ref-text">' . e($part['text']) . '</span></span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Muster fuer [[Item:Name]] / [[Flügel:ID]] - Gruppe 1: Name oder ID (im Rohtext wie im maskierten HTML). */
|
||||||
|
function gear_guide_item_pattern(): string
|
||||||
|
{
|
||||||
|
return '/\[\[\s*(?:' . implode('|', array_map(static fn (string $p): string => preg_quote($p, '/'), GEAR_GUIDE_ITEM_PREFIXES)) . ')\s*:\s*([^\[\]<>]{1,150}?)\s*\]\]/iu';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gegenstands-Verweise in einem Text (Namen bzw. IDs, ohne Doppelte). */
|
||||||
|
function gear_guide_item_refs(string $text): array
|
||||||
|
{
|
||||||
|
preg_match_all(gear_guide_item_pattern(), $text, $m);
|
||||||
|
$refs = [];
|
||||||
|
foreach ($m[1] as $ref) {
|
||||||
|
$refs[mb_strtolower(trim($ref))] = trim($ref);
|
||||||
|
}
|
||||||
|
return array_values($refs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Schon nachgeschlagener Gegenstand zu einem Verweis (ID oder Name wie bei aion2hub) - null = (noch) unbekannt. */
|
||||||
|
function gear_guide_item_cached(string $ref): ?array
|
||||||
|
{
|
||||||
|
require_once __DIR__ . '/item_db.php';
|
||||||
|
if (ctype_digit($ref)) {
|
||||||
|
return item_db_get((int) $ref);
|
||||||
|
}
|
||||||
|
$stmt = db()->prepare('SELECT item_id FROM item_db_names WHERE name = ? AND item_id IS NOT NULL');
|
||||||
|
$stmt->execute([$ref]);
|
||||||
|
$id = $stmt->fetchColumn();
|
||||||
|
return $id !== false ? item_db_get((int) $id) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gegenstaende eines Guides bei aion2hub nachschlagen (beim Speichern): Daten in item_db, Bild unter
|
||||||
|
* assets/uploads/gear. Schon bekannte zaehlen nicht mit. Liefert die Verweise, die es nicht gibt bzw. die
|
||||||
|
* diesmal nicht drankamen (Tempolimit) - fuer den Hinweis nach dem Speichern.
|
||||||
|
*
|
||||||
|
* @return array{missing: string[], later: string[]}
|
||||||
|
*/
|
||||||
|
function gear_guide_items_lookup(string $text): array
|
||||||
|
{
|
||||||
|
require_once __DIR__ . '/item_db.php';
|
||||||
|
$result = ['missing' => [], 'later' => []];
|
||||||
|
$fetched = 0;
|
||||||
|
foreach (gear_guide_item_refs($text) as $ref) {
|
||||||
|
$item = gear_guide_item_cached($ref);
|
||||||
|
if ($item === null) {
|
||||||
|
if ($fetched >= GEAR_GUIDE_ITEM_LOOKUPS) {
|
||||||
|
$result['later'][] = $ref;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$fetched++;
|
||||||
|
if (ctype_digit($ref)) {
|
||||||
|
try {
|
||||||
|
$item = item_db_parse(item_db_fetch(GEAR_SOURCE_ITEM_URL . (int) $ref), (int) $ref);
|
||||||
|
item_db_store($item);
|
||||||
|
} catch (ItemDbBusyException $e) {
|
||||||
|
$result['later'][] = $ref;
|
||||||
|
continue;
|
||||||
|
} catch (RuntimeException $e) {
|
||||||
|
$item = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$found = item_db_lookup($ref);
|
||||||
|
$item = $found['status'] === 'ok' ? $found['item'] : null;
|
||||||
|
if ($found['status'] === 'busy') {
|
||||||
|
$result['later'][] = $ref;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($item === null) {
|
||||||
|
$result['missing'][] = $ref;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gear_guide_item_icon_url((int) $item['id']) === null) {
|
||||||
|
gear_icon_download((int) $item['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Bild eines Gegenstands (assets/uploads/gear/<ID>.*), null = nicht geladen. */
|
||||||
|
function gear_guide_item_icon_url(int $id): ?string
|
||||||
|
{
|
||||||
|
foreach (['png', 'webp', 'jpg', 'gif'] as $ext) {
|
||||||
|
$file = GEAR_ICON_DIR . $id . '.' . $ext;
|
||||||
|
if (is_file($file)) {
|
||||||
|
return GEAR_ICON_URL . $id . '.' . $ext . '?v=' . filemtime($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [[Item:...]] im Text: Bild und Name in der Farbe der Seltenheit, beim Drueberfahren die Info-Blase wie im Lagerhaus
|
||||||
|
* (Werte, Effekte, Infos von aion2hub; assets/js/gear.js). Unbekannt: nur der Name, gedaempft.
|
||||||
|
*/
|
||||||
|
function gear_guide_item_chip(string $ref): string
|
||||||
|
{
|
||||||
|
require_once __DIR__ . '/item_db.php';
|
||||||
|
$item = gear_guide_item_cached($ref);
|
||||||
|
if ($item === null) {
|
||||||
|
return '<span class="gear-guide-item-chip is-missing" title="Bei aion2hub (noch) nicht gefunden – Name bzw. ID wie dort schreiben, dann den Guide speichern">' . e($ref) . '</span>';
|
||||||
|
}
|
||||||
|
$grade = strtolower((string) $item['grade']);
|
||||||
|
$icon = gear_guide_item_icon_url((int) $item['id']);
|
||||||
|
$iconHtml = $icon !== null ? '<img src="' . e($icon) . '" alt="" width="56" height="56" class="gear-guide-item-tip-icon">' : '';
|
||||||
|
return '<span class="gear-guide-item-chip' . (in_array($grade, ITEM_DB_GRADES, true) ? ' grade-' . e($grade) : '') . '" data-skill data-skill-tip tabindex="0">'
|
||||||
|
. ($icon !== null ? '<img src="' . e($icon) . '" alt="" loading="lazy">' : '')
|
||||||
|
. e((string) $item['name'])
|
||||||
|
// <template>: der Inhalt (mit <div>s) darf so mitten im Absatz stehen, ohne ihn aufzubrechen
|
||||||
|
. '<template class="gear-tip-src">' . item_db_tip_html($item, $iconHtml) . '</template></span>';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schon maskiertes HTML: [[Skillname]] durch Skill-Chips ersetzen, [[Skillname:2]] bzw. [[Skillname:II]] durch die
|
* Schon maskiertes HTML: [[Skillname]] durch Skill-Chips ersetzen, [[Skillname:2]] bzw. [[Skillname:II]] durch die
|
||||||
* Spezialisierung (Stigmen: den Bonus) mit dieser Nummer. Unbekannte Namen bleiben als Text (ohne Klammern), eine
|
* Spezialisierung (Stigmen: den Bonus) mit dieser Nummer. Unbekannte Namen bleiben als Text (ohne Klammern), eine
|
||||||
|
|
@ -333,6 +450,8 @@ function gear_guide_chips(string $html, ?string $className): string
|
||||||
if (!str_contains($html, '[[')) {
|
if (!str_contains($html, '[[')) {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
$html = (string) preg_replace_callback(gear_guide_item_pattern(), static fn (array $match): string =>
|
||||||
|
gear_guide_item_chip(html_entity_decode($match[1], ENT_QUOTES | ENT_HTML5, 'UTF-8')), $html);
|
||||||
$skills = gear_guide_chip_skills($className);
|
$skills = gear_guide_chip_skills($className);
|
||||||
$romans = array_flip(array_map('strtoupper', GEAR_SKILL_SPEC_NUMERALS));
|
$romans = array_flip(array_map('strtoupper', GEAR_SKILL_SPEC_NUMERALS));
|
||||||
return (string) preg_replace_callback('/\[\[([^\[\]<>:]{1,80})(?::\s*([1-9]|[IVX]{1,4})\s*)?\]\]/iu', static function (array $match) use ($skills, $romans): string {
|
return (string) preg_replace_callback('/\[\[([^\[\]<>:]{1,80})(?::\s*([1-9]|[IVX]{1,4})\s*)?\]\]/iu', static function (array $match) use ($skills, $romans): string {
|
||||||
|
|
@ -1284,7 +1403,8 @@ function gear_render_guide_tab(array $set, bool $isOwn, array $slots, array $pla
|
||||||
</div>
|
</div>
|
||||||
<?php $hintSkill = $planned ? gear_skill_display_name(reset($planned)['skill']) : ''; ?>
|
<?php $hintSkill = $planned ? gear_skill_display_name(reset($planned)['skill']) : ''; ?>
|
||||||
<p class="field-hint gear-guide-chip-hint">Tipp: <code>[[Skillname]]</code> in Beschreibung, Begründungen, Tasten und Tipps wird zu einem Skill-Chip mit Icon<?= $hintSkill !== '' ? ', z.B. <code>[[' . e($hintSkill) . ']]</code>' : '' ?>.
|
<p class="field-hint gear-guide-chip-hint">Tipp: <code>[[Skillname]]</code> in Beschreibung, Begründungen, Tasten und Tipps wird zu einem Skill-Chip mit Icon<?= $hintSkill !== '' ? ', z.B. <code>[[' . e($hintSkill) . ']]</code>' : '' ?>.
|
||||||
Mit Nummer zeigt er eine Spezialisierung bzw. bei Stigmen einen Bonus: <code>[[<?= e($hintSkill !== '' ? $hintSkill : 'Skillname') ?>:1]]</code> für die erste (auch <code>:II</code> usw.).</p>
|
Mit Nummer zeigt er eine Spezialisierung bzw. bei Stigmen einen Bonus: <code>[[<?= e($hintSkill !== '' ? $hintSkill : 'Skillname') ?>:1]]</code> für die erste (auch <code>:II</code> usw.).
|
||||||
|
Gegenstände wie Flügel: <code>[[Item:Ancient Aullaeu Wings]]</code> oder <code>[[Flügel:…]]</code> – Name bzw. ID wie bei aion2hub (englisch), mit Bild und Info beim Drüberfahren.</p>
|
||||||
<label>Beschreibung <span class="text-muted">(Absätze mit einer Leerzeile)</span>
|
<label>Beschreibung <span class="text-muted">(Absätze mit einer Leerzeile)</span>
|
||||||
<textarea name="description" rows="6" maxlength="<?= GEAR_DESCRIPTION_MAX ?>" placeholder="Wofür ist der Build gedacht, wie spielt er sich, warum diese Skills und Stigmen …"><?= e($description) ?></textarea>
|
<textarea name="description" rows="6" maxlength="<?= GEAR_DESCRIPTION_MAX ?>" placeholder="Wofür ist der Build gedacht, wie spielt er sich, warum diese Skills und Stigmen …"><?= e($description) ?></textarea>
|
||||||
</label>
|
</label>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,15 @@ const PATCHNOTE_TYPES = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const PATCHNOTES = [
|
const PATCHNOTES = [
|
||||||
|
[
|
||||||
|
'id' => '2026-10-18-h',
|
||||||
|
'date' => '2026-10-18',
|
||||||
|
'title' => 'Gegenstände und Flügel in Guide-Texten',
|
||||||
|
'summary' => 'Mit [[Item:Name]] bzw. [[Flügel:Name]] zeigt ein Guide-Text einen Gegenstand mit Bild und Info.',
|
||||||
|
'changes' => [
|
||||||
|
['type' => 'neu', 'area' => 'Gear-Planer', 'text' => 'In allen Guide-Texten zeigt [[Item:Name]] (auch [[Flügel:Name]] oder die ID statt des Namens) einen Gegenstand aus der Datenbank von aion2hub – z. B. Flügel als Tipp. Im Text stehen Bild und Name in der Farbe der Seltenheit, beim Drüberfahren alle Infos. Name bzw. ID so schreiben wie bei aion2hub (englisch); beim Speichern wird nachgeschlagen, was es nicht gibt, steht im Hinweis.'],
|
||||||
|
],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'id' => '2026-10-18-g',
|
'id' => '2026-10-18-g',
|
||||||
'date' => '2026-10-18',
|
'date' => '2026-10-18',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue