Skip to content

Commit

Permalink
Merge branch 'feat.more-keybinds' of https://github.com/zacharied/Ong…
Browse files Browse the repository at this point in the history
…ekiFumenEditor into batch_mode
  • Loading branch information
MikiraSora committed Oct 28, 2024
2 parents fad1143 + 8000550 commit ff6ee4d
Show file tree
Hide file tree
Showing 8 changed files with 372 additions and 325 deletions.
8 changes: 4 additions & 4 deletions OngekiFumenEditor/Base/OngekiObjects/Bell.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using OngekiFumenEditor.Base.Attributes;
using OngekiFumenEditor.Base.OngekiObjects.BulletPalleteEnums;
using System.Collections.Generic;
using System.Collections.Generic;
using static OngekiFumenEditor.Base.OngekiObjects.BulletPallete;

namespace OngekiFumenEditor.Base.OngekiObjects
namespace OngekiFumenEditor.Base.OngekiObjects
{
public class Bell : OngekiMovableObjectBase, IBulletPalleteReferencable
{
Expand Down Expand Up @@ -117,5 +117,5 @@ public override void Copy(OngekiObjectBase fromObj)

ReferenceBulletPallete = from.ReferenceBulletPallete;
}
}
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,17 @@ public abstract class BatchModeInputSubmode : BatchModeSubmode

