diff --git a/src/js/game/hud/hud.js b/src/js/game/hud/hud.js index 11f580b1..3689d41a 100644 --- a/src/js/game/hud/hud.js +++ b/src/js/game/hud/hud.js @@ -45,6 +45,7 @@ import { HUDLeverToggle } from "./parts/lever_toggle"; import { HUDLayerPreview } from "./parts/layer_preview"; import { HUDMinerHighlight } from "./parts/miner_highlight"; import { HUDBetaOverlay } from "./parts/beta_overlay"; +import { HUDPerformanceWarning } from "./parts/performance_warning"; export class GameHUD { /** @@ -85,6 +86,7 @@ export class GameHUD { layerPreview: new HUDLayerPreview(this.root), minerHighlight: new HUDMinerHighlight(this.root), + performanceWarning: new HUDPerformanceWarning(this.root), // Typing hints /* typehints:start */ diff --git a/src/js/game/hud/parts/performance_warning.js b/src/js/game/hud/parts/performance_warning.js new file mode 100644 index 00000000..4875acc8 --- /dev/null +++ b/src/js/game/hud/parts/performance_warning.js @@ -0,0 +1,16 @@ +import { T } from "../../../translations"; +import { BaseHUDPart } from "../base_hud_part"; + +export class HUDPerformanceWarning extends BaseHUDPart { + initialize() { + this.warningShown = false; + this.root.signals.entityManuallyPlaced.add(this.checkAfterPlace, this); + } + + checkAfterPlace() { + if (!this.warningShown && this.root.entityMgr.entities.length > 10000) { + this.root.hud.parts.dialogs.showInfo(T.dialogs.entityWarning.title, T.dialogs.entityWarning.desc); + this.warningShown = true; + } + } +} diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 8d3d581c..d0f70ad8 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -287,6 +287,10 @@ dialogs: title: Rename Savegame desc: You can rename your savegame here. + entityWarning: + title: Performance Warning + desc: You have placed a lot of buildings, this is just a friendly reminder that the game can not handle an endless count of buildings - So try to keep your factories compact! + ingame: # This is shown in the top left corner and displays useful keybindings in # every situation