Skip to content

Commit

Permalink
Mod repo now has categories
Browse files Browse the repository at this point in the history
Finally fix camera snapping bug
  • Loading branch information
superpowers04 committed Aug 15, 2024
1 parent 275c2c6 commit ae5242b
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 16 deletions.
7 changes: 3 additions & 4 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class PlayState extends ScriptMusicBeatState
public var moveCamera(default,set):Bool = true;
public function set_moveCamera(v):Bool{
if(v){
FlxG.camera.follow(camFollow, LOCKON, 0.04 * (30 / (cast (Lib.current.getChildAt(0), Main)).getFPS()));
FlxG.camera.follow(camFollow, LOCKON, 0.25);
}else{
FlxG.camera.follow(null);
}
Expand Down Expand Up @@ -2164,10 +2164,9 @@ class PlayState extends ScriptMusicBeatState
}
vocals.update(elapsed);

var e = getDefaultCamPos();
if(SESave.data.animDebug && updateOverlay){
var vt = 0;
if(vocals != null) vt = Std.int(vocals.time);
var e = getDefaultCamPos();
var vt = (vocals == null) ? 0 : Std.int(vocals.time);
Overlay.debugVar += '\nResync count:${resyncCount}'
+'\nCond/Music/Vocals time:${Std.int(Conductor.songPosition)}/${Std.int(FlxG.sound.music.time)}/${vt}'
+'\nHealth:${health}'
Expand Down
4 changes: 2 additions & 2 deletions source/se/states/DownloadState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class DownloadState extends MusicBeatState
inError=true;
progress = 0;
fileSizeText.text = "";
loadingText.text = 'Error! Press any key to exit\n\n${e}';
trace('Error! ${e}');
loadingText.text = 'Error! Press any key to exit\n\n${e ?? "Unknown error??"}';
trace('Error! ${e} ${Type.typeof(e)}');
canClose = true;
}
// public dynamic function onIOError(e:IOErrorEvent){
Expand Down
109 changes: 100 additions & 9 deletions source/se/states/ModRepoState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,66 @@ import lime.net.HTTPRequest;
import openfl.events.Event;
import openfl.events.ProgressEvent;
import openfl.events.IOErrorEvent;
import flixel.tweens.FlxTween;
import flixel.tweens.FlxEase;
using StringTools;

