Skip to content

Commit 2e0a5e6

Browse files
doing this before cne v1.0 releases lol!
1 parent c1aa7bf commit 2e0a5e6

36 files changed

Lines changed: 267 additions & 121 deletions

project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
title="fnf vs br" main="funkin.backend.system.Main"
66
file="VsBrRetoasted" packageName="com.thebrcrew.codenameengine"
77
package="com.thebrcrew.codenameengine"
8-
version="0.1.0" company="TheBrCrew" />
8+
version="0.1.0-legacy" company="TheBrCrew" />
99

1010
<!--
1111
CHANGE THE SAVE PATH & NAME FOR YOUR MOD HERE!

source/funkin/backend/assets/Paths.hx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ class Paths
2828
public static var tempFramesCache:Map<String, FlxFramesCollection> = [];
2929

3030
public static function init() {
31-
FlxG.signals.preStateSwitch.add(function() {
32-
tempFramesCache.clear();
33-
});
31+
FlxG.signals.preStateSwitch.add(() -> tempFramesCache.clear());
3432
}
3533

3634
public static inline function getPath(file:String, ?library:String)

source/funkin/backend/system/Main.hx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ class Main extends Sprite
3535
// make this empty once you guys are done with the project.
3636
// good luck /gen <3 @crowplexus
3737
public static final releaseCycle:String = "Beta";
38+
// add a version number in dis shid rn
39+
public static var releaseVersion(get, default):String = null;
40+
public static function get_releaseVersion():String {
41+
if (releaseVersion != null)
42+
return releaseVersion;
43+
44+
return lime.app.Application.current.meta.get('version');
45+
}
3846

3947
public static var instance:Main;
4048

