Skip to content

Weapon/Animated part texture sizes + Animated part remove button #443

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 1 commit 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
7 changes: 7 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\MIR.sln",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/weapon-editor-qol/v17/.wsuo
Binary file not shown.
31 changes: 31 additions & 0 deletions .vs/weapon-editor-qol/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\Oliwi\\source\\repos\\weapon-editor-qol\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:128:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:129:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
},
{
"$type": "Bookmark",
"Name": "ST:130:0:{75188d03-9892-4ae2-abf1-207126247ce5}"
}
]
}
]
}
]
}
11 changes: 6 additions & 5 deletions src/MadnessInteractiveReloaded/Prefabs/Prefabs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using OpenTK.Graphics.OpenGL;
using OpenTK.Graphics.OpenGL;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -529,8 +529,8 @@ public static WeaponComponent CreateWeapon(Scene scene, Vector2 position, Weapon
});
var baseTransformRef = new ComponentRef<TransformComponent>(@base);

var baseSpriteEntity = CreateSprite(scene, instructions.BaseTexture, default, parent: baseTransformRef,
renderOrder: RenderOrders.Default);
var baseSpriteEntity = CreateSprite(scene, instructions.BaseTexture, default, RenderOrders.Default,
baseTransformRef, instructions.TextureSize, instructions.TextureSize);

Entity[]? animatedParts = null;
if (instructions.AnimatedParts?.Count > 0)
Expand All @@ -541,7 +541,7 @@ public static WeaponComponent CreateWeapon(Scene scene, Vector2 position, Weapon
AnimatedWeaponPart animatedPart = instructions.AnimatedParts[i];
var startPos = animatedPart.TranslationCurve?.Evaluate(0) ?? default;
var ent = CreateSprite(scene, animatedPart.Texture, startPos, parent: baseTransformRef,
xScaleMultiplier: animatedPart.Scale.X, yScaleMultiplier: animatedPart.Scale.Y);
xScaleMultiplier: animatedPart.TextureSize, yScaleMultiplier: animatedPart.TextureSize);
scene.AttachComponent(ent, new WeaponPartAnimationComponent
{
IsPlaying = false,
Expand Down Expand Up @@ -571,7 +571,8 @@ public static WeaponComponent CreateWeapon(Scene scene, Vector2 position, Weapon
HoldForGrip = instructions.HoldForGrip,
HoldStockHandPose = instructions.HoldStockHandPose,
RemainingRounds = instructions.WeaponData.RoundsPerMagazine,
Texture = instructions.BaseTexture
Texture = instructions.BaseTexture,
TextureSize = instructions.TextureSize
});
scene.AttachComponent(@base, new PhysicsBodyComponent
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -283,6 +283,11 @@ private void DrawBasicInfo(WeaponEditorComponent editor, WeaponInstructions weap

Ui.Spacer(s);

Ui.Label("Texture Size");
Ui.Layout.FitWidth().Height(h);
Ui.FloatInputBox(ref weapon.TextureSize, (0f, 360f));
Ui.Spacer(s);

Ui.Label("Codename", HorizontalTextAlign.Left);
Ui.Layout.FitWidth().Height(h);
Ui.StringInputBox(ref weapon.Id, new TextBoxOptions(placeholder: "Codename", maxLength: 50));
Expand Down Expand Up @@ -549,7 +554,7 @@ private void DrawAnimatedPartSettings(WeaponEditorComponent editor, WeaponInstru
{
var item = weapon.AnimatedParts[i];

Ui.Layout.Height(210).FitWidth().VerticalLayout();
Ui.Layout.Height(280).FitWidth().VerticalLayout();
if (editor.CurrentSelectedAnimatedPart == item)
Ui.Theme.OutlineWidth(2).OutlineColour(Colors.White).Once();
Ui.StartGroup(true, i);
Expand All @@ -567,6 +572,10 @@ private void DrawAnimatedPartSettings(WeaponEditorComponent editor, WeaponInstru
if (Ui.FloatInputBox(ref item.Duration, null, null))
editor.CurrentSelectedAnimatedPart = item;

layout.Height(WeaponEditorComponent.ControlHeight).FitWidth().CenterHorizontal();
if (Ui.FloatInputBox(ref item.TextureSize, placeholder: "1"))
editor.CurrentSelectedAnimatedPart = item;

layout.Height(WeaponEditorComponent.ControlHeight).FitWidth().CenterHorizontal();
if (Ui.ClickButton("Edit keyframes"))
editor.CurrentSelectedAnimatedPart = item;
Expand Down Expand Up @@ -666,9 +675,9 @@ private void DrawWeapon(WeaponEditorComponent editor, WeaponInstructions weapon)

//draw base texture
Draw.Texture = weapon.BaseTexture.Value;
var hS = Draw.Texture.Size / 2;
var hS = (Draw.Texture.Size * weapon.TextureSize) / 2;
var offset = new Vector2(-hS.X, hS.Y);
Draw.Quad(offset, Draw.Texture.Size);
Draw.Quad(offset, Draw.Texture.Size * weapon.TextureSize);

//draw animated parts
if (weapon.AnimatedParts != null)
Expand All @@ -684,15 +693,15 @@ private void DrawWeapon(WeaponEditorComponent editor, WeaponInstructions weapon)

Draw.Texture = item.Texture.Value;

var pos = new Vector2(-Draw.Texture.Size.X, Draw.Texture.Size.Y) * 0.5f;
var pos = new Vector2(-(Draw.Texture.Size.X * item.TextureSize), Draw.Texture.Size.Y * item.TextureSize) * 0.5f;

if (item.TranslationCurve != null)
{
var o = item.TranslationCurve.Evaluate(time);
pos += o;
}

Draw.Quad(pos, Draw.Texture.Size * item.Scale);
Draw.Quad(pos, Draw.Texture.Size * item.TextureSize);
}

//draw hold points
Expand Down
3 changes: 2 additions & 1 deletion src/MadnessInteractiveReloaded/Weapons/AnimatedWeaponPart.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using Walgelijk;
using Walgelijk.AssetManager;

Expand All @@ -14,6 +14,7 @@ public class AnimatedWeaponPart
public float Duration = 0.15f;
public Vector2 Scale = new(1, 1);
public AssetRef<Texture> Texture;
public float TextureSize = 1;
public Vec2Curve? TranslationCurve;
public FloatCurve? AngleCurve;
public FloatCurve? VisibilityCurve;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Numerics;
using Walgelijk;
Expand Down Expand Up @@ -74,6 +74,8 @@ public class WeaponComponent : Component
/// </summary>
public AssetRef<Texture>? Texture { get; init; }

public float TextureSize = 1;

/// <summary>
/// Is this weapon in the world hung up on a wall all nice and pretty?
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion src/MadnessInteractiveReloaded/Weapons/WeaponInstructions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Numerics;
using Walgelijk;
using Walgelijk.AssetManager;
Expand Down Expand Up @@ -26,6 +26,8 @@ public class WeaponInstructions
/// </summary>
public AssetRef<Texture> BaseTexture;

public float TextureSize = 1;

/// <summary>
/// If the secondary hand holds the grip like a vertical foregrip or not.
/// </summary>
Expand Down