typedef RepoAsset = {
var name:String;
var id:String;
var index:Int;
var description:String;
var blurb:String;
var type:String;
var url:String;
}
@:publicFields class ModRepoState extends SearchMenuState {
var url:String = "https://github.com/superpowers04/Super-Engine-Custom-Content/raw/meow/RepoListing.json";
var url:String = se.SESave.data.repoURL == "" ? "https://github.com/superpowers04/Super-Engine-Custom-Content/raw/meow/RepoListing.json" : se.SESave.data.repoURL;
var repoList:Array<RepoAsset> = [];
final categories:Array<String> = ['All','Songs','Characters','Packs','Ports'];
final categoryIDs:Array<Array<String>> = [[''],['song','chart','music'],['character','char'],['pack','mod'],['port']];
var currentCat:Int = 0;
var loadingProgress:Float = 0;
var shouldReload = true;
var diffText:FlxText;
var assetNameText:FlxText;
var twee:FlxTween;
override function new() {
if(se.SESave.data.repoURL != ""){
url = se.SESave.data.repoURL;
}
super();
}
override function updateInfoText(str:String = ""){
if(infotext != null){
infotext.text = str;
infotext.wordWrap = true;
infotext.scrollFactor.set();
infotext.y = infoTextBorder.y + 100;
infotext.x = infoTextBorder.x + 10;
}
}
inline function updateName(?name = "funninameherelmaomlmaonjosn"){
if(name != "funninameherelmaomlmaonjosn"){
assetNameText.text = name;
assetNameText.x = (infoTextBorder.x + (infoTextBorder.width * 0.5) - (assetNameText.width * 0.5));
}

}
override function create(){
toggleables['search']=true;
super.create();
bg.color = 0x400060;
diffText = new FlxText(FlxG.width * 0.7, 5, 0, '< ' + categories[0] + ' >', 32);
diffText.font = CoolUtil.font;
diffText.borderSize = 2;
add(diffText);
infoTextBorder.makeGraphic(500,720,FlxColor.BLACK);
infoTextBorder.setPosition(1280 - infoTextBorder.width,140);
infotext.fieldWidth = infoTextBorder.width - 20;

assetNameText = new FlxText(5, infoTextBorder.y + 50, 0, "yes", 20);
assetNameText.wordWrap = false;
assetNameText.scrollFactor.set();
assetNameText.setFormat(CoolUtil.font, 24, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
overLay.add(assetNameText);
loadScripts();
new HTTPRequest<Bytes>(url).load(url).onComplete(onData).onProgress(updateProgress).onError(onError);
showBeatBouncing=false;
Expand Down Expand Up @@ -74,15 +111,32 @@ typedef RepoAsset = {
override function update(e:Float){
if(shouldReload){
shouldReload = false;
reloadList();
changeCat(0);
// reloadList();
}
super.update(e);

}
override function extraKeys(){
if(controls.LEFT_P){changeCat(-1);}
if(controls.RIGHT_P){changeCat(1);}
}
public function changeCat(count:Int=1){
currentCat+=count;
if(currentCat >= categories.length) currentCat = 0;
if(currentCat < 0) currentCat = categories.length -1;
diffText.text = '< ${categories[currentCat]} >';
diffText.screenCenter(X);
if(twee != null)twee.cancel();
diffText.scale.set(1.2,1.2);
twee = FlxTween.tween(diffText.scale,{x:1,y:1},(30 / Conductor.bpm));
reloadList(true);
}
override function reloadList(?reload = false,?search=""){
curSelected = 0;
CoolUtil.clearFlxGroup(grpSongs);
songs = [];

if(repoList[0] == null){
addToList('Downloading repo',0);
var meow = grpSongs.members[grpSongs.members.length-1];
Expand All @@ -95,19 +149,56 @@ typedef RepoAsset = {
var i:Int = 0;
var query = new EReg((~/[-_ ]/g).replace(search.toLowerCase().replace('\\','\\\\'),'[-_ ]'),'i'); // Regex that allows _ and - for songs to still pop up if user puts space, game ignores - and _ when showing
for (asset in repoList){
if(!query.match(asset.name ?? "") && !query.match(asset.id ?? "")) continue;
if(currentCat != 0){
if(asset.type == null) continue;
var contains = false;
for(str in categoryIDs[currentCat]){
if(asset.type.contains(str)){
contains = true;
break;
}
}
if(!contains) continue;
}
addToList(asset.name ?? asset.id,i);
var meow = grpSongs.members[i];
meow.menuValue = asset;
meow.add(new FlxText(10,meow.members[0].height,0,asset.description ?? "No Description Provided",18));
if(asset.blurb != null && asset.blurb != ""){

meow.add(new FlxText(15,60,0,asset.blurb,18));
}
i++;
}
if(grpSongs.members.length == 0){
addToList('No mods found',0);
}
changeSelection();
}
override function select(i:Int = 0){
if(grpSongs.members[i] == null || grpSongs.members[i].menuValue == null){
showTempmessage('No asset associated with that menu item');
showTempmessage('No asset associated with that menu item',0xFFFF0000);
return;
}
FlxG.switchState(new se.states.DownloadState(grpSongs.members[i].menuValue.url,'./requestedFile',ImportMod.ImportModFromFolder.fromZip.bind(null,_),FlxG.switchState.bind(new ModRepoState())));
}
override function changeSelection(change:Int = 0){
var _oldSel = curSelected;
super.changeSelection(change);
var alpha = grpSongs.members[curSelected];
if(alpha.menuValue == null) {
updateInfoText("");
updateName("");
infoTextBorder.alpha=0;
return;
}
FlxG.switchState(new se.states.DownloadState(grpSongs.members[i].menuValue.url,'./requestedFile',
ImportMod.ImportModFromFolder.fromZip.bind(null,_),FlxG.switchState.bind(new ModRepoState())));
infoTextBorder.alpha=1;
var value = alpha.menuValue;

var text = (value.description ?? "No description provided")
+'\n\nID: ${value.id}\nType: ${value.type}\n';
updateInfoText(text);
updateName(value.name ?? value.id);

}
}
2 changes: 1 addition & 1 deletion version.downloadMe
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
24.08.15.0235;
24.08.15.0333;
* Better Psych character support(Still kinda experimental but should be more stable)
* Fix some small errors
* Fix characters not loading due to using ID instead of folderName
Expand Down

0 comments on commit ae5242b

Please sign in to comment.