Skip to content

Commit

Permalink
assets submod
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjamuffin99 committed Apr 29, 2024
2 parents 21ab198 + 347b1b5 commit c5c22b2
Show file tree
Hide file tree
Showing 55 changed files with 608 additions and 269 deletions.
6 changes: 6 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
"type": "lime",
"request": "launch"
},
{
"name": "Debug",
"type": "lime",
"request": "launch",
"preLaunchTask": null
},
{
// Launch in browser
"name": "HTML5 Debug",
Expand Down
22 changes: 11 additions & 11 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "lime",
"command": "test",
"group": {
"kind": "build",
"isDefault": true
}
}
]
"version": "2.0.0",
"tasks": [
{
"type": "lime",
"command": "test",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
86 changes: 79 additions & 7 deletions source/funkin/Conductor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import flixel.util.FlxSignal;
import flixel.math.FlxMath;
import funkin.data.song.SongData.SongTimeChange;
import funkin.data.song.SongDataUtils;
import funkin.save.Save;
import haxe.Timer;
import flixel.sound.FlxSound;

/**
* A core class which handles musical timing throughout the game,
Expand Down Expand Up @@ -89,6 +92,9 @@ class Conductor
*/
public var songPosition(default, null):Float = 0;

var prevTimestamp:Float = 0;
var prevTime:Float = 0;

/**
* Beats per minute of the current song at the current time.
*/
Expand Down Expand Up @@ -233,8 +239,41 @@ class Conductor

/**
* An offset set by the user to compensate for input lag.
* No matter if you're using a local conductor or not, this always loads
* to/from the save file
*/
public var inputOffset:Float = 0;
public var inputOffset(get, set):Int;

/**
* An offset set by the user to compensate for audio/visual lag
* No matter if you're using a local conductor or not, this always loads
* to/from the save file
*/
public var audioVisualOffset(get, set):Int;

function get_inputOffset():Int
{
return Save.instance.options.inputOffset;
}

function set_inputOffset(value:Int):Int
{
Save.instance.options.inputOffset = value;
Save.instance.flush();
return Save.instance.options.inputOffset;
}

function get_audioVisualOffset():Int
{
return Save.instance.options.audioVisualOffset;
}

function set_audioVisualOffset(value:Int):Int
{
Save.instance.options.audioVisualOffset = value;
Save.instance.flush();
return Save.instance.options.audioVisualOffset;
}

/**
* The number of beats in a measure. May be fractional depending on the time signature.
Expand Down Expand Up @@ -353,16 +392,19 @@ class Conductor
* BPM, current step, etc. will be re-calculated based on the song position.
*
* @param songPosition The current position in the song in milliseconds.
* Leave blank to use the `FlxG.sound.music` position.
* Leave blank to use the FlxG.sound.music position.
* @param applyOffsets If it should apply the instrumentalOffset + formatOffset + audioVisualOffset
*/
public function update(?songPos:Float):Void
public function update(?songPos:Float, applyOffsets:Bool = true, forceDispatch:Bool = false)
{
if (songPos == null)
{
// Take into account instrumental and file format song offsets.
songPos = (FlxG.sound.music != null) ? (FlxG.sound.music.time + instrumentalOffset + formatOffset) : 0.0;
songPos = (FlxG.sound.music != null) ? FlxG.sound.music.time : 0.0;
}

// Take into account instrumental and file format song offsets.
songPos += applyOffsets ? (instrumentalOffset + formatOffset + audioVisualOffset) : 0;

var oldMeasure:Float = this.currentMeasure;
var oldBeat:Float = this.currentBeat;
var oldStep:Float = this.currentStep;
Expand Down Expand Up @@ -421,6 +463,35 @@ class Conductor
{
this.onMeasureHit.dispatch();
}

// only update the timestamp if songPosition actually changed
// which it doesn't do every frame!
if (prevTime != this.songPosition)
{
// Update the timestamp for use in-between frames
prevTime = this.songPosition;
prevTimestamp = Std.int(Timer.stamp() * 1000);
}
}

/**
* Can be called in-between frames, usually for input related things
* that can potentially get processed on exact milliseconds/timestmaps.
* If you need song position, use `Conductor.instance.songPosition` instead
* for use in update() related functions.
* @param soundToCheck Which FlxSound object to check, defaults to FlxG.sound.music if no input
* @return Float
*/
public function getTimeWithDiff(?soundToCheck:FlxSound):Float
{
if (soundToCheck == null) soundToCheck = FlxG.sound.music;
// trace(this.songPosition);

@:privateAccess
this.songPosition = soundToCheck._channel.position;
// return this.songPosition + (Std.int(Timer.stamp() * 1000) - prevTimestamp);
// trace("\t--> " + this.songPosition);
return this.songPosition;
}

/**
Expand Down Expand Up @@ -468,7 +539,7 @@ class Conductor
}

// Update currentStepTime
this.update(Conductor.instance.songPosition);
this.update(this.songPosition, false);
}

/**
Expand Down Expand Up @@ -587,7 +658,8 @@ class Conductor
}

/**
* Add variables of the current Conductor instance to the Flixel debugger.
* Adds Conductor fields to the Flixel debugger variable display.
* @param conductorToUse The conductor to use. Defaults to `Conductor.instance`.
*/
public static function watchQuick(?target:Conductor):Void
{
Expand Down
12 changes: 6 additions & 6 deletions source/funkin/InitState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import funkin.util.macro.MacroUtil;
import funkin.util.WindowUtil;
import funkin.play.PlayStatePlaylist;
import openfl.display.BitmapData;
import funkin.data.level.LevelRegistry;
import funkin.data.story.level.LevelRegistry;
import funkin.data.notestyle.NoteStyleRegistry;
import funkin.data.event.SongEventRegistry;
import funkin.data.stage.StageRegistry;
import funkin.data.dialogue.ConversationRegistry;
import funkin.data.dialogue.DialogueBoxRegistry;
import funkin.data.dialogue.SpeakerRegistry;
import funkin.data.freeplay.AlbumRegistry;
import funkin.data.dialogue.conversation.ConversationRegistry;
import funkin.data.dialogue.dialoguebox.DialogueBoxRegistry;
import funkin.data.dialogue.speaker.SpeakerRegistry;
import funkin.data.freeplay.album.AlbumRegistry;
import funkin.data.song.SongRegistry;
import funkin.play.character.CharacterData.CharacterDataParser;
import funkin.modding.module.ModuleHandler;
Expand Down Expand Up @@ -304,7 +304,7 @@ class InitState extends FlxState
*/
function startLevel(levelId:String, difficultyId:String = 'normal'):Void
{
var currentLevel:funkin.ui.story.Level = funkin.data.level.LevelRegistry.instance.fetchEntry(levelId);
var currentLevel:funkin.ui.story.Level = funkin.data.story.level.LevelRegistry.instance.fetchEntry(levelId);

if (currentLevel == null)
{
Expand Down
4 changes: 2 additions & 2 deletions source/funkin/data/DataParse.hx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class DataParse
}
}

public static function backdropData(json:Json, name:String):funkin.data.dialogue.ConversationData.BackdropData
public static function backdropData(json:Json, name:String):funkin.data.dialogue.conversation.ConversationData.BackdropData
{
switch (json.value)
{
Expand Down Expand Up @@ -152,7 +152,7 @@ class DataParse
}
}

public static function outroData(json:Json, name:String):Null<funkin.data.dialogue.ConversationData.OutroData>
public static function outroData(json:Json, name:String):Null<funkin.data.dialogue.conversation.ConversationData.OutroData>
{
switch (json.value)
{
Expand Down
Empty file.
Empty file.
9 changes: 9 additions & 0 deletions source/funkin/data/dialogue/conversation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Dialogue Conversation Data Schema Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0]
Initial release.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package funkin.data.dialogue;
package funkin.data.dialogue.conversation;

import funkin.data.animation.AnimationData;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package funkin.data.dialogue;
package funkin.data.dialogue.conversation;

import funkin.play.cutscene.dialogue.Conversation;
import funkin.data.dialogue.ConversationData;
import funkin.data.dialogue.conversation.ConversationData;
import funkin.play.cutscene.dialogue.ScriptedConversation;

class ConversationRegistry extends BaseRegistry<Conversation, ConversationData>
Expand Down
13 changes: 13 additions & 0 deletions source/funkin/data/dialogue/dialoguebox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Dialogue Box Data Schema Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0]
### Added
- Added an option to specify the font used by the dialogue box. Defaults to `Arial` if unspecified.

## [1.0.0]
Initial release.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package funkin.data.dialogue;
package funkin.data.dialogue.dialoguebox;

import funkin.data.animation.AnimationData;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package funkin.data.dialogue;
package funkin.data.dialogue.dialoguebox;

import funkin.play.cutscene.dialogue.DialogueBox;
import funkin.data.dialogue.DialogueBoxData;
import funkin.data.dialogue.dialoguebox.DialogueBoxData;
import funkin.play.cutscene.dialogue.ScriptedDialogueBox;

class DialogueBoxRegistry extends BaseRegistry<DialogueBox, DialogueBoxData>
Expand Down
9 changes: 9 additions & 0 deletions source/funkin/data/dialogue/speaker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Dialogue Speaker Data Schema Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0]
Initial release.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package funkin.data.dialogue;
package funkin.data.dialogue.speaker;

import funkin.data.animation.AnimationData;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package funkin.data.dialogue;
package funkin.data.dialogue.speaker;

import funkin.play.cutscene.dialogue.Speaker;
import funkin.data.dialogue.SpeakerData;
import funkin.data.dialogue.speaker.SpeakerData;
import funkin.play.cutscene.dialogue.ScriptedSpeaker;

class SpeakerRegistry extends BaseRegistry<Speaker, SpeakerData>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package funkin.data.freeplay;
package funkin.data.freeplay.album;

import funkin.data.animation.AnimationData;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package funkin.data.freeplay;
package funkin.data.freeplay.album;

import funkin.ui.freeplay.Album;
import funkin.data.freeplay.AlbumData;
import funkin.data.freeplay.album.AlbumData;
import funkin.ui.freeplay.ScriptedAlbum;

class AlbumRegistry extends BaseRegistry<Album, AlbumData>
Expand Down
9 changes: 9 additions & 0 deletions source/funkin/data/freeplay/album/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Freeplay Album Data Schema Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0]
Initial release.
36 changes: 36 additions & 0 deletions source/funkin/data/song/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Song Chart Data Schema Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.2.2]
### Added
- Added `playData.previewStart` and `playData.previewEnd` fields to specify when in the song should the song's audio should be played as a preview in Freeplay.

