-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cc606f
commit 3467cc6
Showing
13 changed files
with
700 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...umenEditor/Modules/FumenVisualEditor/Graphics/Drawing/Editors/DrawPlayerLocationHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Numerics; | ||
using Caliburn.Micro; | ||
using OngekiFumenEditor.Base; | ||
using OngekiFumenEditor.Base.EditorObjects; | ||
using OngekiFumenEditor.Kernel.Graphics; | ||
using OngekiFumenEditor.Kernel.Graphics.Base; | ||
using OngekiFumenEditor.Utils; | ||
|
||
namespace OngekiFumenEditor.Modules.FumenVisualEditor.Graphics.Drawing.Editors; | ||
|
||
public class DrawPlayerLocationHelper | ||
{ | ||
private readonly (Vector2 size, Vector2 position, float rotation)[] arr = { default }; | ||
private readonly Texture texture; | ||
private readonly ITextureDrawing textureDrawing; | ||
private bool enableShowPlayerLocation; | ||
|
||
public DrawPlayerLocationHelper() | ||
{ | ||
textureDrawing = IoC.Get<ITextureDrawing>(); | ||
arr[0].size = new Vector2(48, 48); | ||
arr[0].rotation = 0f; | ||
|
||
texture = ResourceUtils.OpenReadTextureFromResource(@"Modules\FumenVisualEditor\Views\OngekiObjects\playerLoc.png"); | ||
|
||
UpdateProps(); | ||
Properties.EditorGlobalSetting.Default.PropertyChanged += Default_PropertyChanged; | ||
} | ||
|
||
private void UpdateProps() | ||
{ | ||
enableShowPlayerLocation = Properties.EditorGlobalSetting.Default.EnableShowPlayerLocation; | ||
} | ||
|
||
private void Default_PropertyChanged(object sender, PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(Properties.EditorGlobalSetting.EnableShowPlayerLocation): | ||
UpdateProps(); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
public void Draw(IFumenEditorDrawingContext target) | ||
{ | ||
if (target.Editor.IsDesignMode) | ||
return; | ||
if (!enableShowPlayerLocation) | ||
return; | ||
|
||
var tGrid = TGridCalculator.ConvertAudioTimeToTGrid(target.CurrentPlayTime, target.Editor); | ||
var apfLane = target.Editor.Fumen.Lanes.GetVisibleStartObjects(tGrid, tGrid).OfType<AutoplayFaderLaneStart>() | ||
.LastOrDefault(); | ||
var xGrid = apfLane?.CalulateXGrid(tGrid) ?? XGrid.Zero; | ||
|
||
var x = XGridCalculator.ConvertXGridToX(xGrid, target.Editor); | ||
var y = target.ConvertToY(tGrid); | ||
|
||
arr[0].position = new Vector2((float)x, (float)y); | ||
|
||
textureDrawing.Draw(target, texture, arr); | ||
} | ||
} |
Oops, something went wrong.