-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathResetScoreSubState.hx
More file actions
121 lines (106 loc) · 3.03 KB
/
ResetScoreSubState.hx
File metadata and controls
121 lines (106 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxSubState;
import flixel.util.FlxColor;
using StringTools;
class ResetScoreSubState extends MusicBeatSubstate
{
var bg:FlxSprite;
var alphabetArray:Array<Alphabet> = [];
var icon:HealthIcon;
var onYes:Bool = false;
var yesText:Alphabet;
var noText:Alphabet;
var song:String;
var difficulty:Int;
var week:Int;
// Week -1 = Freeplay
public function new(song:String, difficulty:Int, character:String, week:Int = -1)
{
this.song = song;
this.difficulty = difficulty;
this.week = week;
super();
var name:String = song;
if(week > -1) {
name = WeekData.weeksLoaded.get(WeekData.weeksList[week]).weekName;
}
name += ' (' + CoolUtil.difficultyStuff[difficulty][0] + ')?';
bg = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
bg.alpha = 0;
bg.scrollFactor.set();
add(bg);
var tooLong:Float = (name.length > 18) ? 0.8 : 1; //Fucking Winter Horrorland
var text:Alphabet = new Alphabet(0, 180, "Reset the score of", true);
text.screenCenter(X);
alphabetArray.push(text);
text.alpha = 0;
add(text);
var text:Alphabet = new Alphabet(0, text.y + 90, name, true, false, 0.05, tooLong);
text.screenCenter(X);
if(week == -1) text.x += 60 * tooLong;
alphabetArray.push(text);
text.alpha = 0;
add(text);
if(week == -1) {
icon = new HealthIcon(character);
icon.setGraphicSize(Std.int(icon.width * tooLong));
icon.updateHitbox();
icon.setPosition(text.x - icon.width + (10 * tooLong), text.y - 30);
icon.alpha = 0;
add(icon);
}
yesText = new Alphabet(0, text.y + 150, 'Yes', true);
yesText.screenCenter(X);
yesText.x -= 200;
add(yesText);
noText = new Alphabet(0, text.y + 150, 'No', true);
noText.screenCenter(X);
noText.x += 200;
add(noText);
updateOptions();
#if mobileC
addVirtualPad(LEFT_RIGHT, A_B);
#end
}
override function update(elapsed:Float)
{
bg.alpha += elapsed * 1.5;
if(bg.alpha > 0.6) bg.alpha = 0.6;
for (i in 0...alphabetArray.length) {
var spr = alphabetArray[i];
spr.alpha += elapsed * 2.5;
}
if(week == -1) icon.alpha += elapsed * 2.5;
if(controls.UI_LEFT_P || controls.UI_RIGHT_P) {
FlxG.sound.play(Paths.sound('scrollMenu'), 1);
onYes = !onYes;
updateOptions();
}
if(controls.BACK) {
FlxG.sound.play(Paths.sound('cancelMenu'), 1);
close();
} else if(controls.ACCEPT) {
if(onYes) {
if(week == -1) {
Highscore.resetSong(song, difficulty);
} else {
Highscore.resetWeek(WeekData.weeksList[week], difficulty);
}
}
FlxG.sound.play(Paths.sound('cancelMenu'), 1);
close();
}
super.update(elapsed);
}
function updateOptions() {
var scales:Array<Float> = [0.75, 1];
var alphas:Array<Float> = [0.6, 1.25];
var confirmInt:Int = onYes ? 1 : 0;
yesText.alpha = alphas[confirmInt];
yesText.scale.set(scales[confirmInt], scales[confirmInt]);
noText.alpha = alphas[1 - confirmInt];
noText.scale.set(scales[1 - confirmInt], scales[1 - confirmInt]);
if(week == -1) icon.animation.curAnim.curFrame = confirmInt;
}
}