Skip to content

Commit

Permalink
keep Http + some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Jul 9, 2024
1 parent 050e86a commit 7ddcb72
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 37 deletions.
3 changes: 2 additions & 1 deletion source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class InitState extends FlxState
}
}

@:keepSub(Http)
class Main extends Sprite
{
var settings = {
final settings = {
width: 1280, // Width of the game in pixels (might be less / more in actual pixels depending on your zoom).
height: 720, // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).
initialState: InitState, // The FlxState the game starts with.
Expand Down
20 changes: 8 additions & 12 deletions source/funkin/states/editors/chart/grid/ChartEvent.hx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@ class ChartEvent extends SpriteGroup
data.push(new Event()); // Dummy event
}

public var text(default, set):FlxBitmapText;
function set_text(value) {
if (value != null) {
value.alignment = RIGHT;
}
return text = value;
}
public var text:FlxBitmapText;

override function kill() {
super.kill();
Expand Down Expand Up @@ -76,17 +70,19 @@ class ChartEvent extends SpriteGroup

data.fastForEach((event, i) -> {
dataText += strigifyArray(event.values) + ' - ' + event.name;
if (i < data.length - 1) {
if (i < data.length - 1)
dataText += "\n";
}
});

text.text = dataText;
text.text = dataText.trim();
text.alignment = LEFT;
packSprite.visible = chartData.length > 1;

text.updateHitbox();
text.origin.set();
text.offset.set(
text.width - GRID_SIZE * 0.75,
(text.height * 0.75 - GRID_SIZE) * 0.5
(text.textWidth * 2) + (GRID_SIZE / 4),
((text.textHeight * 2) - GRID_SIZE) / 2
);
}

Expand Down
31 changes: 15 additions & 16 deletions source/funkin/util/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Paths
inline public static var SOUND_EXT = "ogg";
public static var currentLevel(default, set):String = "";

public static function set_currentLevel(value:String)
public static inline function set_currentLevel(value:String)
return currentLevel = value.toLowerCase();

public static function getPath(file:String, type:AssetType, ?library:String, allMods:Bool = false, mods:Bool = true, ?level:String):String
Expand Down Expand Up @@ -94,12 +94,9 @@ class Paths
return (library == "preload" || library == "default") ? getAssetsPath(file) : getLibraryPathForce(file, library, level, root);
}

inline static function getLibraryPathForce(file:String, library:String, ?level:String, root:String = "assets"):String
inline static public function getLibraryPathForce(file:String, library:String, ?level:String, root:String = "assets"):String
{
if (level != null)
return '$root/$library/$level/$file';

return '$root/$library/$file';
return (level != null) ? '$root/$library/$level/$file' : '$root/$library/$file';
}

inline static public function getModPath(file:String):String
Expand Down Expand Up @@ -236,17 +233,19 @@ class Paths
}

inline static public function exists(file:String, type:AssetType):Bool {
#if desktop
#if sys
return FileSystem.exists(file);
#else
return OpenFlAssets.exists(file, type);
#end
}

// Returns [file Mod, file Name]
inline static public function getFileMod(dir:String):Array<String> {
var dirParts = dir.split('/');
return [dirParts[1], dirParts[dirParts.length-1].split('.')[0]];
public static inline function getPathMod(path:String):String {
return path.split('/')[1];
}

public static inline function getPathFile(path:String):String {
return path.split('/').pop().split('.')[0];
}

// Gotta do this to make sure FlxAtlasFrames doesnt lose his shit when the graphic is smaller than the data
Expand All @@ -258,7 +257,7 @@ class Paths
return frames;
}

inline static public function getSparrowAtlas(key:String, ?library:String, ?useTexture:Bool, ?lodLevel:LodLevel):FlxAtlasFrames
static public function getSparrowAtlas(key:String, ?library:String, ?useTexture:Bool, ?lodLevel:LodLevel):FlxAtlasFrames
{
var image = image(key, library, false, useTexture, lodLevel);
var frames = FlxAtlasFrames.findFrame(image);
Expand All @@ -269,7 +268,7 @@ class Paths
return __checkLodFrames(getFrames(image, () -> return FlxAtlasFrames.fromSparrow(image, xml)));
}