## [2.2.1]
### Added
- Added `playData.offsets` field to specify instrumental and vocal offsets.

## [2.2.0]
### Added
- Added `playData.album` to specify the album art to display in Freeplay.
- Added `playData.ratings` for difficulty ratings displayed in Freeplay.
### Changed
- Renamed `playData.noteSkin` to `playData.noteStyle`.

## [2.1.0]
### Changed
- Rearranged the `playData` field.
- Refactored the `playableChars`
### Removed
- Removed the `variation` field.

## [2.0.0]
Full refactor of the chart format for improved structure.
### Added
- Added a semantic version field for migration tracking.

## [1.0.0]
Initial version from 2020.
Empty file removed source/funkin/data/speaker/TODO.md
Empty file.
14 changes: 14 additions & 0 deletions source/funkin/data/stage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Story Mode Level Data Schema Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.1]
### Added
- Added the ability to specify a hexadecimal color in the `assetPath` field instead of a texture key.
- In this case, the `scale` property will be used to determine the size of the rectangle in pixels.

## [1.0.0]
Initial release.
2 changes: 1 addition & 1 deletion source/funkin/data/stage/StageRegistry.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class StageRegistry extends BaseRegistry<Stage, StageData>
* Handle breaking changes by incrementing this value
* and adding migration to the `migrateStageData()` function.
*/
public static final STAGE_DATA_VERSION:thx.semver.Version = "1.0.1";
public static final STAGE_DATA_VERSION:thx.semver.Version = "1.0.0";

public static final STAGE_DATA_VERSION_RULE:thx.semver.VersionRule = "1.0.x";

Expand Down
Loading

0 comments on commit c5c22b2

Please sign in to comment.