public class BatchModeInputClipboard : BatchModeInputSubmode
{
private IReadOnlyCollection<OngekiTimelineObjectBase> ClipboardContents;
private IFumenEditorClipboard Clipboard;

public BatchModeInputClipboard()
{
ClipboardContents = IoC.Get<IFumenEditorClipboard>()
.CurrentCopiedObjects.OfType<OngekiTimelineObjectBase>()
.Select(obj => (OngekiTimelineObjectBase)obj.CopyNew()).ToList();
Clipboard = IoC.Get<IFumenEditorClipboard>();
}

public override string DisplayName => Resources.Clipboard;
public override IEnumerable<OngekiTimelineObjectBase> GenerateObject()
{
return ClipboardContents.Select(obj => (OngekiTimelineObjectBase)obj.CopyNew());
return Clipboard.CurrentCopiedObjects.Select(obj => (OngekiTimelineObjectBase)obj.CopyNew());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
using System.Collections.Generic;
using System.Numerics;
using OngekiFumenEditor.Modules.FumenVisualEditor.ViewModels;
using OngekiFumenEditor.Utils;
using static OngekiFumenEditor.Kernel.Graphics.ILineDrawing;

namespace OngekiFumenEditor.Modules.FumenVisualEditor.Graphics.Drawing.Editors
{
public class DrawSelectingRangeHelper
{
private Dictionary<SelectRegionType, (Vector4 lineColor, Vector4 rectColor)> RegionColors = new()
private record RangeColors(Vector4 LineColor, Vector4 RectColor)
{
[SelectRegionType.Select] = (new(1, 0, 1, 1), new(1, 1, 1, 0.15f)),
[SelectRegionType.SelectFiltered] = (new(1, 0, 1, 1), new(0.8f, 0.0f, 0.8f, 0.15f)),
[SelectRegionType.Delete] = (new(1, 0.1f, 0.1f, 1), new(1, 0.1f, 0.1f, 0.15f)),
[SelectRegionType.DeleteFiltered] = (new(1, 0.1f, 0.1f, 1), new(0.8f, 0.8f, 0, 0.15f))
};
public readonly Vector4 LineColor = LineColor;
public readonly Vector4 RectColor = RectColor;
}

private RangeColors SelectAll = new(new(1, 0, 1, 1), new(1, 1, 1, 0.15f));
private RangeColors SelectFiltered = new(new(1, 0, 1, 1), new(0.8f, 0.0f, 0.8f, 0.15f));
private RangeColors DeleteAll = new(new(1, 0.1f, 0.1f, 1), new(1, 0.1f, 0.1f, 0.15f));
private RangeColors DeleteFiltered = new(new(1, 0.1f, 0.1f, 1), new(0.8f, 0.8f, 0, 0.15f));

private ISimpleLineDrawing lineDrawing;
private IPolygonDrawing polygonDrawing;
Expand All @@ -36,39 +40,57 @@ public DrawSelectingRangeHelper()

public void Draw(IFumenEditorDrawingContext target)
{
if (target.Editor.SelectionVisibility != System.Windows.Visibility.Visible)
if (target.Editor.SelectionArea is not { } selectionArea || selectionArea.Rect is { Height: 0, Width: 0 } || !selectionArea.IsActive)
return;

var (lineColor, fillColor) = RegionColors[target.Editor.SelectRegionType];
RangeColors colors;
if (selectionArea.SelectionAreaKind == SelectionAreaKind.Select) {
if (selectionArea.FilterFunc is not null) {
colors = SelectFiltered;
}
else {
colors = SelectAll;
}
} else if (selectionArea.SelectionAreaKind == SelectionAreaKind.Delete) {
if (selectionArea.FilterFunc is not null) {
colors = DeleteFiltered;
}
else {
colors = DeleteAll;
}
}
else {
colors = SelectAll;
}

var topY = Math.Max(target.Editor.SelectionCurrentCursorPosition.Y, target.Editor.SelectionStartPosition.Y);
var buttomY = Math.Min(target.Editor.SelectionCurrentCursorPosition.Y, target.Editor.SelectionStartPosition.Y);
var rightX = Math.Max(target.Editor.SelectionCurrentCursorPosition.X, target.Editor.SelectionStartPosition.X);
var leftX = Math.Min(target.Editor.SelectionCurrentCursorPosition.X, target.Editor.SelectionStartPosition.X);
var topY = (float)selectionArea.Rect.Top;
var buttomY = (float)selectionArea.Rect.Bottom;
var rightX = (float)selectionArea.Rect.Right;
var leftX = (float)selectionArea.Rect.Left;
var centerX = (leftX + rightX) / 2;
var centerY = (topY + buttomY) / 2;

polygonDrawing.Begin(target, PrimitiveType.TriangleStrip);
{
polygonDrawing.PostPoint(new(leftX, buttomY), fillColor);
polygonDrawing.PostPoint(new(centerX, centerY), fillColor);
polygonDrawing.PostPoint(new(leftX, topY), fillColor);
polygonDrawing.PostPoint(new(centerX, centerY), fillColor);
polygonDrawing.PostPoint(new(rightX, topY), fillColor);
polygonDrawing.PostPoint(new(centerX, centerY), fillColor);
polygonDrawing.PostPoint(new(rightX, buttomY), fillColor);
polygonDrawing.PostPoint(new(centerX, centerY), fillColor);
polygonDrawing.PostPoint(new(leftX, buttomY), fillColor);
polygonDrawing.PostPoint(new(leftX, buttomY), colors.RectColor);
polygonDrawing.PostPoint(new(centerX, centerY), colors.RectColor);
polygonDrawing.PostPoint(new(leftX, topY), colors.RectColor);
polygonDrawing.PostPoint(new(centerX, centerY), colors.RectColor);
polygonDrawing.PostPoint(new(rightX, topY), colors.RectColor);
polygonDrawing.PostPoint(new(centerX, centerY), colors.RectColor);
polygonDrawing.PostPoint(new(rightX, buttomY), colors.RectColor);
polygonDrawing.PostPoint(new(centerX, centerY), colors.RectColor);
polygonDrawing.PostPoint(new(leftX, buttomY), colors.RectColor);
}
polygonDrawing.End();

lineDrawing.Begin(target, 1);
{
lineDrawing.PostPoint(new(leftX, buttomY), lineColor, dash);
lineDrawing.PostPoint(new(leftX, topY), lineColor, dash);
lineDrawing.PostPoint(new(rightX, topY), lineColor, dash);
lineDrawing.PostPoint(new(rightX, buttomY), lineColor, dash);
lineDrawing.PostPoint(new(leftX, buttomY), lineColor, dash);
lineDrawing.PostPoint(new(leftX, buttomY), colors.LineColor, dash);
lineDrawing.PostPoint(new(leftX, topY), colors.LineColor, dash);
lineDrawing.PostPoint(new(rightX, topY), colors.LineColor, dash);
lineDrawing.PostPoint(new(rightX, buttomY), colors.LineColor, dash);
lineDrawing.PostPoint(new(leftX, buttomY), colors.LineColor, dash);
}
lineDrawing.End();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ void SetTexture(BulletDamageType k1, BulletType k2, string rPath, string key, Ve

public override void DrawVisibleObject_DesignMode(IFumenEditorDrawingContext target, Bullet obj, Vector2 pos, float rotate)
{
if (obj.ReferenceBulletPallete is null) {
Log.LogWarn($"Bullet {obj.Id} has null reference bullet pallete");
return;
}
var damageType = obj.BulletDamageTypeValue;
var bulletType = obj.ReferenceBulletPallete.TypeValue;

Expand Down
Loading

0 comments on commit ff6ee4d

Please sign in to comment.