Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
k2d222 committed Nov 24, 2024
1 parent 13a1050 commit 57b0495
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 66 deletions.
9 changes: 3 additions & 6 deletions client/src/gl/viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ export class Viewport {
const [canvasX, canvasY] = this.pixelToCanvas(e.clientX, e.clientY)

// wheel button or ctrl + left click
if (e.buttons === 4 || (e.ctrlKey && e.buttons === 1))
this.onDragStart(canvasX, canvasY)
if (e.buttons === 4 || (e.ctrlKey && e.buttons === 1)) this.onDragStart(canvasX, canvasY)
}

private onmousemove(e: MouseEvent) {
Expand All @@ -119,10 +118,8 @@ export class Viewport {
this.mousePos.y = worldY

if (this.drag) {
if (e.buttons === 4 || (e.ctrlKey && e.buttons === 1))
this.onDrag(canvasX, canvasY)
else
this.drag = false
if (e.buttons === 4 || (e.ctrlKey && e.buttons === 1)) this.onDrag(canvasX, canvasY)
else this.drag = false
}
}

Expand Down
11 changes: 7 additions & 4 deletions client/src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class WebSocketServer extends EventDispatcher<Recv> implements Server {

this.httpUrl = serverHttpUrl(cfg)

this.errorListener = () => { }
this.errorListener = () => {}
this.queryListeners = {}

this.history = new History()
Expand All @@ -120,14 +120,18 @@ export class WebSocketServer extends EventDispatcher<Recv> implements Server {
async fetch(path: string, init: RequestInit = {}) {
init.headers = {
...init.headers,
...(this.token && { 'Authorization': 'Bearer ' + this.token })
...(this.token && { Authorization: 'Bearer ' + this.token }),
}
const resp = await fetch(`${this.httpUrl}/${path}`, init)
if (!resp.ok) throw await resp.text()
return resp
}

query<K extends SendKey>(type: K, content: Send[K], options: Partial<Options> = {}): Promise<Resp[K]> {
query<K extends SendKey>(
type: K,
content: Send[K],
options: Partial<Options> = {}
): Promise<Resp[K]> {
let timeoutID = -1
let id = this.generateID()

Expand Down Expand Up @@ -208,7 +212,6 @@ export class WebSocketServer extends EventDispatcher<Recv> implements Server {
}
}


send<K extends SendKey>(type: K, content: Send[K], options: Partial<Options> = {}) {
this.query(type, content, options)
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/storage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ServerConfig } from "./server/server"
import type { ServerConfig } from './server/server'

const { VITE_SERVER_URLS } = import.meta.env

Expand Down
5 changes: 4 additions & 1 deletion client/src/twmap/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ export class Map {
this.groups.findIndex(
g =>
g.layers.findIndex(
l => (l instanceof TilesLayer && l.colorEnv === envelope) || (l instanceof QuadsLayer && l.quads.findIndex(q => q.colorEnv === envelope || q.posEnv === envelope) !== -1)
l =>
(l instanceof TilesLayer && l.colorEnv === envelope) ||
(l instanceof QuadsLayer &&
l.quads.findIndex(q => q.colorEnv === envelope || q.posEnv === envelope) !== -1)
) !== -1
) !== -1
)
Expand Down
6 changes: 2 additions & 4 deletions client/src/twmap/tilesLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ export abstract class AnyTilesLayer<Tile extends { id: number }> extends Layer {
}

getTile(x: number, y: number) {
if ((0 <= x && x < this.width) && (0 <= y && y < this.height))
return this.tiles[y * this.width + x]
else
return this.defaultTile()
if (0 <= x && x < this.width && 0 <= y && y < this.height) return this.tiles[y * this.width + x]
else return this.defaultTile()
}

setTile(x: number, y: number, tile: Tile) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/ui/lib/editAutomapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { basicSetup } from 'codemirror'
import { EditorState } from '@codemirror/state'
import { EditorView, tooltips, keymap } from '@codemirror/view'
import { linter, setDiagnostics } from '@codemirror/lint'
import { setDiagnostics } from '@codemirror/lint'
import { DDNetRules } from './lang-ddnet_rules/index'
import { DDNetRulesLinter } from './lang-ddnet_rules/lint'
import { Rpp } from './lang-rpp/index'
Expand Down
Loading

0 comments on commit 57b0495

Please sign in to comment.