Skip to content

Commit d1ad9bb

Browse files
committed
Holy shit.
1 parent 992b222 commit d1ad9bb

20 files changed

+1913
-296
lines changed

source/Main.hx

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ extern "C" HRESULT WINAPI SetCurrentProcessExplicitAppUserModelID(PCWSTR AppID);
7070
')
7171
#end
7272
// // // // // // // // //
73+
@:autoBuild(yutautil.StatePick.addToDatabase(Main))
7374
class Main extends Sprite
7475
{
7576
public static final game = {
@@ -99,6 +100,85 @@ class Main extends Sprite
99100
trace("Error: " + e);
100101
}
101102
trace("Finished testing forceCast.");
103+
104+
var r:Random<Int> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
105+
trace("Random Test: " + r);
106+
107+
trace("Random Test 2: " + new Random<Int>([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
108+
109+
var r2:Random<Int> = [for (i in 1...11) i];
110+
trace("Random Test 3: " + r2);
111+
112+
113+
var temp:Temp<Int> = 23932;
114+
115+
trace("Temp Test 2: " + temp);
116+
117+
var temp2:Temp<{value:Int, otherValue:Int}> = {
118+
value: 123,
119+
otherValue: 456
120+
};
121+
122+
var nonTemp:{value:Int, otherValue:Int} = {
123+
value: 123,
124+
otherValue: 456
125+
};
126+
127+
var temp2Address = cpp.Native.addressOf(game);
128+
trace("Star test 1: " + temp2Address);
129+
var randofdsde:Temp<Int> = 123;
130+
trace("Temp Test 3: " + randofdsde);
131+
132+
133+
134+
var eeee:Int = 123;
135+
136+
var p = cpp.Pointer.addressOf(eeee)[0];
137+
trace("Pointer Test: " + p);
138+
139+
var funnyDouble = new HaxePointer<Dynamic>(game);
140+
trace("Funny Double Test: " + funnyDouble);
141+
trace("Funny Double Test: " + new HaxePointer<Dynamic>(game));
142+
143+
(new Fields(temp2).printFields());
144+
(new Fields(nonTemp).printFields());
145+
146+
trace("TestAcc: " + new FieldAccTest({}).eeeee);
147+
trace("TestAcc2: " );
148+
var testAcc2 = new FieldAccTest({eeeee: 123}).eeeee = 456;
149+
150+
var collaped:Collapsed<Int> = [[1], [2], [3], [4], [5]];
151+
152+
trace("Collaped Test: " + collaped);
153+
154+
var gaming:GlobalPointer<Dynamic> = game;
155+
156+
// gaming.startFullscreen = true;
157+
158+
// Pointer of a pointer test (HaxePointer of HaxePointer, stacked 5 times)
159+
var arr:Array<Int> = [1, 2, 3, 4, 5];
160+
161+
// var ptr1 = new HaxePointer<Array<Int>>(arr);
162+
// var ptr2 = new HaxePointer<HaxePointer<Array<Int>>>(ptr1);
163+
// var ptr3 = new HaxePointer<HaxePointer<HaxePointer<Array<Int>>>>(ptr2);
164+
// var ptr4 = new HaxePointer<HaxePointer<HaxePointer<HaxePointer<Array<Int>>>>>(ptr3);
165+
// var ptr5 = new HaxePointer<HaxePointer<HaxePointer<HaxePointer<HaxePointer<Array<Int>>>>>>(ptr4);
166+
167+
// // Now resolve the pointer all the way down to the array
168+
// var ptr = ptr5;
169+
// var resolvedArr:Array<Int> = ptr;
170+
171+
172+
// trace("Resolved stacked HaxePointer array: " + resolvedArr);
173+
174+
// // Let's also put the pointer in another array and resolve it
175+
// var pointerArray:Array<Dynamic> = [ptr];
176+
// var resolvedFromArray:Array<Int> = pointerArray[0];
177+
// trace("Resolved from pointerArray: " + resolvedFromArray);
178+
179+
180+
trace("TypeTools ptrMap: " + TypeTools.ptrMap);
181+
102182
Lib.current.addChild(new Main());
103183
//Stolen from Psych Online. Thanks for making the next hour of my life not hell.
104184
Lib.current.addChild(new archipelago.console.SideUI());

source/archipelago/APGameState.hx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,12 @@ class APGameState
472472
}
473473
}
474474

475-
public function getSongLocations(songName:String, modName:String):Array<Int>
475+
public function getSongLocations(songName:String, ?modName:String):Array<Int>
476476
{
477477
return locationData(songName, modName).concat(noteData(songName, modName));
478478
}
479479

480-
public function checkGoal(songName:String, modName:String):Bool
480+
public function checkGoal(songName:String, ?modName:String):Bool
481481
{ modName = (modName != null && modName != "") ? modName.trim() : "";
482482
var info = info();
483483
var locations = locationData(songName, modName).concat(noteData(songName, modName));
@@ -496,6 +496,13 @@ class APGameState
496496
return false;
497497
}
498498

499+
public function songInMultiworld(songName:String, ?modName:String):Bool
500+
{
501+
modName = (modName != null && modName != "") ? modName.trim() : "";
502+
return locationData(songName, modName).length > 0
503+
|| noteData(songName, modName).length > 0;
504+
}
505+
499506
public function setGoal():Void
500507
{
501508
info().set_goal();

source/archipelago/APPlayState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ class APPlayState extends PlayState {
12511251
shieldSprite.visible = false;
12521252
add(shieldSprite);
12531253

1254-
if (cpuControlled || ClientPrefs.getGameplaySetting('showcase', false))
1254+
if (cpuControlled || ClientPrefs.getGameplaySetting('showcase', false) && !(Sys.args().contains('-livereload')))
12551255
{
12561256
//set_cpuControlled(false);
12571257
cpuControlled = false;

source/backend/MusicBeatState.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import flixel.FlxState;
88
import backend.PsychCamera;
99
import archipelago.APEntryState;
1010

11+
@:autoBuild(yutautil.StatePick.addToDatabase(MusicBeatState))
1112
class MusicBeatState extends FlxState
1213
{
1314
private var curSection:Int = 0;
@@ -63,6 +64,10 @@ class MusicBeatState extends FlxState
6364

6465
super.create();
6566

67+
// if (!(this is PlayState) && PlayState.instance != null)
68+
// yutautil.MemoryHelper.freeMemory(PlayState.instance);
69+
70+
6671
// if (backend.window.CppAPI.getWindowOpacity()!=1)
6772
#if windows
6873

source/debug/FPSCounter.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ class FPSCounter extends TextField
207207
#end
208208

209209
if (ClientPrefs.data.showInitialMemoryUsage && initMemory != null && Sys.args().indexOf('-livereload') != -1)
210-
text += '\nInitial Memory: ${flixel.util.FlxStringUtil.formatBytes(initMemory)}';
210+
text += '\nInitial Memory: ${flixel.util.FlxStringUtil.formatBytes(initMemory)}' + '\n' +
211+
'Current State Address: ${new HaxeAddress(FlxG.state)}';
211212
}
212213

213214
function obtainMemory():Dynamic

source/import.hx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ import flixel.addons.transition.FlxTransitionableState;
9494

9595
import yutautil.ImprovedFileHandling;
9696

97+
import yutautil.ChanceSelector;
98+
9799
using StringTools;
98100
using yutautil.CollectionUtils;
99101
using yutautil.MetaData;
@@ -104,5 +106,7 @@ using yutautil.GenericObject;
104106
using yutautil.PyScript;
105107
using yutautil.FieldMap;
106108
using yutautil.Tracked;
107-
using yutautil.OneOrMany;
109+
using yutautil.TypeUtils;
110+
using yutautil.MacroTypeUtils;
111+
using yutautil.RuntimeTypedef;
108112
#end

source/stages/PhillyBlazin.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PhillyBlazin extends BaseStage
2828

2929
override function create()
3030
{
31-
StickerSubState.STICKER_PACK = "weekend";
31+
substates.StickerSubState.STICKER_PACK = "weekend";
3232
FlxTransitionableState.skipNextTransOut = true; //skip the original transition fade
3333
function setupScale(spr:BGSprite)
3434
{

source/states/PlayState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7627,7 +7627,7 @@ class PlayState extends MusicBeatState
76277627

76287628
NoteSplash.configs.clear();
76297629
mania = 3;
7630-
instance = null;
7630+
// instance = null;
76317631
super.destroy();
76327632
endingSong = true;
76337633
Paths.clearStoredWithoutStickers();

source/states/TitleState.hx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,15 @@ class TitleState extends MusicBeatState
8080
super.create();
8181
trace(this.metadata());
8282
for (classthing in this.metadata().super_tree.toIterable())
83-
trace("Ultimate Super Tree for " + classthing + ": " + classthing.metadata().super_tree);
84-
83+
try {
84+
trace("Ultimate Super Tree for " + classthing + ": " + Type.createEmptyInstance(Type.resolveClass(classthing)).metadata().super_tree);
85+
} catch (e:haxe.Exception) {
86+
trace("Error retrieving super tree for " + classthing + ": " + e.message);
87+
trace("Details: " + e.details());
88+
trace("Stack: " + e.stack);
89+
trace("Type: " + Type.getClassName(Type.resolveClass(classthing)));
90+
}
91+
8592
curWacky = FlxG.random.getObject(getIntroTextShit());
8693

8794
if(!initialized)

source/yutautil/ChanceSelector.hx

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,49 @@ typedef ChanceFunction = {
88
func: Void -> Dynamic, // Function to execute
99
chance: Float // Chance of execution, assumed to be between 0 and 100
1010
}
11-
class ChanceSelector {
11+
12+
13+
/**
14+
* Random<T> is an abstract type that allows you to create a random item from an array of items.
15+
* It provides methods to get a random item, set a new array of items, and convert between Random<T> and T.
16+
*/
17+
abstract Random<T>(OneOrMore<T>) {
18+
public inline function new(values:OneOrMore<T>) this = values;
19+
20+
// Returns a random item from the array
21+
@:to public inline function get():T {
22+
if (this == null || this.isEmpty()) throw "Random: No items to select from";
23+
return ChanceExtensions.chanceArray(this);
24+
}
25+
26+
// Sets the array to a new set of items and returns a random item from the new array
27+
@:from
28+
static public inline function set<T>(values:Array<T>):Random<T> {
29+
return new Random<T>((values));
30+
}
31+
32+
@:to public inline function fromArray<T>():T {
33+
return ChanceExtensions.chanceArray(this);
34+
}
35+
@:to public inline function fromArrayOrNull<T>():T {
36+
if (this == null || this.isEmpty()) return null;
37+
return ChanceExtensions.chanceArray(this);
38+
}
39+
40+
@:to public inline function toArray():Array<T> {
41+
return new OneOrMore<T>(this).toArray();
42+
}
43+
44+
@:to public inline function oneOrMore():OneOrMore<T> {
45+
return new OneOrMore<T>(this).toArray();
46+
}
47+
48+
@:from public static inline function fromOneOrMore<T>(values:OneOrMore<T>):Random<T> {
49+
"This is just a constructor for Random<T> from OneOrMore<T>".NativeComment();
50+
return new Random<T>(values);
51+
}
52+
}
53+
class ChanceSelector {
1254
public static function selectOption(options:Array<Chance>, strict:Bool = false, downsize:Bool = true, allowNull:Bool = false):Dynamic {
1355
//trace("Entering selectOption function");
1456
//trace("Input options: " + options);

0 commit comments

Comments
 (0)