Skip to content

Commit

Permalink
Add more details to quest stage information in test.html view
Browse files Browse the repository at this point in the history
  • Loading branch information
valarnin committed May 14, 2022
1 parent 91c3e34 commit 80d2c81
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oblivion-save-reader",
"version": "1.2",
"version": "1.3",
"description": "Library to read ES4:Oblivion save files",
"main": "test.js",
"scripts": {
Expand Down
29 changes: 27 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,53 @@ const rebuildQuestsTable = (saveFile = undefined) => {

for (const quest of window.oblivionSaveFile.SaveFile.constants.quests) {
let status = '✖';
let haveStages = [];
let completedStatus = false;
if (saveFile) {

let record = saveFile.records.find((e) => e.formId === quest.formId);
if (record) {
record.subRecord.stage.filter((stage) => stage.flag & 0x1).forEach((stage) => {
haveStages.push({index: stage.index, completion: quest.stages.includes(stage.index)});
});
for (const stage of record.subRecord.stage) {
if (quest.stages.includes(stage.index) && stage.flag&0x1) {
status = '✔';
++completed;
fame += quest.fame;
completedStatus = true;
break;
}
}
}
}
for (const stage of quest.stages) {
if (haveStages.find((s2) => s2.index === stage) === undefined)
haveStages.push({index: stage});
}

haveStages = haveStages.sort((l, r) => l.index - r.index);

let stagesStr = '';

for (const stage of haveStages) {
if (stage.completion)
stagesStr += `<strong style='color:green'>${stage.index}</strong><br>`;
else if (stage.completion === undefined)
stagesStr += `<strong style='color:${completedStatus ? 'yellow' : 'red'}'>${stage.index}</strong><br>`;
else
stagesStr += `${stage.index}<br>`;
}

let qTr = document.createElement('tr');
if (completedStatus === true && haveStages.length <= 1)
qTr.style.backgroundColor = 'lightyellow';

qTr.innerHTML = `
<td class='status ${status}'>${status}</td>
<td class='id'>${quest.id}</td>
<td class='formId'>${('0000000'+quest.formId.toString(16)).substr(-8)}</td>
<td class='name'>${quest.name}</td>
<td class='stages'>${quest.stages.join('<br>')}</td>
<td class='stages'>${stagesStr}</td>
<td class='fame'>${quest.fame}</td>
<td class='url'><a href="${quest.url}">UESP</a></td>
`;
Expand Down

0 comments on commit 80d2c81

Please sign in to comment.