Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,6 @@ release
dist-ssr
*.local
.vscode/settings.json

# Webstorm
.idea
2 changes: 2 additions & 0 deletions packages/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ const en: BaseTranslation = {
interface: 'Interface',
sound: 'Sound',
gameData: 'Game data',
debug: 'Debug',
activateDebugLogs: 'Activate the debug logs. Warning: this may worsen the performance',
language: 'Language',
resolution: 'Resolution',
fullScreen: 'Full screen',
Expand Down
2 changes: 2 additions & 0 deletions packages/i18n/es/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ const es: Translation = {
interface: 'Interfaz',
sound: 'Sonido',
gameData: 'Datos del juego',
debug: 'Debug',
activateDebugLogs: 'Activa los logs de debug. Atencion: Esto puede empeorar el rendimiento',
language: 'Lenguaje',
resolution: 'Resolución',
fullScreen: 'Pantalla completa',
Expand Down
2 changes: 2 additions & 0 deletions packages/i18n/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ const fr: Translation = {
interface: 'Interface',
sound: 'Son',
gameData: 'Données du jeu',
debug: 'Debug',
activateDebugLogs: 'Activer les journaux de débogage. Attention : Cela peut nuire à la performance du système.',
language: 'Langue',
resolution: 'Résolution',
fullScreen: 'Activer le mode plein écran',
Expand Down
16 changes: 16 additions & 0 deletions packages/i18n/i18n-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,14 @@ type RootTranslation = {
* Game data
*/
gameData: string
/**
* Debug
*/
debug: string
/**
* Activate the debug logs. Warning: this may worsen the performance
*/
activateDebugLogs: string
/**
* Language
*/
Expand Down Expand Up @@ -1439,6 +1447,14 @@ export type TranslationFunctions = {
* Game data
*/
gameData: () => LocalizedString
/**
* Debug
*/
debug: () => LocalizedString
/**
* Activate the debug logs. Warning: this may worsen the performance
*/
activateDebugLogs: () => LocalizedString
/**
* Language
*/
Expand Down
77 changes: 77 additions & 0 deletions packages/renderer/src/mods/debug message helper/debug messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Mod } from '@/mods/mod'
import { DofusWindow } from '@/dofus-window'
import { RootStore } from '@/store'
import { TranslationFunctions } from '@lindo/i18n'
import { EventManager } from '@/mods/helpers'
import { IObjectDidChange, Lambda, observe } from 'mobx'

interface ValueDidChange {
value: boolean
oldValue: boolean
}

export class DebugMessagesMod extends Mod {
private readonly eventManager = new EventManager()
private readonly _disposers: Array<Lambda> = []

constructor(wGame: DofusWindow, rootStore: RootStore, LL: TranslationFunctions) {
super(wGame, rootStore, LL)
console.log('- enabled debug messages')
const disposer = observe(this.rootStore.optionStore.window, (change: IObjectDidChange<ValueDidChange>) => {
if (change.name !== 'debugLogs') return
if (change.type !== 'update') return
if (change?.newValue?.value) this.startEvents()
else this.removeEvents()
})
this._disposers.push(disposer)
if (this.rootStore.optionStore.window.debugLogs) this.load()
}

private load() {
this.startEvents()
}

private startEvents() {
console.log('- starting debug events')
this.eventManager.on(this.wGame.dofus.connectionManager, 'send', this.onSend)
this.eventManager.on(this.wGame.dofus.connectionManager, 'data', this.onReceive)
this.eventManager.on(this.wGame.dofus.connectionManager, 'messageSequence', this.onMsgSeq)
}

onSend = (msg: any) => {
if (msg.call === 'sendMessage') {
console.debug('%c-> ' + msg.data.data.type, 'background-color: orange; color:black', msg.data.data.data)
} else {
console.debug('%c-> ' + msg.data.call, 'background-color: red; color:white', msg.data.data)
}
}

onReceive = (msg: any) => {
const msgCopy = { ...msg }
const type = msg._messageType
delete msgCopy._messageType
console.debug('%c<- ' + type, 'background-color: green;color: white', msgCopy)
}

onMsgSeq = (msg: any) => {
msg.sequence.forEach((s: any) => {
const msgCopy = { ...s }
delete msgCopy._messageType
console.debug('%cSEQ ' + s._messageType, 'background-color: yellow;color:black;', msgCopy)
})
}

destroy(): void {
this.removeEvents()
for (const disposer of this._disposers) {
disposer()
}
}

private removeEvents() {
console.log('- removing debug events')
this.eventManager.removeListener(this.wGame.dofus.connectionManager, 'send', this.onSend)
this.eventManager.removeListener(this.wGame.dofus.connectionManager, 'data', this.onReceive)
this.eventManager.removeListener(this.wGame.dofus.connectionManager, 'messageSequence', this.onMsgSeq)
}
}
1 change: 1 addition & 0 deletions packages/renderer/src/mods/debug message helper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './debug messages'
6 changes: 6 additions & 0 deletions packages/renderer/src/mods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { ShortcutsMod } from './shortcuts'
import { ShowResourcesMod } from './show-resources'
import { VerticalTimelineMod } from './vertical-timeline'
import { ZaapSearchFilterMod } from './zaap-search-filter'
import { RecipePrice } from './recipe-price'
import { OffensiveMonsters } from '@/mods/ofensive monsters'
import { DebugMessagesMod } from '@/mods/debug message helper'

export * from './shortcuts'
export * from './notifications'
Expand Down Expand Up @@ -46,5 +49,8 @@ export const MODS = [
RuneListerMod,
ShowResourcesMod,
ZaapSearchFilterMod,
RecipePrice,
OffensiveMonsters,
DebugMessagesMod,
...GENERAL_MODS
] as const
1 change: 1 addition & 0 deletions packages/renderer/src/mods/ofensive monsters/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './offensive-monsters'
Loading