Skip to content

Commit d6ca62a

Browse files
focus gain and lost events for scripts
- added `alpha`, `scroll`, and `angle` to `StageDataCharacter` - added week titles for freya, milky, and kanimate - fixed long burp for pico (dark & playable)
1 parent 9805302 commit d6ca62a

File tree

16 files changed

+130
-1
lines changed

16 files changed

+130
-1
lines changed

assets/preload/data/characters/pico-dark.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@
7878
"prefix": "burpsmile",
7979
"offsets": [37, 0]
8080
},
81+
{
82+
"name": "burpSmileLong",
83+
"prefix": "burpsmile",
84+
"frameIndices": [
85+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
86+
20, 21, 22, 23, 24, 25, 25, 26, 27, 28, 29, 30, 31, 31, 31, 31, 31, 31,
87+
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
88+
31, 31, 31, 31, 31, 31
89+
],
90+
"offsets": [37, 0]
91+
},
8192
{
8293
"name": "shit",
8394
"prefix": "shit",

assets/preload/data/characters/pico-playable.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@
9898
"prefix": "burpsmile",
9999
"offsets": [37, 0]
100100
},
101+
{
102+
"name": "burpSmileLong",
103+
"prefix": "burpsmile",
104+
"assetPath": "characters/Pico_Burps",
105+
"frameIndices": [
106+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
107+
20, 21, 22, 23, 24, 25, 25, 26, 27, 28, 29, 30, 31, 31, 31, 31, 31, 31,
108+
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
109+
31, 31, 31, 31, 31, 31
110+
],
111+
"offsets": [37, 0]
112+
},
101113
{
102114
"name": "shit",
103115
"assetPath": "characters/Pico_Burps",

assets/preload/data/levels/xweek4.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"titleAsset": "storymenu/titles/chainz",
55
"props": [],
66
"background": "#413CAE",
7+
"visible": false,
78
"songs": ["topp", "azure", "doublyon"]
89
}
Loading
17.1 KB
Loading
Loading
14.7 KB
Loading

source/funkin/data/stage/StageData.hx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ typedef StageDataProp =
176176
* How much the prop scrolls relative to the camera. Used to create a parallax effect.
177177
* Represented as an [x, y] array of two floats.
178178
* [1, 1] means the prop moves 1:1 with the camera.
179-
* [0.5, 0.5] means the prop half as much as the camera.
179+
* [0.5, 0.5] means the prop moves half as much as the camera.
180180
* [0, 0] means the prop is not moved.
181181
* @default [0, 0]
182182
*/
@@ -266,4 +266,32 @@ typedef StageDataCharacter =
266266
*/
267267
@:optional
268268
var cameraOffsets:Array<Float>;
269+
270+
/**
271+
* How much the character scrolls relative to the camera. Used to create a parallax effect.
272+
* Represented as an [x, y] array of two floats.
273+
* [1, 1] means the character moves 1:1 with the camera.
274+
* [0.5, 0.5] means the character moves half as much as the camera.
275+
* [0, 0] means the character is not moved.
276+
* @default [0, 0]
277+
*/
278+
@:optional
279+
@:default([0, 0])
280+
var scroll:Array<Float>;
281+
282+
/**
283+
* The alpha of the character, as a float.
284+
* @default 1.0
285+
*/
286+
@:optional
287+
@:default(1.0)
288+
var alpha:Float;
289+
290+
/**
291+
* The angle of the character, as a float.
292+
* @default 1.0
293+
*/
294+
@:optional
295+
@:default(0.0)
296+
var angle:Float;
269297
};

source/funkin/modding/IScriptedClass.hx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ interface IStateChangingScriptedClass extends IScriptedClass
3737
public function onSubStateOpenEnd(event:SubStateScriptEvent):Void;
3838
public function onSubStateCloseBegin(event:SubStateScriptEvent):Void;
3939
public function onSubStateCloseEnd(event:SubStateScriptEvent):Void;
40+
41+
public function onFocusLost(event:FocusScriptEvent):Void;
42+
public function onFocusGained(event:FocusScriptEvent):Void;
4043
}
4144

