|
| 1 | +package; |
| 2 | + |
| 3 | +import flixel.util.FlxTimer; |
| 4 | +import flixel.tweens.FlxEase; |
| 5 | +import flixel.tweens.FlxTween; |
| 6 | +import Controls.Control; |
| 7 | +import flash.text.TextField; |
| 8 | +import flixel.FlxG; |
| 9 | +import flixel.FlxSprite; |
| 10 | +import flixel.addons.display.FlxGridOverlay; |
| 11 | +import flixel.group.FlxGroup.FlxTypedGroup; |
| 12 | +import flixel.input.keyboard.FlxKey; |
| 13 | +import flixel.math.FlxMath; |
| 14 | +import flixel.text.FlxText; |
| 15 | +import flixel.util.FlxColor; |
| 16 | +import lime.utils.Assets; |
| 17 | + |
| 18 | +class CreditsMenu extends MusicBeatState |
| 19 | +{ |
| 20 | + var selector:FlxText; |
| 21 | + var curSelected:Int = 0; |
| 22 | + |
| 23 | + var controlsStrings:Array<String> = []; |
| 24 | + |
| 25 | + private var grpControls:FlxTypedGroup<Alphabet>; |
| 26 | + |
| 27 | + var bg:FlxSprite; |
| 28 | + |
| 29 | + override function create() |
| 30 | + { |
| 31 | + trace("Opened credits! From " + CumFart.stateFrom); |
| 32 | + |
| 33 | + bg = new FlxSprite(-1300, -90); |
| 34 | + add(bg); |
| 35 | + bg.loadGraphic(Paths.image('mainMenuCity')); |
| 36 | + FlxTween.linearMotion(bg, -1300, -90, -600, -90, 1, true, {type: FlxTween.ONESHOT, ease: FlxEase.expoInOut}); |
| 37 | + |
| 38 | + controlsStrings = CoolUtil.coolTextFile(Paths.txt("credits")); |
| 39 | + |
| 40 | + grpControls = new FlxTypedGroup<Alphabet>(); |
| 41 | + //add(grpControls); |
| 42 | + for (i in 0...controlsStrings.length) |
| 43 | + { |
| 44 | + if (controlsStrings[i].indexOf('set') != -1) |
| 45 | + { |
| 46 | + var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, controlsStrings[i].substring(3) + ' : ' + controlsStrings[i + 1], true, false); |
| 47 | + controlLabel.isMenuItem = true; |
| 48 | + controlLabel.targetY = i; |
| 49 | + grpControls.add(controlLabel); |
| 50 | + } |
| 51 | + // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! |
| 52 | + } |
| 53 | + new FlxTimer().start(0.9, function(tmr:FlxTimer) { |
| 54 | + add(grpControls); |
| 55 | + changeSelection(); |
| 56 | + }); |
| 57 | + super.create(); |
| 58 | + } |
| 59 | + |
| 60 | + override function update(elapsed:Float) |
| 61 | + { |
| 62 | + super.update(elapsed); |
| 63 | + if (controls.ACCEPT) |
| 64 | + { |
| 65 | + switch(curSelected) { |
| 66 | + case 0: |
| 67 | + FlxG.openURL("https://youtube.com/channel/UCVgVvwOzvsR8pRwVy316SyA"); |
| 68 | + case 1: |
| 69 | + FlxG.openURL("https://www.youtube.com/channel/UC7M0aIL8-eVSJker9p0OyUQ"); |
| 70 | + case 2: |
| 71 | + FlxG.openURL("https://twitter.com/EvanClubYT"); |
| 72 | + case 3: |
| 73 | + FlxG.openURL("https://twitter.com/C0nfuzzl3dis/"); |
| 74 | + case 4: |
| 75 | + FlxG.openURL("https://youtube.com/channel/UCVgVvwOzvsR8pRwVy316SyA"); |
| 76 | + case 5: |
| 77 | + FlxG.openURL("https://twitter.com/ninja_muffin99"); |
| 78 | + } |
| 79 | + // var funnystring = Std.string(curSelected); |
| 80 | + // FlxG.openURL(funnystring); |
| 81 | + } |
| 82 | + |
| 83 | + if (isSettingControl) |
| 84 | + waitingInput(); |
| 85 | + { |
| 86 | + if (controls.BACK) |
| 87 | + CumFart.stateFrom = "freeplay"; // doesnt rlly matter |
| 88 | + FlxG.switchState(new MainMenuState()); |
| 89 | + if (controls.UP_P) |
| 90 | + changeSelection(-1); |
| 91 | + if (controls.DOWN_P) |
| 92 | + changeSelection(1); |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + function waitingInput():Void |
| 97 | + { |
| 98 | + if (FlxG.keys.getIsDown().length > 0) |
| 99 | + { |
| 100 | + PlayerSettings.player1.controls.replaceBinding(Control.LEFT, Keys, FlxG.keys.getIsDown()[0].ID, null); |
| 101 | + } |
| 102 | + // PlayerSettings.player1.controls.replaceBinding(Control) |
| 103 | + } |
| 104 | + |
| 105 | + var isSettingControl:Bool = false; |
| 106 | + |
| 107 | + function changeBinding():Void |
| 108 | + { |
| 109 | + if (!isSettingControl) |
| 110 | + { |
| 111 | + isSettingControl = true; |
| 112 | + } |
| 113 | + } |
| 114 | + |
| 115 | + function changeSelection(change:Int = 0) |
| 116 | + { |
| 117 | +// #if !switch |
| 118 | + //NGio.logEvent('Fresh'); |
| 119 | +// #end |
| 120 | + |
| 121 | + FlxG.sound.play(Paths.sound('scrollMenu'), 0.4); |
| 122 | + |
| 123 | + curSelected += change; |
| 124 | + |
| 125 | + if (curSelected < 0) |
| 126 | + curSelected = grpControls.length - 1; |
| 127 | + if (curSelected >= grpControls.length) |
| 128 | + curSelected = 0; |
| 129 | + |
| 130 | + // selector.y = (70 * curSelected) + 30; |
| 131 | + |
| 132 | + var bullShit:Int = 0; |
| 133 | + |
| 134 | + for (item in grpControls.members) |
| 135 | + { |
| 136 | + item.targetY = bullShit - curSelected; |
| 137 | + bullShit++; |
| 138 | + |
| 139 | + item.alpha = 0; |
| 140 | + // item.setGraphicSize(Std.int(item.width * 0.8)); |
| 141 | + |
| 142 | + if (item.targetY == 0) |
| 143 | + { |
| 144 | + item.alpha = 1; |
| 145 | + // item.setGraphicSize(Std.int(item.width)); |
| 146 | + } |
| 147 | + if (item.targetY - 1 == 0 || item.targetY + 1 == 0) { |
| 148 | + item.alpha = 0.6; |
| 149 | + } |
| 150 | + } |
| 151 | + } |
| 152 | +} |
0 commit comments