Skip to content

Commit

Permalink
new log format
Browse files Browse the repository at this point in the history
  • Loading branch information
Herysia committed Apr 27, 2023
1 parent 315bf80 commit c375699
Show file tree
Hide file tree
Showing 19 changed files with 427 additions and 554 deletions.
2 changes: 1 addition & 1 deletion meter-data
Submodule meter-data updated 1 files
+231,000 −88,898 databases/SkillEffect.json
393 changes: 142 additions & 251 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loa-details",
"version": "1.1.15",
"version": "1.2.0",
"description": "Damage meter for Lost Ark",
"productName": "LOA Details",
"author": "Herysia, Mathicha, Eren Kara <[email protected]>",
Expand All @@ -20,16 +20,12 @@
"electron-log": "^4.4.8",
"electron-store": "^8.1.0",
"electron-updater": "^5.3.0",
"loa-details-log-parser": "github:Herysia/loa-details-log-parser",
"lodash": "^4.17.21",
"meter-core": "github:lost-ark-dev/meter-core",
"worker-farm": "^1.7.0"
"meter-core": "github:lost-ark-dev/meter-core"
},
"devDependencies": {
"@electron/rebuild": "^3.2.12",
"@quasar/app-vite": "^1.2.1",
"@electron/rebuild": "^3.2.13",
"@quasar/app-vite": "^1.2.2",
"@quasar/extras": "^1.16.2",
"@types/lodash": "^4.14.194",
"@types/node": "*",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
Expand All @@ -45,8 +41,7 @@
"prettier": "^2.8.7",
"quasar": "^2.11.10",
"typescript": "^4.9.4",
"uuid": "^9.0.0",
"vue": "^3.2.47",
"vue": "^3.2.45",
"vue-router": "^4.1.6"
},
"engines": {
Expand Down
88 changes: 47 additions & 41 deletions src-electron/electron-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import log from "electron-log";
import Store from "electron-store";
import { unlinkSync } from "fs";
import { LogParser } from "loa-details-log-parser";
import os from "os";
import path from "path";
import {
Expand Down Expand Up @@ -41,6 +40,7 @@ import {
updaterEventEmitter,
} from "./util/updater";
import { adminRelauncher, PktCaptureMode } from "meter-core/pkt-capture";
import { Parser } from "meter-core/logger/parser";

if (app.commandLine.hasSwitch("disable-hardware-acceleration")) {
log.info("Hardware acceleration disabled");
Expand Down Expand Up @@ -77,21 +77,42 @@ if (!gotTheLock) {
});
}

const meterData = InitMeterData();

const logParser = new LogParser(meterData, true);
logParser.debugLines = true;

let appSettings = getSettings();

logParser.dontResetOnZoneChange =
appSettings.damageMeter.functionality.dontResetOnZoneChange;

logParser.resetAfterPhaseTransition =
appSettings.damageMeter.functionality.resetAfterPhaseTransition;

logParser.removeOverkillDamage =
appSettings.damageMeter.functionality.removeOverkillDamage;
// log file stuff
const padTo2Digits = (num: number) => num.toString().padStart(2, "0");
const date = new Date();
const filename =
"LostArk_" +
[
date.getFullYear(),
padTo2Digits(date.getMonth() + 1),
padTo2Digits(date.getDate()),
padTo2Digits(date.getHours()),
padTo2Digits(date.getMinutes()),
padTo2Digits(date.getSeconds()),
].join("-") +
".raw";
const meterData = InitMeterData();
let liveParser: Parser;
try {
liveParser = InitLogger(
meterData,
appSettings?.general?.useRawSocket,
appSettings?.general?.listenPort ?? 6040,
filename,
{
isLive: true,
dontResetOnZoneChange:
appSettings.damageMeter.functionality.dontResetOnZoneChange,
resetAfterPhaseTransition:
appSettings.damageMeter.functionality.resetAfterPhaseTransition,
splitOnPhaseTransition: appSettings.logs.splitOnPhaseTransition,
}
);
} catch (e) {
log.error(e);
}

appSettings.appVersion = app.getVersion();

Expand Down Expand Up @@ -240,18 +261,7 @@ function startApplication() {
});

