Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
SWF SUPPORT?!?!?!
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Aug 11, 2022
1 parent 6f63961 commit a4f2dac
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
haxelib install hscript
haxelib git hscript-ex https://github.com/ianharrigan/hscript-ex
haxelib install polymod 1.5.2
haxelib install swf 3.0.2
haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc
haxelib install hxcpp-debug-server
haxelib git systools https://github.com/haya3218/systools
Expand Down Expand Up @@ -102,6 +103,7 @@ jobs:
haxelib install hscript
haxelib git hscript-ex https://github.com/ianharrigan/hscript-ex
haxelib install polymod 1.5.2
haxelib install swf 3.0.2
haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc
haxelib git extension-webm https://github.com/KadeDev/extension-webm
haxelib run lime rebuild extension-webm windows
Expand Down Expand Up @@ -154,6 +156,7 @@ jobs:
haxelib install hscript
haxelib git hscript-ex https://github.com/ianharrigan/hscript-ex
haxelib install polymod 1.5.2
haxelib install swf 3.0.2
haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc
haxelib git extension-webm https://github.com/KadeDev/extension-webm
haxelib run lime rebuild extension-webm mac
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
haxelib install hscript
haxelib git hscript-ex https://github.com/ianharrigan/hscript-ex
haxelib install polymod 1.5.2
haxelib install swf 3.0.2
haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc
haxelib install hxcpp-debug-server
haxelib git systools https://github.com/haya3218/systools
Expand Down Expand Up @@ -102,6 +103,7 @@ jobs:
haxelib install hscript
haxelib git hscript-ex https://github.com/ianharrigan/hscript-ex
haxelib install polymod 1.5.2
haxelib install swf 3.0.2
haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc
haxelib git extension-webm https://github.com/KadeDev/extension-webm
haxelib run lime rebuild extension-webm windows
Expand Down Expand Up @@ -154,6 +156,7 @@ jobs:
haxelib install hscript
haxelib git hscript-ex https://github.com/ianharrigan/hscript-ex
haxelib install polymod 1.5.2
haxelib install swf 3.0.2
haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc
haxelib git extension-webm https://github.com/KadeDev/extension-webm
haxelib run lime rebuild extension-webm mac
Expand Down
3 changes: 3 additions & 0 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<define name="ACHIEVEMENTS_ALLOWED" />
<define name="PYTHON_ALLOWED"/>
<define name="VIDEOS_ALLOWED" if="web || windows" unless="32bits"/>
<define name="SWF_ALLOWED"/>
<define name="JOALOR64_WATERMARKS"/> <!-- DELETE THIS TO REMOVE WATERMARKS/DEV NAMES ON TITLE SCREEN -->
<define name="MP3_ALLOWED"/>
<define name="WAV_ALLOWED"/>
Expand Down Expand Up @@ -120,6 +121,7 @@
<assets path="assets/week6" library="week6" exclude="*.mp3" unless="web"/>

<assets path="assets/artemis" library="artemis" if="windows"/>
<assets path="assets/swf" library="swf" if="SWF_ALLOWED"/>

<assets path='example_mods' rename='mods' embed='false' if="MODS_ALLOWED"/>
<assets path='polymod_mods' rename='polymods' if="MODS_ALLOWED"/>
Expand Down Expand Up @@ -159,6 +161,7 @@
<haxelib name="hxCodec" if="VIDEOS_ALLOWED"/>
<haxelib name="faxe" if='switch'/>
<haxelib name="polymod" if="MODS_ALLOWED"/>
<haxelib name="swf" if="SWF_ALLOWED"/>
<haxelib name="SScript" if="HAXE_EXTENSION"/>
<haxelib name="tjson"/>
<haxelib name="discord_rpc" if="desktop"/>
Expand Down
2 changes: 2 additions & 0 deletions assets/swf/swf-movies-go-here.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Your SWF movies go here!
Make sure they are in the .swf format (obviously)!
4 changes: 4 additions & 0 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ import sys.io.File;
import vlc.MP4Handler;
#end

/*#if SWF_ALLOWED
import swf.SWF;
#end*/

using CoolUtil;
using StringTools;

Expand Down
80 changes: 80 additions & 0 deletions source/SwfVideo.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package;

import openfl.utils.Assets;
import flixel.system.FlxSound;
import openfl.display.Sprite;
import openfl.Lib;
import openfl.events.Event;
import flixel.FlxG;
import openfl.display.MovieClip;

class SwfVideo extends Sprite
{
public var clip:MovieClip;

private var barLeft:Sprite;
private var barRight:Sprite;

public function new(movieClip:String, sound:String, onComplete:Void->Void)
{
super();

barLeft = new Sprite();
barRight = new Sprite();

var audio:FlxSound = new FlxSound().loadEmbedded(sound);
Assets.loadLibrary('$movieClip').onComplete(function(_) {
clip = Assets.getMovieClip('$movieClip:');
addChild(clip);

addChild(barLeft);
addChild(barRight);

audio.onComplete = function() {
onComplete();
removeChild(clip);
(cast (Lib.current.getChildAt(0), Main)).removeChild(this);
};
audio.play();
});

(cast (Lib.current.getChildAt(0), Main)).addChild(this);

addEventListener(Event.ENTER_FRAME, onResize);
}

/**
* Partly Copied from FlxGame
*/
function onResize(_):Void
{
var width:Int = FlxG.stage.stageWidth;
var height:Int = FlxG.stage.stageHeight;

width > height ?
clip.scaleX = clip.scaleY = height / 720
: clip.scaleY = clip.scaleX = width / 1280;

screenCenter();

// trace('RESIZED TO ${clip.scaleX}%');
}

public function screenCenter()
{
var ratio:Float = FlxG.width / FlxG.height;
var realRatio:Float = FlxG.stage.stageWidth / FlxG.stage.stageHeight;
var preX:Float = 0;

preX = Math.floor(FlxG.stage.stageHeight * ratio);

clip.x = Math.ceil((FlxG.stage.stageWidth - preX) * 0.5);

barLeft.graphics.clear();
barRight.graphics.clear();
barLeft.graphics.beginFill();
barRight.graphics.beginFill();
barLeft.graphics.drawRect(0, 0, clip.x, FlxG.stage.stageHeight);
barRight.graphics.drawRect(FlxG.stage.stageWidth - clip.x, 0, clip.x, FlxG.stage.stageHeight);
}
}

0 comments on commit a4f2dac

Please sign in to comment.