Skip to content

Commit

Permalink
viewer: add interval support
Browse files Browse the repository at this point in the history
  • Loading branch information
SnosMe committed Dec 28, 2024
1 parent 45c1bf3 commit 5728f34
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 40 deletions.
4 changes: 2 additions & 2 deletions viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"expiry-map": "^2.0.0",
"file-saver": "^2.0.2",
"idb": "^7.0.0",
"pathofexile-dat": "^12.0.0",
"pathofexile-dat-schema": "^7.0.0",
"pathofexile-dat": "^13.0.0",
"pathofexile-dat-schema": "^8.0.0",
"string-metric": "^0.3.3",
"tailwindcss": "^3.0.0",
"vue": "^3.2.16"
Expand Down
89 changes: 51 additions & 38 deletions viewer/src/app/dat-viewer/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,44 +163,57 @@ function serializeHeaders (headers: Header[]) {
}

function fromPublicSchema (sch: SchemaTable): DatSchema {
const headers: ViewerSerializedHeader[] = sch.columns.map(column => {
return { /* eslint-disable @typescript-eslint/indent */
name: column.name || '',
type: {
array: column.array,
byteView:
column.type === 'array' ? { array: true }
: undefined,
integer:
// column.type === 'u8' ? { unsigned: true, size: 1 }
column.type === 'u16' ? { unsigned: true, size: 2 }
: column.type === 'u32' ? { unsigned: true, size: 4 }
// : column.type === 'u64' ? { unsigned: true, size: 8 }
// : column.type === 'i8' ? { unsigned: false, size: 1 }
: column.type === 'i16' ? { unsigned: false, size: 2 }
: column.type === 'i32' ? { unsigned: false, size: 4 }
// : column.type === 'i64' ? { unsigned: false, size: 8 }
: column.type === 'enumrow' ? { unsigned: false, size: 4 }
: undefined,
decimal:
column.type === 'f32' ? { size: 4 }
// : column.type === 'f64' ? { size: 8 }
: undefined,
string:
column.type === 'string' ? {}
: undefined,
boolean:
column.type === 'bool' ? {}
: undefined,
key:
(column.type === 'row' || column.type === 'foreignrow') ? {
foreign: (column.type === 'foreignrow'),
table: column.references?.table ?? null,
viewColumn: null
}
: undefined
},
textLength: 4 * 3 - 1
const headers = sch.columns.flatMap<ViewerSerializedHeader>(column => {
const type: ViewerSerializedHeader['type'] = { /* eslint-disable @typescript-eslint/indent */
array: column.array,
byteView:
column.type === 'array' ? { array: true }
: undefined,
integer:
// column.type === 'u8' ? { unsigned: true, size: 1 }
column.type === 'u16' ? { unsigned: true, size: 2 }
: column.type === 'u32' ? { unsigned: true, size: 4 }
// : column.type === 'u64' ? { unsigned: true, size: 8 }
// : column.type === 'i8' ? { unsigned: false, size: 1 }
: column.type === 'i16' ? { unsigned: false, size: 2 }
: column.type === 'i32' ? { unsigned: false, size: 4 }
// : column.type === 'i64' ? { unsigned: false, size: 8 }
: column.type === 'enumrow' ? { unsigned: false, size: 4 }
: undefined,
decimal:
column.type === 'f32' ? { size: 4 }
// : column.type === 'f64' ? { size: 8 }
: undefined,
string:
column.type === 'string' ? {}
: undefined,
boolean:
column.type === 'bool' ? {}
: undefined,
key:
(column.type === 'row' || column.type === 'foreignrow') ? {
foreign: (column.type === 'foreignrow'),
table: column.references?.table ?? null,
viewColumn: null
}
: undefined
}
if (column.interval) {
return [{
name: (column.name) ? `${column.name}[0]` : '',
type,
textLength: 4 * 3 - 1
}, {
name: (column.name) ? `${column.name}[1]` : '',
type,
textLength: 4 * 3 - 1
}]
} else {
return [{
name: column.name || '',
type,
textLength: 4 * 3 - 1
}]
}
})

Expand Down

0 comments on commit 5728f34

Please sign in to comment.