mainWindow = createMainWindow(appSettings);
damageMeterWindow = createDamageMeterWindow(logParser, appSettings);

try {
InitLogger(
logParser,
meterData,
appSettings?.general?.useRawSocket,
appSettings?.general?.listenPort ?? 6040
);
} catch (e) {
log.error(e);
}
damageMeterWindow = createDamageMeterWindow(liveParser, appSettings);

initializeShortcuts(appSettings);

Expand Down Expand Up @@ -284,12 +294,10 @@ const ipcFunctions: {
[key: string]: (event: Electron.IpcMainEvent, arg: any) => void;
} = {
"reset-session": () => {
logParser.softReset();
liveParser.reset();
},
"cancel-reset-session": () => {
if (logParser.resetTimer) {
logParser.cancelReset();
}
liveParser.cancelReset();
},
"save-settings": (event, arg: { value: string }) => {
appSettings = JSON.parse(arg.value);
Expand All @@ -299,15 +307,13 @@ const ipcFunctions: {

mainWindow?.webContents.send("on-settings-change", appSettings);
damageMeterWindow?.webContents.send("on-settings-change", appSettings);

logParser.dontResetOnZoneChange =
appSettings.damageMeter.functionality.dontResetOnZoneChange;

logParser.removeOverkillDamage =
appSettings.damageMeter.functionality.removeOverkillDamage;

logParser.resetAfterPhaseTransition =
appSettings.damageMeter.functionality.resetAfterPhaseTransition;
liveParser.updateOptions({
dontResetOnZoneChange:
appSettings.damageMeter.functionality.dontResetOnZoneChange,
resetAfterPhaseTransition:
appSettings.damageMeter.functionality.resetAfterPhaseTransition,
splitOnPhaseTransition: appSettings.logs.splitOnPhaseTransition,
});

damageMeterWindow?.setOpacity(appSettings.damageMeter.design.opacity);
},
Expand All @@ -318,8 +324,8 @@ const ipcFunctions: {
await parseLogs(
event,
appSettings.logs.splitOnPhaseTransition,
appSettings.logs.multithreadParsing,
meterData
meterData,
filename
);
},
"get-parsed-logs": async (event) => {
Expand Down
14 changes: 7 additions & 7 deletions src-electron/electron-windows/damage-meter-window.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { app, BrowserWindow, shell } from "electron";
import log from "electron-log";
import { LogParser } from "loa-details-log-parser";
import type { Game } from "loa-details-log-parser/data";
import type { GameState } from "meter-core/logger/data";
import path from "path";
import { Settings } from "../util/app-settings";
import { upload } from "../util/uploads";
import { initWindow } from "../util/window-init";
import { Parser } from "meter-core/logger/parser";

export function createDamageMeterWindow(
logParser: LogParser,
liveParser: Parser,
appSettings: Settings
) {
let damageMeterWindow: BrowserWindow | null = new BrowserWindow({
Expand Down Expand Up @@ -50,7 +50,7 @@ export function createDamageMeterWindow(
damageMeterWindow.setAlwaysOnTop(true, "normal");

// Event listeners
logParser.on("reset-state", (state: Game) => {
liveParser.on("reset-state", (state: GameState) => {
try {
damageMeterWindow?.webContents.send("pcap-on-reset-state", "1");

Expand Down Expand Up @@ -87,7 +87,7 @@ export function createDamageMeterWindow(
log.error(e);
}
});
logParser.on("state-change", (newState: unknown) => {
liveParser.on("state-change", (newState: GameState) => {
try {
if (typeof damageMeterWindow !== "undefined" && damageMeterWindow) {
damageMeterWindow.webContents.send("pcap-on-state-change", newState);
Expand All @@ -96,9 +96,9 @@ export function createDamageMeterWindow(
log.error(e);
}
});
logParser.on("message", (val: unknown) => {
liveParser.on("message", (msg: string) => {
try {
damageMeterWindow?.webContents.send("pcap-on-message", val);
damageMeterWindow?.webContents.send("pcap-on-message", msg);
} catch (e) {
log.error(e);
}
Expand Down
Loading

0 comments on commit c375699

Please sign in to comment.