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

Commit

Permalink
support of leather engine
Browse files Browse the repository at this point in the history
except charts/maps with different numbers of keys
  • Loading branch information
TheLeerName committed Jan 8, 2022
1 parent f6a87cd commit eba46d2
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<app packageName="com.theleername.maniaconverter" main="Main" company="ManiaConverter"/>

<!-- Better change this -->
<app title="Mania Converter" package="com.theleername.maniaconverter" version="1.1" file="ManiaConverter"/>
<app title="Mania Converter" package="com.theleername.maniaconverter" version="1.1.1" file="ManiaConverter"/>


<!--Switch Export with Unique ApplicationID and Icon-->
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ Converter of FNF maps/charts, example from 4 key to 6 key.
- `from_key_default` for default **REAL** number of keys, if in chart/map `mania` line is not exist.
- `to_key_default` for default **REAL** number of keys, if you type value in `to_key` less than 1 or more than length of array in algorithm.
- `algorithm` for placing a notes.
- `extra_keys_sync` for sync with [tposejank's Extra Keys Mod](https://gamebanana.com/mods/333373).
- `extra_keys_sync` for sync with [tposejank's Extra Keys Mod](https://gamebanana.com/mods/333373). It working as `"mania": 3,` its **4 keys**, and without sync be `"mania": 3,` its **3 keys**. You must type a **REAL** number of keys in `to_key`.
- `leather_sync` for sync with [Leather128's Leather Engine](https://gamebanana.com/mods/334945). It working as `mania` its `keyCount` and `playerKeyCount`. For now charts/maps with different numbers of keys not supported. If its true, `extra_keys_sync` is disabled.
- `from_file` for name of chart/map before converting.
- `to_file` for name of chart/map after converting.
3. Move your chart/map to the converter folder.
4. Run a EXE file again.
5. Now you have a converted chart/map!
> I dont want do the ui of options in app, please no :(

## Explain of `extra_keys_sync`
It working as `"mania": 3,` its **4 keys**, and without sync be `"mania": 3,` its **3 keys**. You must type a **REAL** number of keys in `to_key`.
> I dont want do the ui of options in app, please no :(
3 changes: 3 additions & 0 deletions source/Options.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ typedef OptionsJSON = {
var from_key_default:Int;
var to_key_default:Int;
var extra_keys_sync:Bool;
var leather_sync:Bool;
var algorithm:Array<Dynamic>;
}

Expand All @@ -23,6 +24,7 @@ class Options
from_key_default: 4, // default value for key count before converting (crash preventing)
to_key_default: 4, // default value for key count after converting (crash preventing)
extra_keys_sync: true, // sync with mania from extra keys mod (real key count - 1, example 4 keys is mania = 3)
leather_sync: false, // sync with keyCount from leather engine (mania = (keyCount && playerKeyCount)), if its true extra_keys_sync = false
algorithm: [ // algorithm for placing a notes
[],
[
Expand Down Expand Up @@ -153,6 +155,7 @@ class Options
json.to_key == null ||
json.from_key_default == null ||
json.extra_keys_sync == null ||
json.leather_sync == null ||
json.algorithm == null ||
json.from_file == null ||
json.to_file == null
Expand Down
42 changes: 38 additions & 4 deletions source/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,37 @@ class TitleState extends FlxUIState
var json:Dynamic = FileAPI.file.parseJSON(options.from_file);

var from_key:Dynamic = 0;
if (json.song.mania == null)
from_key = options.from_key_default;
if (options.leather_sync)
{
var keys:Array<Int> = [0, 0];
if (json.song.keyCount == null)
keys[0] = options.from_key_default;
else
keys[0] = json.song.keyCount;

if (json.song.playerKeyCount == null)
keys[1] = options.from_key_default;
else
keys[1] = json.song.playerKeyCount;

if (keys[0] != keys[1])
{
Debug.log.error('Charts/maps with different numbers of keys not supported! (you have ${keys[0]} for opponent and ${keys[1]} for player)');
Application.current.window.close();
return;
}
else
from_key = keys[0];

options.extra_keys_sync = false;
}
else
from_key = json.song.mania + (options.extra_keys_sync ? 1 : 0);
{
if (json.song.mania == null)
from_key = options.from_key_default;
else
from_key = json.song.mania + (options.extra_keys_sync ? 1 : 0);
}

var to_key:Int = 0;
if (options.to_key < 1 || options.to_key > options.algorithm.length - 1)
Expand Down Expand Up @@ -82,7 +109,14 @@ class TitleState extends FlxUIState
for (i in 0...json.song.notes.length)
value += json.song.notes[i].sectionNotes.length;

json.song.mania = to_key + (options.extra_keys_sync ? -1 : 0);
if (options.leather_sync)
{
json.song.keyCount = to_key;
json.song.playerKeyCount = to_key;
}
else
json.song.mania = to_key + (options.extra_keys_sync ? -1 : 0);

FileAPI.file.saveFile(options.to_file, FileAPI.file.stringify(json, "\t", false));

Debug.log.trace('Successfully converted ${json.song.song} from ${from_key} keys to ${to_key} keys (${value} notes, include events)!');
Expand Down

0 comments on commit eba46d2

Please sign in to comment.