mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-12-24 17:02:50 +00:00
implement reference counted resources
This commit is contained in:
parent
2b6b3b0bc8
commit
3008482ab5
39 changed files with 390 additions and 156 deletions
|
|
@ -8,12 +8,15 @@ import h3d.Vector;
|
|||
import hxd.res.Sound;
|
||||
import src.Settings;
|
||||
import hxd.snd.ChannelGroup;
|
||||
import src.Resource;
|
||||
|
||||
class AudioManager {
|
||||
static var manager:hxd.snd.Manager;
|
||||
static var soundGroup:hxd.snd.SoundGroup;
|
||||
static var musicGroup:hxd.snd.SoundGroup;
|
||||
|
||||
static var currentMusicResource:Resource<Sound>;
|
||||
|
||||
public static function init() {
|
||||
AudioManager.manager = hxd.snd.Manager.get();
|
||||
AudioManager.soundGroup = new SoundGroup("sound");
|
||||
|
|
@ -50,10 +53,14 @@ class AudioManager {
|
|||
|
||||
public static function playShell() {
|
||||
AudioManager.manager.stopByName("music");
|
||||
var snd = ResourceLoader.getAudio("data/sound/shell.ogg");
|
||||
if (snd == null)
|
||||
var sndres = ResourceLoader.getAudio("data/sound/shell.ogg");
|
||||
if (sndres == null)
|
||||
return;
|
||||
var ch = AudioManager.manager.play(snd, null, musicGroup);
|
||||
sndres.acquire();
|
||||
if (currentMusicResource != null)
|
||||
currentMusicResource.release();
|
||||
currentMusicResource = sndres;
|
||||
var ch = AudioManager.manager.play(sndres.resource, null, musicGroup);
|
||||
ch.loop = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,9 @@ class DifBuilder {
|
|||
];
|
||||
|
||||
public static function loadDif(path:String, itr:InteriorObject, ?so:Int = -1) {
|
||||
var dif = ResourceLoader.loadInterior(path);
|
||||
var difresource = ResourceLoader.loadInterior(path);
|
||||
difresource.acquire();
|
||||
var dif = difresource.resource;
|
||||
|
||||
var geo = so == -1 ? dif.interiors[0] : dif.subObjects[so];
|
||||
|
||||
|
|
@ -374,5 +376,7 @@ class DifBuilder {
|
|||
|
||||
var mesh = new Mesh(prim, material, itr);
|
||||
}
|
||||
|
||||
difresource.release();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package src;
|
||||
|
||||
import hxd.res.Sound;
|
||||
import h3d.col.Bounds;
|
||||
import src.TimeState;
|
||||
import shaders.Billboard;
|
||||
|
|
@ -30,6 +31,7 @@ import src.ResourceLoader;
|
|||
import dts.DtsFile;
|
||||
import h3d.Matrix;
|
||||
import src.Util;
|
||||
import src.Resource;
|
||||
|
||||
var DROP_TEXTURE_FOR_ENV_MAP = ['shapes/items/superjump.dts', 'shapes/items/antigravity.dts'];
|
||||
|
||||
|
|
@ -72,6 +74,7 @@ class DtsObject extends GameObject {
|
|||
var dtsPath:String;
|
||||
var directoryPath:String;
|
||||
var dts:DtsFile;
|
||||
var dtsResource:Resource<DtsFile>;
|
||||
|
||||
var level:MarbleWorld;
|
||||
|
||||
|
|
@ -110,7 +113,10 @@ class DtsObject extends GameObject {
|
|||
}
|
||||
|
||||
public function init(level:MarbleWorld) {
|
||||
this.dts = ResourceLoader.loadDts(this.dtsPath);
|
||||
this.dtsResource = ResourceLoader.loadDts(this.dtsPath);
|
||||
this.dtsResource.acquire();
|
||||
this.dts = this.dtsResource.resource;
|
||||
|
||||
this.directoryPath = Path.directory(this.dtsPath);
|
||||
if (level != null)
|
||||
this.level = level;
|
||||
|
|
@ -300,7 +306,7 @@ class DtsObject extends GameObject {
|
|||
var completion = 0 / (iflSequence[0].duration);
|
||||
var keyframe = Math.floor(completion * info.length) % info.length;
|
||||
var currentFile = info[keyframe];
|
||||
var texture = ResourceLoader.getTexture(this.directoryPath + '/' + currentFile);
|
||||
var texture = ResourceLoader.getResource(this.directoryPath + '/' + currentFile, ResourceLoader.getTexture, this.textureResources);
|
||||
|
||||
var flags = this.dts.matFlags[i];
|
||||
if (flags & 1 > 0 || flags & 2 > 0)
|
||||
|
|
@ -363,7 +369,7 @@ class DtsObject extends GameObject {
|
|||
this.materialInfos.set(material, keyframes);
|
||||
iflMaterial = true;
|
||||
} else {
|
||||
var texture:Texture = ResourceLoader.getTexture(fullName);
|
||||
var texture = ResourceLoader.getResource(fullName, ResourceLoader.getTexture, this.textureResources);
|
||||
texture.wrap = Wrap.Repeat;
|
||||
material.texture = texture;
|
||||
// if (this.useInstancing) {
|
||||
|
|
@ -393,7 +399,7 @@ class DtsObject extends GameObject {
|
|||
#end
|
||||
// Apparently creating these bitmap datas dont work so we'll just get the snag a white texture in the filesystem
|
||||
#if js
|
||||
var texture:Texture = ResourceLoader.getTexture("data/interiors/parts/white.jpg");
|
||||
var texture:Texture = ResourceLoader.getResource("data/interiors/parts/white.jpg", ResourceLoader.getTexture, this.textureResources);
|
||||
texture.wrap = Wrap.Repeat;
|
||||
#end
|
||||
material.texture = texture;
|
||||
|
|
@ -855,7 +861,7 @@ class DtsObject extends GameObject {
|
|||
var completion = timeState.timeSinceLoad / (iflSequence[0].duration);
|
||||
var keyframe = Math.floor(completion * info.length) % info.length;
|
||||
var currentFile = info[keyframe];
|
||||
var texture = ResourceLoader.getTexture(this.directoryPath + '/' + currentFile);
|
||||
var texture = ResourceLoader.getResource(this.directoryPath + '/' + currentFile, ResourceLoader.getTexture, this.textureResources);
|
||||
|
||||
var flags = this.dts.matFlags[i];
|
||||
if (flags & 1 > 0 || flags & 2 > 0)
|
||||
|
|
@ -938,4 +944,9 @@ class DtsObject extends GameObject {
|
|||
public function setCollisionEnabled(flag:Bool) {
|
||||
this.isCollideable = flag;
|
||||
}
|
||||
|
||||
public override function dispose() {
|
||||
super.dispose();
|
||||
this.dtsResource.release();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ package src;
|
|||
import src.TimeState;
|
||||
import collision.CollisionInfo;
|
||||
import h3d.scene.Object;
|
||||
import src.Resource;
|
||||
import h3d.mat.Texture;
|
||||
import hxd.res.Sound;
|
||||
|
||||
class GameObject extends Object {
|
||||
public var identifier:String;
|
||||
|
|
@ -10,6 +13,9 @@ class GameObject extends Object {
|
|||
public var isCollideable:Bool = false;
|
||||
public var isBoundingBoxCollideable:Bool = true;
|
||||
|
||||
var textureResources:Array<Resource<Texture>> = [];
|
||||
var soundResources:Array<Resource<Sound>> = [];
|
||||
|
||||
public function onMarbleContact(time:TimeState, ?contact:CollisionInfo) {}
|
||||
|
||||
public function onMarbleInside(time:TimeState) {}
|
||||
|
|
@ -21,4 +27,13 @@ class GameObject extends Object {
|
|||
public function onLevelStart() {}
|
||||
|
||||
public function reset() {}
|
||||
|
||||
public function dispose() {
|
||||
for (textureResource in textureResources) {
|
||||
textureResource.release();
|
||||
}
|
||||
for (audioResource in soundResources) {
|
||||
audioResource.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class Main extends hxd.App {
|
|||
var marbleGame:MarbleGame;
|
||||
|
||||
// var fpsCounter:Text;
|
||||
var debugProfiler:h3d.impl.Benchmark;
|
||||
var loaded:Bool = false;
|
||||
|
||||
override function init() {
|
||||
|
|
@ -39,6 +40,8 @@ class Main extends hxd.App {
|
|||
|
||||
// world.init();
|
||||
// world.start();
|
||||
// debugProfiler = new h3d.impl.Benchmark(s2d);
|
||||
// debugProfiler.y = 40;
|
||||
|
||||
// fpsCounter = new Text(DefaultFont.get(), s2d);
|
||||
// fpsCounter.y = 40;
|
||||
|
|
@ -59,8 +62,12 @@ class Main extends hxd.App {
|
|||
|
||||
override function render(e:h3d.Engine) {
|
||||
// this.world.render(e);
|
||||
if (loaded)
|
||||
if (loaded) {
|
||||
// debugProfiler.begin();
|
||||
// debugProfiler.measure("marbleGame");
|
||||
marbleGame.render(e);
|
||||
// debugProfiler.end();
|
||||
}
|
||||
super.render(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ import h3d.prim.Sphere;
|
|||
import h3d.scene.Object;
|
||||
import src.MarbleGame;
|
||||
import src.CameraController;
|
||||
import src.Resource;
|
||||
import h3d.mat.Texture;
|
||||
|
||||
class Move {
|
||||
public var d:Vector;
|
||||
|
|
@ -200,21 +202,26 @@ class Marble extends GameObject {
|
|||
|
||||
this.bounceEmitterData = new ParticleData();
|
||||
this.bounceEmitterData.identifier = "MarbleBounceParticle";
|
||||
this.bounceEmitterData.texture = ResourceLoader.getTexture("data/particles/star.png");
|
||||
this.bounceEmitterData.texture = ResourceLoader.getResource("data/particles/star.png", ResourceLoader.getTexture, this.textureResources);
|
||||
|
||||
this.trailEmitterData = new ParticleData();
|
||||
this.trailEmitterData.identifier = "MarbleTrailParticle";
|
||||
this.trailEmitterData.texture = ResourceLoader.getTexture("data/particles/smoke.png");
|
||||
this.trailEmitterData.texture = ResourceLoader.getResource("data/particles/smoke.png", ResourceLoader.getTexture, this.textureResources);
|
||||
|
||||
this.rollSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/rolling_hard.wav"), this.getAbsPos().getPosition(), true);
|
||||
this.slipSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/sliding.wav"), this.getAbsPos().getPosition(), true);
|
||||
this.rollSound = AudioManager.playSound(ResourceLoader.getResource("data/sound/rolling_hard.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
this.getAbsPos().getPosition(), true);
|
||||
this.slipSound = AudioManager.playSound(ResourceLoader.getResource("data/sound/sliding.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
this.getAbsPos().getPosition(), true);
|
||||
this.rollSound.volume = 0;
|
||||
this.slipSound.volume = 0;
|
||||
this.shockabsorberSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/superbounceactive.wav"), null, true);
|
||||
this.shockabsorberSound = AudioManager.playSound(ResourceLoader.getResource("data/sound/superbounceactive.wav", ResourceLoader.getAudio,
|
||||
this.soundResources), null, true);
|
||||
this.shockabsorberSound.pause = true;
|
||||
this.superbounceSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/forcefield.wav"), null, true);
|
||||
this.superbounceSound = AudioManager.playSound(ResourceLoader.getResource("data/sound/forcefield.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
null, true);
|
||||
this.superbounceSound.pause = true;
|
||||
this.helicopterSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/use_gyrocopter.wav"), null, true);
|
||||
this.helicopterSound = AudioManager.playSound(ResourceLoader.getResource("data/sound/use_gyrocopter.wav", ResourceLoader.getAudio,
|
||||
this.soundResources), null, true);
|
||||
this.helicopterSound.pause = true;
|
||||
}
|
||||
|
||||
|
|
@ -291,13 +298,13 @@ class Marble extends GameObject {
|
|||
if (contact.force != 0 && !forceObjects.contains(contact.otherObject)) {
|
||||
if (contact.otherObject is RoundBumper) {
|
||||
if (!playedSounds.contains("data/sound/bumperding1.wav")) {
|
||||
AudioManager.playSound(ResourceLoader.getAudio("data/sound/bumperding1.wav"));
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/bumperding1.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
playedSounds.push("data/sound/bumperding1.wav");
|
||||
}
|
||||
}
|
||||
if (contact.otherObject is TriangleBumper) {
|
||||
if (!playedSounds.contains("data/sound/bumper1.wav")) {
|
||||
AudioManager.playSound(ResourceLoader.getAudio("data/sound/bumper1.wav"));
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/bumper1.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
playedSounds.push("data/sound/bumper1.wav");
|
||||
}
|
||||
}
|
||||
|
|
@ -545,7 +552,7 @@ class Marble extends GameObject {
|
|||
if (sv < this._jumpImpulse) {
|
||||
this.velocity = this.velocity.add(bestContact.normal.multiply((this._jumpImpulse - sv)));
|
||||
if (!playedSounds.contains("data/sound/jump.wav")) {
|
||||
AudioManager.playSound(ResourceLoader.getAudio("data/sound/jump.wav"));
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/jump.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
playedSounds.push("data/sound/jump.wav");
|
||||
}
|
||||
}
|
||||
|
|
@ -658,7 +665,7 @@ class Marble extends GameObject {
|
|||
"data/sound/bouncehard3.wav",
|
||||
"data/sound/bouncehard4.wav"
|
||||
];
|
||||
var snd = ResourceLoader.getAudio(sndList[bounceSoundNum]);
|
||||
var snd = ResourceLoader.getResource(sndList[bounceSoundNum], ResourceLoader.getAudio, this.soundResources);
|
||||
var gain = bounceMinGain;
|
||||
gain = Util.clamp(Math.pow(contactVel / 12, 1.5), 0, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ import src.InteriorObject;
|
|||
import h3d.scene.Scene;
|
||||
import collision.CollisionWorld;
|
||||
import src.Marble;
|
||||
import src.Resource;
|
||||
|
||||
class MarbleWorld extends Scheduler {
|
||||
public var collisionWorld:CollisionWorld;
|
||||
|
|
@ -131,6 +132,9 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
var _loadingLength:Int = 0;
|
||||
|
||||
var textureResources:Array<Resource<h3d.mat.Texture>> = [];
|
||||
var soundResources:Array<Resource<Sound>> = [];
|
||||
|
||||
public function new(scene:Scene, scene2d:h2d.Scene, mission:Mission) {
|
||||
this.scene = scene;
|
||||
this.scene2d = scene2d;
|
||||
|
|
@ -175,7 +179,7 @@ class MarbleWorld extends Scheduler {
|
|||
'data/sound/classic vibe.ogg',
|
||||
'data/sound/beach party.ogg'
|
||||
][(mission.index + 1) % 3];
|
||||
AudioManager.playMusic(ResourceLoader.getAudio(musicFileName));
|
||||
AudioManager.playMusic(ResourceLoader.getResource(musicFileName, ResourceLoader.getAudio, this.soundResources));
|
||||
});
|
||||
this.resourceLoadFuncs.push(() -> {
|
||||
this.addSimGroup(this.mission.root);
|
||||
|
|
@ -296,22 +300,22 @@ class MarbleWorld extends Scheduler {
|
|||
this.newOrientationQuat = new Quat();
|
||||
this.deselectPowerUp();
|
||||
|
||||
AudioManager.playSound(ResourceLoader.getAudio('data/sound/spawn.wav'));
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
|
||||
this.clearSchedule();
|
||||
this.schedule(0.5, () -> {
|
||||
// setCenterText('ready');
|
||||
AudioManager.playSound(ResourceLoader.getAudio('data/sound/ready.wav'));
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/ready.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
return 0;
|
||||
});
|
||||
this.schedule(2, () -> {
|
||||
// setCenterText('set');
|
||||
AudioManager.playSound(ResourceLoader.getAudio('data/sound/set.wav'));
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/set.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
return 0;
|
||||
});
|
||||
this.schedule(3.5, () -> {
|
||||
// setCenterText('go');
|
||||
AudioManager.playSound(ResourceLoader.getAudio('data/sound/go.wav'));
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/go.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
return 0;
|
||||
});
|
||||
|
||||
|
|
@ -760,7 +764,7 @@ class MarbleWorld extends Scheduler {
|
|||
this.bonusTime = 0;
|
||||
}
|
||||
if (timeTravelSound == null) {
|
||||
var ttsnd = ResourceLoader.getAudio("data/sound/timetravelactive.wav");
|
||||
var ttsnd = ResourceLoader.getResource("data/sound/timetravelactive.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
timeTravelSound = AudioManager.playSound(ttsnd, null, true);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -847,7 +851,7 @@ class MarbleWorld extends Scheduler {
|
|||
if (this.gemCount == this.totalGems) {
|
||||
string = "You have all the gems, head for the finish!";
|
||||
// if (!this.rewinding)
|
||||
AudioManager.playSound(ResourceLoader.getAudio('data/sound/gotallgems.wav'));
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/gotallgems.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
|
||||
// Some levels with this package end immediately upon collection of all gems
|
||||
// if (this.mission.misFile.activatedPackages.includes('endWithTheGems')) {
|
||||
|
|
@ -866,7 +870,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
// if (!this.rewinding)
|
||||
AudioManager.playSound(ResourceLoader.getAudio('data/sound/gotgem.wav'));
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/gotgem.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
}
|
||||
|
||||
displayAlert(string);
|
||||
|
|
@ -959,7 +963,7 @@ class MarbleWorld extends Scheduler {
|
|||
return;
|
||||
|
||||
if (this.gemCount < this.totalGems) {
|
||||
AudioManager.playSound(ResourceLoader.getAudio('data/sound/missinggems.wav'));
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/missinggems.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
displayAlert("You can't finish without all the gems!!");
|
||||
} else {
|
||||
this.endPad.spawnFirework(this.timeState);
|
||||
|
|
@ -1077,7 +1081,7 @@ class MarbleWorld extends Scheduler {
|
|||
// sky.follow = null;
|
||||
// this.oobCameraPosition = camera.position.clone();
|
||||
playGui.setCenterText('outofbounds');
|
||||
AudioManager.playSound(ResourceLoader.getAudio('data/sound/whoosh.wav'));
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/whoosh.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
// if (this.replay.mode != = 'playback')
|
||||
this.schedule(this.timeState.currentAttemptTime + 2, () -> this.restart());
|
||||
}
|
||||
|
|
@ -1096,6 +1100,31 @@ class MarbleWorld extends Scheduler {
|
|||
public function dispose() {
|
||||
this.playGui.dispose();
|
||||
scene.removeChildren();
|
||||
|
||||
for (interior in this.interiors) {
|
||||
interior.dispose();
|
||||
}
|
||||
for (pathedInteriors in this.pathedInteriors) {
|
||||
pathedInteriors.dispose();
|
||||
}
|
||||
for (marble in this.marbles) {
|
||||
marble.dispose();
|
||||
}
|
||||
for (dtsObject in this.dtsObjects) {
|
||||
dtsObject.dispose();
|
||||
}
|
||||
for (trigger in this.triggers) {
|
||||
trigger.dispose();
|
||||
}
|
||||
for (soundResource in this.soundResources) {
|
||||
soundResource.release();
|
||||
}
|
||||
for (textureResource in this.textureResources) {
|
||||
textureResource.release();
|
||||
}
|
||||
|
||||
sky.dispose();
|
||||
|
||||
this._disposed = true;
|
||||
AudioManager.stopAllSounds();
|
||||
AudioManager.playShell();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import mis.MissionElement.MissionElementType;
|
|||
import mis.MisFile;
|
||||
import mis.MissionElement.MissionElementSimGroup;
|
||||
import src.ResourceLoader;
|
||||
import hxd.res.Image;
|
||||
import src.Resource;
|
||||
|
||||
class Mission {
|
||||
public var root:MissionElementSimGroup;
|
||||
|
|
@ -25,6 +27,8 @@ class Mission {
|
|||
public var id:Int;
|
||||
public var isClaMission:Bool;
|
||||
|
||||
var imageResources:Array<Resource<Image>> = [];
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function load() {
|
||||
|
|
@ -33,6 +37,12 @@ class Mission {
|
|||
root = contents.root;
|
||||
}
|
||||
|
||||
public function dispose() {
|
||||
for (imageResource in imageResources) {
|
||||
imageResource.release();
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromMissionInfo(path:String, mInfo:MissionElementScriptObject) {
|
||||
var mission = new Mission();
|
||||
mission.path = path;
|
||||
|
|
@ -57,10 +67,10 @@ class Mission {
|
|||
if (!this.isClaMission) {
|
||||
var basename = haxe.io.Path.withoutExtension(this.path);
|
||||
if (ResourceLoader.fileSystem.exists(basename + ".png")) {
|
||||
return ResourceLoader.getImage(basename + ".png").toTile();
|
||||
return ResourceLoader.getResource(basename + ".png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
}
|
||||
if (ResourceLoader.fileSystem.exists(basename + ".jpg")) {
|
||||
return ResourceLoader.getImage(basename + ".jpg").toTile();
|
||||
return ResourceLoader.getResource(basename + ".jpg", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
}
|
||||
var img = new BitmapData(1, 1);
|
||||
img.setPixel(0, 0, 0);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import h3d.Vector;
|
|||
import src.Util;
|
||||
import src.PathedInteriorMarker;
|
||||
import src.InteriorObject;
|
||||
import src.Resource;
|
||||
|
||||
typedef PIState = {
|
||||
var currentTime:Float;
|
||||
|
|
@ -131,7 +132,8 @@ class PathedInterior extends InteriorObject {
|
|||
}
|
||||
|
||||
if (this.element.datablock.toLowerCase() == "pathedmovingblock") {
|
||||
this.soundChannel = AudioManager.playSound(ResourceLoader.getAudio("data/sound/movingblockloop.wav"), new Vector(), true);
|
||||
this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/movingblockloop.wav", ResourceLoader.getAudio,
|
||||
this.soundResources), new Vector(), true);
|
||||
}
|
||||
|
||||
this.reset();
|
||||
|
|
|
|||
31
src/Resource.hx
Normal file
31
src/Resource.hx
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package src;
|
||||
|
||||
class Resource<T> {
|
||||
public var resource:T;
|
||||
public var identifier:String;
|
||||
|
||||
var referenceCount:Int = 0;
|
||||
var resourceMap:Map<String, Resource<T>>;
|
||||
var disposeFunc:T->Void;
|
||||
|
||||
public function new(resource:T, identifier:String, resList:Map<String, Resource<T>>, disposeFunc:T->Void) {
|
||||
this.resource = resource;
|
||||
this.resourceMap = resList;
|
||||
this.disposeFunc = disposeFunc;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public function acquire() {
|
||||
this.referenceCount++;
|
||||
trace('Acquiring Resource ${this.identifier}: ${this.referenceCount}');
|
||||
}
|
||||
|
||||
public function release() {
|
||||
this.referenceCount--;
|
||||
if (this.referenceCount == 0) {
|
||||
disposeFunc(this.resource);
|
||||
this.resourceMap.remove(this.identifier);
|
||||
trace('Releasing Resource ${this.identifier}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import hxd.fs.LocalFileSystem;
|
|||
import hxd.fs.FileSystem;
|
||||
import hxd.res.Loader;
|
||||
import fs.ManifestProgress;
|
||||
import src.Resource;
|
||||
|
||||
class ResourceLoader {
|
||||
#if hl
|
||||
|
|
@ -27,11 +28,11 @@ class ResourceLoader {
|
|||
#if js
|
||||
public static var loader:Loader = null;
|
||||
#end
|
||||
static var interiorResources:Map<String, Dif> = new Map();
|
||||
static var dtsResources:Map<String, DtsFile> = new Map();
|
||||
static var textureCache:Map<String, Texture> = new Map();
|
||||
static var imageCache:Map<String, Image> = new Map();
|
||||
static var audioCache:Map<String, Sound> = new Map();
|
||||
static var interiorResources:Map<String, Resource<Dif>> = new Map();
|
||||
static var dtsResources:Map<String, Resource<DtsFile>> = new Map();
|
||||
static var textureCache:Map<String, Resource<Texture>> = new Map();
|
||||
static var imageCache:Map<String, Resource<Image>> = new Map();
|
||||
static var audioCache:Map<String, Resource<Sound>> = new Map();
|
||||
|
||||
// static var threadPool:FixedThreadPool = new FixedThreadPool(4);
|
||||
|
||||
|
|
@ -63,11 +64,12 @@ class ResourceLoader {
|
|||
// var lock = new Lock();
|
||||
// threadPool.run(() -> {
|
||||
itr = Dif.LoadFromBuffer(fileSystem.get(path).getBytes());
|
||||
interiorResources.set(path, itr);
|
||||
var itrresource = new Resource(itr, path, interiorResources, dif -> {});
|
||||
interiorResources.set(path, itrresource);
|
||||
// lock.release();
|
||||
// });
|
||||
// lock.wait();
|
||||
return itr;
|
||||
return itrresource;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,11 +84,12 @@ class ResourceLoader {
|
|||
// var lock = new Lock();
|
||||
// threadPool.run(() -> {
|
||||
dts.read(path);
|
||||
dtsResources.set(path, dts);
|
||||
var dtsresource = new Resource(dts, path, dtsResources, dtsFile -> {});
|
||||
dtsResources.set(path, dtsresource);
|
||||
// lock.release();
|
||||
// });
|
||||
// lock.wait();
|
||||
return dts;
|
||||
return dtsresource;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -104,9 +107,10 @@ class ResourceLoader {
|
|||
var tex = img.toTexture();
|
||||
tex.mipMap = Nearest;
|
||||
// tex.filter = Nearest;
|
||||
textureCache.set(path, tex);
|
||||
var textureresource = new Resource(tex, path, textureCache, tex -> tex.dispose());
|
||||
textureCache.set(path, textureresource);
|
||||
|
||||
return tex;
|
||||
return textureresource;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -119,8 +123,9 @@ class ResourceLoader {
|
|||
return imageCache.get(path);
|
||||
if (fileSystem.exists(path)) {
|
||||
var tex = loader.load(path).toImage();
|
||||
imageCache.set(path, tex);
|
||||
return tex;
|
||||
var imageresource = new Resource(tex, path, imageCache, img -> {});
|
||||
imageCache.set(path, imageresource);
|
||||
return imageresource;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -133,8 +138,21 @@ class ResourceLoader {
|
|||
return audioCache.get(path);
|
||||
if (fileSystem.exists(path)) {
|
||||
var snd = loader.load(path).toSound();
|
||||
audioCache.set(path, snd);
|
||||
return snd;
|
||||
var audioresource = new Resource(snd, path, audioCache, snd -> snd.dispose());
|
||||
audioCache.set(path, audioresource);
|
||||
return audioresource;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getResource<T>(path:String, resourceAcquirerer:String->Null<Resource<T>>, resourceCollector:Array<Resource<T>>) {
|
||||
var res = resourceAcquirerer(path);
|
||||
if (res != null) {
|
||||
if (!resourceCollector.contains(res)) {
|
||||
res.acquire();
|
||||
resourceCollector.push(res);
|
||||
}
|
||||
return res.resource;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
12
src/Sky.hx
12
src/Sky.hx
|
|
@ -12,10 +12,14 @@ import h3d.mat.Texture;
|
|||
import haxe.io.Path;
|
||||
import src.ResourceLoader;
|
||||
import h3d.scene.Object;
|
||||
import src.Resource;
|
||||
import hxd.res.Image;
|
||||
|
||||
class Sky extends Object {
|
||||
public var dmlPath:String;
|
||||
|
||||
var imageResources:Array<Resource<Image>> = [];
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
}
|
||||
|
|
@ -47,6 +51,12 @@ class Sky extends Object {
|
|||
// skyMesh.material.shadows = false;
|
||||
}
|
||||
|
||||
public function dispose() {
|
||||
for (imageResource in imageResources) {
|
||||
imageResource.release();
|
||||
}
|
||||
}
|
||||
|
||||
function createSkyboxCubeTextured(dmlPath:String) {
|
||||
#if js
|
||||
dmlPath = StringTools.replace(dmlPath, "data/", "");
|
||||
|
|
@ -67,7 +77,7 @@ class Sky extends Object {
|
|||
if (filenames.length == 0) {
|
||||
skyboxImages.push(new BitmapData(128, 128));
|
||||
} else {
|
||||
var image = ResourceLoader.getImage(filenames[0]).toBitmap();
|
||||
var image = ResourceLoader.getResource(filenames[0], ResourceLoader.getImage, this.imageResources).toBitmap();
|
||||
skyboxImages.push(image);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ class EndGameGui extends GuiControl {
|
|||
this.mission = mission;
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getImage('${path}_n.png').toTile();
|
||||
var hover = ResourceLoader.getImage('${path}_h.png').toTile();
|
||||
var pressed = ResourceLoader.getImage('${path}_d.png').toTile();
|
||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return [normal, hover, pressed];
|
||||
}
|
||||
|
||||
var pg = new GuiImage(ResourceLoader.getImage("data/ui/play/playgui.png").toTile());
|
||||
var pg = new GuiImage(ResourceLoader.getResource("data/ui/play/playgui.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
pg.horizSizing = Center;
|
||||
pg.vertSizing = Center;
|
||||
pg.position = new Vector(77, 9);
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ class EnterNameDlg extends GuiControl {
|
|||
this.vertSizing = Height;
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getImage('${path}_n.png').toTile();
|
||||
var hover = ResourceLoader.getImage('${path}_h.png').toTile();
|
||||
var pressed = ResourceLoader.getImage('${path}_d.png').toTile();
|
||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return [normal, hover, pressed];
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ class EnterNameDlg extends GuiControl {
|
|||
}
|
||||
}
|
||||
|
||||
var dlg = new GuiImage(ResourceLoader.getImage("data/ui/common/dialog.png").toTile());
|
||||
var dlg = new GuiImage(ResourceLoader.getResource("data/ui/common/dialog.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
dlg.horizSizing = Center;
|
||||
dlg.vertSizing = Center;
|
||||
dlg.position = new Vector(112, 111);
|
||||
|
|
@ -72,7 +72,7 @@ class EnterNameDlg extends GuiControl {
|
|||
}
|
||||
dlg.addChild(okbutton);
|
||||
|
||||
var wnd = new GuiImage(ResourceLoader.getImage("data/ui/common/window.png").toTile());
|
||||
var wnd = new GuiImage(ResourceLoader.getResource("data/ui/common/window.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
wnd.position = new Vector(58, 124);
|
||||
wnd.extent = new Vector(295, 55);
|
||||
dlg.addChild(wnd);
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ class ExitGameDlg extends GuiControl {
|
|||
this.extent = new Vector(640, 480);
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getImage('${path}_n.png').toTile();
|
||||
var hover = ResourceLoader.getImage('${path}_h.png').toTile();
|
||||
var pressed = ResourceLoader.getImage('${path}_d.png').toTile();
|
||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return [normal, hover, pressed];
|
||||
}
|
||||
|
||||
var dialogImg = new GuiImage(ResourceLoader.getImage("data/ui/common/dialog.png").toTile());
|
||||
var dialogImg = new GuiImage(ResourceLoader.getResource("data/ui/common/dialog.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
dialogImg.horizSizing = Center;
|
||||
dialogImg.vertSizing = Center;
|
||||
dialogImg.position = new Vector(134, 148);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class GuiButton extends GuiAnim {
|
|||
var renderRect = getRenderRectangle();
|
||||
if (renderRect.inRect(mouseState.position) && !disabled) {
|
||||
if (buttonSounds && Key.isPressed(Key.MOUSE_LEFT)) {
|
||||
AudioManager.playSound(ResourceLoader.getAudio("data/sound/buttonpress.wav"));
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/buttonpress.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
}
|
||||
}
|
||||
if (buttonType == Normal) {
|
||||
|
|
@ -87,7 +87,7 @@ class GuiButton extends GuiAnim {
|
|||
super.onMouseEnter(mouseState);
|
||||
|
||||
if (buttonSounds) {
|
||||
AudioManager.playSound(ResourceLoader.getAudio("data/sound/buttonover.wav"));
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/buttonover.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
package gui;
|
||||
|
||||
import hxd.res.Image;
|
||||
import h2d.Graphics;
|
||||
import hxd.Key;
|
||||
import h2d.Scene;
|
||||
import h2d.col.Bounds;
|
||||
import hxd.Window;
|
||||
import h3d.Vector;
|
||||
import src.Resource;
|
||||
import hxd.res.Sound;
|
||||
import h3d.mat.Texture;
|
||||
|
||||
enum HorizSizing {
|
||||
Right;
|
||||
|
|
@ -43,6 +47,10 @@ class GuiControl {
|
|||
var _entered:Bool = false;
|
||||
var _skipNextEvent:Bool = false;
|
||||
|
||||
var imageResources:Array<Resource<Image>> = [];
|
||||
var textureResources:Array<Resource<Texture>> = [];
|
||||
var soundResources:Array<Resource<Sound>> = [];
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function render(scene2d:Scene) {
|
||||
|
|
@ -191,6 +199,16 @@ class GuiControl {
|
|||
c.dispose();
|
||||
}
|
||||
this.children = [];
|
||||
|
||||
for (textureResource in textureResources) {
|
||||
textureResource.release();
|
||||
}
|
||||
for (imageResource in imageResources) {
|
||||
imageResource.release();
|
||||
}
|
||||
for (audioResource in soundResources) {
|
||||
audioResource.release();
|
||||
}
|
||||
}
|
||||
|
||||
public function onMouseDown(mouseState:MouseState) {}
|
||||
|
|
|
|||
|
|
@ -34,13 +34,14 @@ class HelpCreditsGui extends GuiImage {
|
|||
var superBounceCtrl:GuiObjectShow;
|
||||
|
||||
public function new() {
|
||||
super(ResourceLoader.getImage("data/ui/background.jpg").toTile());
|
||||
var img = ResourceLoader.getImage("data/ui/background.jpg");
|
||||
super(img.resource.toTile());
|
||||
this.position = new Vector();
|
||||
this.extent = new Vector(640, 480);
|
||||
this.horizSizing = Width;
|
||||
this.vertSizing = Height;
|
||||
|
||||
var helpGui = new GuiImage(ResourceLoader.getImage("data/ui/help/help_gui.png").toTile());
|
||||
var helpGui = new GuiImage(ResourceLoader.getResource("data/ui/help/help_gui.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
helpGui.horizSizing = Center;
|
||||
helpGui.vertSizing = Center;
|
||||
helpGui.position = new Vector(15, 10);
|
||||
|
|
@ -48,9 +49,9 @@ class HelpCreditsGui extends GuiImage {
|
|||
this.addChild(helpGui);
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getImage('${path}_n.png').toTile();
|
||||
var hover = ResourceLoader.getImage('${path}_h.png').toTile();
|
||||
var pressed = ResourceLoader.getImage('${path}_d.png').toTile();
|
||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return [normal, hover, pressed];
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +75,7 @@ class HelpCreditsGui extends GuiImage {
|
|||
}
|
||||
helpGui.addChild(homeButton);
|
||||
|
||||
var helpWindow = new GuiImage(ResourceLoader.getImage("data/ui/help/help_window.png").toTile());
|
||||
var helpWindow = new GuiImage(ResourceLoader.getResource("data/ui/help/help_window.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
helpWindow.position = new Vector(30, 31);
|
||||
helpWindow.extent = new Vector(549, 338);
|
||||
helpGui.addChild(helpWindow);
|
||||
|
|
|
|||
|
|
@ -9,22 +9,23 @@ class LoadingGui extends GuiImage {
|
|||
public var setProgress:Float->Void;
|
||||
|
||||
public function new(missionName:String) {
|
||||
super(ResourceLoader.getImage("data/ui/background.jpg").toTile());
|
||||
var img = ResourceLoader.getImage("data/ui/background.jpg");
|
||||
super(img.resource.toTile());
|
||||
this.horizSizing = Width;
|
||||
this.vertSizing = Height;
|
||||
this.extent = new Vector(640, 480);
|
||||
this.position = new Vector();
|
||||
|
||||
var loadingGui = new GuiImage(ResourceLoader.getImage("data/ui/loading/loadinggui.png").toTile());
|
||||
var loadingGui = new GuiImage(ResourceLoader.getResource("data/ui/loading/loadinggui.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
loadingGui.horizSizing = Center;
|
||||
loadingGui.vertSizing = Center;
|
||||
loadingGui.position = new Vector(86, 77);
|
||||
loadingGui.extent = new Vector(468, 325);
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getImage('${path}_n.png').toTile();
|
||||
var hover = ResourceLoader.getImage('${path}_h.png').toTile();
|
||||
var pressed = ResourceLoader.getImage('${path}_d.png').toTile();
|
||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return [normal, hover, pressed];
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ class LoadingGui extends GuiImage {
|
|||
MarbleGame.instance.quitMission();
|
||||
}
|
||||
|
||||
var overlay = new GuiImage(ResourceLoader.getImage("data/ui/loading/overlay.png").toTile());
|
||||
var overlay = new GuiImage(ResourceLoader.getResource("data/ui/loading/overlay.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
overlay.position = new Vector(151, 131);
|
||||
overlay.extent = new Vector(278, 86);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ import src.ResourceLoader;
|
|||
|
||||
class MainMenuGui extends GuiImage {
|
||||
public function new() {
|
||||
super(ResourceLoader.getImage("data/ui/background.jpg").toTile());
|
||||
var img = ResourceLoader.getImage("data/ui/background.jpg");
|
||||
super(img.resource.toTile());
|
||||
var fontdata = ResourceLoader.getFileEntry("data/font/DomCasual32px.fnt");
|
||||
var bfont = new BitmapFont(fontdata.entry);
|
||||
@:privateAccess bfont.loader = ResourceLoader.loader;
|
||||
|
|
@ -26,7 +27,7 @@ class MainMenuGui extends GuiImage {
|
|||
versionText.text.text = "1.0.0";
|
||||
this.addChild(versionText);
|
||||
|
||||
var homebase = new GuiImage(ResourceLoader.getImage("data/ui/home/homegui.png").toTile());
|
||||
var homebase = new GuiImage(ResourceLoader.getResource("data/ui/home/homegui.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
homebase.horizSizing = Center;
|
||||
homebase.vertSizing = Center;
|
||||
homebase.extent = new Vector(349, 477);
|
||||
|
|
@ -34,9 +35,9 @@ class MainMenuGui extends GuiImage {
|
|||
this.addChild(homebase);
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getImage('${path}_n.png').toTile();
|
||||
var hover = ResourceLoader.getImage('${path}_h.png').toTile();
|
||||
var pressed = ResourceLoader.getImage('${path}_d.png').toTile();
|
||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return [normal, hover, pressed];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ class MessageBoxYesNoDlg extends GuiControl {
|
|||
@:privateAccess domcasual24.loader = ResourceLoader.loader;
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getImage('${path}_n.png').toTile();
|
||||
var hover = ResourceLoader.getImage('${path}_h.png').toTile();
|
||||
var pressed = ResourceLoader.getImage('${path}_d.png').toTile();
|
||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return [normal, hover, pressed];
|
||||
}
|
||||
|
||||
var yesNoFrame = new GuiImage(ResourceLoader.getImage("data/ui/common/dialog.png").toTile());
|
||||
var yesNoFrame = new GuiImage(ResourceLoader.getResource("data/ui/common/dialog.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
yesNoFrame.horizSizing = Center;
|
||||
yesNoFrame.vertSizing = Center;
|
||||
yesNoFrame.position = new Vector(187, 156);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ class OptionsDlg extends GuiImage {
|
|||
var musicSliderFunc:(dt:Float, mouseState:MouseState) -> Void;
|
||||
|
||||
public function new() {
|
||||
super(ResourceLoader.getImage("data/ui/background.jpg").toTile());
|
||||
var img = ResourceLoader.getImage("data/ui/background.jpg");
|
||||
super(img.resource.toTile());
|
||||
this.horizSizing = Width;
|
||||
this.vertSizing = Height;
|
||||
this.position = new Vector();
|
||||
|
|
@ -27,9 +28,9 @@ class OptionsDlg extends GuiImage {
|
|||
@:privateAccess arial14.loader = ResourceLoader.loader;
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getImage('${path}_n.png').toTile();
|
||||
var hover = ResourceLoader.getImage('${path}_h.png').toTile();
|
||||
var pressed = ResourceLoader.getImage('${path}_d.png').toTile();
|
||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return [normal, hover, pressed];
|
||||
}
|
||||
|
||||
|
|
@ -42,21 +43,21 @@ class OptionsDlg extends GuiImage {
|
|||
|
||||
var setTab:String->Void = null;
|
||||
|
||||
var graphicsTab = new GuiImage(ResourceLoader.getImage("data/ui/options/graf_tab.png").toTile());
|
||||
var graphicsTab = new GuiImage(ResourceLoader.getResource("data/ui/options/graf_tab.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
graphicsTab.position = new Vector(58, 44);
|
||||
graphicsTab.extent = new Vector(149, 86);
|
||||
|
||||
var controlsTab = new GuiImage(ResourceLoader.getImage("data/ui/options/cntr_tab.png").toTile());
|
||||
var controlsTab = new GuiImage(ResourceLoader.getResource("data/ui/options/cntr_tab.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
controlsTab.position = new Vector(315, 15);
|
||||
controlsTab.extent = new Vector(149, 65);
|
||||
|
||||
var boxFrame = new GuiImage(ResourceLoader.getImage("data/ui/options/options_base.png").toTile());
|
||||
var boxFrame = new GuiImage(ResourceLoader.getResource("data/ui/options/options_base.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
boxFrame.position = new Vector(25, 14);
|
||||
boxFrame.extent = new Vector(470, 422);
|
||||
boxFrame.horizSizing = Center;
|
||||
boxFrame.vertSizing = Center;
|
||||
|
||||
var audioTab = new GuiImage(ResourceLoader.getImage("data/ui/options/aud_tab.png").toTile());
|
||||
var audioTab = new GuiImage(ResourceLoader.getResource("data/ui/options/aud_tab.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
audioTab.position = new Vector(204, 33);
|
||||
audioTab.extent = new Vector(114, 75);
|
||||
|
||||
|
|
@ -125,7 +126,7 @@ class OptionsDlg extends GuiImage {
|
|||
graphicsPane.addChild(gfxFull);
|
||||
windowBoxes.push(gfxFull);
|
||||
|
||||
var gfxText = new GuiImage(ResourceLoader.getImage("data/ui/options/graf_txt.png").toTile());
|
||||
var gfxText = new GuiImage(ResourceLoader.getResource("data/ui/options/graf_txt.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
gfxText.horizSizing = Right;
|
||||
gfxText.vertSizing = Bottom;
|
||||
gfxText.position = new Vector(12, 12);
|
||||
|
|
@ -269,17 +270,17 @@ class OptionsDlg extends GuiImage {
|
|||
audioPane.extent = new Vector(425, 281);
|
||||
// mainPane.addChild(audioPane);
|
||||
|
||||
var audSndSlide = new GuiImage(ResourceLoader.getImage("data/ui/options/aud_snd_slide.png").toTile());
|
||||
var audSndSlide = new GuiImage(ResourceLoader.getResource("data/ui/options/aud_snd_slide.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
audSndSlide.position = new Vector(14, 92);
|
||||
audSndSlide.extent = new Vector(388, 34);
|
||||
audioPane.addChild(audSndSlide);
|
||||
|
||||
var audMusSlide = new GuiImage(ResourceLoader.getImage("data/ui/options/aud_mus_slide.png").toTile());
|
||||
var audMusSlide = new GuiImage(ResourceLoader.getResource("data/ui/options/aud_mus_slide.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
audMusSlide.position = new Vector(17, 32);
|
||||
audMusSlide.extent = new Vector(381, 40);
|
||||
audioPane.addChild(audMusSlide);
|
||||
|
||||
var audMusKnob = new GuiSlider(ResourceLoader.getImage("data/ui/options/aud_mus_knb.png").toTile());
|
||||
var audMusKnob = new GuiSlider(ResourceLoader.getResource("data/ui/options/aud_mus_knb.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
audMusKnob.position = new Vector(137, 37);
|
||||
audMusKnob.extent = new Vector(250, 34);
|
||||
audMusKnob.sliderValue = Settings.optionsSettings.musicVolume;
|
||||
|
|
@ -288,11 +289,12 @@ class OptionsDlg extends GuiImage {
|
|||
}
|
||||
audioPane.addChild(audMusKnob);
|
||||
|
||||
var audSndKnob = new GuiSlider(ResourceLoader.getImage("data/ui/options/aud_snd_knb.png").toTile());
|
||||
var audSndKnob = new GuiSlider(ResourceLoader.getResource("data/ui/options/aud_snd_knb.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
audSndKnob.position = new Vector(137, 95);
|
||||
audSndKnob.extent = new Vector(254, 37);
|
||||
audSndKnob.sliderValue = Settings.optionsSettings.soundVolume;
|
||||
var testingSnd = AudioManager.playSound(ResourceLoader.getAudio("data/sound/testing.wav"), null, true);
|
||||
var testingSnd = AudioManager.playSound(ResourceLoader.getResource("data/sound/testing.wav", ResourceLoader.getAudio, this.soundResources), null,
|
||||
true);
|
||||
testingSnd.pause = true;
|
||||
audSndKnob.slidingSound = testingSnd;
|
||||
audSndKnob.pressedAction = (sender) -> {
|
||||
|
|
@ -315,7 +317,7 @@ class OptionsDlg extends GuiImage {
|
|||
}
|
||||
}
|
||||
|
||||
var audTxtWndo = new GuiImage(ResourceLoader.getImage("data/ui/options/aud_txt_wndo.png").toTile());
|
||||
var audTxtWndo = new GuiImage(ResourceLoader.getResource("data/ui/options/aud_txt_wndo.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
audTxtWndo.position = new Vector(26, 130);
|
||||
audTxtWndo.extent = new Vector(396, 132);
|
||||
audioPane.addChild(audTxtWndo);
|
||||
|
|
@ -368,7 +370,8 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
|
|||
controlsPane.position = new Vector(44, 58);
|
||||
controlsPane.extent = new Vector(459, 339);
|
||||
// MARBLE PANEL
|
||||
var marbleControlsPane = new GuiImage(ResourceLoader.getImage("data/ui/options/cntrl_marb_bse.png").toTile());
|
||||
var marbleControlsPane = new GuiImage(ResourceLoader.getResource("data/ui/options/cntrl_marb_bse.png", ResourceLoader.getImage, this.imageResources)
|
||||
.toTile());
|
||||
marbleControlsPane.position = new Vector(0, 5);
|
||||
marbleControlsPane.extent = new Vector(438, 320);
|
||||
controlsPane.addChild(marbleControlsPane);
|
||||
|
|
@ -503,7 +506,8 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
|
|||
marbleControlsPane.addChild(marbleToMouseButton);
|
||||
|
||||
// CAMERA PANEL
|
||||
cameraControlsPane = new GuiImage(ResourceLoader.getImage("data/ui/options/cntrl_cam_bse.png").toTile());
|
||||
cameraControlsPane = new GuiImage(ResourceLoader.getResource("data/ui/options/cntrl_cam_bse.png", ResourceLoader.getImage, this.imageResources)
|
||||
.toTile());
|
||||
cameraControlsPane.position = new Vector(0, 5);
|
||||
cameraControlsPane.extent = new Vector(438, 320);
|
||||
|
||||
|
|
@ -565,7 +569,8 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
|
|||
|
||||
// MOUSE CONTROLS
|
||||
|
||||
mouseControlsPane = new GuiImage(ResourceLoader.getImage("data/ui/options/cntrl_mous_base.png").toTile());
|
||||
mouseControlsPane = new GuiImage(ResourceLoader.getResource("data/ui/options/cntrl_mous_base.png", ResourceLoader.getImage, this.imageResources)
|
||||
.toTile());
|
||||
mouseControlsPane.position = new Vector(-17, -47);
|
||||
mouseControlsPane.extent = new Vector(470, 425);
|
||||
|
||||
|
|
@ -619,7 +624,8 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
|
|||
}
|
||||
mouseControlsPane.addChild(alwaysFreelook);
|
||||
|
||||
var mouseSensitivity = new GuiSlider(ResourceLoader.getImage("data/ui/options/cntrl_mous_knb.png").toTile());
|
||||
var mouseSensitivity = new GuiSlider(ResourceLoader.getResource("data/ui/options/cntrl_mous_knb.png", ResourceLoader.getImage, this.imageResources)
|
||||
.toTile());
|
||||
mouseSensitivity.position = new Vector(147, 148);
|
||||
mouseSensitivity.extent = new Vector(254, 34);
|
||||
mouseSensitivity.sliderValue = (Settings.controlsSettings.cameraSensitivity - 0.2) / (3 - 0.2);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package gui;
|
||||
|
||||
import hxd.res.Image;
|
||||
import hxd.Window;
|
||||
import h3d.shader.AlphaMult;
|
||||
import h3d.shader.ColorKey;
|
||||
|
|
@ -22,6 +23,9 @@ import h2d.Anim;
|
|||
import h2d.Bitmap;
|
||||
import src.ResourceLoader;
|
||||
import src.MarbleGame;
|
||||
import src.Resource;
|
||||
import hxd.res.Sound;
|
||||
import h3d.mat.Texture;
|
||||
|
||||
class PlayGui {
|
||||
var scene2d:h2d.Scene;
|
||||
|
|
@ -52,6 +56,10 @@ class PlayGui {
|
|||
var alertTextForeground:GuiText;
|
||||
var alertTextBackground:GuiText;
|
||||
|
||||
var imageResources:Array<Resource<Image>> = [];
|
||||
var textureResources:Array<Resource<Texture>> = [];
|
||||
var soundResources:Array<Resource<Sound>> = [];
|
||||
|
||||
var playGuiCtrl:GuiControl;
|
||||
|
||||
var resizeEv:Void->Void;
|
||||
|
|
@ -68,6 +76,17 @@ class PlayGui {
|
|||
powerupImageSceneTarget.dispose();
|
||||
powerupImageSceneTargetBitmap.remove();
|
||||
RSGOCenterText.remove();
|
||||
|
||||
for (textureResource in textureResources) {
|
||||
textureResource.release();
|
||||
}
|
||||
for (imageResource in imageResources) {
|
||||
imageResource.release();
|
||||
}
|
||||
for (audioResource in soundResources) {
|
||||
audioResource.release();
|
||||
}
|
||||
|
||||
Window.getInstance().removeResizeEvent(resizeEv);
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +103,7 @@ class PlayGui {
|
|||
|
||||
var numberTiles = [];
|
||||
for (i in 0...10) {
|
||||
var tile = ResourceLoader.getImage('data/ui/game/numbers/${i}.png').toTile();
|
||||
var tile = ResourceLoader.getResource('data/ui/game/numbers/${i}.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
numberTiles.push(tile);
|
||||
}
|
||||
|
||||
|
|
@ -97,13 +116,13 @@ class PlayGui {
|
|||
}
|
||||
|
||||
var rsgo = [];
|
||||
rsgo.push(ResourceLoader.getImage("data/ui/game/ready.png").toTile());
|
||||
rsgo.push(ResourceLoader.getImage("data/ui/game/set.png").toTile());
|
||||
rsgo.push(ResourceLoader.getImage("data/ui/game/go.png").toTile());
|
||||
rsgo.push(ResourceLoader.getImage("data/ui/game/outofbounds.png").toTile());
|
||||
rsgo.push(ResourceLoader.getResource("data/ui/game/ready.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
rsgo.push(ResourceLoader.getResource("data/ui/game/set.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
rsgo.push(ResourceLoader.getResource("data/ui/game/go.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
rsgo.push(ResourceLoader.getResource("data/ui/game/outofbounds.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
RSGOCenterText = new Anim(rsgo, 0, scene2d);
|
||||
|
||||
powerupBox = new GuiImage(ResourceLoader.getImage('data/ui/game/powerup.png').toTile());
|
||||
powerupBox = new GuiImage(ResourceLoader.getResource('data/ui/game/powerup.png', ResourceLoader.getImage, this.imageResources).toTile());
|
||||
initTimer();
|
||||
initGemCounter();
|
||||
initCenterText();
|
||||
|
|
@ -133,7 +152,7 @@ class PlayGui {
|
|||
timerNumbers[1].position = new Vector(47, 0);
|
||||
timerNumbers[1].extent = new Vector(43, 55);
|
||||
|
||||
timerColon = new GuiImage(ResourceLoader.getImage('data/ui/game/numbers/colon.png').toTile());
|
||||
timerColon = new GuiImage(ResourceLoader.getResource('data/ui/game/numbers/colon.png', ResourceLoader.getImage, this.imageResources).toTile());
|
||||
timerColon.position = new Vector(67, 0);
|
||||
timerColon.extent = new Vector(43, 55);
|
||||
|
||||
|
|
@ -143,7 +162,7 @@ class PlayGui {
|
|||
timerNumbers[3].position = new Vector(107, 0);
|
||||
timerNumbers[3].extent = new Vector(43, 55);
|
||||
|
||||
timerPoint = new GuiImage(ResourceLoader.getImage('data/ui/game/numbers/point.png').toTile());
|
||||
timerPoint = new GuiImage(ResourceLoader.getResource('data/ui/game/numbers/point.png', ResourceLoader.getImage, this.imageResources).toTile());
|
||||
timerPoint.position = new Vector(127, 0);
|
||||
timerPoint.extent = new Vector(43, 55);
|
||||
|
||||
|
|
@ -203,7 +222,7 @@ class PlayGui {
|
|||
gemCountNumbers[1].position = new Vector(54, 0);
|
||||
gemCountNumbers[1].extent = new Vector(43, 55);
|
||||
|
||||
gemCountSlash = new GuiImage(ResourceLoader.getImage('data/ui/game/numbers/slash.png').toTile());
|
||||
gemCountSlash = new GuiImage(ResourceLoader.getResource('data/ui/game/numbers/slash.png', ResourceLoader.getImage, this.imageResources).toTile());
|
||||
gemCountSlash.position = new Vector(75, 0);
|
||||
gemCountSlash.extent = new Vector(43, 55);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ class PlayMissionGui extends GuiImage {
|
|||
currentSelection = PlayMissionGui.currentSelectionStatic;
|
||||
currentCategory = PlayMissionGui.currentCategoryStatic;
|
||||
|
||||
super(ResourceLoader.getImage("data/ui/background.jpg").toTile());
|
||||
var img = ResourceLoader.getImage("data/ui/background.jpg");
|
||||
super(img.resource.toTile());
|
||||
|
||||
this.horizSizing = Width;
|
||||
this.vertSizing = Height;
|
||||
|
|
@ -60,14 +61,14 @@ class PlayMissionGui extends GuiImage {
|
|||
this.addChild(localContainer);
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getImage('${path}_n.png').toTile();
|
||||
var hover = ResourceLoader.getImage('${path}_h.png').toTile();
|
||||
var pressed = ResourceLoader.getImage('${path}_d.png').toTile();
|
||||
var disabled = ResourceLoader.getImage('${path}_i.png').toTile();
|
||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var disabled = ResourceLoader.getResource('${path}_i.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return [normal, hover, pressed, disabled];
|
||||
}
|
||||
|
||||
var tabAdvanced = new GuiImage(ResourceLoader.getImage("data/ui/play/tab_adv.png").toTile());
|
||||
var tabAdvanced = new GuiImage(ResourceLoader.getResource("data/ui/play/tab_adv.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
tabAdvanced.position = new Vector(410, 21);
|
||||
tabAdvanced.extent = new Vector(166, 43);
|
||||
tabAdvanced.pressedAction = (sender) -> {
|
||||
|
|
@ -77,7 +78,7 @@ class PlayMissionGui extends GuiImage {
|
|||
}
|
||||
localContainer.addChild(tabAdvanced);
|
||||
|
||||
var tabIntermediate = new GuiImage(ResourceLoader.getImage("data/ui/play/tab_inter.png").toTile());
|
||||
var tabIntermediate = new GuiImage(ResourceLoader.getResource("data/ui/play/tab_inter.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
tabIntermediate.position = new Vector(213, 6);
|
||||
tabIntermediate.extent = new Vector(205, 58);
|
||||
tabIntermediate.pressedAction = (sender) -> {
|
||||
|
|
@ -87,7 +88,7 @@ class PlayMissionGui extends GuiImage {
|
|||
}
|
||||
localContainer.addChild(tabIntermediate);
|
||||
|
||||
var tabCustom = new GuiImage(ResourceLoader.getImage("data/ui/play/cust_tab.png").toTile());
|
||||
var tabCustom = new GuiImage(ResourceLoader.getResource("data/ui/play/cust_tab.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
tabCustom.position = new Vector(589, 91);
|
||||
tabCustom.extent = new Vector(52, 198);
|
||||
tabCustom.pressedAction = (sender) -> {
|
||||
|
|
@ -97,28 +98,29 @@ class PlayMissionGui extends GuiImage {
|
|||
}
|
||||
localContainer.addChild(tabCustom);
|
||||
|
||||
var pmBox = new GuiImage(ResourceLoader.getImage("data/ui/play/playgui.png").toTile());
|
||||
var pmBox = new GuiImage(ResourceLoader.getResource("data/ui/play/playgui.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
pmBox.position = new Vector(0, 42);
|
||||
pmBox.extent = new Vector(610, 351);
|
||||
pmBox.horizSizing = Width;
|
||||
pmBox.vertSizing = Height;
|
||||
localContainer.addChild(pmBox);
|
||||
|
||||
var textWnd = new GuiImage(ResourceLoader.getImage("data/ui/play/text_window.png").toTile());
|
||||
var textWnd = new GuiImage(ResourceLoader.getResource("data/ui/play/text_window.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
textWnd.horizSizing = Width;
|
||||
textWnd.vertSizing = Height;
|
||||
textWnd.position = new Vector(31, 29);
|
||||
textWnd.extent = new Vector(276, 229);
|
||||
pmBox.addChild(textWnd);
|
||||
|
||||
var pmPreview = new GuiImage(ResourceLoader.getImage("data/missions/beginner/superspeed.jpg").toTile());
|
||||
var pmPreview = new GuiImage(ResourceLoader.getResource("data/missions/beginner/superspeed.jpg", ResourceLoader.getImage, this.imageResources)
|
||||
.toTile());
|
||||
pmPreview.position = new Vector(312, 42);
|
||||
pmPreview.extent = new Vector(258, 193);
|
||||
pmBox.addChild(pmPreview);
|
||||
var filt = new ColorMatrix(Matrix.I());
|
||||
pmPreview.bmp.filter = filt;
|
||||
|
||||
var levelWnd = new GuiImage(ResourceLoader.getImage("data/ui/play/level_window.png").toTile());
|
||||
var levelWnd = new GuiImage(ResourceLoader.getResource("data/ui/play/level_window.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
levelWnd.position = new Vector();
|
||||
levelWnd.extent = new Vector(258, 194);
|
||||
pmPreview.addChild(levelWnd);
|
||||
|
|
@ -289,7 +291,7 @@ class PlayMissionGui extends GuiImage {
|
|||
pmDescriptionOther.text.text = descText2;
|
||||
pmBox.addChild(pmDescriptionOther);
|
||||
|
||||
var tabBeginner = new GuiImage(ResourceLoader.getImage("data/ui/play/tab_begin.png").toTile());
|
||||
var tabBeginner = new GuiImage(ResourceLoader.getResource("data/ui/play/tab_begin.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
tabBeginner.position = new Vector(29, 2);
|
||||
tabBeginner.extent = new Vector(184, 55);
|
||||
tabBeginner.pressedAction = (sender) -> {
|
||||
|
|
@ -309,7 +311,7 @@ class PlayMissionGui extends GuiImage {
|
|||
localContainer.removeChild(tabCustom);
|
||||
localContainer.removeChild(pmBox);
|
||||
if (doRender)
|
||||
AudioManager.playSound(ResourceLoader.getAudio("data/sound/buttonpress.wav"));
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/buttonpress.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
if (category == "beginner") {
|
||||
localContainer.addChild(tabIntermediate);
|
||||
localContainer.addChild(tabAdvanced);
|
||||
|
|
@ -376,7 +378,7 @@ class PlayMissionGui extends GuiImage {
|
|||
return splits.join('\n');
|
||||
}
|
||||
|
||||
var goldBadge = ResourceLoader.getImage("data/ui/play/goldscore.png").toTile();
|
||||
var goldBadge = ResourceLoader.getResource("data/ui/play/goldscore.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
goldBadge.dy = 2.5;
|
||||
goldBadge.dx = 8;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class RemapDlg extends GuiControl {
|
|||
this.position = new Vector();
|
||||
this.extent = new Vector(640, 480);
|
||||
|
||||
var remapDlg = new GuiImage(ResourceLoader.getImage("data/ui/common/dialog.png").toTile());
|
||||
var remapDlg = new GuiImage(ResourceLoader.getResource("data/ui/common/dialog.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
remapDlg.horizSizing = Center;
|
||||
remapDlg.vertSizing = Center;
|
||||
remapDlg.position = new Vector(170, 159);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class AntiGravity extends PowerUp {
|
|||
this.identifier = "AntiGravity";
|
||||
this.pickUpName = "Gravity Modifier";
|
||||
this.autoUse = true;
|
||||
this.pickupSound = ResourceLoader.getAudio("data/sound/gravitychange.wav");
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/gravitychange.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ class DuctFan extends ForceObject {
|
|||
public override function init(level:src.MarbleWorld) {
|
||||
super.init(level);
|
||||
|
||||
this.soundChannel = AudioManager.playSound(ResourceLoader.getAudio("data/sound/fan_loop.wav"), new Vector(1e8, 1e8, 1e8), true);
|
||||
this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/fan_loop.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
new Vector(1e8, 1e8, 1e8), true);
|
||||
}
|
||||
|
||||
public override function update(timeState:src.TimeState) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import src.MarbleWorld.Scheduler;
|
|||
import src.ParticleSystem.ParticleEmitter;
|
||||
import src.ParticleSystem.ParticleEmitterOptions;
|
||||
import h3d.Vector;
|
||||
import src.Resource;
|
||||
import h3d.mat.Texture;
|
||||
|
||||
class EndPad extends DtsObject {
|
||||
var fireworks:Array<Firework> = [];
|
||||
|
|
@ -45,7 +47,8 @@ class EndPad extends DtsObject {
|
|||
function spawnFirework(time:TimeState) {
|
||||
var firework = new Firework(this.getAbsPos().getPosition(), time.timeSinceLoad, this.level);
|
||||
this.fireworks.push(firework);
|
||||
AudioManager.playSound(ResourceLoader.getAudio("data/sound/firewrks.wav"), this.getAbsPos().getPosition());
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/firewrks.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
this.getAbsPos().getPosition());
|
||||
// AudioManager.play(this.sounds[0], 1, AudioManager.soundGain, this.worldPosition);
|
||||
}
|
||||
|
||||
|
|
@ -245,6 +248,8 @@ class Firework extends Scheduler {
|
|||
var fireworkRedSparkData:ParticleData;
|
||||
var fireworkBlueSparkData:ParticleData;
|
||||
|
||||
var textureResources:Array<Resource<Texture>> = [];
|
||||
|
||||
public function new(pos:Vector, spawnTime:Float, level:MarbleWorld) {
|
||||
this.pos = pos;
|
||||
this.spawnTime = spawnTime;
|
||||
|
|
@ -252,23 +257,43 @@ class Firework extends Scheduler {
|
|||
|
||||
fireworkSmokeData = new ParticleData();
|
||||
fireworkSmokeData.identifier = "fireworkSmoke";
|
||||
fireworkSmokeData.texture = ResourceLoader.getTexture("data/particles/saturn.png");
|
||||
var res1 = ResourceLoader.getTexture("data/particles/saturn.png");
|
||||
res1.acquire();
|
||||
if (!this.textureResources.contains(res1))
|
||||
this.textureResources.push(res1);
|
||||
fireworkSmokeData.texture = res1.resource;
|
||||
|
||||
fireworkRedTrailData = new ParticleData();
|
||||
fireworkRedTrailData.identifier = "fireworkRedTrail";
|
||||
fireworkRedTrailData.texture = ResourceLoader.getTexture("data/particles/spark.png");
|
||||
var res2 = ResourceLoader.getTexture("data/particles/spark.png");
|
||||
res2.acquire();
|
||||
if (!this.textureResources.contains(res2))
|
||||
this.textureResources.push(res2);
|
||||
fireworkRedTrailData.texture = res2.resource;
|
||||
|
||||
fireworkBlueTrailData = new ParticleData();
|
||||
fireworkBlueTrailData.identifier = "fireworkBlueTrail";
|
||||
fireworkBlueTrailData.texture = ResourceLoader.getTexture("data/particles/spark.png");
|
||||
var res3 = ResourceLoader.getTexture("data/particles/spark.png");
|
||||
res3.acquire();
|
||||
if (!this.textureResources.contains(res3))
|
||||
this.textureResources.push(res3);
|
||||
fireworkBlueTrailData.texture = res3.resource;
|
||||
|
||||
fireworkRedSparkData = new ParticleData();
|
||||
fireworkRedSparkData.identifier = "fireworkRedSpark";
|
||||
fireworkRedSparkData.texture = ResourceLoader.getTexture("data/particles/star.png");
|
||||
var res4 = ResourceLoader.getTexture("data/particles/star.png");
|
||||
res4.acquire();
|
||||
if (!this.textureResources.contains(res4))
|
||||
this.textureResources.push(res4);
|
||||
fireworkRedSparkData.texture = res4.resource;
|
||||
|
||||
fireworkBlueSparkData = new ParticleData();
|
||||
fireworkBlueSparkData.identifier = "fireworkBlueSpark";
|
||||
fireworkBlueSparkData.texture = ResourceLoader.getTexture("data/particles/bubble.png");
|
||||
var res5 = ResourceLoader.getTexture("data/particles/bubble.png");
|
||||
res5.acquire();
|
||||
if (!this.textureResources.contains(res5))
|
||||
this.textureResources.push(res5);
|
||||
fireworkBlueSparkData.texture = res5.resource;
|
||||
|
||||
level.particleManager.createEmitter(fireworkSmoke, fireworkSmokeData, this.pos); // Start the smoke
|
||||
this.doWave(this.spawnTime); // Start the first wave
|
||||
|
|
@ -335,4 +360,10 @@ class Firework extends Scheduler {
|
|||
};
|
||||
this.trails.push(trail);
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
for (textureResource in this.textureResources) {
|
||||
textureResource.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Helicopter extends PowerUp {
|
|||
this.showSequences = false;
|
||||
this.identifier = "Helicopter";
|
||||
this.pickUpName = "Gyrocopter PowerUp";
|
||||
this.pickupSound = ResourceLoader.getAudio("data/sound/pugyrocoptervoice.wav");
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pugyrocoptervoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
|
|
|
|||
|
|
@ -103,15 +103,15 @@ class LandMine extends DtsObject {
|
|||
|
||||
landMineParticleData = new ParticleData();
|
||||
landMineParticleData.identifier = "landMineParticle";
|
||||
landMineParticleData.texture = ResourceLoader.getTexture("data/particles/smoke.png");
|
||||
landMineParticleData.texture = ResourceLoader.getResource("data/particles/smoke.png", ResourceLoader.getTexture, this.textureResources);
|
||||
|
||||
landMineSmokeParticleData = new ParticleData();
|
||||
landMineSmokeParticleData.identifier = "landMineSmokeParticle";
|
||||
landMineSmokeParticleData.texture = ResourceLoader.getTexture("data/particles/smoke.png");
|
||||
landMineSmokeParticleData.texture = ResourceLoader.getResource("data/particles/smoke.png", ResourceLoader.getTexture, this.textureResources);
|
||||
|
||||
landMineSparkParticleData = new ParticleData();
|
||||
landMineSparkParticleData.identifier = "landMineSparkParticle";
|
||||
landMineSparkParticleData.texture = ResourceLoader.getTexture("data/particles/spark.png");
|
||||
landMineSparkParticleData.texture = ResourceLoader.getResource("data/particles/spark.png", ResourceLoader.getTexture, this.textureResources);
|
||||
}
|
||||
|
||||
override function onMarbleContact(timeState:TimeState, ?contact:CollisionInfo) {
|
||||
|
|
@ -121,7 +121,7 @@ class LandMine extends DtsObject {
|
|||
this.setCollisionEnabled(false);
|
||||
|
||||
// if (!this.level.rewinding)
|
||||
AudioManager.playSound(ResourceLoader.getAudio("data/sound/explode1.wav"));
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/explode1.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
this.level.particleManager.createEmitter(landMineParticle, landMineParticleData, this.getAbsPos().getPosition());
|
||||
this.level.particleManager.createEmitter(landMineSmokeParticle, landMineSmokeParticleData, this.getAbsPos().getPosition());
|
||||
this.level.particleManager.createEmitter(landMineSparksParticle, landMineSparkParticleData, this.getAbsPos().getPosition());
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class ShockAbsorber extends PowerUp {
|
|||
this.isTSStatic = false;
|
||||
this.identifier = "ShockAbsorber";
|
||||
this.pickUpName = "Shock Absorber PowerUp";
|
||||
this.pickupSound = ResourceLoader.getAudio("data/sound/pushockabsorbervoice.wav");
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pushockabsorbervoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ class SmallDuctFan extends ForceObject {
|
|||
public override function init(level:src.MarbleWorld) {
|
||||
super.init(level);
|
||||
|
||||
this.soundChannel = AudioManager.playSound(ResourceLoader.getAudio("data/sound/fan_loop.wav"), new Vector(1e8, 1e8, 1e8), true);
|
||||
this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/fan_loop.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
new Vector(1e8, 1e8, 1e8), true);
|
||||
}
|
||||
|
||||
public override function update(timeState:src.TimeState) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class SuperBounce extends PowerUp {
|
|||
this.isTSStatic = false;
|
||||
this.identifier = "SuperBounce";
|
||||
this.pickUpName = "Super Bounce PowerUp";
|
||||
this.pickupSound = ResourceLoader.getAudio("data/sound/pusuperbouncevoice.wav");
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pusuperbouncevoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ class SuperJump extends PowerUp {
|
|||
this.pickUpName = "Super Jump PowerUp";
|
||||
sjEmitterParticleData = new ParticleData();
|
||||
sjEmitterParticleData.identifier = "superJumpParticle";
|
||||
sjEmitterParticleData.texture = ResourceLoader.getTexture("data/particles/twirl.png");
|
||||
this.pickupSound = ResourceLoader.getAudio("data/sound/pusuperjumpvoice.wav");
|
||||
sjEmitterParticleData.texture = ResourceLoader.getResource("data/particles/twirl.png", ResourceLoader.getTexture, this.textureResources);
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pusuperjumpvoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
|
|
@ -58,7 +58,7 @@ class SuperJump extends PowerUp {
|
|||
this.level.particleManager.createEmitter(superJumpParticleOptions, this.sjEmitterParticleData, null, () -> marble.getAbsPos().getPosition());
|
||||
// marble.body.addLinearVelocity(this.level.currentUp.scale(20)); // Simply add to vertical velocity
|
||||
// if (!this.level.rewinding)
|
||||
AudioManager.playSound(ResourceLoader.getAudio("data/sound/dosuperjump.wav"));
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/dosuperjump.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
// this.level.particles.createEmitter(superJumpParticleOptions, null, () => Util.vecOimoToThree(marble.body.getPosition()));
|
||||
this.level.deselectPowerUp();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ class SuperSpeed extends PowerUp {
|
|||
this.useInstancing = true;
|
||||
ssEmitterParticleData = new ParticleData();
|
||||
ssEmitterParticleData.identifier = "superSpeedParticle";
|
||||
ssEmitterParticleData.texture = ResourceLoader.getTexture("data/particles/spark.png");
|
||||
this.pickupSound = ResourceLoader.getAudio("data/sound/pusuperspeedvoice.wav");
|
||||
ssEmitterParticleData.texture = ResourceLoader.getResource("data/particles/spark.png", ResourceLoader.getTexture, this.textureResources);
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pusuperspeedvoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
|
|
@ -76,7 +76,7 @@ class SuperSpeed extends PowerUp {
|
|||
// marble.body.addLinearVelocity(Util.vecThreeToOimo(movementVector).scale(24.7)); // Whirligig's determined value
|
||||
// marble.body.addLinearVelocity(this.level.currentUp.scale(20)); // Simply add to vertical velocity
|
||||
// if (!this.level.rewinding)
|
||||
AudioManager.playSound(ResourceLoader.getAudio("data/sound/dosuperspeed.wav"));
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/dosuperspeed.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
this.level.particleManager.createEmitter(superSpeedParticleOptions, this.ssEmitterParticleData, null, () -> marble.getAbsPos().getPosition());
|
||||
this.level.deselectPowerUp();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class TimeTravel extends PowerUp {
|
|||
this.cooldownDuration = 1e8;
|
||||
this.useInstancing = true;
|
||||
this.autoUse = true;
|
||||
this.pickupSound = ResourceLoader.getAudio("data/sound/putimetravelvoice.wav");
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/putimetravelvoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ class Tornado extends ForceObject {
|
|||
|
||||
public override function init(level:src.MarbleWorld) {
|
||||
super.init(level);
|
||||
this.soundChannel = AudioManager.playSound(ResourceLoader.getAudio("data/sound/tornado.wav"), new Vector(1e8, 1e8, 1e8), true);
|
||||
this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/tornado.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
new Vector(1e8, 1e8, 1e8), true);
|
||||
for (material in this.materials) {
|
||||
material.blendMode = Alpha;
|
||||
material.mainPass.culling = h3d.mat.Data.Face.None;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ class Trapdoor extends DtsObject {
|
|||
direction = -1;
|
||||
if (direction != 0 && direction != this.lastDirection) {
|
||||
// If the direction has changed, play the sound
|
||||
var ch = AudioManager.playSound(ResourceLoader.getAudio("data/sound/trapdooropen.wav"), this.getAbsPos().getPosition());
|
||||
var ch = AudioManager.playSound(ResourceLoader.getResource("data/sound/trapdooropen.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
this.getAbsPos().getPosition());
|
||||
}
|
||||
|
||||
this.lastCompletion = currentCompletion;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import src.AudioManager;
|
|||
|
||||
class HelpTrigger extends Trigger {
|
||||
override function onMarbleEnter(timeState:TimeState) {
|
||||
AudioManager.playSound(ResourceLoader.getAudio('data/sound/infotutorial.wav'));
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/infotutorial.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
this.level.displayHelp(this.element.text);
|
||||
// this.level.replay.recordMarbleEnter(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue