Add configuration files and update project documentation
- Introduced .editorconfig for consistent coding styles across the project. - Added .golangci.yml for Go linting configuration. - Updated AGENTS.md to clarify project structure and components. - Enhanced CONTRIBUTING.md with Makefile usage for common tasks. - Updated Dockerfiles to use Go 1.24 and improved build instructions. - Refined README.md and deployment documentation for clarity. - Added testing documentation in testing.md for backend and frontend tests. - Introduced Makefile for streamlined development commands and tasks.
This commit is contained in:
@@ -16,99 +16,111 @@ export interface MapViewRef {
|
||||
markerLayer: L.LayerGroup
|
||||
}
|
||||
|
||||
export interface MapMarker {
|
||||
id: number
|
||||
position: { x: number; y: number }
|
||||
name: string
|
||||
image: string
|
||||
type: string
|
||||
text: string
|
||||
value: number
|
||||
hidden: boolean
|
||||
map: number
|
||||
leafletMarker: L.Marker | null
|
||||
remove: (mapview: MapViewRef) => void
|
||||
add: (mapview: MapViewRef) => void
|
||||
update: (mapview: MapViewRef, updated: MarkerData | MapMarker) => void
|
||||
jumpTo: (map: L.Map) => void
|
||||
setClickCallback: (callback: (e: L.LeafletMouseEvent) => void) => void
|
||||
setContextMenu: (callback: (e: L.LeafletMouseEvent) => void) => void
|
||||
}
|
||||
|
||||
function detectType(name: string): string {
|
||||
if (name === 'gfx/invobjs/small/bush' || name === 'gfx/invobjs/small/bumling') return 'quest'
|
||||
if (name === 'custom') return 'custom'
|
||||
return name.substring('gfx/terobjs/mm/'.length)
|
||||
}
|
||||
|
||||
export class Marker {
|
||||
id: number
|
||||
position: { x: number; y: number }
|
||||
name: string
|
||||
image: string
|
||||
type: string
|
||||
marker: L.Marker | null = null
|
||||
text: string
|
||||
value: number
|
||||
hidden: boolean
|
||||
map: number
|
||||
onClick: ((e: L.LeafletMouseEvent) => void) | null = null
|
||||
onContext: ((e: L.LeafletMouseEvent) => void) | null = null
|
||||
export function createMarker(data: MarkerData): MapMarker {
|
||||
let leafletMarker: L.Marker | null = null
|
||||
let onClick: ((e: L.LeafletMouseEvent) => void) | null = null
|
||||
let onContext: ((e: L.LeafletMouseEvent) => void) | null = null
|
||||
|
||||
constructor(markerData: MarkerData) {
|
||||
this.id = markerData.id
|
||||
this.position = markerData.position
|
||||
this.name = markerData.name
|
||||
this.image = markerData.image
|
||||
this.type = detectType(this.image)
|
||||
this.text = this.name
|
||||
this.value = this.id
|
||||
this.hidden = markerData.hidden
|
||||
this.map = markerData.map
|
||||
}
|
||||
const marker: MapMarker = {
|
||||
id: data.id,
|
||||
position: { ...data.position },
|
||||
name: data.name,
|
||||
image: data.image,
|
||||
type: detectType(data.image),
|
||||
text: data.name,
|
||||
value: data.id,
|
||||
hidden: data.hidden,
|
||||
map: data.map,
|
||||
|
||||
remove(_mapview: MapViewRef): void {
|
||||
if (this.marker) {
|
||||
this.marker.remove()
|
||||
this.marker = null
|
||||
}
|
||||
}
|
||||
get leafletMarker() {
|
||||
return leafletMarker
|
||||
},
|
||||
|
||||
add(mapview: MapViewRef): void {
|
||||
if (!this.hidden) {
|
||||
let icon: L.Icon
|
||||
if (this.image === 'gfx/terobjs/mm/custom') {
|
||||
icon = new ImageIcon({
|
||||
iconUrl: 'gfx/terobjs/mm/custom.png',
|
||||
iconSize: [21, 23],
|
||||
iconAnchor: [11, 21],
|
||||
popupAnchor: [1, 3],
|
||||
tooltipAnchor: [1, 3],
|
||||
})
|
||||
} else {
|
||||
icon = new ImageIcon({ iconUrl: `${this.image}.png`, iconSize: [32, 32] })
|
||||
remove(_mapview: MapViewRef): void {
|
||||
if (leafletMarker) {
|
||||
leafletMarker.remove()
|
||||
leafletMarker = null
|
||||
}
|
||||
},
|
||||
|
||||
const position = mapview.map.unproject([this.position.x, this.position.y], HnHMaxZoom)
|
||||
this.marker = L.marker(position, { icon, title: this.name })
|
||||
this.marker.addTo(mapview.markerLayer)
|
||||
this.marker.on('click', this.callClickCallback.bind(this))
|
||||
this.marker.on('contextmenu', this.callContextCallback.bind(this))
|
||||
}
|
||||
add(mapview: MapViewRef): void {
|
||||
if (!marker.hidden) {
|
||||
let icon: L.Icon
|
||||
if (marker.image === 'gfx/terobjs/mm/custom') {
|
||||
icon = new ImageIcon({
|
||||
iconUrl: 'gfx/terobjs/mm/custom.png',
|
||||
iconSize: [21, 23],
|
||||
iconAnchor: [11, 21],
|
||||
popupAnchor: [1, 3],
|
||||
tooltipAnchor: [1, 3],
|
||||
})
|
||||
} else {
|
||||
icon = new ImageIcon({ iconUrl: `${marker.image}.png`, iconSize: [32, 32] })
|
||||
}
|
||||
|
||||
const position = mapview.map.unproject([marker.position.x, marker.position.y], HnHMaxZoom)
|
||||
leafletMarker = L.marker(position, { icon, title: marker.name })
|
||||
leafletMarker.addTo(mapview.markerLayer)
|
||||
leafletMarker.on('click', (e: L.LeafletMouseEvent) => {
|
||||
if (onClick) onClick(e)
|
||||
})
|
||||
leafletMarker.on('contextmenu', (e: L.LeafletMouseEvent) => {
|
||||
if (onContext) onContext(e)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
update(mapview: MapViewRef, updated: MarkerData | MapMarker): void {
|
||||
marker.position = { ...updated.position }
|
||||
marker.name = updated.name
|
||||
marker.hidden = updated.hidden
|
||||
marker.map = updated.map
|
||||
if (leafletMarker) {
|
||||
const position = mapview.map.unproject([updated.position.x, updated.position.y], HnHMaxZoom)
|
||||
leafletMarker.setLatLng(position)
|
||||
}
|
||||
},
|
||||
|
||||
jumpTo(map: L.Map): void {
|
||||
if (leafletMarker) {
|
||||
const position = map.unproject([marker.position.x, marker.position.y], HnHMaxZoom)
|
||||
leafletMarker.setLatLng(position)
|
||||
}
|
||||
},
|
||||
|
||||
setClickCallback(callback: (e: L.LeafletMouseEvent) => void): void {
|
||||
onClick = callback
|
||||
},
|
||||
|
||||
setContextMenu(callback: (e: L.LeafletMouseEvent) => void): void {
|
||||
onContext = callback
|
||||
},
|
||||
}
|
||||
|
||||
update(mapview: MapViewRef, updated: MarkerData): void {
|
||||
this.position = updated.position
|
||||
this.name = updated.name
|
||||
this.hidden = updated.hidden
|
||||
this.map = updated.map
|
||||
if (this.marker) {
|
||||
const position = mapview.map.unproject([updated.position.x, updated.position.y], HnHMaxZoom)
|
||||
this.marker.setLatLng(position)
|
||||
}
|
||||
}
|
||||
|
||||
jumpTo(map: L.Map): void {
|
||||
if (this.marker) {
|
||||
const position = map.unproject([this.position.x, this.position.y], HnHMaxZoom)
|
||||
this.marker.setLatLng(position)
|
||||
}
|
||||
}
|
||||
|
||||
setClickCallback(callback: (e: L.LeafletMouseEvent) => void): void {
|
||||
this.onClick = callback
|
||||
}
|
||||
|
||||
callClickCallback(e: L.LeafletMouseEvent): void {
|
||||
if (this.onClick != null) this.onClick(e)
|
||||
}
|
||||
|
||||
setContextMenu(callback: (e: L.LeafletMouseEvent) => void): void {
|
||||
this.onContext = callback
|
||||
}
|
||||
|
||||
callContextCallback(e: L.LeafletMouseEvent): void {
|
||||
if (this.onContext != null) this.onContext(e)
|
||||
}
|
||||
return marker
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user