|
| 1 | +$file = 'x:\dev\devnull\docs\FCOM_AgielColorCodedLoadOrder.html' |
| 2 | +$lines = Get-Content $file |
| 3 | + |
| 4 | +$inTableBody = $false |
| 5 | +$output = @() |
| 6 | +$currentEntry = @() |
| 7 | + |
| 8 | +for ($i = 0; $i -lt $lines.Count; $i++) { |
| 9 | + $line = $lines[$i] |
| 10 | + |
| 11 | + if ($line -match '<tbody>') { |
| 12 | + $inTableBody = $true |
| 13 | + } |
| 14 | + elseif ($line -match '</tbody>') { |
| 15 | + $inTableBody = $false |
| 16 | + } |
| 17 | + |
| 18 | + # Check if this is a row start |
| 19 | + if ($inTableBody -and $line -match '^ <tr>$') { |
| 20 | + # Collect the entire entry |
| 21 | + $currentEntry = @($line) |
| 22 | + $j = $i + 1 |
| 23 | + |
| 24 | + # Read until we find the closing </tr> |
| 25 | + while ($j -lt $lines.Count -and $lines[$j] -notmatch '</tr>') { |
| 26 | + $currentEntry += $lines[$j] |
| 27 | + $j++ |
| 28 | + } |
| 29 | + if ($j -lt $lines.Count) { |
| 30 | + $currentEntry += $lines[$j] # Add closing </tr> |
| 31 | + } |
| 32 | + |
| 33 | + # Join to analyze |
| 34 | + $entryText = $currentEntry -join "`n" |
| 35 | + |
| 36 | + # Determine color class |
| 37 | + $colorClass = "" |
| 38 | + |
| 39 | + # Check category |
| 40 | + if ($entryText -match '<td class="category">Gameplay</td>') { |
| 41 | + $colorClass = "row-gameplay" |
| 42 | + } |
| 43 | + elseif ($entryText -match '<td class="category">Spells</td>') { |
| 44 | + $colorClass = "row-gameplay" |
| 45 | + } |
| 46 | + elseif ($entryText -match '<td class="category">NPC</td>') { |
| 47 | + $colorClass = "row-gameplay" |
| 48 | + } |
| 49 | + elseif ($entryText -match '<td class="category">Textures</td>') { |
| 50 | + $colorClass = "row-aesthetic" |
| 51 | + } |
| 52 | + elseif ($entryText -match '<td class="category">Scenery</td>') { |
| 53 | + $colorClass = "row-aesthetic" |
| 54 | + } |
| 55 | + elseif ($entryText -match '<td class="category">Water</td>') { |
| 56 | + $colorClass = "row-aesthetic" |
| 57 | + } |
| 58 | + elseif ($entryText -match '<td class="category">Lights</td>') { |
| 59 | + $colorClass = "row-aesthetic" |
| 60 | + } |
| 61 | + elseif ($entryText -match '<td class="category">Mesh replacement</td>') { |
| 62 | + $colorClass = "row-aesthetic" |
| 63 | + } |
| 64 | + elseif ($entryText -match '<td class="category">Sounds</td>') { |
| 65 | + $colorClass = "row-aesthetic" |
| 66 | + } |
| 67 | + elseif ($entryText -match '<td class="category">Official Plugin</td>') { |
| 68 | + $colorClass = "row-official" |
| 69 | + } |
| 70 | + elseif ($entryText -match '<td class="category">Official plugin</td>') { |
| 71 | + $colorClass = "row-official" |
| 72 | + } |
| 73 | + elseif ($entryText -match '<td class="category">Patch</td>') { |
| 74 | + $colorClass = "row-patch" |
| 75 | + } |
| 76 | + elseif ($entryText -match '<td class="category">Quest</td>') { |
| 77 | + $colorClass = "row-new-content" |
| 78 | + } |
| 79 | + elseif ($entryText -match '<td class="category">House</td>') { |
| 80 | + $colorClass = "row-new-content" |
| 81 | + } |
| 82 | + elseif ($entryText -match '<td class="category">Armor Weapons</td>') { |
| 83 | + $colorClass = "row-new-content" |
| 84 | + } |
| 85 | + elseif ($entryText -match '<td class="category">Performance</td>') { |
| 86 | + $colorClass = "row-patch" |
| 87 | + } |
| 88 | + elseif ($entryText -match '<td class="category">Player Character</td>') { |
| 89 | + $colorClass = "row-aesthetic" |
| 90 | + } |
| 91 | + elseif ($entryText -match '<td class="category"></td>' -or $entryText -match '<td class="category">Core</td>') { |
| 92 | + # Empty category or Core - determine by mod name/group |
| 93 | + if ($entryText -match 'Unique Landscapes' -or $entryText -match 'Better Cities' -or $entryText -match 'Fellan Cities') { |
| 94 | + $colorClass = "row-aesthetic" |
| 95 | + } |
| 96 | + elseif ($entryText -match 'Supreme Magicka' -or $entryText -match 'MMM') { |
| 97 | + $colorClass = "row-gameplay" |
| 98 | + } |
| 99 | + else { |
| 100 | + $colorClass = "row-gameplay" # Default for empty |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + # Check for conflicts - add severe class |
| 105 | + if ($entryText -match 'Customized' -or $entryText -match 'Serious conflicts' -or $entryText -match 'Several .* conflicts') { |
| 106 | + if ($colorClass) { |
| 107 | + $colorClass += " row-conflict-severe" |
| 108 | + } else { |
| 109 | + $colorClass = "row-conflict-severe" |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + # Apply color class |
| 114 | + if ($colorClass) { |
| 115 | + $currentEntry[0] = " <tr class=`"$colorClass`">" |
| 116 | + } |
| 117 | + |
| 118 | + # Add to output |
| 119 | + $output += $currentEntry |
| 120 | + |
| 121 | + # Skip ahead |
| 122 | + $i = $j |
| 123 | + } |
| 124 | + else { |
| 125 | + $output += $line |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +# Write output |
| 130 | +$output | Set-Content $file |
| 131 | + |
| 132 | +Write-Host "Color coding complete!" |
0 commit comments