Skip to content
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

Allows for the mouse to wrap and removes the old algorithm where it locked the mouse and didn't do much #1

Merged
merged 1 commit into from
Sep 24, 2019
Merged
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
40 changes: 26 additions & 14 deletions BrawlLib/System/Windows/Controls/Model Panel/ModelPanel.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using BrawlLib.Modeling;
using BrawlLib.OpenGL;
using BrawlLib.SSBB.ResourceNodes;
using OpenTK.Graphics.OpenGL;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;

using BrawlLib.Modeling;
using BrawlLib.OpenGL;
using BrawlLib.SSBB.ResourceNodes;

using OpenTK.Graphics.OpenGL;

namespace System.Windows.Forms
{
public delegate void GLRenderEventHandler(ModelPanelViewport sender);
Expand Down Expand Up @@ -65,7 +67,7 @@ public void SetCamWithBox(Vector3 min, Vector3 max)

//Get the position of the midpoint of the bounding box plane closer to the camera
Vector3 frontMidPt = new Vector3((max._x + min._x) / 2.0f, (max._y + min._y) / 2.0f, max._z);
float tan = (float) Math.Tan(cam.VerticalFieldOfView / 2.0f * Maths._deg2radf), distX = 0, distY = 0;
float tan = (float)Math.Tan(cam.VerticalFieldOfView / 2.0f * Maths._deg2radf), distX = 0, distY = 0;

//The tangent value would only be 0 if the FOV was 0,
//meaning nothing would be visible anyway
Expand Down Expand Up @@ -359,6 +361,11 @@ protected override void OnMouseDown(MouseEventArgs e)
break;
}

if (e.Button != MouseButtons.Left)
{
CurrentViewport.HandleOtherMouseDown(e);
}

base.OnMouseDown(e);
}

Expand Down Expand Up @@ -404,6 +411,11 @@ protected override void OnMouseUp(MouseEventArgs e)
return;
}

if (e.Button != MouseButtons.Left)
{
CurrentViewport.HandleOtherMouseUp(e);
}

Invalidate();
base.OnMouseUp(e);
}
Expand Down Expand Up @@ -439,14 +451,14 @@ protected override void OnMouseMove(MouseEventArgs e)
if (_draggingViewports)
{
float
yP = (float) y / Height,
xP = (float) x / Width;
yP = (float)y / Height,
xP = (float)x / Width;

foreach (KeyValuePair<ModelPanelViewport, DragFlags> t in _dragging)
{
//TODO: don't allow the user to drag over another viewport
//bool cont = false;
bool isX = ((int) t.Value & 1) == 0;
bool isX = ((int)t.Value & 1) == 0;
float p = isX ? xP : yP;
//foreach (ModelPanelViewport v in _viewports)
//{
Expand All @@ -467,7 +479,7 @@ protected override void OnMouseMove(MouseEventArgs e)
//}
//if (cont)
// continue;
t.Key.SetPercentageIndex((int) t.Value, p);
t.Key.SetPercentageIndex((int)t.Value, p);
}

Invalidate();
Expand Down Expand Up @@ -556,7 +568,7 @@ protected override void OnMouseMove(MouseEventArgs e)

protected override bool IsInputKey(Keys keyData)
{
keyData &= (Keys) 0xFFFF;
keyData &= (Keys)0xFFFF;
switch (keyData)
{
case Keys.Up:
Expand Down Expand Up @@ -589,7 +601,7 @@ protected override bool ProcessKeyMessage(ref Message m)
}
else if (Enabled && m.Msg == 0x100)
{
if (CurrentViewport.ProcessKeys((Keys) m.WParam, ModifierKeys))
if (CurrentViewport.ProcessKeys((Keys)m.WParam, ModifierKeys))
{
return true;
}
Expand All @@ -604,7 +616,7 @@ protected override bool ProcessKeyMessage(ref Message m)

internal override unsafe void OnInit(TKContext ctx)
{
Vector3 v = (Vector3) BackColor;
Vector3 v = (Vector3)BackColor;
GL.ClearColor(v._x, v._y, v._z, 0.0f);
GL.ClearDepth(1.0);

Expand Down Expand Up @@ -1039,7 +1051,7 @@ private static void GetModelsRecursive(ResourceNode node, List<IModel> models)
break;
case ResourceType.MDL0:
case ResourceType.BMD:
models.Add((IModel) node);
models.Add((IModel)node);
break;
}
}
Expand Down
Loading