4245
/**

source/funkin/modding/events/ScriptEvent.hx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,22 @@ class StateChangeScriptEvent extends ScriptEvent
467467
}
468468
}
469469

470+
/**
471+
* An event that is fired when the game loses or gains focus.
472+
*/
473+
class FocusScriptEvent extends ScriptEvent
474+
{
475+
public function new(type:ScriptEventType, cancelable:Bool = false):Void
476+
{
477+
super(type, cancelable);
478+
}
479+
480+
public override function toString():String
481+
{
482+
return 'FocusScriptEvent(type=' + type + ')';
483+
}
484+
}
485+
470486
/**
471487
* An event that is fired when moving out of or into an FlxSubState.
472488
*/

source/funkin/modding/events/ScriptEventDispatcher.hx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ class ScriptEventDispatcher
182182
case SUBSTATE_CLOSE_END:
183183
t.onSubStateCloseEnd(cast event);
184184
return;
185+
case FOCUS_LOST:
186+
t.onFocusLost(cast event);
187+
return;
188+
case FOCUS_GAINED:
189+
t.onFocusGained(cast event);
190+
return;
185191
default: // Continue;
186192
}
187193
}

source/funkin/modding/events/ScriptEventType.hx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,20 @@ enum abstract ScriptEventType(String) from String to String
237237
*/
238238
var SUBSTATE_CLOSE_END = 'SUBSTATE_CLOSE_END';
239239

240+
/**
241+
* Called when the game regains focus.
242+
*
243+
* This event is not cancelable.
244+
*/
245+
var FOCUS_GAINED = 'FOCUS_GAINED';
246+
247+
/**
248+
* Called when the game loses focus.
249+
*
250+
* This event is not cancelable.
251+
*/
252+
var FOCUS_LOST = 'FOCUS_LOST';
253+
240254
/**
241255
* Called when the game starts a conversation.
242256
*

source/funkin/modding/module/Module.hx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,9 @@ class Module implements IPlayStateScriptedClass implements IStateChangingScripte
121121

122122
public function onSubStateCloseEnd(event:SubStateScriptEvent) {}
123123

124+
public function onFocusGained(event:FocusScriptEvent) {}
125+
126+
public function onFocusLost(event:FocusScriptEvent) {}
127+
124128
public function onSongRetry(event:ScriptEvent) {}
125129
}

source/funkin/play/stage/Stage.hx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,12 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass implements
452452
character.cameraFocusPoint.x += stageCharData.cameraOffsets[0];
453453
character.cameraFocusPoint.y += stageCharData.cameraOffsets[1];
454454

455+
character.scrollFactor.x = stageCharData.scroll[0];
456+
character.scrollFactor.y = stageCharData.scroll[1];
457+
458+
character.alpha = stageCharData.alpha;
459+
character.angle = stageCharData.angle;
460+
455461
#if FEATURE_DEBUG_FUNCTIONS
456462
// Draw the debug icon at the character's feet.
457463
if (charType == BF || charType == DAD)

source/funkin/ui/MusicBeatState.hx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,20 @@ class MusicBeatState extends FlxTransitionableState implements IEventHandler
152152
dispatchEvent(new UpdateScriptEvent(elapsed));
153153
}
154154

155+
override function onFocus():Void
156+
{
157+
super.onFocus();
158+
159+
dispatchEvent(new FocusScriptEvent(FOCUS_GAINED));
160+
}
161+
162+
override function onFocusLost():Void
163+
{
164+
super.onFocusLost();
165+
166+
dispatchEvent(new FocusScriptEvent(FOCUS_LOST));
167+
}
168+
155169
function createWatermarkText()
156170
{
157171
// Both have an xPos of 0, but a width equal to the full screen.

source/funkin/ui/MusicBeatSubState.hx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,20 @@ class MusicBeatSubState extends FlxSubState implements IEventHandler
144144
dispatchEvent(new UpdateScriptEvent(elapsed));
145145
}
146146

147+
override function onFocus():Void
148+
{
149+
super.onFocus();
150+
151+
dispatchEvent(new FocusScriptEvent(FOCUS_GAINED));
152+
}
153+
154+
override function onFocusLost():Void
155+
{
156+
super.onFocusLost();
157+
158+
dispatchEvent(new FocusScriptEvent(FOCUS_LOST));
159+
}
160+
147161
public function initConsoleHelpers():Void {}
148162

149163
function reloadAssets()

0 commit comments

Comments
 (0)