source/funkin/backend/system/framerate/SystemInfo.hx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ class SystemInfo extends FramerateCategory {
4949
if (osName != "")
5050
osInfo = '${osName} ${osVersion}'.trim();
5151
}
52+
#elseif windows
53+
var windowsCurrentVersionPath = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
54+
var buildNumber = Std.parseInt(RegistryUtil.get(HKEY_LOCAL_MACHINE, windowsCurrentVersionPath, "CurrentBuildNumber"));
55+
var edition = RegistryUtil.get(HKEY_LOCAL_MACHINE, windowsCurrentVersionPath, "ProductName");
56+
57+
var lcuKey = "WinREVersion"; // Last Cumulative Update Key On Older Windows Versions
58+
if (buildNumber >= 22000) { // Windows 11 Initial Release Build Number
59+
edition = edition.replace("Windows 10", "Windows 11");
60+
lcuKey = "LCUVer"; // Last Cumulative Update Key On Windows 11
61+
}
62+
63+
var lcuVersion = RegistryUtil.get(HKEY_LOCAL_MACHINE, windowsCurrentVersionPath, lcuKey);
64+
65+
osInfo = edition;
66+
67+
if (lcuVersion != null && lcuVersion != "")
68+
osInfo += ' ${lcuVersion}';
69+
else if (lime.system.System.platformVersion != null && lime.system.System.platformVersion != "")
70+
osInfo += ' ${lime.system.System.platformVersion}';
5271
#else
5372
if (lime.system.System.platformLabel != null && lime.system.System.platformLabel != "" && lime.system.System.platformVersion != null && lime.system.System.platformVersion != "")
5473
osInfo = '${lime.system.System.platformLabel.replace(lime.system.System.platformVersion, "").trim()} ${lime.system.System.platformVersion}';
@@ -58,10 +77,7 @@ class SystemInfo extends FramerateCategory {
5877

5978
try {
6079
#if windows
61-
var process = new HiddenProcess("wmic", ["cpu", "get", "name"]);
62-
if (process.exitCode() != 0) throw 'Could not fetch CPU information';
63-
64-
cpuName = process.stdout.readAll().toString().trim().split("\n")[1].trim();
80+
cpuName = RegistryUtil.get(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString");
6581
#elseif mac
6682
var process = new HiddenProcess("sysctl -a | grep brand_string"); // Somehow this isnt able to use the args but it still works
6783
if (process.exitCode() != 0) throw 'Could not fetch CPU information';

source/funkin/backend/system/modules/FunkinCache.hx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@ class FunkinCache extends AssetCache {
3535
public static function init() {
3636
openfl.utils.Assets.cache = new FunkinCache();
3737

38-
FlxG.signals.preStateSwitch.add(function() {
39-
instance.moveToSecondLayer();
40-
});
38+
FlxG.signals.preStateSwitch.add(() -> instance.moveToSecondLayer());
4139

42-
FlxG.signals.postStateSwitch.add(function() {
43-
instance.clearSecondLayer();
44-
});
40+
FlxG.signals.postStateSwitch.add(() -> instance.clearSecondLayer());
4541
}
4642

4743
public function moveToSecondLayer() {

source/funkin/backend/system/updating/AsyncUpdater.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ class AsyncUpdater {
101101
progress.files = files.length;
102102
progress.step = DOWNLOADING_ASSETS;
103103
trace('starting assets download');
104-
doFile(files.copy(), fileNames.copy(), function() {
104+
doFile(files.copy(), fileNames.copy(), () -> {
105105
progress.curFile = -1;
106106
progress.curFileName = null;
107107
progress.files = 1;
108108
progress.step = DOWNLOADING_EXECUTABLE;
109109
trace('starting exe download');
110-
doFile([exePath], [executableName], function() {
110+
doFile([exePath], [executableName], () -> {
111111
trace('done, starting installation');
112112
installFiles(fileNames);
113113
progress.done = true;

source/funkin/backend/system/updating/UpdateScreen.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class UpdateScreen extends MusicBeatState {
116116
bf.animation.play("loading-anim", true, false, 1);
117117
bf.alpha = 1;
118118

119-
FlxG.camera.fade(0xFF000000, overSound.length / 1000, false, function() {
119+
FlxG.camera.fade(0xFF000000, overSound.length / 1000, false, () -> {
120120
if (updater.executableReplaced) {
121121
#if windows
122122
// the executable has been replaced, restart the game entirely

source/funkin/backend/utils/DiscordUtil.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class DiscordUtil
4747
return;
4848
initialized = true;
4949

50-
discordThread = Thread.create(function()
50+
discordThread = Thread.create(() ->
5151
{
5252
while (true)
5353
{

source/funkin/backend/utils/MemoryUtil.hx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class MemoryUtil {
9292
public static function getMemType():String {
9393
#if windows
9494
var memoryMap:Map<Int, String> = [
95-
0 => "Unknown",
95+
0 => null,
9696
1 => "Other",
9797
2 => "DRAM",
9898
3 => "Synchronous DRAM",
@@ -117,13 +117,23 @@ class MemoryUtil {
117117
22 => "DDR2 FB-DIMM",
118118
24 => "DDR3",
119119
25 => "FBD2",
120-
26 => "DDR4"
120+
26 => "DDR4",
121+
27 => "LPDDR",
122+
28 => "LPDDR2",
123+
29 => "LPDDR3",
124+
30 => "LPDDR4",
125+
31 => "Logical Non-volatile device",
126+
32 => "HBM",
127+
33 => "HBM2",
128+
34 => "DDR5",
129+
35 => "LPDDR5",
130+
36 => "HBM3",
121131
];
122132
var memoryOutput:Int = -1;
123133

124-
var process = new HiddenProcess("wmic", ["memorychip", "get", "SMBIOSMemoryType"]);
134+
var process = new HiddenProcess("powershell", ["-Command", "Get-CimInstance Win32_PhysicalMemory | Select-Object -ExpandProperty SMBIOSMemoryType" ]);
125135
if (process.exitCode() == 0) memoryOutput = Std.int(Std.parseFloat(process.stdout.readAll().toString().trim().split("\n")[1]));
126-
if (memoryOutput != -1) return memoryMap[memoryOutput];
136+
if (memoryOutput != -1) return memoryMap[memoryOutput] == null ? 'Unknown ($memoryOutput)' : memoryMap[memoryOutput];
127137
#elseif mac
128138
var process = new HiddenProcess("system_profiler", ["SPMemoryDataType"]);
129139
var reg = ~/Type: (.+)/;
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package funkin.backend.utils;
2+
3+
enum abstract RegistryHive(Int) {
4+
var HKEY_CLASSES_ROOT = 0x80000000;
5+
var HKEY_CURRENT_USER = 0x80000001;
6+
var HKEY_LOCAL_MACHINE = 0x80000002;
7+
var HKEY_USERS = 0x80000003;
8+
var HKEY_CURRENT_CONFIG = 0x80000005;
9+
}
10+
#if windows
11+
@:cppFileCode('
12+
#include <windows.h>
13+
#include <tchar.h>
14+
#include <string>
15+
#include <vector>
16+
')
17+
#end
18+
class RegistryUtil {
19+
#if windows
20+
@:functionCode('
21+
HKEY hKey;
22+
LONG result;
23+
DWORD dataSize = 0;
24+
DWORD dataType = 0;
25+
26+
std::wstring subkey = std::wstring(key.wchar_str());
27+
std::wstring valname = std::wstring(string.wchar_str());
28+
29+
result = RegOpenKeyExW((HKEY)reinterpret_cast<HKEY>(static_cast<uintptr_t>(hive)), subkey.c_str(), 0, KEY_READ, &hKey);
30+
if (result != ERROR_SUCCESS) return null();
31+
32+
result = RegQueryValueExW(hKey, valname.c_str(), NULL, &dataType, NULL, &dataSize);
33+
if (result != ERROR_SUCCESS || dataSize == 0) {
34+
RegCloseKey(hKey);
35+
return null();
36+
}
37+
38+
std::vector<wchar_t> buffer(dataSize / sizeof(wchar_t));
39+
result = RegQueryValueExW(hKey, valname.c_str(), NULL, NULL, (LPBYTE)buffer.data(), &dataSize);
40+
RegCloseKey(hKey);
41+
42+
if (result == ERROR_SUCCESS) {
43+
return ::String(buffer.data());
44+
}
45+
return null();
46+
')
47+
#end
48+
public static function get(hive:RegistryHive, key:String, string:String):Null<String>
49+
{
50+
return null;
51+
}
52+
53+
#if windows
54+
@:functionCode('
55+
HKEY hKey;
56+
LONG result;
57+
58+
std::wstring subkey = std::wstring(key.wchar_str());
59+
std::wstring valname = std::wstring(string.wchar_str());
60+
std::wstring data = std::wstring(value.wchar_str());
61+
62+
result = RegCreateKeyExW((HKEY)reinterpret_cast<HKEY>(static_cast<uintptr_t>(hive)), subkey.c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
63+
if (result != ERROR_SUCCESS) return false;
64+
65+
result = RegSetValueExW(hKey, valname.c_str(), 0, REG_SZ, (const BYTE*)data.c_str(), (DWORD)((data.length() + 1) * sizeof(wchar_t)));
66+
RegCloseKey(hKey);
67+
68+
return result == ERROR_SUCCESS;
69+
')
70+
#end
71+
public static function set(hive:RegistryHive, key:String, string:String, value:String):Bool
72+
{
73+
return false;
74+
}
75+
76+
#if windows
77+
@:functionCode('
78+
HKEY hKey;
79+
LONG result;
80+
81+
std::wstring subkey = std::wstring(key.wchar_str());
82+
std::wstring valname = std::wstring(string.wchar_str());
83+
84+
result = RegOpenKeyExW((HKEY)reinterpret_cast<HKEY>(static_cast<uintptr_t>(hive)), subkey.c_str(), 0, KEY_READ, &hKey);
85+
if (result != ERROR_SUCCESS) return false;
86+
87+
DWORD dataType = 0;
88+
result = RegQueryValueExW(hKey, valname.c_str(), NULL, &dataType, NULL, NULL);
89+
90+
RegCloseKey(hKey);
91+
92+
return result == ERROR_SUCCESS;
93+
')
94+
#end
95+
public static function exists(hive:RegistryHive, key:String, string:String):Bool
96+
{
97+
return false;
98+
}
99+
100+
#if windows
101+
@:functionCode('
102+
HKEY hKey;
103+
LONG result;
104+
105+
std::wstring subkey = std::wstring(key.wchar_str());
106+
std::wstring valname = std::wstring(string.wchar_str());
107+
108+
result = RegOpenKeyExW((HKEY)reinterpret_cast<HKEY>(static_cast<uintptr_t>(hive)), subkey.c_str(), 0, KEY_SET_VALUE, &hKey);
109+
if (result != ERROR_SUCCESS) return false;
110+
111+
result = RegDeleteValueW(hKey, valname.c_str());
112+
RegCloseKey(hKey);
113+
114+
return result == ERROR_SUCCESS;
115+
')
116+
#end
117+
public static function delete(hive:RegistryHive, key:String, string:String):Bool {
118+
return false;
119+
}
120+
}

0 commit comments

Comments
 (0)