mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-05 03:52:14 +00:00
New icons (#1287)
## Description: Add a new pixi layer for rendering structure icons Add new sprites for structures  ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: Vivacious Box --------- Co-authored-by: evanpelle <evanpelle@gmail.com>
This commit is contained in:
@@ -14,6 +14,7 @@ export const CAMERA_SMOOTHING = 0.03;
|
||||
|
||||
export class TransformHandler {
|
||||
public scale: number = 1.8;
|
||||
private _boundingRect: DOMRect;
|
||||
private offsetX: number = -350;
|
||||
private offsetY: number = -200;
|
||||
private lastGoToCallTime: number | null = null;
|
||||
@@ -27,6 +28,7 @@ export class TransformHandler {
|
||||
private eventBus: EventBus,
|
||||
private canvas: HTMLCanvasElement,
|
||||
) {
|
||||
this._boundingRect = this.canvas.getBoundingClientRect();
|
||||
this.eventBus.on(ZoomEvent, (e) => this.onZoom(e));
|
||||
this.eventBus.on(DragEvent, (e) => this.onMove(e));
|
||||
this.eventBus.on(GoToPlayerEvent, (e) => this.onGoToPlayer(e));
|
||||
@@ -35,8 +37,12 @@ export class TransformHandler {
|
||||
this.eventBus.on(CenterCameraEvent, () => this.centerCamera());
|
||||
}
|
||||
|
||||
public updateCanvasBoundingRect() {
|
||||
this._boundingRect = this.canvas.getBoundingClientRect();
|
||||
}
|
||||
|
||||
boundingRect(): DOMRect {
|
||||
return this.canvas.getBoundingClientRect();
|
||||
return this._boundingRect;
|
||||
}
|
||||
|
||||
width(): number {
|
||||
@@ -45,6 +51,9 @@ export class TransformHandler {
|
||||
hasChanged(): boolean {
|
||||
return this.changed;
|
||||
}
|
||||
resetChanged() {
|
||||
this.changed = false;
|
||||
}
|
||||
|
||||
handleTransform(context: CanvasRenderingContext2D) {
|
||||
// Disable image smoothing for pixelated effect
|
||||
@@ -59,7 +68,6 @@ export class TransformHandler {
|
||||
this.game.width() / 2 - this.offsetX * this.scale,
|
||||
this.game.height() / 2 - this.offsetY * this.scale,
|
||||
);
|
||||
this.changed = false;
|
||||
}
|
||||
|
||||
worldToScreenCoordinates(cell: Cell): { x: number; y: number } {
|
||||
|
||||
Reference in New Issue
Block a user