Skip to content

Commit

Permalink
chore(release): 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KotRikD committed Dec 16, 2023
1 parent 1b1b987 commit f19e17c
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 56 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ node_modules
yarn-error.log
static/
package-lock.json
config.ini
gameOverlay/
config.ini
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.4.0](https://github.com/KotRikD/tosu/compare/v1.3.4...v1.4.0) (2023-12-16)


### Features

* gosumemory gameOverlay implementation ([1b1b987](https://github.com/KotRikD/tosu/commit/1b1b987dc523db9160423c8b39b0fbb6b92f34f9))

### [1.3.4](https://github.com/KotRikD/tosu/compare/v1.3.3...v1.3.4) (2023-12-15)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Mikhail Babynichev",
"license": "GPL-3.0",
"version": "1.3.4",
"version": "1.4.0",
"scripts": {
"prepare": "husky install",
"start": "pnpm run -C packages/tosu run:dev",
Expand Down
3 changes: 3 additions & 0 deletions packages/gameOverlay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tosu/game-overlay
---
A temp project to allow users use gosu memory game Overlay, probably in future will be replaced with own interpretation of this thing. I just wouldn't make it, due I agree with BlackShark's position about this (that it can give rise to a certain set of people who will use it for the evil of the game (cheats, etc.)) for the same reason, he doesn't even want to tell me how he compiled original `gameOverlay` project. Yes, this file that your `gosumemory` downloads at first launch!
15 changes: 15 additions & 0 deletions packages/gameOverlay/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "game-overlay",
"private": "true",
"version": "0.0.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"prepare": "npm run build",
"build": "tsc"
},
"dependencies": {
"decompress": "^4.2.1",
"tsprocess": "workspace:*"
}
}
63 changes: 63 additions & 0 deletions packages/gameOverlay/src/features/downloader/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import fs from 'fs';
import https from 'https';

const progressBarWidth = 40;

const updateProgressBar = (progress: number): void => {
const filledWidth = Math.round(progressBarWidth * progress);
const emptyWidth = progressBarWidth - filledWidth;
const progressBar = '█'.repeat(filledWidth) + '░'.repeat(emptyWidth);
process.stdout.write(
`Progress: [${progressBar}] ${(progress * 100).toFixed(2)}%\r`
);
};

/**
* A cyperdark's downloadFile implmentation based on pure node api
* @param url {string}
* @param destination {string}
* @returns {Promise<string>}
*/
export const downloadFile = (
url: string,
destination: string
): Promise<string> =>
new Promise((resolve, reject) => {
const options = {
headers: {
Accept: 'application/octet-stream',
'User-Agent': '@KotRikD/tosu'
}
};

const file = fs.createWriteStream(destination);

file.on('error', (err) => {
fs.unlinkSync(destination);
reject(err);
});

file.on('finish', () => {
file.close();
resolve(destination);
});

// find url
https
.get(url, options, (response) => {
const totalSize = parseInt(
response.headers['content-length']!,
10
);
let downloadedSize = 0;

response.on('data', (data) => {
downloadedSize += data.length;
const progress = downloadedSize / totalSize;
updateProgressBar(progress);
});

response.pipe(file);
})
.on('error', reject);
});
82 changes: 82 additions & 0 deletions packages/gameOverlay/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import decompress from 'decompress';
import { execFile } from 'node:child_process';
import { existsSync, writeFileSync } from 'node:fs';
import { mkdir, rm } from 'node:fs/promises';
import path from 'node:path';
import { Process } from 'tsprocess/dist/process';

import { downloadFile } from './features/downloader';

const checkGameOverlayConfig = () => {
const configPath = path.join(process.cwd(), 'config.ini');
if (!existsSync(configPath)) {
writeFileSync(
configPath,
`[GameOverlay]; https://github.com/l3lackShark/gosumemory/wiki/GameOverlay
enabled = false
gameWidth = 1920
gameHeight = 1080
overlayURL = http://127.0.0.1:24050/InGame2/index.html
overlayWidth = 380
overlayHeight = 110
overlayOffsetX = 0
overlayOffsetY = 0
overlayScale = 10`
);
}
};

export const injectGameOverlay = async (p: Process) => {
if (process.platform !== 'win32') {
throw new Error(
'Gameoverlay can run only under windows, sorry linux/darwin user!'
);
}

// Check for DEPRECATED GOSU CONFIG, due its needed to read [GameOverlay] section from original configuration
checkGameOverlayConfig();

if (!existsSync(path.join(process.cwd(), 'gameOverlay'))) {
const gameOverlayPath = path.join(process.cwd(), 'gameOverlay');
const archivePath = path.join(gameOverlayPath, 'gosu-gameoverlay.zip');

await mkdir(gameOverlayPath);
await downloadFile(
'https://dl.kotworks.cyou/gosu-gameoverlay.zip',
archivePath
);
await decompress(archivePath, gameOverlayPath);
await rm(archivePath);
}

if (
!existsSync(
path.join(process.cwd(), 'gameOverlay', 'gosumemoryoverlay.dll')
)
) {
console.log('Please delete gameOverlay folder, and restart program!');
process.exit(1);
}

return await new Promise((resolve, reject) => {
const child = execFile(
path.join(process.cwd(), 'gameOverlay', 'a.exe'),
[
p.id.toString(),
path.join(process.cwd(), 'gameOverlay', 'gosumemoryoverlay.dll')
],
{
windowsHide: true
}
);
child.on('error', (err) => {
reject(err);
});
child.on('exit', () => {
console.log(
'[gosu-overlay] initialized successfully, see https://github.com/l3lackShark/gosumemory/wiki/GameOverlay for tutorial'
);
resolve(true);
});
});
};
20 changes: 20 additions & 0 deletions packages/gameOverlay/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"lib": ["ES2020"],
"module": "commonjs",
"moduleResolution": "Node",
"allowJs": true,
"esModuleInterop": true,
"outDir": "dist",
"rootDir": "src",
"sourceMap": false,
"declaration": false,
"strict": true,
"noImplicitAny": false,
"target": "ES2020",
"strictPropertyInitialization": false,
"baseUrl": ".",
},
"exclude": ["node_modules"],
"include": ["src"]
}
4 changes: 2 additions & 2 deletions packages/tosu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@vercel/ncc": "^0.36.1",
"dotenv": "^16.0.3",
"find-process": "^1.4.7",
"game-overlay": "workspace:*",
"koa": "^2.14.1",
"koa-mount": "^4.0.0",
"koa-send": "^5.0.1",
Expand All @@ -43,7 +44,6 @@
"rosu-pp": "^0.9.4",
"ts-node": "^10.9.1",
"tsprocess": "workspace:*",
"winston": "^3.8.2",
"@tosu/game-overlay": "workspace:*"
"winston": "^3.8.2"
}
}
2 changes: 1 addition & 1 deletion packages/tosu/src/objects/instanceManager/osuInstance.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { injectGameOverlay } from '@tosu/game-overlay';
import EventEmitter from 'events';
import fs from 'fs';
import { injectGameOverlay } from 'game-overlay';
import path from 'path';
import { Process } from 'tsprocess/dist/process';

Expand Down
Loading

0 comments on commit f19e17c

Please sign in to comment.