Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit 8a2059c

Browse files
committed
Add HScript tools and shaders for enhanced scripting and visual effects
- Implemented Code
1 parent 723ff1c commit 8a2059c

38 files changed

+1314
-7597
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: ['https://easydonate.app/paopun2060']

Project.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@
120120
<haxelib name="tjson" version="1.4.0"/>
121121

122122
<haxelib name="linc_luajit" if="LUA_ALLOWED"/>
123-
<haxelib name="hscript-iris" if="HSCRIPT_ALLOWED" version="1.1.3"/>
123+
<haxelib name="hscript-iris" if="HSCRIPT_ALLOWED"/>
124+
<haxelib name="hscript-improved" if="HSCRIPT_ALLOWED"/>
124125

125126
<!-- Dev Only -->
126-
<section if="NotDeveloper">
127-
<haxelib name="hscript-plus" if="HSCRIPT_ALLOWED"/>
127+
<section unless="NotDeveloper">
128128
<haxelib name="haxe-ws"/>
129129
</section>
130130

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ HyperCode Engine is made for advanced mods.
4545
- `flx3d` and `away3d`[GitHub](https://github.com/TBar09/FNF-tbarEngine)
4646

4747
### Codename Engine's libraries
48-
- 3D model + NDLL support + improved HScript (modified for this engine)
48+
- away3d librarie — [GitHub](https://github.com/CodenameCrew/hscript-improved)
49+
- NDLL support — [GitHub](https://github.com/CodenameCrew/CodenameEngine)
50+
- HScript improved — [GitHub](https://github.com/CodenameCrew/CodenameEngine)
51+
- AudioAnalyzer — [GitHub](https://github.com/CodenameCrew/CodenameEngine)
52+
53+
4954

5055
---
5156

52-
## **Extensions**
57+
## **Extensions ( Current this build supports )**
5358

5459
### **Lua + Haxe**
5560
- `BrainFuck`
@@ -63,7 +68,7 @@ HyperCode Engine is made for advanced mods.
6368

6469
### **Haxe-Only**
6570
- `NdllUtil`
66-
- `Manager3D`
71+
- `AudioAnalyzer`
6772

6873
---
6974

openLog.ps1

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Save current directory
2+
$originalDir = Get-Location
3+
4+
# Parse arguments
5+
$ArgsMap = @{}
6+
$debug = $false
7+
8+
foreach ($arg in $args) {
9+
if ($arg -like "-*") {
10+
$key = $arg.TrimStart("-")
11+
$ArgsMap[$key] = $true
12+
if ($key -eq "debug") {
13+
$debug = $true
14+
}
15+
}
16+
}
17+
18+
# Platform full names and their shortcuts
19+
$platformAliases = @{
20+
"air" = "air"
21+
"android" = "android"
22+
"flash" = "flash"
23+
"html5" = "html5"
24+
"ios" = "ios"
25+
"linux" = "linux"
26+
"mac" = "mac"
27+
"tvos" = "tvos"
28+
"webassembly" = "webassembly"
29+
"windows" = "windows"
30+
31+
# shortcuts
32+
"win" = "windows"
33+
"macos" = "mac"
34+
"and" = "android"
35+
}
36+
37+
$selectedPlatforms = @()
38+
39+
foreach ($key in $ArgsMap.Keys) {
40+
if ($key -ne "debug" -and $platformAliases.ContainsKey($key)) {
41+
$selectedPlatforms += $platformAliases[$key]
42+
}
43+
}
44+
45+
if ($selectedPlatforms.Count -eq 0) {
46+
Write-Error "Please specify at least one platform, e.g. --windows or --win"
47+
exit 1
48+
}
49+
50+
if ($selectedPlatforms.Count -gt 1) {
51+
Write-Error "Please specify only one platform"
52+
exit 1
53+
}
54+
55+
$platform = $selectedPlatforms[0]
56+
57+
# Determine build type
58+
$buildType = if ($debug) { "debug" } else { "release" }
59+
$targetPath = Join-Path -Path "export/$buildType/$platform/bin" -ChildPath "crash"
60+
61+
if (-not (Test-Path $targetPath)) {
62+
Write-Error "Crash folder not found: $targetPath"
63+
exit 1
64+
}
65+
66+
Write-Host "Looking for the most recent file in: $targetPath"
67+
68+
# Get the most recently modified file
69+
$latestFile = Get-ChildItem -Path $targetPath -File | Sort-Object LastWriteTime -Descending | Select-Object -First 1
70+
71+
if ($null -eq $latestFile) {
72+
Write-Error "No files found in the crash folder"
73+
exit 1
74+
}
75+
76+
Write-Host "Opening latest file: $($latestFile.FullName)"
77+
Start-Process -FilePath $latestFile.FullName

source/Main.hx

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ class Main extends Sprite
261261

262262
#if windows
263263
WindowColorMode.setDarkMode();
264+
WindowColorMode.redrawWindowHeader(); // bug fix light window bar.
264265
#end
265266

266267
#if CRASH_HANDLER
@@ -294,24 +295,24 @@ class Main extends Sprite
294295
}
295296
}
296297

297-
function saveCrashReport(content:String):String
298-
{
299-
var path = "./crash/HyperCodeEngine_" + Date.now().toString().replace(" ", "_").replace(":", "'") + ".txt";
300-
301-
if (!FileSystem.exists("./crash/")) {
302-
FileSystem.createDirectory("./crash/");
303-
}
304-
305-
File.saveContent(path, content + "\n");
306-
Sys.println(content);
307-
Sys.println("Crash dump saved in " + Path.normalize(path));
308-
309-
return path;
310-
}
311-
312298
// Code was entirely made by sqirra-rng for their fnf engine named "Izzy Engine", big props to them!!!
313299
// very cool person for real they don't get enough credit for their work
314300
#if CRASH_HANDLER
301+
function saveCrashReport(content:String):String
302+
{
303+
var path = "./crash/HyperCodeEngine_" + Date.now().toString().replace(" ", "_").replace(":", "'") + ".txt";
304+
305+
if (!FileSystem.exists("./crash/")) {
306+
FileSystem.createDirectory("./crash/");
307+
}
308+
309+
File.saveContent(path, content + "\n");
310+
Sys.println(content);
311+
Sys.println("Crash dump saved in " + Path.normalize(path));
312+
313+
return path;
314+
}
315+
315316
function onCrash(e:UncaughtErrorEvent):Void
316317
{
317318
var errMsg:String = "";
@@ -335,25 +336,26 @@ class Main extends Sprite
335336
errMsg += "Date: " + dateNow + "\n";
336337

337338
// Exception stack trace
338-
errMsg += "==== STACK TRACE ====\n";
339-
for (stackItem in callStack)
340-
{
341-
switch (stackItem)
342-
{
343-
case FilePos(s, file, line, column):
344-
errMsg += file + " (line " + line + ")\n";
345-
case CFunction:
346-
errMsg += "C Function\n";
347-
case Module(m):
348-
errMsg += "Module: " + m + "\n";
349-
case Method(classname, method):
350-
errMsg += "Method: " + classname + "." + method + "\n";
351-
case LocalFunction(n):
352-
errMsg += "Local Function: " + n + "\n";
353-
default:
354-
errMsg += "Unknown: " + stackItem + "\n";
355-
}
356-
}
339+
var stackBuf = new StringBuf();
340+
stackBuf.add("==== STACK TRACE ====\n");
341+
var callStack = CallStack.exceptionStack(true);
342+
for (stackItem in callStack) {
343+
switch (stackItem) {
344+
case FilePos(s, file, line, column):
345+
stackBuf.add(" File: " + file + " (line " + line + ")\n");
346+
case CFunction:
347+
stackBuf.add(" C Function\n");
348+
case Module(m):
349+
stackBuf.add(" Module: " + m + "\n");
350+
case Method(classname, method):
351+
stackBuf.add(" Method: " + classname + "." + method + "\n");
352+
case LocalFunction(n):
353+
stackBuf.add(" Local Function: " + n + "\n");
354+
case _:
355+
stackBuf.add(" Unknown stack item: " + Std.string(stackItem) + "\n");
356+
}
357+
}
358+
errMsg += stackBuf.toString();
357359

358360
// Error details
359361
errMsg += "\n==== ERROR DETAILS ====\n";
@@ -407,7 +409,7 @@ class Main extends Sprite
407409
#if LUA_ALLOWED
408410
errMsg += "\n==== MOD INFO ====\n";
409411
errMsg += "Current Mod: " + Mods.currentModDirectory + "\n";
410-
@:privateAccess errMsg += "Global Mods: " + Mods.globalMods.join(", ") + "\n";
412+
@:privateAccess errMsg += "Global Mods:\n" + Mods.globalMods.join('\n ') + "\n";
411413
#end
412414
} catch(e:Dynamic) {
413415
errMsg += "Failed to get mod info: " + e + "\n";
@@ -426,9 +428,16 @@ class Main extends Sprite
426428
var displayMsg = "The game crashed!\n";
427429
displayMsg += "A crash report has been saved to:\n" + Path.normalize(saveCrashReport(errMsg)) + "\n\n";
428430
displayMsg += "Error: " + Std.string(e.error).split("\n")[0] + "\n";
429-
#if officialBuild
430-
displayMsg += "\nPlease report this issue on GitHub.";
431-
#end
431+
#if (officialBuild && !NotDeveloper)
432+
displayMsg += "\nPlease restart the game. If the same crash occurs again, please send the crash report to the GitHub Issues page.\n\n";
433+
displayMsg += "How to send the crash report to the GitHub Issues page?\n";
434+
displayMsg += "- Go to the game folder.\n";
435+
displayMsg += "- Go to the 'crash' folder.\n";
436+
displayMsg += "- Send the latest crash report file to the GitHub Issues page.\n";
437+
#else
438+
displayMsg += "\nHey Developer! Looks like you broke this engine again\n";
439+
displayMsg += "Here's your crash report, enjoy your nightmares! Dev...\n";
440+
#end
432441

433442
Application.current.window.alert(displayMsg, "Crash Report");
434443

source/backend/CacheManager.hx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package backend;
2+
3+
import flixel.graphics.FlxGraphic;
4+
import openfl.media.Sound;
5+
import haxe.ds.StringMap;
6+
7+
class CacheManager
8+
{
9+
private var cachedGraphics:StringMap<FlxGraphic>;
10+
private var cachedSounds:StringMap<Sound>;
11+
12+
public function new()
13+
{
14+
cachedGraphics = new StringMap();
15+
cachedSounds = new StringMap();
16+
}
17+
18+
public function getGraphic(key:String):FlxGraphic
19+
{
20+
return cachedGraphics.get(key);
21+
}
22+
23+
public function addGraphic(key:String, graphic:FlxGraphic):Void
24+
{
25+
cachedGraphics.set(key, graphic);
26+
}
27+
28+
public function removeGraphic(key:String):Void
29+
{
30+
var graphic = cachedGraphics.get(key);
31+
if (graphic != null)
32+
{
33+
@:privateAccess if (graphic.bitmap != null && graphic.bitmap.__texture != null) graphic.bitmap.__texture.dispose();
34+
}
35+
cachedGraphics.remove(key);
36+
}
37+
38+
public function getSound(key:String):Sound
39+
{
40+
return cachedSounds.get(key);
41+
}
42+
43+
public function addSound(key:String, sound:Sound):Void
44+
{
45+
cachedSounds.set(key, sound);
46+
}
47+
48+
public function removeSound(key:String):Void
49+
{
50+
cachedSounds.remove(key);
51+
}
52+
53+
public function clearUnused(usedKeys:Array<String>):Void
54+
{
55+
for (key in cachedGraphics.keys())
56+
{
57+
if (!usedKeys.contains(key))
58+
removeGraphic(key);
59+
}
60+
for (key in cachedSounds.keys())
61+
{
62+
if (!usedKeys.contains(key))
63+
removeSound(key);
64+
}
65+
}
66+
}

source/backend/FFT.hx

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ class FFT {
88
private var sinTable:Array<Float>;
99

1010
public function new(size:Int) {
11-
// must be power of two
12-
if ((size & (size - 1)) != 0) {
13-
throw "FFT size must be a power of two";
14-
}
11+
if ((size & (size - 1)) != 0) throw "FFT size must be a power of two";
12+
1513
this.size = size;
1614
this.log2Size = Std.int(Math.log(size) / Math.log(2));
1715

18-
// build bit-reversal table
1916
bitrev = [];
2017
for (i in 0...size) {
2118
var rev = 0;
@@ -27,21 +24,16 @@ class FFT {
2724
bitrev.push(rev);
2825
}
2926

30-
// precompute twiddle factors
3127
cosTable = [];
3228
sinTable = [];
33-
for (i in 0...Std.int(size/2)) {
29+
for (i in 0...Std.int(size / 2)) {
3430
var angle = -2 * Math.PI * i / size;
3531
cosTable.push(Math.cos(angle));
3632
sinTable.push(Math.sin(angle));
3733
}
3834
}
3935

40-
/**
41-
* In-place radix-2 FFT on real (re) and imaginary (im) arrays.
42-
*/
4336
public function forward(re:Array<Float>, im:Array<Float>):Void {
44-
// 1) bit-reversal reorder
4537
for (i in 0...size) {
4638
var j = bitrev[i];
4739
if (j > i) {
@@ -54,20 +46,18 @@ class FFT {
5446
}
5547
}
5648

57-
// 2) Danielson-Lanczos section
5849
var halfSize = 1;
59-
var tableStep = size >> 1;
60-
for (stage in 1...log2Size+1) {
61-
var step = halfSize << 1;
50+
for (stage in 0...log2Size) {
51+
var step = halfSize * 2;
6252
var twiddleStep = Std.int(size / step);
6353
for (m in 0...halfSize) {
64-
var idx = Std.int(m * twiddleStep);
54+
var idx = m * twiddleStep;
6555
var cosW = cosTable[idx];
6656
var sinW = sinTable[idx];
6757
var k = m;
6858
while (k < size) {
69-
var tRe = cosW * re[k + halfSize] - sinW * im[k + halfSize];
70-
var tIm = sinW * re[k + halfSize] + cosW * im[k + halfSize];
59+
var tRe = cosW * re[k + halfSize] - sinW * im[k + halfSize];
60+
var tIm = sinW * re[k + halfSize] + cosW * im[k + halfSize];
7161
re[k + halfSize] = re[k] - tRe;
7262
im[k + halfSize] = im[k] - tIm;
7363
re[k] += tRe;

source/backend/HealthIconAnimation.hx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ class HealthIconAnimation
6565
apply(typeID, elapsed);
6666
}
6767

68+
public inline function stop():Void
69+
{
70+
apply("Reset", 0);
71+
this.icon = null;
72+
this.animationID = "None";
73+
}
74+
6875
private function updateAnimationType():Void
6976
{
7077
currentAnimationType = animationMap.exists(animationID) ? animationMap.get(animationID) : animationMap.get("None");

0 commit comments

Comments
 (0)