inline static public function getSpriteSheetAtlas(key:String, ?library:String, ?useTexture:Bool, ?lodLevel:LodLevel):FlxAtlasFrames
static public function getSpriteSheetAtlas(key:String, ?library:String, ?useTexture:Bool, ?lodLevel:LodLevel):FlxAtlasFrames
{
var image = image(key, library, false, useTexture, lodLevel);
var frames = FlxAtlasFrames.findFrame(image);
Expand All @@ -280,7 +279,7 @@ class Paths
return __checkLodFrames(getFrames(image, () -> return FlxAtlasFrames.fromSpriteSheetPacker(image, txt)));
}

inline static public function getAsepriteAtlas(key:String, ?library:String, ?useTexture:Bool, ?lodLevel:LodLevel):FlxAtlasFrames
static public function getAsepriteAtlas(key:String, ?library:String, ?useTexture:Bool, ?lodLevel:LodLevel):FlxAtlasFrames
{
var image = image(key, library, false, useTexture, lodLevel);
var frames = FlxAtlasFrames.findFrame(image);
Expand All @@ -292,7 +291,7 @@ class Paths
}

@:noCompletion
inline public static function __checkLodFrames(frames:FlxAtlasFrames):FlxAtlasFrames {
public static function __checkLodFrames(frames:FlxAtlasFrames):FlxAtlasFrames {
var parent:LodGraphic = cast(frames.parent, LodGraphic);
if (parent.lodLevel == 0 || parent.parsedChildren)
return frames;
Expand Down Expand Up @@ -430,7 +429,7 @@ class Paths
#end
}

inline static public function getPackerType(key:String, ?library:String):PackerType {
static public function getPackerType(key:String, ?library:String):PackerType {
if (exists(file('images/$key.xml', library), TEXT)) return SPARROW;
else if (exists(file('images/$key.txt', library), TEXT)) return SHEETPACKER;
else if (exists(file('images/$key.json', library), TEXT)) return JSON;
Expand Down
12 changes: 8 additions & 4 deletions source/funkin/util/modding/ModdingUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ class ModdingUtil
value ??= "";

curModFolder = value;
curModData = value.length > 0 ? modsMap.get(value) : null;
curModData = value.length > 0 ? getModFolder(value) : null;

return value;
}

public static inline function getModFolder(mod:String):ModFolder {
return modsMap.get(mod);
}

public static var activeMods:Map<String, Bool> = [];
public static var globalMods:Array<ModFolder> = [];
Expand Down Expand Up @@ -152,9 +156,9 @@ class ModdingUtil
tag ??= path;

if (path.startsWith("mods/")) {
final _mod = ModdingUtil.modsMap.get(Paths.getFileMod(path)[0]);
if (_mod != null) if (_mod.apiVersion != API_VERSION)
scriptCode = updateScript(scriptCode, _mod.apiVersion);
var mod = getModFolder(Paths.getPathMod(path));
if (mod != null) if (mod.apiVersion != API_VERSION)
scriptCode = updateScript(scriptCode, mod.apiVersion);
}

final script:FunkScript = new FunkScript(scriptCode, tag);
Expand Down
10 changes: 6 additions & 4 deletions source/funkin/util/song/WeekSetup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ class WeekSetup

// Make sure theres no mods from innactive weeks
for (week in modWeeks) {
final mod = Paths.getFileMod(week)[0];
var mod = Paths.getPathMod(week);
if (!ModdingUtil.existsModFolder(mod) || !ModdingUtil.getModActive(mod))
modWeeks.remove(week);
}

//Vanilla weeks go first >:)
if (!hideVanilla) weeks = weeks.concat(vanillaWeeks);
weeks = weeks.concat(globalWeeks);
weeks = weeks.concat(modWeeks.map(week -> Paths.getFileMod(week)[1]));
weeks = weeks.concat(modWeeks.map(week -> Paths.getPathMod(week)));
weeks = CoolUtil.removeDuplicates(weeks);

weekList.clear();
Expand All @@ -99,8 +99,10 @@ class WeekSetup

final modMap:Map<String, String> = [];
for (i in modWeeks) {
final pathParts = Paths.getFileMod(i);
modMap.set(pathParts[1], pathParts[0]);
modMap.set(
Paths.getPathMod(i),
Paths.getPathFile(i)
);
}

for (i in weeks) {
Expand Down

0 comments on commit 7ddcb72

Please sign in to comment.