Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALTV-601 [client] Need to show PC performance metrics #342

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
24 changes: 12 additions & 12 deletions .github/workflows/build-deploy-custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: windows-2019
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -45,12 +45,12 @@ jobs:
copy dist\libnode.dll upload\modules\js-module
copy dist\js-module.pdb debug

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: js-module-windows
path: ./server/upload/

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: js-module-windows-debug
path: ./server/debug
Expand All @@ -60,7 +60,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
cp ./dist/libnode.so ./upload/modules/js-module
echo ${{ steps.version.outputs.SDK_COMMIT }} >> ./upload/sdk.version

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: js-module-linux
path: ./server/upload/
Expand All @@ -100,24 +100,24 @@ jobs:
needs: [build-linux, build-windows]
steps:
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16.x

- name: Cache node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}

- name: Download windows artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: js-module-windows
path: dist-windows

- name: Download linux artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: js-module-linux
path: dist-linux
Expand Down Expand Up @@ -191,19 +191,19 @@ jobs:
needs: [build-linux, build-windows]
steps:
- name: Download windows artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: js-module-windows
path: dist-windows

- name: Download windows debug artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: js-module-windows-debug
path: dist-windows

- name: Download linux artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: js-module-linux
path: dist-linux
Expand Down
6 changes: 4 additions & 2 deletions client/src/bindings/ClientBindingsMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,8 @@ extern V8Module sharedModule;
extern V8Class v8Player, v8Player, v8Vehicle, v8WebView, v8HandlingData, v8LocalStorage, v8MemoryBuffer, v8MapZoomData, v8Discord, v8Voice, v8WebSocketClient, v8Checkpoint, v8HttpClient,
v8Audio, v8LocalPlayer, v8Profiler, v8Worker, v8RmlDocument, v8RmlElement, v8WeaponData, v8FocusData, v8LocalObject, v8TextEncoder, v8TextDecoder, v8Object, v8VirtualEntityGroup,
v8VirtualEntity, v8AudioFilter, v8Marker, v8Ped, v8Colshape, v8ColshapeCylinder, v8ColshapeSphere, v8ColshapeCircle, v8ColshapeCuboid, v8ColshapeRectangle, v8ColshapePolygon, v8TextLabel,
v8LocalPed, v8LocalVehicle, v8Font, v8WeaponObject, v8AudioOutput, v8AudioOutputFrontend, v8AudioOutputWorld, v8AudioOutputAttached, v8AudioCategory, v8Interior, v8InteriorRoom, v8InteriorPortal;
v8LocalPed, v8LocalVehicle, v8Font, v8WeaponObject, v8AudioOutput, v8AudioOutputFrontend, v8AudioOutputWorld, v8AudioOutputAttached, v8AudioCategory, v8Interior, v8InteriorRoom,
v8InteriorPortal, v8SystemInfo;
extern V8Module altModule("alt",
&sharedModule,
{ v8Player,
Expand Down Expand Up @@ -1411,7 +1412,8 @@ extern V8Module altModule("alt",
v8AudioCategory,
v8Interior,
v8InteriorRoom,
v8InteriorPortal },
v8InteriorPortal,
v8SystemInfo },
[](v8::Local<v8::Context> ctx, v8::Local<v8::Object> exports)
{
v8::Isolate* isolate = ctx->GetIsolate();
Expand Down
49 changes: 49 additions & 0 deletions client/src/bindings/SystemInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

#include "V8Helpers.h"
#include "V8ResourceImpl.h"
#include "V8Class.h"

static void GetCpuLoad(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();

V8_RETURN_NUMBER(alt::ICore::Instance().GetCPULoad());
}

static void GetVideoMemoryUsage(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();

V8_RETURN_NUMBER(alt::ICore::Instance().GetVideoMemoryUsage());
}

static void GetRAMUsage(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();

V8_RETURN_NUMBER(alt::ICore::Instance().GetRAMUsage());
}

static void GetTotalRAM(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();

V8_RETURN_NUMBER(alt::ICore::Instance().GetTotalRAM());
}

static void GetCurrentProcessRamUsage(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();

V8_RETURN_NUMBER(alt::ICore::Instance().GetCurrentProcessRamUsage());
}

extern V8Class v8SystemInfo("SystemInfo", [](v8::Local<v8::FunctionTemplate> tpl) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();

V8Helpers::SetStaticAccessor(isolate, tpl, "cpuLoad", GetCpuLoad, nullptr);
V8Helpers::SetStaticAccessor(isolate, tpl, "videoMemoryUsage", GetVideoMemoryUsage, nullptr);
V8Helpers::SetStaticAccessor(isolate, tpl, "ramUsage", GetRAMUsage, nullptr);
V8Helpers::SetStaticAccessor(isolate, tpl, "totalRamSize", GetTotalRAM, nullptr);
V8Helpers::SetStaticAccessor(isolate, tpl, "currentProcessRamUsage", GetCurrentProcessRamUsage, nullptr);
});
2 changes: 1 addition & 1 deletion shared/deps/cpp-sdk
Submodule cpp-sdk updated 1 files
+6 −0 ICore.h
Loading