Skip to content

Commit

Permalink
smol modchart warning + console print optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed May 26, 2024
1 parent 99d49e4 commit 75a926f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
26 changes: 15 additions & 11 deletions source/funkin/ScriptConsole.hx
Original file line number Diff line number Diff line change
Expand Up @@ -163,26 +163,30 @@ class ScriptConsole extends ResizableSprite {
script.__runCode(code.endsWith(";") ? code : code + ";");
}

public function print(p:Dynamic, type:PrintType = NONE) {
public function print(p:Dynamic, type:PrintType = NONE)
{
// Move last prints down
for (i in 0...printsLength-1) {
final id:Int = printsLength-i-1;

final print = prints[id];
final lastPrint = prints[id-1];

print.text = lastPrint.text;
print.type = lastPrint.type;
print.alpha = lastPrint.alpha;
print.timer = lastPrint.timer;

// Only update visible prints
if (print.y <= 620) {
print.text = lastPrint.text;
print.type = lastPrint.type;
print.alpha = lastPrint.alpha;
print.timer = lastPrint.timer;
} else {
print.hide();
}
}

// Display the new print
final text:String = Std.string(p);
prints[0].text = text;
prints[0].text = Std.string(p);
prints[0].type = type;
prints[0].resetTimer();

// Move down all the prints
var Y = 50;
for (i in 0...printsLength) {
Expand Down
28 changes: 14 additions & 14 deletions source/funkin/util/frontend/ModchartManager.hx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
package funkin.util.frontend;
import funkin.objects.note.BasicNote;

import funkin.objects.NotesGroup;
import funkin.objects.note.StrumLineGroup;
import funkin.util.frontend.CutsceneManager;

enum abstract ModchartModifiers(String) from String to String {
var COS = "cos";
var SIN = "sin";
var BOOST = "boost";
}

typedef ModchartData = {
var cos:Array<Float>; // [size, offset]
var sin:Array<Float>; // [size, offset]
Expand Down Expand Up @@ -90,22 +84,28 @@ class ModchartManager extends EventHandler implements IMusicHit

// TODO: add the typical modchart effects like drunk, wavy n all that shit

public function setValue(value:String, data:Dynamic) {
public function setValue(value:String, ?data:Dynamic) {
for (strumline in strumLines.keys())
setStrumLineValue(strumline, value, data);
}

inline public function setStrumLineValue(strumline:Int, value:String, data:Dynamic) {
inline public function setStrumLineValue(strumline:Int, value:String, ?data:Dynamic) {
for (i in 0...getStrumLine(strumline).members.length)
setStrumValue(strumline, i, value, data);
}

inline public function setStrumValue(strumline:Int, id:Int, value:String, valueData:Dynamic) {
inline public function setStrumValue(strumline:Int, id:Int, value:String, ?valueData:Dynamic) {
final data = resolveData(getStrum(strumline, id));
switch (value.toLowerCase().trim()) {
case COS: data.cos = valueData;
case SIN: data.sin = valueData;
case BOOST: data.boost = valueData;
value = value.toLowerCase().trim();

if (Reflect.hasField(data, value))
{
if (valueData != null)
Reflect.setProperty(data, value, valueData);
}
else
{
ModdingUtil.warningPrint("Couldn't find modchart value for " + '"$value"');
}
}

Expand Down

0 comments on commit 75a926f

Please sign in to comment.