mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Multiple improvements, fix saves on underground belts
This commit is contained in:
@@ -12,7 +12,7 @@ import { HUDKeybindingOverlay } from "./parts/keybinding_overlay";
|
||||
import { HUDUnlockNotification } from "./parts/unlock_notification";
|
||||
import { HUDGameMenu } from "./parts/game_menu";
|
||||
import { HUDShop } from "./parts/shop";
|
||||
import { IS_MOBILE } from "../../core/config";
|
||||
import { IS_MOBILE, globalConfig } from "../../core/config";
|
||||
import { HUDMassSelector } from "./parts/mass_selector";
|
||||
import { HUDVignetteOverlay } from "./parts/vignette_overlay";
|
||||
import { HUDStatistics } from "./parts/statistics";
|
||||
@@ -22,6 +22,7 @@ import { ShapeDefinition } from "../shape_definition";
|
||||
import { HUDNotifications, enumNotificationType } from "./parts/notifications";
|
||||
import { HUDSettingsMenu } from "./parts/settings_menu";
|
||||
import { HUDDebugInfo } from "./parts/debug_info";
|
||||
import { HUDEntityDebugger } from "./parts/entity_debugger";
|
||||
|
||||
export class GameHUD {
|
||||
/**
|
||||
@@ -71,6 +72,10 @@ export class GameHUD {
|
||||
this.parts.keybindingOverlay = new HUDKeybindingOverlay(this.root);
|
||||
}
|
||||
|
||||
if (G_IS_DEV && globalConfig.debug.enableEntityInspector) {
|
||||
this.parts.entityDebugger = new HUDEntityDebugger(this.root);
|
||||
}
|
||||
|
||||
const frag = document.createDocumentFragment();
|
||||
for (const key in this.parts) {
|
||||
this.parts[key].createElements(frag);
|
||||
|
||||
68
src/js/game/hud/parts/entity_debugger.js
Normal file
68
src/js/game/hud/parts/entity_debugger.js
Normal file
@@ -0,0 +1,68 @@
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
import { makeDiv, removeAllChildren } from "../../../core/utils";
|
||||
import { globalConfig } from "../../../core/config";
|
||||
|
||||
export class HUDEntityDebugger extends BaseHUDPart {
|
||||
createElements(parent) {
|
||||
this.element = makeDiv(
|
||||
parent,
|
||||
"ingame_HUD_EntityDebugger",
|
||||
[],
|
||||
`
|
||||
Tile below cursor: <span class="mousePos"></span><br>
|
||||
Chunk below cursor: <span class="chunkPos"></span><br>
|
||||
<div class="entityInfo"></div>
|
||||
`
|
||||
);
|
||||
|
||||
this.mousePosElem = this.element.querySelector(".mousePos");
|
||||
this.chunkPosElem = this.element.querySelector(".chunkPos");
|
||||
this.entityInfoElem = this.element.querySelector(".entityInfo");
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.root.camera.downPreHandler.add(this.onMouseDown, this);
|
||||
}
|
||||
|
||||
update() {
|
||||
const mousePos = this.root.app.mousePosition;
|
||||
const worldPos = this.root.camera.screenToWorld(mousePos);
|
||||
const worldTile = worldPos.toTileSpace();
|
||||
|
||||
const chunk = worldTile.divideScalar(globalConfig.mapChunkSize).floor();
|
||||
this.mousePosElem.innerText = worldTile.x + " / " + worldTile.y;
|
||||
this.chunkPosElem.innerText = chunk.x + " / " + chunk.y;
|
||||
|
||||
const entity = this.root.map.getTileContent(worldTile);
|
||||
if (entity) {
|
||||
removeAllChildren(this.entityInfoElem);
|
||||
let html = "Entity";
|
||||
|
||||
const flag = (name, val) =>
|
||||
`<span class='flag' data-value='${val ? "1" : "0"}'><u>${name}</u> ${val}</span>`;
|
||||
|
||||
html += "<div class='entityFlags'>";
|
||||
html += flag("registered", entity.registered);
|
||||
html += flag("uid", entity.uid);
|
||||
html += flag("destroyed", entity.destroyed);
|
||||
html += "</div>";
|
||||
|
||||
html += "<div class='components'>";
|
||||
|
||||
for (const componentId in entity.components) {
|
||||
const data = entity.components[componentId];
|
||||
html += "<div class='component'>";
|
||||
html += "<strong class='name'>" + componentId + "</strong>";
|
||||
html += "<textarea class='data'>" + JSON.stringify(data.serialize(), null, 2) + "</textarea>";
|
||||
|
||||
html += "</div>";
|
||||
}
|
||||
|
||||
html += "</div>";
|
||||
|
||||
this.entityInfoElem.innerHTML = html;
|
||||
}
|
||||
}
|
||||
|
||||
onMouseDown() {}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
import { makeDiv, formatSeconds } from "../../../core/utils";
|
||||
import { makeDiv, formatSeconds, formatBigNumberFull } from "../../../core/utils";
|
||||
import { DynamicDomAttach } from "../dynamic_dom_attach";
|
||||
import { InputReceiver } from "../../../core/input_receiver";
|
||||
import { KeyActionMapper } from "../../key_action_mapper";
|
||||
import { T } from "../../../translations";
|
||||
import { StaticMapEntityComponent } from "../../components/static_map_entity";
|
||||
import { ItemProcessorComponent } from "../../components/item_processor";
|
||||
import { BeltComponent } from "../../components/belt";
|
||||
|
||||
export class HUDSettingsMenu extends BaseHUDPart {
|
||||
createElements(parent) {
|
||||
@@ -11,11 +14,16 @@ export class HUDSettingsMenu extends BaseHUDPart {
|
||||
|
||||
this.menuElement = makeDiv(this.background, null, ["menuElement"]);
|
||||
|
||||
this.timePlayed = makeDiv(
|
||||
this.statsElement = makeDiv(
|
||||
this.background,
|
||||
null,
|
||||
["timePlayed"],
|
||||
`<strong>${T.ingame.settingsMenu.playtime}</strong><span class="playtime"></span>`
|
||||
["statsElement"],
|
||||
`
|
||||
<strong>${T.ingame.settingsMenu.beltsPlaced}</strong><span class="beltsPlaced"></span>
|
||||
<strong>${T.ingame.settingsMenu.buildingsPlaced}</strong><span class="buildingsPlaced"></span>
|
||||
<strong>${T.ingame.settingsMenu.playtime}</strong><span class="playtime"></span>
|
||||
|
||||
`
|
||||
);
|
||||
|
||||
this.buttonContainer = makeDiv(this.menuElement, null, ["buttons"]);
|
||||
@@ -89,10 +97,18 @@ export class HUDSettingsMenu extends BaseHUDPart {
|
||||
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever);
|
||||
|
||||
const totalMinutesPlayed = Math.ceil(this.root.time.now() / 60);
|
||||
this.timePlayed.querySelector(".playtime").innerText = T.global.time.xMinutes.replace(
|
||||
this.statsElement.querySelector(".playtime").innerText = T.global.time.xMinutes.replace(
|
||||
"<x>",
|
||||
"" + totalMinutesPlayed
|
||||
);
|
||||
|
||||
this.statsElement.querySelector(".buildingsPlaced").innerText = formatBigNumberFull(
|
||||
this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent).length -
|
||||
this.root.entityMgr.getAllWithComponent(BeltComponent).length
|
||||
);
|
||||
this.statsElement.querySelector(".beltsPlaced").innerText = formatBigNumberFull(
|
||||
this.root.entityMgr.getAllWithComponent(BeltComponent).length
|
||||
);
|
||||
}
|
||||
|
||||
close() {
|
||||
|
||||
Reference in New Issue
Block a user