Skip to content

Commit

Permalink
Inventory - hover informations
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed Jun 1, 2019
1 parent c430354 commit 89d0b05
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

Display packets and information about a current diablo2 session

**Map**

<img src="images/base_viewer.gif" width="200" height="200"> <img src="images/filters_viewer.gif" width="200" height="200"><img src="images/tp_viewer.gif" width="200" height="200"> <img src="images/mobs_viewer.gif" width="200" height="200">

**Inventory**

<img src="images/inventory.gif" width="200" height="200">
<img src="images/inventory1.gif" width="200" height="200"> <img src="images/inventory2.gif" width="200" height="200">

Uses
* [leaflet](https://leafletjs.com/) to display maps
Expand Down
Binary file removed images/inventory.gif
Binary file not shown.
Binary file added images/inventory1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/inventory2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 38 additions & 6 deletions src/inventory-live-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,40 @@ class InventoryLiveViewer extends LitElement {
display: inline-block;
margin:10px;
background-color:grey;
}
#popup {
display: none;
position: absolute;
left: 0px;
top: 0px;
border:1px solid;
background: #d9d9d9;
overflow-wrap: break-word;
width: 500px;
}`
}

firstUpdated () {
}

displayItemData (data) {
console.log(data)
displayItemData (e, data) {
let popup = this.shadowRoot.getElementById('popup')
popup.innerHTML = JSON.stringify(data)
popup.style.display = 'block'

window.addEventListener('mousemove', (e) => { this.followCursor(e) }, true)
}

followCursor (e) {
let popup = this.shadowRoot.getElementById('popup')
popup.style.top = e.clientY + 'px'
popup.style.left = e.clientX + 'px'
}

hideItemData () {
this.shadowRoot.getElementById('popup').style.display = 'none'
window.removeEventListener('mousemove', (e) => { this.followCursor(e) }, true)
}

listenToPackets () {
Expand All @@ -46,7 +72,8 @@ class InventoryLiveViewer extends LitElement {
let y = params['y'] + h
const e = this.shadowRoot.getElementById(`${params['container']}${x};${y}`)
e.src = 'assets/itemGrid.png'
e.addEventListener('mouseover', () => { this.displayItemData(params) })
e.addEventListener('mouseover', (event) => { this.displayItemData(event, params) })
e.addEventListener('mouseout', () => { this.hideItemData() })
} catch (exception) {
console.log(`Failed ${JSON.stringify(params)}`)
}
Expand All @@ -56,15 +83,17 @@ class InventoryLiveViewer extends LitElement {
case 8: // unequip TODO: handle case when removing belt (it drop potions into inventory non-equipped)
const e = this.shadowRoot.getElementById(`e${params['x']};${params['y']}`)
e.src = 'assets/itemGrid.png'
e.removeEventListener('mouseover', () => { this.displayItemData(params) })
e.removeEventListener('mouseover', (event) => { this.displayItemData(event, params) })
e.removeEventListener('mouseout', () => { this.hideItemData() })
break
case 4: // -> inventory non-equipped
case 6: // whatever -> equipped
case 14: // inventory closed -> ground -> inventory OR inventory -> belt
if (params['equipped'] === 1) {
const e = this.shadowRoot.getElementById(`e${params['x']};${params['y']}`)
e.src = 'assets/itemGrid_filled.png'
e.addEventListener('mouseover', () => { this.displayItemData(params) })
e.addEventListener('mouseover', (event) => { this.displayItemData(event, params) })
e.addEventListener('mouseout', () => { this.hideItemData() })
} else {
for (let w = 0; w < params['width']; w++) {
for (let h = 0; h < params['height']; h++) {
Expand All @@ -73,7 +102,8 @@ class InventoryLiveViewer extends LitElement {
let y = params['y'] + h
const e = this.shadowRoot.getElementById(`${params['container']}${x};${y}`)
e.src = 'assets/itemGrid_filled.png'
e.removeEventListener('mouseover', () => { this.displayItemData(params) })
e.removeEventListener('mouseover', (event) => { this.displayItemData(event, params) })
e.removeEventListener('mouseout', () => { this.hideItemData() })
} catch (exception) {
console.log(`Failed ${JSON.stringify(params)}`)
}
Expand Down Expand Up @@ -116,6 +146,8 @@ class InventoryLiveViewer extends LitElement {
*/

return html`
<p id="popup">some text here</div>
<!-- TODO: use diablo images for inventory (make same interface than diablo) -->
<div>
<h1>Equipped</h1>
Expand Down

0 comments on commit 89d0b05

Please sign in to comment.