Skip to content

Mouse Controls #743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions source/funkin/backend/MusicBeatState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import funkin.backend.system.GraphicCacheSprite;
import funkin.backend.system.framerate.Framerate;
import funkin.backend.system.interfaces.IBeatReceiver;
import funkin.backend.system.interfaces.IBeatCancellableReceiver;
import funkin.menus.MainMenuState;
import funkin.options.PlayerSettings;

/**
Expand Down Expand Up @@ -166,6 +167,11 @@ class MusicBeatState extends FlxState implements IBeatCancellableReceiver
FlxG.resetState();
}

if (FlxG.keys.justPressed.F1 && FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.SHIFT) {
Logs.trace("Returning to Main Menu...", INFO, YELLOW);
FlxG.switchState(new MainMenuState());
}

if (subState != null)
subState.tryUpdate(elapsed);
}
Expand Down
36 changes: 24 additions & 12 deletions source/funkin/menus/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class FreeplayState extends MusicBeatState
#end


if (controls.BACK)
if (controls.BACK || FlxG.mouse.justPressedRight)
{
CoolUtil.playMenuSFX(CANCEL, 0.7);
FlxG.switchState(new MainMenuState());
Expand All @@ -306,6 +306,19 @@ class FreeplayState extends MusicBeatState
convertChart();
#end

if(FlxG.mouse.justPressed){
if(#if PRELOAD_ALL !dontPlaySongThisFrame && #end FlxG.mouse.overlaps(grpSongs.members[curSelected])){
select();
}else if(canSelect){
for(index => sprite in grpSongs.members){
if(curSelected != index && FlxG.mouse.overlaps(sprite)){
changeSelection(index-curSelected);
updateOptionsAlpha();
break;
}
}
}
}
if (controls.ACCEPT #if PRELOAD_ALL && !dontPlaySongThisFrame #end)
select();
}
Expand Down Expand Up @@ -480,20 +493,19 @@ class FreeplayState extends MusicBeatState

final idleAlpha = #if PRELOAD_ALL songInstPlaying ? event.idlePlayingAlpha : #end event.idleAlpha;
final selectedAlpha = #if PRELOAD_ALL songInstPlaying ? event.selectedPlayingAlpha : #end event.selectedAlpha;

for (i in 0...iconArray.length)
iconArray[i].alpha = lerp(iconArray[i].alpha, idleAlpha, event.lerp);

iconArray[curSelected].alpha = selectedAlpha;

for (i=>item in grpSongs.members)
{

for (i=>item in grpSongs.members) {
item.targetY = i - curSelected;
final icon = iconArray[i];

item.alpha = lerp(item.alpha, idleAlpha, event.lerp);

if (item.targetY == 0)
item.alpha = selectedAlpha;
if (item.targetY == 0){
item.alpha = icon.alpha = selectedAlpha;
}else{
item.alpha = lerp(item.alpha, idleAlpha, event.lerp);
icon.alpha = lerp(icon.alpha, idleAlpha, event.lerp);
}
icon.visible = item.visible = (item.targetY > -20 && item.targetY < 20);
}
}

Expand Down
27 changes: 23 additions & 4 deletions source/funkin/menus/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,25 @@ class MainMenuState extends MusicBeatState
if (controls.BACK)
FlxG.switchState(new TitleState());

if (FlxG.mouse.justPressed){
for(index => sprite in menuItems.members){
if(FlxG.mouse.overlaps(sprite)){
if(curSelected != index)
changeItem(index-curSelected);
else
selectItem();
break;
}
}
#if MOD_SUPPORT
if(FlxG.mouse.overlaps(versionText)){
openSubState(new ModSwitchMenu());
persistentUpdate = false;
persistentDraw = true;

}
#end
}
#if MOD_SUPPORT
if (controls.SWITCHMOD) {
openSubState(new ModSwitchMenu());
Expand All @@ -157,10 +176,10 @@ class MainMenuState extends MusicBeatState
super.update(elapsed);

if (forceCenterX)
menuItems.forEach(function(spr:FlxSprite)
{
spr.screenCenter(X);
});
menuItems.forEach(function(spr:FlxSprite)
{
spr.screenCenter(X);
});
}

public override function switchTo(nextState:FlxState):Bool {
Expand Down
15 changes: 14 additions & 1 deletion source/funkin/menus/StoryMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,25 @@ class StoryMenuState extends MusicBeatState {
if (leftArrow != null && leftArrow.exists) leftArrow.animation.play(controls.LEFT ? 'press' : 'idle');
if (rightArrow != null && rightArrow.exists) rightArrow.animation.play(controls.RIGHT ? 'press' : 'idle');

if (controls.BACK) {
if (controls.BACK || FlxG.mouse.justPressedRight) {
goBack();
}

changeDifficulty((controls.LEFT_P ? -1 : 0) + (controls.RIGHT_P ? 1 : 0));
changeWeek((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel);
if(FlxG.mouse.justPressed){
if(leftArrow.exists && FlxG.mouse.overlaps(leftArrow)){
leftArrow.animation.play('press');
changeDifficulty(-1);
}else if(rightArrow.exists && FlxG.mouse.overlaps(rightArrow)){
rightArrow.animation.play('press');
changeDifficulty(1);
}else if(FlxG.mouse.overlaps(weekSprites.members[curWeek])){
selectWeek();
}else if(weekSprites.members[curWeek+1] != null && FlxG.mouse.overlaps(weekSprites.members[curWeek+1])){
changeWeek(1);
}
}

if (controls.ACCEPT)
selectWeek();
Expand Down