mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 15:30:41 +09:00
remoteMap place rotated items, fix selection box offset
This commit is contained in:
1 parent
f5eef7c1bb
commit
e6d734d4eb
3 files changed
+27
-6
No files matched your search
@@ -4,6 +4,7 @@ export class itemSelector {
|
||||
this.container = document.querySelector(containerSelector);
|
||||
if(!this.container) throw new Error("Could not find container "+container);
|
||||
this.entities = entities;
|
||||
this.direction = 0;
|
||||
|
||||
// populate container
|
||||
let cont = this.container;
|
||||
@@ -17,6 +18,12 @@ export class itemSelector {
|
||||
this.entities.forEach(entity => HTML += "<option value='"+entity.name+"'>"+entity.name+"</option>");
|
||||
HTML += "</select>";
|
||||
HTML += "</div>";
|
||||
// direction selector
|
||||
HTML += "<div id='directionSelector'>";
|
||||
HTML += "<h2>Direction: </h2>";
|
||||
HTML += "<p>Press R to rotate</p>";
|
||||
HTML += "<p id='directionDisplay'>0</p>"
|
||||
HTML += "</div>";
|
||||
|
||||
// write styles
|
||||
let styles = {
|
||||
@@ -42,9 +49,18 @@ export class itemSelector {
|
||||
HTML += "}";
|
||||
}
|
||||
cont.innerHTML += HTML + "</style>";
|
||||
|
||||
// handle direction keyboard event
|
||||
Mousetrap.bind('r', ()=>this.rotate());
|
||||
}
|
||||
rotate(){
|
||||
this.direction = (this.direction + 2) % 8;
|
||||
// update display
|
||||
document.querySelector("#directionDisplay").innerHTML = this.direction;
|
||||
}
|
||||
getItem(){
|
||||
let name = document.querySelector(this.containerSelector+" > .itemSelector > select").value;
|
||||
return {name};
|
||||
let direction = this.direction;
|
||||
return {name, direction};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user